Moved static helper function to top of tests. Extracted now uneeded expectations from tests.

This commit is contained in:
jakeg00dwin 2024-07-27 09:42:40 -07:00
parent f10ed49eb4
commit a061258669
1 changed files with 35 additions and 34 deletions

View File

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