]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/beast/test/beast/core/ostream.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / beast / test / beast / core / ostream.cpp
1 //
2 // Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
3 //
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)
6 //
7 // Official repository: https://github.com/boostorg/beast
8 //
9
10 // Test that header file is self-contained.
11 #include <boost/beast/core/ostream.hpp>
12
13 #include <boost/beast/core/multi_buffer.hpp>
14 #include <boost/beast/unit_test/suite.hpp>
15 #include <ostream>
16
17 namespace boost {
18 namespace beast {
19
20 class ostream_test : public beast::unit_test::suite
21 {
22 public:
23 template<class ConstBufferSequence>
24 static
25 std::string
26 to_string(ConstBufferSequence const& bs)
27 {
28 std::string s;
29 s.reserve(buffer_size(bs));
30 for(auto b : beast::detail::buffers_range(bs))
31 s.append(reinterpret_cast<
32 char const*>(b.data()), b.size());
33 return s;
34 }
35
36 void
37 run() override
38 {
39 {
40 multi_buffer b;
41 auto os = ostream(b);
42 os << "Hello, world!\n";
43 os.flush();
44 BEAST_EXPECT(to_string(b.data()) == "Hello, world!\n");
45 auto os2 = std::move(os);
46 }
47 {
48 auto const s =
49 "0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef"
50 "0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef"
51 "0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef"
52 "0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef"
53 "0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef"
54 "0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef"
55 "0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef"
56 "0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef";
57 multi_buffer b;
58 ostream(b) << s;
59 BEAST_EXPECT(to_string(b.data()) == s);
60 }
61 }
62 };
63
64 BEAST_DEFINE_TESTSUITE(beast,core,ostream);
65
66 } // beast
67 } // boost