]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/throw_exception/test/throw_exception_test4.cpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / libs / throw_exception / test / throw_exception_test4.cpp
1 // Copyright 2018 Peter Dimov
2 //
3 // Distributed under the Boost Software License, Version 1.0.
4 //
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
7
8 #include <boost/throw_exception.hpp>
9 #include <boost/exception/get_error_info.hpp>
10 #include <boost/detail/lightweight_test.hpp>
11
12 class my_exception: public std::exception
13 {
14 };
15
16 class my_exception2: public std::exception, public boost::exception
17 {
18 };
19
20 class my_exception3: public std::exception, public virtual boost::exception
21 {
22 };
23
24 int main()
25 {
26 try
27 {
28 BOOST_THROW_EXCEPTION( my_exception() );
29 }
30 catch( boost::exception const & x )
31 {
32 {
33 char const * const * file = boost::get_error_info<boost::throw_file>( x );
34
35 BOOST_TEST( file != 0 );
36 BOOST_TEST_CSTR_EQ( *file, __FILE__ );
37 }
38
39 {
40 int const * line = boost::get_error_info<boost::throw_line>( x );
41
42 BOOST_TEST( line != 0 );
43 BOOST_TEST_EQ( *line, 28 );
44 }
45
46 {
47 char const * const * function = boost::get_error_info<boost::throw_function>( x );
48
49 BOOST_TEST( function != 0 );
50 BOOST_TEST_CSTR_EQ( *function, BOOST_CURRENT_FUNCTION );
51 }
52 }
53
54 try
55 {
56 BOOST_THROW_EXCEPTION( my_exception2() );
57 }
58 catch( boost::exception const & x )
59 {
60 {
61 char const * const * file = boost::get_error_info<boost::throw_file>( x );
62
63 BOOST_TEST( file != 0 );
64 BOOST_TEST_CSTR_EQ( *file, __FILE__ );
65 }
66
67 {
68 int const * line = boost::get_error_info<boost::throw_line>( x );
69
70 BOOST_TEST( line != 0 );
71 BOOST_TEST_EQ( *line, 56 );
72 }
73
74 {
75 char const * const * function = boost::get_error_info<boost::throw_function>( x );
76
77 BOOST_TEST( function != 0 );
78 BOOST_TEST_CSTR_EQ( *function, BOOST_CURRENT_FUNCTION );
79 }
80 }
81
82 try
83 {
84 BOOST_THROW_EXCEPTION( my_exception3() );
85 }
86 catch( boost::exception const & x )
87 {
88 {
89 char const * const * file = boost::get_error_info<boost::throw_file>( x );
90
91 BOOST_TEST( file != 0 );
92 BOOST_TEST_CSTR_EQ( *file, __FILE__ );
93 }
94
95 {
96 int const * line = boost::get_error_info<boost::throw_line>( x );
97
98 BOOST_TEST( line != 0 );
99 BOOST_TEST_EQ( *line, 84 );
100 }
101
102 {
103 char const * const * function = boost::get_error_info<boost::throw_function>( x );
104
105 BOOST_TEST( function != 0 );
106 BOOST_TEST_CSTR_EQ( *function, BOOST_CURRENT_FUNCTION );
107 }
108 }
109
110 return boost::report_errors();
111 }