File indexing completed on 2025-12-15 10:09:21
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER
0013 #define BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER
0014
0015
0016 #include <boost/test/detail/config.hpp>
0017 #include <boost/test/framework.hpp>
0018 #include <boost/test/tree/auto_registration.hpp>
0019 #include <boost/test/tree/test_case_template.hpp>
0020 #include <boost/test/tree/global_fixture.hpp>
0021
0022
0023 #include <boost/test/detail/suppress_warnings.hpp>
0024
0025
0026 #include <boost/test/detail/pp_variadic.hpp>
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 #define BOOST_TEST_CASE_NAME( test_function, test_name ) \
0037 boost::unit_test::make_test_case( boost::function<void ()>(test_function), \
0038 test_name , \
0039 __FILE__, __LINE__ )
0040 #define BOOST_TEST_CASE( test_function ) \
0041 BOOST_TEST_CASE_NAME(test_function, BOOST_TEST_STRINGIZE( test_function) )
0042 #define BOOST_CLASS_TEST_CASE( test_function, tc_instance ) \
0043 boost::unit_test::make_test_case( (test_function), \
0044 BOOST_TEST_STRINGIZE( test_function ), \
0045 __FILE__, __LINE__, tc_instance )
0046
0047
0048
0049
0050
0051 #define BOOST_TEST_SUITE( testsuite_name ) \
0052 ( new boost::unit_test::test_suite( testsuite_name, __FILE__, __LINE__ ) )
0053
0054
0055
0056
0057
0058 #define BOOST_AUTO_TEST_SUITE_WITH_DECOR( suite_name, decorators ) \
0059 namespace suite_name { \
0060 BOOST_AUTO_TU_REGISTRAR( suite_name )( \
0061 BOOST_STRINGIZE( suite_name ), \
0062 __FILE__, __LINE__, \
0063 decorators ); \
0064
0065
0066 #define BOOST_AUTO_TEST_SUITE_NO_DECOR( suite_name ) \
0067 BOOST_AUTO_TEST_SUITE_WITH_DECOR( \
0068 suite_name, \
0069 boost::unit_test::decorator::collector_t::instance() ) \
0070
0071
0072 #if BOOST_PP_VARIADICS
0073 #define BOOST_AUTO_TEST_SUITE( ... ) \
0074 BOOST_TEST_INVOKE_IF_N_ARGS( 1, \
0075 BOOST_AUTO_TEST_SUITE_NO_DECOR, \
0076 BOOST_AUTO_TEST_SUITE_WITH_DECOR, \
0077 __VA_ARGS__) \
0078
0079
0080 #else
0081
0082 #define BOOST_AUTO_TEST_SUITE( suite_name ) \
0083 BOOST_AUTO_TEST_SUITE_NO_DECOR( suite_name ) \
0084
0085
0086
0087 #endif
0088
0089
0090
0091
0092
0093 #define BOOST_FIXTURE_TEST_SUITE_WITH_DECOR(suite_name, F, decorators) \
0094 BOOST_AUTO_TEST_SUITE_WITH_DECOR( suite_name, decorators ) \
0095 typedef F BOOST_AUTO_TEST_CASE_FIXTURE; \
0096
0097
0098 #define BOOST_FIXTURE_TEST_SUITE_NO_DECOR( suite_name, F ) \
0099 BOOST_AUTO_TEST_SUITE_NO_DECOR( suite_name ) \
0100 typedef F BOOST_AUTO_TEST_CASE_FIXTURE; \
0101
0102
0103 #if BOOST_PP_VARIADICS
0104
0105 #define BOOST_FIXTURE_TEST_SUITE( ... ) \
0106 BOOST_TEST_INVOKE_IF_N_ARGS( 2, \
0107 BOOST_FIXTURE_TEST_SUITE_NO_DECOR, \
0108 BOOST_FIXTURE_TEST_SUITE_WITH_DECOR, \
0109 __VA_ARGS__) \
0110
0111
0112 #else
0113
0114 #define BOOST_FIXTURE_TEST_SUITE( suite_name, F ) \
0115 BOOST_FIXTURE_TEST_SUITE_NO_DECOR( suite_name, F ) \
0116
0117
0118
0119 #endif
0120
0121
0122
0123
0124
0125
0126 #define BOOST_AUTO_TEST_SUITE_END() \
0127 BOOST_AUTO_TU_REGISTRAR( end_suite )( 1 ); \
0128 } \
0129
0130
0131
0132
0133
0134
0135
0136 #define BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES( test_name, n ) \
0137 BOOST_TEST_DECORATOR( * boost::unit_test::expected_failures( n ) ) \
0138
0139
0140
0141
0142
0143
0144 #define BOOST_FIXTURE_TEST_CASE_WITH_DECOR( test_name, F, decorators ) \
0145 struct test_name : public F { void test_method(); }; \
0146 \
0147 static void BOOST_AUTO_TC_INVOKER( test_name )() \
0148 { \
0149 BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture ctor"); \
0150 test_name t; \
0151 BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture setup"); \
0152 boost::unit_test::setup_conditional(t); \
0153 BOOST_TEST_CHECKPOINT('"' << #test_name << "\" test entry"); \
0154 t.test_method(); \
0155 BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture teardown"); \
0156 boost::unit_test::teardown_conditional(t); \
0157 BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture dtor"); \
0158 } \
0159 \
0160 struct BOOST_AUTO_TC_UNIQUE_ID( test_name ) {}; \
0161 \
0162 BOOST_AUTO_TU_REGISTRAR( test_name )( \
0163 boost::unit_test::make_test_case( \
0164 &BOOST_AUTO_TC_INVOKER( test_name ), \
0165 #test_name, __FILE__, __LINE__ ), \
0166 decorators ); \
0167 \
0168 void test_name::test_method() \
0169
0170
0171 #define BOOST_FIXTURE_TEST_CASE_NO_DECOR( test_name, F ) \
0172 BOOST_FIXTURE_TEST_CASE_WITH_DECOR( test_name, F, \
0173 boost::unit_test::decorator::collector_t::instance() ) \
0174
0175
0176 #if BOOST_PP_VARIADICS
0177
0178 #define BOOST_FIXTURE_TEST_CASE( ... ) \
0179 BOOST_TEST_INVOKE_IF_N_ARGS( 2, \
0180 BOOST_FIXTURE_TEST_CASE_NO_DECOR, \
0181 BOOST_FIXTURE_TEST_CASE_WITH_DECOR, \
0182 __VA_ARGS__) \
0183
0184
0185 #else
0186
0187 #define BOOST_FIXTURE_TEST_CASE( test_name, F ) \
0188 BOOST_FIXTURE_TEST_CASE_NO_DECOR(test_name, F) \
0189
0190
0191
0192 #endif
0193
0194
0195
0196
0197
0198 #define BOOST_AUTO_TEST_CASE_NO_DECOR( test_name ) \
0199 BOOST_FIXTURE_TEST_CASE_NO_DECOR( test_name, \
0200 BOOST_AUTO_TEST_CASE_FIXTURE ) \
0201
0202
0203 #define BOOST_AUTO_TEST_CASE_WITH_DECOR( test_name, decorators ) \
0204 BOOST_FIXTURE_TEST_CASE_WITH_DECOR( test_name, \
0205 BOOST_AUTO_TEST_CASE_FIXTURE, decorators ) \
0206
0207
0208 #if BOOST_PP_VARIADICS
0209
0210 #define BOOST_AUTO_TEST_CASE( ... ) \
0211 BOOST_TEST_INVOKE_IF_N_ARGS( 1, \
0212 BOOST_AUTO_TEST_CASE_NO_DECOR, \
0213 BOOST_AUTO_TEST_CASE_WITH_DECOR, \
0214 __VA_ARGS__) \
0215
0216
0217 #else
0218
0219 #define BOOST_AUTO_TEST_CASE( test_name ) \
0220 BOOST_AUTO_TEST_CASE_NO_DECOR( test_name ) \
0221
0222
0223
0224 #endif
0225
0226
0227
0228
0229
0230 #define BOOST_FIXTURE_TEST_CASE_TEMPLATE( test_name, type_name, TL, F ) \
0231 template<typename type_name> \
0232 struct test_name : public F \
0233 { void test_method(); }; \
0234 \
0235 struct BOOST_AUTO_TC_INVOKER( test_name ) { \
0236 template<typename TestType> \
0237 static void run( boost::type<TestType>* = 0 ) \
0238 { \
0239 BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture ctor"); \
0240 test_name<TestType> t; \
0241 BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture setup"); \
0242 boost::unit_test::setup_conditional(t); \
0243 BOOST_TEST_CHECKPOINT('"' << #test_name << "\" test entry"); \
0244 t.test_method(); \
0245 BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture teardown");\
0246 boost::unit_test::teardown_conditional(t); \
0247 BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture dtor"); \
0248 } \
0249 }; \
0250 \
0251 BOOST_AUTO_TU_REGISTRAR( test_name )( \
0252 boost::unit_test::ut_detail::template_test_case_gen< \
0253 BOOST_AUTO_TC_INVOKER( test_name ),TL >( \
0254 BOOST_STRINGIZE( test_name ), __FILE__, __LINE__ ), \
0255 boost::unit_test::decorator::collector_t::instance() ); \
0256 \
0257 template<typename type_name> \
0258 void test_name<type_name>::test_method() \
0259
0260
0261
0262
0263
0264
0265 #define BOOST_AUTO_TEST_CASE_TEMPLATE( test_name, type_name, TL ) \
0266 BOOST_FIXTURE_TEST_CASE_TEMPLATE( test_name, type_name, TL, \
0267 BOOST_AUTO_TEST_CASE_FIXTURE ) \
0268
0269
0270
0271
0272
0273
0274 #define BOOST_TEST_CASE_TEMPLATE( name, typelist ) \
0275 boost::unit_test::ut_detail::template_test_case_gen<name,typelist>( \
0276 BOOST_TEST_STRINGIZE( name ), __FILE__, __LINE__ ) \
0277
0278
0279
0280
0281
0282
0283 #define BOOST_TEST_CASE_TEMPLATE_FUNCTION( name, type_name ) \
0284 template<typename type_name> \
0285 void BOOST_JOIN( name, _impl )( boost::type<type_name>* ); \
0286 \
0287 struct name { \
0288 template<typename TestType> \
0289 static void run( boost::type<TestType>* frwrd = 0 ) \
0290 { \
0291 BOOST_JOIN( name, _impl )( frwrd ); \
0292 } \
0293 }; \
0294 \
0295 template<typename type_name> \
0296 void BOOST_JOIN( name, _impl )( boost::type<type_name>* ) \
0297
0298
0299
0300
0301
0302
0303 #define BOOST_GLOBAL_FIXTURE( F ) \
0304 static boost::unit_test::ut_detail::global_configuration_impl<F> BOOST_JOIN( gf_, F ) \
0305
0306
0307
0308
0309
0310
0311 #define BOOST_TEST_GLOBAL_CONFIGURATION( F ) \
0312 static boost::unit_test::ut_detail::global_configuration_impl<F> BOOST_JOIN( gf_, F ) \
0313
0314
0315
0316
0317
0318
0319 #define BOOST_TEST_GLOBAL_FIXTURE( F ) \
0320 static boost::unit_test::ut_detail::global_fixture_impl<F> BOOST_JOIN( gf_, F ) \
0321
0322
0323
0324
0325
0326
0327 #define BOOST_TEST_DECORATOR( D ) \
0328 static boost::unit_test::decorator::collector_t const& \
0329 BOOST_TEST_APPEND_UNIQUE_ID(decorator_collector) BOOST_ATTRIBUTE_UNUSED = D; \
0330
0331
0332
0333
0334
0335
0336 namespace boost { namespace unit_test { namespace ut_detail {
0337
0338 struct nil_t {};
0339
0340 }
0341 }
0342 }
0343
0344
0345 typedef ::boost::unit_test::ut_detail::nil_t BOOST_AUTO_TEST_CASE_FIXTURE;
0346
0347
0348
0349
0350
0351
0352 #if defined(__COUNTER__)
0353 #define BOOST_TEST_INTERNAL_HAS_COUNTER
0354 #endif
0355
0356 #if defined(BOOST_TEST_INTERNAL_HAS_COUNTER)
0357 #define BOOST_TEST_APPEND_UNIQUE_ID( name ) \
0358 BOOST_JOIN( BOOST_JOIN( name, __LINE__ ), __COUNTER__)
0359
0360 #else
0361 #define BOOST_TEST_APPEND_UNIQUE_ID( name ) \
0362 BOOST_JOIN( name, __LINE__ )
0363
0364 #endif
0365
0366
0367 #define BOOST_AUTO_TU_REGISTRAR( test_name ) \
0368 static boost::unit_test::ut_detail::auto_test_unit_registrar \
0369 BOOST_TEST_APPEND_UNIQUE_ID( BOOST_JOIN( test_name, _registrar ) ) BOOST_ATTRIBUTE_UNUSED \
0370
0371 #define BOOST_AUTO_TC_INVOKER( test_name ) BOOST_JOIN( test_name, _invoker )
0372 #define BOOST_AUTO_TC_UNIQUE_ID( test_name ) BOOST_JOIN( test_name, _id )
0373
0374
0375
0376
0377
0378 #if defined(BOOST_TEST_MAIN)
0379
0380
0381
0382 #ifdef BOOST_TEST_MODULE
0383 static const boost::unit_test::framework::impl::master_test_suite_name_setter mtsetter(BOOST_TEST_STRINGIZE( BOOST_TEST_MODULE ).trim( "\"" ));
0384 #endif
0385
0386 #ifdef BOOST_TEST_ALTERNATIVE_INIT_API
0387 bool init_unit_test() {
0388 #else
0389 ::boost::unit_test::test_suite*
0390 init_unit_test_suite( int, char* [] ) {
0391 #endif
0392
0393 #ifdef BOOST_TEST_ALTERNATIVE_INIT_API
0394 return true;
0395 }
0396 #else
0397 return 0;
0398 }
0399 #endif
0400
0401 #endif
0402
0403
0404
0405 #include <boost/test/detail/enable_warnings.hpp>
0406
0407
0408 #endif
0409