-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevilunit_selftest_module_contains_no_tests.i
160 lines (141 loc) · 5.51 KB
/
evilunit_selftest_module_contains_no_tests.i
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*
* This file is part of EvilUnit.
*
* EvilUnit is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* EvilUnit is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with EvilUnit. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Copyright Jon Chesterfield. All rights reserved.
*/
#include "EvilUnit.h"
static MODULE(set_containing_no_checks)
{
(void)evilunit_internal_state;
}
static MODULE(set_containing_passing_check)
{
CHECK(42==42);
}
static MODULE(set_containing_failing_check)
{
CHECK(42!=42);
}
static MODULE(set_containing_passing_then_failing_check)
{
CHECK(10==10);
CHECK(42!=42);
}
static MODULE(set_containing_failing_then_passing_check)
{
CHECK(42!=42);
CHECK(10==10);
}
static MODULE(set_containing_passing_then_passing_check)
{
CHECK(10==10);
CHECK(42==42);
}
static MODULE(set_containing_failing_then_failing_check)
{
CHECK(42!=42);
CHECK(10!=10);
}
static MODULE(set_containing_passing_then_failing_then_passing_check)
{
CHECK(10==10);
CHECK(42!=42);
CHECK(10==10);
}
static MODULE(set_containing_failing_then_passing_then_failing_check)
{
CHECK(42!=42);
CHECK(10==10);
CHECK(10!=10);
}
static MODULE(evilunit_selftest_module_contains_no_tests)
{
unsigned int test_to_run = 42; /* For these tests, any number will do */
struct evilunit_test_state answer = evilunit_make_test_state("");
struct evilunit_test_state expect = evilunit_make_test_state("");
TEST("module with no checks returns pass")
{
expect.result = evilunit_test_result_pass;
expect.testname_string = "set_containing_no_checks";
answer = evilunit_execute_specific_test(EVILUNIT_MODULE_MANGLE(set_containing_no_checks),test_to_run);
CHECK(evilunit_test_states_match(&expect,&answer));
}
TEST("module with passing check returns pass and the checked string")
{
expect.result = evilunit_test_result_pass;
expect.check_string = "42==42";
expect.testname_string = "set_containing_passing_check";
answer = evilunit_execute_specific_test(EVILUNIT_MODULE_MANGLE(set_containing_passing_check),test_to_run);
CHECK(evilunit_test_states_match(&expect,&answer));
}
TEST("module with failing check returns fail and the checked string")
{
expect.result = evilunit_test_result_fail;
expect.check_string = "42!=42";
expect.testname_string = "set_containing_failing_check";
answer = evilunit_execute_specific_test(EVILUNIT_MODULE_MANGLE(set_containing_failing_check),test_to_run);
CHECK(evilunit_test_states_match(&expect,&answer));
}
TEST("module with a passing then a failing test fails with the failed string")
{
expect.result = evilunit_test_result_fail;
expect.check_string = "42!=42";
expect.testname_string = "set_containing_passing_then_failing_check";
answer = evilunit_execute_specific_test(EVILUNIT_MODULE_MANGLE(set_containing_passing_then_failing_check),test_to_run);
CHECK(evilunit_test_states_match(&expect,&answer));
}
TEST("module with a failing then a passing test fails with the failed string")
{
expect.result = evilunit_test_result_fail;
expect.check_string = "42!=42";
expect.testname_string = "set_containing_failing_then_passing_check";
answer = evilunit_execute_specific_test(EVILUNIT_MODULE_MANGLE(set_containing_failing_then_passing_check),test_to_run);
CHECK(evilunit_test_states_match(&expect,&answer));
}
TEST("multiple passing checks, last wins")
{
expect.result = evilunit_test_result_pass;
expect.check_string = "42==42";
expect.testname_string = "set_containing_passing_then_passing_check";
answer = evilunit_execute_specific_test(EVILUNIT_MODULE_MANGLE(set_containing_passing_then_passing_check),test_to_run);
CHECK(evilunit_test_states_match(&expect,&answer));
}
TEST("multiple failing checks, first wins")
{
expect.result = evilunit_test_result_fail;
expect.check_string = "42!=42";
expect.testname_string = "set_containing_failing_then_failing_check";
answer = evilunit_execute_specific_test(EVILUNIT_MODULE_MANGLE(set_containing_failing_then_failing_check),test_to_run);
CHECK(evilunit_test_states_match(&expect,&answer));
}
TEST("module with {pass/fail/pass} tests fails with the failed string")
{
expect.result = evilunit_test_result_fail;
expect.check_string = "42!=42";
expect.testname_string = "set_containing_passing_then_failing_then_passing_check";
answer = evilunit_execute_specific_test(EVILUNIT_MODULE_MANGLE(set_containing_passing_then_failing_then_passing_check),test_to_run);
CHECK(evilunit_test_states_match(&expect,&answer));
}
TEST("module with {fail/pass/fail} first fail wins")
{
expect.result = evilunit_test_result_fail;
expect.check_string = "42!=42";
expect.testname_string = "set_containing_failing_then_passing_then_failing_check";
answer = evilunit_execute_specific_test(EVILUNIT_MODULE_MANGLE(set_containing_failing_then_passing_then_failing_check),test_to_run);
CHECK(evilunit_test_states_match(&expect,&answer));
}
}