The SetPointerPlugin provides a Pointer restore mechanism - helpful when tests overwrite a pointer that must be restored to its original value after the test. This is especially helpful when a pointer to a function is modified for test purposes.
MockSupportPlugin makes the work with mocks easier. It does the following work for you automatically:
checkExpectations at the end of every test (on global scope, which goes recursive over all scopes)
clear all expectations at the end of every test
install all comparators that were configured in the plugin at the beginning of every test
remove all comparators at the end of every test
Installing the MockPlugin means you’ll have to add to main something like:
This code creates a comparator for MyDummy and installs it at the plugin. This means the comparator is available for all test cases. It creates the plugin and installs it at the current test registry. After installing the plugin, you don’t have to worry too much anymore about calling checkExpectations or cleaning your MockSupport.
This plugin detects floating point error conditions and fails the test, if any were found. According to the IEEE754 Floating Point Standard, floating point errors do not by default cause abnormal program termination. Rather, flags are set to indicate a problem, and the operation returns a defined value such as Infinity or Not-a-Number (NaN).
This is a list of floating point error conditions, and how they are supported by the plugin:
You can turn on FE_INEXACT checking manually, although this probably won’t be very useful most of the time, since almost every floating-point operation is likely to set this flag:
The output of these tests will be:
Debugging floating point failures
When a test fails due to a floating point error, it can be challenging to find the location of the offending operation, since the plugin has no knowledge of where the flag was originally set. To aid in debugging, there is are a number of static methods you can use to set up a watch:
Here is an minimal example using Gdb, example.cpp:
1) Compile the example. Your command line will look roughly like this:
2) Start the example in Gdb:
3) Set a breakpoint and run the example:
4) Set up the watch you need:
5) Stepping over the offending statement will change the value of your watch:
Of course you don’t have to use commandline Gdb to do this; you can debug your code from within your favorite IDE (Eclipse, Code::Blocks, …) following basically the same procedure.
Order: Test are executed from lowest to highest level. Tests with same same level are executed top down.
Only the C++-wrapper changes, the C-file synatx is as usual.