DCMTK  Version 3.6.2
OFFIS DICOM Toolkit
Classes | Macros
oftest.h File Reference

A simple framework for writing and running test cases. More...

Classes

class  OFTestTest
 A single test case which can be run. More...
 
class  OFTestManager
 The test manager singleton manages the list of available test cases and executes them. More...
 

Macros

#define OFTEST_MAIN(module)
 Implement a main() function for running tests. More...
 
#define OFTEST_CLASS(testName)
 Internal macro for generating a class definition, don't use yourself!
 
#define OFTEST_REGISTER_INT(testName)   OFTest ## testName OFTest ## testName ## instance
 Register a test to the test manager. More...
 
#define OFTEST_REGISTER(testName)
 Register a test to the test manager. More...
 
#define OFTEST(testName)   OFTEST_FLAGS(testName, EF_None)
 Macro to define a new test case. More...
 
#define OFTEST_FLAGS(testName, flags)
 Macro to define a new test case. More...
 
macros for checking conditions in tests

These macros can be used for doing various checks in test cases.

In case their check fails, they emit a descriptive message explaining the problem.

#define OFCHECK(condition)
 Check if a condition is true. More...
 
#define OFCHECK_EQUAL(val1, val2)
 Check if two values are equal. More...
 
#define OFCHECK_FAIL(message)
 Unconditionally add a failure. More...
 

Detailed Description

A simple framework for writing and running test cases.

Macro Definition Documentation

◆ OFCHECK

#define OFCHECK (   condition)
Value:
do { \
if (!(condition)) \
OFTestManager::instance().currentTest().recordFailure(__FILE__, __LINE__, #condition); \
} while (0)
void recordFailure(const OFString &file, unsigned long int line, const OFString &message)
Add a new failure to the result set.
Definition: oftest.h:119
static OFTestManager & instance()
Definition: oftest.h:146
OFTestTest & currentTest()
Definition: oftest.h:153

Check if a condition is true.

Can only be used inside OFTEST().

Parameters
conditioncondition to check

◆ OFCHECK_EQUAL

#define OFCHECK_EQUAL (   val1,
  val2 
)
Value:
do { \
if ((val1) != (val2)) { \
OFOStringStream oss___; \
oss___ << "(" << (val1) << ") should equal (" << (val2) << ")" << OFStringStream_ends; \
OFSTRINGSTREAM_GETOFSTRING(oss___, str___) \
OFTestManager::instance().currentTest().recordFailure(__FILE__, __LINE__, str___); \
} \
} while (0)
void recordFailure(const OFString &file, unsigned long int line, const OFString &message)
Add a new failure to the result set.
Definition: oftest.h:119
static OFTestManager & instance()
Definition: oftest.h:146
OFTestTest & currentTest()
Definition: oftest.h:153

Check if two values are equal.

Can only be used inside OFTEST(). Both arguments must be compatible with OFOStringStream's operator<<.

Parameters
val1first value to compare
val2second value to compare

◆ OFCHECK_FAIL

#define OFCHECK_FAIL (   message)
Value:
do { \
OFOStringStream oss___; \
oss___ << message << OFStringStream_ends; \
OFSTRINGSTREAM_GETOFSTRING(oss___, str___) \
OFTestManager::instance().currentTest().recordFailure(__FILE__, __LINE__, str___); \
} while (0)
void recordFailure(const OFString &file, unsigned long int line, const OFString &message)
Add a new failure to the result set.
Definition: oftest.h:119
static OFTestManager & instance()
Definition: oftest.h:146
OFTestTest & currentTest()
Definition: oftest.h:153

Unconditionally add a failure.

Parameters
messagestring describing the failure

◆ OFTEST

#define OFTEST (   testName)    OFTEST_FLAGS(testName, EF_None)

Macro to define a new test case.

Internally this defines a new class inheriting from OFTest. This is equivalent to OFTEST_FLAGS(testName, EF_None).

Parameters
testNamename describing the test
See also
OFTEST_FLAGS

◆ OFTEST_FLAGS

#define OFTEST_FLAGS (   testName,
  flags 
)
Value:
OFTEST_CLASS(testName); \
OFTest ## testName::OFTest ## testName() \
: OFTestTest(#testName, flags) \
{ \
} \
void OFTest ## testName ::run()
OFCondition run(T_ASC_Association *assoc)
Take over incoming association that is in the state that the underlying TCP/IP connection is already ...
A single test case which can be run.
Definition: oftest.h:61
void addTest(OFTestTest *test)
Register a test with this test manager.
Definition: oftest.h:163
#define OFTEST_CLASS(testName)
Internal macro for generating a class definition, don&#39;t use yourself!
Definition: oftest.h:426
static OFTestManager & instance()
Definition: oftest.h:146

Macro to define a new test case.

Internally this defines a new class inheriting from OFTest.

Parameters
flagsflags that should be set for this test
testNamename describing the test
See also
OFTEST

◆ OFTEST_MAIN

#define OFTEST_MAIN (   module)
Value:
int main(int argc, char* argv[]) \
{ \
return OFTestManager::instance().run(argc, argv, module); \
}
int run(int argc, char *argv[], const char *module)
Handle the given arguments and run the requested test case.
Definition: oftest.h:220
static OFTestManager & instance()
Definition: oftest.h:146

Implement a main() function for running tests.

The main function will return the number of failed tests or -1 if an invalid test name was given.

Parameters
modulethe name of the module which is under test.

◆ OFTEST_REGISTER

#define OFTEST_REGISTER (   testName)
Value:
OFTEST_CLASS(testName); \
OFTEST_REGISTER_INT(testName)
#define OFTEST_CLASS(testName)
Internal macro for generating a class definition, don&#39;t use yourself!
Definition: oftest.h:426

Register a test to the test manager.

Parameters
testNamename of the test to register

◆ OFTEST_REGISTER_INT

#define OFTEST_REGISTER_INT (   testName)    OFTest ## testName OFTest ## testName ## instance

Register a test to the test manager.

Normally you should use OFTEST_REGISTER instead, but that macro doesn't work if OFTEST and OFTEST_REGISTER are called in the same source file.

Parameters
testNamename of the test to register


Generated on Mon Jul 17 2017 for DCMTK Version 3.6.2 by Doxygen 1.8.13