this is a class for unit testing
This is an UnitTest library. You can use for POST.
UnitTest.cpp@0:b8a9485ea4f3, 2017-11-01 (annotated)
- Committer:
- sPymbed
- Date:
- Wed Nov 01 13:00:17 2017 +0000
- Revision:
- 0:b8a9485ea4f3
- Child:
- 2:543a87f138d2
initial version
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 | 0:b8a9485ea4f3 | 20 | while(true){} |
sPymbed | 0:b8a9485ea4f3 | 21 | } |
sPymbed | 0:b8a9485ea4f3 | 22 | testCount++; |
sPymbed | 0:b8a9485ea4f3 | 23 | } |