Open astro-stan opened 1 month ago
Consider the following example:
// MyHeader.h typedef enum { a, b, c, } MyType_t; int myFunc( const MyType_t t_MyType );
When myFunc gets mocked it results in the following code being generated:
myFunc
// MockMyHeader.c ... void CMockExpectParameters_MyFunc(CMOCK_MyFunc_CALL_INSTANCE* cmock_call_instance, const MyType_t t_MyType) { memcpy((void*)(&cmock_call_instance->Expected_t_MyType), (void*)(&t_MyType), // <---- NO CONST WHEN CASTING sizeof(MyType_t[sizeof(t_MyType) == sizeof(MyType_t) ? 1 : -1])); /* add MyType_t to :treat_as_array if this causes an error */ cmock_call_instance->IgnoreArg_t_MyType = 0; } ITC_Status_t MyFunc(const MyType_t t_MyType) { ... if (!cmock_call_instance->IgnoreArg_t_MyType) { UNITY_SET_DETAILS(CMockString_MyFunc,CMockString_t_MyType); // v AGAIN NO CONST WHEN CASTING v UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(&cmock_call_instance->Expected_t_MyType), (void*)(&t_MyType), sizeof(MyType_t), cmock_line, CMockStringMismatch); } } ... }
Consider the following example:
When
myFunc
gets mocked it results in the following code being generated: