123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- #ifndef APITEST_CXXTEST_H
- #define APITEST_CXXTEST_H
- #include <typeinfo>
- #include <iostream>
- #include <cxxtest/TestSuite.h>
- using namespace std;
- using namespace CxxTest;
- struct TableEntry
- {
- int a;
- std::string b;
- double c;
- };
- TableEntry MyTable[] = {
- {4, "hugo", 3.3},
- {5, "emma", 4.4},
- };
- #define N_TABLE_ITEMS (sizeof(MyTable)/sizeof(TableEntry))
- class ApiTest_CxxTest : public CxxTest::TestSuite
- {
- public:
- void testAssertEquals()
- {
- int a=2;
- int b=4;
- TS_ASSERT_DIFFERS(a,b);
- }
- void XtestStringAssert()
- {
- string a="hallo";
- string b="otto";
- string c="otto";
- TS_ASSERT_EQUALS(a,b);
- TS_ASSERT_EQUALS(b,c);
- }
-
- void testStringLiteralAssert()
- {
- char a[]="alal";
- char b[]="gugu";
- string A="alal";
- string B="gugu";
- TS_ASSERT_EQUALS(a, a);
- TS_ASSERT_EQUALS(b, B);
- }
-
- void testTypeInfo()
- {
- string a="otto";
- string a_quoted = string("\"") + a + "\"";
- string b="hallo";
- cout << "TypeInfo=" << typeid(a).name() << "\n";
- cout << "TypeInfo=" << typeid(CxxTest::traits(a)).name() << "\n";
- cout << "TypeInfo=" << typeid(CxxTest::traits(b)).name() << "\n";
- cout << "TS_AS_STRING(x) = " << TS_AS_STRING(a) << "\n";
- string otto =TS_AS_STRING(a);
- TS_ASSERT_EQUALS(a_quoted, otto);
- }
-
- void testCppTable()
- {
- TS_ASSERT_EQUALS(MyTable[0].a, 4);
- TS_ASSERT_EQUALS(MyTable[1].a, 5);
- TS_ASSERT_EQUALS(N_TABLE_ITEMS, 2);
- }
-
- };
- #endif // APITEST_CXXTEST_H
|