Skip to content

Commit 6878cdf

Browse files
author
Arnd R. Strube
committed
Add new C interface functions
1 parent eb050ff commit 6878cdf

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

mocking_manual.markdown

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ Sometimes it is useful to access the mocking framework from a .c file rather tha
482482
#include "CppUTestExt/MockSupport_c.h"
483483

484484
mock_c()->expectOneCall("foo")->withIntParameters("integer", 10)->andReturnDoubleValue(1.11);
485-
mock_c()->actualCall("foo")->withIntParameters("integer", 10)->returnValue().value.doubleValue;
485+
return mock_c()->actualCall("foo")->withIntParameters("integer", 10)->returnValue().value.doubleValue;
486486

487487
mock_c()->installComparator("type", equalMethod, toStringMethod);
488488
mock_scope_c("scope")->expectOneCall("bar")->withParameterOfType("type", "name", object);
@@ -497,6 +497,20 @@ mock_c()->clear();
497497

498498
The C interface uses a similar builder structure as the C++ interface. It is far less common in C, but it works the same.
499499

500+
It is now also possible to specify the actual return value in the same way as with C++ (3.8):
501+
502+
{% highlight c++ %}
503+
return mock_c()->actualCall("foo")->withIntParameters("integer", 10)->doubleReturnValue();
504+
return mock_c()->doubleReturnValue();
505+
{% endhighlight %}
506+
507+
and to specify a default return value, in case mocking is currently disabled when the actual call occurs (3.8):
508+
509+
{% highlight c++ %}
510+
return mock_c()->actualCall("foo")->withIntParameters("integer", 10)->returnDoubleValueOrDefault(2.25);
511+
return mock_c()->returnDoubleValueOrDefault(2.25);
512+
{% endhighlight %}
513+
500514
<a id="miscellaneous"></a>
501515

502516
### Miscellaneous

0 commit comments

Comments
 (0)