this is a class for unit testing

Dependents:   OS

This is an UnitTest library. You can use for POST.

Committer:
sPymbed
Date:
Wed Sep 11 10:36:53 2019 +0000
Revision:
3:658ba851ab74
Parent:
2:543a87f138d2
Child:
4:13e7349640c0
fixed: assert problem

Who changed what in which revision?

UserRevisionLine numberNew 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 3:658ba851ab74 14 void UnitTest::assertOn(int a, int b){
sPymbed 0:b8a9485ea4f3 15 printf("Test %d: ", testCount);
sPymbed 3:658ba851ab74 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 }