mirror of
https://github.com/boostorg/exception.git
synced 2025-07-17 06:22:05 +02:00
decoupled boost/exception/exception.hpp from boost/exception/detail/type_info.hpp
diagnostic_information improvements documentation update [SVN r48469]
This commit is contained in:
@ -10,12 +10,37 @@
|
||||
struct throws_on_copy;
|
||||
struct non_printable { };
|
||||
|
||||
struct
|
||||
user_data
|
||||
{
|
||||
int & count;
|
||||
|
||||
explicit
|
||||
user_data( int & count ):
|
||||
count(count)
|
||||
{
|
||||
++count;
|
||||
}
|
||||
|
||||
user_data( user_data const & x ):
|
||||
count(x.count)
|
||||
{
|
||||
++count;
|
||||
}
|
||||
|
||||
~user_data()
|
||||
{
|
||||
--count;
|
||||
}
|
||||
};
|
||||
|
||||
typedef boost::error_info<struct tag_test_1,int> test_1;
|
||||
typedef boost::error_info<struct tag_test_2,unsigned int> test_2;
|
||||
typedef boost::error_info<struct tag_test_3,float> test_3;
|
||||
typedef boost::error_info<struct tag_test_4,throws_on_copy> test_4;
|
||||
typedef boost::error_info<struct tag_test_5,std::string> test_5;
|
||||
typedef boost::error_info<struct tag_test_6,non_printable> test_6;
|
||||
typedef boost::error_info<struct tag_user_data,user_data> test_7;
|
||||
|
||||
struct
|
||||
test_exception:
|
||||
@ -135,7 +160,9 @@ test_empty()
|
||||
catch(
|
||||
test_exception & x )
|
||||
{
|
||||
BOOST_TEST( boost::exception_detail::get_boost_exception(&x) );
|
||||
#ifndef BOOST_NO_RTTI
|
||||
BOOST_TEST( dynamic_cast<boost::exception const *>(&x)!=0 );
|
||||
#endif
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
@ -256,6 +283,29 @@ test_add_tuple()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_lifetime()
|
||||
{
|
||||
int count=0;
|
||||
try
|
||||
{
|
||||
throw test_exception() << test_7(user_data(count));
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
catch(
|
||||
boost::exception & x )
|
||||
{
|
||||
BOOST_TEST(count==1);
|
||||
BOOST_TEST( boost::get_error_info<test_7>(x) );
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
BOOST_TEST(!count);
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
@ -265,5 +315,6 @@ main()
|
||||
test_basic_throw_catch();
|
||||
test_catch_add_info();
|
||||
test_add_tuple();
|
||||
test_lifetime();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
Reference in New Issue
Block a user