Simpatico
v1.10
|
This example shows how to construct and run a single UnitTest class.
Trivial example of UnitTest use for parallel MPI job.
This file demonstrates the usage of a composite test runner.
We create a subclass of UnitTest named TestA, which has 3 test methods. We then use a set of preprocessor macros to define an associated subclass of UnitTestRunner. The name of the UnitTestRunner subclass is given by the macro TEST_RUNNER(TestA), which expands to TestA_Runner.
In the main program, we create an instance of TEST_RUNNER(TestA) and call its run method, which runs all 3 test methods in sequence. Trivial subclass of UnitTest, for illustration.
A CompositeTestRunner is a TestRunner that runs and accumulates statistics of the tests associated with several child TestRunner objects. The child runners are usually instances of UnitTestRunner.
To demonstrate the usage, we define two trivial unit tests, TestA and TestB, and use macros to define associated UnitTestRunner subclasses, TEST_RUNNER(TestA) and TEST_RUNNER(TestB). The preprocessor macros in the main program then define a class CompositeExample that is derived from CompositeTestRunner, which contains instances of the TEST_RUNNER(TestA) and TEST_RUNNER(TestB). Calling the run() method of the CompositeExample then runs the all of the tests defined in TestA and TestB. Trivial UnitTest A.
Trivial subclass of UnitTest for an MPI job.
Definition at line 20 of file example1.cpp.
Additional Inherited Members | |
![]() | |
UnitTest () | |
Constructor. More... | |
virtual | ~UnitTest () |
Destructor. More... | |
virtual void | setUp () |
Set up before each test method (empty default implementation). More... | |
virtual void | tearDown () |
Tear down after each test method (empty default implementation). More... | |
void | setVerbose (int verbose) |
Set verbosity level. More... | |
void | setFilePrefix (const std::string &prefix) |
Set file prefix. More... | |
const std::string & | filePrefix () |
Get file prefix string. More... | |
bool | isIoProcessor () const |
Should this processor read and write to file? More... | |
![]() | |
void | printMethod (const char *methodName) |
Write name of a class method, iff ioProcessor. More... | |
void | printEndl () |
Write carriage return, iff isIoProcessor. More... | |
virtual void | endMarker () |
Print a line of hashes, iff isIoProcessor. More... | |
void | openInputFile (const std::string &name, std::ifstream &in) const |
Open C++ input file ifstream. More... | |
void | openOutputFile (const std::string &name, std::ofstream &out) const |
Open C++ output file ofstream. More... | |
FILE * | openFile (const std::string &name, const char *mode) const |
Open C file handle with specified mode. More... | |
int | verbose () const |
Return integer verbosity level (0 == silent). More... | |
![]() | |
static bool | eq (int s1, int s2) |
Return true if two integers are equal. More... | |
static bool | eq (double s1, double s2) |
Return true if two double precision floats are equal. More... | |