-
Notifications
You must be signed in to change notification settings - Fork 0
/
UT.cpp
50 lines (42 loc) · 876 Bytes
/
UT.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "UT.h";
#include "pch.h"
std::vector<UT::function>* UT::caseList_ = nullptr;
void UT::printCaseInfo(const std::string& caseName)
{
std::cout << "TEST CASE :" << caseName << endl;
}
void UT::printErrorInfo()
{
std::cout << "ERROR_INFO:FILE=" << __FILE__ << " LINE=" << __LINE__ << std::endl;
}
void UT::addCase(function f)
{
if (caseList_ == nullptr)
{
caseList_ = new std::vector<function>;
}
caseList_->push_back(f);
}
void UT::runAllTest()
{
if (caseList_ == nullptr)
{
return;
}
uint32_t passed = 0;
try
{
for (auto& caseExcutor : *caseList_)
{
caseExcutor();
passed++;
}
}
catch (assertException)
{
printErrorInfo();
}
std::cout << "################################################" << std::endl;
std::cout << "Passed case is:" << passed << " Total case is :" << caseList_->size() << std::endl;
delete caseList_;
}