mirror of
https://github.com/boostorg/beast.git
synced 2025-08-04 07:14:32 +02:00
Add BEAST_EXPECT macro:
This macro is used in the unit test framework to assist in reporting the file and line number of test failures.
This commit is contained in:
@@ -510,6 +510,14 @@ suite::run (runner& r)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef BEAST_EXPECT
|
||||
/** Check a precondition.
|
||||
*/
|
||||
#define BEAST_EXPECT_S1(x) #x
|
||||
#define BEAST_EXPECT_S2(x) BEAST_EXPECT_S1(x)
|
||||
#define BEAST_EXPECT(cond) expect(cond, __FILE__ ":" BEAST_EXPECT_S2(__LINE__))
|
||||
#endif
|
||||
|
||||
} // unit_test
|
||||
} // beast
|
||||
|
||||
|
@@ -153,10 +153,10 @@ public:
|
||||
void
|
||||
expect_size(std::size_t n, ConstBufferSequence const& buffers)
|
||||
{
|
||||
expect(test::size_pre(buffers) == n);
|
||||
expect(test::size_post(buffers) == n);
|
||||
expect(test::size_rev_pre(buffers) == n);
|
||||
expect(test::size_rev_post(buffers) == n);
|
||||
BEAST_EXPECT(test::size_pre(buffers) == n);
|
||||
BEAST_EXPECT(test::size_post(buffers) == n);
|
||||
BEAST_EXPECT(test::size_rev_pre(buffers) == n);
|
||||
BEAST_EXPECT(test::size_rev_post(buffers) == n);
|
||||
}
|
||||
|
||||
template<class U, class V>
|
||||
@@ -173,7 +173,7 @@ public:
|
||||
using boost::asio::buffer_cast;
|
||||
using boost::asio::buffer_size;
|
||||
std::string const s = "Hello, world";
|
||||
expect(s.size() == 12);
|
||||
BEAST_EXPECT(s.size() == 12);
|
||||
for(std::size_t i = 1; i < 12; ++i) {
|
||||
for(std::size_t x = 1; x < 4; ++x) {
|
||||
for(std::size_t y = 1; y < 4; ++y) {
|
||||
@@ -183,28 +183,28 @@ public:
|
||||
sb.commit(buffer_copy(sb.prepare(x), buffer(s.data(), x)));
|
||||
sb.commit(buffer_copy(sb.prepare(y), buffer(s.data()+x, y)));
|
||||
sb.commit(buffer_copy(sb.prepare(z), buffer(s.data()+x+y, z)));
|
||||
expect(to_string(sb.data()) == s);
|
||||
BEAST_EXPECT(to_string(sb.data()) == s);
|
||||
{
|
||||
streambuf sb2(sb);
|
||||
expect(eq(sb, sb2));
|
||||
BEAST_EXPECT(eq(sb, sb2));
|
||||
}
|
||||
{
|
||||
streambuf sb2;
|
||||
sb2 = sb;
|
||||
expect(eq(sb, sb2));
|
||||
BEAST_EXPECT(eq(sb, sb2));
|
||||
}
|
||||
{
|
||||
streambuf sb2(std::move(sb));
|
||||
expect(to_string(sb2.data()) == s);
|
||||
BEAST_EXPECT(to_string(sb2.data()) == s);
|
||||
expect_size(0, sb.data());
|
||||
sb = std::move(sb2);
|
||||
expect(to_string(sb.data()) == s);
|
||||
BEAST_EXPECT(to_string(sb.data()) == s);
|
||||
expect_size(0, sb2.data());
|
||||
}
|
||||
self_assign(sb, sb);
|
||||
expect(to_string(sb.data()) == s);
|
||||
BEAST_EXPECT(to_string(sb.data()) == s);
|
||||
self_assign(sb, std::move(sb));
|
||||
expect(to_string(sb.data()) == s);
|
||||
BEAST_EXPECT(to_string(sb.data()) == s);
|
||||
}
|
||||
}}}
|
||||
try
|
||||
@@ -226,16 +226,16 @@ public:
|
||||
test_allocator<char, false, false, false, false>;
|
||||
using sb_type = basic_streambuf<alloc_type>;
|
||||
sb_type sb;
|
||||
expect(sb.get_allocator().id() == 1);
|
||||
BEAST_EXPECT(sb.get_allocator().id() == 1);
|
||||
}
|
||||
{
|
||||
using alloc_type =
|
||||
test_allocator<char, false, false, false, false>;
|
||||
using sb_type = basic_streambuf<alloc_type>;
|
||||
sb_type sb;
|
||||
expect(sb.get_allocator().id() == 2);
|
||||
BEAST_EXPECT(sb.get_allocator().id() == 2);
|
||||
sb_type sb2(sb);
|
||||
expect(sb2.get_allocator().id() == 2);
|
||||
BEAST_EXPECT(sb2.get_allocator().id() == 2);
|
||||
sb_type sb3(sb, alloc_type{});
|
||||
}
|
||||
}
|
||||
@@ -246,16 +246,16 @@ public:
|
||||
using boost::asio::buffer_size;
|
||||
{
|
||||
streambuf sb(2);
|
||||
expect(buffer_size(sb.prepare(5)) == 5);
|
||||
expect(buffer_size(sb.prepare(8)) == 8);
|
||||
expect(buffer_size(sb.prepare(7)) == 7);
|
||||
BEAST_EXPECT(buffer_size(sb.prepare(5)) == 5);
|
||||
BEAST_EXPECT(buffer_size(sb.prepare(8)) == 8);
|
||||
BEAST_EXPECT(buffer_size(sb.prepare(7)) == 7);
|
||||
}
|
||||
{
|
||||
streambuf sb(2);
|
||||
sb.prepare(2);
|
||||
expect(test::buffer_count(sb.prepare(5)) == 2);
|
||||
expect(test::buffer_count(sb.prepare(8)) == 3);
|
||||
expect(test::buffer_count(sb.prepare(4)) == 2);
|
||||
BEAST_EXPECT(test::buffer_count(sb.prepare(5)) == 2);
|
||||
BEAST_EXPECT(test::buffer_count(sb.prepare(8)) == 3);
|
||||
BEAST_EXPECT(test::buffer_count(sb.prepare(4)) == 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ public:
|
||||
using boost::asio::buffer_cast;
|
||||
using boost::asio::buffer_size;
|
||||
std::string const s = "Hello, world";
|
||||
expect(s.size() == 12);
|
||||
BEAST_EXPECT(s.size() == 12);
|
||||
for(std::size_t i = 1; i < 12; ++i) {
|
||||
for(std::size_t x = 1; x < 4; ++x) {
|
||||
for(std::size_t y = 1; y < 4; ++y) {
|
||||
@@ -298,78 +298,78 @@ public:
|
||||
streambuf sb(i);
|
||||
{
|
||||
auto d = sb.prepare(z);
|
||||
expect(buffer_size(d) == z);
|
||||
BEAST_EXPECT(buffer_size(d) == z);
|
||||
}
|
||||
{
|
||||
auto d = sb.prepare(0);
|
||||
expect(buffer_size(d) == 0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
{
|
||||
auto d = sb.prepare(y);
|
||||
expect(buffer_size(d) == y);
|
||||
BEAST_EXPECT(buffer_size(d) == y);
|
||||
}
|
||||
{
|
||||
auto d = sb.prepare(x);
|
||||
expect(buffer_size(d) == x);
|
||||
BEAST_EXPECT(buffer_size(d) == x);
|
||||
sb.commit(buffer_copy(d, buffer(s.data(), x)));
|
||||
}
|
||||
expect(sb.size() == x);
|
||||
expect(buffer_size(sb.data()) == sb.size());
|
||||
BEAST_EXPECT(sb.size() == x);
|
||||
BEAST_EXPECT(buffer_size(sb.data()) == sb.size());
|
||||
{
|
||||
auto d = sb.prepare(x);
|
||||
expect(buffer_size(d) == x);
|
||||
BEAST_EXPECT(buffer_size(d) == x);
|
||||
}
|
||||
{
|
||||
auto d = sb.prepare(0);
|
||||
expect(buffer_size(d) == 0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
{
|
||||
auto d = sb.prepare(z);
|
||||
expect(buffer_size(d) == z);
|
||||
BEAST_EXPECT(buffer_size(d) == z);
|
||||
}
|
||||
{
|
||||
auto d = sb.prepare(y);
|
||||
expect(buffer_size(d) == y);
|
||||
BEAST_EXPECT(buffer_size(d) == y);
|
||||
sb.commit(buffer_copy(d, buffer(s.data()+x, y)));
|
||||
}
|
||||
sb.commit(1);
|
||||
expect(sb.size() == x + y);
|
||||
expect(buffer_size(sb.data()) == sb.size());
|
||||
BEAST_EXPECT(sb.size() == x + y);
|
||||
BEAST_EXPECT(buffer_size(sb.data()) == sb.size());
|
||||
{
|
||||
auto d = sb.prepare(x);
|
||||
expect(buffer_size(d) == x);
|
||||
BEAST_EXPECT(buffer_size(d) == x);
|
||||
}
|
||||
{
|
||||
auto d = sb.prepare(y);
|
||||
expect(buffer_size(d) == y);
|
||||
BEAST_EXPECT(buffer_size(d) == y);
|
||||
}
|
||||
{
|
||||
auto d = sb.prepare(0);
|
||||
expect(buffer_size(d) == 0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
{
|
||||
auto d = sb.prepare(z);
|
||||
expect(buffer_size(d) == z);
|
||||
BEAST_EXPECT(buffer_size(d) == z);
|
||||
sb.commit(buffer_copy(d, buffer(s.data()+x+y, z)));
|
||||
}
|
||||
sb.commit(2);
|
||||
expect(sb.size() == x + y + z);
|
||||
expect(buffer_size(sb.data()) == sb.size());
|
||||
expect(to_string(sb.data()) == s);
|
||||
BEAST_EXPECT(sb.size() == x + y + z);
|
||||
BEAST_EXPECT(buffer_size(sb.data()) == sb.size());
|
||||
BEAST_EXPECT(to_string(sb.data()) == s);
|
||||
sb.consume(t);
|
||||
{
|
||||
auto d = sb.prepare(0);
|
||||
expect(buffer_size(d) == 0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
expect(to_string(sb.data()) == s.substr(t, std::string::npos));
|
||||
BEAST_EXPECT(to_string(sb.data()) == s.substr(t, std::string::npos));
|
||||
sb.consume(u);
|
||||
expect(to_string(sb.data()) == s.substr(t + u, std::string::npos));
|
||||
BEAST_EXPECT(to_string(sb.data()) == s.substr(t + u, std::string::npos));
|
||||
sb.consume(v);
|
||||
expect(to_string(sb.data()) == "");
|
||||
BEAST_EXPECT(to_string(sb.data()) == "");
|
||||
sb.consume(1);
|
||||
{
|
||||
auto d = sb.prepare(0);
|
||||
expect(buffer_size(d) == 0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
}
|
||||
}}}}}
|
||||
@@ -387,14 +387,14 @@ public:
|
||||
sb.prepare(1);
|
||||
expect_size(3, sb.prepare(3));
|
||||
sb.commit(2);
|
||||
expect(test::buffer_count(sb.data()) == 4);
|
||||
BEAST_EXPECT(test::buffer_count(sb.data()) == 4);
|
||||
}
|
||||
|
||||
void testOutputStream()
|
||||
{
|
||||
streambuf sb;
|
||||
sb << "x";
|
||||
expect(to_string(sb.data()) == "x");
|
||||
BEAST_EXPECT(to_string(sb.data()) == "x");
|
||||
}
|
||||
|
||||
void testReadSizeHelper()
|
||||
@@ -402,44 +402,44 @@ public:
|
||||
using boost::asio::buffer_size;
|
||||
{
|
||||
streambuf sb(10);
|
||||
expect(read_size_helper(sb, 0) == 0);
|
||||
expect(read_size_helper(sb, 1) == 1);
|
||||
expect(read_size_helper(sb, 10) == 10);
|
||||
expect(read_size_helper(sb, 20) == 20);
|
||||
expect(read_size_helper(sb, 1000) == 512);
|
||||
BEAST_EXPECT(read_size_helper(sb, 0) == 0);
|
||||
BEAST_EXPECT(read_size_helper(sb, 1) == 1);
|
||||
BEAST_EXPECT(read_size_helper(sb, 10) == 10);
|
||||
BEAST_EXPECT(read_size_helper(sb, 20) == 20);
|
||||
BEAST_EXPECT(read_size_helper(sb, 1000) == 512);
|
||||
sb.prepare(3);
|
||||
sb.commit(3);
|
||||
expect(read_size_helper(sb, 10) == 7);
|
||||
expect(read_size_helper(sb, 1000) == 7);
|
||||
BEAST_EXPECT(read_size_helper(sb, 10) == 7);
|
||||
BEAST_EXPECT(read_size_helper(sb, 1000) == 7);
|
||||
}
|
||||
{
|
||||
streambuf sb(1000);
|
||||
expect(read_size_helper(sb, 0) == 0);
|
||||
expect(read_size_helper(sb, 1) == 1);
|
||||
expect(read_size_helper(sb, 1000) == 1000);
|
||||
expect(read_size_helper(sb, 2000) == 1000);
|
||||
BEAST_EXPECT(read_size_helper(sb, 0) == 0);
|
||||
BEAST_EXPECT(read_size_helper(sb, 1) == 1);
|
||||
BEAST_EXPECT(read_size_helper(sb, 1000) == 1000);
|
||||
BEAST_EXPECT(read_size_helper(sb, 2000) == 1000);
|
||||
sb.prepare(3);
|
||||
expect(read_size_helper(sb, 0) == 0);
|
||||
expect(read_size_helper(sb, 1) == 1);
|
||||
expect(read_size_helper(sb, 1000) == 1000);
|
||||
expect(read_size_helper(sb, 2000) == 1000);
|
||||
BEAST_EXPECT(read_size_helper(sb, 0) == 0);
|
||||
BEAST_EXPECT(read_size_helper(sb, 1) == 1);
|
||||
BEAST_EXPECT(read_size_helper(sb, 1000) == 1000);
|
||||
BEAST_EXPECT(read_size_helper(sb, 2000) == 1000);
|
||||
sb.commit(3);
|
||||
expect(read_size_helper(sb, 0) == 0);
|
||||
expect(read_size_helper(sb, 1) == 1);
|
||||
expect(read_size_helper(sb, 1000) == 997);
|
||||
expect(read_size_helper(sb, 2000) == 997);
|
||||
BEAST_EXPECT(read_size_helper(sb, 0) == 0);
|
||||
BEAST_EXPECT(read_size_helper(sb, 1) == 1);
|
||||
BEAST_EXPECT(read_size_helper(sb, 1000) == 997);
|
||||
BEAST_EXPECT(read_size_helper(sb, 2000) == 997);
|
||||
sb.consume(2);
|
||||
expect(read_size_helper(sb, 0) == 0);
|
||||
expect(read_size_helper(sb, 1) == 1);
|
||||
expect(read_size_helper(sb, 1000) == 997);
|
||||
expect(read_size_helper(sb, 2000) == 997);
|
||||
BEAST_EXPECT(read_size_helper(sb, 0) == 0);
|
||||
BEAST_EXPECT(read_size_helper(sb, 1) == 1);
|
||||
BEAST_EXPECT(read_size_helper(sb, 1000) == 997);
|
||||
BEAST_EXPECT(read_size_helper(sb, 2000) == 997);
|
||||
}
|
||||
{
|
||||
streambuf sb(2);
|
||||
expect(test::buffer_count(sb.prepare(2)) == 1);
|
||||
expect(test::buffer_count(sb.prepare(3)) == 2);
|
||||
expect(buffer_size(sb.prepare(5)) == 5);
|
||||
expect(read_size_helper(sb, 10) == 6);
|
||||
BEAST_EXPECT(test::buffer_count(sb.prepare(2)) == 1);
|
||||
BEAST_EXPECT(test::buffer_count(sb.prepare(3)) == 2);
|
||||
BEAST_EXPECT(buffer_size(sb.prepare(5)) == 5);
|
||||
BEAST_EXPECT(read_size_helper(sb, 10) == 6);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -47,32 +47,32 @@ public:
|
||||
std::list<const_buffer> b6;
|
||||
auto bs = buffer_cat(
|
||||
b1, b2, b3, b4, b5, b6);
|
||||
expect(buffer_size(bs) == 10);
|
||||
BEAST_EXPECT(buffer_size(bs) == 10);
|
||||
std::vector<const_buffer> v;
|
||||
for(auto iter = make_reverse_iterator(bs.end());
|
||||
iter != make_reverse_iterator(bs.begin()); ++iter)
|
||||
v.emplace_back(*iter);
|
||||
expect(buffer_size(bs) == 10);
|
||||
BEAST_EXPECT(buffer_size(bs) == 10);
|
||||
decltype(bs) bs2(bs);
|
||||
auto bs3(std::move(bs));
|
||||
bs = bs2;
|
||||
bs3 = std::move(bs2);
|
||||
{
|
||||
boost::asio::streambuf sb1, sb2;
|
||||
expect(buffer_size(buffer_cat(
|
||||
BEAST_EXPECT(buffer_size(buffer_cat(
|
||||
sb1.prepare(5), sb2.prepare(7))) == 12);
|
||||
sb1.commit(5);
|
||||
sb2.commit(7);
|
||||
expect(buffer_size(buffer_cat(
|
||||
BEAST_EXPECT(buffer_size(buffer_cat(
|
||||
sb1.data(), sb2.data())) == 12);
|
||||
}
|
||||
for(auto it = bs.begin(); it != bs.end(); ++it)
|
||||
{
|
||||
decltype(bs)::const_iterator copy;
|
||||
copy = it;
|
||||
expect(copy == it);
|
||||
BEAST_EXPECT(copy == it);
|
||||
copy = copy;
|
||||
expect(copy == it);
|
||||
BEAST_EXPECT(copy == it);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,11 +132,11 @@ public:
|
||||
pass();
|
||||
}
|
||||
auto bs2 = bs;
|
||||
expect(bs.begin() != bs2.begin());
|
||||
expect(bs.end() != bs2.end());
|
||||
BEAST_EXPECT(bs.begin() != bs2.begin());
|
||||
BEAST_EXPECT(bs.end() != bs2.end());
|
||||
decltype(bs)::const_iterator it;
|
||||
decltype(bs2)::const_iterator it2;
|
||||
expect(it == it2);
|
||||
BEAST_EXPECT(it == it2);
|
||||
}
|
||||
|
||||
void run() override
|
||||
|
@@ -43,7 +43,7 @@ public:
|
||||
using boost::asio::mutable_buffer;
|
||||
char buf[12];
|
||||
std::string const s = "Hello, world";
|
||||
expect(s.size() == sizeof(buf));
|
||||
BEAST_EXPECT(s.size() == sizeof(buf));
|
||||
for(std::size_t i = 1; i < 4; ++i) {
|
||||
for(std::size_t j = 1; j < 4; ++j) {
|
||||
for(std::size_t x = 1; x < 4; ++x) {
|
||||
@@ -60,83 +60,83 @@ public:
|
||||
mutable_buffer{&buf[i], j},
|
||||
mutable_buffer{&buf[i+j], k}}};
|
||||
buffers_adapter<decltype(bs)> ba(std::move(bs));
|
||||
expect(ba.max_size() == sizeof(buf));
|
||||
BEAST_EXPECT(ba.max_size() == sizeof(buf));
|
||||
{
|
||||
auto d = ba.prepare(z);
|
||||
expect(buffer_size(d) == z);
|
||||
BEAST_EXPECT(buffer_size(d) == z);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
expect(buffer_size(d) == 0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(y);
|
||||
expect(buffer_size(d) == y);
|
||||
BEAST_EXPECT(buffer_size(d) == y);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(x);
|
||||
expect(buffer_size(d) == x);
|
||||
BEAST_EXPECT(buffer_size(d) == x);
|
||||
ba.commit(buffer_copy(d, buffer(s.data(), x)));
|
||||
}
|
||||
expect(ba.size() == x);
|
||||
expect(ba.max_size() == sizeof(buf) - x);
|
||||
expect(buffer_size(ba.data()) == ba.size());
|
||||
BEAST_EXPECT(ba.size() == x);
|
||||
BEAST_EXPECT(ba.max_size() == sizeof(buf) - x);
|
||||
BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
{
|
||||
auto d = ba.prepare(x);
|
||||
expect(buffer_size(d) == x);
|
||||
BEAST_EXPECT(buffer_size(d) == x);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
expect(buffer_size(d) == 0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(z);
|
||||
expect(buffer_size(d) == z);
|
||||
BEAST_EXPECT(buffer_size(d) == z);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(y);
|
||||
expect(buffer_size(d) == y);
|
||||
BEAST_EXPECT(buffer_size(d) == y);
|
||||
ba.commit(buffer_copy(d, buffer(s.data()+x, y)));
|
||||
}
|
||||
ba.commit(1);
|
||||
expect(ba.size() == x + y);
|
||||
expect(ba.max_size() == sizeof(buf) - (x + y));
|
||||
expect(buffer_size(ba.data()) == ba.size());
|
||||
BEAST_EXPECT(ba.size() == x + y);
|
||||
BEAST_EXPECT(ba.max_size() == sizeof(buf) - (x + y));
|
||||
BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
{
|
||||
auto d = ba.prepare(x);
|
||||
expect(buffer_size(d) == x);
|
||||
BEAST_EXPECT(buffer_size(d) == x);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(y);
|
||||
expect(buffer_size(d) == y);
|
||||
BEAST_EXPECT(buffer_size(d) == y);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
expect(buffer_size(d) == 0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(z); expect(buffer_size(d) == z);
|
||||
auto d = ba.prepare(z); BEAST_EXPECT(buffer_size(d) == z);
|
||||
ba.commit(buffer_copy(d, buffer(s.data()+x+y, z)));
|
||||
}
|
||||
ba.commit(2);
|
||||
expect(ba.size() == x + y + z);
|
||||
expect(ba.max_size() == 0);
|
||||
expect(buffer_size(ba.data()) == ba.size());
|
||||
expect(to_string(ba.data()) == s);
|
||||
BEAST_EXPECT(ba.size() == x + y + z);
|
||||
BEAST_EXPECT(ba.max_size() == 0);
|
||||
BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
BEAST_EXPECT(to_string(ba.data()) == s);
|
||||
ba.consume(t);
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
expect(buffer_size(d) == 0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
expect(to_string(ba.data()) == s.substr(t, std::string::npos));
|
||||
BEAST_EXPECT(to_string(ba.data()) == s.substr(t, std::string::npos));
|
||||
ba.consume(u);
|
||||
expect(to_string(ba.data()) == s.substr(t + u, std::string::npos));
|
||||
BEAST_EXPECT(to_string(ba.data()) == s.substr(t + u, std::string::npos));
|
||||
ba.consume(v);
|
||||
expect(to_string(ba.data()) == "");
|
||||
BEAST_EXPECT(to_string(ba.data()) == "");
|
||||
ba.consume(1);
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
expect(buffer_size(d) == 0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
try
|
||||
{
|
||||
@@ -158,9 +158,9 @@ public:
|
||||
sb_type sb;
|
||||
buffers_adapter<
|
||||
sb_type::mutable_buffers_type> ba(sb.prepare(3));
|
||||
expect(buffer_size(ba.prepare(3)) == 3);
|
||||
BEAST_EXPECT(buffer_size(ba.prepare(3)) == 3);
|
||||
ba.commit(2);
|
||||
expect(buffer_size(ba.data()) == 2);
|
||||
BEAST_EXPECT(buffer_size(ba.data()) == 2);
|
||||
}
|
||||
{
|
||||
using sb_type = beast::streambuf;
|
||||
@@ -168,13 +168,13 @@ public:
|
||||
sb.prepare(3);
|
||||
buffers_adapter<
|
||||
sb_type::mutable_buffers_type> ba(sb.prepare(8));
|
||||
expect(buffer_size(ba.prepare(8)) == 8);
|
||||
BEAST_EXPECT(buffer_size(ba.prepare(8)) == 8);
|
||||
ba.commit(2);
|
||||
expect(buffer_size(ba.data()) == 2);
|
||||
BEAST_EXPECT(buffer_size(ba.data()) == 2);
|
||||
ba.consume(1);
|
||||
ba.commit(6);
|
||||
ba.consume(2);
|
||||
expect(buffer_size(ba.data()) == 5);
|
||||
BEAST_EXPECT(buffer_size(ba.data()) == 5);
|
||||
ba.consume(5);
|
||||
}
|
||||
}
|
||||
|
@@ -31,10 +31,10 @@ public:
|
||||
void
|
||||
expect_size(std::size_t n, ConstBufferSequence const& buffers)
|
||||
{
|
||||
expect(test::size_pre(buffers) == n);
|
||||
expect(test::size_post(buffers) == n);
|
||||
expect(test::size_rev_pre(buffers) == n);
|
||||
expect(test::size_rev_post(buffers) == n);
|
||||
BEAST_EXPECT(test::size_pre(buffers) == n);
|
||||
BEAST_EXPECT(test::size_post(buffers) == n);
|
||||
BEAST_EXPECT(test::size_rev_pre(buffers) == n);
|
||||
BEAST_EXPECT(test::size_rev_post(buffers) == n);
|
||||
}
|
||||
|
||||
void testMatrix()
|
||||
@@ -43,9 +43,9 @@ public:
|
||||
using boost::asio::const_buffer;
|
||||
char buf[12];
|
||||
std::string const s = "Hello, world";
|
||||
expect(s.size() == sizeof(buf));
|
||||
BEAST_EXPECT(s.size() == sizeof(buf));
|
||||
buffer_copy(buffer(buf), buffer(s));
|
||||
expect(to_string(buffer(buf)) == s);
|
||||
BEAST_EXPECT(to_string(buffer(buf)) == s);
|
||||
for(std::size_t i = 1; i < 4; ++i) {
|
||||
for(std::size_t j = 1; j < 4; ++j) {
|
||||
for(std::size_t x = 1; x < 4; ++x) {
|
||||
@@ -58,24 +58,24 @@ public:
|
||||
const_buffer{&buf[i], j},
|
||||
const_buffer{&buf[i+j], k}}};
|
||||
consuming_buffers<decltype(bs)> cb(bs);
|
||||
expect(to_string(cb) == s);
|
||||
BEAST_EXPECT(to_string(cb) == s);
|
||||
expect_size(s.size(), cb);
|
||||
cb.consume(0);
|
||||
expect(eq(cb, consumed_buffers(bs, 0)));
|
||||
expect(to_string(cb) == s);
|
||||
BEAST_EXPECT(eq(cb, consumed_buffers(bs, 0)));
|
||||
BEAST_EXPECT(to_string(cb) == s);
|
||||
expect_size(s.size(), cb);
|
||||
cb.consume(x);
|
||||
expect(to_string(cb) == s.substr(x));
|
||||
expect(eq(cb, consumed_buffers(bs, x)));
|
||||
BEAST_EXPECT(to_string(cb) == s.substr(x));
|
||||
BEAST_EXPECT(eq(cb, consumed_buffers(bs, x)));
|
||||
cb.consume(y);
|
||||
expect(to_string(cb) == s.substr(x+y));
|
||||
expect(eq(cb, consumed_buffers(bs, x+y)));
|
||||
BEAST_EXPECT(to_string(cb) == s.substr(x+y));
|
||||
BEAST_EXPECT(eq(cb, consumed_buffers(bs, x+y)));
|
||||
cb.consume(z);
|
||||
expect(to_string(cb) == "");
|
||||
expect(eq(cb, consumed_buffers(bs, x+y+z)));
|
||||
BEAST_EXPECT(to_string(cb) == "");
|
||||
BEAST_EXPECT(eq(cb, consumed_buffers(bs, x+y+z)));
|
||||
cb.consume(1);
|
||||
expect(to_string(cb) == "");
|
||||
expect(eq(cb, consumed_buffers(bs, x+y+z)));
|
||||
BEAST_EXPECT(to_string(cb) == "");
|
||||
BEAST_EXPECT(eq(cb, consumed_buffers(bs, x+y+z)));
|
||||
}
|
||||
}}}}
|
||||
}
|
||||
@@ -87,10 +87,10 @@ public:
|
||||
using boost::asio::null_buffers;
|
||||
consuming_buffers<null_buffers> cb(
|
||||
null_buffers{});
|
||||
expect(buffer_size(cb) == 0);
|
||||
BEAST_EXPECT(buffer_size(cb) == 0);
|
||||
consuming_buffers<null_buffers> cb2(
|
||||
null_buffers{});
|
||||
expect(buffer_copy(cb2, cb) == 0);
|
||||
BEAST_EXPECT(buffer_copy(cb2, cb) == 0);
|
||||
}
|
||||
|
||||
void testIterator()
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
std::size_t n = 0;
|
||||
for(auto it = cb.end(); it != cb.begin(); --it)
|
||||
++n;
|
||||
expect(n == 3);
|
||||
BEAST_EXPECT(n == 3);
|
||||
}
|
||||
|
||||
void run() override
|
||||
|
@@ -20,8 +20,8 @@ public:
|
||||
check (std::string const& in, std::string const& out)
|
||||
{
|
||||
auto const encoded = base64_encode (in);
|
||||
expect (encoded == out);
|
||||
expect (base64_decode (encoded) == in);
|
||||
BEAST_EXPECT(encoded == out);
|
||||
BEAST_EXPECT(base64_decode (encoded) == in);
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -82,9 +82,9 @@ public:
|
||||
void
|
||||
run ()
|
||||
{
|
||||
expect (test_one());
|
||||
expect (test_two());
|
||||
pass ();
|
||||
BEAST_EXPECT(test_one());
|
||||
BEAST_EXPECT(test_two());
|
||||
pass();
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -54,7 +54,7 @@ public:
|
||||
init(ctx);
|
||||
update(ctx, message.data(), message.size());
|
||||
finish(ctx, &result[0]);
|
||||
expect(result == digest);
|
||||
BEAST_EXPECT(result == digest);
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -32,8 +32,8 @@ public:
|
||||
dynabuf_readstream<socket_type, streambuf> srs(ios);
|
||||
dynabuf_readstream<socket_type, streambuf> srs2(std::move(srs));
|
||||
srs = std::move(srs2);
|
||||
expect(&srs.get_io_service() == &ios);
|
||||
expect(&srs.get_io_service() == &srs2.get_io_service());
|
||||
BEAST_EXPECT(&srs.get_io_service() == &ios);
|
||||
BEAST_EXPECT(&srs.get_io_service() == &srs2.get_io_service());
|
||||
}
|
||||
{
|
||||
socket_type sock(ios);
|
||||
@@ -63,11 +63,11 @@ public:
|
||||
boost::asio::read(srs, buffer(&s[0], s.size()), ec);
|
||||
if(! ec)
|
||||
{
|
||||
expect(s == "Hello, world!");
|
||||
BEAST_EXPECT(s == "Hello, world!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
expect(n < limit);
|
||||
BEAST_EXPECT(n < limit);
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
@@ -82,11 +82,11 @@ public:
|
||||
boost::asio::read(srs, buffer(&s[0], s.size()), ec);
|
||||
if(! ec)
|
||||
{
|
||||
expect(s == "Hello, world!");
|
||||
BEAST_EXPECT(s == "Hello, world!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
expect(n < limit);
|
||||
BEAST_EXPECT(n < limit);
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
@@ -101,11 +101,11 @@ public:
|
||||
srs, buffer(&s[0], s.size()), do_yield[ec]);
|
||||
if(! ec)
|
||||
{
|
||||
expect(s == "Hello, world!");
|
||||
BEAST_EXPECT(s == "Hello, world!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
expect(n < limit);
|
||||
BEAST_EXPECT(n < limit);
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
@@ -121,11 +121,11 @@ public:
|
||||
srs, buffer(&s[0], s.size()), do_yield[ec]);
|
||||
if(! ec)
|
||||
{
|
||||
expect(s == "Hello, world!");
|
||||
BEAST_EXPECT(s == "Hello, world!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
expect(n < limit);
|
||||
BEAST_EXPECT(n < limit);
|
||||
}
|
||||
|
||||
void run() override
|
||||
|
@@ -18,7 +18,7 @@ class to_string_test : public beast::unit_test::suite
|
||||
public:
|
||||
void run()
|
||||
{
|
||||
expect(to_string(boost::asio::const_buffers_1("x", 1)) == "x");
|
||||
BEAST_EXPECT(to_string(boost::asio::const_buffers_1("x", 1)) == "x");
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -38,7 +38,7 @@ public:
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
std::string s = "Hello, world";
|
||||
expect(s.size() == 12);
|
||||
BEAST_EXPECT(s.size() == 12);
|
||||
for(std::size_t x = 1; x < 4; ++x) {
|
||||
for(std::size_t y = 1; y < 4; ++y) {
|
||||
std::size_t z = s.size() - (x + y);
|
||||
@@ -50,14 +50,14 @@ public:
|
||||
for(std::size_t i = 0; i <= s.size() + 1; ++i)
|
||||
{
|
||||
auto pb = prepare_buffers(i, bs);
|
||||
expect(to_string(pb) == s.substr(0, i));
|
||||
BEAST_EXPECT(to_string(pb) == s.substr(0, i));
|
||||
auto pb2 = pb;
|
||||
expect(to_string(pb2) == to_string(pb));
|
||||
BEAST_EXPECT(to_string(pb2) == to_string(pb));
|
||||
pb = prepare_buffers(0, bs);
|
||||
pb2 = pb;
|
||||
expect(buffer_size(pb2) == 0);
|
||||
BEAST_EXPECT(buffer_size(pb2) == 0);
|
||||
pb2 = prepare_buffers(i, bs);
|
||||
expect(to_string(pb2) == s.substr(0, i));
|
||||
BEAST_EXPECT(to_string(pb2) == s.substr(0, i));
|
||||
}
|
||||
}
|
||||
}}
|
||||
@@ -69,22 +69,22 @@ public:
|
||||
using boost::asio::buffer_size;
|
||||
using boost::asio::null_buffers;
|
||||
auto pb0 = prepare_buffers(0, null_buffers{});
|
||||
expect(buffer_size(pb0) == 0);
|
||||
BEAST_EXPECT(buffer_size(pb0) == 0);
|
||||
auto pb1 = prepare_buffers(1, null_buffers{});
|
||||
expect(buffer_size(pb1) == 0);
|
||||
expect(buffer_copy(pb0, pb1) == 0);
|
||||
BEAST_EXPECT(buffer_size(pb1) == 0);
|
||||
BEAST_EXPECT(buffer_copy(pb0, pb1) == 0);
|
||||
|
||||
using pb_type = decltype(pb0);
|
||||
consuming_buffers<pb_type> cb(pb0);
|
||||
expect(buffer_size(cb) == 0);
|
||||
expect(buffer_copy(cb, pb1) == 0);
|
||||
BEAST_EXPECT(buffer_size(cb) == 0);
|
||||
BEAST_EXPECT(buffer_copy(cb, pb1) == 0);
|
||||
cb.consume(1);
|
||||
expect(buffer_size(cb) == 0);
|
||||
expect(buffer_copy(cb, pb1) == 0);
|
||||
BEAST_EXPECT(buffer_size(cb) == 0);
|
||||
BEAST_EXPECT(buffer_copy(cb, pb1) == 0);
|
||||
|
||||
auto pbc = prepare_buffers(2, cb);
|
||||
expect(buffer_size(pbc) == 0);
|
||||
expect(buffer_copy(pbc, cb) == 0);
|
||||
BEAST_EXPECT(buffer_size(pbc) == 0);
|
||||
BEAST_EXPECT(buffer_copy(pbc, cb) == 0);
|
||||
}
|
||||
|
||||
void testIterator()
|
||||
@@ -101,11 +101,11 @@ public:
|
||||
for(auto it = pb.end(); it != pb.begin(); --it)
|
||||
{
|
||||
decltype(pb)::const_iterator it2(std::move(it));
|
||||
expect(buffer_size(*it2) == 1);
|
||||
BEAST_EXPECT(buffer_size(*it2) == 1);
|
||||
it = std::move(it2);
|
||||
++n;
|
||||
}
|
||||
expect(n == 2);
|
||||
BEAST_EXPECT(n == 2);
|
||||
}
|
||||
|
||||
void run() override
|
||||
|
@@ -39,7 +39,7 @@ public:
|
||||
using boost::asio::buffer_size;
|
||||
char buf[12];
|
||||
std::string const s = "Hello, world";
|
||||
expect(s.size() == sizeof(buf));
|
||||
BEAST_EXPECT(s.size() == sizeof(buf));
|
||||
for(std::size_t i = 1; i < 4; ++i) {
|
||||
for(std::size_t j = 1; j < 4; ++j) {
|
||||
for(std::size_t x = 1; x < 4; ++x) {
|
||||
@@ -53,78 +53,78 @@ public:
|
||||
static_streambuf_n<sizeof(buf)> ba;
|
||||
{
|
||||
auto d = ba.prepare(z);
|
||||
expect(buffer_size(d) == z);
|
||||
BEAST_EXPECT(buffer_size(d) == z);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
expect(buffer_size(d) == 0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(y);
|
||||
expect(buffer_size(d) == y);
|
||||
BEAST_EXPECT(buffer_size(d) == y);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(x);
|
||||
expect(buffer_size(d) == x);
|
||||
BEAST_EXPECT(buffer_size(d) == x);
|
||||
ba.commit(buffer_copy(d, buffer(s.data(), x)));
|
||||
}
|
||||
expect(ba.size() == x);
|
||||
expect(buffer_size(ba.data()) == ba.size());
|
||||
BEAST_EXPECT(ba.size() == x);
|
||||
BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
{
|
||||
auto d = ba.prepare(x);
|
||||
expect(buffer_size(d) == x);
|
||||
BEAST_EXPECT(buffer_size(d) == x);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
expect(buffer_size(d) == 0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(z);
|
||||
expect(buffer_size(d) == z);
|
||||
BEAST_EXPECT(buffer_size(d) == z);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(y);
|
||||
expect(buffer_size(d) == y);
|
||||
BEAST_EXPECT(buffer_size(d) == y);
|
||||
ba.commit(buffer_copy(d, buffer(s.data()+x, y)));
|
||||
}
|
||||
ba.commit(1);
|
||||
expect(ba.size() == x + y);
|
||||
expect(buffer_size(ba.data()) == ba.size());
|
||||
BEAST_EXPECT(ba.size() == x + y);
|
||||
BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
{
|
||||
auto d = ba.prepare(x);
|
||||
expect(buffer_size(d) == x);
|
||||
BEAST_EXPECT(buffer_size(d) == x);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(y);
|
||||
expect(buffer_size(d) == y);
|
||||
BEAST_EXPECT(buffer_size(d) == y);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
expect(buffer_size(d) == 0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(z);
|
||||
expect(buffer_size(d) == z);
|
||||
BEAST_EXPECT(buffer_size(d) == z);
|
||||
ba.commit(buffer_copy(d, buffer(s.data()+x+y, z)));
|
||||
}
|
||||
ba.commit(2);
|
||||
expect(ba.size() == x + y + z);
|
||||
expect(buffer_size(ba.data()) == ba.size());
|
||||
expect(to_string(ba.data()) == s);
|
||||
BEAST_EXPECT(ba.size() == x + y + z);
|
||||
BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
BEAST_EXPECT(to_string(ba.data()) == s);
|
||||
ba.consume(t);
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
expect(buffer_size(d) == 0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
expect(to_string(ba.data()) == s.substr(t, std::string::npos));
|
||||
BEAST_EXPECT(to_string(ba.data()) == s.substr(t, std::string::npos));
|
||||
ba.consume(u);
|
||||
expect(to_string(ba.data()) == s.substr(t + u, std::string::npos));
|
||||
BEAST_EXPECT(to_string(ba.data()) == s.substr(t + u, std::string::npos));
|
||||
ba.consume(v);
|
||||
expect(to_string(ba.data()) == "");
|
||||
BEAST_EXPECT(to_string(ba.data()) == "");
|
||||
ba.consume(1);
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
expect(buffer_size(d) == 0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
try
|
||||
{
|
||||
@@ -149,25 +149,25 @@ public:
|
||||
for(auto it = mb.begin();
|
||||
it != mb.end(); it++)
|
||||
++n;
|
||||
expect(n == 1);
|
||||
BEAST_EXPECT(n == 1);
|
||||
mb = ba.prepare(2);
|
||||
n = 0;
|
||||
for(auto it = mb.begin();
|
||||
it != mb.end(); ++it)
|
||||
++n;
|
||||
expect(n == 1);
|
||||
BEAST_EXPECT(n == 1);
|
||||
mb = ba.prepare(2);
|
||||
n = 0;
|
||||
for(auto it = mb.end();
|
||||
it != mb.begin(); it--)
|
||||
++n;
|
||||
expect(n == 1);
|
||||
BEAST_EXPECT(n == 1);
|
||||
mb = ba.prepare(2);
|
||||
n = 0;
|
||||
for(auto it = mb.end();
|
||||
it != mb.begin(); --it)
|
||||
++n;
|
||||
expect(n == 1);
|
||||
BEAST_EXPECT(n == 1);
|
||||
}
|
||||
ba.prepare(2);
|
||||
ba.commit(1);
|
||||
@@ -176,22 +176,22 @@ public:
|
||||
for(auto it = ba.data().begin();
|
||||
it != ba.data().end(); it++)
|
||||
++n;
|
||||
expect(n == 1);
|
||||
BEAST_EXPECT(n == 1);
|
||||
n = 0;
|
||||
for(auto it = ba.data().begin();
|
||||
it != ba.data().end(); ++it)
|
||||
++n;
|
||||
expect(n == 1);
|
||||
BEAST_EXPECT(n == 1);
|
||||
n = 0;
|
||||
for(auto it = ba.data().end();
|
||||
it != ba.data().begin(); it--)
|
||||
++n;
|
||||
expect(n == 1);
|
||||
BEAST_EXPECT(n == 1);
|
||||
n = 0;
|
||||
for(auto it = ba.data().end();
|
||||
it != ba.data().begin(); --it)
|
||||
++n;
|
||||
expect(n == 1);
|
||||
BEAST_EXPECT(n == 1);
|
||||
}
|
||||
|
||||
void run() override
|
||||
|
@@ -21,107 +21,107 @@ public:
|
||||
using str2 = static_string<2>;
|
||||
{
|
||||
str1 s1;
|
||||
expect(s1 == "");
|
||||
expect(s1.empty());
|
||||
expect(s1.size() == 0);
|
||||
expect(s1.max_size() == 1);
|
||||
expect(s1.capacity() == 1);
|
||||
expect(s1.begin() == s1.end());
|
||||
expect(s1.cbegin() == s1.cend());
|
||||
expect(s1.rbegin() == s1.rend());
|
||||
expect(s1.crbegin() == s1.crend());
|
||||
BEAST_EXPECT(s1 == "");
|
||||
BEAST_EXPECT(s1.empty());
|
||||
BEAST_EXPECT(s1.size() == 0);
|
||||
BEAST_EXPECT(s1.max_size() == 1);
|
||||
BEAST_EXPECT(s1.capacity() == 1);
|
||||
BEAST_EXPECT(s1.begin() == s1.end());
|
||||
BEAST_EXPECT(s1.cbegin() == s1.cend());
|
||||
BEAST_EXPECT(s1.rbegin() == s1.rend());
|
||||
BEAST_EXPECT(s1.crbegin() == s1.crend());
|
||||
try
|
||||
{
|
||||
expect(s1.at(0) == 0);
|
||||
BEAST_EXPECT(s1.at(0) == 0);
|
||||
fail();
|
||||
}
|
||||
catch(std::exception const&)
|
||||
{
|
||||
pass();
|
||||
}
|
||||
expect(s1.data()[0] == 0);
|
||||
expect(*s1.c_str() == 0);
|
||||
expect(std::distance(s1.begin(), s1.end()) == 0);
|
||||
expect(std::distance(s1.cbegin(), s1.cend()) == 0);
|
||||
expect(std::distance(s1.rbegin(), s1.rend()) == 0);
|
||||
expect(std::distance(s1.crbegin(), s1.crend()) == 0);
|
||||
expect(s1.compare(s1) == 0);
|
||||
expect(s1.to_string() == std::string{});
|
||||
BEAST_EXPECT(s1.data()[0] == 0);
|
||||
BEAST_EXPECT(*s1.c_str() == 0);
|
||||
BEAST_EXPECT(std::distance(s1.begin(), s1.end()) == 0);
|
||||
BEAST_EXPECT(std::distance(s1.cbegin(), s1.cend()) == 0);
|
||||
BEAST_EXPECT(std::distance(s1.rbegin(), s1.rend()) == 0);
|
||||
BEAST_EXPECT(std::distance(s1.crbegin(), s1.crend()) == 0);
|
||||
BEAST_EXPECT(s1.compare(s1) == 0);
|
||||
BEAST_EXPECT(s1.to_string() == std::string{});
|
||||
}
|
||||
{
|
||||
str1 const s1;
|
||||
expect(s1 == "");
|
||||
expect(s1.empty());
|
||||
expect(s1.size() == 0);
|
||||
expect(s1.max_size() == 1);
|
||||
expect(s1.capacity() == 1);
|
||||
expect(s1.begin() == s1.end());
|
||||
expect(s1.cbegin() == s1.cend());
|
||||
expect(s1.rbegin() == s1.rend());
|
||||
expect(s1.crbegin() == s1.crend());
|
||||
BEAST_EXPECT(s1 == "");
|
||||
BEAST_EXPECT(s1.empty());
|
||||
BEAST_EXPECT(s1.size() == 0);
|
||||
BEAST_EXPECT(s1.max_size() == 1);
|
||||
BEAST_EXPECT(s1.capacity() == 1);
|
||||
BEAST_EXPECT(s1.begin() == s1.end());
|
||||
BEAST_EXPECT(s1.cbegin() == s1.cend());
|
||||
BEAST_EXPECT(s1.rbegin() == s1.rend());
|
||||
BEAST_EXPECT(s1.crbegin() == s1.crend());
|
||||
try
|
||||
{
|
||||
expect(s1.at(0) == 0);
|
||||
BEAST_EXPECT(s1.at(0) == 0);
|
||||
fail();
|
||||
}
|
||||
catch(std::exception const&)
|
||||
{
|
||||
pass();
|
||||
}
|
||||
expect(s1.data()[0] == 0);
|
||||
expect(*s1.c_str() == 0);
|
||||
expect(std::distance(s1.begin(), s1.end()) == 0);
|
||||
expect(std::distance(s1.cbegin(), s1.cend()) == 0);
|
||||
expect(std::distance(s1.rbegin(), s1.rend()) == 0);
|
||||
expect(std::distance(s1.crbegin(), s1.crend()) == 0);
|
||||
expect(s1.compare(s1) == 0);
|
||||
expect(s1.to_string() == std::string{});
|
||||
BEAST_EXPECT(s1.data()[0] == 0);
|
||||
BEAST_EXPECT(*s1.c_str() == 0);
|
||||
BEAST_EXPECT(std::distance(s1.begin(), s1.end()) == 0);
|
||||
BEAST_EXPECT(std::distance(s1.cbegin(), s1.cend()) == 0);
|
||||
BEAST_EXPECT(std::distance(s1.rbegin(), s1.rend()) == 0);
|
||||
BEAST_EXPECT(std::distance(s1.crbegin(), s1.crend()) == 0);
|
||||
BEAST_EXPECT(s1.compare(s1) == 0);
|
||||
BEAST_EXPECT(s1.to_string() == std::string{});
|
||||
}
|
||||
{
|
||||
str1 s1;
|
||||
str1 s2("x");
|
||||
expect(s2 == "x");
|
||||
expect(s2[0] == 'x');
|
||||
expect(s2.at(0) == 'x');
|
||||
expect(s2.front() == 'x');
|
||||
expect(s2.back() == 'x');
|
||||
BEAST_EXPECT(s2 == "x");
|
||||
BEAST_EXPECT(s2[0] == 'x');
|
||||
BEAST_EXPECT(s2.at(0) == 'x');
|
||||
BEAST_EXPECT(s2.front() == 'x');
|
||||
BEAST_EXPECT(s2.back() == 'x');
|
||||
str1 const s3(s2);
|
||||
expect(s3 == "x");
|
||||
expect(s3[0] == 'x');
|
||||
expect(s3.at(0) == 'x');
|
||||
expect(s3.front() == 'x');
|
||||
expect(s3.back() == 'x');
|
||||
BEAST_EXPECT(s3 == "x");
|
||||
BEAST_EXPECT(s3[0] == 'x');
|
||||
BEAST_EXPECT(s3.at(0) == 'x');
|
||||
BEAST_EXPECT(s3.front() == 'x');
|
||||
BEAST_EXPECT(s3.back() == 'x');
|
||||
s2 = "y";
|
||||
expect(s2 == "y");
|
||||
expect(s3 == "x");
|
||||
BEAST_EXPECT(s2 == "y");
|
||||
BEAST_EXPECT(s3 == "x");
|
||||
s1 = s2;
|
||||
expect(s1 == "y");
|
||||
BEAST_EXPECT(s1 == "y");
|
||||
s1.clear();
|
||||
expect(s1.empty());
|
||||
expect(s1.size() == 0);
|
||||
BEAST_EXPECT(s1.empty());
|
||||
BEAST_EXPECT(s1.size() == 0);
|
||||
}
|
||||
{
|
||||
str2 s1("x");
|
||||
str1 s2(s1);
|
||||
expect(s2 == "x");
|
||||
BEAST_EXPECT(s2 == "x");
|
||||
str1 s3;
|
||||
s3 = s2;
|
||||
expect(s3 == "x");
|
||||
BEAST_EXPECT(s3 == "x");
|
||||
s1 = "xy";
|
||||
expect(s1.size() == 2);
|
||||
expect(s1[0] == 'x');
|
||||
expect(s1[1] == 'y');
|
||||
expect(s1.at(0) == 'x');
|
||||
expect(s1.at(1) == 'y');
|
||||
expect(s1.front() == 'x');
|
||||
expect(s1.back() == 'y');
|
||||
BEAST_EXPECT(s1.size() == 2);
|
||||
BEAST_EXPECT(s1[0] == 'x');
|
||||
BEAST_EXPECT(s1[1] == 'y');
|
||||
BEAST_EXPECT(s1.at(0) == 'x');
|
||||
BEAST_EXPECT(s1.at(1) == 'y');
|
||||
BEAST_EXPECT(s1.front() == 'x');
|
||||
BEAST_EXPECT(s1.back() == 'y');
|
||||
auto const s4 = s1;
|
||||
expect(s4[0] == 'x');
|
||||
expect(s4[1] == 'y');
|
||||
expect(s4.at(0) == 'x');
|
||||
expect(s4.at(1) == 'y');
|
||||
expect(s4.front() == 'x');
|
||||
expect(s4.back() == 'y');
|
||||
BEAST_EXPECT(s4[0] == 'x');
|
||||
BEAST_EXPECT(s4[1] == 'y');
|
||||
BEAST_EXPECT(s4.at(0) == 'x');
|
||||
BEAST_EXPECT(s4.at(1) == 'y');
|
||||
BEAST_EXPECT(s4.front() == 'x');
|
||||
BEAST_EXPECT(s4.back() == 'y');
|
||||
try
|
||||
{
|
||||
s3 = s1;
|
||||
@@ -167,87 +167,87 @@ public:
|
||||
str2 s2;
|
||||
s1 = "1";
|
||||
s2 = "22";
|
||||
expect(s1.compare(s2) < 0);
|
||||
expect(s2.compare(s1) > 0);
|
||||
expect(s1 < "10");
|
||||
expect(s2 > "1");
|
||||
expect("10" > s1);
|
||||
expect("1" < s2);
|
||||
expect(s1 < "20");
|
||||
expect(s2 > "1");
|
||||
expect(s2 > "2");
|
||||
BEAST_EXPECT(s1.compare(s2) < 0);
|
||||
BEAST_EXPECT(s2.compare(s1) > 0);
|
||||
BEAST_EXPECT(s1 < "10");
|
||||
BEAST_EXPECT(s2 > "1");
|
||||
BEAST_EXPECT("10" > s1);
|
||||
BEAST_EXPECT("1" < s2);
|
||||
BEAST_EXPECT(s1 < "20");
|
||||
BEAST_EXPECT(s2 > "1");
|
||||
BEAST_EXPECT(s2 > "2");
|
||||
}
|
||||
{
|
||||
str2 s1("x");
|
||||
str2 s2("x");
|
||||
expect(s1 == s2);
|
||||
expect(s1 <= s2);
|
||||
expect(s1 >= s2);
|
||||
expect(! (s1 < s2));
|
||||
expect(! (s1 > s2));
|
||||
expect(! (s1 != s2));
|
||||
BEAST_EXPECT(s1 == s2);
|
||||
BEAST_EXPECT(s1 <= s2);
|
||||
BEAST_EXPECT(s1 >= s2);
|
||||
BEAST_EXPECT(! (s1 < s2));
|
||||
BEAST_EXPECT(! (s1 > s2));
|
||||
BEAST_EXPECT(! (s1 != s2));
|
||||
}
|
||||
{
|
||||
str1 s1("x");
|
||||
str2 s2("x");
|
||||
expect(s1 == s2);
|
||||
expect(s1 <= s2);
|
||||
expect(s1 >= s2);
|
||||
expect(! (s1 < s2));
|
||||
expect(! (s1 > s2));
|
||||
expect(! (s1 != s2));
|
||||
BEAST_EXPECT(s1 == s2);
|
||||
BEAST_EXPECT(s1 <= s2);
|
||||
BEAST_EXPECT(s1 >= s2);
|
||||
BEAST_EXPECT(! (s1 < s2));
|
||||
BEAST_EXPECT(! (s1 > s2));
|
||||
BEAST_EXPECT(! (s1 != s2));
|
||||
}
|
||||
{
|
||||
str2 s("x");
|
||||
expect(s == "x");
|
||||
expect(s <= "x");
|
||||
expect(s >= "x");
|
||||
expect(! (s < "x"));
|
||||
expect(! (s > "x"));
|
||||
expect(! (s != "x"));
|
||||
expect("x" == s);
|
||||
expect("x" <= s);
|
||||
expect("x" >= s);
|
||||
expect(! ("x" < s));
|
||||
expect(! ("x" > s));
|
||||
expect(! ("x" != s));
|
||||
BEAST_EXPECT(s == "x");
|
||||
BEAST_EXPECT(s <= "x");
|
||||
BEAST_EXPECT(s >= "x");
|
||||
BEAST_EXPECT(! (s < "x"));
|
||||
BEAST_EXPECT(! (s > "x"));
|
||||
BEAST_EXPECT(! (s != "x"));
|
||||
BEAST_EXPECT("x" == s);
|
||||
BEAST_EXPECT("x" <= s);
|
||||
BEAST_EXPECT("x" >= s);
|
||||
BEAST_EXPECT(! ("x" < s));
|
||||
BEAST_EXPECT(! ("x" > s));
|
||||
BEAST_EXPECT(! ("x" != s));
|
||||
}
|
||||
{
|
||||
str2 s("x");
|
||||
expect(s <= "y");
|
||||
expect(s < "y");
|
||||
expect(s != "y");
|
||||
expect(! (s == "y"));
|
||||
expect(! (s >= "y"));
|
||||
expect(! (s > "x"));
|
||||
expect("y" >= s);
|
||||
expect("y" > s);
|
||||
expect("y" != s);
|
||||
expect(! ("y" == s));
|
||||
expect(! ("y" <= s));
|
||||
expect(! ("y" < s));
|
||||
BEAST_EXPECT(s <= "y");
|
||||
BEAST_EXPECT(s < "y");
|
||||
BEAST_EXPECT(s != "y");
|
||||
BEAST_EXPECT(! (s == "y"));
|
||||
BEAST_EXPECT(! (s >= "y"));
|
||||
BEAST_EXPECT(! (s > "x"));
|
||||
BEAST_EXPECT("y" >= s);
|
||||
BEAST_EXPECT("y" > s);
|
||||
BEAST_EXPECT("y" != s);
|
||||
BEAST_EXPECT(! ("y" == s));
|
||||
BEAST_EXPECT(! ("y" <= s));
|
||||
BEAST_EXPECT(! ("y" < s));
|
||||
}
|
||||
{
|
||||
str1 s1("x");
|
||||
str2 s2("y");
|
||||
expect(s1 <= s2);
|
||||
expect(s1 < s2);
|
||||
expect(s1 != s2);
|
||||
expect(! (s1 == s2));
|
||||
expect(! (s1 >= s2));
|
||||
expect(! (s1 > s2));
|
||||
BEAST_EXPECT(s1 <= s2);
|
||||
BEAST_EXPECT(s1 < s2);
|
||||
BEAST_EXPECT(s1 != s2);
|
||||
BEAST_EXPECT(! (s1 == s2));
|
||||
BEAST_EXPECT(! (s1 >= s2));
|
||||
BEAST_EXPECT(! (s1 > s2));
|
||||
}
|
||||
{
|
||||
str1 s1("x");
|
||||
str2 s2("xx");
|
||||
expect(s1 < s2);
|
||||
expect(s2 > s1);
|
||||
BEAST_EXPECT(s1 < s2);
|
||||
BEAST_EXPECT(s2 > s1);
|
||||
}
|
||||
{
|
||||
str1 s1("x");
|
||||
str2 s2("yy");
|
||||
expect(s1 < s2);
|
||||
expect(s2 > s1);
|
||||
BEAST_EXPECT(s1 < s2);
|
||||
BEAST_EXPECT(s2 > s1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -41,23 +41,23 @@ public:
|
||||
void testHeaders()
|
||||
{
|
||||
bh h1;
|
||||
expect(h1.empty());
|
||||
BEAST_EXPECT(h1.empty());
|
||||
fill(1, h1);
|
||||
expect(h1.size() == 1);
|
||||
BEAST_EXPECT(h1.size() == 1);
|
||||
bh h2;
|
||||
h2 = h1;
|
||||
expect(h2.size() == 1);
|
||||
BEAST_EXPECT(h2.size() == 1);
|
||||
h2.insert("2", "2");
|
||||
expect(std::distance(h2.begin(), h2.end()) == 2);
|
||||
BEAST_EXPECT(std::distance(h2.begin(), h2.end()) == 2);
|
||||
h1 = std::move(h2);
|
||||
expect(h1.size() == 2);
|
||||
expect(h2.size() == 0);
|
||||
BEAST_EXPECT(h1.size() == 2);
|
||||
BEAST_EXPECT(h2.size() == 0);
|
||||
bh h3(std::move(h1));
|
||||
expect(h3.size() == 2);
|
||||
expect(h1.size() == 0);
|
||||
BEAST_EXPECT(h3.size() == 2);
|
||||
BEAST_EXPECT(h1.size() == 0);
|
||||
self_assign(h3, std::move(h3));
|
||||
expect(h3.size() == 2);
|
||||
expect(h2.erase("Not-Present") == 0);
|
||||
BEAST_EXPECT(h3.size() == 2);
|
||||
BEAST_EXPECT(h2.erase("Not-Present") == 0);
|
||||
}
|
||||
|
||||
void testRFC2616()
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
h.insert("a", "x");
|
||||
h.insert("aa", "y");
|
||||
h.insert("b", "z");
|
||||
expect(h.count("a") == 2);
|
||||
BEAST_EXPECT(h.count("a") == 2);
|
||||
}
|
||||
|
||||
void testErase()
|
||||
@@ -77,9 +77,9 @@ public:
|
||||
h.insert("a", "x");
|
||||
h.insert("aa", "y");
|
||||
h.insert("b", "z");
|
||||
expect(h.size() == 4);
|
||||
BEAST_EXPECT(h.size() == 4);
|
||||
h.erase("a");
|
||||
expect(h.size() == 2);
|
||||
BEAST_EXPECT(h.size() == 2);
|
||||
}
|
||||
|
||||
void run() override
|
||||
|
@@ -120,17 +120,17 @@ public:
|
||||
"\r\n"
|
||||
"*";
|
||||
p.write(buffer(s), ec);
|
||||
if(expect(! ec))
|
||||
if(BEAST_EXPECT(! ec))
|
||||
{
|
||||
expect(p.start);
|
||||
expect(p.method);
|
||||
expect(p.uri);
|
||||
expect(p.request);
|
||||
expect(p.field);
|
||||
expect(p.value);
|
||||
expect(p.headers);
|
||||
expect(p.body);
|
||||
expect(p.complete);
|
||||
BEAST_EXPECT(p.start);
|
||||
BEAST_EXPECT(p.method);
|
||||
BEAST_EXPECT(p.uri);
|
||||
BEAST_EXPECT(p.request);
|
||||
BEAST_EXPECT(p.field);
|
||||
BEAST_EXPECT(p.value);
|
||||
BEAST_EXPECT(p.headers);
|
||||
BEAST_EXPECT(p.body);
|
||||
BEAST_EXPECT(p.complete);
|
||||
}
|
||||
}
|
||||
{
|
||||
@@ -143,16 +143,16 @@ public:
|
||||
"\r\n"
|
||||
"*";
|
||||
p.write(buffer(s), ec);
|
||||
if(expect(! ec))
|
||||
if(BEAST_EXPECT(! ec))
|
||||
{
|
||||
expect(p.start);
|
||||
expect(p.reason);
|
||||
expect(p.response);
|
||||
expect(p.field);
|
||||
expect(p.value);
|
||||
expect(p.headers);
|
||||
expect(p.body);
|
||||
expect(p.complete);
|
||||
BEAST_EXPECT(p.start);
|
||||
BEAST_EXPECT(p.reason);
|
||||
BEAST_EXPECT(p.response);
|
||||
BEAST_EXPECT(p.field);
|
||||
BEAST_EXPECT(p.value);
|
||||
BEAST_EXPECT(p.headers);
|
||||
BEAST_EXPECT(p.body);
|
||||
BEAST_EXPECT(p.complete);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -211,25 +211,25 @@ public:
|
||||
p.write(buffer(s1.data(), s1.size()), ec);
|
||||
if(ec == test::fail_error)
|
||||
continue;
|
||||
if(! expect(! ec))
|
||||
if(! BEAST_EXPECT(! ec))
|
||||
break;
|
||||
if(! expect(s2.empty() || ! p.complete()))
|
||||
if(! BEAST_EXPECT(s2.empty() || ! p.complete()))
|
||||
break;
|
||||
p.write(buffer(s2.data(), s2.size()), ec);
|
||||
if(ec == test::fail_error)
|
||||
continue;
|
||||
if(! expect(! ec))
|
||||
if(! BEAST_EXPECT(! ec))
|
||||
break;
|
||||
p.write_eof(ec);
|
||||
if(ec == test::fail_error)
|
||||
continue;
|
||||
if(! expect(! ec))
|
||||
if(! BEAST_EXPECT(! ec))
|
||||
break;
|
||||
expect(p.complete());
|
||||
BEAST_EXPECT(p.complete());
|
||||
f(p);
|
||||
break;
|
||||
}
|
||||
expect(n < Limit);
|
||||
BEAST_EXPECT(n < Limit);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -261,10 +261,10 @@ public:
|
||||
continue;
|
||||
if(ec)
|
||||
{
|
||||
expect((ec && ! ev) || ec == ev);
|
||||
BEAST_EXPECT((ec && ! ev) || ec == ev);
|
||||
break;
|
||||
}
|
||||
if(! expect(! p.complete()))
|
||||
if(! BEAST_EXPECT(! p.complete()))
|
||||
break;
|
||||
if(! s2.empty())
|
||||
{
|
||||
@@ -273,20 +273,20 @@ public:
|
||||
continue;
|
||||
if(ec)
|
||||
{
|
||||
expect((ec && ! ev) || ec == ev);
|
||||
BEAST_EXPECT((ec && ! ev) || ec == ev);
|
||||
break;
|
||||
}
|
||||
if(! expect(! p.complete()))
|
||||
if(! BEAST_EXPECT(! p.complete()))
|
||||
break;
|
||||
}
|
||||
p.write_eof(ec);
|
||||
if(ec == test::fail_error)
|
||||
continue;
|
||||
expect(! p.complete());
|
||||
expect((ec && ! ev) || ec == ev);
|
||||
BEAST_EXPECT(! p.complete());
|
||||
BEAST_EXPECT((ec && ! ev) || ec == ev);
|
||||
break;
|
||||
}
|
||||
expect(n < Limit);
|
||||
BEAST_EXPECT(n < Limit);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -317,8 +317,8 @@ public:
|
||||
void
|
||||
operator()(Parser const& p) const
|
||||
{
|
||||
s_.expect(p.http_major() == major_);
|
||||
s_.expect(p.http_minor() == minor_);
|
||||
s_.BEAST_EXPECT(p.http_major() == major_);
|
||||
s_.BEAST_EXPECT(p.http_minor() == minor_);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -337,7 +337,7 @@ public:
|
||||
void
|
||||
operator()(Parser const& p) const
|
||||
{
|
||||
s_.expect(p.status_code() == code_);
|
||||
s_.BEAST_EXPECT(p.status_code() == code_);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -392,7 +392,7 @@ public:
|
||||
buf("GET / "), buf("_TTP/1.1\r\n"),
|
||||
buf("\r\n")
|
||||
), ec);
|
||||
expect(ec == parse_error::bad_version);
|
||||
BEAST_EXPECT(ec == parse_error::bad_version);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,7 +509,7 @@ public:
|
||||
void
|
||||
operator()(Parser const& p) const
|
||||
{
|
||||
s_.expect(p.flags() == value_);
|
||||
s_.BEAST_EXPECT(p.flags() == value_);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -529,7 +529,7 @@ public:
|
||||
void
|
||||
operator()(Parser const& p) const
|
||||
{
|
||||
s_.expect(p.keep_alive() == value_);
|
||||
s_.BEAST_EXPECT(p.keep_alive() == value_);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -661,9 +661,9 @@ public:
|
||||
good<true>(1, s,
|
||||
[&](fail_parser<true> const& p)
|
||||
{
|
||||
expect(p.content_length() == v);
|
||||
BEAST_EXPECT(p.content_length() == v);
|
||||
if(v != no_content_length)
|
||||
expect(p.flags() & parse_flag::contentlength);
|
||||
BEAST_EXPECT(p.flags() & parse_flag::contentlength);
|
||||
});
|
||||
};
|
||||
auto const c =
|
||||
@@ -787,7 +787,7 @@ public:
|
||||
"\r\n",
|
||||
[&](fail_parser<true> const& p)
|
||||
{
|
||||
expect(p.upgrade());
|
||||
BEAST_EXPECT(p.upgrade());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -811,7 +811,7 @@ public:
|
||||
void
|
||||
operator()(Parser const& p) const
|
||||
{
|
||||
s_.expect(p.body == body_);
|
||||
s_.BEAST_EXPECT(p.body == body_);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -855,8 +855,8 @@ public:
|
||||
"Content-Length: 1\r\n"
|
||||
"\r\n"
|
||||
), ec);
|
||||
expect(! ec);
|
||||
expect(p.complete());
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(p.complete());
|
||||
}
|
||||
|
||||
// write the body in 3 pieces
|
||||
@@ -871,15 +871,15 @@ public:
|
||||
buf("12"),
|
||||
buf("345"),
|
||||
buf("67890")), ec);
|
||||
expect(! ec);
|
||||
expect(p.complete());
|
||||
expect(! p.needs_eof());
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(p.complete());
|
||||
BEAST_EXPECT(! p.needs_eof());
|
||||
p.write_eof(ec);
|
||||
expect(! ec);
|
||||
BEAST_EXPECT(! ec);
|
||||
p.write_eof(ec);
|
||||
expect(! ec);
|
||||
BEAST_EXPECT(! ec);
|
||||
p.write(buf("GET / HTTP/1.1\r\n\r\n"), ec);
|
||||
expect(ec == parse_error::connection_closed);
|
||||
BEAST_EXPECT(ec == parse_error::connection_closed);
|
||||
}
|
||||
|
||||
// request without Content-Length or
|
||||
@@ -892,9 +892,9 @@ public:
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"\r\n"
|
||||
), ec);
|
||||
expect(! ec);
|
||||
expect(! p.needs_eof());
|
||||
expect(p.complete());
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(! p.needs_eof());
|
||||
BEAST_EXPECT(p.complete());
|
||||
}
|
||||
{
|
||||
error_code ec;
|
||||
@@ -904,9 +904,9 @@ public:
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"\r\n"
|
||||
), ec);
|
||||
expect(! ec);
|
||||
expect(! p.needs_eof());
|
||||
expect(p.complete());
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(! p.needs_eof());
|
||||
BEAST_EXPECT(p.complete());
|
||||
}
|
||||
|
||||
// response without Content-Length or
|
||||
@@ -919,20 +919,20 @@ public:
|
||||
"HTTP/1.0 200 OK\r\n"
|
||||
"\r\n"
|
||||
), ec);
|
||||
expect(! ec);
|
||||
expect(! p.complete());
|
||||
expect(p.needs_eof());
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(! p.complete());
|
||||
BEAST_EXPECT(p.needs_eof());
|
||||
p.write(buf(
|
||||
"hello"
|
||||
), ec);
|
||||
expect(! ec);
|
||||
expect(! p.complete());
|
||||
expect(p.needs_eof());
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(! p.complete());
|
||||
BEAST_EXPECT(p.needs_eof());
|
||||
p.write_eof(ec);
|
||||
expect(! ec);
|
||||
expect(p.complete());
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(p.complete());
|
||||
p.write(buf("GET / HTTP/1.1\r\n\r\n"), ec);
|
||||
expect(ec == parse_error::connection_closed);
|
||||
BEAST_EXPECT(ec == parse_error::connection_closed);
|
||||
}
|
||||
|
||||
// 304 "Not Modified" response does not require eof
|
||||
@@ -944,9 +944,9 @@ public:
|
||||
"HTTP/1.0 304 Not Modified\r\n"
|
||||
"\r\n"
|
||||
), ec);
|
||||
expect(! ec);
|
||||
expect(! p.needs_eof());
|
||||
expect(p.complete());
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(! p.needs_eof());
|
||||
BEAST_EXPECT(p.complete());
|
||||
}
|
||||
|
||||
// Chunked response does not require eof
|
||||
@@ -959,15 +959,15 @@ public:
|
||||
"Transfer-Encoding: chunked\r\n"
|
||||
"\r\n"
|
||||
), ec);
|
||||
expect(! ec);
|
||||
expect(! p.needs_eof());
|
||||
expect(! p.complete());
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(! p.needs_eof());
|
||||
BEAST_EXPECT(! p.complete());
|
||||
p.write(buf(
|
||||
"0\r\n\r\n"
|
||||
), ec);
|
||||
expect(! ec);
|
||||
expect(! p.needs_eof());
|
||||
expect(p.complete());
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(! p.needs_eof());
|
||||
BEAST_EXPECT(p.complete());
|
||||
}
|
||||
|
||||
// restart: 1.0 assumes Connection: close
|
||||
@@ -979,13 +979,13 @@ public:
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"\r\n"
|
||||
), ec);
|
||||
expect(! ec);
|
||||
expect(p.complete());
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(p.complete());
|
||||
p.write(buf(
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"\r\n"
|
||||
), ec);
|
||||
expect(ec == parse_error::connection_closed);
|
||||
BEAST_EXPECT(ec == parse_error::connection_closed);
|
||||
}
|
||||
|
||||
// restart: 1.1 assumes Connection: keep-alive
|
||||
@@ -997,14 +997,14 @@ public:
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"\r\n"
|
||||
), ec);
|
||||
expect(! ec);
|
||||
expect(p.complete());
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(p.complete());
|
||||
p.write(buf(
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"\r\n"
|
||||
), ec);
|
||||
expect(! ec);
|
||||
expect(p.complete());
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(p.complete());
|
||||
}
|
||||
|
||||
bad<false>(3,
|
||||
@@ -1110,9 +1110,9 @@ public:
|
||||
), ec);
|
||||
if(! ec)
|
||||
break;
|
||||
expect(ec == parse_error::headers_too_big);
|
||||
BEAST_EXPECT(ec == parse_error::headers_too_big);
|
||||
}
|
||||
expect(n < Limit);
|
||||
BEAST_EXPECT(n < Limit);
|
||||
}
|
||||
{
|
||||
for(n = 1; n < Limit; ++n)
|
||||
@@ -1130,9 +1130,9 @@ public:
|
||||
), ec);
|
||||
if(! ec)
|
||||
break;
|
||||
expect(ec == parse_error::headers_too_big);
|
||||
BEAST_EXPECT(ec == parse_error::headers_too_big);
|
||||
}
|
||||
expect(n < Limit);
|
||||
BEAST_EXPECT(n < Limit);
|
||||
}
|
||||
{
|
||||
test::fail_counter fc(1000);
|
||||
@@ -1146,7 +1146,7 @@ public:
|
||||
"\r\n"
|
||||
"****"
|
||||
), ec);
|
||||
expect(ec == parse_error::body_too_big);
|
||||
BEAST_EXPECT(ec == parse_error::body_too_big);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -71,7 +71,7 @@ public:
|
||||
{
|
||||
std::string s;
|
||||
encode(s, args...);
|
||||
expect(s == answer);
|
||||
BEAST_EXPECT(s == answer);
|
||||
}
|
||||
|
||||
void run() override
|
||||
|
@@ -108,22 +108,22 @@ public:
|
||||
{
|
||||
Arg1 arg1;
|
||||
message<true, one_arg_body, headers>{std::move(arg1)};
|
||||
expect(arg1.moved);
|
||||
BEAST_EXPECT(arg1.moved);
|
||||
}
|
||||
|
||||
{
|
||||
headers h;
|
||||
h.insert("User-Agent", "test");
|
||||
message<true, one_arg_body, headers> m{Arg1{}, h};
|
||||
expect(h["User-Agent"] == "test");
|
||||
expect(m.headers["User-Agent"] == "test");
|
||||
BEAST_EXPECT(h["User-Agent"] == "test");
|
||||
BEAST_EXPECT(m.headers["User-Agent"] == "test");
|
||||
}
|
||||
{
|
||||
headers h;
|
||||
h.insert("User-Agent", "test");
|
||||
message<true, one_arg_body, headers> m{Arg1{}, std::move(h)};
|
||||
expect(! h.exists("User-Agent"));
|
||||
expect(m.headers["User-Agent"] == "test");
|
||||
BEAST_EXPECT(! h.exists("User-Agent"));
|
||||
BEAST_EXPECT(m.headers["User-Agent"] == "test");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,14 +137,14 @@ public:
|
||||
m2.method = "G";
|
||||
m2.body = "2";
|
||||
swap(m1, m2);
|
||||
expect(m1.method == "G");
|
||||
expect(m2.method.empty());
|
||||
expect(m1.url.empty());
|
||||
expect(m2.url == "u");
|
||||
expect(m1.body == "2");
|
||||
expect(m2.body == "1");
|
||||
expect(! m1.headers.exists("h"));
|
||||
expect(m2.headers.exists("h"));
|
||||
BEAST_EXPECT(m1.method == "G");
|
||||
BEAST_EXPECT(m2.method.empty());
|
||||
BEAST_EXPECT(m1.url.empty());
|
||||
BEAST_EXPECT(m2.url == "u");
|
||||
BEAST_EXPECT(m1.body == "2");
|
||||
BEAST_EXPECT(m2.body == "1");
|
||||
BEAST_EXPECT(! m1.headers.exists("h"));
|
||||
BEAST_EXPECT(m2.headers.exists("h"));
|
||||
}
|
||||
|
||||
void run() override
|
||||
|
@@ -27,14 +27,14 @@ public:
|
||||
m.url = "/";
|
||||
m.version = 11;
|
||||
m.headers.insert("Upgrade", "test");
|
||||
expect(! is_upgrade(m));
|
||||
BEAST_EXPECT(! is_upgrade(m));
|
||||
|
||||
prepare(m, connection::upgrade);
|
||||
expect(is_upgrade(m));
|
||||
expect(m.headers["Connection"] == "upgrade");
|
||||
BEAST_EXPECT(is_upgrade(m));
|
||||
BEAST_EXPECT(m.headers["Connection"] == "upgrade");
|
||||
|
||||
m.version = 10;
|
||||
expect(! is_upgrade(m));
|
||||
BEAST_EXPECT(! is_upgrade(m));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
{
|
||||
request_v1<empty_body> m;
|
||||
m.version = 10;
|
||||
expect(! is_upgrade(m));
|
||||
BEAST_EXPECT(! is_upgrade(m));
|
||||
m.headers.insert("Transfer-Encoding", "chunked");
|
||||
try
|
||||
{
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
m.version = 11;
|
||||
m.headers.erase("Connection");
|
||||
m.headers.insert("Connection", "close");
|
||||
expect(! is_keep_alive(m));
|
||||
BEAST_EXPECT(! is_keep_alive(m));
|
||||
}
|
||||
|
||||
void testSwap()
|
||||
@@ -93,16 +93,16 @@ public:
|
||||
m2.body = "2";
|
||||
m2.version = 11;
|
||||
swap(m1, m2);
|
||||
expect(m1.status == 404);
|
||||
expect(m2.status == 200);
|
||||
expect(m1.reason == "OK");
|
||||
expect(m2.reason.empty());
|
||||
expect(m1.version == 11);
|
||||
expect(m2.version == 10);
|
||||
expect(m1.body == "2");
|
||||
expect(m2.body == "1");
|
||||
expect(! m1.headers.exists("h"));
|
||||
expect(m2.headers.exists("h"));
|
||||
BEAST_EXPECT(m1.status == 404);
|
||||
BEAST_EXPECT(m2.status == 200);
|
||||
BEAST_EXPECT(m1.reason == "OK");
|
||||
BEAST_EXPECT(m2.reason.empty());
|
||||
BEAST_EXPECT(m1.version == 11);
|
||||
BEAST_EXPECT(m2.version == 10);
|
||||
BEAST_EXPECT(m1.body == "2");
|
||||
BEAST_EXPECT(m2.body == "1");
|
||||
BEAST_EXPECT(! m1.headers.exists("h"));
|
||||
BEAST_EXPECT(m2.headers.exists("h"));
|
||||
}
|
||||
|
||||
void run() override
|
||||
|
@@ -20,13 +20,13 @@ public:
|
||||
void check(char const* name, parse_error ev)
|
||||
{
|
||||
auto const ec = make_error_code(ev);
|
||||
expect(std::string{ec.category().name()} == name);
|
||||
expect(! ec.message().empty());
|
||||
expect(std::addressof(ec.category()) ==
|
||||
BEAST_EXPECT(std::string{ec.category().name()} == name);
|
||||
BEAST_EXPECT(! ec.message().empty());
|
||||
BEAST_EXPECT(std::addressof(ec.category()) ==
|
||||
std::addressof(get_parse_error_category()));
|
||||
expect(get_parse_error_category().equivalent(static_cast<int>(ev),
|
||||
BEAST_EXPECT(get_parse_error_category().equivalent(static_cast<int>(ev),
|
||||
ec.category().default_error_condition(static_cast<int>(ev))));
|
||||
expect(get_parse_error_category().equivalent(
|
||||
BEAST_EXPECT(get_parse_error_category().equivalent(
|
||||
ec, static_cast<int>(ev)));
|
||||
}
|
||||
|
||||
|
@@ -32,14 +32,14 @@ public:
|
||||
"\r\n"
|
||||
"*";
|
||||
p.write(buffer(s), ec);
|
||||
expect(! ec);
|
||||
expect(p.complete());
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(p.complete());
|
||||
auto m = p.release();
|
||||
expect(m.method == "GET");
|
||||
expect(m.url == "/");
|
||||
expect(m.version == 11);
|
||||
expect(m.headers["User-Agent"] == "test");
|
||||
expect(m.body == "*");
|
||||
BEAST_EXPECT(m.method == "GET");
|
||||
BEAST_EXPECT(m.url == "/");
|
||||
BEAST_EXPECT(m.version == 11);
|
||||
BEAST_EXPECT(m.headers["User-Agent"] == "test");
|
||||
BEAST_EXPECT(m.body == "*");
|
||||
}
|
||||
{
|
||||
error_code ec;
|
||||
@@ -52,14 +52,14 @@ public:
|
||||
"\r\n"
|
||||
"*";
|
||||
p.write(buffer(s), ec);
|
||||
expect(! ec);
|
||||
expect(p.complete());
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(p.complete());
|
||||
auto m = p.release();
|
||||
expect(m.status == 200);
|
||||
expect(m.reason == "OK");
|
||||
expect(m.version == 11);
|
||||
expect(m.headers["Server"] == "test");
|
||||
expect(m.body == "*");
|
||||
BEAST_EXPECT(m.status == 200);
|
||||
BEAST_EXPECT(m.reason == "OK");
|
||||
BEAST_EXPECT(m.version == 11);
|
||||
BEAST_EXPECT(m.headers["Server"] == "test");
|
||||
BEAST_EXPECT(m.body == "*");
|
||||
}
|
||||
// skip body
|
||||
{
|
||||
@@ -71,8 +71,8 @@ public:
|
||||
"\r\n";
|
||||
p.set_option(skip_body{true});
|
||||
p.write(buffer(s), ec);
|
||||
expect(! ec);
|
||||
expect(p.complete());
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(p.complete());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@@ -48,7 +48,7 @@ public:
|
||||
if(! ec)
|
||||
break;
|
||||
}
|
||||
expect(n < limit);
|
||||
BEAST_EXPECT(n < limit);
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
static std::size_t constexpr pre = 10;
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
if(! ec)
|
||||
break;
|
||||
}
|
||||
expect(n < limit);
|
||||
BEAST_EXPECT(n < limit);
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
streambuf sb;
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
if(! ec)
|
||||
break;
|
||||
}
|
||||
expect(n < limit);
|
||||
BEAST_EXPECT(n < limit);
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
static std::size_t constexpr pre = 10;
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
if(! ec)
|
||||
break;
|
||||
}
|
||||
expect(n < limit);
|
||||
BEAST_EXPECT(n < limit);
|
||||
}
|
||||
|
||||
void testThrow()
|
||||
@@ -201,7 +201,7 @@ public:
|
||||
{
|
||||
}
|
||||
}
|
||||
expect(n < limit);
|
||||
BEAST_EXPECT(n < limit);
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
@@ -219,7 +219,7 @@ public:
|
||||
if(! ec)
|
||||
break;
|
||||
}
|
||||
expect(n < limit);
|
||||
BEAST_EXPECT(n < limit);
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
@@ -237,7 +237,7 @@ public:
|
||||
if(! ec)
|
||||
break;
|
||||
}
|
||||
expect(n < limit);
|
||||
BEAST_EXPECT(n < limit);
|
||||
}
|
||||
|
||||
void testEof(yield_context do_yield)
|
||||
@@ -248,7 +248,7 @@ public:
|
||||
parser_v1<true, streambuf_body, headers> p;
|
||||
error_code ec;
|
||||
parse(ss, sb, p, ec);
|
||||
expect(ec == boost::asio::error::eof);
|
||||
BEAST_EXPECT(ec == boost::asio::error::eof);
|
||||
}
|
||||
{
|
||||
streambuf sb;
|
||||
@@ -256,7 +256,7 @@ public:
|
||||
parser_v1<true, streambuf_body, headers> p;
|
||||
error_code ec;
|
||||
async_parse(ss, sb, p, do_yield[ec]);
|
||||
expect(ec == boost::asio::error::eof);
|
||||
BEAST_EXPECT(ec == boost::asio::error::eof);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -19,7 +19,7 @@ public:
|
||||
void run() override
|
||||
{
|
||||
for(int i = 1; i <= 999; ++i)
|
||||
expect(reason_string(i) != nullptr);
|
||||
BEAST_EXPECT(reason_string(i) != nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -37,8 +37,8 @@ public:
|
||||
parser_v1<false, streambuf_body, headers> p;
|
||||
streambuf sb;
|
||||
parse(ss, sb, p);
|
||||
expect(to_string(p.get().body.data()) == "xyz");
|
||||
expect(boost::lexical_cast<std::string>(p.get()) == s);
|
||||
BEAST_EXPECT(to_string(p.get().body.data()) == "xyz");
|
||||
BEAST_EXPECT(boost::lexical_cast<std::string>(p.get()) == s);
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -242,7 +242,7 @@ public:
|
||||
string_write_stream ss(ios_);
|
||||
async_write(ss, m, do_yield[ec]);
|
||||
if(expect(! ec, ec.message()))
|
||||
expect(ss.str ==
|
||||
BEAST_EXPECT(ss.str ==
|
||||
"HTTP/1.0 200 OK\r\n"
|
||||
"Server: test\r\n"
|
||||
"Content-Length: 5\r\n"
|
||||
@@ -261,7 +261,7 @@ public:
|
||||
string_write_stream ss(ios_);
|
||||
async_write(ss, m, do_yield[ec]);
|
||||
if(expect(! ec, ec.message()))
|
||||
expect(ss.str ==
|
||||
BEAST_EXPECT(ss.str ==
|
||||
"HTTP/1.1 200 OK\r\n"
|
||||
"Server: test\r\n"
|
||||
"Transfer-Encoding: chunked\r\n"
|
||||
@@ -295,7 +295,7 @@ public:
|
||||
try
|
||||
{
|
||||
write(fs, m);
|
||||
expect(fs.next_layer().str ==
|
||||
BEAST_EXPECT(fs.next_layer().str ==
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Content-Length: 5\r\n"
|
||||
@@ -309,7 +309,7 @@ public:
|
||||
{
|
||||
}
|
||||
}
|
||||
expect(n < limit);
|
||||
BEAST_EXPECT(n < limit);
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
@@ -329,7 +329,7 @@ public:
|
||||
write(fs, m, ec);
|
||||
if(ec == boost::asio::error::eof)
|
||||
{
|
||||
expect(fs.next_layer().str ==
|
||||
BEAST_EXPECT(fs.next_layer().str ==
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Transfer-Encoding: chunked\r\n"
|
||||
@@ -344,7 +344,7 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
expect(n < limit);
|
||||
BEAST_EXPECT(n < limit);
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
@@ -364,7 +364,7 @@ public:
|
||||
async_write(fs, m, do_yield[ec]);
|
||||
if(ec == boost::asio::error::eof)
|
||||
{
|
||||
expect(fs.next_layer().str ==
|
||||
BEAST_EXPECT(fs.next_layer().str ==
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Transfer-Encoding: chunked\r\n"
|
||||
@@ -379,7 +379,7 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
expect(n < limit);
|
||||
BEAST_EXPECT(n < limit);
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
@@ -399,7 +399,7 @@ public:
|
||||
write(fs, m, ec);
|
||||
if(! ec)
|
||||
{
|
||||
expect(fs.next_layer().str ==
|
||||
BEAST_EXPECT(fs.next_layer().str ==
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Content-Length: 5\r\n"
|
||||
@@ -409,7 +409,7 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
expect(n < limit);
|
||||
BEAST_EXPECT(n < limit);
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
@@ -429,7 +429,7 @@ public:
|
||||
async_write(fs, m, do_yield[ec]);
|
||||
if(! ec)
|
||||
{
|
||||
expect(fs.next_layer().str ==
|
||||
BEAST_EXPECT(fs.next_layer().str ==
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Content-Length: 5\r\n"
|
||||
@@ -439,7 +439,7 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
expect(n < limit);
|
||||
BEAST_EXPECT(n < limit);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -454,7 +454,7 @@ public:
|
||||
m.headers.insert("User-Agent", "test");
|
||||
m.body = "*";
|
||||
prepare(m);
|
||||
expect(str(m) ==
|
||||
BEAST_EXPECT(str(m) ==
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Content-Length: 1\r\n"
|
||||
@@ -471,7 +471,7 @@ public:
|
||||
m.headers.insert("User-Agent", "test");
|
||||
m.body = "*";
|
||||
prepare(m, connection::keep_alive);
|
||||
expect(str(m) ==
|
||||
BEAST_EXPECT(str(m) ==
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Content-Length: 1\r\n"
|
||||
@@ -510,8 +510,8 @@ public:
|
||||
string_write_stream ss(ios_);
|
||||
error_code ec;
|
||||
write(ss, m, ec);
|
||||
expect(ec == boost::asio::error::eof);
|
||||
expect(ss.str ==
|
||||
BEAST_EXPECT(ec == boost::asio::error::eof);
|
||||
BEAST_EXPECT(ss.str ==
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"\r\n"
|
||||
@@ -527,7 +527,7 @@ public:
|
||||
m.headers.insert("User-Agent", "test");
|
||||
m.body = "*";
|
||||
prepare(m);
|
||||
expect(str(m) ==
|
||||
BEAST_EXPECT(str(m) ==
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Content-Length: 1\r\n"
|
||||
@@ -547,8 +547,8 @@ public:
|
||||
string_write_stream ss(ios_);
|
||||
error_code ec;
|
||||
write(ss, m, ec);
|
||||
expect(ec == boost::asio::error::eof);
|
||||
expect(ss.str ==
|
||||
BEAST_EXPECT(ec == boost::asio::error::eof);
|
||||
BEAST_EXPECT(ss.str ==
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Content-Length: 1\r\n"
|
||||
@@ -565,7 +565,7 @@ public:
|
||||
m.version = 11;
|
||||
m.headers.insert("User-Agent", "test");
|
||||
prepare(m, connection::upgrade);
|
||||
expect(str(m) ==
|
||||
BEAST_EXPECT(str(m) ==
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Connection: upgrade\r\n"
|
||||
@@ -584,7 +584,7 @@ public:
|
||||
string_write_stream ss(ios_);
|
||||
error_code ec;
|
||||
write(ss, m, ec);
|
||||
expect(ss.str ==
|
||||
BEAST_EXPECT(ss.str ==
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Transfer-Encoding: chunked\r\n"
|
||||
@@ -605,7 +605,7 @@ public:
|
||||
m.headers.insert("User-Agent", "test");
|
||||
m.body = "*";
|
||||
prepare(m);
|
||||
expect(boost::lexical_cast<std::string>(m) ==
|
||||
BEAST_EXPECT(boost::lexical_cast<std::string>(m) ==
|
||||
"GET / HTTP/1.1\r\nUser-Agent: test\r\nContent-Length: 1\r\n\r\n*");
|
||||
}
|
||||
|
||||
|
@@ -34,20 +34,20 @@ class frame_test : public beast::unit_test::suite
|
||||
public:
|
||||
void testCloseCodes()
|
||||
{
|
||||
expect(! is_valid(0));
|
||||
expect(! is_valid(1));
|
||||
expect(! is_valid(999));
|
||||
expect(! is_valid(1004));
|
||||
expect(! is_valid(1005));
|
||||
expect(! is_valid(1006));
|
||||
expect(! is_valid(1016));
|
||||
expect(! is_valid(2000));
|
||||
expect(! is_valid(2999));
|
||||
expect(is_valid(1000));
|
||||
expect(is_valid(1002));
|
||||
expect(is_valid(3000));
|
||||
expect(is_valid(4000));
|
||||
expect(is_valid(5000));
|
||||
BEAST_EXPECT(! is_valid(0));
|
||||
BEAST_EXPECT(! is_valid(1));
|
||||
BEAST_EXPECT(! is_valid(999));
|
||||
BEAST_EXPECT(! is_valid(1004));
|
||||
BEAST_EXPECT(! is_valid(1005));
|
||||
BEAST_EXPECT(! is_valid(1006));
|
||||
BEAST_EXPECT(! is_valid(1016));
|
||||
BEAST_EXPECT(! is_valid(2000));
|
||||
BEAST_EXPECT(! is_valid(2999));
|
||||
BEAST_EXPECT(is_valid(1000));
|
||||
BEAST_EXPECT(is_valid(1002));
|
||||
BEAST_EXPECT(is_valid(3000));
|
||||
BEAST_EXPECT(is_valid(4000));
|
||||
BEAST_EXPECT(is_valid(5000));
|
||||
}
|
||||
|
||||
struct test_fh : frame_header
|
||||
@@ -80,16 +80,16 @@ public:
|
||||
close_code::value code;
|
||||
auto const n = read_fh1(
|
||||
fh1, sb, role, code);
|
||||
if(! expect(! code))
|
||||
if(! BEAST_EXPECT(! code))
|
||||
return;
|
||||
if(! expect(sb.size() == n))
|
||||
if(! BEAST_EXPECT(sb.size() == n))
|
||||
return;
|
||||
read_fh2(fh1, sb, role, code);
|
||||
if(! expect(! code))
|
||||
if(! BEAST_EXPECT(! code))
|
||||
return;
|
||||
if(! expect(sb.size() == 0))
|
||||
if(! BEAST_EXPECT(sb.size() == 0))
|
||||
return;
|
||||
expect(fh1 == fh);
|
||||
BEAST_EXPECT(fh1 == fh);
|
||||
};
|
||||
|
||||
test_fh fh;
|
||||
@@ -135,12 +135,12 @@ public:
|
||||
pass();
|
||||
return;
|
||||
}
|
||||
if(! expect(sb.size() == n))
|
||||
if(! BEAST_EXPECT(sb.size() == n))
|
||||
return;
|
||||
read_fh2(fh1, sb, role, code);
|
||||
if(! expect(code))
|
||||
if(! BEAST_EXPECT(code))
|
||||
return;
|
||||
if(! expect(sb.size() == 0))
|
||||
if(! BEAST_EXPECT(sb.size() == 0))
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -200,12 +200,12 @@ public:
|
||||
pass();
|
||||
return;
|
||||
}
|
||||
if(! expect(sb.size() == n))
|
||||
if(! BEAST_EXPECT(sb.size() == n))
|
||||
return;
|
||||
read_fh2(fh, sb, role, code);
|
||||
if(! expect(code))
|
||||
if(! BEAST_EXPECT(code))
|
||||
return;
|
||||
if(! expect(sb.size() == 0))
|
||||
if(! BEAST_EXPECT(sb.size() == 0))
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -38,7 +38,7 @@ public:
|
||||
void run() override
|
||||
{
|
||||
maskgen_t<test_generator> mg;
|
||||
expect(mg() != 0);
|
||||
BEAST_EXPECT(mg() != 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -21,7 +21,7 @@ class stream_base_test : public beast::unit_test::suite
|
||||
public:
|
||||
void testClamp()
|
||||
{
|
||||
expect(detail::clamp(
|
||||
BEAST_EXPECT(detail::clamp(
|
||||
std::numeric_limits<std::uint64_t>::max()) ==
|
||||
std::numeric_limits<std::size_t>::max());
|
||||
}
|
||||
|
@@ -35,18 +35,18 @@ public:
|
||||
})();
|
||||
|
||||
// Valid range 0-127
|
||||
expect(utf8.write(buf.data(), 128));
|
||||
expect(utf8.finish());
|
||||
BEAST_EXPECT(utf8.write(buf.data(), 128));
|
||||
BEAST_EXPECT(utf8.finish());
|
||||
|
||||
// Invalid range 128-193
|
||||
for (auto it = std::next(buf.begin(), 128);
|
||||
it != std::next(buf.begin(), 194); ++it)
|
||||
expect(! utf8.write(&(*it), 1));
|
||||
BEAST_EXPECT(! utf8.write(&(*it), 1));
|
||||
|
||||
// Invalid range 245-255
|
||||
for (auto it = std::next(buf.begin(), 245);
|
||||
it != buf.end(); ++it)
|
||||
expect(! utf8.write(&(*it), 1));
|
||||
BEAST_EXPECT(! utf8.write(&(*it), 1));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -63,22 +63,22 @@ public:
|
||||
{
|
||||
// Second byte valid range 128-191
|
||||
buf[1] = static_cast<std::uint8_t>(j);
|
||||
expect(utf8.write(buf, 2));
|
||||
expect(utf8.finish());
|
||||
BEAST_EXPECT(utf8.write(buf, 2));
|
||||
BEAST_EXPECT(utf8.finish());
|
||||
}
|
||||
|
||||
for (auto j = 0; j <= 127; ++j)
|
||||
{
|
||||
// Second byte invalid range 0-127
|
||||
buf[1] = static_cast<std::uint8_t>(j);
|
||||
expect(! utf8.write(buf, 2));
|
||||
BEAST_EXPECT(! utf8.write(buf, 2));
|
||||
}
|
||||
|
||||
for (auto j = 192; j <= 255; ++j)
|
||||
{
|
||||
// Second byte invalid range 192-255
|
||||
buf[1] = static_cast<std::uint8_t>(j);
|
||||
expect(! utf8.write(buf, 2));
|
||||
BEAST_EXPECT(! utf8.write(buf, 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,22 +104,22 @@ public:
|
||||
{
|
||||
// Third byte valid range 128-191
|
||||
buf[2] = static_cast<std::uint8_t>(k);
|
||||
expect(utf8.write(buf, 3));
|
||||
expect(utf8.finish());
|
||||
BEAST_EXPECT(utf8.write(buf, 3));
|
||||
BEAST_EXPECT(utf8.finish());
|
||||
}
|
||||
|
||||
for (auto k = 0; k <= 127; ++k)
|
||||
{
|
||||
// Third byte invalid range 0-127
|
||||
buf[2] = static_cast<std::uint8_t>(k);
|
||||
expect(! utf8.write(buf, 3));
|
||||
BEAST_EXPECT(! utf8.write(buf, 3));
|
||||
}
|
||||
|
||||
for (auto k = 192; k <= 255; ++k)
|
||||
{
|
||||
// Third byte invalid range 192-255
|
||||
buf[2] = static_cast<std::uint8_t>(k);
|
||||
expect(! utf8.write(buf, 3));
|
||||
BEAST_EXPECT(! utf8.write(buf, 3));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,14 +127,14 @@ public:
|
||||
{
|
||||
// Second byte invalid range 0-127 or 0-159
|
||||
buf[1] = static_cast<std::uint8_t>(j);
|
||||
expect(! utf8.write(buf, 3));
|
||||
BEAST_EXPECT(! utf8.write(buf, 3));
|
||||
}
|
||||
|
||||
for (auto j = e + 1; j <= 255; ++j)
|
||||
{
|
||||
// Second byte invalid range 160-255 or 192-255
|
||||
buf[1] = static_cast<std::uint8_t>(j);
|
||||
expect(! utf8.write(buf, 3));
|
||||
BEAST_EXPECT(! utf8.write(buf, 3));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -166,22 +166,22 @@ public:
|
||||
{
|
||||
// Fourth byte valid range 128-191
|
||||
buf[3] = static_cast<std::uint8_t>(n);
|
||||
expect(utf8.write(const_buffers_1{buf, 4}));
|
||||
expect(utf8.finish());
|
||||
BEAST_EXPECT(utf8.write(const_buffers_1{buf, 4}));
|
||||
BEAST_EXPECT(utf8.finish());
|
||||
}
|
||||
|
||||
for (auto n = 0; n <= 127; ++n)
|
||||
{
|
||||
// Fourth byte invalid range 0-127
|
||||
buf[3] = static_cast<std::uint8_t>(n);
|
||||
expect(! utf8.write(const_buffers_1{buf, 4}));
|
||||
BEAST_EXPECT(! utf8.write(const_buffers_1{buf, 4}));
|
||||
}
|
||||
|
||||
for (auto n = 192; n <= 255; ++n)
|
||||
{
|
||||
// Fourth byte invalid range 192-255
|
||||
buf[3] = static_cast<std::uint8_t>(n);
|
||||
expect(! utf8.write(buf, 4));
|
||||
BEAST_EXPECT(! utf8.write(buf, 4));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,14 +189,14 @@ public:
|
||||
{
|
||||
// Third byte invalid range 0-127
|
||||
buf[2] = static_cast<std::uint8_t>(k);
|
||||
expect(! utf8.write(buf, 4));
|
||||
BEAST_EXPECT(! utf8.write(buf, 4));
|
||||
}
|
||||
|
||||
for (auto k = 192; k <= 255; ++k)
|
||||
{
|
||||
// Third byte invalid range 192-255
|
||||
buf[2] = static_cast<std::uint8_t>(k);
|
||||
expect(! utf8.write(buf, 4));
|
||||
BEAST_EXPECT(! utf8.write(buf, 4));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,14 +204,14 @@ public:
|
||||
{
|
||||
// Second byte invalid range 0-127 or 0-143
|
||||
buf[1] = static_cast<std::uint8_t>(j);
|
||||
expect(! utf8.write(buf, 3));
|
||||
BEAST_EXPECT(! utf8.write(buf, 3));
|
||||
}
|
||||
|
||||
for (auto j = e + 1; j <= 255; ++j)
|
||||
{
|
||||
// Second byte invalid range 144-255 or 192-255
|
||||
buf[1] = static_cast<std::uint8_t>(j);
|
||||
expect(! utf8.write(buf, 3));
|
||||
BEAST_EXPECT(! utf8.write(buf, 3));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -258,8 +258,8 @@ public:
|
||||
cb.consume(amount);
|
||||
n -= amount;
|
||||
}
|
||||
expect(utf8.write(sb.data()));
|
||||
expect(utf8.finish());
|
||||
BEAST_EXPECT(utf8.write(sb.data()));
|
||||
BEAST_EXPECT(utf8.finish());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -20,13 +20,13 @@ public:
|
||||
void check(char const* name, error ev)
|
||||
{
|
||||
auto const ec = make_error_code(ev);
|
||||
expect(std::string{ec.category().name()} == name);
|
||||
expect(! ec.message().empty());
|
||||
expect(std::addressof(ec.category()) ==
|
||||
BEAST_EXPECT(std::string{ec.category().name()} == name);
|
||||
BEAST_EXPECT(! ec.message().empty());
|
||||
BEAST_EXPECT(std::addressof(ec.category()) ==
|
||||
std::addressof(detail::get_error_category()));
|
||||
expect(detail::get_error_category().equivalent(static_cast<int>(ev),
|
||||
BEAST_EXPECT(detail::get_error_category().equivalent(static_cast<int>(ev),
|
||||
ec.category().default_error_condition(static_cast<int>(ev))));
|
||||
expect(detail::get_error_category().equivalent(
|
||||
BEAST_EXPECT(detail::get_error_category().equivalent(
|
||||
ec, static_cast<int>(ev)));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user