]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/beast/test/beast/core/handler_ptr.cpp
2 // Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // Official repository: https://github.com/boostorg/beast
10 // Test that header file is self-contained.
11 #include <boost/beast/core/handler_ptr.hpp>
13 #include <boost/beast/unit_test/suite.hpp>
21 class handler_ptr_test
: public beast::unit_test::suite
26 std::unique_ptr
<int> ptr
;
27 void operator()(bool& b
) const
35 explicit T(handler
const&)
49 explicit U(handler
const&)
51 throw std::exception
{};
54 handler_ptr
<T
, handler
> p1
{handler
{}};
57 handler_ptr
<U
, handler
> p2
{handler
{}};
60 catch(std::exception
const&)
66 fail("", __FILE__
, __LINE__
);
73 struct throwing_handler
75 throwing_handler() = default;
76 throwing_handler(throwing_handler
&&)
78 throw std::bad_alloc
{};
80 void operator()() const
86 explicit T(throwing_handler
const&) noexcept
{}
91 handler_ptr
<T
, throwing_handler
> p
{std::move(h
)};
92 fail("", __FILE__
, __LINE__
);
94 catch (std::bad_alloc
const&)
103 handler_ptr
<T
, handler
> p
{handler
{}};
105 p
.invoke(std::ref(b
));
118 BEAST_DEFINE_TESTSUITE(beast
,core
,handler_ptr
);