]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/leaf/test/defer_basic_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/on_error.hpp>
7 #include <boost/leaf/handle_errors.hpp>
8 #include <boost/leaf/result.hpp>
9 #include "lightweight_test.hpp"
12 namespace leaf
= boost::leaf
;
16 int get_global() noexcept
30 auto load
= leaf::on_error( []{ return info
<42>{get_global()}; }, []{ return info
<-42>{-42}; } );
32 return leaf::new_error();
42 int r
= leaf::try_handle_all(
43 []() -> leaf::result
<int>
47 []( info
<42> const & i42
, leaf::diagnostic_info
const & di
)
49 BOOST_TEST_EQ(i42
.value
, 42);
50 std::stringstream ss
; ss
<< di
;
51 std::string s
= ss
.str();
53 #if BOOST_LEAF_DIAGNOSTICS
54 BOOST_TEST(s
.find("info<-42>")!=s
.npos
);
56 BOOST_TEST(s
.find("BOOST_LEAF_DIAGNOSTICS")!=s
.npos
);
65 return boost::report_errors();