2009-04-07 03:02:15 +00:00
|
|
|
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
2008-03-04 01:41:17 +00:00
|
|
|
|
|
|
|
//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)
|
|
|
|
|
|
|
|
#include "helper1.hpp"
|
2008-08-28 23:49:55 +00:00
|
|
|
#include <boost/exception/get_error_info.hpp>
|
2008-03-04 01:41:17 +00:00
|
|
|
#include <boost/exception/info.hpp>
|
2008-06-25 23:27:56 +00:00
|
|
|
#include <boost/exception/diagnostic_information.hpp>
|
2008-03-04 01:41:17 +00:00
|
|
|
#include <boost/detail/lightweight_test.hpp>
|
|
|
|
|
|
|
|
namespace
|
2008-04-08 21:29:37 +00:00
|
|
|
{
|
|
|
|
typedef boost::error_info<struct tag_test_int,int> test_int;
|
2008-03-04 01:41:17 +00:00
|
|
|
|
2008-04-08 21:29:37 +00:00
|
|
|
void
|
|
|
|
throw_wrapper()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
boost::exception_test::throw_length_error();
|
|
|
|
}
|
|
|
|
catch(
|
|
|
|
boost::exception & x )
|
|
|
|
{
|
|
|
|
x << test_int(42);
|
|
|
|
throw;
|
|
|
|
}
|
2008-06-25 23:27:56 +00:00
|
|
|
catch(
|
|
|
|
... )
|
|
|
|
{
|
|
|
|
BOOST_TEST(false);
|
|
|
|
}
|
2008-04-08 21:29:37 +00:00
|
|
|
}
|
|
|
|
}
|
2008-03-04 01:41:17 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
main()
|
2008-04-08 21:29:37 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
throw_wrapper();
|
|
|
|
BOOST_TEST(false);
|
|
|
|
}
|
|
|
|
catch(
|
|
|
|
std::exception & x )
|
|
|
|
{
|
2008-08-30 02:57:12 +00:00
|
|
|
#ifdef BOOST_NO_RTTI
|
|
|
|
try
|
|
|
|
{
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
catch(
|
|
|
|
boost::exception & x )
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
BOOST_TEST( boost::get_error_info<test_int>(x) );
|
2009-04-06 23:15:42 +00:00
|
|
|
if( int const * p=boost::get_error_info<test_int>(x) )
|
2008-08-30 02:57:12 +00:00
|
|
|
BOOST_TEST( 42==*p );
|
|
|
|
#ifdef BOOST_NO_RTTI
|
|
|
|
}
|
|
|
|
catch(
|
|
|
|
... )
|
|
|
|
{
|
|
|
|
BOOST_TEST(false);
|
|
|
|
}
|
|
|
|
#endif
|
2008-06-25 23:27:56 +00:00
|
|
|
BOOST_TEST( std::string(x.what())==std::string("exception test length error") );
|
2008-04-08 21:29:37 +00:00
|
|
|
}
|
|
|
|
catch(
|
|
|
|
... )
|
|
|
|
{
|
|
|
|
BOOST_TEST(false);
|
|
|
|
}
|
|
|
|
return boost::report_errors();
|
|
|
|
}
|