mirror of
https://github.com/boostorg/beast.git
synced 2025-07-29 20:37:31 +02:00
11
CHANGELOG.md
11
CHANGELOG.md
@ -1,6 +1,7 @@
|
||||
Version 204
|
||||
|
||||
* Add basic_timeout_stream
|
||||
* Unit test macros use the global suite
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -226,7 +227,7 @@ Version 189:
|
||||
Version 188:
|
||||
|
||||
* Remove extraneous strand from example
|
||||
* Add missing include in http/read.ipp
|
||||
* Add missing include in http/read.ipp
|
||||
* Test for gcc warning bug
|
||||
* Fix a spurious gcc warning
|
||||
|
||||
@ -513,7 +514,7 @@ Version 153:
|
||||
|
||||
* Remove BOOST_VERSION checks
|
||||
* Use make_error_code for setting an error_code from errc
|
||||
* Use boost::winapi::GetLastError() consistently
|
||||
* Use boost::winapi::GetLastError() consistently
|
||||
* Update README.md for branches
|
||||
* Avoid string_view::clear
|
||||
* Fix iterator version of basic_fields::erase
|
||||
@ -1413,7 +1414,7 @@ WebSocket
|
||||
|
||||
API Changes:
|
||||
|
||||
* Add static_buffer
|
||||
* Add static_buffer
|
||||
|
||||
Actions Required:
|
||||
|
||||
@ -1975,7 +1976,7 @@ Version 54:
|
||||
|
||||
API Changes:
|
||||
|
||||
* basic_fields refactor
|
||||
* basic_fields refactor
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -2054,7 +2055,7 @@ Version 51
|
||||
API Changes:
|
||||
|
||||
* Tune up static_buffer
|
||||
* multi_buffer implementation change
|
||||
* multi_buffer implementation change
|
||||
|
||||
Actions Required:
|
||||
|
||||
|
@ -23,7 +23,6 @@ namespace unit_test {
|
||||
namespace detail {
|
||||
|
||||
template<class String>
|
||||
static
|
||||
std::string
|
||||
make_reason(String const& reason,
|
||||
char const* file, int line)
|
||||
@ -610,12 +609,20 @@ run(runner& r)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef BEAST_PASS
|
||||
#define BEAST_PASS() ::boost::beast::unit_test::suite::this_suite()->pass()
|
||||
#endif
|
||||
|
||||
#ifndef BEAST_FAIL
|
||||
#define BEAST_FAIL() ::boost::beast::unit_test::suite::this_suite()->fail("", __FILE__, __LINE__)
|
||||
#endif
|
||||
|
||||
#ifndef BEAST_EXPECT
|
||||
/** Check a precondition.
|
||||
|
||||
If the condition is false, the file and line number are reported.
|
||||
*/
|
||||
#define BEAST_EXPECT(cond) expect(cond, __FILE__, __LINE__)
|
||||
#define BEAST_EXPECT(cond) ::boost::beast::unit_test::suite::this_suite()->expect(cond, __FILE__, __LINE__)
|
||||
#endif
|
||||
|
||||
#ifndef BEAST_EXPECTS
|
||||
@ -623,8 +630,9 @@ run(runner& r)
|
||||
|
||||
If the condition is false, the file and line number are reported.
|
||||
*/
|
||||
#define BEAST_EXPECTS(cond, reason) ((cond) ? (pass(), true) : \
|
||||
(fail((reason), __FILE__, __LINE__), false))
|
||||
#define BEAST_EXPECTS(cond, reason) ((cond) ? \
|
||||
(::boost::beast::unit_test::suite::this_suite()->pass(), true) : \
|
||||
(::boost::beast::unit_test::suite::this_suite()->fail((reason), __FILE__, __LINE__), false))
|
||||
#endif
|
||||
|
||||
} // unit_test
|
||||
|
@ -429,7 +429,7 @@ public:
|
||||
}
|
||||
|
||||
// legacy hooks
|
||||
legacy_handler::test(*this,
|
||||
legacy_handler::test(
|
||||
[](legacy_handler h)
|
||||
{
|
||||
return async_op_base<
|
||||
@ -488,7 +488,7 @@ public:
|
||||
}
|
||||
|
||||
// legacy hooks
|
||||
legacy_handler::test(*this,
|
||||
legacy_handler::test(
|
||||
[](legacy_handler h)
|
||||
{
|
||||
return stable_async_op_base<
|
||||
|
@ -58,6 +58,7 @@ public:
|
||||
a.async_accept(s2,
|
||||
[](error_code ec)
|
||||
{
|
||||
boost::ignore_unused(ec);
|
||||
#if 0
|
||||
if(ec == net::error::operation_aborted)
|
||||
return;
|
||||
@ -377,20 +378,17 @@ public:
|
||||
|
||||
struct match
|
||||
{
|
||||
suite& suite_;
|
||||
error_code ec_;
|
||||
std::size_t n_;
|
||||
|
||||
match(suite& s, error_code ec, std::size_t n)
|
||||
: suite_(s)
|
||||
, ec_(ec)
|
||||
match(error_code ec, std::size_t n)
|
||||
: ec_(ec)
|
||||
, n_(n)
|
||||
{
|
||||
}
|
||||
|
||||
match(match&& other)
|
||||
: suite_(other.suite_)
|
||||
, ec_(other.ec_)
|
||||
: ec_(other.ec_)
|
||||
, n_(boost::exchange(other.n_,
|
||||
(std::numeric_limits<std::size_t>::max)()))
|
||||
{
|
||||
@ -398,15 +396,15 @@ public:
|
||||
|
||||
~match()
|
||||
{
|
||||
suite_.BEAST_EXPECT(
|
||||
BEAST_EXPECT(
|
||||
n_ == (std::numeric_limits<std::size_t>::max)());
|
||||
}
|
||||
|
||||
void
|
||||
operator()(error_code ec, std::size_t n)
|
||||
{
|
||||
suite_.expect(ec == ec_, ec.message(), __FILE__, __LINE__);
|
||||
suite_.BEAST_EXPECT(n == n_);
|
||||
BEAST_EXPECTS(ec == ec_, ec.message());
|
||||
BEAST_EXPECT(n == n_);
|
||||
n_ = (std::numeric_limits<std::size_t>::max)();
|
||||
}
|
||||
};
|
||||
@ -429,7 +427,7 @@ public:
|
||||
net::io_context ioc;
|
||||
stream_t s(ioc);
|
||||
s.next_layer().connect(srv.local_endpoint());
|
||||
s.async_read_some(mb, match{*this, {}, 1});
|
||||
s.async_read_some(mb, match{{}, 1});
|
||||
ioc.run_for(std::chrono::seconds(1));
|
||||
}
|
||||
|
||||
@ -440,7 +438,7 @@ public:
|
||||
stream_t s(ioc);
|
||||
s.next_layer().connect(srv.local_endpoint());
|
||||
s.expires_after(std::chrono::milliseconds(100));
|
||||
s.async_read_some(mb, match{*this, {}, 1});
|
||||
s.async_read_some(mb, match{{}, 1});
|
||||
ioc.run_for(std::chrono::seconds(1));
|
||||
s.expires_never();
|
||||
ioc.run();
|
||||
@ -452,7 +450,7 @@ public:
|
||||
net::io_context ioc;
|
||||
stream_t s(ioc);
|
||||
s.next_layer().connect(srv.local_endpoint());
|
||||
s.async_read_some(mb, match{*this,
|
||||
s.async_read_some(mb, match{
|
||||
net::error::operation_aborted, 0});
|
||||
{
|
||||
error_code ec;
|
||||
@ -470,7 +468,7 @@ public:
|
||||
net::io_context ioc;
|
||||
stream_t s(ioc);
|
||||
s.next_layer().connect(srv.local_endpoint());
|
||||
s.async_read_some(mb, match{*this,
|
||||
s.async_read_some(mb, match{
|
||||
net::error::operation_aborted, 0});
|
||||
ioc.run_for(std::chrono::milliseconds(100));
|
||||
s.cancel();
|
||||
@ -508,7 +506,7 @@ public:
|
||||
s.next_layer().connect(srv.local_endpoint());
|
||||
s.expires_after(std::chrono::milliseconds(100));
|
||||
s.async_read_some(mb,
|
||||
match{*this, error::timeout, 0});
|
||||
match{error::timeout, 0});
|
||||
ioc.run_for(std::chrono::seconds(1));
|
||||
}
|
||||
|
||||
@ -522,7 +520,7 @@ public:
|
||||
std::chrono::steady_clock::now() +
|
||||
std::chrono::milliseconds(100));
|
||||
s.async_read_some(mb,
|
||||
match{*this, {}, 1});
|
||||
match{{}, 1});
|
||||
ioc.run_for(std::chrono::seconds(1));
|
||||
}
|
||||
|
||||
@ -595,7 +593,7 @@ public:
|
||||
stream_t s(ioc);
|
||||
s.next_layer().connect(srv.local_endpoint());
|
||||
s.async_write_some(mb,
|
||||
match{*this, {}, mb.size()});
|
||||
match{{}, mb.size()});
|
||||
{
|
||||
error_code ec;
|
||||
s.next_layer().shutdown(
|
||||
|
@ -148,82 +148,65 @@ public:
|
||||
|
||||
class test_cb
|
||||
{
|
||||
bind_handler_test& s_;
|
||||
bool fail_ = true;
|
||||
|
||||
public:
|
||||
test_cb() = default;
|
||||
test_cb(test_cb const&) = delete;
|
||||
|
||||
test_cb(bind_handler_test& s)
|
||||
: s_(s)
|
||||
{
|
||||
}
|
||||
|
||||
test_cb(test_cb&& other)
|
||||
: s_(other.s_)
|
||||
, fail_(boost::exchange(
|
||||
: fail_(boost::exchange(
|
||||
other.fail_, false))
|
||||
{
|
||||
}
|
||||
|
||||
~test_cb()
|
||||
{
|
||||
if(fail_)
|
||||
s_.fail("handler not invoked",
|
||||
__FILE__, __LINE__);
|
||||
BEAST_EXPECT(! fail_);
|
||||
}
|
||||
|
||||
void
|
||||
operator()()
|
||||
{
|
||||
fail_ = false;
|
||||
s_.pass();
|
||||
BEAST_EXPECT(true);
|
||||
}
|
||||
|
||||
void
|
||||
operator()(int v)
|
||||
{
|
||||
fail_ = false;
|
||||
s_.expect(
|
||||
v == 42, __FILE__, __LINE__);
|
||||
BEAST_EXPECT(v == 42);
|
||||
}
|
||||
|
||||
void
|
||||
operator()(int v, string_view s)
|
||||
{
|
||||
fail_ = false;
|
||||
s_.expect(
|
||||
v == 42, __FILE__, __LINE__);
|
||||
s_.expect(
|
||||
s == "s", __FILE__, __LINE__);
|
||||
BEAST_EXPECT(v == 42);
|
||||
BEAST_EXPECT(s == "s");
|
||||
}
|
||||
|
||||
void
|
||||
operator()(int v, string_view s, move_arg<1>)
|
||||
{
|
||||
fail_ = false;
|
||||
s_.expect(
|
||||
v == 42, __FILE__, __LINE__);
|
||||
s_.expect(
|
||||
s == "s", __FILE__, __LINE__);
|
||||
BEAST_EXPECT(v == 42);
|
||||
BEAST_EXPECT(s == "s");
|
||||
}
|
||||
|
||||
void
|
||||
operator()(int v, string_view s, move_arg<1>, move_arg<2>)
|
||||
{
|
||||
fail_ = false;
|
||||
s_.expect(
|
||||
v == 42, __FILE__, __LINE__);
|
||||
s_.expect(
|
||||
s == "s", __FILE__, __LINE__);
|
||||
BEAST_EXPECT(v == 42);
|
||||
BEAST_EXPECT(s == "s");
|
||||
}
|
||||
|
||||
void
|
||||
operator()(error_code, std::size_t n)
|
||||
{
|
||||
fail_ = false;
|
||||
s_.expect(
|
||||
n == 256, __FILE__, __LINE__);
|
||||
BEAST_EXPECT(n == 256);
|
||||
}
|
||||
|
||||
void
|
||||
@ -232,16 +215,14 @@ public:
|
||||
{
|
||||
boost::ignore_unused(s);
|
||||
fail_ = false;
|
||||
s_.expect(
|
||||
n == 256, __FILE__, __LINE__);
|
||||
BEAST_EXPECT(n == 256);
|
||||
}
|
||||
|
||||
void
|
||||
operator()(std::shared_ptr<int> const& sp)
|
||||
{
|
||||
fail_ = false;
|
||||
s_.expect(sp.get() != nullptr,
|
||||
__FILE__, __LINE__);
|
||||
BEAST_EXPECT(sp.get() != nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
@ -251,19 +232,19 @@ public:
|
||||
void
|
||||
failStdBind()
|
||||
{
|
||||
std::bind(bind_handler(test_cb{*this}));
|
||||
std::bind(bind_handler(test_cb{}));
|
||||
}
|
||||
|
||||
void
|
||||
failStdBindFront()
|
||||
{
|
||||
std::bind(bind_front_handler(test_cb{*this}));
|
||||
std::bind(bind_front_handler(test_cb{}));
|
||||
}
|
||||
|
||||
void
|
||||
failStdBindBack()
|
||||
{
|
||||
std::bind(bind_back_handler(test_cb{*this}));
|
||||
std::bind(bind_back_handler(test_cb{}));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -300,68 +281,68 @@ public:
|
||||
using namespace std::placeholders;
|
||||
|
||||
// 0-ary
|
||||
bind_handler(test_cb{*this})();
|
||||
bind_handler(test_cb{})();
|
||||
|
||||
// 1-ary
|
||||
bind_handler(test_cb{*this}, 42)();
|
||||
bind_handler(test_cb{*this}, _1)(42);
|
||||
bind_handler(test_cb{*this}, _2)(0, 42);
|
||||
bind_handler(test_cb{}, 42)();
|
||||
bind_handler(test_cb{}, _1)(42);
|
||||
bind_handler(test_cb{}, _2)(0, 42);
|
||||
|
||||
// 2-ary
|
||||
bind_handler(test_cb{*this}, 42, "s")();
|
||||
bind_handler(test_cb{*this}, 42, "s")(0);
|
||||
bind_handler(test_cb{*this}, _1, "s")(42);
|
||||
bind_handler(test_cb{*this}, 42, _1) ("s");
|
||||
bind_handler(test_cb{*this}, _1, _2)(42, "s");
|
||||
bind_handler(test_cb{*this}, _1, _2)(42, "s", "X");
|
||||
bind_handler(test_cb{*this}, _2, _1)("s", 42);
|
||||
bind_handler(test_cb{*this}, _3, _2)("X", "s", 42);
|
||||
bind_handler(test_cb{}, 42, "s")();
|
||||
bind_handler(test_cb{}, 42, "s")(0);
|
||||
bind_handler(test_cb{}, _1, "s")(42);
|
||||
bind_handler(test_cb{}, 42, _1) ("s");
|
||||
bind_handler(test_cb{}, _1, _2)(42, "s");
|
||||
bind_handler(test_cb{}, _1, _2)(42, "s", "X");
|
||||
bind_handler(test_cb{}, _2, _1)("s", 42);
|
||||
bind_handler(test_cb{}, _3, _2)("X", "s", 42);
|
||||
|
||||
// 3-ary
|
||||
bind_handler(test_cb{*this}, 42, "s")(m1{});
|
||||
bind_handler(test_cb{*this}, 42, "s", _1)(m1{});
|
||||
bind_handler(test_cb{*this}, 42, _1, m1{})("s");
|
||||
bind_handler(test_cb{}, 42, "s")(m1{});
|
||||
bind_handler(test_cb{}, 42, "s", _1)(m1{});
|
||||
bind_handler(test_cb{}, 42, _1, m1{})("s");
|
||||
|
||||
// 4-ary
|
||||
bind_handler(test_cb{*this}, 42, "s")(m1{}, m2{});
|
||||
bind_handler(test_cb{*this}, 42, "s", m1{})(m2{});
|
||||
bind_handler(test_cb{*this}, 42, "s", m1{}, m2{})();
|
||||
bind_handler(test_cb{*this}, 42, _1, m1{})("s", m2{});
|
||||
bind_handler(test_cb{*this}, _3, _1, m1{})("s", m2{}, 42);
|
||||
bind_handler(test_cb{}, 42, "s")(m1{}, m2{});
|
||||
bind_handler(test_cb{}, 42, "s", m1{})(m2{});
|
||||
bind_handler(test_cb{}, 42, "s", m1{}, m2{})();
|
||||
bind_handler(test_cb{}, 42, _1, m1{})("s", m2{});
|
||||
bind_handler(test_cb{}, _3, _1, m1{})("s", m2{}, 42);
|
||||
}
|
||||
|
||||
{
|
||||
using namespace boost::placeholders;
|
||||
|
||||
// 0-ary
|
||||
bind_handler(test_cb{*this})();
|
||||
bind_handler(test_cb{})();
|
||||
|
||||
// 1-ary
|
||||
bind_handler(test_cb{*this}, 42)();
|
||||
bind_handler(test_cb{*this}, _1)(42);
|
||||
bind_handler(test_cb{*this}, _2)(0, 42);
|
||||
bind_handler(test_cb{}, 42)();
|
||||
bind_handler(test_cb{}, _1)(42);
|
||||
bind_handler(test_cb{}, _2)(0, 42);
|
||||
|
||||
// 2-ary
|
||||
bind_handler(test_cb{*this}, 42, "s")();
|
||||
bind_handler(test_cb{*this}, 42, "s")(0);
|
||||
bind_handler(test_cb{*this}, _1, "s")(42);
|
||||
bind_handler(test_cb{*this}, 42, _1) ("s");
|
||||
bind_handler(test_cb{*this}, _1, _2)(42, "s");
|
||||
bind_handler(test_cb{*this}, _1, _2)(42, "s", "X");
|
||||
bind_handler(test_cb{*this}, _2, _1)("s", 42);
|
||||
bind_handler(test_cb{*this}, _3, _2)("X", "s", 42);
|
||||
bind_handler(test_cb{}, 42, "s")();
|
||||
bind_handler(test_cb{}, 42, "s")(0);
|
||||
bind_handler(test_cb{}, _1, "s")(42);
|
||||
bind_handler(test_cb{}, 42, _1) ("s");
|
||||
bind_handler(test_cb{}, _1, _2)(42, "s");
|
||||
bind_handler(test_cb{}, _1, _2)(42, "s", "X");
|
||||
bind_handler(test_cb{}, _2, _1)("s", 42);
|
||||
bind_handler(test_cb{}, _3, _2)("X", "s", 42);
|
||||
|
||||
// 3-ary
|
||||
bind_handler(test_cb{*this}, 42, "s")(m1{});
|
||||
bind_handler(test_cb{*this}, 42, "s", _1)(m1{});
|
||||
bind_handler(test_cb{*this}, 42, _1, m1{})("s");
|
||||
bind_handler(test_cb{}, 42, "s")(m1{});
|
||||
bind_handler(test_cb{}, 42, "s", _1)(m1{});
|
||||
bind_handler(test_cb{}, 42, _1, m1{})("s");
|
||||
|
||||
// 4-ary
|
||||
bind_handler(test_cb{*this}, 42, "s")(m1{}, m2{});
|
||||
bind_handler(test_cb{*this}, 42, "s", m1{})(m2{});
|
||||
bind_handler(test_cb{*this}, 42, "s", m1{}, m2{})();
|
||||
bind_handler(test_cb{*this}, 42, _1, m1{})("s", m2{});
|
||||
bind_handler(test_cb{*this}, _3, _1, m1{})("s", m2{}, 42);
|
||||
bind_handler(test_cb{}, 42, "s")(m1{}, m2{});
|
||||
bind_handler(test_cb{}, 42, "s", m1{})(m2{});
|
||||
bind_handler(test_cb{}, 42, "s", m1{}, m2{})();
|
||||
bind_handler(test_cb{}, 42, _1, m1{})("s", m2{});
|
||||
bind_handler(test_cb{}, _3, _1, m1{})("s", m2{}, 42);
|
||||
}
|
||||
|
||||
// perfect forwarding
|
||||
@ -369,11 +350,11 @@ public:
|
||||
std::shared_ptr<int> const sp =
|
||||
std::make_shared<int>(42);
|
||||
{
|
||||
bind_handler(test_cb{*this}, sp)();
|
||||
bind_handler(test_cb{}, sp)();
|
||||
BEAST_EXPECT(sp.get() != nullptr);
|
||||
}
|
||||
{
|
||||
bind_handler(test_cb{*this})(sp);
|
||||
bind_handler(test_cb{})(sp);
|
||||
BEAST_EXPECT(sp.get() != nullptr);
|
||||
}
|
||||
}
|
||||
@ -382,7 +363,7 @@ public:
|
||||
{
|
||||
net::io_context ioc;
|
||||
testHooks(ioc, bind_handler(net::bind_executor(
|
||||
test_executor(*this, ioc), test_cb{*this})));
|
||||
test_executor(*this, ioc), test_cb{})));
|
||||
}
|
||||
|
||||
// asio_handler_invoke
|
||||
@ -395,12 +376,12 @@ public:
|
||||
net::io_context::executor_type> s{
|
||||
ioc.get_executor()};
|
||||
net::post(s,
|
||||
bind_handler(test_cb{*this}, 42));
|
||||
bind_handler(test_cb{}, 42));
|
||||
ioc.run();
|
||||
}
|
||||
|
||||
// legacy hooks
|
||||
legacy_handler::test(*this,
|
||||
legacy_handler::test(
|
||||
[](legacy_handler h)
|
||||
{
|
||||
return bind_handler(h);
|
||||
@ -414,44 +395,44 @@ public:
|
||||
using m2 = move_arg<2>;
|
||||
|
||||
// 0-ary
|
||||
bind_front_handler(test_cb{*this})();
|
||||
bind_front_handler(test_cb{})();
|
||||
|
||||
// 1-ary
|
||||
bind_front_handler(test_cb{*this}, 42)();
|
||||
bind_front_handler(test_cb{*this})(42);
|
||||
bind_front_handler(test_cb{}, 42)();
|
||||
bind_front_handler(test_cb{})(42);
|
||||
|
||||
// 2-ary
|
||||
bind_front_handler(test_cb{*this}, 42, "s")();
|
||||
bind_front_handler(test_cb{*this}, 42)("s");
|
||||
bind_front_handler(test_cb{*this})(42, "s");
|
||||
bind_front_handler(test_cb{}, 42, "s")();
|
||||
bind_front_handler(test_cb{}, 42)("s");
|
||||
bind_front_handler(test_cb{})(42, "s");
|
||||
|
||||
// 3-ary
|
||||
bind_front_handler(test_cb{*this}, 42, "s", m1{})();
|
||||
bind_front_handler(test_cb{*this}, 42, "s")(m1{});
|
||||
bind_front_handler(test_cb{*this}, 42)("s", m1{});
|
||||
bind_front_handler(test_cb{*this})(42, "s", m1{});
|
||||
bind_front_handler(test_cb{}, 42, "s", m1{})();
|
||||
bind_front_handler(test_cb{}, 42, "s")(m1{});
|
||||
bind_front_handler(test_cb{}, 42)("s", m1{});
|
||||
bind_front_handler(test_cb{})(42, "s", m1{});
|
||||
|
||||
// 4-ary
|
||||
bind_front_handler(test_cb{*this}, 42, "s", m1{}, m2{})();
|
||||
bind_front_handler(test_cb{*this}, 42, "s", m1{})(m2{});
|
||||
bind_front_handler(test_cb{*this}, 42, "s")(m1{}, m2{});
|
||||
bind_front_handler(test_cb{*this}, 42)("s", m1{}, m2{});
|
||||
bind_front_handler(test_cb{*this})(42, "s", m1{}, m2{});
|
||||
bind_front_handler(test_cb{}, 42, "s", m1{}, m2{})();
|
||||
bind_front_handler(test_cb{}, 42, "s", m1{})(m2{});
|
||||
bind_front_handler(test_cb{}, 42, "s")(m1{}, m2{});
|
||||
bind_front_handler(test_cb{}, 42)("s", m1{}, m2{});
|
||||
bind_front_handler(test_cb{})(42, "s", m1{}, m2{});
|
||||
|
||||
error_code ec;
|
||||
std::size_t n = 256;
|
||||
|
||||
// void(error_code, size_t)
|
||||
bind_front_handler(test_cb{*this}, ec, n)();
|
||||
bind_front_handler(test_cb{}, ec, n)();
|
||||
|
||||
// void(error_code, size_t)(string_view)
|
||||
bind_front_handler(test_cb{*this}, ec, n)("s");
|
||||
bind_front_handler(test_cb{}, ec, n)("s");
|
||||
|
||||
// perfect forwarding
|
||||
{
|
||||
std::shared_ptr<int> const sp =
|
||||
std::make_shared<int>(42);
|
||||
bind_front_handler(test_cb{*this}, sp)();
|
||||
bind_front_handler(test_cb{}, sp)();
|
||||
BEAST_EXPECT(sp.get() != nullptr);
|
||||
}
|
||||
|
||||
@ -460,32 +441,32 @@ public:
|
||||
net::io_context ioc;
|
||||
|
||||
testHooks(ioc, bind_front_handler(net::bind_executor(
|
||||
test_executor(*this, ioc), test_cb{*this})
|
||||
test_executor(*this, ioc), test_cb{})
|
||||
));
|
||||
testHooks(ioc, bind_front_handler(net::bind_executor(
|
||||
test_executor(*this, ioc), test_cb{*this}),
|
||||
test_executor(*this, ioc), test_cb{}),
|
||||
42));
|
||||
testHooks(ioc, bind_front_handler(net::bind_executor(
|
||||
test_executor(*this, ioc), test_cb{*this}),
|
||||
test_executor(*this, ioc), test_cb{}),
|
||||
42, "s"));
|
||||
testHooks(ioc, bind_front_handler(net::bind_executor(
|
||||
test_executor(*this, ioc), test_cb{*this}),
|
||||
test_executor(*this, ioc), test_cb{}),
|
||||
42, "s", m1{}));
|
||||
testHooks(ioc, bind_front_handler(net::bind_executor(
|
||||
test_executor(*this, ioc), test_cb{*this}),
|
||||
test_executor(*this, ioc), test_cb{}),
|
||||
42, "s", m1{}, m2{}));
|
||||
testHooks(ioc, bind_front_handler(net::bind_executor(
|
||||
test_executor(*this, ioc), test_cb{*this}),
|
||||
test_executor(*this, ioc), test_cb{}),
|
||||
ec, n));
|
||||
}
|
||||
|
||||
// legacy hooks
|
||||
legacy_handler::test(*this,
|
||||
legacy_handler::test(
|
||||
[](legacy_handler h)
|
||||
{
|
||||
return bind_front_handler(h);
|
||||
});
|
||||
legacy_handler::test(*this,
|
||||
legacy_handler::test(
|
||||
[](legacy_handler h)
|
||||
{
|
||||
return bind_front_handler(
|
||||
@ -501,44 +482,44 @@ public:
|
||||
using m2 = move_arg<2>;
|
||||
|
||||
// 0-ary
|
||||
bind_back_handler(test_cb{*this})();
|
||||
bind_back_handler(test_cb{})();
|
||||
|
||||
// 1-ary
|
||||
bind_back_handler(test_cb{*this}, 42)();
|
||||
bind_back_handler(test_cb{*this})(42);
|
||||
bind_back_handler(test_cb{}, 42)();
|
||||
bind_back_handler(test_cb{})(42);
|
||||
|
||||
// 2-ary
|
||||
bind_back_handler(test_cb{*this}, 42, "s")();
|
||||
bind_back_handler(test_cb{*this}, "s")(42);
|
||||
bind_back_handler(test_cb{*this})(42, "s");
|
||||
bind_back_handler(test_cb{}, 42, "s")();
|
||||
bind_back_handler(test_cb{}, "s")(42);
|
||||
bind_back_handler(test_cb{})(42, "s");
|
||||
|
||||
// 3-ary
|
||||
bind_back_handler(test_cb{*this}, 42, "s", m1{})();
|
||||
bind_back_handler(test_cb{*this}, m1{})(42, "s");
|
||||
bind_back_handler(test_cb{*this}, "s", m1{})(42);
|
||||
bind_back_handler(test_cb{*this})(42, "s", m1{});
|
||||
bind_back_handler(test_cb{}, 42, "s", m1{})();
|
||||
bind_back_handler(test_cb{}, m1{})(42, "s");
|
||||
bind_back_handler(test_cb{}, "s", m1{})(42);
|
||||
bind_back_handler(test_cb{})(42, "s", m1{});
|
||||
|
||||
// 4-ary
|
||||
bind_back_handler(test_cb{*this}, 42, "s", m1{}, m2{})();
|
||||
bind_back_handler(test_cb{*this}, "s", m1{}, m2{})(42);
|
||||
bind_back_handler(test_cb{*this}, m1{}, m2{})(42, "s");
|
||||
bind_back_handler(test_cb{*this}, "s", m1{}, m2{})(42);
|
||||
bind_back_handler(test_cb{*this})(42, "s", m1{}, m2{});
|
||||
bind_back_handler(test_cb{}, 42, "s", m1{}, m2{})();
|
||||
bind_back_handler(test_cb{}, "s", m1{}, m2{})(42);
|
||||
bind_back_handler(test_cb{}, m1{}, m2{})(42, "s");
|
||||
bind_back_handler(test_cb{}, "s", m1{}, m2{})(42);
|
||||
bind_back_handler(test_cb{})(42, "s", m1{}, m2{});
|
||||
|
||||
error_code ec;
|
||||
std::size_t n = 256;
|
||||
|
||||
// void(error_code, size_t)
|
||||
bind_back_handler(test_cb{*this}, ec, n)();
|
||||
bind_back_handler(test_cb{}, ec, n)();
|
||||
|
||||
// void(error_code, size_t)(string_view)
|
||||
bind_back_handler(test_cb{*this}, "s")(ec, n);
|
||||
bind_back_handler(test_cb{}, "s")(ec, n);
|
||||
|
||||
// perfect forwarding
|
||||
{
|
||||
std::shared_ptr<int> const sp =
|
||||
std::make_shared<int>(42);
|
||||
bind_back_handler(test_cb{*this}, sp)();
|
||||
bind_back_handler(test_cb{}, sp)();
|
||||
BEAST_EXPECT(sp.get() != nullptr);
|
||||
}
|
||||
|
||||
@ -547,32 +528,32 @@ public:
|
||||
net::io_context ioc;
|
||||
|
||||
testHooks(ioc, bind_back_handler(net::bind_executor(
|
||||
test_executor(*this, ioc), test_cb{*this})
|
||||
test_executor(*this, ioc), test_cb{})
|
||||
));
|
||||
testHooks(ioc, bind_back_handler(net::bind_executor(
|
||||
test_executor(*this, ioc), test_cb{*this}),
|
||||
test_executor(*this, ioc), test_cb{}),
|
||||
42));
|
||||
testHooks(ioc, bind_back_handler(net::bind_executor(
|
||||
test_executor(*this, ioc), test_cb{*this}),
|
||||
test_executor(*this, ioc), test_cb{}),
|
||||
42, "s"));
|
||||
testHooks(ioc, bind_back_handler(net::bind_executor(
|
||||
test_executor(*this, ioc), test_cb{*this}),
|
||||
test_executor(*this, ioc), test_cb{}),
|
||||
42, "s", m1{}));
|
||||
testHooks(ioc, bind_back_handler(net::bind_executor(
|
||||
test_executor(*this, ioc), test_cb{*this}),
|
||||
test_executor(*this, ioc), test_cb{}),
|
||||
42, "s", m1{}, m2{}));
|
||||
testHooks(ioc, bind_back_handler(net::bind_executor(
|
||||
test_executor(*this, ioc), test_cb{*this}),
|
||||
test_executor(*this, ioc), test_cb{}),
|
||||
ec, n));
|
||||
}
|
||||
|
||||
// legacy hooks
|
||||
legacy_handler::test(*this,
|
||||
legacy_handler::test(
|
||||
[](legacy_handler h)
|
||||
{
|
||||
return bind_back_handler(h);
|
||||
});
|
||||
legacy_handler::test(*this,
|
||||
legacy_handler::test(
|
||||
[](legacy_handler h)
|
||||
{
|
||||
return bind_back_handler(
|
||||
|
@ -26,19 +26,6 @@
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// VFALCO This is here temporarily
|
||||
|
||||
#define SUITE_EXPECT(test, cond) \
|
||||
((test).expect((cond), __FILE__, __LINE__))
|
||||
|
||||
#define SUITE_EXPECTS(test, cond, reason) \
|
||||
((cond) ? ((test).pass(), true) \
|
||||
: ((test).fail((reason), __FILE__, __LINE__), false))
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** A MutableBufferSequence for tests, where length is always 3.
|
||||
*/
|
||||
class buffers_triple
|
||||
@ -119,7 +106,6 @@ namespace detail {
|
||||
|
||||
template<class MutableBufferSequence>
|
||||
void test_mutable_buffers(
|
||||
unit_test::suite&,
|
||||
MutableBufferSequence const&,
|
||||
net::const_buffer)
|
||||
{
|
||||
@ -127,7 +113,6 @@ void test_mutable_buffers(
|
||||
|
||||
template<class MutableBufferSequence>
|
||||
void test_mutable_buffers(
|
||||
unit_test::suite& test,
|
||||
MutableBufferSequence const& b,
|
||||
net::mutable_buffer)
|
||||
{
|
||||
@ -138,8 +123,7 @@ void test_mutable_buffers(
|
||||
src = {src.data(), buffer_size(b)};
|
||||
net::buffer_copy(b, net::const_buffer(
|
||||
src.data(), src.size()));
|
||||
SUITE_EXPECT(test,
|
||||
beast::buffers_to_string(b) == src);
|
||||
BEAST_EXPECT(beast::buffers_to_string(b) == src);
|
||||
}
|
||||
|
||||
} // detail
|
||||
@ -149,7 +133,6 @@ void test_mutable_buffers(
|
||||
template<class ConstBufferSequence>
|
||||
void
|
||||
test_buffer_sequence(
|
||||
beast::unit_test::suite& test,
|
||||
ConstBufferSequence const& buffers)
|
||||
{
|
||||
BOOST_STATIC_ASSERT(
|
||||
@ -160,28 +143,28 @@ test_buffer_sequence(
|
||||
|
||||
using iterator = decltype(
|
||||
net::buffer_sequence_begin(buffers));
|
||||
SUITE_EXPECT(test, sizeof(iterator) > 0);
|
||||
BEAST_EXPECT(sizeof(iterator) > 0);
|
||||
|
||||
auto const size = buffer_size(buffers);
|
||||
SUITE_EXPECT(test, size > 0 );
|
||||
BEAST_EXPECT(size > 0 );
|
||||
|
||||
// begin, end
|
||||
auto const length = std::distance(
|
||||
net::buffer_sequence_begin(buffers),
|
||||
net::buffer_sequence_end(buffers));
|
||||
SUITE_EXPECT(test, length > 0);
|
||||
SUITE_EXPECT(test,
|
||||
BEAST_EXPECT(length > 0);
|
||||
BEAST_EXPECT(
|
||||
net::buffer_sequence_begin(buffers) !=
|
||||
net::buffer_sequence_end(buffers));
|
||||
|
||||
// copy construction
|
||||
ConstBufferSequence b1(buffers);
|
||||
SUITE_EXPECT(test, buffer_size(b1) == size);
|
||||
BEAST_EXPECT(buffer_size(b1) == size);
|
||||
|
||||
// copy assignment
|
||||
ConstBufferSequence b2(buffers);
|
||||
b2 = b1;
|
||||
SUITE_EXPECT(test, buffer_size(b2) == size);
|
||||
BEAST_EXPECT(buffer_size(b2) == size);
|
||||
|
||||
// iterators
|
||||
{
|
||||
@ -191,11 +174,11 @@ test_buffer_sequence(
|
||||
net::buffer_sequence_begin(buffers);
|
||||
iterator it4 =
|
||||
net::buffer_sequence_end(buffers);
|
||||
SUITE_EXPECT(test, it1 == it2);
|
||||
SUITE_EXPECT(test, it1 != it3);
|
||||
SUITE_EXPECT(test, it3 != it1);
|
||||
SUITE_EXPECT(test, it1 != it4);
|
||||
SUITE_EXPECT(test, it4 != it1);
|
||||
BEAST_EXPECT(it1 == it2);
|
||||
BEAST_EXPECT(it1 != it3);
|
||||
BEAST_EXPECT(it3 != it1);
|
||||
BEAST_EXPECT(it1 != it4);
|
||||
BEAST_EXPECT(it4 != it1);
|
||||
}
|
||||
|
||||
// bidirectional
|
||||
@ -212,24 +195,24 @@ test_buffer_sequence(
|
||||
n = length;
|
||||
for(it = first; n--; ++it)
|
||||
m += net::buffer_size(*it);
|
||||
SUITE_EXPECT(test, it == last);
|
||||
SUITE_EXPECT(test, m == size);
|
||||
BEAST_EXPECT(it == last);
|
||||
BEAST_EXPECT(m == size);
|
||||
|
||||
// post-increment
|
||||
m = 0;
|
||||
n = length;
|
||||
for(it = first; n--;)
|
||||
m += net::buffer_size(*it++);
|
||||
SUITE_EXPECT(test, it == last);
|
||||
SUITE_EXPECT(test, m == size);
|
||||
BEAST_EXPECT(it == last);
|
||||
BEAST_EXPECT(m == size);
|
||||
|
||||
// pre-decrement
|
||||
m = 0;
|
||||
n = length;
|
||||
for(it = last; n--;)
|
||||
m += net::buffer_size(*--it);
|
||||
SUITE_EXPECT(test, it == first);
|
||||
SUITE_EXPECT(test, m == size);
|
||||
BEAST_EXPECT(it == first);
|
||||
BEAST_EXPECT(m == size);
|
||||
|
||||
// post-decrement
|
||||
m = 0;
|
||||
@ -239,11 +222,11 @@ test_buffer_sequence(
|
||||
it--;
|
||||
m += net::buffer_size(*it);
|
||||
}
|
||||
SUITE_EXPECT(test, it == first);
|
||||
SUITE_EXPECT(test, m == size);
|
||||
BEAST_EXPECT(it == first);
|
||||
BEAST_EXPECT(m == size);
|
||||
}
|
||||
|
||||
detail::test_mutable_buffers(test, buffers,
|
||||
detail::test_mutable_buffers(buffers,
|
||||
buffers_type<ConstBufferSequence>{});
|
||||
}
|
||||
|
||||
@ -295,7 +278,6 @@ buffers_fill(
|
||||
template<class MutableDynamicBuffer>
|
||||
void
|
||||
test_mutable_dynamic_buffer(
|
||||
unit_test::suite&,
|
||||
MutableDynamicBuffer const&,
|
||||
std::false_type)
|
||||
{
|
||||
@ -304,7 +286,6 @@ test_mutable_dynamic_buffer(
|
||||
template<class MutableDynamicBuffer>
|
||||
void
|
||||
test_mutable_dynamic_buffer(
|
||||
unit_test::suite& test,
|
||||
MutableDynamicBuffer const& b0,
|
||||
std::true_type)
|
||||
{
|
||||
@ -327,23 +308,23 @@ test_mutable_dynamic_buffer(
|
||||
{
|
||||
MutableDynamicBuffer b(b0);
|
||||
auto const mb = b.prepare(src.size());
|
||||
SUITE_EXPECT(test, buffer_size(mb) == src.size());
|
||||
BEAST_EXPECT(buffer_size(mb) == src.size());
|
||||
buffers_fill(mb, '*');
|
||||
b.commit(src.size());
|
||||
SUITE_EXPECT(test, b.size() == src.size());
|
||||
SUITE_EXPECT(test,
|
||||
BEAST_EXPECT(b.size() == src.size());
|
||||
BEAST_EXPECT(
|
||||
beast::buffers_to_string(b.data()) ==
|
||||
std::string(src.size(), '*'));
|
||||
SUITE_EXPECT(test,
|
||||
BEAST_EXPECT(
|
||||
beast::buffers_to_string(b.cdata()) ==
|
||||
std::string(src.size(), '*'));
|
||||
auto const n = net::buffer_copy(
|
||||
b.data(), net::const_buffer(
|
||||
src.data(), src.size()));
|
||||
SUITE_EXPECT(test, n == src.size());
|
||||
SUITE_EXPECT(test,
|
||||
BEAST_EXPECT(n == src.size());
|
||||
BEAST_EXPECT(
|
||||
beast::buffers_to_string(b.data()) == src);
|
||||
SUITE_EXPECT(test,
|
||||
BEAST_EXPECT(
|
||||
beast::buffers_to_string(b.cdata()) == src);
|
||||
}
|
||||
|
||||
@ -357,13 +338,13 @@ test_mutable_dynamic_buffer(
|
||||
auto cb = static_cast<
|
||||
MutableDynamicBuffer const&>(b).data();
|
||||
auto cbc = b.cdata();
|
||||
SUITE_EXPECT(test,
|
||||
BEAST_EXPECT(
|
||||
beast::buffers_to_string(b.data()) == src);
|
||||
SUITE_EXPECT(test,
|
||||
BEAST_EXPECT(
|
||||
beast::buffers_to_string(b.cdata()) == src);
|
||||
beast::test_buffer_sequence(test, cb);
|
||||
beast::test_buffer_sequence(test, cbc);
|
||||
beast::test_buffer_sequence(test, mb);
|
||||
beast::test_buffer_sequence(cb);
|
||||
beast::test_buffer_sequence(cbc);
|
||||
beast::test_buffer_sequence(mb);
|
||||
{
|
||||
decltype(mb) mb2(mb);
|
||||
mb = mb2;
|
||||
@ -388,7 +369,6 @@ test_mutable_dynamic_buffer(
|
||||
template<class DynamicBuffer>
|
||||
void
|
||||
test_dynamic_buffer(
|
||||
unit_test::suite& test,
|
||||
DynamicBuffer const& b0)
|
||||
{
|
||||
using net::buffer_size;
|
||||
@ -404,8 +384,8 @@ test_dynamic_buffer(
|
||||
net::is_mutable_buffer_sequence<typename
|
||||
DynamicBuffer::mutable_buffers_type>::value);
|
||||
|
||||
SUITE_EXPECT(test, b0.size() == 0);
|
||||
SUITE_EXPECT(test, buffer_size(b0.data()) == 0);
|
||||
BEAST_EXPECT(b0.size() == 0);
|
||||
BEAST_EXPECT(buffer_size(b0.data()) == 0);
|
||||
|
||||
// members
|
||||
{
|
||||
@ -419,8 +399,8 @@ test_dynamic_buffer(
|
||||
// copy constructor
|
||||
{
|
||||
DynamicBuffer b2(b1);
|
||||
SUITE_EXPECT(test, b2.size() == b1.size());
|
||||
SUITE_EXPECT(test,
|
||||
BEAST_EXPECT(b2.size() == b1.size());
|
||||
BEAST_EXPECT(
|
||||
buffers_to_string(b1.data()) ==
|
||||
buffers_to_string(b2.data()));
|
||||
}
|
||||
@ -429,8 +409,8 @@ test_dynamic_buffer(
|
||||
{
|
||||
DynamicBuffer b2(b1);
|
||||
DynamicBuffer b3(std::move(b2));
|
||||
SUITE_EXPECT(test, b3.size() == b1.size());
|
||||
SUITE_EXPECT(test,
|
||||
BEAST_EXPECT(b3.size() == b1.size());
|
||||
BEAST_EXPECT(
|
||||
buffers_to_string(b3.data()) ==
|
||||
buffers_to_string(b1.data()));
|
||||
}
|
||||
@ -439,15 +419,15 @@ test_dynamic_buffer(
|
||||
{
|
||||
DynamicBuffer b2(b0);
|
||||
b2 = b1;
|
||||
SUITE_EXPECT(test, b2.size() == b1.size());
|
||||
SUITE_EXPECT(test,
|
||||
BEAST_EXPECT(b2.size() == b1.size());
|
||||
BEAST_EXPECT(
|
||||
buffers_to_string(b1.data()) ==
|
||||
buffers_to_string(b2.data()));
|
||||
|
||||
// self assignment
|
||||
b2 = b2;
|
||||
SUITE_EXPECT(test, b2.size() == b1.size());
|
||||
SUITE_EXPECT(test,
|
||||
BEAST_EXPECT(b2.size() == b1.size());
|
||||
BEAST_EXPECT(
|
||||
buffers_to_string(b2.data()) ==
|
||||
buffers_to_string(b1.data()));
|
||||
}
|
||||
@ -457,15 +437,15 @@ test_dynamic_buffer(
|
||||
DynamicBuffer b2(b1);
|
||||
DynamicBuffer b3(b0);
|
||||
b3 = std::move(b2);
|
||||
SUITE_EXPECT(test, b3.size() == b1.size());
|
||||
SUITE_EXPECT(test,
|
||||
BEAST_EXPECT(b3.size() == b1.size());
|
||||
BEAST_EXPECT(
|
||||
buffers_to_string(b3.data()) ==
|
||||
buffers_to_string(b1.data()));
|
||||
|
||||
// self move
|
||||
b3 = std::move(b3);
|
||||
SUITE_EXPECT(test, b3.size() == b1.size());
|
||||
SUITE_EXPECT(test,
|
||||
BEAST_EXPECT(b3.size() == b1.size());
|
||||
BEAST_EXPECT(
|
||||
buffers_to_string(b3.data()) ==
|
||||
buffers_to_string(b1.data()));
|
||||
}
|
||||
@ -474,13 +454,13 @@ test_dynamic_buffer(
|
||||
{
|
||||
DynamicBuffer b2(b1);
|
||||
DynamicBuffer b3(b0);
|
||||
SUITE_EXPECT(test, b2.size() == b1.size());
|
||||
SUITE_EXPECT(test, b3.size() == b0.size());
|
||||
BEAST_EXPECT(b2.size() == b1.size());
|
||||
BEAST_EXPECT(b3.size() == b0.size());
|
||||
using std::swap;
|
||||
swap(b2, b3);
|
||||
SUITE_EXPECT(test, b2.size() == b0.size());
|
||||
SUITE_EXPECT(test, b3.size() == b1.size());
|
||||
SUITE_EXPECT(test,
|
||||
BEAST_EXPECT(b2.size() == b0.size());
|
||||
BEAST_EXPECT(b3.size() == b1.size());
|
||||
BEAST_EXPECT(
|
||||
buffers_to_string(b3.data()) ==
|
||||
buffers_to_string(b1.data()));
|
||||
}
|
||||
@ -490,40 +470,40 @@ test_dynamic_buffer(
|
||||
{
|
||||
DynamicBuffer b(b0);
|
||||
b.commit(1);
|
||||
SUITE_EXPECT(test, b.size() == 0);
|
||||
SUITE_EXPECT(test, buffer_size(b.prepare(0)) == 0);
|
||||
BEAST_EXPECT(b.size() == 0);
|
||||
BEAST_EXPECT(buffer_size(b.prepare(0)) == 0);
|
||||
b.commit(0);
|
||||
SUITE_EXPECT(test, b.size() == 0);
|
||||
BEAST_EXPECT(b.size() == 0);
|
||||
b.commit(1);
|
||||
SUITE_EXPECT(test, b.size() == 0);
|
||||
BEAST_EXPECT(b.size() == 0);
|
||||
b.commit(b.max_size() + 1);
|
||||
SUITE_EXPECT(test, b.size() == 0);
|
||||
BEAST_EXPECT(b.size() == 0);
|
||||
b.consume(0);
|
||||
SUITE_EXPECT(test, b.size() == 0);
|
||||
BEAST_EXPECT(b.size() == 0);
|
||||
b.consume(1);
|
||||
SUITE_EXPECT(test, b.size() == 0);
|
||||
BEAST_EXPECT(b.size() == 0);
|
||||
b.consume(b.max_size() + 1);
|
||||
SUITE_EXPECT(test, b.size() == 0);
|
||||
BEAST_EXPECT(b.size() == 0);
|
||||
}
|
||||
|
||||
// max_size
|
||||
{
|
||||
DynamicBuffer b(b0);
|
||||
if(SUITE_EXPECT(test,
|
||||
if(BEAST_EXPECT(
|
||||
b.max_size() + 1 > b.max_size()))
|
||||
{
|
||||
try
|
||||
{
|
||||
b.prepare(b.max_size() + 1);
|
||||
test.fail("no exception", __FILE__, __LINE__);
|
||||
BEAST_FAIL();
|
||||
}
|
||||
catch(std::length_error const&)
|
||||
{
|
||||
test.pass();
|
||||
BEAST_PASS();
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
test.fail("wrong exception", __FILE__, __LINE__);
|
||||
BEAST_FAIL();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -534,9 +514,9 @@ test_dynamic_buffer(
|
||||
string_view src(buf, sizeof(buf));
|
||||
if(src.size() > b0.max_size())
|
||||
src = {src.data(), b0.max_size()};
|
||||
SUITE_EXPECT(test, b0.max_size() >= src.size());
|
||||
SUITE_EXPECT(test, b0.size() == 0);
|
||||
SUITE_EXPECT(test, buffer_size(b0.data()) == 0);
|
||||
BEAST_EXPECT(b0.max_size() >= src.size());
|
||||
BEAST_EXPECT(b0.size() == 0);
|
||||
BEAST_EXPECT(buffer_size(b0.data()) == 0);
|
||||
auto const make_new_src =
|
||||
[&buf, &k0, &src]
|
||||
{
|
||||
@ -551,13 +531,13 @@ test_dynamic_buffer(
|
||||
DynamicBuffer b(b0);
|
||||
auto const& bc(b);
|
||||
auto const mb = b.prepare(src.size());
|
||||
SUITE_EXPECT(test, buffer_size(mb) == src.size());
|
||||
beast::test_buffer_sequence(test, mb);
|
||||
BEAST_EXPECT(buffer_size(mb) == src.size());
|
||||
beast::test_buffer_sequence(mb);
|
||||
b.commit(net::buffer_copy(mb,
|
||||
net::const_buffer(src.data(), src.size())));
|
||||
SUITE_EXPECT(test,
|
||||
BEAST_EXPECT(
|
||||
buffer_size(bc.data()) == src.size());
|
||||
beast::test_buffer_sequence(test, bc.data());
|
||||
beast::test_buffer_sequence(bc.data());
|
||||
}
|
||||
|
||||
// h = in size
|
||||
@ -587,20 +567,20 @@ test_dynamic_buffer(
|
||||
b.commit(n);
|
||||
cb += n;
|
||||
}
|
||||
SUITE_EXPECT(test, b.size() == in.size());
|
||||
SUITE_EXPECT(test,
|
||||
BEAST_EXPECT(b.size() == in.size());
|
||||
BEAST_EXPECT(
|
||||
buffer_size(bc.data()) == in.size());
|
||||
SUITE_EXPECT(test, beast::buffers_to_string(
|
||||
BEAST_EXPECT(beast::buffers_to_string(
|
||||
bc.data()) == in);
|
||||
while(b.size() > 0)
|
||||
b.consume(k);
|
||||
SUITE_EXPECT(test, buffer_size(bc.data()) == 0);
|
||||
BEAST_EXPECT(buffer_size(bc.data()) == 0);
|
||||
}
|
||||
} } }
|
||||
}
|
||||
|
||||
// MutableDynamicBuffer refinement
|
||||
detail::test_mutable_dynamic_buffer(test, b0,
|
||||
detail::test_mutable_dynamic_buffer(b0,
|
||||
is_mutable_dynamic_buffer<DynamicBuffer>{});
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
char s[13];
|
||||
buffers_triple tb(s, sizeof(s));
|
||||
buffers_adaptor<buffers_triple> b(tb);
|
||||
test_dynamic_buffer(*this, b);
|
||||
test_dynamic_buffer(b);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -77,8 +77,7 @@ public:
|
||||
net::const_buffer b1(s.data(), 6);
|
||||
net::const_buffer b2(
|
||||
s.data() + b1.size(), s.size() - b1.size());
|
||||
test_buffer_sequence(
|
||||
*this, buffers_cat(b1, b2));
|
||||
test_buffer_sequence(buffers_cat(b1, b2));
|
||||
}
|
||||
|
||||
template<class F>
|
||||
@ -199,31 +198,31 @@ public:
|
||||
auto const b = beast::buffers_cat(b1, b2, b3);
|
||||
BEAST_EXPECT(beast::buffers_to_string(b) == "Hello, world!");
|
||||
BEAST_EXPECT(buffers_length(b) == 3);
|
||||
test_buffer_sequence(*this, b);
|
||||
test_buffer_sequence(b);
|
||||
}
|
||||
{
|
||||
auto const b = beast::buffers_cat(b0, b1, b2, b3);
|
||||
BEAST_EXPECT(beast::buffers_to_string(b) == "Hello, world!");
|
||||
BEAST_EXPECT(buffers_length(b) == 3);
|
||||
test_buffer_sequence(*this, b);
|
||||
test_buffer_sequence(b);
|
||||
}
|
||||
{
|
||||
auto const b = beast::buffers_cat(b1, b0, b2, b3);
|
||||
BEAST_EXPECT(beast::buffers_to_string(b) == "Hello, world!");
|
||||
BEAST_EXPECT(buffers_length(b) == 3);
|
||||
test_buffer_sequence(*this, b);
|
||||
test_buffer_sequence(b);
|
||||
}
|
||||
{
|
||||
auto const b = beast::buffers_cat(b1, b2, b0, b3);
|
||||
BEAST_EXPECT(beast::buffers_to_string(b) == "Hello, world!");
|
||||
BEAST_EXPECT(buffers_length(b) == 3);
|
||||
test_buffer_sequence(*this, b);
|
||||
test_buffer_sequence(b);
|
||||
}
|
||||
{
|
||||
auto const b = beast::buffers_cat(b1, b2, b3, b0);
|
||||
BEAST_EXPECT(beast::buffers_to_string(b) == "Hello, world!");
|
||||
BEAST_EXPECT(buffers_length(b) == 3);
|
||||
test_buffer_sequence(*this, b);
|
||||
test_buffer_sequence(b);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
auto const b =
|
||||
buffers_triple(buf, sizeof(buf));
|
||||
for(std::size_t i = 1; i <= sizeof(buf); ++i)
|
||||
test_buffer_sequence(*this,
|
||||
test_buffer_sequence(
|
||||
buffers_prefix(i, b));
|
||||
}
|
||||
|
||||
|
@ -70,12 +70,12 @@ public:
|
||||
{
|
||||
{
|
||||
string_view s = "Hello, world!";
|
||||
test_buffer_sequence(*this, buffers_range(
|
||||
test_buffer_sequence(buffers_range(
|
||||
net::const_buffer{s.data(), s.size()}));
|
||||
}
|
||||
{
|
||||
char buf[13];
|
||||
test_buffer_sequence(*this,
|
||||
test_buffer_sequence(
|
||||
buffers_range(net::mutable_buffer{
|
||||
buf, sizeof(buf)}));
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
char buf[13];
|
||||
auto b = buffers_triple(buf, sizeof(buf));
|
||||
buffers_suffix<decltype(b)> bs(b);
|
||||
test_buffer_sequence(*this, bs);
|
||||
test_buffer_sequence(bs);
|
||||
}
|
||||
|
||||
// const
|
||||
@ -42,7 +42,7 @@ public:
|
||||
net::const_buffer(src.data() + 3, 4),
|
||||
net::const_buffer(src.data() + 7, 6) }};
|
||||
buffers_suffix<decltype(b)> bs(b);
|
||||
test_buffer_sequence(*this, bs);
|
||||
test_buffer_sequence(bs);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
void
|
||||
run()
|
||||
{
|
||||
test_file<file_posix>(*this);
|
||||
test_file<file_posix>();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
void
|
||||
run()
|
||||
{
|
||||
test_file<file_stdio>(*this);
|
||||
test_file<file_stdio>();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -23,7 +23,7 @@ namespace beast {
|
||||
|
||||
template<class File>
|
||||
void
|
||||
test_file(beast::unit_test::suite& test)
|
||||
test_file()
|
||||
{
|
||||
BOOST_STATIC_ASSERT(
|
||||
is_file<File>::value);
|
||||
@ -58,13 +58,13 @@ test_file(beast::unit_test::suite& test)
|
||||
};
|
||||
|
||||
auto const create =
|
||||
[&test](fs::path const& path)
|
||||
[](fs::path const& path)
|
||||
{
|
||||
auto const s =
|
||||
path.string<std::string>();
|
||||
test.BEAST_EXPECT(! fs::exists(path));
|
||||
BEAST_EXPECT(! fs::exists(path));
|
||||
FILE* f = ::fopen(s.c_str(), "w");
|
||||
if( test.BEAST_EXPECT(f != nullptr))
|
||||
if( BEAST_EXPECT(f != nullptr))
|
||||
::fclose(f);
|
||||
};
|
||||
|
||||
@ -81,32 +81,32 @@ test_file(beast::unit_test::suite& test)
|
||||
{
|
||||
File f;
|
||||
char buf[1];
|
||||
test.BEAST_EXPECT(! f.is_open());
|
||||
test.BEAST_EXPECT(! fs::exists(path));
|
||||
BEAST_EXPECT(! f.is_open());
|
||||
BEAST_EXPECT(! fs::exists(path));
|
||||
{
|
||||
error_code ec;
|
||||
f.size(ec);
|
||||
test.BEAST_EXPECT(ec == errc::bad_file_descriptor);
|
||||
BEAST_EXPECT(ec == errc::bad_file_descriptor);
|
||||
}
|
||||
{
|
||||
error_code ec;
|
||||
f.pos(ec);
|
||||
test.BEAST_EXPECT(ec == errc::bad_file_descriptor);
|
||||
BEAST_EXPECT(ec == errc::bad_file_descriptor);
|
||||
}
|
||||
{
|
||||
error_code ec;
|
||||
f.seek(0, ec);
|
||||
test.BEAST_EXPECT(ec == errc::bad_file_descriptor);
|
||||
BEAST_EXPECT(ec == errc::bad_file_descriptor);
|
||||
}
|
||||
{
|
||||
error_code ec;
|
||||
f.read(buf, 0, ec);
|
||||
test.BEAST_EXPECT(ec == errc::bad_file_descriptor);
|
||||
BEAST_EXPECT(ec == errc::bad_file_descriptor);
|
||||
}
|
||||
{
|
||||
error_code ec;
|
||||
f.write(buf, 0, ec);
|
||||
test.BEAST_EXPECT(ec == errc::bad_file_descriptor);
|
||||
BEAST_EXPECT(ec == errc::bad_file_descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ test_file(beast::unit_test::suite& test)
|
||||
error_code ec;
|
||||
create(path);
|
||||
f.open(path, file_mode::read, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(! ec);
|
||||
}
|
||||
remove(path);
|
||||
}
|
||||
@ -129,7 +129,7 @@ test_file(beast::unit_test::suite& test)
|
||||
error_code ec;
|
||||
create(path);
|
||||
f.open(path, file_mode::scan, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(! ec);
|
||||
}
|
||||
remove(path);
|
||||
}
|
||||
@ -139,18 +139,18 @@ test_file(beast::unit_test::suite& test)
|
||||
{
|
||||
File f;
|
||||
error_code ec;
|
||||
test.BEAST_EXPECT(! fs::exists(path));
|
||||
BEAST_EXPECT(! fs::exists(path));
|
||||
f.open(path, file_mode::write, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BEAST_EXPECT(fs::exists(path));
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(fs::exists(path));
|
||||
}
|
||||
{
|
||||
File f;
|
||||
error_code ec;
|
||||
test.BEAST_EXPECT(fs::exists(path));
|
||||
BEAST_EXPECT(fs::exists(path));
|
||||
f.open(path, file_mode::write, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BEAST_EXPECT(fs::exists(path));
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(fs::exists(path));
|
||||
}
|
||||
remove(path);
|
||||
}
|
||||
@ -160,17 +160,17 @@ test_file(beast::unit_test::suite& test)
|
||||
{
|
||||
File f;
|
||||
error_code ec;
|
||||
test.BEAST_EXPECT(! fs::exists(path));
|
||||
BEAST_EXPECT(! fs::exists(path));
|
||||
f.open(path, file_mode::write_new, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BEAST_EXPECT(fs::exists(path));
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(fs::exists(path));
|
||||
}
|
||||
{
|
||||
File f;
|
||||
error_code ec;
|
||||
test.BEAST_EXPECT(fs::exists(path));
|
||||
BEAST_EXPECT(fs::exists(path));
|
||||
f.open(path, file_mode::write_new, ec);
|
||||
test.BEAST_EXPECT(ec);
|
||||
BEAST_EXPECT(ec);
|
||||
}
|
||||
remove(path);
|
||||
}
|
||||
@ -180,18 +180,18 @@ test_file(beast::unit_test::suite& test)
|
||||
{
|
||||
File f;
|
||||
error_code ec;
|
||||
test.BEAST_EXPECT(! fs::exists(path));
|
||||
BEAST_EXPECT(! fs::exists(path));
|
||||
f.open(path, file_mode::write_existing, ec);
|
||||
test.BEAST_EXPECT(ec);
|
||||
test.BEAST_EXPECT(! fs::exists(path));
|
||||
BEAST_EXPECT(ec);
|
||||
BEAST_EXPECT(! fs::exists(path));
|
||||
}
|
||||
{
|
||||
File f;
|
||||
error_code ec;
|
||||
create(path);
|
||||
test.BEAST_EXPECT(fs::exists(path));
|
||||
BEAST_EXPECT(fs::exists(path));
|
||||
f.open(path, file_mode::write_existing, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(! ec);
|
||||
}
|
||||
remove(path);
|
||||
}
|
||||
@ -201,18 +201,18 @@ test_file(beast::unit_test::suite& test)
|
||||
{
|
||||
File f;
|
||||
error_code ec;
|
||||
test.BEAST_EXPECT(! fs::exists(path));
|
||||
BEAST_EXPECT(! fs::exists(path));
|
||||
f.open(path, file_mode::append, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BEAST_EXPECT(fs::exists(path));
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(fs::exists(path));
|
||||
}
|
||||
{
|
||||
File f;
|
||||
error_code ec;
|
||||
test.BEAST_EXPECT(fs::exists(path));
|
||||
BEAST_EXPECT(fs::exists(path));
|
||||
f.open(path, file_mode::append, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BEAST_EXPECT(fs::exists(path));
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(fs::exists(path));
|
||||
}
|
||||
remove(path);
|
||||
}
|
||||
@ -222,19 +222,19 @@ test_file(beast::unit_test::suite& test)
|
||||
{
|
||||
File f;
|
||||
error_code ec;
|
||||
test.BEAST_EXPECT(! fs::exists(path));
|
||||
BEAST_EXPECT(! fs::exists(path));
|
||||
f.open(path, file_mode::append_existing, ec);
|
||||
test.BEAST_EXPECT(ec);
|
||||
test.BEAST_EXPECT(! fs::exists(path));
|
||||
BEAST_EXPECT(ec);
|
||||
BEAST_EXPECT(! fs::exists(path));
|
||||
}
|
||||
remove(path);
|
||||
{
|
||||
File f;
|
||||
error_code ec;
|
||||
create(path);
|
||||
test.BEAST_EXPECT(fs::exists(path));
|
||||
BEAST_EXPECT(fs::exists(path));
|
||||
f.open(path, file_mode::append_existing, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(! ec);
|
||||
}
|
||||
remove(path);
|
||||
}
|
||||
@ -245,19 +245,19 @@ test_file(beast::unit_test::suite& test)
|
||||
File f1;
|
||||
error_code ec;
|
||||
f1.open(path, file_mode::write, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BEAST_EXPECT(f1.is_open());
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(f1.is_open());
|
||||
|
||||
// move constructor
|
||||
File f2(std::move(f1));
|
||||
test.BEAST_EXPECT(! f1.is_open());
|
||||
test.BEAST_EXPECT(f2.is_open());
|
||||
BEAST_EXPECT(! f1.is_open());
|
||||
BEAST_EXPECT(f2.is_open());
|
||||
|
||||
// move assignment
|
||||
File f3;
|
||||
f3 = std::move(f2);
|
||||
test.BEAST_EXPECT(! f2.is_open());
|
||||
test.BEAST_EXPECT(f3.is_open());
|
||||
BEAST_EXPECT(! f2.is_open());
|
||||
BEAST_EXPECT(f3.is_open());
|
||||
}
|
||||
remove(path);
|
||||
}
|
||||
@ -268,9 +268,9 @@ test_file(beast::unit_test::suite& test)
|
||||
File f;
|
||||
error_code ec;
|
||||
f.open(path, file_mode::write, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(! ec);
|
||||
f.open(path, file_mode::write, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(! ec);
|
||||
}
|
||||
remove(path);
|
||||
}
|
||||
@ -283,15 +283,15 @@ test_file(beast::unit_test::suite& test)
|
||||
|
||||
File f1;
|
||||
f1.open(path, file_mode::write, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(! ec);
|
||||
|
||||
File f2;
|
||||
f2.open(path2, file_mode::write, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(! ec);
|
||||
|
||||
f2 = std::move(f1);
|
||||
test.BEAST_EXPECT(! f1.is_open());
|
||||
test.BEAST_EXPECT(f2.is_open());
|
||||
BEAST_EXPECT(! f1.is_open());
|
||||
BEAST_EXPECT(f2.is_open());
|
||||
}
|
||||
remove(path);
|
||||
remove(path2);
|
||||
@ -303,9 +303,9 @@ test_file(beast::unit_test::suite& test)
|
||||
File f;
|
||||
error_code ec;
|
||||
f.open(path, file_mode::write, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(! ec);
|
||||
f = std::move(f);
|
||||
test.BEAST_EXPECT(f.is_open());
|
||||
BEAST_EXPECT(f.is_open());
|
||||
}
|
||||
remove(path);
|
||||
}
|
||||
@ -317,11 +317,11 @@ test_file(beast::unit_test::suite& test)
|
||||
auto none = f.native_handle();
|
||||
error_code ec;
|
||||
f.open(path, file_mode::write, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(! ec);
|
||||
auto fd = f.native_handle();
|
||||
test.BEAST_EXPECT(fd != none);
|
||||
BEAST_EXPECT(fd != none);
|
||||
f.native_handle(none);
|
||||
test.BEAST_EXPECT(! f.is_open());
|
||||
BEAST_EXPECT(! f.is_open());
|
||||
}
|
||||
remove(path);
|
||||
}
|
||||
@ -335,21 +335,21 @@ test_file(beast::unit_test::suite& test)
|
||||
File f;
|
||||
error_code ec;
|
||||
f.open(path, file_mode::write, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(! ec);
|
||||
|
||||
f.write(s.data(), s.size(), ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(! ec);
|
||||
|
||||
auto size = f.size(ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BEAST_EXPECT(size == s.size());
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(size == s.size());
|
||||
|
||||
auto pos = f.pos(ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BEAST_EXPECT(pos == size);
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(pos == size);
|
||||
|
||||
f.close(ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(! ec);
|
||||
}
|
||||
|
||||
// read
|
||||
@ -357,29 +357,29 @@ test_file(beast::unit_test::suite& test)
|
||||
File f;
|
||||
error_code ec;
|
||||
f.open(path, file_mode::read, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(! ec);
|
||||
|
||||
std::string buf;
|
||||
buf.resize(s.size());
|
||||
f.read(&buf[0], buf.size(), ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BEAST_EXPECT(buf == s);
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(buf == s);
|
||||
|
||||
f.seek(1, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(! ec);
|
||||
buf.resize(3);
|
||||
f.read(&buf[0], buf.size(), ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BEAST_EXPECT(buf == "ell");
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(buf == "ell");
|
||||
|
||||
auto pos = f.pos(ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BEAST_EXPECT(pos == 4);
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(pos == 4);
|
||||
}
|
||||
remove(path);
|
||||
}
|
||||
|
||||
test.BEAST_EXPECT(! fs::exists(path));
|
||||
BEAST_EXPECT(! fs::exists(path));
|
||||
}
|
||||
|
||||
} // beast
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
void
|
||||
run()
|
||||
{
|
||||
test_file<file_win32>(*this);
|
||||
test_file<file_win32>();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
{
|
||||
flat_buffer b(30);
|
||||
BEAST_EXPECT(b.max_size() == 30);
|
||||
test_dynamic_buffer(*this, b);
|
||||
test_dynamic_buffer(b);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -34,8 +34,7 @@ public:
|
||||
void
|
||||
testDynamicBuffer()
|
||||
{
|
||||
flat_static_buffer<13> b;
|
||||
test_dynamic_buffer(*this, b);
|
||||
test_dynamic_buffer(flat_static_buffer<13>{});
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
{
|
||||
multi_buffer b(30);
|
||||
BEAST_EXPECT(b.max_size() == 30);
|
||||
test_dynamic_buffer(*this, b);
|
||||
test_dynamic_buffer(b);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -23,29 +23,22 @@ class saved_handler_test : public unit_test::suite
|
||||
public:
|
||||
class handler
|
||||
{
|
||||
unit_test::suite& s_;
|
||||
bool failed_ = true;
|
||||
bool throw_on_move_ = false;
|
||||
|
||||
public:
|
||||
handler() = default;
|
||||
handler(handler const&) = delete;
|
||||
handler& operator=(handler&&) = delete;
|
||||
handler& operator=(handler const&) = delete;
|
||||
|
||||
~handler()
|
||||
{
|
||||
s_.BEAST_EXPECT(! failed_);
|
||||
}
|
||||
|
||||
explicit
|
||||
handler(unit_test::suite& s)
|
||||
: s_(s)
|
||||
{
|
||||
BEAST_EXPECT(! failed_);
|
||||
}
|
||||
|
||||
handler(handler&& other)
|
||||
: s_(other.s_)
|
||||
, failed_(boost::exchange(
|
||||
: failed_(boost::exchange(
|
||||
other.failed_, false))
|
||||
{
|
||||
if(throw_on_move_)
|
||||
@ -61,28 +54,21 @@ public:
|
||||
|
||||
class unhandler
|
||||
{
|
||||
unit_test::suite& s_;
|
||||
bool invoked_ = false;
|
||||
|
||||
public:
|
||||
unhandler() = default;
|
||||
unhandler(unhandler const&) = delete;
|
||||
unhandler& operator=(unhandler&&) = delete;
|
||||
unhandler& operator=(unhandler const&) = delete;
|
||||
|
||||
~unhandler()
|
||||
{
|
||||
s_.BEAST_EXPECT(! invoked_);
|
||||
}
|
||||
|
||||
explicit
|
||||
unhandler(unit_test::suite& s)
|
||||
: s_(s)
|
||||
{
|
||||
BEAST_EXPECT(! invoked_);
|
||||
}
|
||||
|
||||
unhandler(unhandler&& other)
|
||||
: s_(other.s_)
|
||||
, invoked_(boost::exchange(
|
||||
: invoked_(boost::exchange(
|
||||
other.invoked_, false))
|
||||
{
|
||||
}
|
||||
@ -116,17 +102,17 @@ public:
|
||||
saved_handler sh;
|
||||
BEAST_EXPECT(! sh.has_value());
|
||||
|
||||
sh.emplace(handler{*this});
|
||||
sh.emplace(handler{});
|
||||
BEAST_EXPECT(sh.has_value());
|
||||
sh.invoke();
|
||||
BEAST_EXPECT(! sh.has_value());
|
||||
|
||||
sh.emplace(handler{*this}, std::allocator<char>{});
|
||||
sh.emplace(handler{}, std::allocator<char>{});
|
||||
BEAST_EXPECT(sh.has_value());
|
||||
sh.invoke();
|
||||
BEAST_EXPECT(! sh.has_value());
|
||||
|
||||
sh.emplace(unhandler{*this});
|
||||
sh.emplace(unhandler{});
|
||||
BEAST_EXPECT(sh.has_value());
|
||||
}
|
||||
|
||||
|
@ -47,8 +47,7 @@ public:
|
||||
void
|
||||
testDynamicBuffer()
|
||||
{
|
||||
static_buffer<13> b;
|
||||
test_dynamic_buffer(*this, b);
|
||||
test_dynamic_buffer(static_buffer<13>{});
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -114,7 +114,7 @@ struct legacy_handler
|
||||
template<class F>
|
||||
static
|
||||
void
|
||||
test(unit_test::suite& suite, F const& f)
|
||||
test(F const& f)
|
||||
{
|
||||
{
|
||||
bool hook_invoked = false;
|
||||
@ -126,29 +126,29 @@ struct legacy_handler
|
||||
{
|
||||
lambda_invoked =true;
|
||||
}, &h);
|
||||
suite.BEAST_EXPECT(hook_invoked);
|
||||
suite.BEAST_EXPECT(lambda_invoked);
|
||||
BEAST_EXPECT(hook_invoked);
|
||||
BEAST_EXPECT(lambda_invoked);
|
||||
}
|
||||
{
|
||||
bool hook_invoked = false;
|
||||
auto h = f(legacy_handler{hook_invoked});
|
||||
using net::asio_handler_allocate;
|
||||
asio_handler_allocate(0, &h);
|
||||
suite.BEAST_EXPECT(hook_invoked);
|
||||
BEAST_EXPECT(hook_invoked);
|
||||
}
|
||||
{
|
||||
bool hook_invoked = false;
|
||||
auto h = f(legacy_handler{hook_invoked});
|
||||
using net::asio_handler_deallocate;
|
||||
asio_handler_deallocate(nullptr, 0, &h);
|
||||
suite.BEAST_EXPECT(hook_invoked);
|
||||
BEAST_EXPECT(hook_invoked);
|
||||
}
|
||||
{
|
||||
bool hook_invoked = false;
|
||||
auto h = f(legacy_handler{hook_invoked});
|
||||
using net::asio_handler_is_continuation;
|
||||
asio_handler_is_continuation(&h);
|
||||
suite.BEAST_EXPECT(hook_invoked);
|
||||
BEAST_EXPECT(hook_invoked);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user