Skip to content

Commit 4442cc1

Browse files
authored
Merge pull request #51 from samryanuofl/AddMemoryBufferParameterDocumentation
Add documentation for withMemoryBufferParameter function
2 parents 9479289 + f7a8db0 commit 4442cc1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

mocking_manual.markdown

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ The main idea is to make manual mocking easier, rather than to make automated mo
2121
* [Using Parameters](#parameters)
2222
* [Objects as Parameters](#objects_as_parameters)
2323
* [Output Parameters](#output_parameters)
24+
* [Memory Buffer Parameters](#memory_buffer_parameters)
2425
* [Output Parameters Using Objects](#output_parameters_using_objects)
2526
* [Return Values](#return_values)
2627
* [Passing other data](#other_data)
@@ -241,6 +242,22 @@ Comparators are *not* copied, instead it uses the exact instance as passed to th
241242

242243
When using the MockPlugin (recommended), then it's best to install the comparators via the MockPlugin or put them in global space. The checkExpectations will be called *after* teardown and if your comparator was destroyed in the teardown then this will cause a crash.
243244

245+
<a id="memory_buffer_parameters"> </a>
246+
247+
### Memory Buffer Parameters
248+
249+
When testing a function that accepts a pointer to data as a parameter you may want to check the value of the data referenced by the pointer instead of the value of the pointer itself. This can be done using withMemoryBufferParameter like:
250+
251+
{% highlight c++ %}
252+
mock().expectOneCall("function").onObject(object).withMemoryBufferParameter("buffer", buffer, length);
253+
{% endhighlight %}
254+
255+
and the actual call would be:
256+
257+
{% highlight c++ %}
258+
mock().actualCall("function").onObject(this).withMemoryBufferParameter("buffer", buffer, length);
259+
{% endhighlight %}
260+
244261
<a id="output_parameters"> </a>
245262

246263
### Output Parameters

0 commit comments

Comments
 (0)