buffers_front tests

This commit is contained in:
Vinnie Falco
2019-02-08 10:47:36 -08:00
parent b8aa6be7fd
commit 44ed20aa2c
2 changed files with 32 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ Version 212:
* dynamic_buffer_ref tests and tidy * dynamic_buffer_ref tests and tidy
* flat_stream tests and tidy * flat_stream tests and tidy
* stranded_socket tests and tidy * stranded_socket tests and tidy
* buffers_front tests
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@@ -124,6 +124,36 @@ public:
BEAST_EXPECT(net::buffer_copy(pb0, pb1) == 0); BEAST_EXPECT(net::buffer_copy(pb0, pb1) == 0);
} }
void
testBuffersFront()
{
{
std::array<net::const_buffer, 2> v;
v[0] = {"", 0};
v[1] = net::const_buffer("Hello, world!", 13);
BEAST_EXPECT(buffers_front(v).size() == 0);
std::swap(v[0], v[1]);
BEAST_EXPECT(buffers_front(v).size() == 13);
}
{
struct null_sequence
{
net::const_buffer b;
using iterator = net::const_buffer const*;
iterator begin() const noexcept
{
return &b;
}
iterator end() const noexcept
{
return begin();
}
};
null_sequence z;
BEAST_EXPECT(buffers_front(z).size() == 0);
}
}
void void
run() override run() override
{ {
@@ -132,6 +162,7 @@ public:
testPrefixes<net::const_buffer>(); testPrefixes<net::const_buffer>();
testPrefixes<net::mutable_buffer>(); testPrefixes<net::mutable_buffer>();
testEmpty(); testEmpty();
testBuffersFront();
} }
}; };