ThrowTheSwitch / CMock

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

ExpectWithArray Passing 0 for param_depth not checking pointer #393

Closed arnedirlelwy closed 3 months ago

arnedirlelwy commented 2 years ago

Hello. I am trying to use ExpectWithArray and have the actual pointer compared (not the values at the pointer). The documentation says to pass 0 for param_depth and set mode (I am assuming for ':when_ptr :smart" and the ptr will be checked. image But when I set that up and run it I get told this and the test fails. image

Am I missing something in the setup to do the pointer comparison. Do I need to have treat_as setup some specific way? Or does this not work when passing 0.

//My function protoype is 
error_t MyFunction(uint8_t *ptr, uint32_t size);
//and the test call is 
uint8_t expected_ptr[] = {0x1, 0x2, 0x3};
MyFunction_ExpectWithArrayAndReturn(expected_ptr, 0, 3, error_none);
MyFunction(expected_ptr, 3);
mvandervoord commented 2 years ago

Can you post the cmock section of your project.yml file here for reference? It's hard to know which setting(s) you might be missing without seeing what you have. :)

arnedirlelwy commented 2 years ago

image

Hello, yes, here it is currently. I also have added :when_ptr :compare_ptr and :when_ptr :smart and couldn't get that to fix the problem.

mvandervoord commented 2 years ago

Yeah, I started digging into it after I replied yesterday. I think it's a bug that crept into Unity. I'm going to fix it and add some tests to keep it from creeping back in.

arnedirlelwy commented 2 years ago

Ohk Thank you!