GTLTest Library


Classes

class  GTLTest::Case
class  GTLTest::Result
class  GTLTest::Suite
class  GTLTest::Thread

Defines

#define GTLTEST_CHECK(a)   GTLTEST_CHECK_MESSAGE( (a), #a);
#define GTLTEST_CHECK_REQUIRED(a)   GTLTEST_CHECK_MESSAGE_REQUIRED( (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_CHECK_MESSAGE_REQUIRED(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.15
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);

For internal use only.

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) << ")" );

For internal use only.

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()); \
  }

For internal use only.

This macro will display the message including the file and line number, in case of failure.

#define GTLTEST_CHECK_MESSAGE_REQUIRED ( a,
msg   ) 

Value:

{ \
    std::stringstream ss; \
    std::string str; \
    ss << __FILE__ << " at " << __LINE__ << ": " << msg; \
    bool t = (a); \
    check( t, ss.str()); \
    if(not t) \
      return; \
  }

For internal use only.

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

For internal use only.

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

For internal use only.

This macro will test that a and b are not equal, and display a message containing the values in case of failure.

#define GTLTEST_CHECK_REQUIRED (  )     GTLTEST_CHECK_MESSAGE_REQUIRED( (a), #a);

For internal use only.

Check that a is true and display a message containing the value. Stop the test if failed;

#define GTLTEST_MAIN_ADD_CASE ( case   )     test.addCase(new case());

For internal use only.

Add a test GTLTest::Case to the main test GTLTest::Suite .

Parameters:
case name of the test

#define GTLTEST_MAIN_BEGIN ( testname   ) 

Value:

int main(int argc, char** argv) \
  { \
    GTLTest::Suite test(#testname); \

For internal use only.

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(); \
  }

For internal use only.

End of the main function.


Generated on Wed Sep 8 00:00:17 2010 for OpenGTL by  doxygen 1.5.6