]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/beast/test/beast/core/_detail_bind_continuation.cpp
2 // Copyright (c) 2016-2019 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/detail/bind_continuation.hpp>
15 #include "test_executor.hpp"
16 #include "test_handler.hpp"
18 #include <boost/beast/_experimental/unit_test/suite.hpp>
19 #include <boost/beast/core/error.hpp>
20 #include <boost/beast/core/stream_traits.hpp>
21 #include <boost/asio/io_context.hpp>
22 #include <boost/asio/dispatch.hpp>
23 #include <boost/asio/post.hpp>
24 #include <boost/asio/defer.hpp>
25 #include <boost/core/exchange.hpp>
31 class bind_continuation_test
32 : public beast::unit_test::suite
47 handler(handler
&& other
)
48 : pass_(boost::exchange(other
.pass_
, true))
66 test_executor
<> ex(ioc
.get_executor());
67 BEAST_EXPECT(ex
->total
== 0);
69 bind_continuation(ex
, handler
{}));
72 BEAST_EXPECT(ex
->dispatch
== 1);
76 test_executor
<> ex(ioc
.get_executor());
77 BEAST_EXPECT(ex
->total
== 0);
79 bind_continuation(ex
, handler
{}));
82 BEAST_EXPECT(ex
->defer
== 1);
86 test_executor
<> ex(ioc
.get_executor());
87 BEAST_EXPECT(ex
->total
== 0);
89 bind_continuation(ex
, handler
{}));
92 BEAST_EXPECT(ex
->defer
== 1);
98 test_executor
<> ex(ioc
.get_executor());
99 BEAST_EXPECT(ex
->total
== 0);
101 bind_continuation(ex
, handler
{}),
102 std::allocator
<void>{});
105 BEAST_EXPECT(ex
->dispatch
== 1);
109 test_executor
<> ex(ioc
.get_executor());
110 BEAST_EXPECT(ex
->total
== 0);
112 bind_continuation(ex
, handler
{}),
113 std::allocator
<void>{});
116 BEAST_EXPECT(ex
->post
== 1);
120 test_executor
<> ex(ioc
.get_executor());
121 BEAST_EXPECT(ex
->total
== 0);
123 bind_continuation(ex
, handler
{}),
124 std::allocator
<void>{});
127 BEAST_EXPECT(ex
->defer
== 1);
133 auto h1
= bind_continuation(
134 ioc
.get_executor(), handler
{});
135 auto h2
= bind_continuation(
136 ioc
.get_executor(), handler
{});
138 net::get_associated_executor(h1
) ==
139 net::get_associated_executor(h2
));
142 net::get_associated_executor(h1
).context()) ==
144 net::get_associated_executor(h2
).context()));
150 net::io_context ioc1
;
151 net::io_context ioc2
;
152 auto h1
= bind_continuation(
153 ioc1
.get_executor(), handler
{});
154 auto h2
= bind_continuation(
155 ioc2
.get_executor(), handler
{});
157 net::get_associated_executor(h1
) !=
158 net::get_associated_executor(h2
));
161 net::get_associated_executor(h1
).context()) !=
163 net::get_associated_executor(h2
).context()));
169 //--------------------------------------------------------------------------
176 //--------------------------------------------------------------------------
186 BEAST_DEFINE_TESTSUITE(beast
,core
,bind_continuation
);