// (C) Copyright Gennadiy Rozental 2001. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org/libs/test for the library home page. // /// @file /// @brief Defines Unit Test Framework public API // *************************************************************************** #ifndef ACTIV_BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER #define ACTIV_BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER // Boost.Test #include #include #include #include #include #include #include //____________________________________________________________________________// // ************************************************************************** // // ************** Non-auto (explicit) test case interface ************** // // ************************************************************************** // #define ACTIV_BOOST_TEST_CASE_NAME( test_function, test_name ) \ Boost::unit_test::make_test_case( Boost::function(test_function), \ test_name , \ __FILE__, __LINE__ ) #define ACTIV_BOOST_TEST_CASE( test_function ) \ ACTIV_BOOST_TEST_CASE_NAME(test_function, ACTIV_BOOST_TEST_STRINGIZE( test_function) ) #define ACTIV_BOOST_CLASS_TEST_CASE( test_function, tc_instance ) \ Boost::unit_test::make_test_case( (test_function), \ ACTIV_BOOST_TEST_STRINGIZE( test_function ), \ __FILE__, __LINE__, tc_instance ) // ************************************************************************** // // ************** ACTIV_BOOST_TEST_SUITE ************** // // ************************************************************************** // #define ACTIV_BOOST_TEST_SUITE( testsuite_name ) \ ( new Boost::unit_test::test_suite( testsuite_name, __FILE__, __LINE__ ) ) // ************************************************************************** // // ************** ACTIV_BOOST_AUTO_TEST_SUITE ************** // // ************************************************************************** // #define ACTIV_BOOST_AUTO_TEST_SUITE_WITH_DECOR( suite_name, decorators ) \ namespace suite_name { \ ACTIV_BOOST_AUTO_TU_REGISTRAR( suite_name )( \ ACTIV_BOOST_STRINGIZE( suite_name ), \ __FILE__, __LINE__, \ decorators ); \ /**/ #define ACTIV_BOOST_AUTO_TEST_SUITE_NO_DECOR( suite_name ) \ ACTIV_BOOST_AUTO_TEST_SUITE_WITH_DECOR( \ suite_name, \ Boost::unit_test::decorator::collector_t::instance() ) \ /**/ #if ACTIV_BOOST_PP_VARIADICS #define ACTIV_BOOST_AUTO_TEST_SUITE( ... ) \ ACTIV_BOOST_TEST_INVOKE_IF_N_ARGS( 1, \ ACTIV_BOOST_AUTO_TEST_SUITE_NO_DECOR, \ ACTIV_BOOST_AUTO_TEST_SUITE_WITH_DECOR, \ __VA_ARGS__) \ /**/ #else /* ACTIV_BOOST_PP_VARIADICS */ #define ACTIV_BOOST_AUTO_TEST_SUITE( suite_name ) \ ACTIV_BOOST_AUTO_TEST_SUITE_NO_DECOR( suite_name ) \ /**/ #endif /* ACTIV_BOOST_PP_VARIADICS */ // ************************************************************************** // // ************** ACTIV_BOOST_FIXTURE_TEST_SUITE ************** // // ************************************************************************** // #define ACTIV_BOOST_FIXTURE_TEST_SUITE_WITH_DECOR(suite_name, F, decorators) \ ACTIV_BOOST_AUTO_TEST_SUITE_WITH_DECOR( suite_name, decorators ) \ typedef F ACTIV_BOOST_AUTO_TEST_CASE_FIXTURE; \ /**/ #define ACTIV_BOOST_FIXTURE_TEST_SUITE_NO_DECOR( suite_name, F ) \ ACTIV_BOOST_AUTO_TEST_SUITE_NO_DECOR( suite_name ) \ typedef F ACTIV_BOOST_AUTO_TEST_CASE_FIXTURE; \ /**/ #if ACTIV_BOOST_PP_VARIADICS #define ACTIV_BOOST_FIXTURE_TEST_SUITE( ... ) \ ACTIV_BOOST_TEST_INVOKE_IF_N_ARGS( 2, \ ACTIV_BOOST_FIXTURE_TEST_SUITE_NO_DECOR, \ ACTIV_BOOST_FIXTURE_TEST_SUITE_WITH_DECOR, \ __VA_ARGS__) \ /**/ #else /* ACTIV_BOOST_PP_VARIADICS */ #define ACTIV_BOOST_FIXTURE_TEST_SUITE( suite_name, F ) \ ACTIV_BOOST_FIXTURE_TEST_SUITE_NO_DECOR( suite_name, F ) \ /**/ #endif /* ACTIV_BOOST_PP_VARIADICS */ // ************************************************************************** // // ************** ACTIV_BOOST_AUTO_TEST_SUITE_END ************** // // ************************************************************************** // #define ACTIV_BOOST_AUTO_TEST_SUITE_END() \ ACTIV_BOOST_AUTO_TU_REGISTRAR( end_suite )( 1 ); \ } \ /**/ // ************************************************************************** // // ************** ACTIV_BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES ************** // // ************************************************************************** // /// @deprecated use decorator instead #define ACTIV_BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES( test_name, n ) \ ACTIV_BOOST_TEST_DECORATOR( * Boost::unit_test::expected_failures( n ) ) \ /**/ // ************************************************************************** // // ************** ACTIV_BOOST_FIXTURE_TEST_CASE ************** // // ************************************************************************** // #define ACTIV_BOOST_FIXTURE_TEST_CASE_WITH_DECOR( test_name, F, decorators ) \ struct test_name : public F { void test_method(); }; \ \ static void ACTIV_BOOST_AUTO_TC_INVOKER( test_name )() \ { \ ACTIV_BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture ctor"); \ test_name t; \ ACTIV_BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture setup"); \ Boost::unit_test::setup_conditional(t); \ ACTIV_BOOST_TEST_CHECKPOINT('"' << #test_name << "\" test entry"); \ t.test_method(); \ ACTIV_BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture teardown"); \ Boost::unit_test::teardown_conditional(t); \ ACTIV_BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture dtor"); \ } \ \ struct ACTIV_BOOST_AUTO_TC_UNIQUE_ID( test_name ) {}; \ \ ACTIV_BOOST_AUTO_TU_REGISTRAR( test_name )( \ Boost::unit_test::make_test_case( \ &ACTIV_BOOST_AUTO_TC_INVOKER( test_name ), \ #test_name, __FILE__, __LINE__ ), \ decorators ); \ \ void test_name::test_method() \ /**/ #define ACTIV_BOOST_FIXTURE_TEST_CASE_NO_DECOR( test_name, F ) \ ACTIV_BOOST_FIXTURE_TEST_CASE_WITH_DECOR( test_name, F, \ Boost::unit_test::decorator::collector_t::instance() ) \ /**/ #if ACTIV_BOOST_PP_VARIADICS #define ACTIV_BOOST_FIXTURE_TEST_CASE( ... ) \ ACTIV_BOOST_TEST_INVOKE_IF_N_ARGS( 2, \ ACTIV_BOOST_FIXTURE_TEST_CASE_NO_DECOR, \ ACTIV_BOOST_FIXTURE_TEST_CASE_WITH_DECOR, \ __VA_ARGS__) \ /**/ #else /* ACTIV_BOOST_PP_VARIADICS */ #define ACTIV_BOOST_FIXTURE_TEST_CASE( test_name, F ) \ ACTIV_BOOST_FIXTURE_TEST_CASE_NO_DECOR(test_name, F) \ /**/ #endif /* ACTIV_BOOST_PP_VARIADICS */ // ************************************************************************** // // ************** ACTIV_BOOST_AUTO_TEST_CASE ************** // // ************************************************************************** // #define ACTIV_BOOST_AUTO_TEST_CASE_NO_DECOR( test_name ) \ ACTIV_BOOST_FIXTURE_TEST_CASE_NO_DECOR( test_name, \ ACTIV_BOOST_AUTO_TEST_CASE_FIXTURE ) \ /**/ #define ACTIV_BOOST_AUTO_TEST_CASE_WITH_DECOR( test_name, decorators ) \ ACTIV_BOOST_FIXTURE_TEST_CASE_WITH_DECOR( test_name, \ ACTIV_BOOST_AUTO_TEST_CASE_FIXTURE, decorators ) \ /**/ #if ACTIV_BOOST_PP_VARIADICS #define ACTIV_BOOST_AUTO_TEST_CASE( ... ) \ ACTIV_BOOST_TEST_INVOKE_IF_N_ARGS( 1, \ ACTIV_BOOST_AUTO_TEST_CASE_NO_DECOR, \ ACTIV_BOOST_AUTO_TEST_CASE_WITH_DECOR, \ __VA_ARGS__) \ /**/ #else /* ACTIV_BOOST_PP_VARIADICS */ #define ACTIV_BOOST_AUTO_TEST_CASE( test_name ) \ ACTIV_BOOST_AUTO_TEST_CASE_NO_DECOR( test_name ) \ /**/ #endif /* ACTIV_BOOST_PP_VARIADICS */ // ************************************************************************** // // ************** ACTIV_BOOST_FIXTURE_TEST_CASE_TEMPLATE ************** // // ************************************************************************** // #define ACTIV_BOOST_FIXTURE_TEST_CASE_TEMPLATE( test_name, type_name, TL, F ) \ template \ struct test_name : public F \ { void test_method(); }; \ \ struct ACTIV_BOOST_AUTO_TC_INVOKER( test_name ) { \ template \ static void run( Boost::type* = 0 ) \ { \ ACTIV_BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture ctor"); \ test_name t; \ ACTIV_BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture setup"); \ Boost::unit_test::setup_conditional(t); \ ACTIV_BOOST_TEST_CHECKPOINT('"' << #test_name << "\" test entry"); \ t.test_method(); \ ACTIV_BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture teardown");\ Boost::unit_test::teardown_conditional(t); \ ACTIV_BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture dtor"); \ } \ }; \ \ ACTIV_BOOST_AUTO_TU_REGISTRAR( test_name )( \ Boost::unit_test::ut_detail::template_test_case_gen< \ ACTIV_BOOST_AUTO_TC_INVOKER( test_name ),TL >( \ ACTIV_BOOST_STRINGIZE( test_name ), __FILE__, __LINE__ ), \ Boost::unit_test::decorator::collector_t::instance() ); \ \ template \ void test_name::test_method() \ /**/ // ************************************************************************** // // ************** ACTIV_BOOST_AUTO_TEST_CASE_TEMPLATE ************** // // ************************************************************************** // #define ACTIV_BOOST_AUTO_TEST_CASE_TEMPLATE( test_name, type_name, TL ) \ ACTIV_BOOST_FIXTURE_TEST_CASE_TEMPLATE( test_name, type_name, TL, \ ACTIV_BOOST_AUTO_TEST_CASE_FIXTURE ) \ /**/ // ************************************************************************** // // ************** ACTIV_BOOST_TEST_CASE_TEMPLATE ************** // // ************************************************************************** // #define ACTIV_BOOST_TEST_CASE_TEMPLATE( name, typelist ) \ Boost::unit_test::ut_detail::template_test_case_gen( \ ACTIV_BOOST_TEST_STRINGIZE( name ), __FILE__, __LINE__ ) \ /**/ // ************************************************************************** // // ************** ACTIV_BOOST_TEST_CASE_TEMPLATE_FUNCTION ************** // // ************************************************************************** // #define ACTIV_BOOST_TEST_CASE_TEMPLATE_FUNCTION( name, type_name ) \ template \ void ACTIV_BOOST_JOIN( name, _impl )( Boost::type* ); \ \ struct name { \ template \ static void run( Boost::type* frwrd = 0 ) \ { \ ACTIV_BOOST_JOIN( name, _impl )( frwrd ); \ } \ }; \ \ template \ void ACTIV_BOOST_JOIN( name, _impl )( Boost::type* ) \ /**/ // ************************************************************************** // // ************** ACTIV_BOOST_GLOBAL_FIXTURE ************** // // ************************************************************************** // #define ACTIV_BOOST_GLOBAL_FIXTURE( F ) \ static Boost::unit_test::ut_detail::global_configuration_impl ACTIV_BOOST_JOIN( gf_, F ) \ /**/ // ************************************************************************** // // ************** ACTIV_BOOST_TEST_GLOBAL_CONFIGURATION ************** // // ************************************************************************** // #define ACTIV_BOOST_TEST_GLOBAL_CONFIGURATION( F ) \ static Boost::unit_test::ut_detail::global_configuration_impl ACTIV_BOOST_JOIN( gf_, F ) \ /**/ // ************************************************************************** // // ************** ACTIV_BOOST_TEST_GLOBAL_FIXTURE ************** // // ************************************************************************** // #define ACTIV_BOOST_TEST_GLOBAL_FIXTURE( F ) \ static Boost::unit_test::ut_detail::global_fixture_impl ACTIV_BOOST_JOIN( gf_, F ) \ /**/ // ************************************************************************** // // ************** ACTIV_BOOST_TEST_DECORATOR ************** // // ************************************************************************** // #define ACTIV_BOOST_TEST_DECORATOR( D ) \ static Boost::unit_test::decorator::collector_t const& \ ACTIV_BOOST_TEST_APPEND_UNIQUE_ID(decorator_collector) ACTIV_BOOST_ATTRIBUTE_UNUSED = D; \ /**/ // ************************************************************************** // // ************** ACTIV_BOOST_AUTO_TEST_CASE_FIXTURE ************** // // ************************************************************************** // namespace Boost { namespace unit_test { namespace ut_detail { struct nil_t {}; } // namespace ut_detail } // unit_test } // namespace Boost // Intentionally is in global namespace, so that FIXTURE_TEST_SUITE can reset it in user code. typedef ::Boost::unit_test::ut_detail::nil_t ACTIV_BOOST_AUTO_TEST_CASE_FIXTURE; // ************************************************************************** // // ************** Auto registration facility helper macros ************** // // ************************************************************************** // // Facility for having a unique name based on __LINE__ and __COUNTER__ (later if available) #if defined(__COUNTER__) #define ACTIV_BOOST_TEST_INTERNAL_HAS_COUNTER #endif #if defined(ACTIV_BOOST_TEST_INTERNAL_HAS_COUNTER) #define ACTIV_BOOST_TEST_APPEND_UNIQUE_ID( name ) \ ACTIV_BOOST_JOIN( ACTIV_BOOST_JOIN( name, __LINE__ ), __COUNTER__) /**/ #else #define ACTIV_BOOST_TEST_APPEND_UNIQUE_ID( name ) \ ACTIV_BOOST_JOIN( name, __LINE__ ) /**/ #endif /**/ #define ACTIV_BOOST_AUTO_TU_REGISTRAR( test_name ) \ static Boost::unit_test::ut_detail::auto_test_unit_registrar \ ACTIV_BOOST_TEST_APPEND_UNIQUE_ID( ACTIV_BOOST_JOIN( test_name, _registrar ) ) ACTIV_BOOST_ATTRIBUTE_UNUSED \ /**/ #define ACTIV_BOOST_AUTO_TC_INVOKER( test_name ) ACTIV_BOOST_JOIN( test_name, _invoker ) #define ACTIV_BOOST_AUTO_TC_UNIQUE_ID( test_name ) ACTIV_BOOST_JOIN( test_name, _id ) // ************************************************************************** // // ************** ACTIV_BOOST_TEST_MAIN ************** // // ************************************************************************** // #if defined(ACTIV_BOOST_TEST_MAIN) // initializing the master test suite name from the user defined macros // this function should be seen exactly once. #ifdef ACTIV_BOOST_TEST_MODULE static const Boost::unit_test::framework::impl::master_test_suite_name_setter mtsetter(ACTIV_BOOST_TEST_STRINGIZE( ACTIV_BOOST_TEST_MODULE ).trim( "\"" )); #endif #ifdef ACTIV_BOOST_TEST_ALTERNATIVE_INIT_API bool init_unit_test() { #else ::Boost::unit_test::test_suite* init_unit_test_suite( int, char* [] ) { #endif #ifdef ACTIV_BOOST_TEST_ALTERNATIVE_INIT_API return true; } #else return 0; } #endif #endif //____________________________________________________________________________// #include #endif // ACTIV_BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER