meekrosoft / fff

A testing micro framework for creating function test doubles
Other
777 stars 168 forks source link

Have the option to make the fakes static functions #13

Closed frankbenoit closed 6 years ago

frankbenoit commented 8 years ago

Hi

to have the testing code in different modules and not having the need to think about unique names, it would be good to have a way to make the fakes static function.

frankbenoit commented 8 years ago

Or the option to use the separated DECLARE and DEFINE macros. Currently the DECLARE_ macro is missing the functions prototype. So it is not possible to but the fakes into a separated modules and have them globally available. E.g.:

define DECLARE_FAKE_VOID_FUNC1(FUNCNAME, ARG0_TYPE) \

FFF_EXTERN_C \
    typedef struct FUNCNAME##_Fake { \
        DECLARE_ARG(ARG0_TYPE, 0, FUNCNAME) \
        DECLARE_ALL_FUNC_COMMON \
        void(*custom_fake)(ARG0_TYPE arg0); \
    } FUNCNAME##_Fake;\
    extern FUNCNAME##_Fake FUNCNAME##_fake;\
    void FUNCNAME##_reset(); \
    void FUNCNAME(ARG0_TYPE arg0); \    // <-- this line is needed
FFF_END_EXTERN_C \

And this in a way, so it can also detect the arguments automatically. Because now, i can only use the makros with the explicit argument number in the name.

usr42 commented 7 years ago

Hi Frank,

can you please check, if my fix is working for you?

Cheers, Balthasar