From 98834967c3c1ef352738c5f0042b79119213968b Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Thu, 7 Feb 2019 20:57:50 -0800 Subject: [PATCH] dynamic_buffer_ref tests and tidy --- CHANGELOG.md | 6 +++++ .../boost/beast/core/dynamic_buffer_ref.hpp | 3 +++ test/beast/core/CMakeLists.txt | 2 +- test/beast/core/buffers_adaptor.cpp | 2 +- test/beast/core/buffers_cat.cpp | 2 +- test/beast/core/buffers_prefix.cpp | 2 +- test/beast/core/buffers_range.cpp | 2 +- test/beast/core/buffers_suffix.cpp | 2 +- test/beast/core/dynamic_buffer_ref.cpp | 22 +++++++++++++++++++ test/beast/core/flat_buffer.cpp | 2 +- test/beast/core/flat_static_buffer.cpp | 2 +- test/beast/core/make_printable.cpp | 2 +- test/beast/core/multi_buffer.cpp | 2 +- test/beast/core/static_buffer.cpp | 2 +- .../core/{buffer_test.hpp => test_buffer.hpp} | 4 ++-- 15 files changed, 44 insertions(+), 13 deletions(-) rename test/beast/core/{buffer_test.hpp => test_buffer.hpp} (99%) diff --git a/CHANGELOG.md b/CHANGELOG.md index f75ac1b2..2347a31f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +Version 212: + +* dynamic_buffer_ref tests and tidy + +-------------------------------------------------------------------------------- + Version 211: * close_socket is in stream_traits.hpp diff --git a/include/boost/beast/core/dynamic_buffer_ref.hpp b/include/boost/beast/core/dynamic_buffer_ref.hpp index 5c17f4c9..523b1329 100644 --- a/include/boost/beast/core/dynamic_buffer_ref.hpp +++ b/include/boost/beast/core/dynamic_buffer_ref.hpp @@ -44,6 +44,9 @@ public: dynamic_buffer_ref_wrapper( dynamic_buffer_ref_wrapper&&) = default; + dynamic_buffer_ref_wrapper( + dynamic_buffer_ref_wrapper const&) = default; + explicit dynamic_buffer_ref_wrapper( DynamicBuffer& b) noexcept diff --git a/test/beast/core/CMakeLists.txt b/test/beast/core/CMakeLists.txt index d481211c..bc43c50d 100644 --- a/test/beast/core/CMakeLists.txt +++ b/test/beast/core/CMakeLists.txt @@ -16,7 +16,7 @@ add_executable (tests-beast-core ${EXTRAS_FILES} ${TEST_MAIN} Jamfile - buffer_test.hpp + test_buffer.hpp file_test.hpp stream_tests.hpp test_handler.hpp diff --git a/test/beast/core/buffers_adaptor.cpp b/test/beast/core/buffers_adaptor.cpp index 9ecd8c04..0c850a1d 100644 --- a/test/beast/core/buffers_adaptor.cpp +++ b/test/beast/core/buffers_adaptor.cpp @@ -10,7 +10,7 @@ // Test that header file is self-contained. #include -#include "buffer_test.hpp" +#include "test_buffer.hpp" #include #include diff --git a/test/beast/core/buffers_cat.cpp b/test/beast/core/buffers_cat.cpp index c48460a2..663480e9 100644 --- a/test/beast/core/buffers_cat.cpp +++ b/test/beast/core/buffers_cat.cpp @@ -10,7 +10,7 @@ // Test that header file is self-contained. #include -#include "buffer_test.hpp" +#include "test_buffer.hpp" #include #include diff --git a/test/beast/core/buffers_prefix.cpp b/test/beast/core/buffers_prefix.cpp index 641b0b31..fdeac592 100644 --- a/test/beast/core/buffers_prefix.cpp +++ b/test/beast/core/buffers_prefix.cpp @@ -10,7 +10,7 @@ // Test that header file is self-contained. #include -#include "buffer_test.hpp" +#include "test_buffer.hpp" #include #include diff --git a/test/beast/core/buffers_range.cpp b/test/beast/core/buffers_range.cpp index 5f7ec887..02bee52e 100644 --- a/test/beast/core/buffers_range.cpp +++ b/test/beast/core/buffers_range.cpp @@ -10,7 +10,7 @@ // Test that header file is self-contained. #include -#include "buffer_test.hpp" +#include "test_buffer.hpp" #include diff --git a/test/beast/core/buffers_suffix.cpp b/test/beast/core/buffers_suffix.cpp index de08a968..8a33c47e 100644 --- a/test/beast/core/buffers_suffix.cpp +++ b/test/beast/core/buffers_suffix.cpp @@ -10,7 +10,7 @@ // Test that header file is self-contained. #include -#include "buffer_test.hpp" +#include "test_buffer.hpp" #include #include diff --git a/test/beast/core/dynamic_buffer_ref.cpp b/test/beast/core/dynamic_buffer_ref.cpp index a0b6785d..ef5a39f2 100644 --- a/test/beast/core/dynamic_buffer_ref.cpp +++ b/test/beast/core/dynamic_buffer_ref.cpp @@ -39,9 +39,31 @@ public: &read_line)); } + 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 { testJavadocs(); + testBuffer(); } }; diff --git a/test/beast/core/flat_buffer.cpp b/test/beast/core/flat_buffer.cpp index ab1a22dc..723d33a5 100644 --- a/test/beast/core/flat_buffer.cpp +++ b/test/beast/core/flat_buffer.cpp @@ -10,7 +10,7 @@ // Test that header file is self-contained. #include -#include "buffer_test.hpp" +#include "test_buffer.hpp" #include #include diff --git a/test/beast/core/flat_static_buffer.cpp b/test/beast/core/flat_static_buffer.cpp index 2995fe24..b9529763 100644 --- a/test/beast/core/flat_static_buffer.cpp +++ b/test/beast/core/flat_static_buffer.cpp @@ -10,7 +10,7 @@ // Test that header file is self-contained. #include -#include "buffer_test.hpp" +#include "test_buffer.hpp" #include #include diff --git a/test/beast/core/make_printable.cpp b/test/beast/core/make_printable.cpp index 55160da6..98cadf07 100644 --- a/test/beast/core/make_printable.cpp +++ b/test/beast/core/make_printable.cpp @@ -15,7 +15,7 @@ #include #include -#include "buffer_test.hpp" +#include "test_buffer.hpp" namespace boost { namespace beast { diff --git a/test/beast/core/multi_buffer.cpp b/test/beast/core/multi_buffer.cpp index c276b58f..2e5fa957 100644 --- a/test/beast/core/multi_buffer.cpp +++ b/test/beast/core/multi_buffer.cpp @@ -10,7 +10,7 @@ // Test that header file is self-contained. #include -#include "buffer_test.hpp" +#include "test_buffer.hpp" #include #include diff --git a/test/beast/core/static_buffer.cpp b/test/beast/core/static_buffer.cpp index d5033fc8..294e566c 100644 --- a/test/beast/core/static_buffer.cpp +++ b/test/beast/core/static_buffer.cpp @@ -10,7 +10,7 @@ // Test that header file is self-contained. #include -#include "buffer_test.hpp" +#include "test_buffer.hpp" #include #include diff --git a/test/beast/core/buffer_test.hpp b/test/beast/core/test_buffer.hpp similarity index 99% rename from test/beast/core/buffer_test.hpp rename to test/beast/core/test_buffer.hpp index 2e0a4b9d..da705069 100644 --- a/test/beast/core/buffer_test.hpp +++ b/test/beast/core/test_buffer.hpp @@ -7,8 +7,8 @@ // Official repository: https://github.com/boostorg/beast // -#ifndef BOOST_BEAST_BUFFER_TEST_HPP -#define BOOST_BEAST_BUFFER_TEST_HPP +#ifndef BOOST_BEAST_TEST_BUFFER_HPP +#define BOOST_BEAST_TEST_BUFFER_HPP #include #include