1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/test/exception_safety.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,207 @@
1.4 +// (C) Copyright Gennadiy Rozental 2005.
1.5 +// Distributed under the Boost Software License, Version 1.0.
1.6 +// (See accompanying file LICENSE_1_0.txt or copy at
1.7 +// http://www.boost.org/LICENSE_1_0.txt)
1.8 +
1.9 +// See http://www.boost.org/libs/test for the library home page.
1.10 +//
1.11 +// File : $RCSfile: exception_safety.hpp,v $
1.12 +//
1.13 +// Version : $Revision: 1.4 $
1.14 +//
1.15 +// Description : Facilities to perform exception safety tests
1.16 +// ***************************************************************************
1.17 +
1.18 +#ifndef BOOST_TEST_EXCEPTION_SAFETY_HPP_111705GER
1.19 +#define BOOST_TEST_EXCEPTION_SAFETY_HPP_111705GER
1.20 +
1.21 +// Boost.Test
1.22 +#include <boost/test/detail/config.hpp>
1.23 +
1.24 +#include <boost/test/utils/callback.hpp>
1.25 +
1.26 +// STL
1.27 +#include <memory>
1.28 +
1.29 +#include <boost/test/detail/suppress_warnings.hpp>
1.30 +
1.31 +//____________________________________________________________________________//
1.32 +
1.33 +// ************************************************************************** //
1.34 +// ************** BOOST_TEST_EXCEPTION_SAFETY ************** //
1.35 +// ************************************************************************** //
1.36 +
1.37 +#define BOOST_TEST_EXCEPTION_SAFETY( test_name ) \
1.38 +struct test_name : public BOOST_AUTO_TEST_CASE_FIXTURE \
1.39 +{ void test_method(); }; \
1.40 + \
1.41 +static void BOOST_AUTO_TC_INVOKER( test_name )() \
1.42 +{ \
1.43 + test_name t; \
1.44 + ::boost::itest::exception_safety( \
1.45 + boost::bind( &test_name::test_method, t ), \
1.46 + BOOST_STRINGIZE(test_name) ); \
1.47 +} \
1.48 + \
1.49 +struct BOOST_AUTO_TC_UNIQUE_ID( test_name ) {}; \
1.50 + \
1.51 +BOOST_AUTO_TC_REGISTRAR( test_name )( \
1.52 + boost::unit_test::make_test_case( \
1.53 + &BOOST_AUTO_TC_INVOKER( test_name ), #test_name ), \
1.54 + boost::unit_test::ut_detail::auto_tc_exp_fail< \
1.55 + BOOST_AUTO_TC_UNIQUE_ID( test_name )>::value ); \
1.56 + \
1.57 +void test_name::test_method() \
1.58 +/**/
1.59 +
1.60 +namespace boost {
1.61 +
1.62 +namespace itest {
1.63 +
1.64 +// ************************************************************************** //
1.65 +// ************** exception safety test ************** //
1.66 +// ************************************************************************** //
1.67 +
1.68 +void BOOST_TEST_DECL exception_safety( unit_test::callback0<> const& F,
1.69 + unit_test::const_string test_name = "" );
1.70 +
1.71 +} // namespace itest
1.72 +
1.73 +} // namespace boost
1.74 +
1.75 +// ************************************************************************** //
1.76 +// ************** global operator new/delete overloads ************** //
1.77 +// ************************************************************************** //
1.78 +
1.79 +#ifndef BOOST_ITEST_NO_NEW_OVERLOADS
1.80 +
1.81 +#include <boost/test/interaction_based.hpp>
1.82 +
1.83 +# ifdef BOOST_NO_STDC_NAMESPACE
1.84 +namespace std { using ::isprint; using ::malloc; using ::free; }
1.85 +# endif
1.86 +
1.87 +inline void*
1.88 +operator new( std::size_t s ) throw(std::bad_alloc)
1.89 +{
1.90 + void* res = std::malloc(s ? s : 1);
1.91 +
1.92 + if( res )
1.93 + ::boost::itest::manager::instance().allocated( 0, 0, res, s );
1.94 + else
1.95 + throw std::bad_alloc();
1.96 +
1.97 + return res;
1.98 +}
1.99 +
1.100 +//____________________________________________________________________________//
1.101 +
1.102 +inline void*
1.103 +operator new( std::size_t s, std::nothrow_t const& ) throw()
1.104 +{
1.105 + void* res = std::malloc(s ? s : 1);
1.106 +
1.107 + if( res )
1.108 + ::boost::itest::manager::instance().allocated( 0, 0, res, s );
1.109 +
1.110 + return res;
1.111 +}
1.112 +
1.113 +//____________________________________________________________________________//
1.114 +
1.115 +inline void*
1.116 +operator new[]( std::size_t s ) throw(std::bad_alloc)
1.117 +{
1.118 + void* res = std::malloc(s ? s : 1);
1.119 +
1.120 + if( res )
1.121 + ::boost::itest::manager::instance().allocated( 0, 0, res, s );
1.122 + else
1.123 + throw std::bad_alloc();
1.124 +
1.125 + return res;
1.126 +}
1.127 +
1.128 +//____________________________________________________________________________//
1.129 +
1.130 +inline void*
1.131 +operator new[]( std::size_t s, std::nothrow_t const& ) throw()
1.132 +{
1.133 + void* res = std::malloc(s ? s : 1);
1.134 +
1.135 + if( res )
1.136 + ::boost::itest::manager::instance().allocated( 0, 0, res, s );
1.137 +
1.138 + return res;
1.139 +}
1.140 +
1.141 +//____________________________________________________________________________//
1.142 +
1.143 +inline void
1.144 +operator delete( void* p ) throw()
1.145 +{
1.146 + ::boost::itest::manager::instance().freed( p );
1.147 +
1.148 + std::free( p );
1.149 +}
1.150 +
1.151 +//____________________________________________________________________________//
1.152 +
1.153 +inline void
1.154 +operator delete( void* p, std::nothrow_t const& ) throw()
1.155 +{
1.156 + ::boost::itest::manager::instance().freed( p );
1.157 +
1.158 + std::free( p );
1.159 +}
1.160 +
1.161 +//____________________________________________________________________________//
1.162 +
1.163 +inline void
1.164 +operator delete[]( void* p ) throw()
1.165 +{
1.166 + ::boost::itest::manager::instance().freed( p );
1.167 +
1.168 + std::free( p );
1.169 +}
1.170 +
1.171 +//____________________________________________________________________________//
1.172 +
1.173 +inline void
1.174 +operator delete[]( void* p, std::nothrow_t const& ) throw()
1.175 +{
1.176 + ::boost::itest::manager::instance().freed( p );
1.177 +
1.178 + std::free( p );
1.179 +}
1.180 +
1.181 +//____________________________________________________________________________//
1.182 +
1.183 +#endif // BOOST_ITEST_NO_NEW_OVERLOADS
1.184 +
1.185 +//____________________________________________________________________________//
1.186 +
1.187 +#include <boost/test/detail/enable_warnings.hpp>
1.188 +
1.189 +// ***************************************************************************
1.190 +// Revision History :
1.191 +//
1.192 +// $Log: exception_safety.hpp,v $
1.193 +// Revision 1.4 2006/01/28 08:52:35 rogeeff
1.194 +// operator new overloads made inline to:
1.195 +// 1. prevent issues with export them from DLL
1.196 +// 2. release link issue fixed
1.197 +//
1.198 +// Revision 1.3 2006/01/15 11:14:38 rogeeff
1.199 +// simpl_mock -> mock_object<>::prototype()
1.200 +// operator new need to be rethinked
1.201 +//
1.202 +// Revision 1.2 2005/12/20 23:50:13 rogeeff
1.203 +// unit_test.hpp removed
1.204 +//
1.205 +// Revision 1.1 2005/12/14 05:03:46 rogeeff
1.206 +// exception safety automatic testing facilties
1.207 +//
1.208 +// ***************************************************************************
1.209 +
1.210 +#endif // BOOST_TEST_EXCEPTION_SAFETY_HPP_111705GER