extracted the expectations into helper func for ZCD poll function.

This commit is contained in:
jakeg00dwin 2024-07-27 09:39:20 -07:00
parent d8403a4e82
commit f10ed49eb4
1 changed files with 29 additions and 3 deletions

View File

@ -67,6 +67,33 @@ TEST(test_zero_cross_detection, ZCD_IsTriggerdTrueWhenRising)
CHECK_TRUE(ZCD_IsTriggered()); CHECK_TRUE(ZCD_IsTriggered());
} }
static void PollIterationExpectations(void)
{
mock().expectOneCall("ADC_Init")
.withUnsignedIntParameter("pin_num", 7);
mock().expectOneCall("ADC_Enable")
.withUnsignedIntParameter("pin_num", 7);
mock().expectOneCall("ADC_ReadValue_Impl")
.withUnsignedIntParameter("pin_num", 7)
.ignoreOtherParameters();
mock().expectOneCall("ADC_Disable");
mock().expectOneCall("ADC_Init")
.withUnsignedIntParameter("pin_num", 7);
mock().expectOneCall("ADC_Enable")
.withUnsignedIntParameter("pin_num", 7);
mock().expectOneCall("ADC_ReadValue_Impl")
.withUnsignedIntParameter("pin_num", 7)
.ignoreOtherParameters();
mock().expectOneCall("ADC_Disable");
}
TEST(test_zero_cross_detection, ZCD_PollWorksAfterCalls) TEST(test_zero_cross_detection, ZCD_PollWorksAfterCalls)
{ {
@ -77,9 +104,8 @@ TEST(test_zero_cross_detection, ZCD_PollWorksAfterCalls)
MockADC_PushValue(50); MockADC_PushValue(50);
MockADC_PushValue(50); MockADC_PushValue(50);
mock().expectNCalls(4, "ADC_ReadValue_Impl") PollIterationExpectations();
.withUnsignedIntParameter("pin_num", 7) PollIterationExpectations();
.ignoreOtherParameters();
ZCD_Poll(); ZCD_Poll();
} }