Menu

#23 Improvement: expectAssignAndReturn

v1.0_(example)
open
pogn
Improvement (1)
1
2014-10-17
2014-10-17
Anonymous
No

Hello Pascal,

while doing UT, I feel the lack of a functionality in the generated mocks. Sometimes, whenever a mocked function is having a pointer as a parameter, it is also interesting that the content of the pointer gets filled with a value that we determine because this pointer is actually an output parameter of a function.

Basically the idea would be to have an extra function funcName_expectAssignAndReturn.
e.g. for the function int foo(int a, int b) we would get foo_expectAssignAndReturn(int a, int b, int rv, OPMOCK_MATCHER match_a, OPMOCK_MATCHER match_b, int valueToAssignTo_b).
This function is almost the same as foo_expectAndReturn() but I've added an extra parameter for the pointer
b. So for every parameter that are pointer, expectAssignAndReturn should give the opportunity to set a value to the content of the pointer if needed.

I'm aware that we can manually do that via funcName_mockWithCallback but then we lose the advantage of having our parameters checked automatically by the framework. And in the end, this is all the time the same kind of mock to implement, so I think better is to generate it.

What do you think about this idea?
Can you make such improvement?

Thanks a lot.

Kind regards,

Laurent

Discussion

Anonymous
Anonymous

Add attachments
Cancel