]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/beast/test/beast/http/span_body.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/http/span_body.hpp>
13 #include <boost/beast/http/message.hpp>
14 #include <boost/beast/unit_test/suite.hpp>
21 : public beast::unit_test::suite
27 using B
= span_body
<char const>;
30 BEAST_EXPECT(req
.body().size() == 0);
31 BEAST_EXPECT(B::size(req
.body()) == 0);
33 req
.body() = B::value_type("xyz", 3);
34 BEAST_EXPECT(req
.body().size() == 3);
35 BEAST_EXPECT(B::size(req
.body()) == 3);
37 B::writer r
{req
, req
.body()};
40 BEAST_EXPECTS(! ec
, ec
.message());
41 auto const buf
= r
.get(ec
);
42 BEAST_EXPECTS(! ec
, ec
.message());
43 if(! BEAST_EXPECT(buf
!= boost::none
))
45 BEAST_EXPECT(boost::asio::buffer_size(buf
->first
) == 3);
46 BEAST_EXPECT(! buf
->second
);
50 using B
= span_body
<char>;
52 req
.body() = span
<char>{buf
, sizeof(buf
)};
53 B::reader w
{req
, req
.body()};
55 w
.init(boost::none
, ec
);
56 BEAST_EXPECTS(! ec
, ec
.message());
57 w
.put(boost::asio::const_buffer
{
59 BEAST_EXPECTS(! ec
, ec
.message());
60 BEAST_EXPECT(buf
[0] == '1');
61 BEAST_EXPECT(buf
[1] == '2');
62 BEAST_EXPECT(buf
[2] == '3');
63 w
.put(boost::asio::const_buffer
{
65 BEAST_EXPECTS(ec
== error::buffer_overflow
, ec
.message());
76 BEAST_DEFINE_TESTSUITE(beast
,http
,span_body
);