2017-06-09 17:52:00 -07:00
|
|
|
//
|
2017-07-24 09:42:36 -07:00
|
|
|
// Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
|
2017-06-09 17:52:00 -07:00
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
2017-06-09 17:52:00 -07:00
|
|
|
|
|
|
|
// Test that header file is self-contained.
|
2017-07-20 13:40:34 -07:00
|
|
|
#include <boost/beast/core/drain_buffer.hpp>
|
2017-06-09 17:52:00 -07:00
|
|
|
|
2017-07-20 13:40:34 -07:00
|
|
|
#include <boost/beast/core/type_traits.hpp>
|
|
|
|
#include <boost/beast/unit_test/suite.hpp>
|
2017-06-09 17:52:00 -07:00
|
|
|
|
2017-07-20 13:40:34 -07:00
|
|
|
namespace boost {
|
2017-06-09 17:52:00 -07:00
|
|
|
namespace beast {
|
|
|
|
|
|
|
|
static_assert(is_dynamic_buffer<drain_buffer>::value,
|
|
|
|
"DynamicBuffer requirements not met");
|
|
|
|
|
|
|
|
class drain_buffer_test : public beast::unit_test::suite
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void
|
|
|
|
run() override
|
|
|
|
{
|
|
|
|
using boost::asio::buffer_size;
|
|
|
|
drain_buffer b;
|
2017-07-25 12:35:54 -07:00
|
|
|
BEAST_EXPECT(buffer_size(b.prepare(0)) == 0);
|
|
|
|
BEAST_EXPECT(buffer_size(b.prepare(100)) == 100);
|
2017-06-09 17:52:00 -07:00
|
|
|
try
|
|
|
|
{
|
|
|
|
b.prepare(b.max_size() + 1);
|
|
|
|
fail("", __FILE__, __LINE__);
|
|
|
|
}
|
|
|
|
catch(std::length_error const&)
|
|
|
|
{
|
|
|
|
pass();
|
|
|
|
}
|
|
|
|
b.prepare(10);
|
2017-07-25 12:35:54 -07:00
|
|
|
BEAST_EXPECT(b.size() == 0);
|
2017-06-09 17:52:00 -07:00
|
|
|
b.commit(10);
|
2017-07-25 12:35:54 -07:00
|
|
|
BEAST_EXPECT(b.size() == 0);
|
2017-06-09 17:52:00 -07:00
|
|
|
b.consume(10);
|
2017-07-25 12:35:54 -07:00
|
|
|
BEAST_EXPECT(b.size() == 0);
|
2017-06-09 17:52:00 -07:00
|
|
|
b.consume(1000);
|
2017-07-25 12:35:54 -07:00
|
|
|
BEAST_EXPECT(b.size() == 0);
|
2017-06-09 17:52:00 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-08-01 16:52:33 -07:00
|
|
|
BEAST_DEFINE_TESTSUITE(drain_buffer,core,beast);
|
2017-06-09 17:52:00 -07:00
|
|
|
|
|
|
|
} // beast
|
2017-07-20 13:40:34 -07:00
|
|
|
} // boost
|