Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed DRV88255 TextLCD Ping mbed-rtos
Diff: testing.cpp
- Revision:
- 36:8aeb014bd651
- Parent:
- 31:1c50d2d8c155
- Child:
- 37:2d9480c498c9
--- a/testing.cpp Tue Jun 14 15:31:30 2016 +0000 +++ b/testing.cpp Tue Jun 14 15:54:12 2016 +0000 @@ -2,6 +2,7 @@ #include "MockSensorController.h" #include "AlarmController.h" +#include "PIDController.h" #include "testing.h" #define NUMBER_OF_SEC_BEFORE_CRITICAL_ALARM 30 @@ -55,14 +56,24 @@ MOCK(salinity_mock4, 12.1+(t*0.00001)); ALARM_TEST(testSalinityDangerousHighAlarm, temp_mock_steady, salinity_mock4, prox_mock_steady, NUMBER_OF_SEC_BEFORE_CRITICAL_ALARM+1); +MOCK(temp_heating_mock, 29+0.001*t); bool testTemperatureHeater(TestCase *tc) { - // TODO + DEF_MOCKS(temp_heating_mock, salt_mock_steady, prox_mock_steady); + PIDController pidc(false,0,&temp,&salt,&prox); + + tc->assert(pidc.is_heating(), "PIDController should be heating at temp=29!"); + Thread::wait(1000); + tc->assert(pidc.is_heating(), "PIDController should be heating at temp=30!"); + Thread::wait(1000); + tc->assert(pidc.is_heating(), "PIDController should be heating at temp=31!"); + Thread::wait(1500); + tc->assert(!pidc.is_heating(), "PIDController shouldn't be heating at temp=32.5!"); + return true; } - int test_main() { START_TESTS(); @@ -77,8 +88,7 @@ TESTCASE("Test if alarm is raised when salinity < 3 for 30 seconds", testSalinityDangerousLowAlarm); TESTCASE("Test if alarm is raised when salinity > 12 for 30 seconds", testSalinityDangerousHighAlarm); - // TODO - //TESTCASE("Test if heater gets enabled at < 32 and disabled at 32+", testTemperatureHeater); + TESTCASE("Test if heater gets enabled at < 32 and disabled at 32+", testTemperatureHeater); TESTCASE("Test if alarm is raised when water tank level in range 900-1000 ml for 5 minutes", testAlarmWaterOverflowUndesired); TESTCASE("Test if alarm is raised when water tank level is 1001 for 30 seconds", testAlarmWaterOverflowCritical);