Updated tests for `Load_HandleLoadPortB()`

This commit is contained in:
jakeg00dwin 2024-09-23 12:53:35 -07:00
parent e03a78a17b
commit 7ca25f5177
1 changed files with 50 additions and 6 deletions

View File

@ -78,6 +78,18 @@ void expect_portb_disabled(uint8_t load_pin)
.withUnsignedIntParameter("bit_num", load_pin); .withUnsignedIntParameter("bit_num", load_pin);
} }
void expect_portb_enabled(uint8_t load_pin)
{
mock().expectOneCall("RegEdit_SetBit")
.withPointerParameter("reg", (void *) &PORTB.DIR)
.withUnsignedIntParameter("bit_num", load_pin);
mock().expectOneCall("RegEdit_SetBit")
.withPointerParameter("reg", (void *) &PORTB.OUT)
.withUnsignedIntParameter("bit_num", load_pin);
}
TEST(test_load, PortAHandlerDisabledHigh) TEST(test_load, PortAHandlerDisabledHigh)
{ {
MockADC_ZeroIndex(); MockADC_ZeroIndex();
@ -122,14 +134,46 @@ TEST(test_load, PortAHandlerDisabledAboveTarget)
Load_HandleLoadPortA(adc_pin, load_pin); Load_HandleLoadPortA(adc_pin, load_pin);
} }
TEST(test_load, PortBHandlerSuccess)
TEST(test_load, PortBHandlerDisabledHigh)
{
MockADC_ZeroIndex();
MockADC_PushValue(HIGHTHRESH);
setup_adc_expectations(adc_pin);
expect_portb_disabled(load_pin);
Load_HandleLoadPortB(adc_pin, load_pin);
}
TEST(test_load, PortBHandlerDisabledLow)
{
MockADC_ZeroIndex();
MockADC_PushValue(LOWTHRESH);
setup_adc_expectations(adc_pin);
expect_portb_disabled(load_pin);
Load_HandleLoadPortB(adc_pin, load_pin);
}
TEST(test_load, PortBHandlerEnabledBelowTarget)
{ {
/*
MockADC_ZeroIndex(); MockADC_ZeroIndex();
MockADC_PushValue(LOWTHRESH + 1);
MockADC_PushValue(HIGHTHRESH - 1);
MockADC_PushValue(HYSTERESIS - 1); MockADC_PushValue(HYSTERESIS - 1);
*/
setup_adc_expectations(adc_pin);
expect_portb_enabled(load_pin);
Load_HandleLoadPortB(adc_pin, load_pin);
}
TEST(test_load, PortBHandlerDisabledAboveTarget)
{
MockADC_ZeroIndex();
MockADC_PushValue(HYSTERESIS);
setup_adc_expectations(adc_pin); setup_adc_expectations(adc_pin);
expect_portb_disabled(load_pin); expect_portb_disabled(load_pin);