Skip to content

Commit 3d4aac5

Browse files
author
Arnd R. Strube
committed
Add documentation for IEEE754ExceptionsPlugin
1 parent 7208642 commit 3d4aac5

File tree

3 files changed

+94
-67
lines changed

3 files changed

+94
-67
lines changed

_includes/header.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ <h2>CppUTest unit testing and mocking framework for C/C++</h2>
3030
<li class="divider-vertical"></li>
3131
<li><a href="mocking_manual.html">CppUMock Manual</a></li>
3232
<li class="divider-vertical"></li>
33-
<li><a href="stories.html">Platforms stories</a></li>
33+
<li><a href="plugins_manual.html">Plugins Manual</a></li>
3434
<li class="divider-vertical"></li>
35-
<li><a href="docs/index.html">Doxygen</a></li>
35+
<li><a href="stories.html">Platforms stories</a></li>
3636
<li class="divider-vertical"></li>
3737
<li><a href="https://github.com/cpputest/cpputest"><span class="github_icon"></span><span>View on
3838
GitHub</span></a></li>

manual.markdown

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -353,73 +353,10 @@ Test plugins let you add a pre-action and a post-action to each test case. Plug
353353

354354
* Memory leak detector (provided)
355355
* Pointer restore mechanism (provided) - 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.
356+
* IEEE754 Floating point exceptions (provided; 3.8) - automatically checks whether any floating point exception flags are set at the end of every test and if so, fails the test.
356357
* All Mutex's released - you could write a plugin that checks that any Mutexs or other shared resource is released before the test exits.
357358

358-
Example of a main with a SetPointerPlugin:
359-
360-
{% highlight c++ %}
361-
int main(int ac, char** av)
362-
{
363-
TestRegistry* r = TestRegistry::getCurrentRegistry();
364-
SetPointerPlugin ps("PointerStore");
365-
r->installPlugin(&ps);
366-
return CommandLineTestRunner::RunAllTests(ac, av);
367-
}
368-
369-
TEST_GROUP(HelloWorld)
370-
{
371-
static int output_method(const char* output, ...)
372-
{
373-
va_list arguments;
374-
va_start(arguments, output);
375-
cpputest_snprintf(buffer, BUFFER_SIZE, output, arguments);
376-
va_end(arguments);
377-
return 1;
378-
}
379-
void setup()
380-
{
381-
//overwrite the production function pointer witha an output method that captures
382-
//output in a buffer.
383-
UT_PTR_SET(helloWorldApiInstance.printHelloWorld_output, &output_method);
384-
}
385-
void teardown()
386-
{
387-
}
388-
};
389-
390-
TEST(HelloWorld, PrintOk)
391-
{
392-
printHelloWorld();
393-
STRCMP_EQUAL("Hello World!\n", buffer)
394-
}
395-
396-
//Hello.h
397-
#ifndef HELLO_H_
398-
#define HELLO_H_
399-
400-
extern void printHelloWorld();
401-
402-
struct helloWorldApi {
403-
int (*printHelloWorld_output) (const char*, ...);
404-
};
405-
406-
#endif /*HELLO_H_*/
407-
408-
//Hello.c
409-
410-
#include <stdio.h>
411-
#include "hello.h"
412-
413-
//in production, print with printf.
414-
struct helloWorldApi helloWorldApiInstance = {
415-
&printf
416-
};
417-
418-
void printHelloWorld()
419-
{
420-
helloWorldApiInstance.printHelloWorld_output("Hello World!\n");
421-
}
422-
{% endhighlight %}
359+
Complete Documentation for provided plugins can be found on the [Plugins Manual](plugins_manual.html) page.
423360

424361
<a id="scripts"> </a>
425362

plugins_manual.markdown

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
layout: default
3+
title: Plugins Manual
4+
---
5+
6+
## Table of Content
7+
8+
* [SetPointerPlugin](#setpointerplugin)
9+
* [MockSupportPlugin](#mocksupportplugin)
10+
* [IEEE754ExceptionsPlugin](#ieee754exceptionsplugin)
11+
12+
<a id="setpointerplugin"> </a>
13+
14+
## SetPointerPlugin
15+
16+
{% highlight c++ %}
17+
int main(int ac, char** av)
18+
{
19+
TestRegistry* r = TestRegistry::getCurrentRegistry();
20+
SetPointerPlugin ps("PointerStore");
21+
r->installPlugin(&ps);
22+
return CommandLineTestRunner::RunAllTests(ac, av);
23+
}
24+
25+
TEST_GROUP(HelloWorld)
26+
{
27+
static int output_method(const char* output, ...)
28+
{
29+
va_list arguments;
30+
va_start(arguments, output);
31+
cpputest_snprintf(buffer, BUFFER_SIZE, output, arguments);
32+
va_end(arguments);
33+
return 1;
34+
}
35+
void setup()
36+
{
37+
//overwrite the production function pointer witha an output method that captures
38+
//output in a buffer.
39+
UT_PTR_SET(helloWorldApiInstance.printHelloWorld_output, &output_method);
40+
}
41+
void teardown()
42+
{
43+
}
44+
};
45+
46+
TEST(HelloWorld, PrintOk)
47+
{
48+
printHelloWorld();
49+
STRCMP_EQUAL("Hello World!\n", buffer)
50+
}
51+
52+
//Hello.h
53+
#ifndef HELLO_H_
54+
#define HELLO_H_
55+
56+
extern void printHelloWorld();
57+
58+
struct helloWorldApi {
59+
int (*printHelloWorld_output) (const char*, ...);
60+
};
61+
62+
#endif /*HELLO_H_*/
63+
64+
//Hello.c
65+
66+
#include <stdio.h>
67+
#include "hello.h"
68+
69+
//in production, print with printf.
70+
struct helloWorldApi helloWorldApiInstance = {
71+
&printf
72+
};
73+
74+
void printHelloWorld()
75+
{
76+
helloWorldApiInstance.printHelloWorld_output("Hello World!\n");
77+
}
78+
{% endhighlight %}
79+
80+
<a id="mocksupportplugin"> </a>
81+
82+
## MockSupportPlugin
83+
84+
Tba
85+
86+
<a id="ieee754exceptionsplugin"> </a>
87+
88+
## IEEE754ExceptionsPlugin
89+
90+
Tba

0 commit comments

Comments
 (0)