Merge pull request #404 from tz18/patch-1

Add example for the usage of ReturnThruPtr
This commit is contained in:
Mark VanderVoord
2022-07-08 12:15:07 -04:00
committed by GitHub
+25
View File
@@ -220,6 +220,31 @@ are queued up and copied into the space being pointed at each time the mock is c
* => `void func_ReturnArrayThruPtr_paramName(val_to_return, len)`
* => `void func_ReturnMemThruPtr_paramName(val_to_return, size)`
For example, consider the following function:
`BOOL divide(uint numerator, uint denominator, uint* result){
if (denominator == 0){
return FALSE;
}
*result = numerator/denominator;
return TRUE;
}
`
We might want to mock this function so that regardless of the inputs, it returns TRUE and a result of 23.
We could do so like this:
`uint result_1 = 23;
divide_ExpectAnyArgsAndReturn(TRUE);
divide_ReturnThruPtr_result(&result_1);
`
If we want to expect a numerator of 5 and a denominator of 2 and return a result of 42:
`uint result_1 = 42;
divide_ExpectAndReturn(5,2,NULL,TRUE);
divide_IgnoreArg_result();
divide_ReturnThruPtr_result(&result_1);
`
Callback:
---------