]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/leaf/test/defer_nested_new_error_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 #ifdef BOOST_LEAF_NO_EXCEPTIONS
14 std::cout
<< "Unit test not applicable." << std::endl
;
20 #ifdef BOOST_LEAF_TEST_SINGLE_HEADER
23 # include <boost/leaf/on_error.hpp>
24 # include <boost/leaf/handle_errors.hpp>
25 # include <boost/leaf/exception.hpp>
28 #include "lightweight_test.hpp"
30 namespace leaf
= boost::leaf
;
40 auto load
= leaf::on_error( [] { return info
<0>{-1}; } );
41 throw leaf::exception(info
<1>{-1});
46 auto load
= leaf::on_error( [] { return info
<0>{0}; }, [] { return info
<1>{1}; }, [] { return info
<2>{2}; } );
47 try { f0(); } catch(...) { }
48 throw leaf::exception();
58 catch( leaf::error_id
const & err
)
60 err
.load( info
<3>{3} );
67 return leaf::new_error();
72 int r
= leaf::try_catch(
78 []( info
<0> i0
, info
<1> i1
, info
<2> i2
, info
<3> i3
)
80 BOOST_TEST_EQ(i0
.value
, 0);
81 BOOST_TEST_EQ(i1
.value
, 1);
82 BOOST_TEST_EQ(i2
.value
, 2);
83 BOOST_TEST_EQ(i3
.value
, 3);
92 return boost::report_errors();