forked from boostorg/beast
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_detail_buffer.cpp
More file actions
83 lines (74 loc) · 2.11 KB
/
Copy path_detail_buffer.cpp
File metadata and controls
83 lines (74 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//
// Copyright (c) 2016-2019 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)
//
// Official repository: https://github.com/boostorg/beast
//
// Test that header file is self-contained.
//#include <boost/beast/core/buffer.hpp>
#include <boost/beast/core/detail/buffer.hpp>
#include <boost/beast/core/flat_buffer.hpp>
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <string>
#include <boost/asio/error.hpp>
namespace boost {
namespace beast {
namespace detail {
// VFALCO No idea why boost::system::errc::message_size fails
// to compile, so we use net::error::eof instead.
//
class buffer_test : public beast::unit_test::suite
{
public:
template<class DynamicBuffer>
void
testPrepare()
{
#ifndef BOOST_NO_EXCEPTIONS
error_code ec;
DynamicBuffer b(32);
dynamic_buffer_prepare(b, 20, ec,
net::error::eof);
BEAST_EXPECTS(! ec, ec.message());
b.commit(20);
auto const result =
dynamic_buffer_prepare(b, 20, ec,
net::error::eof);
BEAST_EXPECT(result == boost::none);
BEAST_EXPECTS(
ec == net::error::eof, ec.message());
#else
fail("exceptions disabled", __FILE__, __LINE__);
#endif
}
template<class DynamicBuffer>
void
testPrepareNoexcept()
{
error_code ec;
DynamicBuffer b(32);
dynamic_buffer_prepare_noexcept(b, 20, ec,
net::error::eof);
BEAST_EXPECTS(! ec, ec.message());
b.commit(20);
auto const result =
detail::dynamic_buffer_prepare_noexcept(b, 20, ec,
net::error::eof);
BEAST_EXPECT(result == boost::none);
BEAST_EXPECTS(
ec == net::error::eof, ec.message());
}
void
run() override
{
testPrepare<flat_buffer>();
testPrepareNoexcept<flat_buffer>();
pass();
}
};
BEAST_DEFINE_TESTSUITE(beast,core,buffer);
} // detail
} // beast
} // boost