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
testing.cpp
- Committer:
- joran
- Date:
- 2016-06-13
- Revision:
- 24:eeef4009640d
- Parent:
- 21:17dd0d778bda
File content as of revision 24:eeef4009640d:
#include "mbed.h" #include "MockSensorController.h" #include "AlarmController.h" #include "testing.h" #define NUMBER_OF_SEC_BEFORE_CRITICAL_ALARM 30 void TestCase::assertTrue(bool b, const char *error) { if(!b) { printf("[%s] ASSERTION FAILED: %s\r\n", this->name, error); this->failed = true; } } MOCK(temp_mock1, 40.1); MOCK(salt_mock1, 6.1); MOCK(prox_mock1, 6.1); bool testTempDangerousHighAlarm(TestCase *tc) { DEF_MOCKS(temp_mock1, salt_mock1, prox_mock1); AlarmController alarm(false,0,&temp,&salt,&prox); for(int i = 0; i < NUMBER_OF_SEC_BEFORE_CRITICAL_ALARM+5; i++) { alarm.run(); Thread::wait(1000); } return alarm.is_error(); } int test_main() { TestCase t1("Test if alarm is raised when seconds when temp > 40", testTempDangerousHighAlarm); return 0; }