1 // (C) Copyright Gennadiy Rozental 2001. 2 // Distributed under the Boost Software License, Version 1.0. 3 // (See accompanying file LICENSE_1_0.txt or copy at 4 // http://www.boost.org/LICENSE_1_0.txt) 5 6 // See http://www.boost.org/libs/test for the library home page. 7 // 8 //!@file 9 //!@brief contains wrappers, which allows to build Boost.Test with no exception 10 // *************************************************************************** 11 12 #ifndef BOOST_TEST_DETAIL_THROW_EXCEPTION_HPP 13 #define BOOST_TEST_DETAIL_THROW_EXCEPTION_HPP 14 15 // Boost 16 #include <boost/config.hpp> // BOOST_NO_EXCEPTIONS 17 18 #ifdef BOOST_NO_EXCEPTIONS 19 // C RUNTIME 20 #include <stdlib.h> 21 22 #endif 23 24 #include <boost/test/detail/suppress_warnings.hpp> 25 26 //____________________________________________________________________________// 27 28 namespace boost { 29 namespace unit_test { 30 namespace ut_detail { 31 32 #ifdef BOOST_NO_EXCEPTIONS 33 34 template<typename E> 35 BOOST_NORETURN inline void throw_exception(E const &)36throw_exception(E const& /*e*/) { abort(); } 37 38 #define BOOST_TEST_I_TRY 39 #define BOOST_TEST_I_CATCH( T, var ) for(T const& var = *(T*)0; false;) 40 #define BOOST_TEST_I_CATCH0( T ) if(0) 41 #define BOOST_TEST_I_CATCHALL() if(0) 42 #define BOOST_TEST_I_RETHROW 43 44 #else 45 46 template<typename E> 47 BOOST_NORETURN inline void 48 throw_exception(E const& e) { throw e; } 49 50 #define BOOST_TEST_I_TRY try 51 #define BOOST_TEST_I_CATCH( T, var ) catch( T const& var ) 52 #define BOOST_TEST_I_CATCH0( T ) catch( T const& ) 53 #define BOOST_TEST_I_CATCHALL() catch(...) 54 #define BOOST_TEST_I_RETHROW throw 55 #endif 56 57 //____________________________________________________________________________// 58 59 #define BOOST_TEST_I_THROW( E ) unit_test::ut_detail::throw_exception( E ) 60 #define BOOST_TEST_I_ASSRT( cond, ex ) if( cond ) {} else BOOST_TEST_I_THROW( ex ) 61 62 63 } // namespace ut_detail 64 } // namespace unit_test 65 } // namespace boost 66 67 //____________________________________________________________________________// 68 69 #include <boost/test/detail/enable_warnings.hpp> 70 71 #endif // BOOST_TEST_DETAIL_THROW_EXCEPTION_HPP 72