unit_test_suite.hpp
Go to the documentation of this file.
00001 //  (C) Copyright Gennadiy Rozental 2001-2008.
00002 //  Distributed under the Boost Software License, Version 1.0.
00003 //  (See accompanying file LICENSE_1_0.txt or copy at 
00004 //  http://www.boost.org/LICENSE_1_0.txt)
00005 
00006 //  See http://www.boost.org/libs/test for the library home page.
00007 //
00008 //  File        : $RCSfile$
00009 //
00010 //  Version     : $Revision: 54633 $
00011 //
00012 //  Description : defines Unit Test Framework public API
00013 // ***************************************************************************
00014 
00015 #ifndef BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER
00016 #define BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER
00017 
00018 // Boost.Test
00019 #include <boost/test/unit_test_suite_impl.hpp>
00020 #include <boost/test/framework.hpp>
00021 
00022 //____________________________________________________________________________//
00023 
00024 // ************************************************************************** //
00025 // **************    Non-auto (explicit) test case interface   ************** //
00026 // ************************************************************************** //
00027 
00028 #define BOOST_TEST_CASE( test_function ) \
00029 boost::unit_test::make_test_case( boost::unit_test::callback0<>(test_function), BOOST_TEST_STRINGIZE( test_function ) )
00030 #define BOOST_CLASS_TEST_CASE( test_function, tc_instance ) \
00031 boost::unit_test::make_test_case((test_function), BOOST_TEST_STRINGIZE( test_function ), tc_instance )
00032 
00033 // ************************************************************************** //
00034 // **************               BOOST_TEST_SUITE               ************** //
00035 // ************************************************************************** //
00036 
00037 #define BOOST_TEST_SUITE( testsuite_name ) \
00038 ( new boost::unit_test::test_suite( testsuite_name ) )
00039 
00040 // ************************************************************************** //
00041 // **************             BOOST_AUTO_TEST_SUITE            ************** //
00042 // ************************************************************************** //
00043 
00044 #define BOOST_AUTO_TEST_SUITE( suite_name )                             \
00045 namespace suite_name {                                                  \
00046 BOOST_AUTO_TU_REGISTRAR( suite_name )( BOOST_STRINGIZE( suite_name ) ); \
00047 
00048 
00049 // ************************************************************************** //
00050 // **************            BOOST_FIXTURE_TEST_SUITE          ************** //
00051 // ************************************************************************** //
00052 
00053 #define BOOST_FIXTURE_TEST_SUITE( suite_name, F )                       \
00054 BOOST_AUTO_TEST_SUITE( suite_name )                                     \
00055 typedef F BOOST_AUTO_TEST_CASE_FIXTURE;                                 \
00056 
00057 
00058 // ************************************************************************** //
00059 // **************           BOOST_AUTO_TEST_SUITE_END          ************** //
00060 // ************************************************************************** //
00061 
00062 #define BOOST_AUTO_TEST_SUITE_END()                                     \
00063 BOOST_AUTO_TU_REGISTRAR( BOOST_JOIN( end_suite, __LINE__ ) )( 1 );      \
00064 }                                                                       \
00065 
00066 
00067 // ************************************************************************** //
00068 // **************    BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES    ************** //
00069 // ************************************************************************** //
00070 
00071 #define BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES( test_name, n )          \
00072 struct BOOST_AUTO_TC_UNIQUE_ID( test_name );                            \
00073                                                                         \
00074 static struct BOOST_JOIN( test_name, _exp_fail_num_spec )               \
00075 : boost::unit_test::ut_detail::                                         \
00076   auto_tc_exp_fail<BOOST_AUTO_TC_UNIQUE_ID( test_name ) >               \
00077 {                                                                       \
00078     BOOST_JOIN( test_name, _exp_fail_num_spec )()                       \
00079     : boost::unit_test::ut_detail::                                     \
00080       auto_tc_exp_fail<BOOST_AUTO_TC_UNIQUE_ID( test_name ) >( n )      \
00081     {}                                                                  \
00082 } BOOST_JOIN( test_name, _exp_fail_num_spec_inst );                     \
00083                                                                         \
00084 
00085 
00086 // ************************************************************************** //
00087 // **************            BOOST_FIXTURE_TEST_CASE           ************** //
00088 // ************************************************************************** //
00089 
00090 #define BOOST_FIXTURE_TEST_CASE( test_name, F )                         \
00091 struct test_name : public F { void test_method(); };                    \
00092                                                                         \
00093 static void BOOST_AUTO_TC_INVOKER( test_name )()                        \
00094 {                                                                       \
00095     BOOST_TEST_CHECKPOINT('"' << #test_name << "\" Fixture entry.");    \
00096     test_name t;                                                        \
00097     BOOST_TEST_CHECKPOINT('"' << #test_name << "\" entry.");            \
00098     t.test_method();                                                    \
00099     BOOST_TEST_CHECKPOINT('"' << #test_name << "\" exit.");             \
00100 }                                                                       \
00101                                                                         \
00102 struct BOOST_AUTO_TC_UNIQUE_ID( test_name ) {};                         \
00103                                                                         \
00104 BOOST_AUTO_TU_REGISTRAR( test_name )(                                   \
00105     boost::unit_test::make_test_case(                                   \
00106         &BOOST_AUTO_TC_INVOKER( test_name ), #test_name ),              \
00107     boost::unit_test::ut_detail::auto_tc_exp_fail<                      \
00108         BOOST_AUTO_TC_UNIQUE_ID( test_name )>::instance()->value() );   \
00109                                                                         \
00110 void test_name::test_method()                                           \
00111 
00112 
00113 // ************************************************************************** //
00114 // **************             BOOST_AUTO_TEST_CASE             ************** //
00115 // ************************************************************************** //
00116 
00117 #define BOOST_AUTO_TEST_CASE( test_name )                               \
00118 BOOST_FIXTURE_TEST_CASE( test_name, BOOST_AUTO_TEST_CASE_FIXTURE )
00119 
00120 
00121 // ************************************************************************** //
00122 // **************        BOOST_AUTO_TEST_CASE_TEMPLATE         ************** //
00123 // ************************************************************************** //
00124 
00125 #define BOOST_AUTO_TEST_CASE_TEMPLATE( test_name, type_name, TL )       \
00126 template<typename type_name>                                            \
00127 struct test_name : public BOOST_AUTO_TEST_CASE_FIXTURE                  \
00128 { void test_method(); };                                                \
00129                                                                         \
00130 struct BOOST_AUTO_TC_INVOKER( test_name ) {                             \
00131     template<typename TestType>                                         \
00132     static void run( boost::type<TestType>* = 0 )                       \
00133     {                                                                   \
00134         BOOST_TEST_CHECKPOINT('"' << #test_name << "\" Fixture entry.");\
00135         test_name<TestType> t;                                          \
00136         BOOST_TEST_CHECKPOINT('"' << #test_name << "\" entry.");        \
00137         t.test_method();                                                \
00138         BOOST_TEST_CHECKPOINT('"' << #test_name << "\" exit.");         \
00139     }                                                                   \
00140 };                                                                      \
00141                                                                         \
00142 BOOST_AUTO_TU_REGISTRAR( test_name )(                                   \
00143     boost::unit_test::ut_detail::template_test_case_gen<                \
00144         BOOST_AUTO_TC_INVOKER( test_name ),TL >(                        \
00145           BOOST_STRINGIZE( test_name ) ) );                             \
00146                                                                         \
00147 template<typename type_name>                                            \
00148 void test_name<type_name>::test_method()                                \
00149 
00150 
00151 // ************************************************************************** //
00152 // **************           BOOST_TEST_CASE_TEMPLATE           ************** //
00153 // ************************************************************************** //
00154 
00155 #define BOOST_TEST_CASE_TEMPLATE( name, typelist )                          \
00156     boost::unit_test::ut_detail::template_test_case_gen<name,typelist >(    \
00157         BOOST_TEST_STRINGIZE( name ) )                                      \
00158 
00159 
00160 // ************************************************************************** //
00161 // **************      BOOST_TEST_CASE_TEMPLATE_FUNCTION       ************** //
00162 // ************************************************************************** //
00163 
00164 #define BOOST_TEST_CASE_TEMPLATE_FUNCTION( name, type_name )    \
00165 template<typename type_name>                                    \
00166 void BOOST_JOIN( name, _impl )( boost::type<type_name>* );      \
00167                                                                 \
00168 struct name {                                                   \
00169     template<typename TestType>                                 \
00170     static void run( boost::type<TestType>* frwrd = 0 )         \
00171     {                                                           \
00172        BOOST_JOIN( name, _impl )( frwrd );                      \
00173     }                                                           \
00174 };                                                              \
00175                                                                 \
00176 template<typename type_name>                                    \
00177 void BOOST_JOIN( name, _impl )( boost::type<type_name>* )       \
00178 
00179 
00180 // ************************************************************************** //
00181 // **************              BOOST_GLOBAL_FIXURE             ************** //
00182 // ************************************************************************** //
00183 
00184 #define BOOST_GLOBAL_FIXTURE( F ) \
00185 static boost::unit_test::ut_detail::global_fixture_impl<F> BOOST_JOIN( gf_, F ) ; \
00186 
00187 
00188 // ************************************************************************** //
00189 // **************         BOOST_AUTO_TEST_CASE_FIXTURE         ************** //
00190 // ************************************************************************** //
00191 
00192 namespace boost { namespace unit_test { namespace ut_detail {
00193 
00194 struct nil_t {};
00195 
00196 } // namespace ut_detail
00197 } // unit_test
00198 } // namespace boost
00199 
00200 // Intentionally is in global namespace, so that FIXURE_TEST_SUITE can reset it in user code.
00201 typedef ::boost::unit_test::ut_detail::nil_t BOOST_AUTO_TEST_CASE_FIXTURE;
00202 
00203 // ************************************************************************** //
00204 // **************   Auto registration facility helper macros   ************** //
00205 // ************************************************************************** //
00206 
00207 #define BOOST_AUTO_TU_REGISTRAR( test_name )    \
00208 static boost::unit_test::ut_detail::auto_test_unit_registrar BOOST_JOIN( BOOST_JOIN( test_name, _registrar ), __LINE__ )
00209 #define BOOST_AUTO_TC_INVOKER( test_name )      BOOST_JOIN( test_name, _invoker )
00210 #define BOOST_AUTO_TC_UNIQUE_ID( test_name )    BOOST_JOIN( test_name, _id )
00211 
00212 // ************************************************************************** //
00213 // **************                BOOST_TEST_MAIN               ************** //
00214 // ************************************************************************** //
00215 
00216 #if defined(BOOST_TEST_MAIN)
00217 
00218 #ifdef BOOST_TEST_ALTERNATIVE_INIT_API
00219 bool init_unit_test()                   {
00220 #else
00221 ::boost::unit_test::test_suite*
00222 init_unit_test_suite( int, char* [] )   {
00223 #endif
00224 
00225 #ifdef BOOST_TEST_MODULE
00226     using namespace ::boost::unit_test;
00227     assign_op( framework::master_test_suite().p_name.value, BOOST_TEST_STRINGIZE( BOOST_TEST_MODULE ).trim( "\"" ), 0 );
00228     
00229 #endif
00230 
00231 #ifdef BOOST_TEST_ALTERNATIVE_INIT_API
00232     return true;
00233 }
00234 #else
00235     return 0;
00236 }
00237 #endif
00238 
00239 #endif
00240 
00241 //____________________________________________________________________________//
00242 
00243 #endif // BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER
00244 


rtt
Author(s): RTT Developers
autogenerated on Wed Aug 26 2015 16:16:20