Hello there,
I have a function that returns a value both via input pointer parameter and return statement:
uint16_t fsm_Event_Get_Digital_Neutral_Green( bool* value );
What is the proper way of mocking it? CMock automatically generates the following candidates:
#define fsm_Event_Get_Digital_Neutral_Green_IgnoreAndReturn(cmock_retval) fsm_Event_Get_Digital_Neutral_Green_CMockIgnoreAndReturn(__LINE__, cmock_retval)
void fsm_Event_Get_Digital_Neutral_Green_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, uint16_t cmock_to_return);
#define fsm_Event_Get_Digital_Neutral_Green_StopIgnore() fsm_Event_Get_Digital_Neutral_Green_CMockStopIgnore()
void fsm_Event_Get_Digital_Neutral_Green_CMockStopIgnore(void);
#define fsm_Event_Get_Digital_Neutral_Green_ExpectAndReturn(value, cmock_retval) fsm_Event_Get_Digital_Neutral_Green_CMockExpectAndReturn(__LINE__, value, cmock_retval)
void fsm_Event_Get_Digital_Neutral_Green_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, _Bool* value, uint16_t cmock_to_return);
typedef uint16_t (* CMOCK_fsm_Event_Get_Digital_Neutral_Green_CALLBACK)(_Bool* value, int cmock_num_calls);
void fsm_Event_Get_Digital_Neutral_Green_AddCallback(CMOCK_fsm_Event_Get_Digital_Neutral_Green_CALLBACK Callback);
void fsm_Event_Get_Digital_Neutral_Green_Stub(CMOCK_fsm_Event_Get_Digital_Neutral_Green_CALLBACK Callback);
#define fsm_Event_Get_Digital_Neutral_Green_StubWithCallback fsm_Event_Get_Digital_Neutral_Green_Stub
So I would like to make an "Expect" statement in the test, but I don;t really grasp the idea about handling the input pointer here. The function is called internally with a local variable that's address is inaccessible for me (so cannot supply it as the input parameter).
Is the only way to ignore these calls? But here I am not sure why isn't there a function call generated with just "Ignore" suffix, but only "IgnoreAndReturn". The general idea is that I would like to decide what value will be returned via the input pointer- is this doable?
I would appreciate all help.