Test virtual inheritance from boost::exception

This commit is contained in:
Peter Dimov
2019-11-30 20:14:39 +02:00
parent ea9bd58f8c
commit 6458a1de40
3 changed files with 68 additions and 2 deletions

View File

@ -17,6 +17,10 @@ class my_exception2: public std::exception, public boost::exception
{
};
class my_exception3: public std::exception, public virtual boost::exception
{
};
int main()
{
try
@ -36,7 +40,7 @@ int main()
int const * line = boost::get_error_info<boost::throw_line>( x );
BOOST_TEST( line != 0 );
BOOST_TEST_EQ( *line, 24 );
BOOST_TEST_EQ( *line, 28 );
}
{
@ -64,7 +68,35 @@ int main()
int const * line = boost::get_error_info<boost::throw_line>( x );
BOOST_TEST( line != 0 );
BOOST_TEST_EQ( *line, 52 );
BOOST_TEST_EQ( *line, 56 );
}
{
char const * const * function = boost::get_error_info<boost::throw_function>( x );
BOOST_TEST( function != 0 );
BOOST_TEST_CSTR_EQ( *function, BOOST_CURRENT_FUNCTION );
}
}
try
{
BOOST_THROW_EXCEPTION( my_exception3() );
}
catch( boost::exception const & x )
{
{
char const * const * file = boost::get_error_info<boost::throw_file>( x );
BOOST_TEST( file != 0 );
BOOST_TEST_CSTR_EQ( *file, __FILE__ );
}
{
int const * line = boost::get_error_info<boost::throw_line>( x );
BOOST_TEST( line != 0 );
BOOST_TEST_EQ( *line, 84 );
}
{