You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CppUTest plugins can be installed in the main and 'extent' the unit test framework. It is a place where you can put work that needs to be done in all unit tests. There is a MockPlugin to make the work with mocks easier. It does the following work:
509
-
510
-
* checkExpectations at the end of every test (on global scope, which goes recursive over all scopes)
511
-
* clear all expectations at the end of every test
512
-
* install all comparators that were configured in the plugin at the beginning of every test
513
-
* remove all comparators at the end of every test
514
-
515
-
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.
508
+
CppUTest plugins can be installed in the main and 'extend' the unit test framework. It is a place where you can put work that needs to be done in all unit tests. There is a MockSupportPlugin to make the work with mocks easier. Complete Documentation for MockSupportPlugin can be found on the [Plugins Manual](plugins_manual.html) page.
Copy file name to clipboardExpand all lines: plugins_manual.markdown
+107-8Lines changed: 107 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,12 @@ title: Plugins Manual
13
13
14
14
## SetPointerPlugin
15
15
16
+
### Description
17
+
18
+
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.
19
+
20
+
### Example
21
+
16
22
{% highlight c++ %}
17
23
int main(int ac, char** av)
18
24
{
@@ -34,8 +40,8 @@ TEST_GROUP(HelloWorld)
34
40
}
35
41
void setup()
36
42
{
37
-
//overwrite the production function pointer witha an output method that captures
38
-
//output in a buffer.
43
+
//overwrite the production function pointer witha an output method that captures
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.
85
111
86
112
<aid="ieee754exceptionsplugin"> </a>
87
113
88
114
## IEEE754ExceptionsPlugin
89
115
90
-
Tba
116
+
### Description
117
+
118
+
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).
119
+
120
+
This is a list of floating point error conditions, and how they are supported by the plugin:
121
+
122
+
{% highlight c++ %}
123
+
FE_DIVBYZERO /* supported (3.8) */
124
+
FE_OVERFLOW /* supported (3.8) */
125
+
FE_UNDERFLOW /* supported (3.8) */
126
+
FE_INVALID /* supported (3.8) */
127
+
FE_INEXACT /* supported; disabled by default (3.8) */
128
+
FE_DENORMAL /* NOT supported (3.8) */
129
+
{% endhighlight %}
130
+
131
+
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:
0 commit comments