]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/leaf/test/capture_exception_state_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) || !BOOST_LEAF_CFG_CAPTURE
14 std::cout
<< "Unit test not applicable." << std::endl
;
20 #ifdef BOOST_LEAF_TEST_SINGLE_HEADER
23 # include <boost/leaf/capture.hpp>
24 # include <boost/leaf/handle_errors.hpp>
25 # include <boost/leaf/exception.hpp>
28 #include "lightweight_test.hpp"
30 namespace leaf
= boost::leaf
;
42 info( info
const & ) noexcept
55 auto error_handlers
= std::make_tuple(
56 []( info
<1>, info
<3> )
64 BOOST_TEST_EQ(count
, 0);
65 std::exception_ptr ep
;
69 leaf::make_shared_context(error_handlers
),
72 throw leaf::exception(info
<1>{}, info
<3>{});
78 ep
= std::current_exception();
80 BOOST_TEST_EQ(count
, 2);
81 int r
= leaf::try_catch(
84 std::rethrow_exception(ep
);
88 ep
= std::exception_ptr();
89 BOOST_TEST_EQ(count
, 0);
90 return boost::report_errors();