Classes | |
| class | GTLTest::Case |
| class | GTLTest::Result |
| class | GTLTest::Suite |
Defines | |
| #define | GTLTEST_CHECK(a) GTLTEST_CHECK_MESSAGE( (a), #a); |
| #define | GTLTEST_CHECK_EQUAL(a, b) GTLTEST_CHECK_MESSAGE( (a) == (b), (#a) << " == " << (#b) << " " << (a) << " == " << (b) ); |
| #define | GTLTEST_CHECK_NOT_EQUAL(a, b) GTLTEST_CHECK( (a) != (b) ); |
| #define | GTLTEST_CHECK_NEAR_EQUAL(a, b) GTLTEST_CHECK_MESSAGE( fabs(a - b) < 10e-6, (#a) << " == " << (#b) << " " << (a) << " == " << (b) ); |
| #define | GTLTEST_CHECK_MESSAGE(a, msg) |
| #define | GTLTEST_MAIN_BEGIN(testname) |
| #define | GTLTEST_MAIN_ADD_CASE(case) test.addCase(new case()); |
| #define | GTLTEST_MAIN_END() |
For internal use only.
This library is internal to OpenGTL. It shouldn't be installed, and shouldn't be used outside OpenGTL.
Exemple of use:
#include "GTLTest/Test.h" class TestAddition : public GTLTest::Case { public: TestAddition() : GTLTest::Case("Addition") {} virtual void runTest() { GTLTEST_CHECK_EQUAL( 2+2, 4); } }; GTLTEST_MAIN_BEGIN(TestGTLTest) GTLTEST_MAIN_ADD_CASE(TestAddition) GTLTEST_MAIN_END()
| #define GTLTEST_CHECK | ( | a | ) | GTLTEST_CHECK_MESSAGE( (a), #a); |
Check that a is true and display a message containing the value
| #define GTLTEST_CHECK_EQUAL | ( | a, | |||
| b | ) | GTLTEST_CHECK_MESSAGE( (a) == (b), (#a) << " == " << (#b) << " " << (a) << " == " << (b) ); |
This macro will test that a and b are strictly equal, and display a message containing the values in case of failure.
| #define GTLTEST_CHECK_MESSAGE | ( | a, | |||
| msg | ) |
Value:
{ \
std::stringstream ss; \
std::string str; \
ss << __FILE__ << " at " << __LINE__ << ": " << msg; \
check( (a), ss.str()); \
}
| #define GTLTEST_CHECK_NEAR_EQUAL | ( | a, | |||
| b | ) | GTLTEST_CHECK_MESSAGE( fabs(a - b) < 10e-6, (#a) << " == " << (#b) << " " << (a) << " == " << (b) ); |
This macro will test that a and b are near equal, and display a message containing the values in case of failure.
| #define GTLTEST_CHECK_NOT_EQUAL | ( | a, | |||
| b | ) | GTLTEST_CHECK( (a) != (b) ); |
This macro will test that a and b are not equal, and display a message containing the values in case of failure.
| #define GTLTEST_MAIN_ADD_CASE | ( | case | ) | test.addCase(new case()); |
Add a test Case to the main test Suite .
| testname | name of the test |
| #define GTLTEST_MAIN_BEGIN | ( | testname | ) |
Value:
int main(int argc, char** argv) \ { \ GTLTest::Suite test(#testname); \
| testname | name of the test |
| #define GTLTEST_MAIN_END | ( | ) |
Value:
test.run(0); \
test.result()->dump(); \
return test.result()->countFailed(); \
}
| testname | name of the test |
1.5.1