Updated tests for `Load_HandleLoadPortB()`
This commit is contained in:
parent
e03a78a17b
commit
7ca25f5177
|
@ -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,11 @@ 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_ZeroIndex();
|
||||||
MockADC_PushValue(LOWTHRESH + 1);
|
MockADC_PushValue(HIGHTHRESH);
|
||||||
MockADC_PushValue(HIGHTHRESH - 1);
|
|
||||||
MockADC_PushValue(HYSTERESIS - 1);
|
|
||||||
*/
|
|
||||||
|
|
||||||
setup_adc_expectations(adc_pin);
|
setup_adc_expectations(adc_pin);
|
||||||
expect_portb_disabled(load_pin);
|
expect_portb_disabled(load_pin);
|
||||||
|
@ -137,6 +146,41 @@ TEST(test_load, PortBHandlerSuccess)
|
||||||
Load_HandleLoadPortB(adc_pin, 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_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);
|
||||||
|
expect_portb_disabled(load_pin);
|
||||||
|
|
||||||
|
Load_HandleLoadPortB(adc_pin, load_pin);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(test_load, HighThreshValid)
|
TEST(test_load, HighThreshValid)
|
||||||
{
|
{
|
||||||
bool result = is_valid_load(HIGHTHRESH);
|
bool result = is_valid_load(HIGHTHRESH);
|
||||||
|
|
Loading…
Reference in New Issue