Files
boost_beast/test/beast/core/ostream.cpp
T

56 lines
1.9 KiB
C++
Raw Normal View History

//
2017-07-24 09:42:36 -07:00
// Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
2017-07-20 13:40:34 -07:00
// Official repository: https://github.com/boostorg/beast
//
// Test that header file is self-contained.
2017-07-20 13:40:34 -07:00
#include <boost/beast/core/ostream.hpp>
2018-04-24 10:55:39 -07:00
#include <boost/beast/core/buffers_to_string.hpp>
2017-07-20 13:40:34 -07:00
#include <boost/beast/core/multi_buffer.hpp>
2018-11-11 14:07:55 -08:00
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <ostream>
2017-07-20 13:40:34 -07:00
namespace boost {
namespace beast {
class ostream_test : public beast::unit_test::suite
{
public:
2017-05-08 07:09:36 -07:00
void
run() override
{
2017-05-08 07:09:36 -07:00
{
multi_buffer b;
auto os = ostream(b);
os << "Hello, world!\n";
os.flush();
2018-04-24 10:55:39 -07:00
BEAST_EXPECT(buffers_to_string(b.data()) == "Hello, world!\n");
2017-05-08 07:09:36 -07:00
auto os2 = std::move(os);
}
{
auto const s =
"0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef";
multi_buffer b;
2017-05-08 07:09:36 -07:00
ostream(b) << s;
2018-04-24 10:55:39 -07:00
BEAST_EXPECT(buffers_to_string(b.data()) == s);
2017-05-08 07:09:36 -07:00
}
}
};
2017-08-01 17:01:57 -07:00
BEAST_DEFINE_TESTSUITE(beast,core,ostream);
} // beast
2017-07-20 13:40:34 -07:00
} // boost