buffer_size is in buffer_traits.hpp

This commit is contained in:
Vinnie Falco committed 2019-03-05 11:09:50 -08:00
1 parent 8e2620e2b1
commit 6ccdcdf51d
52 files changed
+274 -302

No files matched your search

-1
View File
@@ -34,7 +34,6 @@ add_executable (tests-beast-core
async_base.cpp
basic_stream.cpp
bind_handler.cpp
buffer_size.cpp
buffer_traits.cpp
buffered_read_stream.cpp
buffers_adapter.cpp
-1
View File
@@ -22,7 +22,6 @@ local SOURCES =
async_base.cpp
basic_stream.cpp
bind_handler.cpp
buffer_size.cpp
buffer_traits.cpp
buffered_read_stream.cpp
buffers_adapter.cpp
-98
View File
@@ -1,98 +0,0 @@
//
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/beast
//
// Test that header file is self-contained.
#include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <boost/beast/core/detail/is_invocable.hpp>
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_size_test : public beast::unit_test::suite
{
public:
void
testJavadocs()
{
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
{
testFunction();
testJavadocs();
}
};
BEAST_DEFINE_TESTSUITE(beast,core,buffer_size);
} // beast
} // boost
+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();
}
};
+1 -1
View File
@@ -12,7 +12,7 @@
#include "test_buffer.hpp"
#include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/buffer_traits.hpp>
#include <boost/beast/core/multi_buffer.hpp>
#include <boost/beast/core/ostream.hpp>
#include <boost/beast/core/read_size.hpp>
+1 -1
View File
@@ -13,7 +13,7 @@
#include "test_buffer.hpp"
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/buffer_traits.hpp>
#include <boost/beast/core/buffers_prefix.hpp>
#include <boost/beast/core/buffers_suffix.hpp>
#include <boost/asio/buffer.hpp>
+1 -1
View File
@@ -12,7 +12,7 @@
#include "test_buffer.hpp"
#include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/buffer_traits.hpp>
#include <boost/beast/core/buffers_to_string.hpp>
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <string>
+1 -1
View File
@@ -12,7 +12,7 @@
#include "test_buffer.hpp"
#include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/buffer_traits.hpp>
#include <boost/beast/core/buffers_cat.hpp>
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <boost/asio/buffer.hpp>
+1 -1
View File
@@ -12,7 +12,7 @@
#include "test_buffer.hpp"
#include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/buffer_traits.hpp>
#include <boost/beast/core/ostream.hpp>
#include <boost/beast/core/read_size.hpp>
#include <boost/beast/core/string.hpp>
+1 -1
View File
@@ -11,7 +11,7 @@
#include <boost/beast/core/make_printable.hpp>
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/buffer_traits.hpp>
#include <iostream>
#include <sstream>
+1 -1
View File
@@ -12,7 +12,7 @@
#include "test_buffer.hpp"
#include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/buffer_traits.hpp>
#include <boost/beast/core/ostream.hpp>
#include <boost/beast/core/read_size.hpp>
#include <boost/beast/core/string.hpp>
+1 -1
View File
@@ -12,7 +12,7 @@
#include "test_buffer.hpp"
#include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/buffer_traits.hpp>
#include <boost/beast/core/ostream.hpp>
#include <boost/beast/core/read_size.hpp>
#include <boost/beast/core/string.hpp>
-1
View File
@@ -12,7 +12,6 @@
#include <boost/beast/core/detail/config.hpp>
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/buffer_traits.hpp>
#include <boost/beast/core/buffers_to_string.hpp>
#include <boost/beast/core/string.hpp>
+1 -1
View File
@@ -13,7 +13,7 @@
#include "message_fuzz.hpp"
#include "test_parser.hpp"
#include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/buffer_traits.hpp>
#include <boost/beast/core/buffers_cat.hpp>
#include <boost/beast/core/buffers_prefix.hpp>
#include <boost/beast/core/buffers_suffix.hpp>
+1 -1
View File
@@ -10,7 +10,7 @@
// Test that header file is self-contained.
#include <boost/beast/http/file_body.hpp>
#include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/buffer_traits.hpp>
#include <boost/beast/core/buffers_prefix.hpp>
#include <boost/beast/core/file_stdio.hpp>
#include <boost/beast/core/flat_buffer.hpp>
+1 -1
View File
@@ -14,7 +14,7 @@
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <boost/beast/test/yield_to.hpp>
#include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/buffer_traits.hpp>
#include <boost/beast/core/buffers_suffix.hpp>
#include <boost/beast/core/flat_buffer.hpp>
#include <boost/beast/core/multi_buffer.hpp>
+1 -1
View File
@@ -10,7 +10,7 @@
// Test that header file is self-contained.
#include <boost/beast/http/serializer.hpp>
#include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/buffer_traits.hpp>
#include <boost/beast/http/string_body.hpp>
#include <boost/beast/_experimental/unit_test/suite.hpp>
+1 -1
View File
@@ -10,7 +10,7 @@
// Test that header file is self-contained.
#include <boost/beast/http/span_body.hpp>
#include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/buffer_traits.hpp>
#include <boost/beast/http/message.hpp>
#include <boost/beast/_experimental/unit_test/suite.hpp>
+1 -1
View File
@@ -11,7 +11,7 @@
#define BEAST_TEST_WEBSOCKET_TEST_HPP
#include <boost/beast/core/bind_handler.hpp>
#include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/buffer_traits.hpp>
#include <boost/beast/core/buffers_prefix.hpp>
#include <boost/beast/core/buffers_to_string.hpp>
#include <boost/beast/core/ostream.hpp>
+1 -1
View File
@@ -12,7 +12,7 @@
#include "test/beast/http/message_fuzz.hpp"
#include <boost/beast/http.hpp>
#include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/buffer_traits.hpp>
#include <boost/beast/core/buffers_suffix.hpp>
#include <boost/beast/core/buffers_to_string.hpp>
#include <boost/beast/core/ostream.hpp>
+1 -1
View File
@@ -7,7 +7,7 @@
// Official repository: https://github.com/boostorg/beast
//
#include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/buffer_traits.hpp>
#include <boost/beast/core/error.hpp>
#include <boost/beast/core/file_base.hpp>
#include <boost/beast/http/message.hpp>