]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/test/include/boost/test/unit_test_suite.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / test / include / boost / test / unit_test_suite.hpp
1 // (C) Copyright Gennadiy Rozental 2001.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5
6 // See http://www.boost.org/libs/test for the library home page.
7 //
8 /// @file
9 /// @brief Defines Unit Test Framework public API
10 // ***************************************************************************
11
12 #ifndef BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER
13 #define BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER
14
15 // Boost.Test
16 #include <boost/test/framework.hpp>
17 #include <boost/test/tree/auto_registration.hpp>
18 #include <boost/test/tree/test_case_template.hpp>
19 #include <boost/test/tree/global_fixture.hpp>
20
21
22 #include <boost/test/detail/suppress_warnings.hpp>
23
24
25 #include <boost/test/detail/pp_variadic.hpp>
26
27
28
29 //____________________________________________________________________________//
30
31 // ************************************************************************** //
32 // ************** Non-auto (explicit) test case interface ************** //
33 // ************************************************************************** //
34
35 #define BOOST_TEST_CASE( test_function ) \
36 boost::unit_test::make_test_case( boost::function<void ()>(test_function), \
37 BOOST_TEST_STRINGIZE( test_function ), \
38 __FILE__, __LINE__ )
39 #define BOOST_CLASS_TEST_CASE( test_function, tc_instance ) \
40 boost::unit_test::make_test_case( (test_function), \
41 BOOST_TEST_STRINGIZE( test_function ), \
42 __FILE__, __LINE__, tc_instance )
43
44 // ************************************************************************** //
45 // ************** BOOST_TEST_SUITE ************** //
46 // ************************************************************************** //
47
48 #define BOOST_TEST_SUITE( testsuite_name ) \
49 ( new boost::unit_test::test_suite( testsuite_name, __FILE__, __LINE__ ) )
50
51 // ************************************************************************** //
52 // ************** BOOST_AUTO_TEST_SUITE ************** //
53 // ************************************************************************** //
54
55 #define BOOST_AUTO_TEST_SUITE_WITH_DECOR( suite_name, decorators ) \
56 namespace suite_name { \
57 BOOST_AUTO_TU_REGISTRAR( suite_name )( \
58 BOOST_STRINGIZE( suite_name ), \
59 __FILE__, __LINE__, \
60 decorators ); \
61 /**/
62
63 #define BOOST_AUTO_TEST_SUITE_NO_DECOR( suite_name ) \
64 BOOST_AUTO_TEST_SUITE_WITH_DECOR( \
65 suite_name, \
66 boost::unit_test::decorator::collector::instance() ) \
67 /**/
68
69 #if BOOST_PP_VARIADICS
70 #define BOOST_AUTO_TEST_SUITE( ... ) \
71 BOOST_TEST_INVOKE_IF_N_ARGS( 1, \
72 BOOST_AUTO_TEST_SUITE_NO_DECOR, \
73 BOOST_AUTO_TEST_SUITE_WITH_DECOR, \
74 __VA_ARGS__) \
75 /**/
76
77 #else /* BOOST_PP_VARIADICS */
78
79 #define BOOST_AUTO_TEST_SUITE( suite_name ) \
80 BOOST_AUTO_TEST_SUITE_NO_DECOR( suite_name ) \
81 /**/
82
83
84 #endif /* BOOST_PP_VARIADICS */
85
86 // ************************************************************************** //
87 // ************** BOOST_FIXTURE_TEST_SUITE ************** //
88 // ************************************************************************** //
89
90 #define BOOST_FIXTURE_TEST_SUITE_WITH_DECOR(suite_name, F, decorators) \
91 BOOST_AUTO_TEST_SUITE_WITH_DECOR( suite_name, decorators ) \
92 typedef F BOOST_AUTO_TEST_CASE_FIXTURE; \
93 /**/
94
95 #define BOOST_FIXTURE_TEST_SUITE_NO_DECOR( suite_name, F ) \
96 BOOST_AUTO_TEST_SUITE_NO_DECOR( suite_name ) \
97 typedef F BOOST_AUTO_TEST_CASE_FIXTURE; \
98 /**/
99
100 #if BOOST_PP_VARIADICS
101
102 #define BOOST_FIXTURE_TEST_SUITE( ... ) \
103 BOOST_TEST_INVOKE_IF_N_ARGS( 2, \
104 BOOST_FIXTURE_TEST_SUITE_NO_DECOR, \
105 BOOST_FIXTURE_TEST_SUITE_WITH_DECOR, \
106 __VA_ARGS__) \
107 /**/
108
109 #else /* BOOST_PP_VARIADICS */
110
111 #define BOOST_FIXTURE_TEST_SUITE( suite_name, F ) \
112 BOOST_FIXTURE_TEST_SUITE_NO_DECOR( suite_name, F ) \
113 /**/
114
115
116 #endif /* BOOST_PP_VARIADICS */
117
118
119 // ************************************************************************** //
120 // ************** BOOST_AUTO_TEST_SUITE_END ************** //
121 // ************************************************************************** //
122
123 #define BOOST_AUTO_TEST_SUITE_END() \
124 BOOST_AUTO_TU_REGISTRAR( BOOST_JOIN( end_suite, __LINE__ ) )( 1 ); \
125 } \
126 /**/
127
128 // ************************************************************************** //
129 // ************** BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES ************** //
130 // ************************************************************************** //
131
132 /// @deprecated use decorator instead
133 #define BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES( test_name, n ) \
134 BOOST_TEST_DECORATOR( * boost::unit_test::expected_failures( n ) ) \
135 /**/
136
137 // ************************************************************************** //
138 // ************** BOOST_FIXTURE_TEST_CASE ************** //
139 // ************************************************************************** //
140
141 #define BOOST_FIXTURE_TEST_CASE_WITH_DECOR( test_name, F, decorators ) \
142 struct test_name : public F { void test_method(); }; \
143 \
144 static void BOOST_AUTO_TC_INVOKER( test_name )() \
145 { \
146 BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture entry."); \
147 test_name t; \
148 BOOST_TEST_CHECKPOINT('"' << #test_name << "\" entry."); \
149 t.test_method(); \
150 BOOST_TEST_CHECKPOINT('"' << #test_name << "\" exit."); \
151 } \
152 \
153 struct BOOST_AUTO_TC_UNIQUE_ID( test_name ) {}; \
154 \
155 BOOST_AUTO_TU_REGISTRAR( test_name )( \
156 boost::unit_test::make_test_case( \
157 &BOOST_AUTO_TC_INVOKER( test_name ), \
158 #test_name, __FILE__, __LINE__ ), \
159 decorators ); \
160 \
161 void test_name::test_method() \
162 /**/
163
164 #define BOOST_FIXTURE_TEST_CASE_NO_DECOR( test_name, F ) \
165 BOOST_FIXTURE_TEST_CASE_WITH_DECOR( test_name, F, \
166 boost::unit_test::decorator::collector::instance() ) \
167 /**/
168
169 #if BOOST_PP_VARIADICS
170
171 #define BOOST_FIXTURE_TEST_CASE( ... ) \
172 BOOST_TEST_INVOKE_IF_N_ARGS( 2, \
173 BOOST_FIXTURE_TEST_CASE_NO_DECOR, \
174 BOOST_FIXTURE_TEST_CASE_WITH_DECOR, \
175 __VA_ARGS__) \
176 /**/
177
178 #else /* BOOST_PP_VARIADICS */
179
180 #define BOOST_FIXTURE_TEST_CASE( test_name, F ) \
181 BOOST_FIXTURE_TEST_CASE_NO_DECOR(test_name, F) \
182 /**/
183
184
185 #endif /* BOOST_PP_VARIADICS */
186
187 // ************************************************************************** //
188 // ************** BOOST_AUTO_TEST_CASE ************** //
189 // ************************************************************************** //
190
191 #define BOOST_AUTO_TEST_CASE_NO_DECOR( test_name ) \
192 BOOST_FIXTURE_TEST_CASE_NO_DECOR( test_name, \
193 BOOST_AUTO_TEST_CASE_FIXTURE ) \
194 /**/
195
196 #define BOOST_AUTO_TEST_CASE_WITH_DECOR( test_name, decorators ) \
197 BOOST_FIXTURE_TEST_CASE_WITH_DECOR( test_name, \
198 BOOST_AUTO_TEST_CASE_FIXTURE, decorators ) \
199 /**/
200
201 #if BOOST_PP_VARIADICS
202
203 #define BOOST_AUTO_TEST_CASE( ... ) \
204 BOOST_TEST_INVOKE_IF_N_ARGS( 1, \
205 BOOST_AUTO_TEST_CASE_NO_DECOR, \
206 BOOST_AUTO_TEST_CASE_WITH_DECOR, \
207 __VA_ARGS__) \
208 /**/
209
210 #else /* BOOST_PP_VARIADICS */
211
212 #define BOOST_AUTO_TEST_CASE( test_name ) \
213 BOOST_AUTO_TEST_CASE_NO_DECOR( test_name ) \
214 /**/
215
216
217 #endif /* BOOST_PP_VARIADICS */
218
219 // ************************************************************************** //
220 // ************** BOOST_FIXTURE_TEST_CASE_TEMPLATE ************** //
221 // ************************************************************************** //
222
223 #define BOOST_FIXTURE_TEST_CASE_TEMPLATE( test_name, type_name, TL, F ) \
224 template<typename type_name> \
225 struct test_name : public F \
226 { void test_method(); }; \
227 \
228 struct BOOST_AUTO_TC_INVOKER( test_name ) { \
229 template<typename TestType> \
230 static void run( boost::type<TestType>* = 0 ) \
231 { \
232 BOOST_TEST_CHECKPOINT('"' << #test_name <<"\" fixture entry."); \
233 test_name<TestType> t; \
234 BOOST_TEST_CHECKPOINT('"' << #test_name << "\" entry."); \
235 t.test_method(); \
236 BOOST_TEST_CHECKPOINT('"' << #test_name << "\" exit."); \
237 } \
238 }; \
239 \
240 BOOST_AUTO_TU_REGISTRAR( test_name )( \
241 boost::unit_test::ut_detail::template_test_case_gen< \
242 BOOST_AUTO_TC_INVOKER( test_name ),TL >( \
243 BOOST_STRINGIZE( test_name ), __FILE__, __LINE__ ), \
244 boost::unit_test::decorator::collector::instance() ); \
245 \
246 template<typename type_name> \
247 void test_name<type_name>::test_method() \
248 /**/
249
250 // ************************************************************************** //
251 // ************** BOOST_AUTO_TEST_CASE_TEMPLATE ************** //
252 // ************************************************************************** //
253
254 #define BOOST_AUTO_TEST_CASE_TEMPLATE( test_name, type_name, TL ) \
255 BOOST_FIXTURE_TEST_CASE_TEMPLATE( test_name, type_name, TL, \
256 BOOST_AUTO_TEST_CASE_FIXTURE ) \
257 /**/
258
259 // ************************************************************************** //
260 // ************** BOOST_TEST_CASE_TEMPLATE ************** //
261 // ************************************************************************** //
262
263 #define BOOST_TEST_CASE_TEMPLATE( name, typelist ) \
264 boost::unit_test::ut_detail::template_test_case_gen<name,typelist>( \
265 BOOST_TEST_STRINGIZE( name ), __FILE__, __LINE__ ) \
266 /**/
267
268 // ************************************************************************** //
269 // ************** BOOST_TEST_CASE_TEMPLATE_FUNCTION ************** //
270 // ************************************************************************** //
271
272 #define BOOST_TEST_CASE_TEMPLATE_FUNCTION( name, type_name ) \
273 template<typename type_name> \
274 void BOOST_JOIN( name, _impl )( boost::type<type_name>* ); \
275 \
276 struct name { \
277 template<typename TestType> \
278 static void run( boost::type<TestType>* frwrd = 0 ) \
279 { \
280 BOOST_JOIN( name, _impl )( frwrd ); \
281 } \
282 }; \
283 \
284 template<typename type_name> \
285 void BOOST_JOIN( name, _impl )( boost::type<type_name>* ) \
286 /**/
287
288 // ************************************************************************** //
289 // ************** BOOST_GLOBAL_FIXTURE ************** //
290 // ************************************************************************** //
291
292 #define BOOST_GLOBAL_FIXTURE( F ) \
293 static boost::unit_test::ut_detail::global_fixture_impl<F> BOOST_JOIN( gf_, F ) \
294 /**/
295
296 // ************************************************************************** //
297 // ************** BOOST_TEST_DECORATOR ************** //
298 // ************************************************************************** //
299
300 #define BOOST_TEST_DECORATOR( D ) \
301 static boost::unit_test::decorator::collector const& \
302 BOOST_JOIN(decorator_collector,__LINE__) = D; \
303 /**/
304
305 // ************************************************************************** //
306 // ************** BOOST_AUTO_TEST_CASE_FIXTURE ************** //
307 // ************************************************************************** //
308
309 namespace boost { namespace unit_test { namespace ut_detail {
310
311 struct nil_t {};
312
313 } // namespace ut_detail
314 } // unit_test
315 } // namespace boost
316
317 // Intentionally is in global namespace, so that FIXTURE_TEST_SUITE can reset it in user code.
318 typedef ::boost::unit_test::ut_detail::nil_t BOOST_AUTO_TEST_CASE_FIXTURE;
319
320 // ************************************************************************** //
321 // ************** Auto registration facility helper macros ************** //
322 // ************************************************************************** //
323
324 #define BOOST_AUTO_TU_REGISTRAR( test_name ) \
325 static boost::unit_test::ut_detail::auto_test_unit_registrar \
326 BOOST_JOIN( BOOST_JOIN( test_name, _registrar ), __LINE__ ) \
327 /**/
328 #define BOOST_AUTO_TC_INVOKER( test_name ) BOOST_JOIN( test_name, _invoker )
329 #define BOOST_AUTO_TC_UNIQUE_ID( test_name ) BOOST_JOIN( test_name, _id )
330
331 // ************************************************************************** //
332 // ************** BOOST_TEST_MAIN ************** //
333 // ************************************************************************** //
334
335 #if defined(BOOST_TEST_MAIN)
336
337 #ifdef BOOST_TEST_ALTERNATIVE_INIT_API
338 bool init_unit_test() {
339 #else
340 ::boost::unit_test::test_suite*
341 init_unit_test_suite( int, char* [] ) {
342 #endif
343
344 #ifdef BOOST_TEST_MODULE
345 using namespace ::boost::unit_test;
346 assign_op( framework::master_test_suite().p_name.value, BOOST_TEST_STRINGIZE( BOOST_TEST_MODULE ).trim( "\"" ), 0 );
347
348 #endif
349
350 #ifdef BOOST_TEST_ALTERNATIVE_INIT_API
351 return true;
352 }
353 #else
354 return 0;
355 }
356 #endif
357
358 #endif
359
360 //____________________________________________________________________________//
361
362 #include <boost/test/detail/enable_warnings.hpp>
363
364
365 #endif // BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER
366