From f7a8db004b8485b636d9421224516af7fe8d5b45 Mon Sep 17 00:00:00 2001 From: Sam Ryan Date: Thu, 3 Aug 2023 09:29:02 -0400 Subject: [PATCH] Add documentation for withMemoryBufferParameter function --- mocking_manual.markdown | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/mocking_manual.markdown b/mocking_manual.markdown index 102fa90..d99ba84 100644 --- a/mocking_manual.markdown +++ b/mocking_manual.markdown @@ -21,6 +21,7 @@ The main idea is to make manual mocking easier, rather than to make automated mo * [Using Parameters](#parameters) * [Objects as Parameters](#objects_as_parameters) * [Output Parameters](#output_parameters) +* [Memory Buffer Parameters](#memory_buffer_parameters) * [Output Parameters Using Objects](#output_parameters_using_objects) * [Return Values](#return_values) * [Passing other data](#other_data) @@ -241,6 +242,22 @@ Comparators are *not* copied, instead it uses the exact instance as passed to th 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. + + +### Memory Buffer Parameters + +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: + +{% highlight c++ %} +mock().expectOneCall("function").onObject(object).withMemoryBufferParameter("buffer", buffer, length); +{% endhighlight %} + +and the actual call would be: + +{% highlight c++ %} +mock().actualCall("function").onObject(this).withMemoryBufferParameter("buffer", buffer, length); +{% endhighlight %} + ### Output Parameters