-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.cpp
77 lines (61 loc) · 1.14 KB
/
test.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "BUnit.h"
class WasRun : public TestCase {
bool wasRun;
bool wasSetUp;
bool wasTearDown;
public:
WasRun(void (WasRun::*name)())
: TestCase(static_cast<void (TestCase::*)()>(name)) {
wasSetUp = false;
wasRun = false;
}
void testMethod() {
wasRun = true;
}
void setUp(){
wasSetUp = true;
wasTearDown = false;
}
void tearDown() {
wasTearDown = true;
}
bool getWasRun() {
return wasRun;
}
bool getWasSetUp() {
return wasSetUp;
}
bool getWasTearDown() {
return wasTearDown;
}
};
class TestCaseTest : public TestCase {
private:
WasRun* test;
void setUp() {
test = new WasRun(&WasRun::testMethod);
}
void tearDown(){
delete(test);
}
public:
CLASSNAME(TestCaseTest)
void testRunning() {
assert(false == test->getWasRun());
test->run();
assert(true == test->getWasRun());
}
void testSetUp() {
test->run();
assert(true == test->getWasSetUp());
}
void testTearDown() {
test->run();
assert(true == test->getWasTearDown());
}
};
TESTS
ADD(TestCaseTest, testSetUp)
ADD(TestCaseTest, testTearDown)
ADD(TestCaseTest, testRunning)
RUN