Specs
Beautiful C++ Test Framework
Loading...
Searching...
No Matches
GlobalInterface.h
Go to the documentation of this file.
1#pragma once
2
4#include <Specs/SpecDone.h>
5
7 /* Template */
8
9 inline void define_template_fn(std::string_view templateName, FunctionPointer<void()> body) {
11 templateName, std::make_unique<SpecCodeBlock>(std::move(body))
12 );
13 }
14
15 /* Group */
16
17 inline void define_group_fn(
18 std::string_view description, FunctionPointer<void()> body, bool removeUnderscores = false
19 ) {
21 description, std::make_unique<SpecCodeBlock>(std::move(body)), removeUnderscores
22 );
23 }
24
25 inline void define_group_fn(
26 std::string_view description, FunctionPointer<void(ISpecGroup*)> body,
27 bool removeUnderscores = false
28 ) {
30 description, std::make_unique<SpecCodeBlock>(std::move(body)), removeUnderscores
31 );
32 }
33
34 /* Test */
35
36 inline void define_test_fn(std::string_view description, FunctionPointer<void()> body) {
38 description, std::make_unique<SpecCodeBlock>(std::move(body))
39 );
40 }
41
42 inline void define_test_fn(std::string_view description, FunctionPointer<void(SpecDone)> body) {
44 description, std::make_unique<SpecCodeBlock>(std::move(body))
45 );
46 }
47
48 inline void define_test_fn(std::string_view description, FunctionPointer<void(ISpec*)> body) {
50 description, std::make_unique<SpecCodeBlock>(std::move(body))
51 );
52 }
53
54 inline void define_test_fn(
55 std::string_view description, FunctionPointer<void(ISpec*, SpecDone)> body
56 ) {
58 description, std::make_unique<SpecCodeBlock>(std::move(body))
59 );
60 }
61
62 inline void define_test_fn(
63 std::string_view description, FunctionPointer<void(ISpecGroup*)> body
64 ) {
66 description, std::make_unique<SpecCodeBlock>(std::move(body))
67 );
68 }
69
70 inline void define_test_fn(
71 std::string_view description, FunctionPointer<void(ISpecGroup*, SpecDone)> body
72 ) {
74 description, std::make_unique<SpecCodeBlock>(std::move(body))
75 );
76 }
77
78 inline void define_test_fn(
79 std::string_view description, FunctionPointer<void(ISpecGroup*, ISpec*)> body
80 ) {
82 description, std::make_unique<SpecCodeBlock>(std::move(body))
83 );
84 }
85
86 inline void define_test_fn(
87 std::string_view description, FunctionPointer<void(ISpecGroup*, ISpec*, SpecDone)> body
88 ) {
90 description, std::make_unique<SpecCodeBlock>(std::move(body))
91 );
92 }
93
94 /* Setup */
95
96 inline void define_setup_fn(FunctionPointer<void()> body) {
97 GlobalSpecGroup::instance().define_setup(std::make_unique<SpecCodeBlock>(std::move(body)));
98 }
99
100 inline void define_setup_fn(FunctionPointer<void(SpecDone)> body) {
101 GlobalSpecGroup::instance().define_setup(std::make_unique<SpecCodeBlock>(std::move(body)));
102 }
103
104 inline void define_setup_fn(FunctionPointer<void(ISpecComponent*, ISpec*)> body) {
105 GlobalSpecGroup::instance().define_setup(std::make_unique<SpecCodeBlock>(std::move(body)));
106 }
107
108 inline void define_setup_fn(FunctionPointer<void(ISpecComponent*, ISpec*, SpecDone)> body) {
109 GlobalSpecGroup::instance().define_setup(std::make_unique<SpecCodeBlock>(std::move(body)));
110 }
111
112 inline void define_setup_fn(FunctionPointer<void(ISpecGroup*, ISpecComponent*, ISpec*)> body) {
113 GlobalSpecGroup::instance().define_setup(std::make_unique<SpecCodeBlock>(std::move(body)));
114 }
115
116 inline void define_setup_fn(
117 FunctionPointer<void(ISpecGroup*, ISpecComponent*, ISpec*, SpecDone)> body
118 ) {
119 GlobalSpecGroup::instance().define_setup(std::make_unique<SpecCodeBlock>(std::move(body)));
120 }
121
122 /* Teardown */
123
124 inline void define_teardown_fn(FunctionPointer<void()> body) {
125 GlobalSpecGroup::instance().define_teardown(std::make_unique<SpecCodeBlock>(std::move(body))
126 );
127 }
128
129 inline void define_teardown_fn(FunctionPointer<void(SpecDone)> body) {
130 GlobalSpecGroup::instance().define_teardown(std::make_unique<SpecCodeBlock>(std::move(body))
131 );
132 }
133
134 inline void define_teardown_fn(FunctionPointer<void(ISpecComponent*, ISpec*)> body) {
135 GlobalSpecGroup::instance().define_teardown(std::make_unique<SpecCodeBlock>(std::move(body))
136 );
137 }
138
139 inline void define_teardown_fn(FunctionPointer<void(ISpecComponent*, ISpec*, SpecDone)> body) {
140 GlobalSpecGroup::instance().define_teardown(std::make_unique<SpecCodeBlock>(std::move(body))
141 );
142 }
143
144 inline void define_teardown_fn(FunctionPointer<void(ISpecGroup*, ISpecComponent*, ISpec*)> body
145 ) {
146 GlobalSpecGroup::instance().define_teardown(std::make_unique<SpecCodeBlock>(std::move(body))
147 );
148 }
149
151 FunctionPointer<void(ISpecGroup*, ISpecComponent*, ISpec*, SpecDone)> body
152 ) {
153 GlobalSpecGroup::instance().define_teardown(std::make_unique<SpecCodeBlock>(std::move(body))
154 );
155 }
156
157 /* One-time Setup */
158
159 inline void define_one_time_setup_fn(FunctionPointer<void()> body) {
161 std::make_unique<SpecCodeBlock>(std::move(body))
162 );
163 }
164
165 inline void define_one_time_setup_fn(FunctionPointer<void(SpecDone)> body) {
167 std::make_unique<SpecCodeBlock>(std::move(body))
168 );
169 }
170
171 inline void define_one_time_setup_fn(FunctionPointer<void(ISpecComponent*, ISpec*)> body) {
173 std::make_unique<SpecCodeBlock>(std::move(body))
174 );
175 }
176
178 FunctionPointer<void(ISpecComponent*, ISpec*, SpecDone)> body
179 ) {
181 std::make_unique<SpecCodeBlock>(std::move(body))
182 );
183 }
184
186 FunctionPointer<void(ISpecGroup*, ISpecComponent*, ISpec*)> body
187 ) {
189 std::make_unique<SpecCodeBlock>(std::move(body))
190 );
191 }
192
194 FunctionPointer<void(ISpecGroup*, ISpecComponent*, ISpec*, SpecDone)> body
195 ) {
197 std::make_unique<SpecCodeBlock>(std::move(body))
198 );
199 }
200
201 /* One-time Teardown */
202
203 inline void define_one_time_teardown_fn(FunctionPointer<void()> body) {
205 std::make_unique<SpecCodeBlock>(std::move(body))
206 );
207 }
208
209 inline void define_one_time_teardown_fn(FunctionPointer<void(SpecDone)> body) {
211 std::make_unique<SpecCodeBlock>(std::move(body))
212 );
213 }
214
215 inline void define_one_time_teardown_fn(FunctionPointer<void(ISpecComponent*, ISpec*)> body) {
217 std::make_unique<SpecCodeBlock>(std::move(body))
218 );
219 }
220
222 FunctionPointer<void(ISpecComponent*, ISpec*, SpecDone)> body
223 ) {
225 std::make_unique<SpecCodeBlock>(std::move(body))
226 );
227 }
228
230 FunctionPointer<void(ISpecGroup*, ISpecComponent*, ISpec*)> body
231 ) {
233 std::make_unique<SpecCodeBlock>(std::move(body))
234 );
235 }
236
238 FunctionPointer<void(ISpecGroup*, ISpecComponent*, ISpec*, SpecDone)> body
239 ) {
241 std::make_unique<SpecCodeBlock>(std::move(body))
242 );
243 }
244}
static GlobalSpecGroup & instance()
void define_group(std::string_view description, std::unique_ptr< SpecCodeBlock > codeBlock, bool removeUnderscores=false)
void define_teardown(std::unique_ptr< SpecCodeBlock > codeBlock, bool skip=false)
void define_spec(std::string_view description, std::unique_ptr< SpecCodeBlock > codeBlock, bool skip=false)
void define_setup(std::unique_ptr< SpecCodeBlock > codeBlock, bool skip=false)
void define_one_time_teardown(std::unique_ptr< SpecCodeBlock > codeBlock, bool skip=false)
void define_one_time_setup(std::unique_ptr< SpecCodeBlock > codeBlock, bool skip=false)
void define_template(std::string_view templateName, std::unique_ptr< SpecCodeBlock > codeBlock)
void define_setup_fn(FunctionPointer< void()> body)
void define_one_time_teardown_fn(FunctionPointer< void()> body)
void define_template_fn(std::string_view templateName, FunctionPointer< void()> body)
void define_group_fn(std::string_view description, FunctionPointer< void()> body, bool removeUnderscores=false)
void define_test_fn(std::string_view description, FunctionPointer< void()> body)
void define_teardown_fn(FunctionPointer< void()> body)
void define_one_time_setup_fn(FunctionPointer< void()> body)