summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/asio/src/tests/unit/buffer.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2021-11-15 04:15:13 +1100
committer Vas Crabb <vas@vastheman.com>2021-11-15 04:15:13 +1100
commit44ec6d2e0ee569202b75b73eea40972595866779 (patch)
treeb286443c264704198789514e0594dc24b3ca9f96 /3rdparty/asio/src/tests/unit/buffer.cpp
parent137f254b918f1f1ebee43dfbed86793b0dae73eb (diff)
3rdparty: Updated ASIO to version 1.20.0.
The doc folder isn't included as it's pretty big. This required include/asio/detail/win_iocp_socket_accept_op.hpp due to mismatched order in the member declarations and initialiser list for the win_iocp_socket_accept_op class. I reversed the declaration order so it matches win_iocp_socket_move_accept_op.
Diffstat (limited to '3rdparty/asio/src/tests/unit/buffer.cpp')
-rw-r--r--3rdparty/asio/src/tests/unit/buffer.cpp283
1 files changed, 273 insertions, 10 deletions
diff --git a/3rdparty/asio/src/tests/unit/buffer.cpp b/3rdparty/asio/src/tests/unit/buffer.cpp
index b28533059ca..f66a8f0122e 100644
--- a/3rdparty/asio/src/tests/unit/buffer.cpp
+++ b/3rdparty/asio/src/tests/unit/buffer.cpp
@@ -2,7 +2,7 @@
// buffer.cpp
// ~~~~~~~~~~
//
-// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff 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)
@@ -62,18 +62,17 @@ void test()
std::vector<mutable_buffer> mutable_buffer_sequence;
std::vector<const_buffer> const_buffer_sequence;
#if defined(ASIO_HAS_STD_STRING_VIEW)
-# if defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
- std::experimental::string_view string_view_data(string_data);
-# else // defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
std::string_view string_view_data(string_data);
-# endif // defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
-#endif // defined(ASIO_HAS_STD_STRING_VIEW)
+#elif defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
+ std::experimental::string_view string_view_data(string_data);
+#endif // defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
// mutable_buffer constructors.
mutable_buffer mb1;
mutable_buffer mb2(void_ptr_data, 1024);
mutable_buffer mb3(mb1);
+ (void)mb3;
// mutable_buffer functions.
@@ -110,7 +109,9 @@ void test()
const_buffer cb1;
const_buffer cb2(const_void_ptr_data, 1024);
const_buffer cb3(cb1);
+ (void)cb3;
const_buffer cb4(mb1);
+ (void)cb4;
// const_buffer functions.
@@ -204,10 +205,10 @@ void test()
mb1 = buffer(string_data, 1024);
cb1 = buffer(const_string_data);
cb1 = buffer(const_string_data, 1024);
-#if defined(ASIO_HAS_STD_STRING_VIEW)
+#if defined(ASIO_HAS_STRING_VIEW)
cb1 = buffer(string_view_data);
cb1 = buffer(string_view_data, 1024);
-#endif // defined(ASIO_HAS_STD_STRING_VIEW)
+#endif // defined(ASIO_HAS_STRING_VIEW)
// buffer_copy function overloads.
@@ -321,6 +322,7 @@ void test()
std::size_t size40 = db3.max_size();
(void)size40;
+#if !defined(ASIO_NO_DYNAMIC_BUFFER_V1)
dynamic_string_buffer<char, std::string::traits_type,
std::string::allocator_type>::const_buffers_type
cb5 = db1.data();
@@ -339,9 +341,35 @@ void test()
db1.commit(1024);
db3.commit(1024);
+#endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1)
+
+ dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type>::mutable_buffers_type
+ mb7 = db1.data(0, 1);
+ (void)mb7;
+ dynamic_vector_buffer<char, std::allocator<char> >::mutable_buffers_type
+ mb8 = db3.data(0, 1);
+ (void)mb8;
+
+ dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type>::const_buffers_type
+ cb7 = static_cast<const dynamic_string_buffer<char,
+ std::string::traits_type,
+ std::string::allocator_type>&>(db1).data(0, 1);
+ (void)cb7;
+ dynamic_vector_buffer<char, std::allocator<char> >::const_buffers_type
+ cb8 = static_cast<const dynamic_vector_buffer<char,
+ std::allocator<char> >&>(db3).data(0, 1);
+ (void)cb8;
+
+ db1.grow(1024);
+ db3.grow(1024);
- db1.consume(1024);
- db3.consume(1024);
+ db1.shrink(1024);
+ db3.shrink(1024);
+
+ db1.consume(0);
+ db3.consume(0);
}
catch (std::exception&)
{
@@ -559,9 +587,244 @@ void test()
//------------------------------------------------------------------------------
+namespace buffer_sequence {
+
+using namespace asio;
+using namespace std;
+
+struct valid_const_a
+{
+ typedef const_buffer* const_iterator;
+ typedef const_buffer value_type;
+ const_buffer* begin() const { return 0; }
+ const_buffer* end() const { return 0; }
+};
+
+#if defined(ASIO_HAS_DECLTYPE)
+struct valid_const_b
+{
+ const_buffer* begin() const { return 0; }
+ const_buffer* end() const { return 0; }
+};
+#endif // defined(ASIO_HAS_DECLTYPE)
+
+struct valid_mutable_a
+{
+ typedef mutable_buffer* const_iterator;
+ typedef mutable_buffer value_type;
+ mutable_buffer* begin() const { return 0; }
+ mutable_buffer* end() const { return 0; }
+};
+
+#if defined(ASIO_HAS_DECLTYPE)
+struct valid_mutable_b
+{
+ mutable_buffer* begin() const { return 0; }
+ mutable_buffer* end() const { return 0; }
+};
+#endif // defined(ASIO_HAS_DECLTYPE)
+
+struct invalid_const_a
+{
+ typedef int value_type;
+ int* begin() const { return 0; }
+ const_buffer* end() const { return 0; }
+};
+
+struct invalid_const_b
+{
+ typedef const_buffer value_type;
+ const_buffer* begin() const { return 0; }
+};
+
+struct invalid_const_c
+{
+ typedef const_buffer value_type;
+ const_buffer* end() const { return 0; }
+};
+
+#if defined(ASIO_HAS_DECLTYPE)
+struct invalid_const_d
+{
+ int* begin() const { return 0; }
+ const_buffer* end() const { return 0; }
+};
+
+struct invalid_const_e
+{
+ const_buffer* begin() const { return 0; }
+};
+
+struct invalid_const_f
+{
+ const_buffer* end() const { return 0; }
+};
+#endif // defined(ASIO_HAS_DECLTYPE)
+
+struct invalid_mutable_a
+{
+ typedef int value_type;
+ int* begin() const { return 0; }
+ mutable_buffer* end() const { return 0; }
+};
+
+struct invalid_mutable_b
+{
+ typedef mutable_buffer value_type;
+ mutable_buffer* begin() const { return 0; }
+};
+
+struct invalid_mutable_c
+{
+ typedef mutable_buffer value_type;
+ mutable_buffer* end() const { return 0; }
+};
+
+#if defined(ASIO_HAS_DECLTYPE)
+struct invalid_mutable_d
+{
+ int* begin() const { return 0; }
+ mutable_buffer* end() const { return 0; }
+};
+
+struct invalid_mutable_e
+{
+ mutable_buffer* begin() const { return 0; }
+};
+
+struct invalid_mutable_f
+{
+ mutable_buffer* end() const { return 0; }
+};
+#endif // defined(ASIO_HAS_DECLTYPE)
+
+void test()
+{
+ ASIO_CHECK(is_const_buffer_sequence<const_buffer>::value);
+ ASIO_CHECK(!is_mutable_buffer_sequence<const_buffer>::value);
+
+ const_buffer b1;
+ ASIO_CHECK(buffer_sequence_begin(b1) == &b1);
+ ASIO_CHECK(buffer_sequence_end(b1) == &b1 + 1);
+
+ ASIO_CHECK(is_const_buffer_sequence<mutable_buffer>::value);
+ ASIO_CHECK(is_mutable_buffer_sequence<mutable_buffer>::value);
+
+ mutable_buffer b2;
+ ASIO_CHECK(buffer_sequence_begin(b2) == &b2);
+ ASIO_CHECK(buffer_sequence_end(b2) == &b2 + 1);
+
+#if !defined(ASIO_NO_DEPRECATED)
+ ASIO_CHECK(is_const_buffer_sequence<const_buffers_1>::value);
+ ASIO_CHECK(!is_mutable_buffer_sequence<const_buffers_1>::value);
+
+ const_buffers_1 b3(0, 0);
+ ASIO_CHECK(buffer_sequence_begin(b3) == &b3);
+ ASIO_CHECK(buffer_sequence_end(b3) == &b3 + 1);
+
+ ASIO_CHECK(is_const_buffer_sequence<mutable_buffers_1>::value);
+ ASIO_CHECK(is_mutable_buffer_sequence<mutable_buffers_1>::value);
+
+ mutable_buffers_1 b4(0, 0);
+ ASIO_CHECK(buffer_sequence_begin(b4) == &b4);
+ ASIO_CHECK(buffer_sequence_end(b4) == &b4 + 1);
+#endif // !defined(ASIO_NO_DEPRECATED)
+
+ ASIO_CHECK(is_const_buffer_sequence<vector<const_buffer> >::value);
+ ASIO_CHECK(!is_mutable_buffer_sequence<vector<const_buffer> >::value);
+
+ vector<const_buffer> b5;
+ ASIO_CHECK(buffer_sequence_begin(b5) == b5.begin());
+ ASIO_CHECK(buffer_sequence_end(b5) == b5.end());
+
+ ASIO_CHECK(is_const_buffer_sequence<vector<mutable_buffer> >::value);
+ ASIO_CHECK(is_mutable_buffer_sequence<vector<mutable_buffer> >::value);
+
+ vector<mutable_buffer> b6;
+ ASIO_CHECK(buffer_sequence_begin(b6) == b6.begin());
+ ASIO_CHECK(buffer_sequence_end(b6) == b6.end());
+
+ ASIO_CHECK(is_const_buffer_sequence<valid_const_a>::value);
+ ASIO_CHECK(!is_mutable_buffer_sequence<valid_const_a>::value);
+
+ valid_const_a b7;
+ ASIO_CHECK(buffer_sequence_begin(b7) == b7.begin());
+ ASIO_CHECK(buffer_sequence_end(b7) == b7.end());
+
+#if defined(ASIO_HAS_DECLTYPE)
+ ASIO_CHECK(is_const_buffer_sequence<valid_const_b>::value);
+ ASIO_CHECK(!is_mutable_buffer_sequence<valid_const_b>::value);
+
+ valid_const_b b8;
+ ASIO_CHECK(buffer_sequence_begin(b8) == b8.begin());
+ ASIO_CHECK(buffer_sequence_end(b8) == b8.end());
+#endif // defined(ASIO_HAS_DECLTYPE)
+
+ ASIO_CHECK(is_const_buffer_sequence<valid_mutable_a>::value);
+ ASIO_CHECK(is_mutable_buffer_sequence<valid_mutable_a>::value);
+
+ valid_mutable_a b9;
+ ASIO_CHECK(buffer_sequence_begin(b9) == b9.begin());
+ ASIO_CHECK(buffer_sequence_end(b9) == b9.end());
+
+#if defined(ASIO_HAS_DECLTYPE)
+ ASIO_CHECK(is_const_buffer_sequence<valid_mutable_b>::value);
+ ASIO_CHECK(is_mutable_buffer_sequence<valid_mutable_b>::value);
+
+ valid_mutable_b b10;
+ ASIO_CHECK(buffer_sequence_begin(b10) == b10.begin());
+ ASIO_CHECK(buffer_sequence_end(b10) == b10.end());
+#endif // defined(ASIO_HAS_DECLTYPE)
+
+ ASIO_CHECK(!is_const_buffer_sequence<invalid_const_a>::value);
+ ASIO_CHECK(!is_mutable_buffer_sequence<invalid_const_a>::value);
+
+ ASIO_CHECK(!is_const_buffer_sequence<invalid_const_b>::value);
+ ASIO_CHECK(!is_mutable_buffer_sequence<invalid_const_b>::value);
+
+ ASIO_CHECK(!is_const_buffer_sequence<invalid_const_c>::value);
+ ASIO_CHECK(!is_mutable_buffer_sequence<invalid_const_c>::value);
+
+#if defined(ASIO_HAS_DECLTYPE)
+ ASIO_CHECK(!is_const_buffer_sequence<invalid_const_d>::value);
+ ASIO_CHECK(!is_mutable_buffer_sequence<invalid_const_d>::value);
+
+ ASIO_CHECK(!is_const_buffer_sequence<invalid_const_e>::value);
+ ASIO_CHECK(!is_mutable_buffer_sequence<invalid_const_e>::value);
+
+ ASIO_CHECK(!is_const_buffer_sequence<invalid_const_f>::value);
+ ASIO_CHECK(!is_mutable_buffer_sequence<invalid_const_f>::value);
+#endif // defined(ASIO_HAS_DECLTYPE)
+
+ ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_a>::value);
+ ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_a>::value);
+
+ ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_b>::value);
+ ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_b>::value);
+
+ ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_c>::value);
+ ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_c>::value);
+
+#if defined(ASIO_HAS_DECLTYPE)
+ ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_d>::value);
+ ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_d>::value);
+
+ ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_e>::value);
+ ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_e>::value);
+
+ ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_f>::value);
+ ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_f>::value);
+#endif // defined(ASIO_HAS_DECLTYPE)
+}
+
+} // namespace buffer_sequence
+
+//------------------------------------------------------------------------------
+
ASIO_TEST_SUITE
(
"buffer",
ASIO_COMPILE_TEST_CASE(buffer_compile::test)
ASIO_TEST_CASE(buffer_copy_runtime::test)
+ ASIO_TEST_CASE(buffer_sequence::test)
)