Fixes, fail testing:

Core:

* Test buffer_cat iterator move members

HTTP:

* Fixed yield / resume in writer
* Fixed message serialization with chunked encoding

* Test yield / resume in writer
* Test all conditional branches during message serialization
* Test chunked encoding
* Increase coverage on parse_error
* Add parse_error::general

WebSocket:

* Add error::general
* Increase coverage in error
This commit is contained in:
Vinnie Falco committed 2017-07-20 08:12:06 -07:00
1 parent c49cde844b
commit b62d1b2164
44 files changed
+1064 -688

No files matched your search

+9 -1
View File
@@ -81,7 +81,15 @@ public:
const_buffer{buf+4, 2},
const_buffer{buf+6, 3}}};
auto bs = buffer_cat(b1, b2);
for(int n = 0;
n <= std::distance(bs.begin(), bs.end()); ++n)
{
auto it = std::next(bs.begin(), n);
decltype(it) it2(std::move(it));
it = std::move(it2);
auto pit = &it;
it = std::move(*pit);
}
try
{
std::size_t n = 0;
+99 -4
View File
@@ -9,15 +9,22 @@
#include <beast/core/streambuf_readstream.hpp>
#include <beast/core/streambuf.hpp>
#include <beast/test/fail_stream.hpp>
#include <beast/test/string_stream.hpp>
#include <beast/test/yield_to.hpp>
#include <beast/unit_test/suite.hpp>
#include <boost/asio.hpp>
namespace beast {
class streambuf_readstream_test : public beast::unit_test::suite
class streambuf_readstream_test
: public unit_test::suite
, public test::enable_yield_to
{
using self = streambuf_readstream_test;
public:
void testSpecial()
void testSpecialMembers()
{
using socket_type = boost::asio::ip::tcp::socket;
boost::asio::io_service ios;
@@ -33,12 +40,100 @@ public:
streambuf_readstream<socket_type&, streambuf> srs(sock);
streambuf_readstream<socket_type&, streambuf> srs2(std::move(srs));
}
pass();
}
void testRead(yield_context do_yield)
{
using boost::asio::buffer;
using boost::asio::buffer_copy;
static std::size_t constexpr limit = 100;
std::size_t n;
std::string s;
s.resize(13);
for(n = 0; n < limit; ++n)
{
test::fail_stream<
test::string_stream> fs(n, ios_, ", world!");
streambuf_readstream<
decltype(fs)&, streambuf> srs(fs);
srs.buffer().commit(buffer_copy(
srs.buffer().prepare(5), buffer("Hello", 5)));
boost::system::error_code ec;
boost::asio::read(srs, buffer(&s[0], s.size()), ec);
if(! ec)
{
expect(s == "Hello, world!");
break;
}
}
expect(n < limit);
for(n = 0; n < limit; ++n)
{
test::fail_stream<
test::string_stream> fs(n, ios_, ", world!");
streambuf_readstream<
decltype(fs)&, streambuf> srs(fs);
srs.capacity(3);
srs.buffer().commit(buffer_copy(
srs.buffer().prepare(5), buffer("Hello", 5)));
boost::system::error_code ec;
boost::asio::read(srs, buffer(&s[0], s.size()), ec);
if(! ec)
{
expect(s == "Hello, world!");
break;
}
}
expect(n < limit);
for(n = 0; n < limit; ++n)
{
test::fail_stream<
test::string_stream> fs(n, ios_, ", world!");
streambuf_readstream<
decltype(fs)&, streambuf> srs(fs);
srs.buffer().commit(buffer_copy(
srs.buffer().prepare(5), buffer("Hello", 5)));
boost::system::error_code ec;
boost::asio::async_read(
srs, buffer(&s[0], s.size()), do_yield[ec]);
if(! ec)
{
expect(s == "Hello, world!");
break;
}
}
expect(n < limit);
for(n = 0; n < limit; ++n)
{
test::fail_stream<
test::string_stream> fs(n, ios_, ", world!");
streambuf_readstream<
decltype(fs)&, streambuf> srs(fs);
srs.capacity(3);
srs.buffer().commit(buffer_copy(
srs.buffer().prepare(5), buffer("Hello", 5)));
boost::system::error_code ec;
boost::asio::async_read(
srs, buffer(&s[0], s.size()), do_yield[ec]);
if(! ec)
{
expect(s == "Hello, world!");
break;
}
}
expect(n < limit);
}
void run() override
{
testSpecial();
testSpecialMembers();
yield_to(std::bind(&self::testRead,
this, std::placeholders::_1));
}
};