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.h
- Revision:
- 19:ee89eabe1fa2
- Parent:
- 13:1323e2c0b697
- Child:
- 22:4b5bf1c2e1ff
--- a/testing.h Mon Jun 13 10:49:48 2016 +0000 +++ b/testing.h Mon Jun 13 12:33:52 2016 +0000 @@ -1,7 +1,46 @@ +#ifndef __TESTING_H__ +#define __TESTING_H__ + + // #define RUN_TESTS #ifdef RUN_TESTS #define MAIN test_main #else #define MAIN real_main +#endif + +#define MOCK(N, F) static inline float N(int i,int t) {return (F);} + +#define DEF_MOCKS(A,B,C) MockSensorController temp(false,0,A); \ + MockSensorController prox(false,0,B); \ + MockSensorController salt(false,0,C); + +#include "mbed.h" + +class TestCase { + + public: + TestCase(const char *name, bool (*evaluate)(TestCase *tc)) { + this->name = name; + this->evaluate = evaluate; + this->failed = false; + + if(!failed && this->evaluate(this)) { + printf("TESTCASE %s PASSED!\r\n", this->name); + } else { + printf("TESTCASE %s FAILED!\r\n", this->name); + } + } + + void assertTrue(bool b, const char *error); + + + private: + const char *name; + bool failed; + bool (*evaluate)(TestCase *tc); + +}; + #endif \ No newline at end of file