]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/test/tools/interface.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / test / tools / interface.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 : $RCSfile$
9 //
10 // Version : $Revision: 81247 $
11 //
12 // Description : contains definition for all test tools in test toolbox
13 // ***************************************************************************
14
15 #ifndef BOOST_TEST_TOOLS_INTERFACE_HPP_111712GER
16 #define BOOST_TEST_TOOLS_INTERFACE_HPP_111712GER
17
18 // Boost.Test
19 #include <boost/test/unit_test_log.hpp>
20 #ifdef BOOST_TEST_TOOLS_DEBUGGABLE
21 #include <boost/test/debug.hpp>
22 #endif
23 #ifdef BOOST_NO_CXX11_AUTO_DECLARATIONS
24 #include <boost/test/tools/detail/expression_holder.hpp>
25 #endif
26
27 #include <boost/test/detail/pp_variadic.hpp>
28
29 #ifdef BOOST_TEST_NO_OLD_TOOLS
30 #include <boost/preprocessor/seq/to_tuple.hpp>
31
32 #include <iterator>
33 #endif // BOOST_TEST_NO_OLD_TOOLS
34
35 #include <boost/test/detail/suppress_warnings.hpp>
36
37 //____________________________________________________________________________//
38
39 // ************************************************************************** //
40 // ************** BOOST_TEST_<level> ************** //
41 // ************************************************************************** //
42
43 #define BOOST_TEST_BUILD_ASSERTION( P ) \
44 (::boost::test_tools::assertion::seed()->*P) \
45 /**/
46
47 //____________________________________________________________________________//
48
49 // Implementation based on direct predicate evaluation
50 #define BOOST_TEST_TOOL_DIRECT_IMPL( P, level, M ) \
51 do { \
52 ::boost::test_tools::assertion_result res = (P); \
53 report_assertion( \
54 res, \
55 BOOST_TEST_LAZY_MSG( M ), \
56 BOOST_TEST_L(__FILE__), \
57 static_cast<std::size_t>(__LINE__), \
58 ::boost::test_tools::tt_detail::level, \
59 ::boost::test_tools::tt_detail::CHECK_MSG, \
60 0 ); \
61 } while( ::boost::test_tools::tt_detail::dummy_cond() ) \
62 /**/
63
64 //____________________________________________________________________________//
65
66 // Implementation based on expression template construction
67 #define BOOST_TEST_TOOL_ET_IMPL( P, level ) \
68 do { \
69 BOOST_TEST_PASSPOINT(); \
70 \
71 ::boost::test_tools::tt_detail:: \
72 report_assertion( \
73 BOOST_TEST_BUILD_ASSERTION( P ).evaluate(), \
74 BOOST_TEST_LAZY_MSG( BOOST_TEST_STRINGIZE( P ) ), \
75 BOOST_TEST_L(__FILE__), \
76 static_cast<std::size_t>(__LINE__), \
77 ::boost::test_tools::tt_detail::level, \
78 ::boost::test_tools::tt_detail::CHECK_BUILT_ASSERTION, \
79 0 ); \
80 } while( ::boost::test_tools::tt_detail::dummy_cond() ) \
81 /**/
82
83 //____________________________________________________________________________//
84
85 // Implementation based on expression template construction with extra tool arguments
86 #define BOOST_TEST_TOOL_ET_IMPL_EX( P, level, arg ) \
87 do { \
88 BOOST_TEST_PASSPOINT(); \
89 \
90 ::boost::test_tools::tt_detail:: \
91 report_assertion( \
92 ::boost::test_tools::tt_detail::assertion_evaluate( \
93 BOOST_TEST_BUILD_ASSERTION( P ) ) \
94 << arg, \
95 ::boost::test_tools::tt_detail::assertion_text( \
96 BOOST_TEST_LAZY_MSG( BOOST_TEST_STRINGIZE(P) ), \
97 BOOST_TEST_LAZY_MSG( arg ) ), \
98 BOOST_TEST_L(__FILE__), \
99 static_cast<std::size_t>(__LINE__), \
100 ::boost::test_tools::tt_detail::level, \
101 ::boost::test_tools::tt_detail::assertion_type() \
102 << arg, \
103 0 ); \
104 } while( ::boost::test_tools::tt_detail::dummy_cond() ) \
105 /**/
106
107 //____________________________________________________________________________//
108
109 #ifdef BOOST_TEST_TOOLS_UNDER_DEBUGGER
110
111 #define BOOST_TEST_TOOL_UNIV( level, P ) \
112 BOOST_TEST_TOOL_DIRECT_IMPL( P, level, BOOST_TEST_STRINGIZE( P ) ) \
113 /**/
114
115 #define BOOST_TEST_TOOL_UNIV_EX( level, P, ... ) \
116 BOOST_TEST_TOOL_UNIV( level, P ) \
117 /**/
118
119 #elif defined(BOOST_TEST_TOOLS_DEBUGGABLE)
120
121 #define BOOST_TEST_TOOL_UNIV( level, P ) \
122 do { \
123 if( ::boost::debug::under_debugger() ) \
124 BOOST_TEST_TOOL_DIRECT_IMPL( P, level, BOOST_TEST_STRINGIZE( P ) ); \
125 else \
126 BOOST_TEST_TOOL_ET_IMPL( P, level ); \
127 } while( ::boost::test_tools::tt_detail::dummy_cond() ) \
128 /**/
129
130 #define BOOST_TEST_TOOL_UNIV_EX( level, P, ... ) \
131 BOOST_TEST_TOOL_UNIV( level, P ) \
132 /**/
133
134 #else
135
136 #define BOOST_TEST_TOOL_UNIV( level, P ) \
137 BOOST_TEST_TOOL_ET_IMPL( P, level ) \
138 /**/
139
140 #define BOOST_TEST_TOOL_UNIV_EX( level, P, ... ) \
141 BOOST_TEST_TOOL_ET_IMPL_EX( P, level, __VA_ARGS__ ) \
142 /**/
143
144 #endif
145
146 //____________________________________________________________________________//
147
148 #define BOOST_TEST_WARN( ... ) BOOST_TEST_INVOKE_IF_N_ARGS( \
149 2, BOOST_TEST_TOOL_UNIV, BOOST_TEST_TOOL_UNIV_EX, WARN, __VA_ARGS__ ) \
150 /**/
151 #define BOOST_TEST_CHECK( ... ) BOOST_TEST_INVOKE_IF_N_ARGS( \
152 2, BOOST_TEST_TOOL_UNIV, BOOST_TEST_TOOL_UNIV_EX, CHECK, __VA_ARGS__ ) \
153 /**/
154 #define BOOST_TEST_REQUIRE( ... ) BOOST_TEST_INVOKE_IF_N_ARGS( \
155 2, BOOST_TEST_TOOL_UNIV, BOOST_TEST_TOOL_UNIV_EX, REQUIRE, __VA_ARGS__ )\
156 /**/
157
158 #define BOOST_TEST( ... ) BOOST_TEST_INVOKE_IF_N_ARGS( \
159 2, BOOST_TEST_TOOL_UNIV, BOOST_TEST_TOOL_UNIV_EX, CHECK, __VA_ARGS__ ) \
160 /**/
161
162 //____________________________________________________________________________//
163
164 #define BOOST_TEST_ERROR( M ) BOOST_CHECK_MESSAGE( false, M )
165 #define BOOST_TEST_FAIL( M ) BOOST_REQUIRE_MESSAGE( false, M )
166
167 //____________________________________________________________________________//
168
169 #define BOOST_TEST_IS_DEFINED( symb ) ::boost::test_tools::tt_detail::is_defined_impl( symb, BOOST_STRINGIZE(= symb) )
170
171 //____________________________________________________________________________//
172
173 #ifdef BOOST_TEST_NO_OLD_TOOLS
174
175 #ifdef BOOST_TEST_TOOLS_UNDER_DEBUGGER
176
177 #define BOOST_CHECK_THROW_IMPL(S, E, TL, Ppassed, Mpassed, Pcaught, Mcaught)\
178 do { try { \
179 S; \
180 BOOST_TEST_TOOL_DIRECT_IMPL( Ppassed, TL, Mpassed ); \
181 } catch( E ) { \
182 BOOST_TEST_TOOL_DIRECT_IMPL( Pcaught, TL, Mcaught ); \
183 }} while( ::boost::test_tools::tt_detail::dummy_cond() ) \
184 /**/
185
186 #elif defined(BOOST_TEST_TOOLS_DEBUGGABLE)
187
188 #define BOOST_CHECK_THROW_IMPL(S, E, TL, Ppassed, Mpassed, Pcaught, Mcaught)\
189 do { try { \
190 if( ::boost::debug::under_debugger() ) \
191 BOOST_TEST_PASSPOINT(); \
192 S; \
193 BOOST_TEST_TOOL_DIRECT_IMPL( Ppassed, TL, Mpassed ); \
194 } catch( E ) { \
195 BOOST_TEST_TOOL_DIRECT_IMPL( Pcaught, TL, Mcaught ); \
196 }} while( ::boost::test_tools::tt_detail::dummy_cond() ) \
197 /**/
198
199 #else
200
201 #define BOOST_CHECK_THROW_IMPL(S, E, TL, Ppassed, Mpassed, Pcaught, Mcaught)\
202 do { try { \
203 BOOST_TEST_PASSPOINT(); \
204 S; \
205 BOOST_TEST_TOOL_DIRECT_IMPL( Ppassed, TL, Mpassed ); \
206 } catch( E ) { \
207 BOOST_TEST_TOOL_DIRECT_IMPL( Pcaught, TL, Mcaught ); \
208 }} while( ::boost::test_tools::tt_detail::dummy_cond() ) \
209 /**/
210
211 #endif
212
213 //____________________________________________________________________________//
214
215 #define BOOST_WARN_THROW( S, E ) \
216 BOOST_CHECK_THROW_IMPL(S, E const&, WARN, \
217 false, "exception " BOOST_STRINGIZE(E) " is expected", \
218 true , "exception " BOOST_STRINGIZE(E) " is caught" ) \
219 /**/
220 #define BOOST_CHECK_THROW( S, E ) \
221 BOOST_CHECK_THROW_IMPL(S, E const&, CHECK, \
222 false, "exception " BOOST_STRINGIZE(E) " is expected", \
223 true , "exception " BOOST_STRINGIZE(E) " is caught" ) \
224 /**/
225 #define BOOST_REQUIRE_THROW( S, E ) \
226 BOOST_CHECK_THROW_IMPL(S, E const&, REQUIRE, \
227 false, "exception " BOOST_STRINGIZE(E) " is expected", \
228 true , "exception " BOOST_STRINGIZE(E) " is caught" ) \
229 /**/
230
231 //____________________________________________________________________________//
232
233 #define BOOST_WARN_EXCEPTION( S, E, P ) \
234 BOOST_CHECK_THROW_IMPL(S, E const& ex, WARN, \
235 false, "exception " BOOST_STRINGIZE(E) " is expected", \
236 P(ex), "incorrect exception " BOOST_STRINGIZE(E) " is caught" ) \
237 /**/
238 #define BOOST_CHECK_EXCEPTION( S, E, P ) \
239 BOOST_CHECK_THROW_IMPL(S, E const& ex, CHECK, \
240 false, "exception " BOOST_STRINGIZE(E) " is expected", \
241 P(ex), "incorrect exception " BOOST_STRINGIZE(E) " is caught" ) \
242 /**/
243 #define BOOST_REQUIRE_EXCEPTION( S, E, P ) \
244 BOOST_CHECK_THROW_IMPL(S, E const& ex, REQUIRE, \
245 false, "exception " BOOST_STRINGIZE(E) " is expected", \
246 P(ex), "incorrect exception " BOOST_STRINGIZE(E) " is caught" ) \
247 /**/
248
249 //____________________________________________________________________________//
250
251 #define BOOST_WARN_NO_THROW( S ) \
252 BOOST_CHECK_THROW_IMPL(S, ..., WARN, \
253 true , "no exceptions thrown by " BOOST_STRINGIZE( S ), \
254 false, "exception thrown by " BOOST_STRINGIZE( S ) ) \
255 /**/
256 #define BOOST_CHECK_NO_THROW( S ) \
257 BOOST_CHECK_THROW_IMPL(S, ..., CHECK, \
258 true , "no exceptions thrown by " BOOST_STRINGIZE( S ), \
259 false, "exception thrown by " BOOST_STRINGIZE( S ) ) \
260 /**/
261 #define BOOST_REQUIRE_NO_THROW( S ) \
262 BOOST_CHECK_THROW_IMPL(S, ..., REQUIRE, \
263 true , "no exceptions thrown by " BOOST_STRINGIZE( S ), \
264 false, "exception thrown by " BOOST_STRINGIZE( S ) ) \
265 /**/
266
267 //____________________________________________________________________________//
268
269 #define BOOST_WARN_MESSAGE( P, M ) BOOST_TEST_TOOL_DIRECT_IMPL( P, WARN, M )
270 #define BOOST_CHECK_MESSAGE( P, M ) BOOST_TEST_TOOL_DIRECT_IMPL( P, CHECK, M )
271 #define BOOST_REQUIRE_MESSAGE( P, M ) BOOST_TEST_TOOL_DIRECT_IMPL( P, REQUIRE, M )
272
273 //____________________________________________________________________________//
274
275 ////////////////////////////////////////////////////////////////////////////////
276 ///////////////////////////// DEPRECATED TOOLS /////////////////////////////
277
278 #define BOOST_WARN( P ) BOOST_TEST_WARN( P )
279 #define BOOST_CHECK( P ) BOOST_TEST_CHECK( P )
280 #define BOOST_REQUIRE( P ) BOOST_TEST_REQUIRE( P )
281
282 //____________________________________________________________________________//
283
284 #define BOOST_ERROR( M ) BOOST_TEST_ERROR( M )
285 #define BOOST_FAIL( M ) BOOST_TEST_FAIL( M )
286
287 //____________________________________________________________________________//
288
289 #define BOOST_WARN_EQUAL( L, R ) BOOST_TEST_WARN( L == R )
290 #define BOOST_CHECK_EQUAL( L, R ) BOOST_TEST_CHECK( L == R )
291 #define BOOST_REQUIRE_EQUAL( L, R ) BOOST_TEST_REQUIRE( L == R )
292
293 #define BOOST_WARN_NE( L, R ) BOOST_TEST_WARN( L != R )
294 #define BOOST_CHECK_NE( L, R ) BOOST_TEST_CHECK( L != R )
295 #define BOOST_REQUIRE_NE( L, R ) BOOST_TEST_REQUIRE( L != R )
296
297 #define BOOST_WARN_LT( L, R ) BOOST_TEST_WARN( L < R )
298 #define BOOST_CHECK_LT( L, R ) BOOST_TEST_CHECK( L < R )
299 #define BOOST_REQUIRE_LT( L, R ) BOOST_TEST_REQUIRE( L < R )
300
301 #define BOOST_WARN_LE( L, R ) BOOST_TEST_WARN( L <= R )
302 #define BOOST_CHECK_LE( L, R ) BOOST_TEST_CHECK( L <= R )
303 #define BOOST_REQUIRE_LE( L, R ) BOOST_TEST_REQUIRE( L <= R )
304
305 #define BOOST_WARN_GT( L, R ) BOOST_TEST_WARN( L > R )
306 #define BOOST_CHECK_GT( L, R ) BOOST_TEST_CHECK( L > R )
307 #define BOOST_REQUIRE_GT( L, R ) BOOST_TEST_REQUIRE( L > R )
308
309 #define BOOST_WARN_GE( L, R ) BOOST_TEST_WARN( L >= R )
310 #define BOOST_CHECK_GE( L, R ) BOOST_TEST_CHECK( L >= R )
311 #define BOOST_REQUIRE_GE( L, R ) BOOST_TEST_REQUIRE( L >= R )
312
313 //____________________________________________________________________________//
314
315 #define BOOST_WARN_CLOSE( L, R, T ) BOOST_TEST_WARN( L == R, T % ::boost::test_tools::tolerance() )
316 #define BOOST_CHECK_CLOSE( L, R, T ) BOOST_TEST_CHECK( L == R, T % ::boost::test_tools::tolerance() )
317 #define BOOST_REQUIRE_CLOSE( L, R, T ) BOOST_TEST_REQUIRE( L == R, T % ::boost::test_tools::tolerance() )
318
319 #define BOOST_WARN_CLOSE_FRACTION(L, R, T) BOOST_TEST_WARN( L == R, ::boost::test_tools::tolerance( T ) )
320 #define BOOST_CHECK_CLOSE_FRACTION(L, R, T) BOOST_TEST_CHECK( L == R, ::boost::test_tools::tolerance( T ) )
321 #define BOOST_REQUIRE_CLOSE_FRACTION(L,R,T) BOOST_TEST_REQUIRE( L == R, ::boost::test_tools::tolerance( T ) )
322
323 #define BOOST_WARN_SMALL( FPV, T ) BOOST_TEST_WARN( FPV == 0., ::boost::test_tools::tolerance( T ) )
324 #define BOOST_CHECK_SMALL( FPV, T ) BOOST_TEST_CHECK( FPV == 0., ::boost::test_tools::tolerance( T ) )
325 #define BOOST_REQUIRE_SMALL( FPV, T ) BOOST_TEST_REQUIRE( FPV == 0., ::boost::test_tools::tolerance( T ) )
326
327 //____________________________________________________________________________//
328
329 #define BOOST_WARN_EQUAL_COLLECTIONS( L_begin, L_end, R_begin, R_end ) \
330 BOOST_TEST_WARN( ::boost::test_tools::tt_detail::make_it_pair(L_begin, L_end) ==\
331 ::boost::test_tools::tt_detail::make_it_pair(R_begin, R_end), \
332 ::boost::test_tools::per_element() ) \
333 /**/
334
335 #define BOOST_CHECK_EQUAL_COLLECTIONS( L_begin, L_end, R_begin, R_end ) \
336 BOOST_TEST_CHECK( ::boost::test_tools::tt_detail::make_it_pair(L_begin, L_end) ==\
337 ::boost::test_tools::tt_detail::make_it_pair(R_begin, R_end), \
338 ::boost::test_tools::per_element() ) \
339 /**/
340
341 #define BOOST_REQUIRE_EQUAL_COLLECTIONS( L_begin, L_end, R_begin, R_end ) \
342 BOOST_TEST_REQUIRE( ::boost::test_tools::tt_detail::make_it_pair(L_begin, L_end) ==\
343 ::boost::test_tools::tt_detail::make_it_pair(R_begin, R_end), \
344 ::boost::test_tools::per_element() ) \
345 /**/
346
347 //____________________________________________________________________________//
348
349 #define BOOST_WARN_BITWISE_EQUAL( L, R ) BOOST_TEST_WARN( L == R, ::boost::test_tools::bitwise() )
350 #define BOOST_CHECK_BITWISE_EQUAL( L, R ) BOOST_TEST_CHECK( L == R, ::boost::test_tools::bitwise() )
351 #define BOOST_REQUIRE_BITWISE_EQUAL( L, R ) BOOST_TEST_REQUIRE( L == R, ::boost::test_tools::bitwise() )
352
353 //____________________________________________________________________________//
354
355 #define BOOST_WARN_PREDICATE( P, ARGS ) BOOST_TEST_WARN( P BOOST_PP_SEQ_TO_TUPLE(ARGS) )
356 #define BOOST_CHECK_PREDICATE( P, ARGS ) BOOST_TEST_CHECK( P BOOST_PP_SEQ_TO_TUPLE(ARGS) )
357 #define BOOST_REQUIRE_PREDICATE( P, ARGS ) BOOST_TEST_REQUIRE( P BOOST_PP_SEQ_TO_TUPLE(ARGS) )
358
359 //____________________________________________________________________________//
360
361 #define BOOST_IS_DEFINED( symb ) ::boost::test_tools::tt_detail::is_defined_impl( #symb, BOOST_STRINGIZE(= symb) )
362
363 //____________________________________________________________________________//
364
365 #endif // BOOST_TEST_NO_OLD_TOOLS
366
367 #include <boost/test/detail/enable_warnings.hpp>
368
369 #endif // BOOST_TEST_TOOLS_INTERFACE_HPP_111712GER