From 1a5324aef6f51981a9d7cabd04e34a200fd77ab6 Mon Sep 17 00:00:00 2001 From: jakeg00dwin Date: Sat, 27 Jul 2024 09:44:42 -0700 Subject: [PATCH] cleaned up tests a bit more by extracting duplication in helper function --- .../test_zero_cross_detection.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tests/zero_cross_detection/test_zero_cross_detection.cpp b/tests/zero_cross_detection/test_zero_cross_detection.cpp index b3876b0..55d4ac8 100644 --- a/tests/zero_cross_detection/test_zero_cross_detection.cpp +++ b/tests/zero_cross_detection/test_zero_cross_detection.cpp @@ -33,13 +33,18 @@ TEST_GROUP(test_zero_cross_detection) }; -static void PollIterationExpectations(void) +static void ZCDSetupExpectations(void) { mock().expectOneCall("ADC_Init") .withUnsignedIntParameter("pin_num", 7); mock().expectOneCall("ADC_Enable") .withUnsignedIntParameter("pin_num", 7); +} + +static void PollIterationExpectations(void) +{ + ZCDSetupExpectations(); mock().expectOneCall("ADC_ReadValue_Impl") .withUnsignedIntParameter("pin_num", 7) @@ -47,11 +52,7 @@ static void PollIterationExpectations(void) mock().expectOneCall("ADC_Disable"); - mock().expectOneCall("ADC_Init") - .withUnsignedIntParameter("pin_num", 7); - - mock().expectOneCall("ADC_Enable") - .withUnsignedIntParameter("pin_num", 7); + ZCDSetupExpectations(); mock().expectOneCall("ADC_ReadValue_Impl") .withUnsignedIntParameter("pin_num", 7) @@ -63,11 +64,7 @@ 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); + ZCDSetupExpectations(); ZCD_Setup(); }