this is a class for unit testing
This is an UnitTest library. You can use for POST.
UnitTest.cpp@2:543a87f138d2, 2017-11-06 (annotated)
- Committer:
- sPymbed
- Date:
- Mon Nov 06 15:44:25 2017 +0000
- Revision:
- 2:543a87f138d2
- Parent:
- 0:b8a9485ea4f3
- Child:
- 3:658ba851ab74
added: wait(1) in while loop for stability
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sPymbed | 0:b8a9485ea4f3 | 1 | #include "UnitTest.h" |
sPymbed | 0:b8a9485ea4f3 | 2 | |
sPymbed | 0:b8a9485ea4f3 | 3 | void UnitTest::start(){ |
sPymbed | 0:b8a9485ea4f3 | 4 | testCount = 1; |
sPymbed | 0:b8a9485ea4f3 | 5 | printf("UnitTest:\n\n"); |
sPymbed | 0:b8a9485ea4f3 | 6 | unitTest.start(); |
sPymbed | 0:b8a9485ea4f3 | 7 | } |
sPymbed | 0:b8a9485ea4f3 | 8 | |
sPymbed | 0:b8a9485ea4f3 | 9 | void UnitTest::end(){ |
sPymbed | 0:b8a9485ea4f3 | 10 | unitTest.stop(); |
sPymbed | 0:b8a9485ea4f3 | 11 | printf("End: %fs\n", unitTest.read()); |
sPymbed | 0:b8a9485ea4f3 | 12 | } |
sPymbed | 0:b8a9485ea4f3 | 13 | |
sPymbed | 0:b8a9485ea4f3 | 14 | void UnitTest::assert(int a, int b){ |
sPymbed | 0:b8a9485ea4f3 | 15 | printf("Test %d: ", testCount); |
sPymbed | 0:b8a9485ea4f3 | 16 | if(a==b){ |
sPymbed | 0:b8a9485ea4f3 | 17 | printf("Passed\n\n"); |
sPymbed | 0:b8a9485ea4f3 | 18 | } else { |
sPymbed | 0:b8a9485ea4f3 | 19 | printf("Failed\n"); |
sPymbed | 2:543a87f138d2 | 20 | while(true){ |
sPymbed | 2:543a87f138d2 | 21 | wait(1); |
sPymbed | 2:543a87f138d2 | 22 | } |
sPymbed | 0:b8a9485ea4f3 | 23 | } |
sPymbed | 0:b8a9485ea4f3 | 24 | testCount++; |
sPymbed | 0:b8a9485ea4f3 | 25 | } |