Macros | Typedefs | Functions
testlib_register.h File Reference

Macros for registering the tests with the driver. More...

#include <string>

Go to the source code of this file.

Macros

#define DECLARE(testname)   int testname ## _main ( int argc, char* argv[] )
 Declare the existence of the test. More...
 
#define REGISTER(testname)   testlib_register_test(#testname, & testname ## _main );
 Register the test with the driver. More...
 
#define DEFINE_MAIN
 Define the main() routine for this test driver. More...
 

Typedefs

typedef int(* TestMainFunction) (int, char *[])
 

Functions

void testlib_register_test (const std::string &, TestMainFunction)
 

Detailed Description

Macros for registering the tests with the driver.

Author
Amitha Perera A test driver program would simply look like
DECLARE( some_test_name );
void register_tests()
{
REGISTER( some_test_name );
}
The DEFINE_MAIN macro will define the main() function for the driver. You will also have to link in a file defining a function
int some_test_name_main(int,char*[])
See the vxl tests for further examples (such as vil/tests).

Definition in file testlib_register.h.

Macro Definition Documentation

◆ DECLARE

#define DECLARE (   testname)    int testname ## _main ( int argc, char* argv[] )

Declare the existence of the test.

If you DECLARE( x ), then you will need to define a function int x_main(int,char*[]).

Definition at line 37 of file testlib_register.h.

◆ DEFINE_MAIN

#define DEFINE_MAIN
Value:
int testlib_main(int,char*[]); \
void testlib_cleanup(); \
int main( int argc, char* argv[] ) { \
register_tests(); \
int retval = testlib_main( argc, argv ); \
testlib_cleanup(); \
return retval; \
}
void testlib_cleanup()
int testlib_main(int argc, char *argv[])

Define the main() routine for this test driver.

This allows the main function to be defined in the driver code itself–instead of in the testlib library–thus avoiding "awf-weirdness". This also means that functionality from the test library, such as testlib_root_dir, can be used even if it is not used to create a test driver.

Definition at line 53 of file testlib_register.h.

◆ REGISTER

#define REGISTER (   testname)    testlib_register_test(#testname, & testname ## _main );

Register the test with the driver.

Parameters
testnameshould be the same as one of the tests declared with DECLARE.

Definition at line 44 of file testlib_register.h.

Typedef Documentation

◆ TestMainFunction

typedef int(* TestMainFunction) (int, char *[])

Definition at line 30 of file testlib_register.h.

Function Documentation

◆ testlib_register_test()

void testlib_register_test ( const std::string &  ,
TestMainFunction   
)

Definition at line 179 of file testlib_main.cxx.