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
+3 -15
View File
@@ -10,6 +10,7 @@
// Test that header file is self-contained.
#include <boost/beast/core/ostream.hpp>
#include <boost/beast/core/buffers_to_string.hpp>
#include <boost/beast/core/multi_buffer.hpp>
#include <boost/beast/unit_test/suite.hpp>
#include <ostream>
@@ -20,19 +21,6 @@ namespace beast {
class ostream_test : public beast::unit_test::suite
{
public:
template<class ConstBufferSequence>
static
std::string
to_string(ConstBufferSequence const& bs)
{
std::string s;
s.reserve(buffer_size(bs));
for(auto b : beast::detail::buffers_range(bs))
s.append(reinterpret_cast<
char const*>(b.data()), b.size());
return s;
}
void
run() override
{
@@ -41,7 +29,7 @@ public:
auto os = ostream(b);
os << "Hello, world!\n";
os.flush();
BEAST_EXPECT(to_string(b.data()) == "Hello, world!\n");
BEAST_EXPECT(buffers_to_string(b.data()) == "Hello, world!\n");
auto os2 = std::move(os);
}
{
@@ -56,7 +44,7 @@ public:
"0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef";
multi_buffer b;
ostream(b) << s;
BEAST_EXPECT(to_string(b.data()) == s);
BEAST_EXPECT(buffers_to_string(b.data()) == s);
}
}
};