]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/beast/test/beast/core/_detail_read.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/read.hpp>
13 #include <boost/beast/core/buffers_to_string.hpp>
14 #include <boost/beast/core/flat_buffer.hpp>
15 #include <boost/beast/core/ostream.hpp>
16 #include <boost/beast/_experimental/test/stream.hpp>
17 #include <boost/beast/_experimental/unit_test/suite.hpp>
18 #include <boost/asio/completion_condition.hpp>
24 class read_test
: public unit_test::suite
34 ostream(ts
.buffer()) << "test";
37 read(ts
, b
, boost::asio::transfer_at_least(4), ec
);
38 BEAST_EXPECTS(! ec
, ec
.message());
39 BEAST_EXPECT(buffers_to_string(b
.data()) == "test");
44 auto tc
= connect(ts
);
45 ostream(ts
.buffer()) << "test";
49 read(ts
, b
, boost::asio::transfer_all(), ec
);
50 BEAST_EXPECTS(ec
== boost::asio::error::eof
, ec
.message());
51 BEAST_EXPECT(buffers_to_string(b
.data()) == "test");
61 ostream(ts
.buffer()) << "test";
65 async_read(ts
, b
, boost::asio::transfer_at_least(4),
66 [&invoked
, &ec
](error_code ec_
, std::size_t)
72 BEAST_EXPECT(invoked
);
73 BEAST_EXPECTS(! ec
, ec
.message());
74 BEAST_EXPECT(buffers_to_string(b
.data()) == "test");
79 auto tc
= connect(ts
);
80 ostream(ts
.buffer()) << "test";
85 async_read(ts
, b
, boost::asio::transfer_all(),
86 [&invoked
, &ec
](error_code ec_
, std::size_t)
92 BEAST_EXPECT(invoked
);
93 BEAST_EXPECTS(ec
== boost::asio::error::eof
, ec
.message());
94 BEAST_EXPECT(buffers_to_string(b
.data()) == "test");
107 BEAST_DEFINE_TESTSUITE(beast
,core
,read
);