utst Namespace Reference
A simple unit test framework which provides both classes and macros to ease unit testing. A user can add test cases to a test suite and then run all of the test cases or just a specific one. Usually one feeds the arguments from the command line into the runFromCmdLine() member function to allow a user to specify regression test options at run time. An example of using the unit test framework is below:
#include <iostream> #include "utst.h" UTST_TEST_CASE( SimpleTestCase ) { UTST_CHECK_EQUAL( 1+1, 2 ); } int main( int argc, char* argv[] ) { utst::TestSuite suite("A Test Suite"); suite.addTestCase( SimpleTestCase ); suite.runFromCmdLine( argc, argv ); }
The available test macros are listed below. These macros can only be used with the UTST_TEST_CASE macro or in theTest() member function of classes which are derrived from TestCase.
- UTST_CHECK : Check a predicate
- UTST_CHECK_EQUAL : Check if two expressions are equal
- UTST_CHECK_CONTAINERS : Check if two STL containers are equal
- UTST_CHECK_THROW : Check if an expression throws a specific exception
- UTST_FAIL : Fail with a specific error message
- UTST_NOTE : Make a note to the test log stream
- --log-level : Set the level of detail to output
- --test-case : Only run the test case with the given name
- --test-suite : Only run the test suite with the given name
- --examples : Run example test cases instead of regular test cases
- errors : Only output errors
- minimal : Output errors as well as a list of test case names
- moderate : Output errors, test case names, and note/log stream output
- verbose : Output everything
Compounds
- class utst::NullOstream
- Null output stream.
- Null output stream.
- class utst::NullStreambuf
- Stream buffer to be used with a null output stream.
- Stream buffer to be used with a null output stream.
- class utst::TestCase
- Base Class: Self checking regression tests.
- Base Class: Self checking regression tests.
- class utst::FuncPtrTestCase
- Helper class for creating test cases from free functions.
- Helper class for creating test cases from free functions.
- class utst::TestLog
- Regression test output log stream.
- Regression test output log stream.
- struct utst::TestLog::LogLevel
- Enum for various log levels.
- Enum for various log levels.
- class utst::TestSuite
- Collection of test cases.
- Collection of test cases.