]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/throw_exception/test/throw_from_library_test.cpp
1 // Copyright 2018 Peter Dimov
3 // Distributed under the Boost Software License, Version 1.0.
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
8 #include "lib1_throw.hpp"
9 #include "lib2_throw.hpp"
10 #include "lib3_throw.hpp"
11 #include <boost/exception/exception.hpp>
12 #include <boost/exception_ptr.hpp>
13 #include <boost/exception/get_error_info.hpp>
14 #include <boost/core/lightweight_test.hpp>
16 void test_catch_by_type()
18 BOOST_TEST_THROWS( lib1::f(), lib1::exception
);
19 BOOST_TEST_THROWS( lib2::f(), lib2::exception
);
20 BOOST_TEST_THROWS( lib3::f(), lib3::exception
);
23 void test_catch_by_exception()
25 BOOST_TEST_THROWS( lib2::f(), boost::exception
);
26 BOOST_TEST_THROWS( lib3::f(), boost::exception
);
29 void test_exception_ptr()
37 boost::exception_ptr p
= boost::current_exception();
39 BOOST_TEST_THROWS( boost::rethrow_exception( p
), lib2::exception
);
40 BOOST_TEST_THROWS( boost::rethrow_exception( p
), boost::exception
);
49 boost::exception_ptr p
= boost::current_exception();
51 BOOST_TEST_THROWS( boost::rethrow_exception( p
), lib3::exception
);
52 BOOST_TEST_THROWS( boost::rethrow_exception( p
), boost::exception
);
56 void test_throw_line()
62 catch( boost::exception
const & x
)
64 int const * line
= boost::get_error_info
<boost::throw_line
>( x
);
66 BOOST_TEST( line
!= 0 );
67 BOOST_TEST_EQ( *line
, 13 );
74 test_catch_by_exception();
78 return boost::report_errors();