]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/leaf/test/boost_exception_test.cpp
1 // Copyright 2018-2022 Emil Dotchevski and Reverge Studios, Inc.
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #include <boost/leaf/config.hpp>
8 #if defined(BOOST_LEAF_NO_EXCEPTIONS) || !defined(BOOST_LEAF_BOOST_AVAILABLE)
14 std::cout
<< "Unit test not applicable." << std::endl
;
20 #ifdef BOOST_LEAF_TEST_SINGLE_HEADER
23 # include <boost/leaf/handle_errors.hpp>
24 # include <boost/leaf/pred.hpp>
27 #include "lightweight_test.hpp"
28 #include <boost/exception/info.hpp>
29 #include <boost/exception/get_error_info.hpp>
31 namespace leaf
= boost::leaf
;
33 struct test_ex
: std::exception
{ };
35 typedef boost::error_info
<struct test_info_
, int> test_info
;
39 static_assert(std::is_same
<test_info
, decltype(std::declval
<leaf::match
<test_info
, 42>>().matched
)>::value
, "handler_argument_traits deduction bug");
41 using tr
= leaf::leaf_detail::handler_argument_traits
<leaf::match
<test_info
, 42>>;
42 static_assert(std::is_same
<void, tr::error_type
>::value
, "handler_argument_traits deduction bug");
45 int r
= leaf::try_catch(
50 boost::throw_exception(test_ex());
52 catch( boost::exception
& ex
)
61 BOOST_TEST_EQ(x
.value(), 42);
72 int r
= leaf::try_catch(
77 boost::throw_exception(test_ex());
79 catch( boost::exception
& ex
)
86 []( leaf::match
<test_info
, 42> )
98 int r
= leaf::try_catch(
103 boost::throw_exception(test_ex());
105 catch( boost::exception
& ex
)
112 []( leaf::match
<test_info
, 41> )
123 return boost::report_errors();