diff --git a/tests/zero_cross_detection/test_zero_cross_detection.cpp b/tests/zero_cross_detection/test_zero_cross_detection.cpp index 5b4846a..197d336 100644 --- a/tests/zero_cross_detection/test_zero_cross_detection.cpp +++ b/tests/zero_cross_detection/test_zero_cross_detection.cpp @@ -67,6 +67,33 @@ TEST(test_zero_cross_detection, ZCD_IsTriggerdTrueWhenRising) 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) { @@ -77,9 +104,8 @@ TEST(test_zero_cross_detection, ZCD_PollWorksAfterCalls) MockADC_PushValue(50); MockADC_PushValue(50); - mock().expectNCalls(4, "ADC_ReadValue_Impl") - .withUnsignedIntParameter("pin_num", 7) - .ignoreOtherParameters(); + PollIterationExpectations(); + PollIterationExpectations(); ZCD_Poll(); }