Hello,
Sometimes, I am facing an error while calling many mocks one after the other: ceedling complains that one of them is called earlier than expected, whereas my test and my code call the mocks in the same order.
For example, in the following test:
productConfiguration.dateTime.year.data = 2022;
productConfiguration.dateTime.month.data = 02;
productConfiguration.dateTime.day.data = 05;
productConfiguration.dateTime.hours.data = 15;
productConfiguration.dateTime.minutes.data = 45;
SCRN_isDisplayAvailable_ExpectAndReturn(1);
uint8_t date050222[DATE_STRING_SIZE] = "05/02/2022";
SCRN_WriteMsgOnLine_ExpectWithArray(0, date050222, DATE_STRING_SIZE);
uint8_t time15h45[TIME_STRING_SIZE] = "15:45";
SCRN_WriteMsgOnLine_ExpectWithArray(1, time15h45, TIME_STRING_SIZE);
SCRN_setIndexOfActiveLine_Expect(0); // on se positionne sur la 1ere ligne a editer
SCRN_SetPositionOfCharacterToBlink_Expect(E_DIZAINES_JOUR); // on se positionne sur le 1er caractere a editer
SCRN_display_Expect(SCRN_CHOOSE_DATE_TIME);
MSM_Management();
TEST_ASSERT_EQUAL(E_MSM_DATE_TIME_SELECTION, MSM_getState());
I am getting the error "Function SCRN_setIndexOfActiveLine. Called earlier than expected."
The code under test is :
void MSm_Mgt(void)
{
if(1 == SCRN_isDisplayAvailable())
{
switchToState(mainStateInfos[E_MSM_WAIT_FOR_END_OF_CONFIRMATION_DISPLAY].nextState);
}
}
static void switchToState(e_MSM_State state)
{
timerAttenteLectureEnMs = 0;
if(NULL != mainStateInfos[state].stateEntryFunc)
mainStateInfos[state].stateEntryFunc();
MSM_currentState = state;
if(SCRN_NO_SCREEN != mainStateInfos[state].screenToDisplay)
SCRN_display(mainStateInfos[state].screenToDisplay);
}
In this case, stateEntryFunc is
static void sendCurrentDateAndTimeToScrn(void)
{
sprintf((char*) MSM_msgLine0, "%.2d/%.2d/%.4d",
productConfiguration.dateTime.day.data,
productConfiguration.dateTime.month.data,
productConfiguration.dateTime.year.data);
SCRN_WriteMsgOnLine(0, (uint8_t*) MSM_msgLine0);
sprintf((char*) MSM_msgLine1, "%.2d:%.2d",
productConfiguration.dateTime.hours.data,
productConfiguration.dateTime.minutes.data);
SCRN_WriteMsgOnLine(1, (uint8_t*) MSM_msgLine1);
MSM_positionOfCharacterToEdit = 0;
MSM_selectedLine = 0;
SCRN_setIndexOfActiveLine(MSM_selectedLine);
SCRN_SetPositionOfCharacterToBlink(MSM_positionOfCharacterToEdit);
}
... So I do not understand why ceedling is complaining.
Can you help me please?