48 lines
849 B
C++
48 lines
849 B
C++
#include "UTest.hpp"
|
|
|
|
#include <stdio.h>
|
|
|
|
/*static*/ const char* UTest::sp_pstr = "pass";
|
|
/*static*/ const char* UTest::sp_fstr = "fail";
|
|
|
|
/*static*/ unsigned long int UTest::s_pass = 0;
|
|
/*static*/ unsigned long int UTest::s_fail = 0;
|
|
|
|
UTest::UTest( const char* tstr )
|
|
: m_pass(0), m_fail(0)
|
|
{
|
|
init(tstr);
|
|
}
|
|
|
|
void UTest::init( const char* tstr )
|
|
{
|
|
mp_tstr = tstr;
|
|
m_pass = m_fail = 0;
|
|
}
|
|
|
|
void UTest::test( const char* description, const int flag )
|
|
{
|
|
const char * pf = nullptr;
|
|
if (flag) {
|
|
pf = sp_pstr;
|
|
++m_pass;
|
|
++s_pass;
|
|
} else {
|
|
pf = sp_fstr;
|
|
++m_fail;
|
|
++s_fail;
|
|
}
|
|
printf("%s: %s -> %s\n", mp_tstr, description, pf);
|
|
}
|
|
|
|
void UTest::report() const
|
|
{
|
|
printf("%s: pass: %ld, fail: %ld\n", mp_tstr, m_pass, m_fail);
|
|
}
|
|
|
|
/*static*/ void UTest::OverAllReport()
|
|
{
|
|
printf("\nOver All pass: %ld, fail: %ld\n", s_pass, s_fail);
|
|
}
|
|
|