HDK
|
#include <regTest.h>
Public Types | |
typedef bool(* | RegFunc )() |
Type of a function with no arguments. More... | |
typedef bool(* | RegFuncWithArgs )(int argc, char *argv[]) |
Public Member Functions | |
TF_API bool | Register (const char *name, RegFunc) |
TF_API bool | Register (const char *name, RegFuncWithArgs) |
Static Public Member Functions | |
static int | Main (int argc, char *argv[]) |
static TF_API TfRegTest & | GetInstance () |
Friends | |
class | TfSingleton< TfRegTest > |
TfRegTest
is a singleton class, which is used to register functions with either type bool
(*)(int, char*[]), or functions returning type
bool
and taking no arguments.
Here is how TfRegTest
is used to create tests in separate files, which are then compiled into a single standalone executable (and not part of any library):
// file: main.cpp
// file: hammer.cpp
When main.cpp
, drill.cpp
and hammer.cpp
are compiled into an executable, then a test can be run by invoking the executable with a first argument of either PtHammer
or PtDrill
. Since PtHammer
is a function without arguments, supplying additional arguments is an error; but PtDrill
takes arguments, so additional command-line arguments specified are passed to the function. (Most library test functions shouldn't need any arguments.)
typedef bool(* TfRegTest::RegFunc)() |
typedef bool(* TfRegTest::RegFuncWithArgs)(int argc, char *argv[]) |
Run a single regression test function, returning 0 if the function succeeded and 1 otherwise.
This function is intended to be called as follows:
The first argument is the name of the test to be run. If the registered test function run takes no arguments, then no arguments other than the test name should be supplied. Otherwise, the Main()
passes argc-1
and argv+1
to the test function, and the test function is responsible for argument checking.
TF_API bool TfRegTest::Register | ( | const char * | name, |
RegFuncWithArgs | |||
) |
|
friend |