Use buffers_to_string in tests

fix #782
This commit is contained in:
Vinnie Falco
2018-04-24 10:55:39 -07:00
parent 5abac8b380
commit 14392d7f52
21 changed files with 164 additions and 281 deletions
+7 -20
View File
@@ -12,6 +12,7 @@
#include "message_fuzz.hpp"
#include <boost/beast/core/buffers_to_string.hpp>
#include <boost/beast/core/static_string.hpp>
#include <boost/beast/http/fields.hpp>
#include <boost/beast/test/fuzz.hpp>
@@ -35,30 +36,16 @@ public:
BOOST_STATIC_ASSERT(
! detail::is_chunk_extensions<not_chunk_extensions>::value);
template<class ConstBufferSequence>
static
std::string
to_string(ConstBufferSequence const& buffers)
{
std::string s;
s.reserve(boost::asio::buffer_size(buffers));
for(boost::asio::const_buffer b : beast::detail::buffers_range(buffers))
s.append(
reinterpret_cast<char const*>(b.data()),
b.size());
return s;
}
template<class T, class... Args>
void
check(string_view match, Args&&... args)
{
T t(std::forward<Args>(args)...);
BEAST_EXPECT(to_string(t) == match);
BEAST_EXPECT(buffers_to_string(t) == match);
T t2(t);
BEAST_EXPECT(to_string(t2) == match);
BEAST_EXPECT(buffers_to_string(t2) == match);
T t3(std::move(t2));
BEAST_EXPECT(to_string(t3) == match);
BEAST_EXPECT(buffers_to_string(t3) == match);
}
template<class T, class... Args>
@@ -66,11 +53,11 @@ public:
check_fwd(string_view match, Args&&... args)
{
T t(std::forward<Args>(args)...);
BEAST_EXPECT(to_string(t) == match);
BEAST_EXPECT(buffers_to_string(t) == match);
T t2(t);
BEAST_EXPECT(to_string(t2) == match);
BEAST_EXPECT(buffers_to_string(t2) == match);
T t3(std::move(t2));
BEAST_EXPECT(to_string(t3) == match);
BEAST_EXPECT(buffers_to_string(t3) == match);
}
using cb_t = boost::asio::const_buffer;