buffer_size is in buffer_traits.hpp

This commit is contained in:
Vinnie Falco
2019-03-05 11:09:50 -08:00
parent 8e2620e2b1
commit 6ccdcdf51d
52 changed files with 274 additions and 302 deletions
+62
View File
@@ -11,11 +11,46 @@
#include <boost/beast/core/buffer_traits.hpp>
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <boost/beast/core/detail/type_traits.hpp>
#include <array>
namespace boost {
namespace beast {
namespace {
struct sequence
{
struct value_type
{
operator net::const_buffer() const noexcept
{
return {"Hello, world!", 13};
}
};
using const_iterator = value_type const*;
const_iterator begin() const noexcept
{
return &v_;
}
const_iterator end() const noexcept
{
return begin() + 1;
}
private:
value_type v_;
};
struct not_sequence
{
};
} // (anon)
class buffer_traits_test : public beast::unit_test::suite
{
public:
@@ -168,9 +203,36 @@ public:
pass();
}
void
testFunction()
{
BEAST_EXPECT(buffer_size(
net::const_buffer("Hello, world!", 13)) == 13);
BEAST_EXPECT(buffer_size(
net::mutable_buffer{}) == 0);
{
sequence s;
BEAST_EXPECT(buffer_size(s) == 13);
}
{
std::array<net::const_buffer, 2> s({{
net::const_buffer("Hello, world!", 13),
net::const_buffer("Hello, world!", 13)}});
BEAST_EXPECT(buffer_size(s) == 26);
}
BOOST_STATIC_ASSERT(! detail::is_invocable<
detail::buffer_size_impl,
std::size_t(not_sequence const&)>::value);
}
void run() override
{
testJavadocs();
testFunction();
}
};