meekrosoft / fff

A testing micro framework for creating function test doubles
Other
761 stars 167 forks source link

Add macro to get the call count #52

Closed CanadianHoser closed 5 years ago

CanadianHoser commented 6 years ago

I'd like to add a macro into FFF which returns the call count for a mock. This would allow the user to change calls from something like:

CHECK_EQUAL(1, function_to_mock_fake.call_count); to CHECK_EQUAL(1, GET_CALL_COUNT(function_to_mock));

This better masks the internals of the fff framework.

MACRO:

define GET_CALL_COUNT(FUNCNAME) \

FUNCNAME##_fake.call_count
meekrosoft commented 6 years ago

I think this is better implemented in your code rather that fff. Not that it is a bad idea, but for consistency's sake we would need to add GET_XXXX macros for every field. My feeling is that hiding the struct fields behind macros is more about personal coding style than usability.

wulfgarpro commented 5 years ago

I agree; this can be achieve with your own implementation and would unduly introduce complexity to FFF that it can do without.

Feel free to post an example if you found a solution.