diff --git a/docs/CMock_Summary.md b/docs/CMock_Summary.md index 0660619..e63a065 100644 --- a/docs/CMock_Summary.md +++ b/docs/CMock_Summary.md @@ -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: ---------