cleaned up tests a bit more by extracting duplication in helper function

This commit is contained in:
jakeg00dwin 2024-07-27 09:44:42 -07:00
parent a061258669
commit 1a5324aef6
1 changed files with 8 additions and 11 deletions

View File

@ -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();
}