GTLTest Library


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()

Detailed Description

For internal use only.

Version:
0.9.7
Author:
Cyrille Berger
This library contains the base classes and functionnalities to create unit tests for OpenGTL functionalities.

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 Documentation

#define GTLTEST_CHECK (  )     GTLTEST_CHECK_MESSAGE( (a), #a);

Check that a is true and display a message containing the value

#define GTLTEST_CHECK_EQUAL ( a,
 )     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()); \
  }
This macro will display the message including the file and line number, in case of failure.

#define GTLTEST_CHECK_NEAR_EQUAL ( a,
 )     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,
 )     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 .

Parameters:
testname name of the test

#define GTLTEST_MAIN_BEGIN ( testname   ) 

Value:

int main(int argc, char** argv) \
  { \
    GTLTest::Suite test(#testname); \
Start generating the main function of the test program.
Parameters:
testname name of the test

 
#define GTLTEST_MAIN_END (  ) 

Value:

test.run(0); \
    test.result()->dump(); \
    return test.result()->countFailed(); \
  }
End of the main function.
Parameters:
testname name of the test


Generated on Tue Jan 6 01:04:09 2009 for OpenGTL by  doxygen 1.5.1