diff --git a/tests/load/test_load.cpp b/tests/load/test_load.cpp index 77dfde2..566e5ba 100644 --- a/tests/load/test_load.cpp +++ b/tests/load/test_load.cpp @@ -82,16 +82,26 @@ void expect_porta_enabled(uint8_t load_pin, bool output_level) .withUnsignedIntParameter("bit_num", load_pin); } -void expect_portb_disabled(uint8_t load_pin) +void expect_portb_disabled(uint8_t load_pin, bool output_level) { + mock().expectOneCall("RegEdit_IsBitSet") + .withPointerParameter("reg", (void *) &PORTB.OUT) + .withUnsignedIntParameter("bit_num", load_pin) + .andReturnValue(output_level); + mock().expectOneCall("RegEdit_ClearBit") .withPointerParameter("reg", (void *) &PORTB.OUT) .withUnsignedIntParameter("bit_num", load_pin); } -void expect_portb_enabled(uint8_t load_pin) +void expect_portb_enabled(uint8_t load_pin, bool output_level) { + mock().expectOneCall("RegEdit_IsBitSet") + .withPointerParameter("reg", (void *) &PORTB.OUT) + .withUnsignedIntParameter("bit_num", load_pin) + .andReturnValue(output_level); + mock().expectOneCall("RegEdit_SetBit") .withPointerParameter("reg", (void *) &PORTB.DIR) .withUnsignedIntParameter("bit_num", load_pin); @@ -127,7 +137,6 @@ TEST(test_load, PortAHandlerEnabledRisingEdgeLO) MockADC_PushValue(HYSTERESIS_LO - 1); setup_adc_expectations(adc_pin); - expect_porta_enabled(load_pin, false); Load_HandleLoadPortA(adc_pin, load_pin); @@ -175,7 +184,7 @@ TEST(test_load, PortBHandlerDisabledHigh) MockADC_PushValue(HIGHTHRESH); setup_adc_expectations(adc_pin); - expect_portb_disabled(load_pin); + expect_portb_disabled(load_pin, true); Load_HandleLoadPortB(adc_pin, load_pin); } @@ -185,18 +194,30 @@ TEST(test_load, PortBHandlerDisabledLow) MockADC_PushValue(LOWTHRESH); setup_adc_expectations(adc_pin); - expect_portb_disabled(load_pin); + expect_portb_disabled(load_pin, false); Load_HandleLoadPortB(adc_pin, load_pin); } -TEST(test_load, PortBHandlerEnabledBelowTarget) +TEST(test_load, PortBHandlerEnabledRisingEdgeLO) { + //Start from the rising edge. + MockADC_PushValue(HYSTERESIS_LO - 1); + + setup_adc_expectations(adc_pin); + expect_portb_enabled(load_pin, false); + + Load_HandleLoadPortB(adc_pin, load_pin); +} + +TEST(test_load, PortBHandlerEnabledRisingEdgeHI) +{ + //Start from the rising edge. MockADC_PushValue(HYSTERESIS_HI - 1); setup_adc_expectations(adc_pin); - expect_portb_enabled(load_pin); + expect_portb_enabled(load_pin, true); Load_HandleLoadPortB(adc_pin, load_pin); } @@ -207,7 +228,7 @@ TEST(test_load, PortBHandlerDisabledAboveTarget) MockADC_PushValue(HYSTERESIS_HI); setup_adc_expectations(adc_pin); - expect_portb_disabled(load_pin); + expect_portb_disabled(load_pin, true); Load_HandleLoadPortB(adc_pin, load_pin); } @@ -218,10 +239,10 @@ TEST(test_load, PortBHandlerDisablesUntilPoweReset) MockADC_PushValue(HIGHTHRESH); setup_adc_expectations(adc_pin); - expect_portb_disabled(load_pin); + expect_portb_disabled(load_pin, true); setup_adc_expectations(adc_pin); - expect_portb_disabled(load_pin); + expect_portb_disabled(load_pin, false); Load_HandleLoadPortB(adc_pin, load_pin); Load_HandleLoadPortB(adc_pin, load_pin);