7.4 Test Assert Methods


7.4 Test Assert Methods

CppUnit provides several variations on the basic assert method. The assert methods are implemented as macros. The advantage of using macros to implement assert methods is that they enable the compiler preprocessor to record the source code location of each assert, which is otherwise hard to do in C.

As in other xUnits, some of the asserts have variants that take a descriptive message argument. The message is reported if the test fails. Examples of these variants are shown in the following list:



Test that passes if condition is true .


Test that always fails.



Test that passes if expected and actual are equal. It supports arguments of most common data types and std::string .


Test that passes if expected and actual are equal within a tolerance of delta . The arguments are of type double .

Unit Test Frameworks
Unit Test Frameworks
ISBN: 0596006896
EAN: 2147483647
Year: 2006
Pages: 146
Authors: Paul Hamill

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net