ThrowTheSwitch / CMock

CMock - Mock/stub generator for C
http://throwtheswitch.org
MIT License
684 stars 276 forks source link

Plugin :ignore_arg not generating mocks #483

Open vmpxc opened 1 month ago

vmpxc commented 1 month ago

Hello,

I tried using the IgnoreArg functionality of CMock, but it doesn't seem to work. The mocks for ignore_arg are not being generated. The other plugins seem to work just fine for me.

My project.yaml includes the ignore_arg Plugin:

  :plugins:
    - :ignore
    - :ignore_arg
    - :callback
    - :expect_any_args
    - :return_thru_ptr 
    - :array

An example function that I want to mock:

uint16_t GetModuleNameString(uint8_t slot, char* strName)
{
    uint16_t Lenght = 0; 

    if(slot >=1 && slot <= 16) 
    {
        // copy data to strName ...
    }
    return Lenght; 
}

In my testing function I use the following sequence:

test_NameStrings(void)
{
    char testName[] = "Test123"; 

    GetModuleNameString_ExpectAndReturn(1, NULL, 20);    // when called, make sure slot is 1, but don't care about the string yet and return 20
    GetModuleNameString_IgnoreArg_strName();    // this mock is not generated (error: implicit declaration)
    GetModuleNameString_ReturnMemThruPtr_strName(testName, sizeof(testName)); 

    func_that_will_call_GetModuleNameString_somewhere(...); 
    TEST_ASSERTS_...

}

Here I get an error, that GetModuleNameString_IgnoreArg_strName() is declarated implicitly.

At the moment I use GetModuleNameString_ExpectAnyArgsAndReturn(20) instead and it works, but I would like to check the slot parameter too.

Thanks for this great tool so far. Any help would be appreciated!

vmpxc commented 1 month ago

I'm using: Ceedling:: 0.31.1 CMock:: 2.5.4 Unity:: 2.5.4 CException:: 1.3.3