Updated same tests for the port b
This commit is contained in:
parent
0e7deea6e7
commit
c2a5e94bae
|
@ -82,16 +82,26 @@ void expect_porta_enabled(uint8_t load_pin, bool output_level)
|
||||||
.withUnsignedIntParameter("bit_num", load_pin);
|
.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")
|
mock().expectOneCall("RegEdit_ClearBit")
|
||||||
.withPointerParameter("reg", (void *) &PORTB.OUT)
|
.withPointerParameter("reg", (void *) &PORTB.OUT)
|
||||||
.withUnsignedIntParameter("bit_num", load_pin);
|
.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")
|
mock().expectOneCall("RegEdit_SetBit")
|
||||||
.withPointerParameter("reg", (void *) &PORTB.DIR)
|
.withPointerParameter("reg", (void *) &PORTB.DIR)
|
||||||
.withUnsignedIntParameter("bit_num", load_pin);
|
.withUnsignedIntParameter("bit_num", load_pin);
|
||||||
|
@ -127,7 +137,6 @@ TEST(test_load, PortAHandlerEnabledRisingEdgeLO)
|
||||||
MockADC_PushValue(HYSTERESIS_LO - 1);
|
MockADC_PushValue(HYSTERESIS_LO - 1);
|
||||||
|
|
||||||
setup_adc_expectations(adc_pin);
|
setup_adc_expectations(adc_pin);
|
||||||
|
|
||||||
expect_porta_enabled(load_pin, false);
|
expect_porta_enabled(load_pin, false);
|
||||||
|
|
||||||
Load_HandleLoadPortA(adc_pin, load_pin);
|
Load_HandleLoadPortA(adc_pin, load_pin);
|
||||||
|
@ -175,7 +184,7 @@ TEST(test_load, PortBHandlerDisabledHigh)
|
||||||
MockADC_PushValue(HIGHTHRESH);
|
MockADC_PushValue(HIGHTHRESH);
|
||||||
|
|
||||||
setup_adc_expectations(adc_pin);
|
setup_adc_expectations(adc_pin);
|
||||||
expect_portb_disabled(load_pin);
|
expect_portb_disabled(load_pin, true);
|
||||||
|
|
||||||
Load_HandleLoadPortB(adc_pin, load_pin);
|
Load_HandleLoadPortB(adc_pin, load_pin);
|
||||||
}
|
}
|
||||||
|
@ -185,18 +194,30 @@ TEST(test_load, PortBHandlerDisabledLow)
|
||||||
MockADC_PushValue(LOWTHRESH);
|
MockADC_PushValue(LOWTHRESH);
|
||||||
|
|
||||||
setup_adc_expectations(adc_pin);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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);
|
MockADC_PushValue(HYSTERESIS_HI - 1);
|
||||||
|
|
||||||
setup_adc_expectations(adc_pin);
|
setup_adc_expectations(adc_pin);
|
||||||
expect_portb_enabled(load_pin);
|
expect_portb_enabled(load_pin, true);
|
||||||
|
|
||||||
Load_HandleLoadPortB(adc_pin, load_pin);
|
Load_HandleLoadPortB(adc_pin, load_pin);
|
||||||
}
|
}
|
||||||
|
@ -207,7 +228,7 @@ TEST(test_load, PortBHandlerDisabledAboveTarget)
|
||||||
MockADC_PushValue(HYSTERESIS_HI);
|
MockADC_PushValue(HYSTERESIS_HI);
|
||||||
|
|
||||||
setup_adc_expectations(adc_pin);
|
setup_adc_expectations(adc_pin);
|
||||||
expect_portb_disabled(load_pin);
|
expect_portb_disabled(load_pin, true);
|
||||||
|
|
||||||
Load_HandleLoadPortB(adc_pin, load_pin);
|
Load_HandleLoadPortB(adc_pin, load_pin);
|
||||||
}
|
}
|
||||||
|
@ -218,10 +239,10 @@ TEST(test_load, PortBHandlerDisablesUntilPoweReset)
|
||||||
MockADC_PushValue(HIGHTHRESH);
|
MockADC_PushValue(HIGHTHRESH);
|
||||||
|
|
||||||
setup_adc_expectations(adc_pin);
|
setup_adc_expectations(adc_pin);
|
||||||
expect_portb_disabled(load_pin);
|
expect_portb_disabled(load_pin, true);
|
||||||
|
|
||||||
setup_adc_expectations(adc_pin);
|
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);
|
||||||
Load_HandleLoadPortB(adc_pin, load_pin);
|
Load_HandleLoadPortB(adc_pin, load_pin);
|
||||||
|
|
Loading…
Reference in New Issue