]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/leaf/test/preload_exception_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 #if defined(BOOST_LEAF_NO_EXCEPTIONS) || defined(BOOST_LEAF_NO_THREADS)
13 std::cout
<< "Unit test not applicable." << std::endl
;
19 #include <boost/leaf/on_error.hpp>
20 #include <boost/leaf/handle_errors.hpp>
21 #include <boost/leaf/result.hpp>
22 #include "lightweight_test.hpp"
24 namespace leaf
= boost::leaf
;
32 template <class Thrower
>
35 auto load
= leaf::on_error( info
<1>{} );
39 template <class Thrower
>
42 auto load
= leaf::on_error(info
<3>{}, info
<2>{} );
46 template <class Thrower
>
52 template <class Thrower
>
64 f1( [] { throw leaf::exception(); } );
67 []( leaf::error_info
const & err
, info
<1> )
69 BOOST_TEST_EQ(err
.error().value(), 1);
76 []( info
<1>, info
<2> )
85 f2( [] { throw leaf::exception(); } );
92 []( leaf::error_info
const & err
, info
<2>, info
<3> )
94 BOOST_TEST_EQ(err
.error().value(), 9);
97 []( info
<1>, info
<2> )
106 f1( [] { throw std::exception(); } );
109 []( leaf::error_info
const & err
, info
<1> )
111 BOOST_TEST_EQ(err
.error().value(), 17);
118 []( info
<1>, info
<2> )
127 f2( [] { throw std::exception(); } );
134 []( leaf::error_info
const & err
, info
<2>, info
<3> )
136 BOOST_TEST_EQ(err
.error().value(), 21);
139 []( info
<1>, info
<2> )
144 return boost::report_errors();