Re-factored out code into setup(). Also added tests for the disabled pins.
This commit is contained in:
parent
1aca4d7876
commit
cb88baa7bb
|
@ -29,6 +29,8 @@ TEST_GROUP(test_load)
|
||||||
{
|
{
|
||||||
adc_pin = 4;
|
adc_pin = 4;
|
||||||
load_pin = 7;
|
load_pin = 7;
|
||||||
|
MockADC_ZeroIndex();
|
||||||
|
Load_SoftResetDisabledLoads();
|
||||||
}
|
}
|
||||||
void teardown()
|
void teardown()
|
||||||
{
|
{
|
||||||
|
@ -92,7 +94,6 @@ void expect_portb_enabled(uint8_t load_pin)
|
||||||
|
|
||||||
TEST(test_load, PortAHandlerDisabledHigh)
|
TEST(test_load, PortAHandlerDisabledHigh)
|
||||||
{
|
{
|
||||||
MockADC_ZeroIndex();
|
|
||||||
MockADC_PushValue(HIGHTHRESH);
|
MockADC_PushValue(HIGHTHRESH);
|
||||||
|
|
||||||
setup_adc_expectations(adc_pin);
|
setup_adc_expectations(adc_pin);
|
||||||
|
@ -103,7 +104,6 @@ TEST(test_load, PortAHandlerDisabledHigh)
|
||||||
|
|
||||||
TEST(test_load, PortAHandlerDisabledLow)
|
TEST(test_load, PortAHandlerDisabledLow)
|
||||||
{
|
{
|
||||||
MockADC_ZeroIndex();
|
|
||||||
MockADC_PushValue(LOWTHRESH);
|
MockADC_PushValue(LOWTHRESH);
|
||||||
|
|
||||||
setup_adc_expectations(adc_pin);
|
setup_adc_expectations(adc_pin);
|
||||||
|
@ -114,7 +114,6 @@ TEST(test_load, PortAHandlerDisabledLow)
|
||||||
|
|
||||||
TEST(test_load, PortAHandlerEnabledBelowTarget)
|
TEST(test_load, PortAHandlerEnabledBelowTarget)
|
||||||
{
|
{
|
||||||
MockADC_ZeroIndex();
|
|
||||||
MockADC_PushValue(HYSTERESIS - 1);
|
MockADC_PushValue(HYSTERESIS - 1);
|
||||||
|
|
||||||
setup_adc_expectations(adc_pin);
|
setup_adc_expectations(adc_pin);
|
||||||
|
@ -125,7 +124,6 @@ TEST(test_load, PortAHandlerEnabledBelowTarget)
|
||||||
|
|
||||||
TEST(test_load, PortAHandlerDisabledAboveTarget)
|
TEST(test_load, PortAHandlerDisabledAboveTarget)
|
||||||
{
|
{
|
||||||
MockADC_ZeroIndex();
|
|
||||||
MockADC_PushValue(HYSTERESIS);
|
MockADC_PushValue(HYSTERESIS);
|
||||||
|
|
||||||
setup_adc_expectations(adc_pin);
|
setup_adc_expectations(adc_pin);
|
||||||
|
@ -134,10 +132,24 @@ TEST(test_load, PortAHandlerDisabledAboveTarget)
|
||||||
Load_HandleLoadPortA(adc_pin, load_pin);
|
Load_HandleLoadPortA(adc_pin, load_pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(test_load, PortAHandlerDisablesUntilPoweReset)
|
||||||
|
{
|
||||||
|
MockADC_PushValue(HYSTERESIS - 1);
|
||||||
|
MockADC_PushValue(HIGHTHRESH);
|
||||||
|
|
||||||
|
setup_adc_expectations(adc_pin);
|
||||||
|
expect_porta_disabled(load_pin);
|
||||||
|
|
||||||
|
setup_adc_expectations(adc_pin);
|
||||||
|
expect_porta_disabled(load_pin);
|
||||||
|
|
||||||
|
Load_HandleLoadPortA(adc_pin, load_pin);
|
||||||
|
Load_HandleLoadPortA(adc_pin, load_pin);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(test_load, PortBHandlerDisabledHigh)
|
TEST(test_load, PortBHandlerDisabledHigh)
|
||||||
{
|
{
|
||||||
MockADC_ZeroIndex();
|
|
||||||
MockADC_PushValue(HIGHTHRESH);
|
MockADC_PushValue(HIGHTHRESH);
|
||||||
|
|
||||||
setup_adc_expectations(adc_pin);
|
setup_adc_expectations(adc_pin);
|
||||||
|
@ -148,7 +160,6 @@ TEST(test_load, PortBHandlerDisabledHigh)
|
||||||
|
|
||||||
TEST(test_load, PortBHandlerDisabledLow)
|
TEST(test_load, PortBHandlerDisabledLow)
|
||||||
{
|
{
|
||||||
MockADC_ZeroIndex();
|
|
||||||
MockADC_PushValue(LOWTHRESH);
|
MockADC_PushValue(LOWTHRESH);
|
||||||
|
|
||||||
setup_adc_expectations(adc_pin);
|
setup_adc_expectations(adc_pin);
|
||||||
|
@ -160,7 +171,6 @@ TEST(test_load, PortBHandlerDisabledLow)
|
||||||
|
|
||||||
TEST(test_load, PortBHandlerEnabledBelowTarget)
|
TEST(test_load, PortBHandlerEnabledBelowTarget)
|
||||||
{
|
{
|
||||||
MockADC_ZeroIndex();
|
|
||||||
MockADC_PushValue(HYSTERESIS - 1);
|
MockADC_PushValue(HYSTERESIS - 1);
|
||||||
|
|
||||||
setup_adc_expectations(adc_pin);
|
setup_adc_expectations(adc_pin);
|
||||||
|
@ -172,7 +182,6 @@ TEST(test_load, PortBHandlerEnabledBelowTarget)
|
||||||
|
|
||||||
TEST(test_load, PortBHandlerDisabledAboveTarget)
|
TEST(test_load, PortBHandlerDisabledAboveTarget)
|
||||||
{
|
{
|
||||||
MockADC_ZeroIndex();
|
|
||||||
MockADC_PushValue(HYSTERESIS);
|
MockADC_PushValue(HYSTERESIS);
|
||||||
|
|
||||||
setup_adc_expectations(adc_pin);
|
setup_adc_expectations(adc_pin);
|
||||||
|
@ -180,3 +189,18 @@ TEST(test_load, PortBHandlerDisabledAboveTarget)
|
||||||
|
|
||||||
Load_HandleLoadPortB(adc_pin, load_pin);
|
Load_HandleLoadPortB(adc_pin, load_pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(test_load, PortBHandlerDisablesUntilPoweReset)
|
||||||
|
{
|
||||||
|
MockADC_PushValue(HYSTERESIS - 1);
|
||||||
|
MockADC_PushValue(HIGHTHRESH);
|
||||||
|
|
||||||
|
setup_adc_expectations(adc_pin);
|
||||||
|
expect_portb_disabled(load_pin);
|
||||||
|
|
||||||
|
setup_adc_expectations(adc_pin);
|
||||||
|
expect_portb_disabled(load_pin);
|
||||||
|
|
||||||
|
Load_HandleLoadPortB(adc_pin, load_pin);
|
||||||
|
Load_HandleLoadPortB(adc_pin, load_pin);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue