diff --git a/tests/zero_cross_detection/test_zero_cross_detection.cpp b/tests/zero_cross_detection/test_zero_cross_detection.cpp index 197d336..b3876b0 100644 --- a/tests/zero_cross_detection/test_zero_cross_detection.cpp +++ b/tests/zero_cross_detection/test_zero_cross_detection.cpp @@ -32,40 +32,6 @@ TEST_GROUP(test_zero_cross_detection) } }; -TEST(test_zero_cross_detection, ZCD_SetupCallsCorrectFuncs) -{ - mock().expectOneCall("ADC_Init") - .withUnsignedIntParameter("pin_num", 7); - - mock().expectOneCall("ADC_Enable") - .withUnsignedIntParameter("pin_num", 7); - - ZCD_Setup(); -} - -TEST(test_zero_cross_detection, ZCD_IsTriggeredCallsCorrectFunctions) -{ - MockADC_ZeroIndex(); - - mock().expectNCalls(2, "ADC_ReadValue_Impl") - .withUnsignedIntParameter("pin_num", 7); - - CHECK_FALSE(ZCD_IsTriggered()); -} - - -TEST(test_zero_cross_detection, ZCD_IsTriggerdTrueWhenRising) -{ - MockADC_ZeroIndex(); - MockADC_PushValue(512); - MockADC_PushValue(450); - - mock().expectNCalls(2, "ADC_ReadValue_Impl") - .withUnsignedIntParameter("pin_num", 7) - .ignoreOtherParameters(); - - CHECK_TRUE(ZCD_IsTriggered()); -} static void PollIterationExpectations(void) { @@ -95,6 +61,41 @@ static void PollIterationExpectations(void) } +TEST(test_zero_cross_detection, ZCD_SetupCallsCorrectFuncs) +{ + mock().expectOneCall("ADC_Init") + .withUnsignedIntParameter("pin_num", 7); + + mock().expectOneCall("ADC_Enable") + .withUnsignedIntParameter("pin_num", 7); + + ZCD_Setup(); +} + + +TEST(test_zero_cross_detection, ZCD_IsTriggeredCallsCorrectFunctions) +{ + MockADC_ZeroIndex(); + + PollIterationExpectations(); + + CHECK_FALSE(ZCD_IsTriggered()); +} + + +TEST(test_zero_cross_detection, ZCD_IsTriggerdTrueWhenRising) +{ + MockADC_ZeroIndex(); + + MockADC_PushValue(512); + MockADC_PushValue(450); + + PollIterationExpectations(); + + CHECK_TRUE(ZCD_IsTriggered()); +} + + TEST(test_zero_cross_detection, ZCD_PollWorksAfterCalls) { MockADC_ZeroIndex();