Skip to content

Commit e2f565c

Browse files
committed
-changing Return Value documentation to reflect the easier way to return values.
1 parent 8c7e17b commit e2f565c

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

mocking_manual.markdown

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,22 +231,27 @@ When using the MockPlugin (recommended), then its best to install the comparator
231231
<a id="return_values"> </a>
232232
### Return Values
233233

234-
Sometimes it is needed to let a mock function return a value which can then be used in production code. This can be done like:
234+
Sometimes it is needed to let a mock function return a value which can then be used in production code. The test code would look like this:
235235

236236
{% highlight c++ %}
237237
mock().expectOneCall("function").andReturnValue(10);
238238
{% endhighlight %}
239239

240-
And it can be used in the actual call like:
240+
The mock function would look like:
241241

242242
{% highlight c++ %}
243-
int value = mock().actualCall("function").returnValue().getIntValue();
243+
int function () {
244+
return mock().actualCall("function").intReturnValue();
245+
}
244246
{% endhighlight %}
245247

246-
or separate from the actualCall (below it!) like:
248+
or we could separate intReturnValue from the actualCall (below it!) like:
247249

248250
{% highlight c++ %}
249-
value = mock().returnValue().getIntValue();
251+
int function () {
252+
mock().actualCall("function");
253+
return mock().intReturnValue();
254+
}
250255
{% endhighlight %}
251256

252257
The return value options are used to transfer data between the test and the mock object, they themselves do not cause the tests to fail.

0 commit comments

Comments
 (0)