-
Notifications
You must be signed in to change notification settings - Fork 0
/
UT.h
46 lines (38 loc) · 1.02 KB
/
UT.h
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
#pragma once
#include <string>
#include<vector>
#include<iostream>
#include<functional>
using namespace std;
class assertException { };
class UT
{
public:
using function = std::function<void(void)>;
static void printCaseInfo(const std::string& caseName);
static void printErrorInfo();
static void addCase(function f);
static void runAllTest();
static std::vector<function>*caseList_;
};
#define ASSERT_TRUE(CONDITION)\
do\
{ \
if(false==(CONDITION))throw assertException(); \
}while(0) \
#define TEST_CASE(NAME) \
class CASEEXCUTOR_##NAME \
{ \
public:\
static void runCase()\
{ \
UT::printCaseInfo(#NAME);\
testCase_##NAME(); \
} \
CASEEXCUTOR_##NAME()\
{ \
UT::addCase(std::bind(CASEEXCUTOR_##NAME::runCase));\
}\
static void testCase_##NAME(); \
};CASEEXCUTOR_##NAME NAME##instance; \
void CASEEXCUTOR_##NAME :: testCase_##NAME() \