dynamic_buffer_ref tests and tidy

This commit is contained in:
Vinnie Falco
2019-02-07 20:57:50 -08:00
parent 06efddd8b8
commit 98834967c3
15 changed files with 44 additions and 13 deletions

View File

@@ -1,3 +1,9 @@
Version 212:
* dynamic_buffer_ref tests and tidy
--------------------------------------------------------------------------------
Version 211: Version 211:
* close_socket is in stream_traits.hpp * close_socket is in stream_traits.hpp

View File

@@ -44,6 +44,9 @@ public:
dynamic_buffer_ref_wrapper( dynamic_buffer_ref_wrapper(
dynamic_buffer_ref_wrapper&&) = default; dynamic_buffer_ref_wrapper&&) = default;
dynamic_buffer_ref_wrapper(
dynamic_buffer_ref_wrapper const&) = default;
explicit explicit
dynamic_buffer_ref_wrapper( dynamic_buffer_ref_wrapper(
DynamicBuffer& b) noexcept DynamicBuffer& b) noexcept

View File

@@ -16,7 +16,7 @@ add_executable (tests-beast-core
${EXTRAS_FILES} ${EXTRAS_FILES}
${TEST_MAIN} ${TEST_MAIN}
Jamfile Jamfile
buffer_test.hpp test_buffer.hpp
file_test.hpp file_test.hpp
stream_tests.hpp stream_tests.hpp
test_handler.hpp test_handler.hpp

View File

@@ -10,7 +10,7 @@
// Test that header file is self-contained. // Test that header file is self-contained.
#include <boost/beast/core/buffers_adaptor.hpp> #include <boost/beast/core/buffers_adaptor.hpp>
#include "buffer_test.hpp" #include "test_buffer.hpp"
#include <boost/beast/core/buffer_size.hpp> #include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/multi_buffer.hpp> #include <boost/beast/core/multi_buffer.hpp>

View File

@@ -10,7 +10,7 @@
// Test that header file is self-contained. // Test that header file is self-contained.
#include <boost/beast/core/buffers_cat.hpp> #include <boost/beast/core/buffers_cat.hpp>
#include "buffer_test.hpp" #include "test_buffer.hpp"
#include <boost/beast/_experimental/unit_test/suite.hpp> #include <boost/beast/_experimental/unit_test/suite.hpp>
#include <boost/beast/core/buffer_size.hpp> #include <boost/beast/core/buffer_size.hpp>

View File

@@ -10,7 +10,7 @@
// Test that header file is self-contained. // Test that header file is self-contained.
#include <boost/beast/core/buffers_prefix.hpp> #include <boost/beast/core/buffers_prefix.hpp>
#include "buffer_test.hpp" #include "test_buffer.hpp"
#include <boost/beast/core/buffer_size.hpp> #include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/buffers_to_string.hpp> #include <boost/beast/core/buffers_to_string.hpp>

View File

@@ -10,7 +10,7 @@
// Test that header file is self-contained. // Test that header file is self-contained.
#include <boost/beast/core/buffers_range.hpp> #include <boost/beast/core/buffers_range.hpp>
#include "buffer_test.hpp" #include "test_buffer.hpp"
#include <boost/beast/_experimental/unit_test/suite.hpp> #include <boost/beast/_experimental/unit_test/suite.hpp>

View File

@@ -10,7 +10,7 @@
// Test that header file is self-contained. // Test that header file is self-contained.
#include <boost/beast/core/buffers_suffix.hpp> #include <boost/beast/core/buffers_suffix.hpp>
#include "buffer_test.hpp" #include "test_buffer.hpp"
#include <boost/beast/core/buffer_size.hpp> #include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/buffers_cat.hpp> #include <boost/beast/core/buffers_cat.hpp>

View File

@@ -39,9 +39,31 @@ public:
&read_line<test::stream>)); &read_line<test::stream>));
} }
void
testBuffer()
{
flat_buffer b;
b.max_size(1000);
auto db = dynamic_buffer_ref(b);
BEAST_EXPECT(db.max_size() == 1000);
BEAST_EXPECT(db.size() == 0);
BEAST_EXPECT(db.capacity() == 0);
db.prepare(512);
BEAST_EXPECT(db.size() == 0);
BEAST_EXPECT(db.capacity() == 512);
db.commit(12);
BEAST_EXPECT(db.size() == 12);
BEAST_EXPECT(db.capacity() == 512);
BEAST_EXPECT(buffer_size(db.data()) == 12);
db.consume(12);
BEAST_EXPECT(db.size() == 0);
BEAST_EXPECT(db.capacity() == 512);
}
void run() override void run() override
{ {
testJavadocs(); testJavadocs();
testBuffer();
} }
}; };

View File

@@ -10,7 +10,7 @@
// Test that header file is self-contained. // Test that header file is self-contained.
#include <boost/beast/core/flat_buffer.hpp> #include <boost/beast/core/flat_buffer.hpp>
#include "buffer_test.hpp" #include "test_buffer.hpp"
#include <boost/beast/core/ostream.hpp> #include <boost/beast/core/ostream.hpp>
#include <boost/beast/core/read_size.hpp> #include <boost/beast/core/read_size.hpp>

View File

@@ -10,7 +10,7 @@
// Test that header file is self-contained. // Test that header file is self-contained.
#include <boost/beast/core/flat_static_buffer.hpp> #include <boost/beast/core/flat_static_buffer.hpp>
#include "buffer_test.hpp" #include "test_buffer.hpp"
#include <boost/beast/core/buffer_size.hpp> #include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/ostream.hpp> #include <boost/beast/core/ostream.hpp>

View File

@@ -15,7 +15,7 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include "buffer_test.hpp" #include "test_buffer.hpp"
namespace boost { namespace boost {
namespace beast { namespace beast {

View File

@@ -10,7 +10,7 @@
// Test that header file is self-contained. // Test that header file is self-contained.
#include <boost/beast/core/multi_buffer.hpp> #include <boost/beast/core/multi_buffer.hpp>
#include "buffer_test.hpp" #include "test_buffer.hpp"
#include <boost/beast/core/buffer_size.hpp> #include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/ostream.hpp> #include <boost/beast/core/ostream.hpp>

View File

@@ -10,7 +10,7 @@
// Test that header file is self-contained. // Test that header file is self-contained.
#include <boost/beast/core/static_buffer.hpp> #include <boost/beast/core/static_buffer.hpp>
#include "buffer_test.hpp" #include "test_buffer.hpp"
#include <boost/beast/core/buffer_size.hpp> #include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/ostream.hpp> #include <boost/beast/core/ostream.hpp>

View File

@@ -7,8 +7,8 @@
// Official repository: https://github.com/boostorg/beast // Official repository: https://github.com/boostorg/beast
// //
#ifndef BOOST_BEAST_BUFFER_TEST_HPP #ifndef BOOST_BEAST_TEST_BUFFER_HPP
#define BOOST_BEAST_BUFFER_TEST_HPP #define BOOST_BEAST_TEST_BUFFER_HPP
#include <boost/beast/core/detail/config.hpp> #include <boost/beast/core/detail/config.hpp>
#include <boost/beast/_experimental/unit_test/suite.hpp> #include <boost/beast/_experimental/unit_test/suite.hpp>