-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesting.h
39 lines (25 loc) · 828 Bytes
/
testing.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
#ifndef TESTING_H_
#define TESTING_H_
#pragma once
typedef int (TestRunFunc)();
void RegisterTest(const char* name, const char* file, int line, TestRunFunc* testFunc);
struct _TestRegisterObject {
_TestRegisterObject(const char* name, const char* file, int line, TestRunFunc* testFunc) {
RegisterTest(name, file, line, testFunc);
}
};
#define CREATE_TEST_CASE_INT(name, cnt) \
int _BNS_TEST_FUNC_ ## cnt (); \
_TestRegisterObject _bns_test_register ## cnt(name, __FILE__, __LINE__, _BNS_TEST_FUNC_ ## cnt); \
int _BNS_TEST_FUNC_ ## cnt ()
#define CREATE_TEST_CASE_INT_(name, cnt) CREATE_TEST_CASE_INT(name, cnt)
#define CREATE_TEST_CASE(name) CREATE_TEST_CASE_INT_(name, __COUNTER__)
/*
Usage:
CREATE_TEST_CASE("Check numbers") {
int x = 3 + 5;
ASSERT(x == 8);
}
*/
int RunAllTests();
#endif