Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:09:21

0001 //  (C) Copyright Gennadiy Rozental 2001.
0002 //  Distributed under the Boost Software License, Version 1.0.
0003 //  (See accompanying file LICENSE_1_0.txt or copy at
0004 //  http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 //  See http://www.boost.org/libs/test for the library home page.
0007 //
0008 /// @file
0009 /// @brief Defines Unit Test Framework public API
0010 // ***************************************************************************
0011 
0012 #ifndef BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER
0013 #define BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER
0014 
0015 // Boost.Test
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 // **************    Non-auto (explicit) test case interface   ************** //
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 // **************               BOOST_TEST_SUITE               ************** //
0049 // ************************************************************************** //
0050 
0051 #define BOOST_TEST_SUITE( testsuite_name ) \
0052 ( new boost::unit_test::test_suite( testsuite_name, __FILE__, __LINE__ ) )
0053 
0054 // ************************************************************************** //
0055 // **************             BOOST_AUTO_TEST_SUITE            ************** //
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 /* BOOST_PP_VARIADICS */
0081 
0082 #define BOOST_AUTO_TEST_SUITE( suite_name )                             \
0083     BOOST_AUTO_TEST_SUITE_NO_DECOR( suite_name )                        \
0084 /**/
0085 
0086 
0087 #endif /* BOOST_PP_VARIADICS */
0088 
0089 // ************************************************************************** //
0090 // **************            BOOST_FIXTURE_TEST_SUITE          ************** //
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 /* BOOST_PP_VARIADICS */
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 /* BOOST_PP_VARIADICS */
0120 
0121 
0122 // ************************************************************************** //
0123 // **************           BOOST_AUTO_TEST_SUITE_END          ************** //
0124 // ************************************************************************** //
0125 
0126 #define BOOST_AUTO_TEST_SUITE_END()             \
0127 BOOST_AUTO_TU_REGISTRAR( end_suite )( 1 );      \
0128 }                                               \
0129 /**/
0130 
0131 // ************************************************************************** //
0132 // **************    BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES    ************** //
0133 // ************************************************************************** //
0134 
0135 /// @deprecated use decorator instead
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 // **************            BOOST_FIXTURE_TEST_CASE           ************** //
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 /* BOOST_PP_VARIADICS */
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 /* BOOST_PP_VARIADICS */
0193 
0194 // ************************************************************************** //
0195 // **************             BOOST_AUTO_TEST_CASE             ************** //
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 /* BOOST_PP_VARIADICS */
0218 
0219 #define BOOST_AUTO_TEST_CASE( test_name )                               \
0220     BOOST_AUTO_TEST_CASE_NO_DECOR( test_name )                          \
0221 /**/
0222 
0223 
0224 #endif /* BOOST_PP_VARIADICS */
0225 
0226 // ************************************************************************** //
0227 // **************       BOOST_FIXTURE_TEST_CASE_TEMPLATE       ************** //
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 // **************        BOOST_AUTO_TEST_CASE_TEMPLATE         ************** //
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 // **************           BOOST_TEST_CASE_TEMPLATE           ************** //
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 // **************      BOOST_TEST_CASE_TEMPLATE_FUNCTION       ************** //
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 // **************              BOOST_GLOBAL_FIXTURE            ************** //
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 // **************      BOOST_TEST_GLOBAL_CONFIGURATION         ************** //
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 // **************         BOOST_TEST_GLOBAL_FIXTURE            ************** //
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 // **************             BOOST_TEST_DECORATOR             ************** //
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 // **************         BOOST_AUTO_TEST_CASE_FIXTURE         ************** //
0334 // ************************************************************************** //
0335 
0336 namespace boost { namespace unit_test { namespace ut_detail {
0337 
0338 struct nil_t {};
0339 
0340 } // namespace ut_detail
0341 } // unit_test
0342 } // namespace boost
0343 
0344 // Intentionally is in global namespace, so that FIXTURE_TEST_SUITE can reset it in user code.
0345 typedef ::boost::unit_test::ut_detail::nil_t BOOST_AUTO_TEST_CASE_FIXTURE;
0346 
0347 // ************************************************************************** //
0348 // **************   Auto registration facility helper macros   ************** //
0349 // ************************************************************************** //
0350 
0351 // Facility for having a unique name based on __LINE__ and __COUNTER__ (later if available)
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 // **************                BOOST_TEST_MAIN               ************** //
0376 // ************************************************************************** //
0377 
0378 #if defined(BOOST_TEST_MAIN)
0379 
0380 // initializing the master test suite name from the user defined macros
0381 // this function should be seen exactly once.
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 // BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER
0409