Some of the classes and functions from the mockpp library might be of general use so they are listed in a chapter of their own.
A testing framework frequently uses assertions to check conditions of a running application. To be able to express the intention there is a bunch of functions that do special assertions.
Often you also want to provide the current filename and the source line to show the location in some kind of output. To avoid having to add this manually there are #define's under a similar name that do this automatically.
Some of the macros are self explanatory but some need a closer look. Here is a list of the most important ones:
MOCKPP_ASSERT_TRUE(condition); MOCKPP_ASSERT_FALSE(condition); MOCKPP_ASSERT_EQUALS(a, b); MOCKPP_ASSERT_DELTA(a, b, delta); MOCKPP_ASSERT_BOUNDARY(lo, up, a); MOCKPP_ASSERT_INCLUDES(substr, target); MOCKPP_ASSERT_EXCLUDES(substr, target); MOCKPP_ASSERT_STARTSWITH(substr, target); MOCKPP_ASSERT_THROWING(action, action_descr, exception, exception_data); MOCKPP_ASSERT_THROWING_COND(action, action_descr, exception, condition);
Sometimes you need to add some kind of tolerance to your comparison which
is usually needed to compare two floating point numbers.
The following formula verifies the equality of the two values:
This one is for cases when you want to make sure that a value lies
between a lower and an upper boundary. If you have a special data type
you should implement a meaningful
If you want to know if a substring is contained in another string you take this one. The following line contains it's counterpart which asserts the non-existence of a string. And finally the line after it checks if a string starts with the designated substring.
Another frequent task is to test the correct throwing of exceptions. This is easily done with the according macros.
There are some more asserters which are of limited interest, see the api
for a complete list. There you will also find a detailed description of
the above macros and the functions behind them.