Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:52:40

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        : $RCSfile$
0009 //
0010 //  Version     : $Revision: 81247 $
0011 //
0012 //  Description : contains definition for all test tools in old test toolbox
0013 // ***************************************************************************
0014 
0015 #ifndef BOOST_TEST_TOOLS_OLD_INTERFACE_HPP_111712GER
0016 #define BOOST_TEST_TOOLS_OLD_INTERFACE_HPP_111712GER
0017 
0018 // Boost
0019 #include <boost/preprocessor/seq/for_each.hpp>
0020 #include <boost/preprocessor/seq/size.hpp>
0021 #include <boost/preprocessor/seq/to_tuple.hpp>
0022 
0023 #include <boost/core/ignore_unused.hpp>
0024 
0025 #include <boost/test/detail/suppress_warnings.hpp>
0026 
0027 //____________________________________________________________________________//
0028 
0029 // ************************************************************************** //
0030 // **************                    TOOL BOX                  ************** //
0031 // ************************************************************************** //
0032 
0033 // In macros below following argument abbreviations are used:
0034 // P - predicate
0035 // M - message
0036 // S - statement
0037 // E - exception
0038 // L - left argument
0039 // R - right argument
0040 // TL - tool level
0041 // CT - check type
0042 // ARGS - arguments list (as PP sequence)
0043 
0044 // frwd_type:
0045 // 0 - args exists and need to be forwarded; call check_frwd
0046 // 1 - args exists, but do not need to be forwarded; call report_assertion directly
0047 // 2 - no arguments; call report_assertion directly
0048 
0049 #define BOOST_TEST_TOOL_PASS_PRED0( P, ARGS ) P
0050 #define BOOST_TEST_TOOL_PASS_PRED1( P, ARGS ) P BOOST_PP_SEQ_TO_TUPLE(ARGS)
0051 #define BOOST_TEST_TOOL_PASS_PRED2( P, ARGS ) P
0052 
0053 #define BOOST_TEST_TOOL_PASS_ARG( r, _, arg ) , arg, BOOST_STRINGIZE( arg )
0054 #define BOOST_TEST_TOOL_PASS_ARG_DSCR( r, _, arg ) , BOOST_STRINGIZE( arg )
0055 
0056 #define BOOST_TEST_TOOL_PASS_ARGS0( ARGS ) \
0057     BOOST_PP_SEQ_FOR_EACH( BOOST_TEST_TOOL_PASS_ARG, _, ARGS )
0058 #define BOOST_TEST_TOOL_PASS_ARGS1( ARGS ) \
0059     , BOOST_PP_SEQ_SIZE(ARGS) BOOST_PP_SEQ_FOR_EACH( BOOST_TEST_TOOL_PASS_ARG_DSCR, _, ARGS )
0060 #define BOOST_TEST_TOOL_PASS_ARGS2( ARGS ) \
0061     , 0
0062 
0063 #define BOOST_TEST_TOOL_IMPL( frwd_type, P, assertion_descr, TL, CT, ARGS )     \
0064 do {                                                                            \
0065     BOOST_TEST_PASSPOINT();                                                     \
0066     ::boost::test_tools::tt_detail::                                            \
0067     BOOST_PP_IF( frwd_type, report_assertion, check_frwd ) (                    \
0068         BOOST_JOIN( BOOST_TEST_TOOL_PASS_PRED, frwd_type )( P, ARGS ),          \
0069         BOOST_TEST_LAZY_MSG( assertion_descr ),                                 \
0070         BOOST_TEST_L(__FILE__),                                                 \
0071         static_cast<std::size_t>(__LINE__),                                     \
0072         ::boost::test_tools::tt_detail::TL,                                     \
0073         ::boost::test_tools::tt_detail::CT                                      \
0074         BOOST_JOIN( BOOST_TEST_TOOL_PASS_ARGS, frwd_type )( ARGS ) );           \
0075 } while( ::boost::test_tools::tt_detail::dummy_cond() )                         \
0076 /**/
0077 
0078 //____________________________________________________________________________//
0079 
0080 #define BOOST_WARN( P )                     BOOST_TEST_TOOL_IMPL( 2, \
0081     (P), BOOST_TEST_STRINGIZE( P ), WARN, CHECK_PRED, _ )
0082 #define BOOST_CHECK( P )                    BOOST_TEST_TOOL_IMPL( 2, \
0083     (P), BOOST_TEST_STRINGIZE( P ), CHECK, CHECK_PRED, _ )
0084 #define BOOST_REQUIRE( P )                  BOOST_TEST_TOOL_IMPL( 2, \
0085     (P), BOOST_TEST_STRINGIZE( P ), REQUIRE, CHECK_PRED, _ )
0086 
0087 //____________________________________________________________________________//
0088 
0089 #define BOOST_WARN_MESSAGE( P, M )          BOOST_TEST_TOOL_IMPL( 2, (P), M, WARN, CHECK_MSG, _ )
0090 #define BOOST_CHECK_MESSAGE( P, M )         BOOST_TEST_TOOL_IMPL( 2, (P), M, CHECK, CHECK_MSG, _ )
0091 #define BOOST_REQUIRE_MESSAGE( P, M )       BOOST_TEST_TOOL_IMPL( 2, (P), M, REQUIRE, CHECK_MSG, _ )
0092 
0093 //____________________________________________________________________________//
0094 
0095 #define BOOST_ERROR( M )                    BOOST_CHECK_MESSAGE( false, M )
0096 #define BOOST_FAIL( M )                     BOOST_REQUIRE_MESSAGE( false, M )
0097 
0098 //____________________________________________________________________________//
0099 
0100 #define BOOST_CHECK_THROW_IMPL( S, E, P, postfix, TL )                                  \
0101 do {                                                                                    \
0102     try {                                                                               \
0103         BOOST_TEST_PASSPOINT();                                                         \
0104         S;                                                                              \
0105         BOOST_TEST_TOOL_IMPL( 2, false, "exception " BOOST_STRINGIZE(E) " expected but not raised", \
0106                               TL, CHECK_MSG, _ );                                       \
0107     } catch( E const& ex ) {                                                            \
0108         boost::ignore_unused( ex );                                                     \
0109         BOOST_TEST_TOOL_IMPL( 2, P,                                                     \
0110                               "exception \"" BOOST_STRINGIZE( E )"\" raised as expected" postfix,   \
0111                               TL, CHECK_MSG, _  );                                      \
0112     }                                                                                   \
0113 } while( ::boost::test_tools::tt_detail::dummy_cond() )                                 \
0114 /**/
0115 
0116 //____________________________________________________________________________//
0117 
0118 #define BOOST_WARN_THROW( S, E )            BOOST_CHECK_THROW_IMPL( S, E, true, "", WARN )
0119 #define BOOST_CHECK_THROW( S, E )           BOOST_CHECK_THROW_IMPL( S, E, true, "", CHECK )
0120 #define BOOST_REQUIRE_THROW( S, E )         BOOST_CHECK_THROW_IMPL( S, E, true, "", REQUIRE )
0121 
0122 //____________________________________________________________________________//
0123 
0124 #define BOOST_WARN_EXCEPTION( S, E, P )     BOOST_CHECK_THROW_IMPL( S, E, P( ex ), \
0125               ": validation on the raised exception through predicate \"" BOOST_STRINGIZE(P) "\"", WARN )
0126 #define BOOST_CHECK_EXCEPTION( S, E, P )    BOOST_CHECK_THROW_IMPL( S, E, P( ex ), \
0127               ": validation on the raised exception through predicate \"" BOOST_STRINGIZE(P) "\"", CHECK )
0128 #define BOOST_REQUIRE_EXCEPTION( S, E, P )  BOOST_CHECK_THROW_IMPL( S, E, P( ex ), \
0129               ": validation on the raised exception through predicate \"" BOOST_STRINGIZE(P) "\"", REQUIRE )
0130 
0131 //____________________________________________________________________________//
0132 
0133 #define BOOST_CHECK_NO_THROW_IMPL( S, TL )                                              \
0134 do {                                                                                    \
0135     try {                                                                               \
0136         S;                                                                              \
0137         BOOST_TEST_TOOL_IMPL( 2, true, "no exceptions thrown by " BOOST_STRINGIZE( S ), \
0138                               TL, CHECK_MSG, _ );                                       \
0139     } catch( ... ) {                                                                    \
0140         BOOST_TEST_TOOL_IMPL( 2, false, "unexpected exception thrown by " BOOST_STRINGIZE( S ),    \
0141                               TL, CHECK_MSG, _ );                                       \
0142     }                                                                                   \
0143 } while( ::boost::test_tools::tt_detail::dummy_cond() )                                 \
0144 /**/
0145 
0146 #define BOOST_WARN_NO_THROW( S )            BOOST_CHECK_NO_THROW_IMPL( S, WARN )
0147 #define BOOST_CHECK_NO_THROW( S )           BOOST_CHECK_NO_THROW_IMPL( S, CHECK )
0148 #define BOOST_REQUIRE_NO_THROW( S )         BOOST_CHECK_NO_THROW_IMPL( S, REQUIRE )
0149 
0150 //____________________________________________________________________________//
0151 
0152 #define BOOST_WARN_EQUAL( L, R )            BOOST_TEST_TOOL_IMPL( 0, \
0153     ::boost::test_tools::tt_detail::equal_impl_frwd(), "", WARN, CHECK_EQUAL, (L)(R) )
0154 #define BOOST_CHECK_EQUAL( L, R )           BOOST_TEST_TOOL_IMPL( 0, \
0155     ::boost::test_tools::tt_detail::equal_impl_frwd(), "", CHECK, CHECK_EQUAL, (L)(R) )
0156 #define BOOST_REQUIRE_EQUAL( L, R )         BOOST_TEST_TOOL_IMPL( 0, \
0157     ::boost::test_tools::tt_detail::equal_impl_frwd(), "", REQUIRE, CHECK_EQUAL, (L)(R) )
0158 
0159 //____________________________________________________________________________//
0160 
0161 #define BOOST_WARN_NE( L, R )               BOOST_TEST_TOOL_IMPL( 0, \
0162     ::boost::test_tools::tt_detail::ne_impl(), "", WARN, CHECK_NE, (L)(R) )
0163 #define BOOST_CHECK_NE( L, R )              BOOST_TEST_TOOL_IMPL( 0, \
0164     ::boost::test_tools::tt_detail::ne_impl(), "", CHECK, CHECK_NE, (L)(R) )
0165 #define BOOST_REQUIRE_NE( L, R )            BOOST_TEST_TOOL_IMPL( 0, \
0166     ::boost::test_tools::tt_detail::ne_impl(), "", REQUIRE, CHECK_NE, (L)(R) )
0167 
0168 //____________________________________________________________________________//
0169 
0170 #define BOOST_WARN_LT( L, R )               BOOST_TEST_TOOL_IMPL( 0, \
0171     ::boost::test_tools::tt_detail::lt_impl(), "", WARN, CHECK_LT, (L)(R) )
0172 #define BOOST_CHECK_LT( L, R )              BOOST_TEST_TOOL_IMPL( 0, \
0173     ::boost::test_tools::tt_detail::lt_impl(), "", CHECK, CHECK_LT, (L)(R) )
0174 #define BOOST_REQUIRE_LT( L, R )            BOOST_TEST_TOOL_IMPL( 0, \
0175     ::boost::test_tools::tt_detail::lt_impl(), "", REQUIRE, CHECK_LT, (L)(R) )
0176 
0177 //____________________________________________________________________________//
0178 
0179 #define BOOST_WARN_LE( L, R )               BOOST_TEST_TOOL_IMPL( 0, \
0180     ::boost::test_tools::tt_detail::le_impl(), "", WARN, CHECK_LE, (L)(R) )
0181 #define BOOST_CHECK_LE( L, R )              BOOST_TEST_TOOL_IMPL( 0, \
0182     ::boost::test_tools::tt_detail::le_impl(), "", CHECK, CHECK_LE, (L)(R) )
0183 #define BOOST_REQUIRE_LE( L, R )            BOOST_TEST_TOOL_IMPL( 0, \
0184     ::boost::test_tools::tt_detail::le_impl(), "", REQUIRE, CHECK_LE, (L)(R) )
0185 
0186 //____________________________________________________________________________//
0187 
0188 #define BOOST_WARN_GT( L, R )               BOOST_TEST_TOOL_IMPL( 0, \
0189     ::boost::test_tools::tt_detail::gt_impl(), "", WARN, CHECK_GT, (L)(R) )
0190 #define BOOST_CHECK_GT( L, R )              BOOST_TEST_TOOL_IMPL( 0, \
0191     ::boost::test_tools::tt_detail::gt_impl(), "", CHECK, CHECK_GT, (L)(R) )
0192 #define BOOST_REQUIRE_GT( L, R )            BOOST_TEST_TOOL_IMPL( 0, \
0193     ::boost::test_tools::tt_detail::gt_impl(), "", REQUIRE, CHECK_GT, (L)(R) )
0194 
0195 //____________________________________________________________________________//
0196 
0197 #define BOOST_WARN_GE( L, R )               BOOST_TEST_TOOL_IMPL( 0, \
0198     ::boost::test_tools::tt_detail::ge_impl(), "", WARN, CHECK_GE, (L)(R) )
0199 #define BOOST_CHECK_GE( L, R )              BOOST_TEST_TOOL_IMPL( 0, \
0200     ::boost::test_tools::tt_detail::ge_impl(), "", CHECK, CHECK_GE, (L)(R) )
0201 #define BOOST_REQUIRE_GE( L, R )            BOOST_TEST_TOOL_IMPL( 0, \
0202     ::boost::test_tools::tt_detail::ge_impl(), "", REQUIRE, CHECK_GE, (L)(R) )
0203 
0204 //____________________________________________________________________________//
0205 
0206 #define BOOST_WARN_CLOSE( L, R, T )         BOOST_TEST_TOOL_IMPL( 0, \
0207     ::boost::test_tools::check_is_close_t(), "", WARN, CHECK_CLOSE, (L)(R)(::boost::math::fpc::percent_tolerance(T)) )
0208 #define BOOST_CHECK_CLOSE( L, R, T )        BOOST_TEST_TOOL_IMPL( 0, \
0209     ::boost::test_tools::check_is_close_t(), "", CHECK, CHECK_CLOSE, (L)(R)(::boost::math::fpc::percent_tolerance(T)) )
0210 #define BOOST_REQUIRE_CLOSE( L, R, T )      BOOST_TEST_TOOL_IMPL( 0, \
0211     ::boost::test_tools::check_is_close_t(), "", REQUIRE, CHECK_CLOSE, (L)(R)(::boost::math::fpc::percent_tolerance(T)) )
0212 
0213 //____________________________________________________________________________//
0214 
0215 #define BOOST_WARN_CLOSE_FRACTION(L, R, T)  BOOST_TEST_TOOL_IMPL( 0, \
0216     ::boost::test_tools::check_is_close_t(), "", WARN, CHECK_CLOSE_FRACTION, (L)(R)(T) )
0217 #define BOOST_CHECK_CLOSE_FRACTION(L, R, T) BOOST_TEST_TOOL_IMPL( 0, \
0218     ::boost::test_tools::check_is_close_t(), "", CHECK, CHECK_CLOSE_FRACTION, (L)(R)(T) )
0219 #define BOOST_REQUIRE_CLOSE_FRACTION(L,R,T) BOOST_TEST_TOOL_IMPL( 0, \
0220     ::boost::test_tools::check_is_close_t(), "", REQUIRE, CHECK_CLOSE_FRACTION, (L)(R)(T) )
0221 
0222 //____________________________________________________________________________//
0223 
0224 #define BOOST_WARN_SMALL( FPV, T )          BOOST_TEST_TOOL_IMPL( 0, \
0225     ::boost::test_tools::check_is_small_t(), "", WARN, CHECK_SMALL, (FPV)(T) )
0226 #define BOOST_CHECK_SMALL( FPV, T )         BOOST_TEST_TOOL_IMPL( 0, \
0227     ::boost::test_tools::check_is_small_t(), "", CHECK, CHECK_SMALL, (FPV)(T) )
0228 #define BOOST_REQUIRE_SMALL( FPV, T )       BOOST_TEST_TOOL_IMPL( 0, \
0229     ::boost::test_tools::check_is_small_t(), "", REQUIRE, CHECK_SMALL, (FPV)(T) )
0230 
0231 //____________________________________________________________________________//
0232 
0233 #define BOOST_WARN_PREDICATE( P, ARGS )     BOOST_TEST_TOOL_IMPL( 0, \
0234     P, BOOST_TEST_STRINGIZE( P ), WARN, CHECK_PRED_WITH_ARGS, ARGS )
0235 #define BOOST_CHECK_PREDICATE( P, ARGS )    BOOST_TEST_TOOL_IMPL( 0, \
0236     P, BOOST_TEST_STRINGIZE( P ), CHECK, CHECK_PRED_WITH_ARGS, ARGS )
0237 #define BOOST_REQUIRE_PREDICATE( P, ARGS )  BOOST_TEST_TOOL_IMPL( 0, \
0238     P, BOOST_TEST_STRINGIZE( P ), REQUIRE, CHECK_PRED_WITH_ARGS, ARGS )
0239 
0240 //____________________________________________________________________________//
0241 
0242 #define BOOST_WARN_EQUAL_COLLECTIONS( L_begin, L_end, R_begin, R_end )                  \
0243     BOOST_TEST_TOOL_IMPL( 1, ::boost::test_tools::tt_detail::equal_coll_impl(),         \
0244         "", WARN, CHECK_EQUAL_COLL, (L_begin)(L_end)(R_begin)(R_end) )                  \
0245 /**/
0246 #define BOOST_CHECK_EQUAL_COLLECTIONS( L_begin, L_end, R_begin, R_end )                 \
0247     BOOST_TEST_TOOL_IMPL( 1, ::boost::test_tools::tt_detail::equal_coll_impl(),         \
0248         "", CHECK, CHECK_EQUAL_COLL, (L_begin)(L_end)(R_begin)(R_end) )                 \
0249 /**/
0250 #define BOOST_REQUIRE_EQUAL_COLLECTIONS( L_begin, L_end, R_begin, R_end )               \
0251     BOOST_TEST_TOOL_IMPL( 1, ::boost::test_tools::tt_detail::equal_coll_impl(),         \
0252         "", REQUIRE, CHECK_EQUAL_COLL, (L_begin)(L_end)(R_begin)(R_end) )               \
0253 /**/
0254 
0255 //____________________________________________________________________________//
0256 
0257 #define BOOST_WARN_BITWISE_EQUAL( L, R )    BOOST_TEST_TOOL_IMPL( 1, \
0258     ::boost::test_tools::tt_detail::bitwise_equal_impl(), "", WARN, CHECK_BITWISE_EQUAL, (L)(R) )
0259 #define BOOST_CHECK_BITWISE_EQUAL( L, R )   BOOST_TEST_TOOL_IMPL( 1, \
0260     ::boost::test_tools::tt_detail::bitwise_equal_impl(), "", CHECK, CHECK_BITWISE_EQUAL, (L)(R) )
0261 #define BOOST_REQUIRE_BITWISE_EQUAL( L, R ) BOOST_TEST_TOOL_IMPL( 1, \
0262     ::boost::test_tools::tt_detail::bitwise_equal_impl(), "", REQUIRE, CHECK_BITWISE_EQUAL, (L)(R) )
0263 
0264 //____________________________________________________________________________//
0265 
0266 #define BOOST_IS_DEFINED( symb ) ::boost::test_tools::tt_detail::is_defined_impl( #symb, BOOST_STRINGIZE(= symb) )
0267 
0268 //____________________________________________________________________________//
0269 
0270 #ifdef BOOST_TEST_NO_NEW_TOOLS
0271 
0272 #define BOOST_TEST_WARN( P )                BOOST_WARN( P )
0273 #define BOOST_TEST_CHECK( P )               BOOST_CHECK( P )
0274 #define BOOST_TEST_REQUIRE( P )             BOOST_REQUIRE( P )
0275 
0276 #define BOOST_TEST( P )                     BOOST_CHECK( P )
0277 
0278 #endif
0279 
0280 //____________________________________________________________________________//
0281 
0282 #include <boost/test/detail/enable_warnings.hpp>
0283 
0284 #endif // BOOST_TEST_TOOLS_OLD_INTERFACE_HPP_111712GER