]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/leaf/test/capture_exception_state_test.cpp
1 // Copyright (c) 2018-2020 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/detail/config.hpp>
7 #ifdef BOOST_LEAF_NO_EXCEPTIONS
13 std::cout
<< "Unit test not applicable." << std::endl
;
19 #include <boost/leaf/capture.hpp>
20 #include <boost/leaf/handle_errors.hpp>
21 #include <boost/leaf/exception.hpp>
22 #include "lightweight_test.hpp"
24 namespace leaf
= boost::leaf
;
36 info( info
const & ) noexcept
49 auto error_handlers
= std::make_tuple(
50 []( info
<1>, info
<3> )
58 BOOST_TEST_EQ(count
, 0);
59 std::exception_ptr ep
;
63 leaf::make_shared_context(error_handlers
),
66 throw leaf::exception(info
<1>{}, info
<3>{});
72 ep
= std::current_exception();
74 BOOST_TEST_EQ(count
, 2);
75 int r
= leaf::try_catch(
78 std::rethrow_exception(ep
);
82 ep
= std::exception_ptr();
83 BOOST_TEST_EQ(count
, 0);
84 return boost::report_errors();