diff options
Diffstat (limited to '3rdparty/asio/src/tests/unit')
206 files changed, 25174 insertions, 3227 deletions
diff --git a/3rdparty/asio/src/tests/unit/.gitignore b/3rdparty/asio/src/tests/unit/.gitignore deleted file mode 100644 index e11b5d56f36..00000000000 --- a/3rdparty/asio/src/tests/unit/.gitignore +++ /dev/null @@ -1,74 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*.ilk -*.manifest -*.pdb -*.tds -associated_allocator -associated_executor -async_result -basic_datagram_socket -basic_deadline_timer -basic_raw_socket -basic_seq_packet_socket -basic_serial_port -basic_signal_set -basic_socket_acceptor -basic_stream_socket -basic_streambuf -basic_waitable_timer -bind_executor -buffer -buffered_read_stream -buffered_stream -buffered_write_stream -buffers_iterator -completion_condition -connect -coroutine -datagram_socket_service -deadline_timer -deadline_timer_service -defer -dispatch -error -error_handler -execution_context -executor -executor_work_guard -high_resolution_timer -io_context -io_service -is_read_buffered -is_write_buffered -packaged_task -placeholders -post -raw_socket_service -read -read_at -read_until -seq_packet_socket_service -serial_port -serial_port_base -serial_port_service -signal_set -signal_set_service -socket_acceptor_service -socket_base -steady_timer -strand -stream_socket_service -streambuf -system_timer -thread -time_traits -use_future -uses_executor -wait_traits -waitable_timer_service -write -write_at diff --git a/3rdparty/asio/src/tests/unit/any_completion_executor.cpp b/3rdparty/asio/src/tests/unit/any_completion_executor.cpp new file mode 100644 index 00000000000..5d1d5b1e271 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/any_completion_executor.cpp @@ -0,0 +1,463 @@ +// +// any_completion_executor.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/any_completion_executor.hpp" + +#include <cstring> +#include <functional> +#include "asio/system_executor.hpp" +#include "asio/thread_pool.hpp" +#include "unit_test.hpp" + +using namespace asio; +namespace bindns = std; + +static bool next_nothrow_new_fails = false; + +void* operator new(std::size_t n, + const std::nothrow_t&) noexcept +{ + if (next_nothrow_new_fails) + { + next_nothrow_new_fails = false; + return 0; + } + return ::operator new(n); +} + +struct fat_executor +{ + fat_executor(int id) + : id_(id) + { + std::memset(data_, 0, sizeof(data_)); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const fat_executor& a, + const fat_executor& b) noexcept + { + return a.id_ == b.id_; + } + + friend bool operator!=(const fat_executor& a, + const fat_executor& b) noexcept + { + return a.id_ != b.id_; + } + + int id_; + unsigned char data_[1024]; +}; + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +template <typename F> +struct execute_member<fat_executor, F> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = false; + typedef void result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +template <> +struct equality_comparable<fat_executor> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +} // namespace traits +} // namespace asio + +void increment(int* count) +{ + ++(*count); +} + +void any_completion_executor_construction_test() +{ + thread_pool pool(1); + asio::nullptr_t null_ptr = asio::nullptr_t(); + + asio::any_completion_executor ex1; + + ASIO_CHECK(ex1.target<void>() == 0); + ASIO_CHECK(ex1 == null_ptr); + + asio::any_completion_executor ex2(null_ptr); + + ASIO_CHECK(ex2.target<void>() == 0); + ASIO_CHECK(ex2 == null_ptr); + ASIO_CHECK(ex2 == ex1); + + asio::any_completion_executor ex3(pool.executor()); + + ASIO_CHECK(ex3.target<void>() != 0); + ASIO_CHECK(ex3 != null_ptr); + ASIO_CHECK(ex3 != ex1); + + asio::any_completion_executor ex4(ex1); + + ASIO_CHECK(ex4.target<void>() == 0); + ASIO_CHECK(ex4 == null_ptr); + ASIO_CHECK(ex4 == ex1); + + asio::any_completion_executor ex5(ex3); + + ASIO_CHECK(ex5.target<void>() != 0); + ASIO_CHECK(ex5 != null_ptr); + ASIO_CHECK(ex5 == ex3); + + asio::any_completion_executor ex6 = fat_executor(1); + + ASIO_CHECK(ex6.target<void>() != 0); + ASIO_CHECK(ex6 != null_ptr); + ASIO_CHECK(ex6 != ex1); + + asio::any_completion_executor ex7 = fat_executor(1); + + ASIO_CHECK(ex7.target<void>() != 0); + ASIO_CHECK(ex7 != null_ptr); + ASIO_CHECK(ex7 != ex1); + ASIO_CHECK(ex7 == ex6); + + asio::any_completion_executor ex8 = fat_executor(2); + + ASIO_CHECK(ex8.target<void>() != 0); + ASIO_CHECK(ex8 != null_ptr); + ASIO_CHECK(ex8 != ex1); + ASIO_CHECK(ex8 != ex6); + ASIO_CHECK(ex8 != ex7); + + asio::any_completion_executor ex9(ex6); + + ASIO_CHECK(ex9.target<void>() != 0); + ASIO_CHECK(ex9 != null_ptr); + ASIO_CHECK(ex9 != ex1); + ASIO_CHECK(ex9 == ex6); + ASIO_CHECK(ex9 == ex7); + ASIO_CHECK(ex9 != ex8); + + asio::any_completion_executor ex10(std::move(ex1)); + + ASIO_CHECK(ex10.target<void>() == 0); + ASIO_CHECK(ex10 == null_ptr); + ASIO_CHECK(ex1.target<void>() == 0); + ASIO_CHECK(ex1 == null_ptr); + + asio::any_completion_executor ex11(std::move(ex3)); + + ASIO_CHECK(ex11.target<void>() != 0); + ASIO_CHECK(ex11 != null_ptr); + ASIO_CHECK(ex3.target<void>() == 0); + ASIO_CHECK(ex3 == null_ptr); + ASIO_CHECK(ex11 == ex5); + + asio::any_completion_executor ex12(std::move(ex7)); + + ASIO_CHECK(ex12.target<void>() != 0); + ASIO_CHECK(ex12 != null_ptr); + ASIO_CHECK(ex7.target<void>() == 0); + ASIO_CHECK(ex7 == null_ptr); + ASIO_CHECK(ex12 == ex6); + ASIO_CHECK(ex12 != ex8); +} + +void any_completion_executor_nothrow_construction_test() +{ + thread_pool pool(1); + asio::nullptr_t null_ptr = asio::nullptr_t(); + + asio::any_completion_executor ex1; + + ASIO_CHECK(ex1.target<void>() == 0); + ASIO_CHECK(ex1 == null_ptr); + + asio::any_completion_executor ex2(null_ptr); + + ASIO_CHECK(ex2.target<void>() == 0); + ASIO_CHECK(ex2 == null_ptr); + ASIO_CHECK(ex2 == ex1); + + asio::any_completion_executor ex3(std::nothrow, pool.executor()); + + ASIO_CHECK(ex3.target<void>() != 0); + ASIO_CHECK(ex3 != null_ptr); + ASIO_CHECK(ex3 != ex1); + + asio::any_completion_executor ex4(std::nothrow, ex1); + + ASIO_CHECK(ex4.target<void>() == 0); + ASIO_CHECK(ex4 == null_ptr); + ASIO_CHECK(ex4 == ex1); + + asio::any_completion_executor ex5(std::nothrow, ex3); + + ASIO_CHECK(ex5.target<void>() != 0); + ASIO_CHECK(ex5 != null_ptr); + ASIO_CHECK(ex5 == ex3); + + asio::any_completion_executor ex6(std::nothrow, fat_executor(1)); + + ASIO_CHECK(ex6.target<void>() != 0); + ASIO_CHECK(ex6 != null_ptr); + ASIO_CHECK(ex6 != ex1); + + asio::any_completion_executor ex7(std::nothrow, fat_executor(1)); + + ASIO_CHECK(ex7.target<void>() != 0); + ASIO_CHECK(ex7 != null_ptr); + ASIO_CHECK(ex7 != ex1); + ASIO_CHECK(ex7 == ex6); + + asio::any_completion_executor ex8(std::nothrow, fat_executor(2)); + + ASIO_CHECK(ex8.target<void>() != 0); + ASIO_CHECK(ex8 != null_ptr); + ASIO_CHECK(ex8 != ex1); + ASIO_CHECK(ex8 != ex6); + ASIO_CHECK(ex8 != ex7); + + asio::any_completion_executor ex9(std::nothrow, ex6); + + ASIO_CHECK(ex9.target<void>() != 0); + ASIO_CHECK(ex9 != null_ptr); + ASIO_CHECK(ex9 != ex1); + ASIO_CHECK(ex9 == ex6); + ASIO_CHECK(ex9 == ex7); + ASIO_CHECK(ex9 != ex8); + + asio::any_completion_executor ex10(std::nothrow, std::move(ex1)); + + ASIO_CHECK(ex10.target<void>() == 0); + ASIO_CHECK(ex10 == null_ptr); + ASIO_CHECK(ex1.target<void>() == 0); + ASIO_CHECK(ex1 == null_ptr); + + asio::any_completion_executor ex11(std::nothrow, std::move(ex3)); + + ASIO_CHECK(ex11.target<void>() != 0); + ASIO_CHECK(ex11 != null_ptr); + ASIO_CHECK(ex3.target<void>() == 0); + ASIO_CHECK(ex3 == null_ptr); + ASIO_CHECK(ex11 == ex5); + + asio::any_completion_executor ex12(std::nothrow, std::move(ex7)); + + ASIO_CHECK(ex12.target<void>() != 0); + ASIO_CHECK(ex12 != null_ptr); + ASIO_CHECK(ex7.target<void>() == 0); + ASIO_CHECK(ex7 == null_ptr); + ASIO_CHECK(ex12 == ex6); + ASIO_CHECK(ex12 != ex8); + + next_nothrow_new_fails = true; + asio::any_completion_executor ex13(std::nothrow, fat_executor(3)); + + ASIO_CHECK(ex13.target<void>() == 0); + ASIO_CHECK(ex13 == null_ptr); + ASIO_CHECK(ex13 == ex1); +} + +void any_completion_executor_assignment_test() +{ + thread_pool pool(1); + asio::nullptr_t null_ptr = asio::nullptr_t(); + + asio::any_completion_executor ex1; + + asio::any_completion_executor ex2; + ex2 = null_ptr; + + ASIO_CHECK(ex2.target<void>() == 0); + + asio::any_completion_executor ex3; + ex3 = pool.executor(); + + ASIO_CHECK(ex3.target<void>() != 0); + + asio::any_completion_executor ex4; + ex4 = ex1; + + ASIO_CHECK(ex4.target<void>() == 0); + ASIO_CHECK(ex4 == ex1); + + ex4 = ex3; + + ASIO_CHECK(ex4.target<void>() != 0); + ASIO_CHECK(ex4 == ex3); + + asio::any_completion_executor ex5; + ex5 = fat_executor(1); + + ASIO_CHECK(ex5.target<void>() != 0); + ASIO_CHECK(ex5 != null_ptr); + ASIO_CHECK(ex5 != ex1); + + asio::any_completion_executor ex6; + ex6 = fat_executor(1); + + ASIO_CHECK(ex6.target<void>() != 0); + ASIO_CHECK(ex6 != null_ptr); + ASIO_CHECK(ex6 != ex1); + ASIO_CHECK(ex6 == ex5); + + ex6 = fat_executor(2); + + ASIO_CHECK(ex6.target<void>() != 0); + ASIO_CHECK(ex6 != null_ptr); + ASIO_CHECK(ex6 != ex1); + ASIO_CHECK(ex6 != ex5); + + asio::any_completion_executor ex7; + ex7 = ex5; + + ASIO_CHECK(ex7.target<void>() != 0); + ASIO_CHECK(ex7 != null_ptr); + ASIO_CHECK(ex7 != ex1); + ASIO_CHECK(ex7 == ex5); + ASIO_CHECK(ex7 != ex6); + + asio::any_completion_executor ex8; + ex8 = std::move(ex1); + + ASIO_CHECK(ex8.target<void>() == 0); + ASIO_CHECK(ex1.target<void>() == 0); + + ex8 = std::move(ex3); + + ASIO_CHECK(ex8.target<void>() != 0); + ASIO_CHECK(ex3.target<void>() == 0); + ASIO_CHECK(ex8 == ex4); + + ex8 = std::move(ex5); + + ASIO_CHECK(ex8.target<void>() != 0); + ASIO_CHECK(ex5.target<void>() == 0); + ASIO_CHECK(ex8 == ex7); +} + +void any_completion_executor_swap_test() +{ + thread_pool pool1(1); + thread_pool pool2(1); + + asio::any_completion_executor ex1(pool1.executor()); + asio::any_completion_executor ex2(pool2.executor()); + + asio::any_completion_executor ex3(ex1); + asio::any_completion_executor ex4(ex2); + + ASIO_CHECK(ex3 == ex1); + ASIO_CHECK(ex4 == ex2); + + ex3.swap(ex4); + + ASIO_CHECK(ex3 == ex2); + ASIO_CHECK(ex4 == ex1); + + execution::swap(ex3, ex4); + + ASIO_CHECK(ex3 == ex1); + ASIO_CHECK(ex4 == ex2); +} + +void any_completion_executor_query_test() +{ + thread_pool pool(1); + asio::any_completion_executor ex(pool.executor()); + + ASIO_CHECK( + asio::query(ex, asio::execution::blocking) + == asio::execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ex, asio::execution::blocking.possibly) + == asio::execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ex, asio::execution::outstanding_work) + == asio::execution::outstanding_work.untracked); + + ASIO_CHECK( + asio::query(ex, asio::execution::outstanding_work.untracked) + == asio::execution::outstanding_work.untracked); + + ASIO_CHECK( + asio::query(ex, asio::execution::relationship) + == asio::execution::relationship.fork); + + ASIO_CHECK( + asio::query(ex, asio::execution::relationship.fork) + == asio::execution::relationship.fork); +} + +void any_completion_executor_execute_test() +{ + int count = 0; + thread_pool pool(1); + asio::any_completion_executor ex(pool.executor()); + + ex.execute(bindns::bind(increment, &count)); + + asio::prefer(ex, asio::execution::blocking.possibly).execute( + bindns::bind(increment, &count)); + + asio::prefer(ex, + asio::execution::blocking.possibly, + asio::execution::outstanding_work.tracked + ).execute(bindns::bind(increment, &count)); + + asio::prefer(ex, + asio::execution::blocking.possibly, + asio::execution::outstanding_work.untracked + ).execute(bindns::bind(increment, &count)); + + asio::prefer(ex, + asio::execution::blocking.possibly, + asio::execution::outstanding_work.untracked, + asio::execution::relationship.continuation + ).execute(bindns::bind(increment, &count)); + + pool.wait(); + + ASIO_CHECK(count == 5); +} + +ASIO_TEST_SUITE +( + "any_completion_executor", + ASIO_TEST_CASE(any_completion_executor_construction_test) + ASIO_TEST_CASE(any_completion_executor_nothrow_construction_test) + ASIO_TEST_CASE(any_completion_executor_assignment_test) + ASIO_TEST_CASE(any_completion_executor_swap_test) + ASIO_TEST_CASE(any_completion_executor_query_test) + ASIO_TEST_CASE(any_completion_executor_execute_test) +) diff --git a/3rdparty/asio/src/tests/unit/any_completion_handler.cpp b/3rdparty/asio/src/tests/unit/any_completion_handler.cpp new file mode 100644 index 00000000000..887402de8d3 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/any_completion_handler.cpp @@ -0,0 +1,260 @@ +// +// any_completion_handler.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/any_completion_handler.hpp" + +#include "unit_test.hpp" + +#include <functional> +#include "asio/bind_allocator.hpp" +#include "asio/bind_cancellation_slot.hpp" +#include "asio/bind_executor.hpp" +#include "asio/bind_immediate_executor.hpp" +#include "asio/error.hpp" +#include "asio/thread_pool.hpp" + +namespace bindns = std; + +void increment(int* count) +{ + ++(*count); +} + +void any_completion_handler_construction_test() +{ + int count = 0; + asio::nullptr_t null_ptr = asio::nullptr_t(); + + asio::any_completion_handler<void()> h1; + + ASIO_CHECK(!h1); + ASIO_CHECK(h1 == null_ptr); + + asio::any_completion_handler<void()> h2(null_ptr); + + ASIO_CHECK(!h2); + ASIO_CHECK(h2 == null_ptr); + + asio::any_completion_handler<void()> h3( + bindns::bind(&increment, &count)); + + ASIO_CHECK(!!h3); + ASIO_CHECK(h3 != null_ptr); + + asio::any_completion_handler<void()> h4(std::move(h1)); + + ASIO_CHECK(!h4); + ASIO_CHECK(h4 == null_ptr); + ASIO_CHECK(!h1); + ASIO_CHECK(h1 == null_ptr); + + asio::any_completion_handler<void()> h5(std::move(h3)); + + ASIO_CHECK(!!h5); + ASIO_CHECK(h5 != null_ptr); + ASIO_CHECK(!h3); + ASIO_CHECK(h3 == null_ptr); + + asio::any_completion_handler<void()> h6(std::move(h5)); + + ASIO_CHECK(!!h6); + ASIO_CHECK(h6 != null_ptr); + ASIO_CHECK(!h5); + ASIO_CHECK(h5 == null_ptr); +} + +void any_completion_handler_assignment_test() +{ + int count = 0; + asio::nullptr_t null_ptr = asio::nullptr_t(); + + asio::any_completion_handler<void()> h1; + + asio::any_completion_handler<void()> h2; + h2 = null_ptr; + + ASIO_CHECK(!h2); + + asio::any_completion_handler<void()> h3; + h3 = bindns::bind(&increment, &count); + + ASIO_CHECK(!!h3); + + asio::any_completion_handler<void()> h4; + h4 = std::move(h1); + + ASIO_CHECK(!h4); + ASIO_CHECK(!h1); + + h4 = std::move(h3); + + ASIO_CHECK(!!h4); + ASIO_CHECK(!h3); +} + +template <typename T> +class handler_allocator +{ +public: + using value_type = T; + + explicit handler_allocator(int* count) + : count_(count) + { + } + + template <typename U> + handler_allocator(const handler_allocator<U>& other) noexcept + : count_(other.count_) + { + } + + bool operator==(const handler_allocator& other) const noexcept + { + return &count_ == &other.count_; + } + + bool operator!=(const handler_allocator& other) const noexcept + { + return &count_ != &other.count_; + } + + T* allocate(std::size_t n) const + { + ++(*count_); + return static_cast<T*>(::operator new(sizeof(T) * n)); + } + + void deallocate(T* p, std::size_t /*n*/) const + { + ::operator delete(p); + } + +private: + template <typename> friend class handler_allocator; + + int* count_; +}; + +class cancel_handler +{ +public: + explicit cancel_handler(int* count) + : count_(count) + { + } + + void operator()(asio::cancellation_type_t) + { + ++(*count_); + } + +private: + int* count_; +}; + +void any_completion_handler_associator_test() +{ + typedef asio::any_completion_handler<void()> handler_type; + + int count = 0; + int alloc_count = 0; + int cancel_count = 0; + asio::thread_pool pool(1); + asio::cancellation_signal sig; + + asio::any_completion_handler<void()> h1( + asio::bind_allocator(handler_allocator<char>(&alloc_count), + asio::bind_cancellation_slot(sig.slot(), + asio::bind_executor(pool.get_executor(), + asio::bind_immediate_executor(asio::system_executor(), + bindns::bind(&increment, &count)))))); + + ASIO_CHECK(alloc_count == 1); + + ASIO_REBIND_ALLOC(asio::associated_allocator<handler_type>::type, + char) alloc1(asio::get_associated_allocator(h1)); + alloc1.deallocate(alloc1.allocate(1), 1); + + ASIO_CHECK(alloc_count == 2); + + asio::associated_cancellation_slot<handler_type>::type slot1 + = asio::get_associated_cancellation_slot(h1); + + ASIO_CHECK(slot1.is_connected()); + + slot1.emplace<cancel_handler>(&cancel_count); + + ASIO_CHECK(cancel_count == 0); + + sig.emit(asio::cancellation_type::terminal); + + ASIO_CHECK(cancel_count == 1); + + asio::associated_executor<handler_type>::type ex1 + = asio::get_associated_executor(h1); + + ASIO_CHECK(ex1 == pool.get_executor()); + + asio::associated_immediate_executor< + handler_type, asio::thread_pool::executor_type>::type ex2 + = asio::get_associated_immediate_executor(h1, pool.get_executor()); + + ASIO_CHECK(ex2 == asio::system_executor()); +} + +void increment_with_error(asio::error_code ec, + asio::error_code* out_ec, int* count) +{ + *out_ec = ec; + ++(*count); +} + +void any_completion_handler_invocation_test() +{ + int count = 0; + asio::error_code ec; + + asio::any_completion_handler<void()> h1( + bindns::bind(&increment, &count)); + + ASIO_CHECK(count == 0); + + std::move(h1)(); + + ASIO_CHECK(count == 1); + + asio::any_completion_handler<void(asio::error_code)> h2( + bindns::bind(&increment_with_error, + bindns::placeholders::_1, &ec, &count)); + + ASIO_CHECK(!ec); + ASIO_CHECK(count == 1); + + std::move(h2)(asio::error::eof); + + ASIO_CHECK(ec == asio::error::eof); + ASIO_CHECK(count == 2); +} + +ASIO_TEST_SUITE +( + "any_completion_handler", + ASIO_TEST_CASE(any_completion_handler_construction_test) + ASIO_TEST_CASE(any_completion_handler_assignment_test) + ASIO_TEST_CASE(any_completion_handler_associator_test) + ASIO_TEST_CASE(any_completion_handler_invocation_test) +) diff --git a/3rdparty/asio/src/tests/unit/any_io_executor.cpp b/3rdparty/asio/src/tests/unit/any_io_executor.cpp new file mode 100644 index 00000000000..e0a32ba3838 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/any_io_executor.cpp @@ -0,0 +1,515 @@ +// +// any_io_executor.cpp +// ~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/any_io_executor.hpp" + +#include <cstring> +#include <functional> +#include "asio/system_executor.hpp" +#include "asio/thread_pool.hpp" +#include "unit_test.hpp" + +using namespace asio; +namespace bindns = std; + +static bool next_nothrow_new_fails = false; + +void* operator new(std::size_t n, + const std::nothrow_t&) noexcept +{ + if (next_nothrow_new_fails) + { + next_nothrow_new_fails = false; + return 0; + } + return ::operator new(n); +} + +struct fat_executor +{ + fat_executor(int id) + : id_(id) + { + std::memset(data_, 0, sizeof(data_)); + } + + template <typename F> + void execute(const F&) const + { + } + + execution_context& query(execution::context_t) const noexcept + { + return asio::query(system_executor(), execution::context); + } + + constexpr static execution::blocking_t::never_t query( + execution::blocking_t) noexcept + { + return execution::blocking.never; + } + + friend bool operator==(const fat_executor& a, + const fat_executor& b) noexcept + { + return a.id_ == b.id_; + } + + friend bool operator!=(const fat_executor& a, + const fat_executor& b) noexcept + { + return a.id_ != b.id_; + } + + int id_; + unsigned char data_[1024]; +}; + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +template <typename F> +struct execute_member<fat_executor, F> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = false; + typedef void result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +template <> +struct query_member<fat_executor, execution::context_t> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + typedef execution_context& result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT) + +template <typename Property> +struct query_static_constexpr_member<fat_executor, Property, + typename asio::enable_if< + asio::is_convertible< + Property, + asio::execution::blocking_t + >::value + >::type + > +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + typedef execution::blocking_t::never_t result_type; + + static constexpr result_type value() noexcept + { + return result_type(); + } +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +template <> +struct equality_comparable<fat_executor> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +} // namespace traits +} // namespace asio + +void increment(int* count) +{ + ++(*count); +} + +void any_io_executor_construction_test() +{ + thread_pool pool(1); + asio::nullptr_t null_ptr = asio::nullptr_t(); + + asio::any_io_executor ex1; + + ASIO_CHECK(ex1.target<void>() == 0); + ASIO_CHECK(ex1 == null_ptr); + + asio::any_io_executor ex2(null_ptr); + + ASIO_CHECK(ex2.target<void>() == 0); + ASIO_CHECK(ex2 == null_ptr); + ASIO_CHECK(ex2 == ex1); + + asio::any_io_executor ex3(pool.executor()); + + ASIO_CHECK(ex3.target<void>() != 0); + ASIO_CHECK(ex3 != null_ptr); + ASIO_CHECK(ex3 != ex1); + + asio::any_io_executor ex4(ex1); + + ASIO_CHECK(ex4.target<void>() == 0); + ASIO_CHECK(ex4 == null_ptr); + ASIO_CHECK(ex4 == ex1); + + asio::any_io_executor ex5(ex3); + + ASIO_CHECK(ex5.target<void>() != 0); + ASIO_CHECK(ex5 != null_ptr); + ASIO_CHECK(ex5 == ex3); + + asio::any_io_executor ex6 = fat_executor(1); + + ASIO_CHECK(ex6.target<void>() != 0); + ASIO_CHECK(ex6 != null_ptr); + ASIO_CHECK(ex6 != ex1); + + asio::any_io_executor ex7 = fat_executor(1); + + ASIO_CHECK(ex7.target<void>() != 0); + ASIO_CHECK(ex7 != null_ptr); + ASIO_CHECK(ex7 != ex1); + ASIO_CHECK(ex7 == ex6); + + asio::any_io_executor ex8 = fat_executor(2); + + ASIO_CHECK(ex8.target<void>() != 0); + ASIO_CHECK(ex8 != null_ptr); + ASIO_CHECK(ex8 != ex1); + ASIO_CHECK(ex8 != ex6); + ASIO_CHECK(ex8 != ex7); + + asio::any_io_executor ex9(ex6); + + ASIO_CHECK(ex9.target<void>() != 0); + ASIO_CHECK(ex9 != null_ptr); + ASIO_CHECK(ex9 != ex1); + ASIO_CHECK(ex9 == ex6); + ASIO_CHECK(ex9 == ex7); + ASIO_CHECK(ex9 != ex8); + + asio::any_io_executor ex10(std::move(ex1)); + + ASIO_CHECK(ex10.target<void>() == 0); + ASIO_CHECK(ex10 == null_ptr); + ASIO_CHECK(ex1.target<void>() == 0); + ASIO_CHECK(ex1 == null_ptr); + + asio::any_io_executor ex11(std::move(ex3)); + + ASIO_CHECK(ex11.target<void>() != 0); + ASIO_CHECK(ex11 != null_ptr); + ASIO_CHECK(ex3.target<void>() == 0); + ASIO_CHECK(ex3 == null_ptr); + ASIO_CHECK(ex11 == ex5); + + asio::any_io_executor ex12(std::move(ex7)); + + ASIO_CHECK(ex12.target<void>() != 0); + ASIO_CHECK(ex12 != null_ptr); + ASIO_CHECK(ex7.target<void>() == 0); + ASIO_CHECK(ex7 == null_ptr); + ASIO_CHECK(ex12 == ex6); + ASIO_CHECK(ex12 != ex8); +} + +void any_io_executor_nothrow_construction_test() +{ + thread_pool pool(1); + asio::nullptr_t null_ptr = asio::nullptr_t(); + + asio::any_io_executor ex1; + + ASIO_CHECK(ex1.target<void>() == 0); + ASIO_CHECK(ex1 == null_ptr); + + asio::any_io_executor ex2(null_ptr); + + ASIO_CHECK(ex2.target<void>() == 0); + ASIO_CHECK(ex2 == null_ptr); + ASIO_CHECK(ex2 == ex1); + + asio::any_io_executor ex3(std::nothrow, pool.executor()); + + ASIO_CHECK(ex3.target<void>() != 0); + ASIO_CHECK(ex3 != null_ptr); + ASIO_CHECK(ex3 != ex1); + + asio::any_io_executor ex4(std::nothrow, ex1); + + ASIO_CHECK(ex4.target<void>() == 0); + ASIO_CHECK(ex4 == null_ptr); + ASIO_CHECK(ex4 == ex1); + + asio::any_io_executor ex5(std::nothrow, ex3); + + ASIO_CHECK(ex5.target<void>() != 0); + ASIO_CHECK(ex5 != null_ptr); + ASIO_CHECK(ex5 == ex3); + + asio::any_io_executor ex6(std::nothrow, fat_executor(1)); + + ASIO_CHECK(ex6.target<void>() != 0); + ASIO_CHECK(ex6 != null_ptr); + ASIO_CHECK(ex6 != ex1); + + asio::any_io_executor ex7(std::nothrow, fat_executor(1)); + + ASIO_CHECK(ex7.target<void>() != 0); + ASIO_CHECK(ex7 != null_ptr); + ASIO_CHECK(ex7 != ex1); + ASIO_CHECK(ex7 == ex6); + + asio::any_io_executor ex8(std::nothrow, fat_executor(2)); + + ASIO_CHECK(ex8.target<void>() != 0); + ASIO_CHECK(ex8 != null_ptr); + ASIO_CHECK(ex8 != ex1); + ASIO_CHECK(ex8 != ex6); + ASIO_CHECK(ex8 != ex7); + + asio::any_io_executor ex9(std::nothrow, ex6); + + ASIO_CHECK(ex9.target<void>() != 0); + ASIO_CHECK(ex9 != null_ptr); + ASIO_CHECK(ex9 != ex1); + ASIO_CHECK(ex9 == ex6); + ASIO_CHECK(ex9 == ex7); + ASIO_CHECK(ex9 != ex8); + + asio::any_io_executor ex10(std::nothrow, std::move(ex1)); + + ASIO_CHECK(ex10.target<void>() == 0); + ASIO_CHECK(ex10 == null_ptr); + ASIO_CHECK(ex1.target<void>() == 0); + ASIO_CHECK(ex1 == null_ptr); + + asio::any_io_executor ex11(std::nothrow, std::move(ex3)); + + ASIO_CHECK(ex11.target<void>() != 0); + ASIO_CHECK(ex11 != null_ptr); + ASIO_CHECK(ex3.target<void>() == 0); + ASIO_CHECK(ex3 == null_ptr); + ASIO_CHECK(ex11 == ex5); + + asio::any_io_executor ex12(std::nothrow, std::move(ex7)); + + ASIO_CHECK(ex12.target<void>() != 0); + ASIO_CHECK(ex12 != null_ptr); + ASIO_CHECK(ex7.target<void>() == 0); + ASIO_CHECK(ex7 == null_ptr); + ASIO_CHECK(ex12 == ex6); + ASIO_CHECK(ex12 != ex8); + + next_nothrow_new_fails = true; + asio::any_io_executor ex13(std::nothrow, fat_executor(3)); + + ASIO_CHECK(ex13.target<void>() == 0); + ASIO_CHECK(ex13 == null_ptr); + ASIO_CHECK(ex13 == ex1); +} + +void any_io_executor_assignment_test() +{ + thread_pool pool(1); + asio::nullptr_t null_ptr = asio::nullptr_t(); + + asio::any_io_executor ex1; + + asio::any_io_executor ex2; + ex2 = null_ptr; + + ASIO_CHECK(ex2.target<void>() == 0); + + asio::any_io_executor ex3; + ex3 = pool.executor(); + + ASIO_CHECK(ex3.target<void>() != 0); + + asio::any_io_executor ex4; + ex4 = ex1; + + ASIO_CHECK(ex4.target<void>() == 0); + ASIO_CHECK(ex4 == ex1); + + ex4 = ex3; + + ASIO_CHECK(ex4.target<void>() != 0); + ASIO_CHECK(ex4 == ex3); + + asio::any_io_executor ex5; + ex5 = fat_executor(1); + + ASIO_CHECK(ex5.target<void>() != 0); + ASIO_CHECK(ex5 != null_ptr); + ASIO_CHECK(ex5 != ex1); + + asio::any_io_executor ex6; + ex6 = fat_executor(1); + + ASIO_CHECK(ex6.target<void>() != 0); + ASIO_CHECK(ex6 != null_ptr); + ASIO_CHECK(ex6 != ex1); + ASIO_CHECK(ex6 == ex5); + + ex6 = fat_executor(2); + + ASIO_CHECK(ex6.target<void>() != 0); + ASIO_CHECK(ex6 != null_ptr); + ASIO_CHECK(ex6 != ex1); + ASIO_CHECK(ex6 != ex5); + + asio::any_io_executor ex7; + ex7 = ex5; + + ASIO_CHECK(ex7.target<void>() != 0); + ASIO_CHECK(ex7 != null_ptr); + ASIO_CHECK(ex7 != ex1); + ASIO_CHECK(ex7 == ex5); + ASIO_CHECK(ex7 != ex6); + + asio::any_io_executor ex8; + ex8 = std::move(ex1); + + ASIO_CHECK(ex8.target<void>() == 0); + ASIO_CHECK(ex1.target<void>() == 0); + + ex8 = std::move(ex3); + + ASIO_CHECK(ex8.target<void>() != 0); + ASIO_CHECK(ex3.target<void>() == 0); + ASIO_CHECK(ex8 == ex4); + + ex8 = std::move(ex5); + + ASIO_CHECK(ex8.target<void>() != 0); + ASIO_CHECK(ex5.target<void>() == 0); + ASIO_CHECK(ex8 == ex7); +} + +void any_io_executor_swap_test() +{ + thread_pool pool1(1); + thread_pool pool2(1); + + asio::any_io_executor ex1(pool1.executor()); + asio::any_io_executor ex2(pool2.executor()); + + asio::any_io_executor ex3(ex1); + asio::any_io_executor ex4(ex2); + + ASIO_CHECK(ex3 == ex1); + ASIO_CHECK(ex4 == ex2); + + ex3.swap(ex4); + + ASIO_CHECK(ex3 == ex2); + ASIO_CHECK(ex4 == ex1); + + execution::swap(ex3, ex4); + + ASIO_CHECK(ex3 == ex1); + ASIO_CHECK(ex4 == ex2); +} + +void any_io_executor_query_test() +{ + thread_pool pool(1); + asio::any_io_executor ex(pool.executor()); + + ASIO_CHECK( + asio::query(ex, asio::execution::blocking) + == asio::execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ex, asio::execution::blocking.possibly) + == asio::execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ex, asio::execution::outstanding_work) + == asio::execution::outstanding_work.untracked); + + ASIO_CHECK( + asio::query(ex, asio::execution::outstanding_work.untracked) + == asio::execution::outstanding_work.untracked); + + ASIO_CHECK( + asio::query(ex, asio::execution::relationship) + == asio::execution::relationship.fork); + + ASIO_CHECK( + asio::query(ex, asio::execution::relationship.fork) + == asio::execution::relationship.fork); +} + +void any_io_executor_execute_test() +{ + int count = 0; + thread_pool pool(1); + asio::any_io_executor ex(pool.executor()); + + ex.execute(bindns::bind(increment, &count)); + + asio::prefer(ex, asio::execution::blocking.possibly).execute( + bindns::bind(increment, &count)); + + asio::require(ex, asio::execution::blocking.never).execute( + bindns::bind(increment, &count)); + + asio::require( + asio::prefer(ex, asio::execution::outstanding_work.tracked), + asio::execution::blocking.never + ).execute(bindns::bind(increment, &count)); + + asio::require( + asio::prefer(ex, + asio::execution::outstanding_work.untracked), + asio::execution::blocking.never + ).execute(bindns::bind(increment, &count)); + + asio::require( + asio::prefer(ex, + asio::execution::outstanding_work.untracked, + asio::execution::relationship.continuation), + asio::execution::blocking.never + ).execute(bindns::bind(increment, &count)); + + pool.wait(); + + ASIO_CHECK(count == 6); +} + +ASIO_TEST_SUITE +( + "any_io_executor", + ASIO_TEST_CASE(any_io_executor_construction_test) + ASIO_TEST_CASE(any_io_executor_nothrow_construction_test) + ASIO_TEST_CASE(any_io_executor_assignment_test) + ASIO_TEST_CASE(any_io_executor_swap_test) + ASIO_TEST_CASE(any_io_executor_query_test) + ASIO_TEST_CASE(any_io_executor_execute_test) +) diff --git a/3rdparty/asio/src/tests/unit/append.cpp b/3rdparty/asio/src/tests/unit/append.cpp new file mode 100644 index 00000000000..9aa00e3bfa4 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/append.cpp @@ -0,0 +1,58 @@ +// +// append.cpp +// ~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/append.hpp" + +#include "asio/bind_executor.hpp" +#include "asio/io_context.hpp" +#include "asio/post.hpp" +#include "asio/system_timer.hpp" +#include "unit_test.hpp" + +void append_test() +{ + asio::io_context io1; + asio::io_context io2; + asio::system_timer timer1(io1); + int count = 0; + + timer1.expires_after(asio::chrono::seconds(0)); + timer1.async_wait( + asio::append( + asio::bind_executor(io2.get_executor(), + [&count](asio::error_code, int a, int b) + { + ++count; + ASIO_CHECK(a == 123); + ASIO_CHECK(b == 321); + }), 123, 321)); + + ASIO_CHECK(count == 0); + + io1.run(); + + ASIO_CHECK(count == 0); + + io2.run(); + + ASIO_CHECK(count == 1); +} + +ASIO_TEST_SUITE +( + "append", + ASIO_TEST_CASE(append_test) +) diff --git a/3rdparty/asio/src/tests/unit/archetypes/async_ops.hpp b/3rdparty/asio/src/tests/unit/archetypes/async_ops.hpp index 331d8ac32ef..3c2b1308bd8 100644 --- a/3rdparty/asio/src/tests/unit/archetypes/async_ops.hpp +++ b/3rdparty/asio/src/tests/unit/archetypes/async_ops.hpp @@ -1,8 +1,8 @@ // -// async_ops.hpp -// ~~~~~~~~~~~~~ +// archetypes/async_ops.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -11,30 +11,22 @@ #ifndef ARCHETYPES_ASYNC_OPS_HPP #define ARCHETYPES_ASYNC_OPS_HPP -#include <asio/associated_allocator.hpp> -#include <asio/associated_executor.hpp> -#include <asio/async_result.hpp> -#include <asio/error.hpp> - -#if defined(ASIO_HAS_BOOST_BIND) -# include <boost/bind.hpp> -#else // defined(ASIO_HAS_BOOST_BIND) -# include <functional> -#endif // defined(ASIO_HAS_BOOST_BIND) +#include <functional> +#include "asio/associated_allocator.hpp" +#include "asio/associated_executor.hpp" +#include "asio/async_result.hpp" +#include "asio/error.hpp" namespace archetypes { -#if defined(ASIO_HAS_BOOST_BIND) -namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; -#endif // defined(ASIO_HAS_BOOST_BIND) template <typename CompletionToken> -ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) -async_op_0(ASIO_MOVE_ARG(CompletionToken) token) +typename asio::async_result<asio::decay_t<CompletionToken>, + void()>::return_type +async_op_0(CompletionToken&& token) { - typedef typename asio::async_completion<CompletionToken, + typedef typename asio::async_result<asio::decay_t<CompletionToken>, void()>::completion_handler_type handler_type; asio::async_completion<CompletionToken, @@ -46,16 +38,17 @@ async_op_0(ASIO_MOVE_ARG(CompletionToken) token) typename asio::associated_executor<handler_type>::type ex = asio::get_associated_executor(completion.completion_handler); - ex.post(ASIO_MOVE_CAST(handler_type)(completion.completion_handler), a); + ex.post(static_cast<handler_type&&>(completion.completion_handler), a); return completion.result.get(); } template <typename CompletionToken> -ASIO_INITFN_RESULT_TYPE(CompletionToken, void(asio::error_code)) +typename asio::async_result<asio::decay_t<CompletionToken>, + void(asio::error_code)>::return_type async_op_ec_0(bool ok, ASIO_MOVE_ARG(CompletionToken) token) { - typedef typename asio::async_completion<CompletionToken, + typedef typename asio::async_result<asio::decay_t<CompletionToken>, void(asio::error_code)>::completion_handler_type handler_type; asio::async_completion<CompletionToken, @@ -71,14 +64,14 @@ async_op_ec_0(bool ok, ASIO_MOVE_ARG(CompletionToken) token) { ex.post( bindns::bind( - ASIO_MOVE_CAST(handler_type)(completion.completion_handler), + static_cast<handler_type&&>(completion.completion_handler), asio::error_code()), a); } else { ex.post( bindns::bind( - ASIO_MOVE_CAST(handler_type)(completion.completion_handler), + static_cast<handler_type&&>(completion.completion_handler), asio::error_code(asio::error::operation_aborted)), a); } @@ -86,10 +79,11 @@ async_op_ec_0(bool ok, ASIO_MOVE_ARG(CompletionToken) token) } template <typename CompletionToken> -ASIO_INITFN_RESULT_TYPE(CompletionToken, void(std::exception_ptr)) +typename asio::async_result<asio::decay_t<CompletionToken>, + void(std::exception_ptr)>::return_type async_op_ex_0(bool ok, ASIO_MOVE_ARG(CompletionToken) token) { - typedef typename asio::async_completion<CompletionToken, + typedef typename asio::async_result<asio::decay_t<CompletionToken>, void(std::exception_ptr)>::completion_handler_type handler_type; asio::async_completion<CompletionToken, @@ -105,14 +99,14 @@ async_op_ex_0(bool ok, ASIO_MOVE_ARG(CompletionToken) token) { ex.post( bindns::bind( - ASIO_MOVE_CAST(handler_type)(completion.completion_handler), + static_cast<handler_type&&>(completion.completion_handler), std::exception_ptr()), a); } else { ex.post( bindns::bind( - ASIO_MOVE_CAST(handler_type)(completion.completion_handler), + static_cast<handler_type&&>(completion.completion_handler), std::make_exception_ptr(std::runtime_error("blah"))), a); } @@ -120,10 +114,11 @@ async_op_ex_0(bool ok, ASIO_MOVE_ARG(CompletionToken) token) } template <typename CompletionToken> -ASIO_INITFN_RESULT_TYPE(CompletionToken, void(int)) +typename asio::async_result<asio::decay_t<CompletionToken>, + void(int)>::return_type async_op_1(ASIO_MOVE_ARG(CompletionToken) token) { - typedef typename asio::async_completion<CompletionToken, + typedef typename asio::async_result<asio::decay_t<CompletionToken>, void(int)>::completion_handler_type handler_type; asio::async_completion<CompletionToken, @@ -137,18 +132,18 @@ async_op_1(ASIO_MOVE_ARG(CompletionToken) token) ex.post( bindns::bind( - ASIO_MOVE_CAST(handler_type)(completion.completion_handler), + static_cast<handler_type&&>(completion.completion_handler), 42), a); return completion.result.get(); } template <typename CompletionToken> -ASIO_INITFN_RESULT_TYPE(CompletionToken, - void(asio::error_code, int)) +typename asio::async_result<asio::decay_t<CompletionToken>, + void(asio::error_code, int)>::return_type async_op_ec_1(bool ok, ASIO_MOVE_ARG(CompletionToken) token) { - typedef typename asio::async_completion<CompletionToken, + typedef typename asio::async_result<asio::decay_t<CompletionToken>, void(asio::error_code, int)>::completion_handler_type handler_type; @@ -165,14 +160,14 @@ async_op_ec_1(bool ok, ASIO_MOVE_ARG(CompletionToken) token) { ex.post( bindns::bind( - ASIO_MOVE_CAST(handler_type)(completion.completion_handler), + static_cast<handler_type&&>(completion.completion_handler), asio::error_code(), 42), a); } else { ex.post( bindns::bind( - ASIO_MOVE_CAST(handler_type)(completion.completion_handler), + static_cast<handler_type&&>(completion.completion_handler), asio::error_code(asio::error::operation_aborted), 0), a); } @@ -181,10 +176,11 @@ async_op_ec_1(bool ok, ASIO_MOVE_ARG(CompletionToken) token) } template <typename CompletionToken> -ASIO_INITFN_RESULT_TYPE(CompletionToken, void(std::exception_ptr, int)) +typename asio::async_result<asio::decay_t<CompletionToken>, + void(std::exception_ptr, int)>::return_type async_op_ex_1(bool ok, ASIO_MOVE_ARG(CompletionToken) token) { - typedef typename asio::async_completion<CompletionToken, + typedef typename asio::async_result<asio::decay_t<CompletionToken>, void(std::exception_ptr, int)>::completion_handler_type handler_type; @@ -201,14 +197,14 @@ async_op_ex_1(bool ok, ASIO_MOVE_ARG(CompletionToken) token) { ex.post( bindns::bind( - ASIO_MOVE_CAST(handler_type)(completion.completion_handler), + static_cast<handler_type&&>(completion.completion_handler), std::exception_ptr(), 42), a); } else { ex.post( bindns::bind( - ASIO_MOVE_CAST(handler_type)(completion.completion_handler), + static_cast<handler_type&&>(completion.completion_handler), std::make_exception_ptr(std::runtime_error("blah")), 0), a); } @@ -216,10 +212,11 @@ async_op_ex_1(bool ok, ASIO_MOVE_ARG(CompletionToken) token) } template <typename CompletionToken> -ASIO_INITFN_RESULT_TYPE(CompletionToken, void(int, double)) +typename asio::async_result<asio::decay_t<CompletionToken>, + void(int, double)>::return_type async_op_2(ASIO_MOVE_ARG(CompletionToken) token) { - typedef typename asio::async_completion<CompletionToken, + typedef typename asio::async_result<asio::decay_t<CompletionToken>, void(int, double)>::completion_handler_type handler_type; asio::async_completion<CompletionToken, @@ -233,18 +230,18 @@ async_op_2(ASIO_MOVE_ARG(CompletionToken) token) ex.post( bindns::bind( - ASIO_MOVE_CAST(handler_type)(completion.completion_handler), + static_cast<handler_type&&>(completion.completion_handler), 42, 2.0), a); return completion.result.get(); } template <typename CompletionToken> -ASIO_INITFN_RESULT_TYPE(CompletionToken, - void(asio::error_code, int, double)) +typename asio::async_result<asio::decay_t<CompletionToken>, + void(asio::error_code, int, double)>::return_type async_op_ec_2(bool ok, ASIO_MOVE_ARG(CompletionToken) token) { - typedef typename asio::async_completion<CompletionToken, + typedef typename asio::async_result<asio::decay_t<CompletionToken>, void(asio::error_code, int, double)>::completion_handler_type handler_type; @@ -261,14 +258,14 @@ async_op_ec_2(bool ok, ASIO_MOVE_ARG(CompletionToken) token) { ex.post( bindns::bind( - ASIO_MOVE_CAST(handler_type)(completion.completion_handler), + static_cast<handler_type&&>(completion.completion_handler), asio::error_code(), 42, 2.0), a); } else { ex.post( bindns::bind( - ASIO_MOVE_CAST(handler_type)(completion.completion_handler), + static_cast<handler_type&&>(completion.completion_handler), asio::error_code(asio::error::operation_aborted), 0, 0.0), a); } @@ -277,11 +274,11 @@ async_op_ec_2(bool ok, ASIO_MOVE_ARG(CompletionToken) token) } template <typename CompletionToken> -ASIO_INITFN_RESULT_TYPE(CompletionToken, - void(std::exception_ptr, int, double)) +typename asio::async_result<asio::decay_t<CompletionToken>, + void(std::exception_ptr, int, double)>::return_type async_op_ex_2(bool ok, ASIO_MOVE_ARG(CompletionToken) token) { - typedef typename asio::async_completion<CompletionToken, + typedef typename asio::async_result<asio::decay_t<CompletionToken>, void(std::exception_ptr, int, double)>::completion_handler_type handler_type; @@ -298,14 +295,14 @@ async_op_ex_2(bool ok, ASIO_MOVE_ARG(CompletionToken) token) { ex.post( bindns::bind( - ASIO_MOVE_CAST(handler_type)(completion.completion_handler), + static_cast<handler_type&&>(completion.completion_handler), std::exception_ptr(), 42, 2.0), a); } else { ex.post( bindns::bind( - ASIO_MOVE_CAST(handler_type)(completion.completion_handler), + static_cast<handler_type&&>(completion.completion_handler), std::make_exception_ptr(std::runtime_error("blah")), 0, 0.0), a); } @@ -313,10 +310,11 @@ async_op_ex_2(bool ok, ASIO_MOVE_ARG(CompletionToken) token) } template <typename CompletionToken> -ASIO_INITFN_RESULT_TYPE(CompletionToken, void(int, double, char)) +typename asio::async_result<asio::decay_t<CompletionToken>, + void(int, double, char)>::return_type async_op_3(ASIO_MOVE_ARG(CompletionToken) token) { - typedef typename asio::async_completion<CompletionToken, + typedef typename asio::async_result<asio::decay_t<CompletionToken>, void(int, double, char)>::completion_handler_type handler_type; asio::async_completion<CompletionToken, @@ -330,18 +328,18 @@ async_op_3(ASIO_MOVE_ARG(CompletionToken) token) ex.post( bindns::bind( - ASIO_MOVE_CAST(handler_type)(completion.completion_handler), + static_cast<handler_type&&>(completion.completion_handler), 42, 2.0, 'a'), a); return completion.result.get(); } template <typename CompletionToken> -ASIO_INITFN_RESULT_TYPE(CompletionToken, - void(asio::error_code, int, double, char)) +typename asio::async_result<asio::decay_t<CompletionToken>, + void(asio::error_code, int, double, char)>::return_type async_op_ec_3(bool ok, ASIO_MOVE_ARG(CompletionToken) token) { - typedef typename asio::async_completion<CompletionToken, + typedef typename asio::async_result<asio::decay_t<CompletionToken>, void(asio::error_code, int, double, char)>::completion_handler_type handler_type; @@ -358,14 +356,14 @@ async_op_ec_3(bool ok, ASIO_MOVE_ARG(CompletionToken) token) { ex.post( bindns::bind( - ASIO_MOVE_CAST(handler_type)(completion.completion_handler), + static_cast<handler_type&&>(completion.completion_handler), asio::error_code(), 42, 2.0, 'a'), a); } else { ex.post( bindns::bind( - ASIO_MOVE_CAST(handler_type)(completion.completion_handler), + static_cast<handler_type&&>(completion.completion_handler), asio::error_code(asio::error::operation_aborted), 0, 0.0, 'z'), a); } @@ -374,11 +372,11 @@ async_op_ec_3(bool ok, ASIO_MOVE_ARG(CompletionToken) token) } template <typename CompletionToken> -ASIO_INITFN_RESULT_TYPE(CompletionToken, - void(std::exception_ptr, int, double, char)) +typename asio::async_result<asio::decay_t<CompletionToken>, + void(std::exception_ptr, int, double, char)>::return_type async_op_ex_3(bool ok, ASIO_MOVE_ARG(CompletionToken) token) { - typedef typename asio::async_completion<CompletionToken, + typedef typename asio::async_result<asio::decay_t<CompletionToken>, void(std::exception_ptr, int, double, char)>::completion_handler_type handler_type; @@ -395,14 +393,14 @@ async_op_ex_3(bool ok, ASIO_MOVE_ARG(CompletionToken) token) { ex.post( bindns::bind( - ASIO_MOVE_CAST(handler_type)(completion.completion_handler), + static_cast<handler_type&&>(completion.completion_handler), std::exception_ptr(), 42, 2.0, 'a'), a); } else { ex.post( bindns::bind( - ASIO_MOVE_CAST(handler_type)(completion.completion_handler), + static_cast<handler_type&&>(completion.completion_handler), std::make_exception_ptr(std::runtime_error("blah")), 0, 0.0, 'z'), a); } diff --git a/3rdparty/asio/src/tests/unit/archetypes/async_result.hpp b/3rdparty/asio/src/tests/unit/archetypes/async_result.hpp index afd9e56f191..bfd9cf1aac2 100644 --- a/3rdparty/asio/src/tests/unit/archetypes/async_result.hpp +++ b/3rdparty/asio/src/tests/unit/archetypes/async_result.hpp @@ -2,7 +2,7 @@ // async_result.hpp // ~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -12,34 +12,79 @@ #define ARCHETYPES_ASYNC_RESULT_HPP #include <asio/async_result.hpp> +#include <asio/system_executor.hpp> namespace archetypes { +struct immediate_handler +{ +}; + struct lazy_handler { }; -struct concrete_handler +template <typename Signature> +struct concrete_handler; + +template <typename R, typename Arg1> +struct concrete_handler<R(Arg1)> { - concrete_handler(lazy_handler) + concrete_handler() { } - template <typename Arg1> - void operator()(Arg1) + void operator()(typename asio::decay<Arg1>::type) { } - template <typename Arg1, typename Arg2> - void operator()(Arg1, Arg2) + concrete_handler(concrete_handler&&) {} +private: + concrete_handler(const concrete_handler&); +}; + +template <typename R, typename Arg1, typename Arg2> +struct concrete_handler<R(Arg1, Arg2)> +{ + concrete_handler() { } -#if defined(ASIO_HAS_MOVE) - concrete_handler(concrete_handler&&) {} + void operator()(typename asio::decay<Arg1>::type, + typename asio::decay<Arg2>::type) + { + } +}; + +template <typename Signature> +struct immediate_concrete_handler : concrete_handler<Signature> +{ + typedef asio::system_executor immediate_executor_type; + + immediate_concrete_handler(immediate_handler) + { + } + + immediate_executor_type get_immediate_executor() const noexcept + { + return immediate_executor_type(); + } + + immediate_concrete_handler(immediate_concrete_handler&&) {} private: - concrete_handler(const concrete_handler&); -#endif // defined(ASIO_HAS_MOVE) + immediate_concrete_handler(const immediate_concrete_handler&); +}; + +template <typename Signature> +struct lazy_concrete_handler : concrete_handler<Signature> +{ + lazy_concrete_handler(lazy_handler) + { + } + + lazy_concrete_handler(lazy_concrete_handler&&) {} +private: + lazy_concrete_handler(const lazy_concrete_handler&); }; } // namespace archetypes @@ -47,11 +92,38 @@ private: namespace asio { template <typename Signature> +class async_result<archetypes::immediate_handler, Signature> +{ +public: + // The concrete completion handler type. + typedef archetypes::immediate_concrete_handler<Signature> + completion_handler_type; + + // The return type of the initiating function. + typedef void return_type; + + // Construct an async_result from a given handler. + explicit async_result(completion_handler_type&) + { + } + + // Obtain the value to be returned from the initiating function. + void get() + { + } + +private: + // Disallow copying and assignment. + async_result(const async_result&) = delete; + async_result& operator=(const async_result&) = delete; +}; + +template <typename Signature> class async_result<archetypes::lazy_handler, Signature> { public: // The concrete completion handler type. - typedef archetypes::concrete_handler completion_handler_type; + typedef archetypes::lazy_concrete_handler<Signature> completion_handler_type; // The return type of the initiating function. typedef int return_type; @@ -69,8 +141,8 @@ public: private: // Disallow copying and assignment. - async_result(const async_result&) ASIO_DELETED; - async_result& operator=(const async_result&) ASIO_DELETED; + async_result(const async_result&) = delete; + async_result& operator=(const async_result&) = delete; }; } // namespace asio diff --git a/3rdparty/asio/src/tests/unit/archetypes/deprecated_async_ops.hpp b/3rdparty/asio/src/tests/unit/archetypes/deprecated_async_ops.hpp deleted file mode 100644 index ee1cab939cd..00000000000 --- a/3rdparty/asio/src/tests/unit/archetypes/deprecated_async_ops.hpp +++ /dev/null @@ -1,345 +0,0 @@ -// -// deprecated_async_ops.hpp -// ~~~~~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 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) -// - -#ifndef ARCHETYPES_DEPRECATED_ASYNC_OPS_HPP -#define ARCHETYPES_DEPRECATED_ASYNC_OPS_HPP - -#include <asio/async_result.hpp> - -#if !defined(ASIO_NO_DEPRECATED) - -#include <asio/handler_type.hpp> -#include <asio/error.hpp> -#include <asio/io_context.hpp> - -#if defined(ASIO_HAS_BOOST_BIND) -# include <boost/bind.hpp> -#else // defined(ASIO_HAS_BOOST_BIND) -# include <functional> -#endif // defined(ASIO_HAS_BOOST_BIND) - -namespace archetypes { - -#if defined(ASIO_HAS_BOOST_BIND) -namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) -namespace bindns = std; -#endif // defined(ASIO_HAS_BOOST_BIND) - -template <typename CompletionToken> -typename asio::async_result< - typename asio::handler_type<CompletionToken, - void()>::type>::type -deprecated_async_op_0(asio::io_context& ctx, - ASIO_MOVE_ARG(CompletionToken) token) -{ - typedef typename asio::handler_type<CompletionToken, - void()>::type handler_type; - - handler_type handler(ASIO_MOVE_CAST(CompletionToken)(token)); - - asio::async_result<handler_type> result(handler); - - ctx.post(bindns::bind(ASIO_MOVE_CAST(handler_type)(handler))); - - return result.get(); -} - -template <typename CompletionToken> -typename asio::async_result< - typename asio::handler_type<CompletionToken, - void(asio::error_code)>::type>::type -deprecated_async_op_ec_0(asio::io_context& ctx, - bool ok, ASIO_MOVE_ARG(CompletionToken) token) -{ - typedef typename asio::handler_type<CompletionToken, - void(asio::error_code)>::type handler_type; - - handler_type handler(ASIO_MOVE_CAST(CompletionToken)(token)); - - asio::async_result<handler_type> result(handler); - - if (ok) - { - ctx.post(bindns::bind(ASIO_MOVE_CAST(handler_type)(handler), - asio::error_code())); - } - else - { - ctx.post(bindns::bind(ASIO_MOVE_CAST(handler_type)(handler), - asio::error_code(asio::error::operation_aborted))); - } - - return result.get(); -} - -template <typename CompletionToken> -typename asio::async_result< - typename asio::handler_type<CompletionToken, - void(std::exception_ptr)>::type>::type -deprecated_async_op_ex_0(asio::io_context& ctx, - bool ok, ASIO_MOVE_ARG(CompletionToken) token) -{ - typedef typename asio::handler_type<CompletionToken, - void(std::exception_ptr)>::type handler_type; - - handler_type handler(ASIO_MOVE_CAST(CompletionToken)(token)); - - asio::async_result<handler_type> result(handler); - - if (ok) - { - ctx.post(bindns::bind(ASIO_MOVE_CAST(handler_type)(handler), - std::exception_ptr())); - } - else - { - ctx.post(bindns::bind(ASIO_MOVE_CAST(handler_type)(handler), - std::make_exception_ptr(std::runtime_error("blah")))); - } - - return result.get(); -} - -template <typename CompletionToken> -typename asio::async_result< - typename asio::handler_type<CompletionToken, - void(int)>::type>::type -deprecated_async_op_1(asio::io_context& ctx, - ASIO_MOVE_ARG(CompletionToken) token) -{ - typedef typename asio::handler_type<CompletionToken, - void(int)>::type handler_type; - - handler_type handler(ASIO_MOVE_CAST(CompletionToken)(token)); - - asio::async_result<handler_type> result(handler); - - ctx.post(bindns::bind(ASIO_MOVE_CAST(handler_type)(handler), 42)); - - return result.get(); -} - -template <typename CompletionToken> -typename asio::async_result< - typename asio::handler_type<CompletionToken, - void(asio::error_code, int)>::type>::type -deprecated_async_op_ec_1(asio::io_context& ctx, - bool ok, ASIO_MOVE_ARG(CompletionToken) token) -{ - typedef typename asio::handler_type<CompletionToken, - void(asio::error_code, int)>::type handler_type; - - handler_type handler(ASIO_MOVE_CAST(CompletionToken)(token)); - - asio::async_result<handler_type> result(handler); - - if (ok) - { - ctx.post(bindns::bind(ASIO_MOVE_CAST(handler_type)(handler), - asio::error_code(), 42)); - } - else - { - ctx.post(bindns::bind(ASIO_MOVE_CAST(handler_type)(handler), - asio::error_code(asio::error::operation_aborted), 0)); - } - - return result.get(); -} - -template <typename CompletionToken> -typename asio::async_result< - typename asio::handler_type<CompletionToken, - void(std::exception_ptr, int)>::type>::type -deprecated_async_op_ex_1(asio::io_context& ctx, - bool ok, ASIO_MOVE_ARG(CompletionToken) token) -{ - typedef typename asio::handler_type<CompletionToken, - void(std::exception_ptr, int)>::type handler_type; - - handler_type handler(ASIO_MOVE_CAST(CompletionToken)(token)); - - asio::async_result<handler_type> result(handler); - - if (ok) - { - ctx.post(bindns::bind(ASIO_MOVE_CAST(handler_type)(handler), - std::exception_ptr(), 42)); - } - else - { - ctx.post(bindns::bind(ASIO_MOVE_CAST(handler_type)(handler), - std::make_exception_ptr(std::runtime_error("blah")), 0)); - } - - return result.get(); -} - -template <typename CompletionToken> -typename asio::async_result< - typename asio::handler_type<CompletionToken, - void(int, double)>::type>::type -deprecated_async_op_2(asio::io_context& ctx, - ASIO_MOVE_ARG(CompletionToken) token) -{ - typedef typename asio::handler_type<CompletionToken, - void(int, double)>::type handler_type; - - handler_type handler(ASIO_MOVE_CAST(CompletionToken)(token)); - - asio::async_result<handler_type> result(handler); - - ctx.post(bindns::bind(ASIO_MOVE_CAST(handler_type)(handler), - 42, 2.0)); - - return result.get(); -} - -template <typename CompletionToken> -typename asio::async_result< - typename asio::handler_type<CompletionToken, - void(asio::error_code, int, double)>::type>::type -deprecated_async_op_ec_2(asio::io_context& ctx, - bool ok, ASIO_MOVE_ARG(CompletionToken) token) -{ - typedef typename asio::handler_type<CompletionToken, - void(asio::error_code, int, double)>::type handler_type; - - handler_type handler(ASIO_MOVE_CAST(CompletionToken)(token)); - - asio::async_result<handler_type> result(handler); - - if (ok) - { - ctx.post(bindns::bind(ASIO_MOVE_CAST(handler_type)(handler), - asio::error_code(), 42, 2.0)); - } - else - { - ctx.post(bindns::bind(ASIO_MOVE_CAST(handler_type)(handler), - asio::error_code(asio::error::operation_aborted), - 0, 0.0)); - } - - return result.get(); -} - -template <typename CompletionToken> -typename asio::async_result< - typename asio::handler_type<CompletionToken, - void(std::exception_ptr, int, double)>::type>::type -deprecated_async_op_ex_2(asio::io_context& ctx, - bool ok, ASIO_MOVE_ARG(CompletionToken) token) -{ - typedef typename asio::handler_type<CompletionToken, - void(std::exception_ptr, int, double)>::type handler_type; - - handler_type handler(ASIO_MOVE_CAST(CompletionToken)(token)); - - asio::async_result<handler_type> result(handler); - - if (ok) - { - ctx.post(bindns::bind(ASIO_MOVE_CAST(handler_type)(handler), - std::exception_ptr(), 42, 2.0)); - } - else - { - ctx.post(bindns::bind(ASIO_MOVE_CAST(handler_type)(handler), - std::make_exception_ptr(std::runtime_error("blah")), 0, 0.0)); - } - - return result.get(); -} - -template <typename CompletionToken> -typename asio::async_result< - typename asio::handler_type<CompletionToken, - void(int, double, char)>::type>::type -deprecated_async_op_3(asio::io_context& ctx, - ASIO_MOVE_ARG(CompletionToken) token) -{ - typedef typename asio::handler_type<CompletionToken, - void(int, double, char)>::type handler_type; - - handler_type handler(ASIO_MOVE_CAST(CompletionToken)(token)); - - asio::async_result<handler_type> result(handler); - - ctx.post(bindns::bind(ASIO_MOVE_CAST(handler_type)(handler), - 42, 2.0, 'a')); - - return result.get(); -} - -template <typename CompletionToken> -typename asio::async_result< - typename asio::handler_type<CompletionToken, - void(asio::error_code, int, double, char)>::type>::type -deprecated_async_op_ec_3(asio::io_context& ctx, - bool ok, ASIO_MOVE_ARG(CompletionToken) token) -{ - typedef typename asio::handler_type<CompletionToken, - void(asio::error_code, int, double, char)>::type handler_type; - - handler_type handler(ASIO_MOVE_CAST(CompletionToken)(token)); - - asio::async_result<handler_type> result(handler); - - if (ok) - { - ctx.post(bindns::bind(ASIO_MOVE_CAST(handler_type)(handler), - asio::error_code(), 42, 2.0, 'a')); - } - else - { - ctx.post(bindns::bind(ASIO_MOVE_CAST(handler_type)(handler), - asio::error_code(asio::error::operation_aborted), - 0, 0.0, 'z')); - } - - return result.get(); -} - -template <typename CompletionToken> -typename asio::async_result< - typename asio::handler_type<CompletionToken, - void(std::exception_ptr, int, double, char)>::type>::type -deprecated_async_op_ex_3(asio::io_context& ctx, - bool ok, ASIO_MOVE_ARG(CompletionToken) token) -{ - typedef typename asio::handler_type<CompletionToken, - void(std::exception_ptr, int, double, char)>::type handler_type; - - handler_type handler(ASIO_MOVE_CAST(CompletionToken)(token)); - - asio::async_result<handler_type> result(handler); - - if (ok) - { - ctx.post(bindns::bind(ASIO_MOVE_CAST(handler_type)(handler), - std::exception_ptr(), 42, 2.0, 'a')); - } - else - { - ctx.post(bindns::bind(ASIO_MOVE_CAST(handler_type)(handler), - std::make_exception_ptr(std::runtime_error("blah")), - 0, 0.0, 'z')); - } - - return result.get(); -} - -} // namespace archetypes - -#endif // !defined(ASIO_NO_DEPRECATED) - -#endif // ARCHETYPES_DEPRECATED_ASYNC_OPS_HPP diff --git a/3rdparty/asio/src/tests/unit/archetypes/deprecated_async_result.hpp b/3rdparty/asio/src/tests/unit/archetypes/deprecated_async_result.hpp deleted file mode 100644 index c395b37144a..00000000000 --- a/3rdparty/asio/src/tests/unit/archetypes/deprecated_async_result.hpp +++ /dev/null @@ -1,82 +0,0 @@ -// -// async_result.hpp -// ~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 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) -// - -#ifndef ARCHETYPES_DEPRECATED_ASYNC_RESULT_HPP -#define ARCHETYPES_DEPRECATED_ASYNC_RESULT_HPP - -#include <asio/async_result.hpp> - -#if !defined(ASIO_NO_DEPRECATED) - -#include <asio/handler_type.hpp> - -namespace archetypes { - -struct deprecated_lazy_handler -{ -}; - -struct deprecated_concrete_handler -{ - deprecated_concrete_handler(deprecated_lazy_handler) - { - } - - template <typename Arg1> - void operator()(Arg1) - { - } - - template <typename Arg1, typename Arg2> - void operator()(Arg1, Arg2) - { - } - -#if defined(ASIO_HAS_MOVE) - deprecated_concrete_handler(deprecated_concrete_handler&&) {} -private: - deprecated_concrete_handler(const deprecated_concrete_handler&); -#endif // defined(ASIO_HAS_MOVE) -}; - -} // namespace archetypes - -namespace asio { - -template <typename Signature> -struct handler_type<archetypes::deprecated_lazy_handler, Signature> -{ - typedef archetypes::deprecated_concrete_handler type; -}; - -template <> -class async_result<archetypes::deprecated_concrete_handler> -{ -public: - // The return type of the initiating function. - typedef double type; - - // Construct an async_result from a given handler. - explicit async_result(archetypes::deprecated_concrete_handler&) - { - } - - // Obtain the value to be returned from the initiating function. - type get() - { - return 42; - } -}; - -} // namespace asio - -#endif // !defined(ASIO_NO_DEPRECATED) - -#endif // ARCHETYPES_DEPRECATED_ASYNC_RESULT_HPP diff --git a/3rdparty/asio/src/tests/unit/archetypes/gettable_socket_option.hpp b/3rdparty/asio/src/tests/unit/archetypes/gettable_socket_option.hpp index 24544b0497a..e1c2d3f0d4e 100644 --- a/3rdparty/asio/src/tests/unit/archetypes/gettable_socket_option.hpp +++ b/3rdparty/asio/src/tests/unit/archetypes/gettable_socket_option.hpp @@ -2,7 +2,7 @@ // gettable_socket_option.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/archetypes/io_control_command.hpp b/3rdparty/asio/src/tests/unit/archetypes/io_control_command.hpp index 011eb07d8bd..45ed07cf481 100644 --- a/3rdparty/asio/src/tests/unit/archetypes/io_control_command.hpp +++ b/3rdparty/asio/src/tests/unit/archetypes/io_control_command.hpp @@ -2,7 +2,7 @@ // io_control_command.hpp // ~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/archetypes/settable_socket_option.hpp b/3rdparty/asio/src/tests/unit/archetypes/settable_socket_option.hpp index 99b4dac899e..7a5867ba800 100644 --- a/3rdparty/asio/src/tests/unit/archetypes/settable_socket_option.hpp +++ b/3rdparty/asio/src/tests/unit/archetypes/settable_socket_option.hpp @@ -2,7 +2,7 @@ // settable_socket_option.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/as_tuple.cpp b/3rdparty/asio/src/tests/unit/as_tuple.cpp new file mode 100644 index 00000000000..a176d95bb2e --- /dev/null +++ b/3rdparty/asio/src/tests/unit/as_tuple.cpp @@ -0,0 +1,122 @@ +// +// as_tuple.cpp +// ~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/as_tuple.hpp" + +#include "asio/bind_executor.hpp" +#include "asio/deferred.hpp" +#include "asio/io_context.hpp" +#include "asio/post.hpp" +#include "asio/system_timer.hpp" +#include "asio/use_future.hpp" +#include "unit_test.hpp" + +void as_tuple_test() +{ + asio::io_context io1; + asio::io_context io2; + asio::system_timer timer1(io1); + int count = 0; + + timer1.expires_after(asio::chrono::seconds(0)); + timer1.async_wait( + asio::as_tuple( + asio::bind_executor(io2.get_executor(), + [&count](std::tuple<asio::error_code>) + { + ++count; + }))); + + ASIO_CHECK(count == 0); + + io1.run(); + + ASIO_CHECK(count == 0); + + io2.run(); + + ASIO_CHECK(count == 1); + + timer1.async_wait( + asio::as_tuple( + asio::bind_executor(io2.get_executor(), + asio::deferred)))( + [&count](std::tuple<asio::error_code>) + { + ++count; + }); + + ASIO_CHECK(count == 1); + + io1.restart(); + io1.run(); + + ASIO_CHECK(count == 1); + + io2.restart(); + io2.run(); + + ASIO_CHECK(count == 2); + +# if defined(ASIO_HAS_STD_FUTURE_CLASS) + std::future<std::tuple<asio::error_code> > f = timer1.async_wait( + asio::as_tuple( + asio::bind_executor(io2.get_executor(), + asio::use_future))); + + ASIO_CHECK(f.wait_for(std::chrono::seconds(0)) + == std::future_status::timeout); + + io1.restart(); + io1.run(); + + ASIO_CHECK(f.wait_for(std::chrono::seconds(0)) + == std::future_status::timeout); + + io2.restart(); + io2.run(); + + ASIO_CHECK(f.wait_for(std::chrono::seconds(0)) + == std::future_status::ready); +# endif // defined(ASIO_HAS_STD_FUTURE_CLASS) +} + +void as_tuple_constness_test() +{ +# if defined(ASIO_HAS_STD_FUTURE_CLASS) + asio::io_context io1; + asio::system_timer timer1(io1); + + auto tok1 = asio::as_tuple(asio::use_future); + (void)timer1.async_wait(tok1); + (void)timer1.async_wait(std::move(tok1)); + + const auto tok2 = asio::as_tuple(asio::use_future); + (void)timer1.async_wait(tok2); + (void)timer1.async_wait(std::move(tok2)); + + constexpr auto tok3 = asio::as_tuple(asio::use_future); + (void)timer1.async_wait(tok3); + (void)timer1.async_wait(std::move(tok3)); +# endif // defined(ASIO_HAS_STD_FUTURE_CLASS) +} + +ASIO_TEST_SUITE +( + "as_tuple", + ASIO_TEST_CASE(as_tuple_test) + ASIO_COMPILE_TEST_CASE(as_tuple_constness_test) +) diff --git a/3rdparty/asio/src/tests/unit/associated_allocator.cpp b/3rdparty/asio/src/tests/unit/associated_allocator.cpp index 7fe80ab3276..69a8afb0d41 100644 --- a/3rdparty/asio/src/tests/unit/associated_allocator.cpp +++ b/3rdparty/asio/src/tests/unit/associated_allocator.cpp @@ -2,7 +2,7 @@ // associated_allocator.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/seq_packet_socket_service.cpp b/3rdparty/asio/src/tests/unit/associated_cancellation_slot.cpp index fc2d73c7ae9..96d488458cb 100644 --- a/3rdparty/asio/src/tests/unit/seq_packet_socket_service.cpp +++ b/3rdparty/asio/src/tests/unit/associated_cancellation_slot.cpp @@ -1,8 +1,8 @@ // -// seq_packet_socket_service.cpp -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// associated_cancellation_slot.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -14,12 +14,12 @@ #endif // !defined(BOOST_ALL_NO_LIB) // Test that header file is self-contained. -#include "asio/seq_packet_socket_service.hpp" +#include "asio/associated_cancellation_slot.hpp" #include "unit_test.hpp" ASIO_TEST_SUITE ( - "seq_packet_socket_service", + "associated_cancellation_slot", ASIO_TEST_CASE(null_test) ) diff --git a/3rdparty/asio/src/tests/unit/associated_executor.cpp b/3rdparty/asio/src/tests/unit/associated_executor.cpp index a91fbb6336b..60b1f00657f 100644 --- a/3rdparty/asio/src/tests/unit/associated_executor.cpp +++ b/3rdparty/asio/src/tests/unit/associated_executor.cpp @@ -2,7 +2,7 @@ // associated_executor.cpp // ~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/associated_immediate_executor.cpp b/3rdparty/asio/src/tests/unit/associated_immediate_executor.cpp new file mode 100644 index 00000000000..f085a2cfcee --- /dev/null +++ b/3rdparty/asio/src/tests/unit/associated_immediate_executor.cpp @@ -0,0 +1,25 @@ +// +// associated_immediate_executor.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2022 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/associated_immediate_executor.hpp" + +#include "unit_test.hpp" + +ASIO_TEST_SUITE +( + "associated_immediate_executor", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/raw_socket_service.cpp b/3rdparty/asio/src/tests/unit/associator.cpp index c7b736f852e..a35d95c66e0 100644 --- a/3rdparty/asio/src/tests/unit/raw_socket_service.cpp +++ b/3rdparty/asio/src/tests/unit/associator.cpp @@ -1,8 +1,8 @@ // -// raw_socket_service.cpp -// ~~~~~~~~~~~~~~~~~~~~~~ +// associator.cpp +// ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -14,12 +14,12 @@ #endif // !defined(BOOST_ALL_NO_LIB) // Test that header file is self-contained. -#include "asio/raw_socket_service.hpp" +#include "asio/associator.hpp" #include "unit_test.hpp" ASIO_TEST_SUITE ( - "raw_socket_service", + "associator", ASIO_TEST_CASE(null_test) ) diff --git a/3rdparty/asio/src/tests/unit/async_result.cpp b/3rdparty/asio/src/tests/unit/async_result.cpp index 479aeb56e7d..75a4e91b71e 100644 --- a/3rdparty/asio/src/tests/unit/async_result.cpp +++ b/3rdparty/asio/src/tests/unit/async_result.cpp @@ -2,7 +2,7 @@ // async_result.cpp // ~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/stream_socket_service.cpp b/3rdparty/asio/src/tests/unit/awaitable.cpp index 03bbbf2f475..39ca8ddfdbe 100644 --- a/3rdparty/asio/src/tests/unit/stream_socket_service.cpp +++ b/3rdparty/asio/src/tests/unit/awaitable.cpp @@ -1,8 +1,8 @@ // -// stream_socket_service.cpp -// ~~~~~~~~~~~~~~~~~~~~~~~~~ +// awaitable.cpp +// ~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -14,12 +14,12 @@ #endif // !defined(BOOST_ALL_NO_LIB) // Test that header file is self-contained. -#include "asio/stream_socket_service.hpp" +#include "asio/awaitable.hpp" #include "unit_test.hpp" ASIO_TEST_SUITE ( - "stream_socket_service", + "awaitable", ASIO_TEST_CASE(null_test) ) diff --git a/3rdparty/asio/src/tests/unit/basic_datagram_socket.cpp b/3rdparty/asio/src/tests/unit/basic_datagram_socket.cpp index 8b17b5e9503..44fa2561646 100644 --- a/3rdparty/asio/src/tests/unit/basic_datagram_socket.cpp +++ b/3rdparty/asio/src/tests/unit/basic_datagram_socket.cpp @@ -2,7 +2,7 @@ // basic_datagram_socket.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/basic_deadline_timer.cpp b/3rdparty/asio/src/tests/unit/basic_deadline_timer.cpp index 65244031a59..ec6a6e37d18 100644 --- a/3rdparty/asio/src/tests/unit/basic_deadline_timer.cpp +++ b/3rdparty/asio/src/tests/unit/basic_deadline_timer.cpp @@ -2,7 +2,7 @@ // basic_deadline_timer.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/deadline_timer_service.cpp b/3rdparty/asio/src/tests/unit/basic_file.cpp index 87c7aa6ad27..5308d1268b0 100644 --- a/3rdparty/asio/src/tests/unit/deadline_timer_service.cpp +++ b/3rdparty/asio/src/tests/unit/basic_file.cpp @@ -1,8 +1,8 @@ // -// deadline_timer_service.cpp -// ~~~~~~~~~~~~~~~~~~~~~~~~~~ +// basic_file.cpp +// ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -14,12 +14,12 @@ #endif // !defined(BOOST_ALL_NO_LIB) // Test that header file is self-contained. -#include "asio/deadline_timer_service.hpp" +#include "asio/basic_file.hpp" #include "unit_test.hpp" ASIO_TEST_SUITE ( - "deadline_timer_service", + "basic_file", ASIO_TEST_CASE(null_test) ) diff --git a/3rdparty/asio/src/tests/unit/datagram_socket_service.cpp b/3rdparty/asio/src/tests/unit/basic_random_access_file.cpp index 5c4fe1374a6..fffaee3e8a2 100644 --- a/3rdparty/asio/src/tests/unit/datagram_socket_service.cpp +++ b/3rdparty/asio/src/tests/unit/basic_random_access_file.cpp @@ -1,8 +1,8 @@ // -// datagram_socket_service.cpp -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// basic_random_access_file.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -14,12 +14,12 @@ #endif // !defined(BOOST_ALL_NO_LIB) // Test that header file is self-contained. -#include "asio/datagram_socket_service.hpp" +#include "asio/basic_random_access_file.hpp" #include "unit_test.hpp" ASIO_TEST_SUITE ( - "datagram_socket_service", + "basic_random_access_file", ASIO_TEST_CASE(null_test) ) diff --git a/3rdparty/asio/src/tests/unit/basic_raw_socket.cpp b/3rdparty/asio/src/tests/unit/basic_raw_socket.cpp index 0b983e378f5..127df060b0c 100644 --- a/3rdparty/asio/src/tests/unit/basic_raw_socket.cpp +++ b/3rdparty/asio/src/tests/unit/basic_raw_socket.cpp @@ -2,7 +2,7 @@ // basic_raw_socket.cpp // ~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/basic_readable_pipe.cpp b/3rdparty/asio/src/tests/unit/basic_readable_pipe.cpp new file mode 100644 index 00000000000..f390acf4f98 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/basic_readable_pipe.cpp @@ -0,0 +1,25 @@ +// +// basic_readable_pipe.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/basic_readable_pipe.hpp" + +#include "unit_test.hpp" + +ASIO_TEST_SUITE +( + "basic_readable_pipe", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/basic_seq_packet_socket.cpp b/3rdparty/asio/src/tests/unit/basic_seq_packet_socket.cpp index c9f325d5908..c8b9bfa67bc 100644 --- a/3rdparty/asio/src/tests/unit/basic_seq_packet_socket.cpp +++ b/3rdparty/asio/src/tests/unit/basic_seq_packet_socket.cpp @@ -2,7 +2,7 @@ // basic_seq_packet_socket.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/basic_serial_port.cpp b/3rdparty/asio/src/tests/unit/basic_serial_port.cpp index a6c4e67d54a..1a64348a989 100644 --- a/3rdparty/asio/src/tests/unit/basic_serial_port.cpp +++ b/3rdparty/asio/src/tests/unit/basic_serial_port.cpp @@ -2,7 +2,7 @@ // basic_serial_port.cpp // ~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying diff --git a/3rdparty/asio/src/tests/unit/basic_signal_set.cpp b/3rdparty/asio/src/tests/unit/basic_signal_set.cpp index f3f87c5185a..01340178e69 100644 --- a/3rdparty/asio/src/tests/unit/basic_signal_set.cpp +++ b/3rdparty/asio/src/tests/unit/basic_signal_set.cpp @@ -2,7 +2,7 @@ // basic_signal_set.cpp // ~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/basic_socket.cpp b/3rdparty/asio/src/tests/unit/basic_socket.cpp new file mode 100644 index 00000000000..c2814e6b96d --- /dev/null +++ b/3rdparty/asio/src/tests/unit/basic_socket.cpp @@ -0,0 +1,25 @@ +// +// basic_socket.cpp +// ~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/basic_socket.hpp" + +#include "unit_test.hpp" + +ASIO_TEST_SUITE +( + "basic_socket", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/basic_socket_acceptor.cpp b/3rdparty/asio/src/tests/unit/basic_socket_acceptor.cpp index 4e6629f2b69..021a81628ae 100644 --- a/3rdparty/asio/src/tests/unit/basic_socket_acceptor.cpp +++ b/3rdparty/asio/src/tests/unit/basic_socket_acceptor.cpp @@ -2,7 +2,7 @@ // basic_socket_acceptor.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/basic_stream_file.cpp b/3rdparty/asio/src/tests/unit/basic_stream_file.cpp new file mode 100644 index 00000000000..9902122c9cb --- /dev/null +++ b/3rdparty/asio/src/tests/unit/basic_stream_file.cpp @@ -0,0 +1,25 @@ +// +// basic_stream_file.cpp +// ~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/basic_stream_file.hpp" + +#include "unit_test.hpp" + +ASIO_TEST_SUITE +( + "basic_stream_file", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/basic_stream_socket.cpp b/3rdparty/asio/src/tests/unit/basic_stream_socket.cpp index b04a4dc82bd..1edbe5a530c 100644 --- a/3rdparty/asio/src/tests/unit/basic_stream_socket.cpp +++ b/3rdparty/asio/src/tests/unit/basic_stream_socket.cpp @@ -2,7 +2,7 @@ // basic_stream_socket.cpp // ~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/basic_streambuf.cpp b/3rdparty/asio/src/tests/unit/basic_streambuf.cpp index ff9166205c9..9529dd801fe 100644 --- a/3rdparty/asio/src/tests/unit/basic_streambuf.cpp +++ b/3rdparty/asio/src/tests/unit/basic_streambuf.cpp @@ -2,7 +2,7 @@ // basic_streambuf.cpp // ~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/basic_waitable_timer.cpp b/3rdparty/asio/src/tests/unit/basic_waitable_timer.cpp index 6aa90cb2387..9d6be41b754 100644 --- a/3rdparty/asio/src/tests/unit/basic_waitable_timer.cpp +++ b/3rdparty/asio/src/tests/unit/basic_waitable_timer.cpp @@ -2,7 +2,7 @@ // basic_waitable_timer.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/basic_writable_pipe.cpp b/3rdparty/asio/src/tests/unit/basic_writable_pipe.cpp new file mode 100644 index 00000000000..fc0d0fdd955 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/basic_writable_pipe.cpp @@ -0,0 +1,25 @@ +// +// basic_writable_pipe.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/basic_writable_pipe.hpp" + +#include "unit_test.hpp" + +ASIO_TEST_SUITE +( + "basic_writable_pipe", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/bind_allocator.cpp b/3rdparty/asio/src/tests/unit/bind_allocator.cpp new file mode 100644 index 00000000000..b7c11ffb53c --- /dev/null +++ b/3rdparty/asio/src/tests/unit/bind_allocator.cpp @@ -0,0 +1,237 @@ +// +// bind_allocator.cpp +// ~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/bind_allocator.hpp" + +#include <functional> +#include "asio/io_context.hpp" +#include "asio/steady_timer.hpp" +#include "unit_test.hpp" + +#if defined(ASIO_HAS_BOOST_DATE_TIME) +# include "asio/deadline_timer.hpp" +#else // defined(ASIO_HAS_BOOST_DATE_TIME) +# include "asio/steady_timer.hpp" +#endif // defined(ASIO_HAS_BOOST_DATE_TIME) + +using namespace asio; +namespace bindns = std; + +#if defined(ASIO_HAS_BOOST_DATE_TIME) +typedef deadline_timer timer; +namespace chronons = boost::posix_time; +#else // defined(ASIO_HAS_BOOST_DATE_TIME) +typedef steady_timer timer; +namespace chronons = asio::chrono; +#endif // defined(ASIO_HAS_BOOST_DATE_TIME) + +template <typename T> +class test_allocator +{ +public: + typedef T value_type; + + explicit test_allocator(int* allocations) + : allocations_(allocations) + { + } + + template <typename U> + test_allocator(const test_allocator<U>& other) + : allocations_(other.allocations_) + { + } + + template <typename U> + struct rebind + { + typedef test_allocator<U> other; + }; + + bool operator==(const test_allocator&) const + { + return true; + } + + bool operator!=(const test_allocator&) const + { + return false; + } + + T* allocate(std::size_t n) const + { + ++(*allocations_); + return static_cast<T*>(::operator new(sizeof(T) * n)); + } + + void deallocate(T* p, std::size_t /*n*/) const + { + --(*allocations_); + ::operator delete(p); + } + +//private: + int* allocations_; +}; + +void increment(int* count) +{ + ++(*count); +} + +void bind_allocator_to_function_object_test() +{ + io_context ioc; + + int count = 0; + int allocations = 0; + + timer t(ioc, chronons::seconds(1)); + t.async_wait( + bind_allocator( + test_allocator<int>(&allocations), + bindns::bind(&increment, &count))); + + ASIO_CHECK(count == 0); + ASIO_CHECK(allocations == 1); + + ioc.run(); + + ASIO_CHECK(count == 1); + ASIO_CHECK(allocations == 0); + + t.async_wait( + bind_allocator( + test_allocator<int>(&allocations), + bind_allocator( + std::allocator<void>(), + bindns::bind(&increment, &count)))); + + ASIO_CHECK(count == 1); + ASIO_CHECK(allocations == 1); + + ioc.restart(); + ioc.run(); + + ASIO_CHECK(count == 2); + ASIO_CHECK(allocations == 0); +} + +struct incrementer_token_v1 +{ + explicit incrementer_token_v1(int* c) : count(c) {} + int* count; +}; + +struct incrementer_handler_v1 +{ + explicit incrementer_handler_v1(incrementer_token_v1 t) : count(t.count) {} + void operator()(asio::error_code){ increment(count); } + int* count; +}; + +namespace asio { + +template <> +class async_result<incrementer_token_v1, void(asio::error_code)> +{ +public: + typedef incrementer_handler_v1 completion_handler_type; + typedef void return_type; + explicit async_result(completion_handler_type&) {} + return_type get() {} +}; + +} // namespace asio + +void bind_allocator_to_completion_token_v1_test() +{ + io_context ioc; + + int count = 0; + int allocations = 0; + + timer t(ioc, chronons::seconds(1)); + t.async_wait( + bind_allocator( + test_allocator<int>(&allocations), + incrementer_token_v1(&count))); + + ASIO_CHECK(count == 0); + ASIO_CHECK(allocations == 1); + + ioc.run(); + + ASIO_CHECK(count == 1); + ASIO_CHECK(allocations == 0); +} + +struct incrementer_token_v2 +{ + explicit incrementer_token_v2(int* c) : count(c) {} + int* count; +}; + +namespace asio { + +template <> +class async_result<incrementer_token_v2, void(asio::error_code)> +{ +public: +#if !defined(ASIO_HAS_RETURN_TYPE_DEDUCTION) + typedef void return_type; +#endif // !defined(ASIO_HAS_RETURN_TYPE_DEDUCTION) + + template <typename Initiation, typename... Args> + static void initiate(Initiation initiation, + incrementer_token_v2 token, Args&&... args) + { + initiation(bindns::bind(&increment, token.count), + static_cast<Args&&>(args)...); + } +}; + +} // namespace asio + +void bind_allocator_to_completion_token_v2_test() +{ + io_context ioc; + + int count = 0; + int allocations = 0; + + timer t(ioc, chronons::seconds(1)); + t.async_wait( + bind_allocator( + test_allocator<int>(&allocations), + incrementer_token_v2(&count))); + + ASIO_CHECK(count == 0); + ASIO_CHECK(allocations == 1); + + ioc.run(); + + ASIO_CHECK(count == 1); + ASIO_CHECK(allocations == 0); +} + +ASIO_TEST_SUITE +( + "bind_allocator", + ASIO_TEST_CASE(bind_allocator_to_function_object_test) + ASIO_TEST_CASE(bind_allocator_to_completion_token_v1_test) + ASIO_TEST_CASE(bind_allocator_to_completion_token_v2_test) +) diff --git a/3rdparty/asio/src/tests/unit/bind_cancellation_slot.cpp b/3rdparty/asio/src/tests/unit/bind_cancellation_slot.cpp new file mode 100644 index 00000000000..25b0ff1c995 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/bind_cancellation_slot.cpp @@ -0,0 +1,202 @@ +// +// bind_cancellation_slot.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/bind_cancellation_slot.hpp" + +#include <functional> +#include "asio/cancellation_signal.hpp" +#include "asio/io_context.hpp" +#include "asio/steady_timer.hpp" +#include "unit_test.hpp" + +#if defined(ASIO_HAS_BOOST_DATE_TIME) +# include "asio/deadline_timer.hpp" +#else // defined(ASIO_HAS_BOOST_DATE_TIME) +# include "asio/steady_timer.hpp" +#endif // defined(ASIO_HAS_BOOST_DATE_TIME) + +using namespace asio; +namespace bindns = std; + +#if defined(ASIO_HAS_BOOST_DATE_TIME) +typedef deadline_timer timer; +namespace chronons = boost::posix_time; +#else // defined(ASIO_HAS_BOOST_DATE_TIME) +typedef steady_timer timer; +namespace chronons = asio::chrono; +#endif // defined(ASIO_HAS_BOOST_DATE_TIME) + +void increment_on_cancel(int* count, const asio::error_code& error) +{ + if (error == asio::error::operation_aborted) + ++(*count); +} + +void bind_cancellation_slot_to_function_object_test() +{ + io_context ioc; + cancellation_signal sig; + + int count = 0; + + timer t(ioc, chronons::seconds(5)); + t.async_wait( + bind_cancellation_slot(sig.slot(), + bindns::bind(&increment_on_cancel, + &count, bindns::placeholders::_1))); + + ioc.poll(); + + ASIO_CHECK(count == 0); + + sig.emit(asio::cancellation_type::all); + + ioc.run(); + + ASIO_CHECK(count == 1); + + t.async_wait( + bind_cancellation_slot(sig.slot(), + bind_cancellation_slot(sig.slot(), + bindns::bind(&increment_on_cancel, + &count, bindns::placeholders::_1)))); + + ioc.restart(); + ioc.poll(); + + ASIO_CHECK(count == 1); + + sig.emit(asio::cancellation_type::all); + + ioc.run(); + + ASIO_CHECK(count == 2); +} + +struct incrementer_token_v1 +{ + explicit incrementer_token_v1(int* c) : count(c) {} + int* count; +}; + +struct incrementer_handler_v1 +{ + explicit incrementer_handler_v1(incrementer_token_v1 t) : count(t.count) {} + + void operator()(asio::error_code error) + { + increment_on_cancel(count, error); + } + + int* count; +}; + +namespace asio { + +template <> +class async_result<incrementer_token_v1, void(asio::error_code)> +{ +public: + typedef incrementer_handler_v1 completion_handler_type; + typedef void return_type; + explicit async_result(completion_handler_type&) {} + return_type get() {} +}; + +} // namespace asio + +void bind_cancellation_slot_to_completion_token_v1_test() +{ + io_context ioc; + cancellation_signal sig; + + int count = 0; + + timer t(ioc, chronons::seconds(5)); + t.async_wait( + bind_cancellation_slot(sig.slot(), + incrementer_token_v1(&count))); + + ioc.poll(); + + ASIO_CHECK(count == 0); + + sig.emit(asio::cancellation_type::all); + + ioc.run(); + + ASIO_CHECK(count == 1); +} + +struct incrementer_token_v2 +{ + explicit incrementer_token_v2(int* c) : count(c) {} + int* count; +}; + +namespace asio { + +template <> +class async_result<incrementer_token_v2, void(asio::error_code)> +{ +public: +#if !defined(ASIO_HAS_RETURN_TYPE_DEDUCTION) + typedef void return_type; +#endif // !defined(ASIO_HAS_RETURN_TYPE_DEDUCTION) + + template <typename Initiation, typename... Args> + static void initiate(Initiation initiation, + incrementer_token_v2 token, Args&&... args) + { + initiation( + bindns::bind(&increment_on_cancel, + token.count, bindns::placeholders::_1), + static_cast<Args&&>(args)...); + } +}; + +} // namespace asio + +void bind_cancellation_slot_to_completion_token_v2_test() +{ + io_context ioc; + cancellation_signal sig; + + int count = 0; + + timer t(ioc, chronons::seconds(5)); + t.async_wait( + bind_cancellation_slot(sig.slot(), + incrementer_token_v2(&count))); + + ioc.poll(); + + ASIO_CHECK(count == 0); + + sig.emit(asio::cancellation_type::all); + + ioc.run(); + + ASIO_CHECK(count == 1); +} + +ASIO_TEST_SUITE +( + "bind_cancellation_slot", + ASIO_TEST_CASE(bind_cancellation_slot_to_function_object_test) + ASIO_TEST_CASE(bind_cancellation_slot_to_completion_token_v1_test) + ASIO_TEST_CASE(bind_cancellation_slot_to_completion_token_v2_test) +) diff --git a/3rdparty/asio/src/tests/unit/bind_executor.cpp b/3rdparty/asio/src/tests/unit/bind_executor.cpp index 74f24638a62..59be1cd14f3 100644 --- a/3rdparty/asio/src/tests/unit/bind_executor.cpp +++ b/3rdparty/asio/src/tests/unit/bind_executor.cpp @@ -2,7 +2,7 @@ // bind_executor.cpp // ~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -16,10 +16,174 @@ // Test that header file is self-contained. #include "asio/bind_executor.hpp" +#include <functional> +#include "asio/io_context.hpp" +#include "asio/steady_timer.hpp" #include "unit_test.hpp" +#if defined(ASIO_HAS_BOOST_DATE_TIME) +# include "asio/deadline_timer.hpp" +#else // defined(ASIO_HAS_BOOST_DATE_TIME) +# include "asio/steady_timer.hpp" +#endif // defined(ASIO_HAS_BOOST_DATE_TIME) + +using namespace asio; +namespace bindns = std; + +#if defined(ASIO_HAS_BOOST_DATE_TIME) +typedef deadline_timer timer; +namespace chronons = boost::posix_time; +#else // defined(ASIO_HAS_BOOST_DATE_TIME) +typedef steady_timer timer; +namespace chronons = asio::chrono; +#endif // defined(ASIO_HAS_BOOST_DATE_TIME) + +void increment(int* count) +{ + ++(*count); +} + +void bind_executor_to_function_object_test() +{ + io_context ioc1; + io_context ioc2; + + int count = 0; + + timer t(ioc1, chronons::seconds(1)); + t.async_wait( + bind_executor( + ioc2.get_executor(), + bindns::bind(&increment, &count))); + + ioc1.run(); + + ASIO_CHECK(count == 0); + + ioc2.run(); + + ASIO_CHECK(count == 1); + + t.async_wait( + bind_executor( + ioc2.get_executor(), + bind_executor( + asio::system_executor(), + bindns::bind(&increment, &count)))); + + ioc1.restart(); + ioc1.run(); + + ASIO_CHECK(count == 1); + + ioc2.restart(); + ioc2.run(); + + ASIO_CHECK(count == 2); +} + +struct incrementer_token_v1 +{ + explicit incrementer_token_v1(int* c) : count(c) {} + int* count; +}; + +struct incrementer_handler_v1 +{ + explicit incrementer_handler_v1(incrementer_token_v1 t) : count(t.count) {} + void operator()(asio::error_code){ increment(count); } + int* count; +}; + +namespace asio { + +template <> +class async_result<incrementer_token_v1, void(asio::error_code)> +{ +public: + typedef incrementer_handler_v1 completion_handler_type; + typedef void return_type; + explicit async_result(completion_handler_type&) {} + return_type get() {} +}; + +} // namespace asio + +void bind_executor_to_completion_token_v1_test() +{ + io_context ioc1; + io_context ioc2; + + int count = 0; + + timer t(ioc1, chronons::seconds(1)); + t.async_wait( + bind_executor( + ioc2.get_executor(), + incrementer_token_v1(&count))); + + ioc1.run(); + + ASIO_CHECK(count == 0); + + ioc2.run(); + + ASIO_CHECK(count == 1); +} + +struct incrementer_token_v2 +{ + explicit incrementer_token_v2(int* c) : count(c) {} + int* count; +}; + +namespace asio { + +template <> +class async_result<incrementer_token_v2, void(asio::error_code)> +{ +public: +#if !defined(ASIO_HAS_RETURN_TYPE_DEDUCTION) + typedef void return_type; +#endif // !defined(ASIO_HAS_RETURN_TYPE_DEDUCTION) + + template <typename Initiation, typename... Args> + static void initiate(Initiation initiation, + incrementer_token_v2 token, Args&&... args) + { + initiation(bindns::bind(&increment, token.count), + static_cast<Args&&>(args)...); + } +}; + +} // namespace asio + +void bind_executor_to_completion_token_v2_test() +{ + io_context ioc1; + io_context ioc2; + + int count = 0; + + timer t(ioc1, chronons::seconds(1)); + t.async_wait( + bind_executor( + ioc2.get_executor(), + incrementer_token_v2(&count))); + + ioc1.run(); + + ASIO_CHECK(count == 0); + + ioc2.run(); + + ASIO_CHECK(count == 1); +} + ASIO_TEST_SUITE ( "bind_executor", - ASIO_TEST_CASE(null_test) + ASIO_TEST_CASE(bind_executor_to_function_object_test) + ASIO_TEST_CASE(bind_executor_to_completion_token_v1_test) + ASIO_TEST_CASE(bind_executor_to_completion_token_v2_test) ) diff --git a/3rdparty/asio/src/tests/unit/bind_immediate_executor.cpp b/3rdparty/asio/src/tests/unit/bind_immediate_executor.cpp new file mode 100644 index 00000000000..ecf82de7470 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/bind_immediate_executor.cpp @@ -0,0 +1,199 @@ +// +// bind_immediate_executor.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/bind_immediate_executor.hpp" + +#include <functional> +#include "asio/dispatch.hpp" +#include "asio/io_context.hpp" +#include "unit_test.hpp" + +#if defined(ASIO_HAS_BOOST_DATE_TIME) +# include "asio/deadline_timer.hpp" +#else // defined(ASIO_HAS_BOOST_DATE_TIME) +# include "asio/steady_timer.hpp" +#endif // defined(ASIO_HAS_BOOST_DATE_TIME) + +using namespace asio; +namespace bindns = std; + +struct initiate_immediate +{ + template <typename Handler> + void operator()(Handler&& handler, io_context* ctx) const + { + typename associated_immediate_executor< + Handler, io_context::executor_type>::type ex = + get_associated_immediate_executor(handler, ctx->get_executor()); + dispatch(ex, static_cast<Handler&&>(handler)); + } +}; + +template <ASIO_COMPLETION_TOKEN_FOR(void()) Token> +ASIO_INITFN_AUTO_RESULT_TYPE_PREFIX(Token, void()) +async_immediate(io_context& ctx, Token&& token) + ASIO_INITFN_AUTO_RESULT_TYPE_SUFFIX(( + async_initiate<Token, void()>(declval<initiate_immediate>(), token))) +{ + return async_initiate<Token, void()>(initiate_immediate(), token, &ctx); +} + +void increment(int* count) +{ + ++(*count); +} + +void bind_immediate_executor_to_function_object_test() +{ + io_context ioc1; + io_context ioc2; + + int count = 0; + + async_immediate(ioc1, + bind_immediate_executor( + ioc2.get_executor(), + bindns::bind(&increment, &count))); + + ioc1.run(); + + ASIO_CHECK(count == 0); + + ioc2.run(); + + ASIO_CHECK(count == 1); + + async_immediate(ioc1, + bind_immediate_executor( + ioc2.get_executor(), + bind_immediate_executor( + asio::system_executor(), + bindns::bind(&increment, &count)))); + + ioc1.restart(); + ioc1.run(); + + ASIO_CHECK(count == 1); + + ioc2.restart(); + ioc2.run(); + + ASIO_CHECK(count == 2); +} + +struct incrementer_token_v1 +{ + explicit incrementer_token_v1(int* c) : count(c) {} + int* count; +}; + +struct incrementer_handler_v1 +{ + explicit incrementer_handler_v1(incrementer_token_v1 t) : count(t.count) {} + void operator()(){ increment(count); } + int* count; +}; + +namespace asio { + +template <> +class async_result<incrementer_token_v1, void()> +{ +public: + typedef incrementer_handler_v1 completion_handler_type; + typedef void return_type; + explicit async_result(completion_handler_type&) {} + return_type get() {} +}; + +} // namespace asio + +void bind_immediate_executor_to_completion_token_v1_test() +{ + io_context ioc1; + io_context ioc2; + + int count = 0; + + async_immediate(ioc1, + bind_immediate_executor( + ioc2.get_executor(), + incrementer_token_v1(&count))); + + ioc1.run(); + + ASIO_CHECK(count == 0); + + ioc2.run(); + + ASIO_CHECK(count == 1); +} + +struct incrementer_token_v2 +{ + explicit incrementer_token_v2(int* c) : count(c) {} + int* count; +}; + +namespace asio { + +template <> +class async_result<incrementer_token_v2, void()> +{ +public: +#if !defined(ASIO_HAS_RETURN_TYPE_DEDUCTION) + typedef void return_type; +#endif // !defined(ASIO_HAS_RETURN_TYPE_DEDUCTION) + + template <typename Initiation, typename... Args> + static void initiate(Initiation initiation, + incrementer_token_v2 token, Args&&... args) + { + initiation(bindns::bind(&increment, token.count), + static_cast<Args&&>(args)...); + } +}; + +} // namespace asio + +void bind_immediate_executor_to_completion_token_v2_test() +{ + io_context ioc1; + io_context ioc2; + + int count = 0; + + async_immediate(ioc1, + bind_immediate_executor( + ioc2.get_executor(), + incrementer_token_v2(&count))); + + ioc1.run(); + + ASIO_CHECK(count == 0); + + ioc2.run(); + + ASIO_CHECK(count == 1); +} + +ASIO_TEST_SUITE +( + "bind_immediate_executor", + ASIO_TEST_CASE(bind_immediate_executor_to_function_object_test) + ASIO_TEST_CASE(bind_immediate_executor_to_completion_token_v1_test) + ASIO_TEST_CASE(bind_immediate_executor_to_completion_token_v2_test) +) diff --git a/3rdparty/asio/src/tests/unit/buffer.cpp b/3rdparty/asio/src/tests/unit/buffer.cpp index b28533059ca..9fa1db6e67f 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-2024 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) @@ -16,16 +16,14 @@ // Test that header file is self-contained. #include "asio/buffer.hpp" +#include <array> +#include <cstring> #include "unit_test.hpp" #if defined(ASIO_HAS_BOOST_ARRAY) # include <boost/array.hpp> #endif // defined(ASIO_HAS_BOOST_ARRAY) -#if defined(ASIO_HAS_STD_ARRAY) -# include <array> -#endif // defined(ASIO_HAS_STD_ARRAY) - //------------------------------------------------------------------------------ // buffer_compile test @@ -37,6 +35,42 @@ namespace buffer_compile { using namespace asio; +template <typename T> +class mutable_contiguous_container +{ +public: + typedef T value_type; + typedef T* iterator; + typedef const T* const_iterator; + typedef T& reference; + typedef const T& const_reference; + + mutable_contiguous_container() {} + std::size_t size() const { return 0; } + iterator begin() { return 0; } + const_iterator begin() const { return 0; } + iterator end() { return 0; } + const_iterator end() const { return 0; } +}; + +template <typename T> +class const_contiguous_container +{ +public: + typedef const T value_type; + typedef const T* iterator; + typedef const T* const_iterator; + typedef const T& reference; + typedef const T& const_reference; + + const_contiguous_container() {} + std::size_t size() const { return 0; } + iterator begin() { return 0; } + const_iterator begin() const { return 0; } + iterator end() { return 0; } + const_iterator end() const { return 0; } +}; + void test() { try @@ -50,11 +84,9 @@ void test() const boost::array<char, 1024>& const_array_data_1 = array_data; boost::array<const char, 1024> const_array_data_2 = { { 0 } }; #endif // defined(ASIO_HAS_BOOST_ARRAY) -#if defined(ASIO_HAS_STD_ARRAY) std::array<char, 1024> std_array_data; const std::array<char, 1024>& const_std_array_data_1 = std_array_data; std::array<const char, 1024> const_std_array_data_2 = { { 0 } }; -#endif // defined(ASIO_HAS_STD_ARRAY) std::vector<char> vector_data(1024); const std::vector<char>& const_vector_data = vector_data; std::string string_data(1024, ' '); @@ -62,18 +94,21 @@ 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_contiguous_container<char> mutable_contiguous_data; + const mutable_contiguous_container<char> const_mutable_contiguous_data; + const_contiguous_container<char> const_contiguous_data; + const const_contiguous_container<char> const_const_contiguous_data; // mutable_buffer constructors. mutable_buffer mb1; mutable_buffer mb2(void_ptr_data, 1024); mutable_buffer mb3(mb1); + (void)mb3; // mutable_buffer functions. @@ -110,7 +145,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. @@ -188,14 +225,12 @@ void test() cb1 = buffer(const_array_data_2); cb1 = buffer(const_array_data_2, 1024); #endif // defined(ASIO_HAS_BOOST_ARRAY) -#if defined(ASIO_HAS_STD_ARRAY) mb1 = buffer(std_array_data); mb1 = buffer(std_array_data, 1024); cb1 = buffer(const_std_array_data_1); cb1 = buffer(const_std_array_data_1, 1024); cb1 = buffer(const_std_array_data_2); cb1 = buffer(const_std_array_data_2, 1024); -#endif // defined(ASIO_HAS_STD_ARRAY) mb1 = buffer(vector_data); mb1 = buffer(vector_data, 1024); cb1 = buffer(const_vector_data); @@ -204,10 +239,18 @@ 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) + mb1 = buffer(mutable_contiguous_data); + mb1 = buffer(mutable_contiguous_data, 1024); + cb1 = buffer(const_mutable_contiguous_data); + cb1 = buffer(const_mutable_contiguous_data, 1024); + cb1 = buffer(const_contiguous_data); + cb1 = buffer(const_contiguous_data, 1024); + cb1 = buffer(const_const_contiguous_data); + cb1 = buffer(const_const_contiguous_data, 1024); // buffer_copy function overloads. @@ -321,6 +364,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 +383,35 @@ void test() db1.commit(1024); db3.commit(1024); +#endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) - db1.consume(1024); - db3.consume(1024); + 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.shrink(1024); + db3.shrink(1024); + + db1.consume(0); + db3.consume(0); } catch (std::exception&) { @@ -559,9 +629,285 @@ 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; } +}; + +struct valid_const_b +{ + const_buffer* begin() const { return 0; } + const_buffer* end() const { return 0; } +}; + +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; } +}; + +struct valid_mutable_b +{ + mutable_buffer* begin() const { return 0; } + mutable_buffer* end() const { return 0; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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()); + + 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()); + + 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()); + + 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()); + + 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); + + 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); + + 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); + + 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); +} + +} // namespace buffer_sequence + +namespace buffer_literals { + +void test() +{ +#if defined(ASIO_HAS_USER_DEFINED_LITERALS) + using namespace asio::buffer_literals; + using namespace std; // For memcmp. + + asio::const_buffer b1 = ""_buf; + ASIO_CHECK(b1.size() == 0); + + asio::const_buffer b2 = "hello"_buf; + ASIO_CHECK(b2.size() == 5); + ASIO_CHECK(memcmp(b2.data(), "hello", 5) == 0); + + asio::const_buffer b3 = 0x00_buf; + ASIO_CHECK(b3.size() == 1); + ASIO_CHECK(memcmp(b3.data(), "\x00", 1) == 0); + + asio::const_buffer b4 = 0X01_buf; + ASIO_CHECK(b4.size() == 1); + ASIO_CHECK(memcmp(b4.data(), "\x01", 1) == 0); + + asio::const_buffer b5 = 0xaB_buf; + ASIO_CHECK(b5.size() == 1); + ASIO_CHECK(memcmp(b5.data(), "\xab", 1) == 0); + + asio::const_buffer b6 = 0xABcd_buf; + ASIO_CHECK(b6.size() == 2); + ASIO_CHECK(memcmp(b6.data(), "\xab\xcd", 2) == 0); + + asio::const_buffer b7 = 0x01ab01cd01ef01ba01dc01fe_buf; + ASIO_CHECK(b7.size() == 12); + ASIO_CHECK(memcmp(b7.data(), + "\x01\xab\x01\xcd\x01\xef\x01\xba\x01\xdc\x01\xfe", 12) == 0); + + asio::const_buffer b8 = 0b00000000_buf; + ASIO_CHECK(b8.size() == 1); + ASIO_CHECK(memcmp(b8.data(), "\x00", 1) == 0); + + asio::const_buffer b9 = 0B00000001_buf; + ASIO_CHECK(b9.size() == 1); + ASIO_CHECK(memcmp(b9.data(), "\x01", 1) == 0); + + asio::const_buffer b10 = 0B11111111_buf; + ASIO_CHECK(b10.size() == 1); + ASIO_CHECK(memcmp(b10.data(), "\xFF", 1) == 0); + + asio::const_buffer b11 = 0b1111000000001111_buf; + ASIO_CHECK(b11.size() == 2); + ASIO_CHECK(memcmp(b11.data(), "\xF0\x0F", 2) == 0); +#endif // (defined(ASIO_HAS_USER_DEFINED_LITERALS) +} + +} // namespace buffer_literals + +//------------------------------------------------------------------------------ + ASIO_TEST_SUITE ( "buffer", ASIO_COMPILE_TEST_CASE(buffer_compile::test) ASIO_TEST_CASE(buffer_copy_runtime::test) + ASIO_TEST_CASE(buffer_sequence::test) + ASIO_TEST_CASE(buffer_literals::test) ) diff --git a/3rdparty/asio/src/tests/unit/buffer_registration.cpp b/3rdparty/asio/src/tests/unit/buffer_registration.cpp new file mode 100644 index 00000000000..72826a394cc --- /dev/null +++ b/3rdparty/asio/src/tests/unit/buffer_registration.cpp @@ -0,0 +1,25 @@ +// +// buffer_registration.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/buffer_registration.hpp" + +#include "unit_test.hpp" + +ASIO_TEST_SUITE +( + "buffer_registration", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/buffered_read_stream.cpp b/3rdparty/asio/src/tests/unit/buffered_read_stream.cpp index 28a0db1eb93..21b4abc0bbb 100644 --- a/3rdparty/asio/src/tests/unit/buffered_read_stream.cpp +++ b/3rdparty/asio/src/tests/unit/buffered_read_stream.cpp @@ -2,7 +2,7 @@ // buffered_read_stream.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -17,6 +17,7 @@ #include "asio/buffered_read_stream.hpp" #include <cstring> +#include <functional> #include "archetypes/async_result.hpp" #include "asio/buffer.hpp" #include "asio/io_context.hpp" @@ -30,12 +31,6 @@ # include <array> #endif // defined(ASIO_HAS_BOOST_ARRAY) -#if defined(ASIO_HAS_BOOST_BIND) -# include <boost/bind.hpp> -#else // defined(ASIO_HAS_BOOST_BIND) -# include <functional> -#endif // defined(ASIO_HAS_BOOST_BIND) - typedef asio::buffered_read_stream< asio::ip::tcp::socket> stream_type; @@ -81,14 +76,6 @@ void test_compile() stream_type::executor_type ex = stream1.get_executor(); (void)ex; -#if !defined(ASIO_NO_DEPRECATED) - io_context& ioc_ref = stream1.get_io_context(); - (void)ioc_ref; - - io_context& ioc_ref2 = stream1.get_io_service(); - (void)ioc_ref2; -#endif // !defined(ASIO_NO_DEPRECATED) - stream_type::lowest_layer_type& lowest_layer = stream1.lowest_layer(); (void)lowest_layer; @@ -255,13 +242,9 @@ void test_async_operations() { using namespace std; // For memcmp. -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context io_context; @@ -340,7 +323,7 @@ void test_async_operations() ASIO_TEST_SUITE ( "buffered_read_stream", - ASIO_TEST_CASE(test_compile) + ASIO_COMPILE_TEST_CASE(test_compile) ASIO_TEST_CASE(test_sync_operations) ASIO_TEST_CASE(test_async_operations) ) diff --git a/3rdparty/asio/src/tests/unit/buffered_stream.cpp b/3rdparty/asio/src/tests/unit/buffered_stream.cpp index 7e077d0ca71..4830ec277de 100644 --- a/3rdparty/asio/src/tests/unit/buffered_stream.cpp +++ b/3rdparty/asio/src/tests/unit/buffered_stream.cpp @@ -2,7 +2,7 @@ // buffered_stream.cpp // ~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -17,6 +17,7 @@ #include "asio/buffered_stream.hpp" #include <cstring> +#include <functional> #include "archetypes/async_result.hpp" #include "asio/buffer.hpp" #include "asio/io_context.hpp" @@ -30,12 +31,6 @@ # include <array> #endif // defined(ASIO_HAS_BOOST_ARRAY) -#if defined(ASIO_HAS_BOOST_BIND) -# include <boost/bind.hpp> -#else // defined(ASIO_HAS_BOOST_BIND) -# include <functional> -#endif // defined(ASIO_HAS_BOOST_BIND) - typedef asio::buffered_stream< asio::ip::tcp::socket> stream_type; @@ -85,14 +80,6 @@ void test_compile() stream_type::executor_type ex = stream1.get_executor(); (void)ex; -#if !defined(ASIO_NO_DEPRECATED) - io_context& ioc_ref = stream1.get_io_context(); - (void)ioc_ref; - - io_context& ioc_ref2 = stream1.get_io_service(); - (void)ioc_ref2; -#endif // !defined(ASIO_NO_DEPRECATED) - stream_type::lowest_layer_type& lowest_layer = stream1.lowest_layer(); (void)lowest_layer; @@ -273,13 +260,9 @@ void test_async_operations() { using namespace std; // For memcmp. -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context io_context; @@ -366,7 +349,7 @@ void test_async_operations() ASIO_TEST_SUITE ( "buffered_stream", - ASIO_TEST_CASE(test_compile) + ASIO_COMPILE_TEST_CASE(test_compile) ASIO_TEST_CASE(test_sync_operations) ASIO_TEST_CASE(test_async_operations) ) diff --git a/3rdparty/asio/src/tests/unit/buffered_write_stream.cpp b/3rdparty/asio/src/tests/unit/buffered_write_stream.cpp index dd520505d33..635ff984b8d 100644 --- a/3rdparty/asio/src/tests/unit/buffered_write_stream.cpp +++ b/3rdparty/asio/src/tests/unit/buffered_write_stream.cpp @@ -2,7 +2,7 @@ // buffered_write_stream.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -17,6 +17,7 @@ #include "asio/buffered_write_stream.hpp" #include <cstring> +#include <functional> #include "archetypes/async_result.hpp" #include "asio/buffer.hpp" #include "asio/io_context.hpp" @@ -30,12 +31,6 @@ # include <array> #endif // defined(ASIO_HAS_BOOST_ARRAY) -#if defined(ASIO_HAS_BOOST_BIND) -# include <boost/bind.hpp> -#else // defined(ASIO_HAS_BOOST_BIND) -# include <functional> -#endif // defined(ASIO_HAS_BOOST_BIND) - typedef asio::buffered_write_stream< asio::ip::tcp::socket> stream_type; @@ -81,14 +76,6 @@ void test_compile() stream_type::executor_type ex = stream1.get_executor(); (void)ex; -#if !defined(ASIO_NO_DEPRECATED) - io_context& ioc_ref = stream1.get_io_context(); - (void)ioc_ref; - - io_context& ioc_ref2 = stream1.get_io_service(); - (void)ioc_ref2; -#endif // !defined(ASIO_NO_DEPRECATED) - stream_type::lowest_layer_type& lowest_layer = stream1.lowest_layer(); (void)lowest_layer; @@ -262,13 +249,9 @@ void test_async_operations() { using namespace std; // For memcmp. -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context io_context; @@ -355,7 +338,7 @@ void test_async_operations() ASIO_TEST_SUITE ( "buffered_write_stream", - ASIO_TEST_CASE(test_compile) + ASIO_COMPILE_TEST_CASE(test_compile) ASIO_TEST_CASE(test_sync_operations) ASIO_TEST_CASE(test_async_operations) ) diff --git a/3rdparty/asio/src/tests/unit/buffers_iterator.cpp b/3rdparty/asio/src/tests/unit/buffers_iterator.cpp index bd8c27522b2..071dc1bb8b3 100644 --- a/3rdparty/asio/src/tests/unit/buffers_iterator.cpp +++ b/3rdparty/asio/src/tests/unit/buffers_iterator.cpp @@ -2,7 +2,7 @@ // buffers_iterator.cpp // ~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -16,17 +16,10 @@ // Test that header file is self-contained. #include "asio/buffers_iterator.hpp" +#include <array> #include "asio/buffer.hpp" #include "unit_test.hpp" -#if defined(ASIO_HAS_BOOST_ARRAY) -# include <boost/array.hpp> -#endif // defined(ASIO_HAS_BOOST_ARRAY) - -#if defined(ASIO_HAS_STD_ARRAY) -# include <array> -#endif // defined(ASIO_HAS_STD_ARRAY) - //------------------------------------------------------------------------------ // buffers_iterator_compile test @@ -36,11 +29,7 @@ namespace buffers_iterator_compile { -#if defined(ASIO_HAS_BOOST_ARRAY) -using boost::array; -#elif defined(ASIO_HAS_STD_ARRAY) using std::array; -#endif // defined(ASIO_HAS_BOOST_ARRAY) using std::vector; using namespace asio; @@ -288,5 +277,5 @@ void test() ASIO_TEST_SUITE ( "buffers_iterator", - ASIO_TEST_CASE(buffers_iterator_compile::test) + ASIO_COMPILE_TEST_CASE(buffers_iterator_compile::test) ) diff --git a/3rdparty/asio/src/tests/unit/cancellation_signal.cpp b/3rdparty/asio/src/tests/unit/cancellation_signal.cpp new file mode 100644 index 00000000000..0b0f72fcbcb --- /dev/null +++ b/3rdparty/asio/src/tests/unit/cancellation_signal.cpp @@ -0,0 +1,25 @@ +// +// cancellation_signal.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/cancellation_signal.hpp" + +#include "unit_test.hpp" + +ASIO_TEST_SUITE +( + "cancellation_signal", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/signal_set_service.cpp b/3rdparty/asio/src/tests/unit/cancellation_state.cpp index 1dd2a2c651f..74bc6566916 100644 --- a/3rdparty/asio/src/tests/unit/signal_set_service.cpp +++ b/3rdparty/asio/src/tests/unit/cancellation_state.cpp @@ -1,8 +1,8 @@ // -// signal_set_service.cpp +// cancellation_state.cpp // ~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -14,12 +14,12 @@ #endif // !defined(BOOST_ALL_NO_LIB) // Test that header file is self-contained. -#include "asio/signal_set_service.hpp" +#include "asio/cancellation_state.hpp" #include "unit_test.hpp" ASIO_TEST_SUITE ( - "signal_set_service", + "cancellation_state", ASIO_TEST_CASE(null_test) ) diff --git a/3rdparty/asio/src/tests/unit/cancellation_type.cpp b/3rdparty/asio/src/tests/unit/cancellation_type.cpp new file mode 100644 index 00000000000..fd6accb0a05 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/cancellation_type.cpp @@ -0,0 +1,25 @@ +// +// cancellation_type.cpp +// ~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/cancellation_type.hpp" + +#include "unit_test.hpp" + +ASIO_TEST_SUITE +( + "cancellation_type", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/co_spawn.cpp b/3rdparty/asio/src/tests/unit/co_spawn.cpp new file mode 100644 index 00000000000..c5d1fbf776d --- /dev/null +++ b/3rdparty/asio/src/tests/unit/co_spawn.cpp @@ -0,0 +1,133 @@ +// +// co_spawn.cpp +// ~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/co_spawn.hpp" + +#include "unit_test.hpp" + +#if defined(ASIO_HAS_CO_AWAIT) + +#include <stdexcept> +#include "asio/any_completion_handler.hpp" +#include "asio/bind_cancellation_slot.hpp" +#include "asio/io_context.hpp" + +asio::awaitable<void> void_returning_coroutine() +{ + co_return; +} + +asio::awaitable<int> int_returning_coroutine() +{ + co_return 42; +} + +void test_co_spawn_with_any_completion_handler() +{ + asio::io_context ctx; + + bool called = false; + asio::co_spawn(ctx, void_returning_coroutine(), + asio::any_completion_handler<void(std::exception_ptr)>( + [&](std::exception_ptr) + { + called = true; + })); + + ASIO_CHECK(!called); + + ctx.run(); + + ASIO_CHECK(called); + + int result = 0; + asio::co_spawn(ctx, int_returning_coroutine(), + asio::any_completion_handler<void(std::exception_ptr, int)>( + [&](std::exception_ptr, int i) + { + result = i; + })); + + ASIO_CHECK(result == 0); + + ctx.restart(); + ctx.run(); + + ASIO_CHECK(result == 42); +} + +void test_co_spawn_immediate_cancel() +{ + asio::cancellation_signal sig; + asio::io_context ctx; + + std::exception_ptr result = nullptr; + bool called = false; + asio::co_spawn(ctx, void_returning_coroutine(), + asio::bind_cancellation_slot(sig.slot(), + [&](std::exception_ptr e) + { + result = e; + called = true; + })); + + ASIO_CHECK(!called); + ASIO_CHECK(result == nullptr); + + sig.emit(asio::cancellation_type::all); + ctx.run(); + + ASIO_CHECK(called); + ASIO_CHECK(result != nullptr); + + result = nullptr; + called = false; + asio::co_spawn(ctx, int_returning_coroutine(), + asio::bind_cancellation_slot(sig.slot(), + [&](std::exception_ptr e, int i) + { + ASIO_CHECK(i != 42); + result = e; + called = true; + })); + + ASIO_CHECK(!called); + ASIO_CHECK(result == nullptr); + + sig.emit(asio::cancellation_type::all); + ctx.restart(); + ctx.run(); + + ASIO_CHECK(called); + ASIO_CHECK(result != nullptr); +} + +ASIO_TEST_SUITE +( + "co_spawn", + ASIO_TEST_CASE(test_co_spawn_with_any_completion_handler) + ASIO_TEST_CASE(test_co_spawn_immediate_cancel) +) + +#else // defined(ASIO_HAS_CO_AWAIT) + +ASIO_TEST_SUITE +( + "co_spawn", + ASIO_TEST_CASE(null_test) +) + +#endif // defined(ASIO_HAS_CO_AWAIT) diff --git a/3rdparty/asio/src/tests/unit/completion_condition.cpp b/3rdparty/asio/src/tests/unit/completion_condition.cpp index 43e64544728..106789e5e3c 100644 --- a/3rdparty/asio/src/tests/unit/completion_condition.cpp +++ b/3rdparty/asio/src/tests/unit/completion_condition.cpp @@ -2,7 +2,7 @@ // completion_condition.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/compose.cpp b/3rdparty/asio/src/tests/unit/compose.cpp new file mode 100644 index 00000000000..c9820af2fd3 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/compose.cpp @@ -0,0 +1,528 @@ +// +// compose.cpp +// ~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/compose.hpp" + +#include <functional> +#include "asio/bind_cancellation_slot.hpp" +#include "asio/cancellation_signal.hpp" +#include "asio/io_context.hpp" +#include "asio/post.hpp" +#include "asio/system_timer.hpp" +#include "unit_test.hpp" + +//------------------------------------------------------------------------------ + +class impl_0_completion_args +{ +public: + explicit impl_0_completion_args(asio::io_context& ioc) + : ioc_(ioc), + state_(starting) + { + } + + template <typename Self> + void operator()(Self& self) + { + switch (state_) + { + case starting: + state_ = posting; + asio::post(ioc_, static_cast<Self&&>(self)); + break; + case posting: + self.complete(); + break; + default: + break; + } + } + +private: + asio::io_context& ioc_; + enum { starting, posting } state_; +}; + +template <typename CompletionToken> +ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) +async_0_completion_args(asio::io_context& ioc, + CompletionToken&& token) +{ + return asio::async_compose<CompletionToken, void()>( + impl_0_completion_args(ioc), token); +} + +void compose_0_args_handler(int* count) +{ + ++(*count); +} + +struct compose_0_args_lvalue_handler +{ + int* count_; + + void operator()() + { + ++(*count_); + } +}; + +void compose_0_completion_args_test() +{ + namespace bindns = std; + + asio::io_context ioc; + int count = 0; + + async_0_completion_args(ioc, bindns::bind(&compose_0_args_handler, &count)); + + // No handlers can be called until run() is called. + ASIO_CHECK(!ioc.stopped()); + ASIO_CHECK(count == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + + ioc.restart(); + count = 0; + + compose_0_args_lvalue_handler lvalue_handler = { &count }; + async_0_completion_args(ioc, lvalue_handler); + + // No handlers can be called until run() is called. + ASIO_CHECK(!ioc.stopped()); + ASIO_CHECK(count == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); +} + +//------------------------------------------------------------------------------ + +class impl_1_completion_arg +{ +public: + explicit impl_1_completion_arg(asio::io_context& ioc) + : ioc_(ioc), + state_(starting) + { + } + + template <typename Self> + void operator()(Self& self) + { + switch (state_) + { + case starting: + state_ = posting; + asio::post(ioc_, static_cast<Self&&>(self)); + break; + case posting: + self.complete(42); + break; + default: + break; + } + } + +private: + asio::io_context& ioc_; + enum { starting, posting } state_; +}; + +template <typename CompletionToken> +ASIO_INITFN_RESULT_TYPE(CompletionToken, void(int)) +async_1_completion_arg(asio::io_context& ioc, + CompletionToken&& token) +{ + return asio::async_compose<CompletionToken, void(int)>( + impl_1_completion_arg(ioc), token); +} + +void compose_1_arg_handler(int* count, int* result_out, int result) +{ + ++(*count); + *result_out = result; +} + +struct compose_1_arg_lvalue_handler +{ + int* count_; + int* result_out_; + + void operator()(int result) + { + ++(*count_); + *result_out_ = result; + } +}; + +void compose_1_completion_arg_test() +{ + namespace bindns = std; + using bindns::placeholders::_1; + + asio::io_context ioc; + int count = 0; + int result = 0; + + async_1_completion_arg(ioc, + bindns::bind(&compose_1_arg_handler, &count, &result, _1)); + + // No handlers can be called until run() is called. + ASIO_CHECK(!ioc.stopped()); + ASIO_CHECK(count == 0); + ASIO_CHECK(result == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + ASIO_CHECK(result == 42); + + ioc.restart(); + count = 0; + result = 0; + + compose_1_arg_lvalue_handler lvalue_handler = { &count, &result }; + async_1_completion_arg(ioc, lvalue_handler); + + // No handlers can be called until run() is called. + ASIO_CHECK(!ioc.stopped()); + ASIO_CHECK(count == 0); + ASIO_CHECK(result == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + ASIO_CHECK(result == 42); +} + +//------------------------------------------------------------------------------ + +typedef asio::enable_terminal_cancellation default_filter; + +template <typename CancellationFilter> +class impl_cancellable +{ +public: + explicit impl_cancellable(CancellationFilter cancellation_filter, + asio::system_timer& timer) + : cancellation_filter_(cancellation_filter), + timer_(timer), + state_(starting) + { + } + + template <typename Self> + void operator()(Self& self, + const asio::error_code& ec = asio::error_code()) + { + switch (state_) + { + case starting: + if (!asio::is_same<CancellationFilter, default_filter>::value) + self.reset_cancellation_state(cancellation_filter_); + state_ = waiting; + timer_.expires_after(asio::chrono::milliseconds(100)); + timer_.async_wait(static_cast<Self&&>(self)); + break; + case waiting: + self.complete(!ec); + break; + default: + break; + } + } + +private: + CancellationFilter cancellation_filter_; + asio::system_timer& timer_; + enum { starting, waiting } state_; +}; + +template <typename CancellationFilter, typename CompletionToken> +ASIO_INITFN_RESULT_TYPE(CompletionToken, void(bool)) +async_cancellable(CancellationFilter cancellation_filter, + asio::system_timer& timer, + CompletionToken&& token) +{ + return asio::async_compose<CompletionToken, void(bool)>( + impl_cancellable<CancellationFilter>(cancellation_filter, timer), token); +} + +void compose_partial_cancellation_handler( + int* count, bool* result_out, bool result) +{ + ++(*count); + *result_out = result; +} + +void compose_default_cancellation_test() +{ + namespace bindns = std; + using bindns::placeholders::_1; + + asio::io_context ioc; + asio::system_timer timer(ioc); + asio::cancellation_signal signal; + int count = 0; + bool result = false; + + async_cancellable(default_filter(), timer, + bindns::bind(&compose_partial_cancellation_handler, + &count, &result, _1)); + + ioc.run(); + + // No cancellation, operation completes successfully. + + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + ASIO_CHECK(result == true); + + ioc.restart(); + count = 0; + result = 0; + + async_cancellable(default_filter(), timer, + asio::bind_cancellation_slot(signal.slot(), + bindns::bind(&compose_partial_cancellation_handler, + &count, &result, _1))); + + // Total cancellation unsupported. Operation completes successfully. + signal.emit(asio::cancellation_type::total); + + ioc.run(); + + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + ASIO_CHECK(result == true); + + ioc.restart(); + count = 0; + result = 0; + + async_cancellable(default_filter(), timer, + asio::bind_cancellation_slot(signal.slot(), + bindns::bind(&compose_partial_cancellation_handler, + &count, &result, _1))); + + // Partial cancellation unsupported. Operation completes successfully. + signal.emit(asio::cancellation_type::partial); + + ioc.run(); + + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + ASIO_CHECK(result == true); + + ioc.restart(); + count = 0; + result = 0; + + async_cancellable(default_filter(), timer, + asio::bind_cancellation_slot(signal.slot(), + bindns::bind(&compose_partial_cancellation_handler, + &count, &result, _1))); + + // Terminal cancellation works. Operation completes with failure. + signal.emit(asio::cancellation_type::terminal); + + ioc.run(); + + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + ASIO_CHECK(result == false); +} + +void compose_partial_cancellation_test() +{ + namespace bindns = std; + using bindns::placeholders::_1; + + asio::io_context ioc; + asio::system_timer timer(ioc); + asio::cancellation_signal signal; + int count = 0; + bool result = false; + + async_cancellable(asio::enable_partial_cancellation(), timer, + bindns::bind(&compose_partial_cancellation_handler, + &count, &result, _1)); + + ioc.run(); + + // No cancellation, operation completes successfully. + + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + ASIO_CHECK(result == true); + + ioc.restart(); + count = 0; + result = 0; + + async_cancellable(asio::enable_partial_cancellation(), timer, + asio::bind_cancellation_slot(signal.slot(), + bindns::bind(&compose_partial_cancellation_handler, + &count, &result, _1))); + + // Total cancellation unsupported. Operation completes successfully. + signal.emit(asio::cancellation_type::total); + + ioc.run(); + + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + ASIO_CHECK(result == true); + + ioc.restart(); + count = 0; + result = 0; + + async_cancellable(asio::enable_partial_cancellation(), timer, + asio::bind_cancellation_slot(signal.slot(), + bindns::bind(&compose_partial_cancellation_handler, + &count, &result, _1))); + + // Partial cancellation works. Operation completes with failure. + signal.emit(asio::cancellation_type::partial); + + ioc.run(); + + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + ASIO_CHECK(result == false); + + ioc.restart(); + count = 0; + result = 0; + + async_cancellable(asio::enable_partial_cancellation(), timer, + asio::bind_cancellation_slot(signal.slot(), + bindns::bind(&compose_partial_cancellation_handler, + &count, &result, _1))); + + // Terminal cancellation works. Operation completes with failure. + signal.emit(asio::cancellation_type::terminal); + + ioc.run(); + + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + ASIO_CHECK(result == false); +} + +void compose_total_cancellation_test() +{ + namespace bindns = std; + using bindns::placeholders::_1; + + asio::io_context ioc; + asio::system_timer timer(ioc); + asio::cancellation_signal signal; + int count = 0; + bool result = false; + + async_cancellable(asio::enable_total_cancellation(), timer, + bindns::bind(&compose_partial_cancellation_handler, + &count, &result, _1)); + + ioc.run(); + + // No cancellation, operation completes successfully. + + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + ASIO_CHECK(result == true); + + ioc.restart(); + count = 0; + result = 0; + + async_cancellable(asio::enable_total_cancellation(), timer, + asio::bind_cancellation_slot(signal.slot(), + bindns::bind(&compose_partial_cancellation_handler, + &count, &result, _1))); + + // Total cancellation works. Operation completes with failure. + signal.emit(asio::cancellation_type::total); + + ioc.run(); + + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + ASIO_CHECK(result == false); + + ioc.restart(); + count = 0; + result = 0; + + async_cancellable(asio::enable_total_cancellation(), timer, + asio::bind_cancellation_slot(signal.slot(), + bindns::bind(&compose_partial_cancellation_handler, + &count, &result, _1))); + + // Partial cancellation works. Operation completes with failure. + signal.emit(asio::cancellation_type::partial); + + ioc.run(); + + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + ASIO_CHECK(result == false); + + ioc.restart(); + count = 0; + result = 0; + + async_cancellable(asio::enable_total_cancellation(), timer, + asio::bind_cancellation_slot(signal.slot(), + bindns::bind(&compose_partial_cancellation_handler, + &count, &result, _1))); + + // Terminal cancellation works. Operation completes with failure. + signal.emit(asio::cancellation_type::terminal); + + ioc.run(); + + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + ASIO_CHECK(result == false); +} + +//------------------------------------------------------------------------------ + +ASIO_TEST_SUITE +( + "compose", + ASIO_TEST_CASE(compose_0_completion_args_test) + ASIO_TEST_CASE(compose_1_completion_arg_test) + ASIO_TEST_CASE(compose_default_cancellation_test) + ASIO_TEST_CASE(compose_partial_cancellation_test) + ASIO_TEST_CASE(compose_total_cancellation_test) +) diff --git a/3rdparty/asio/src/tests/unit/connect.cpp b/3rdparty/asio/src/tests/unit/connect.cpp index 3b0a43248f3..16c0331b4a3 100644 --- a/3rdparty/asio/src/tests/unit/connect.cpp +++ b/3rdparty/asio/src/tests/unit/connect.cpp @@ -2,7 +2,7 @@ // connect.cpp // ~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -16,10 +16,1165 @@ // Test that header file is self-contained. #include "asio/connect.hpp" +#include <functional> +#include <vector> +#include "asio/detail/thread.hpp" +#include "asio/ip/tcp.hpp" #include "unit_test.hpp" +namespace bindns = std; +using bindns::placeholders::_1; +using bindns::placeholders::_2; + +class connection_sink +{ +public: + connection_sink() + : acceptor_(io_context_, + asio::ip::tcp::endpoint( + asio::ip::address_v4::loopback(), 0)), + target_endpoint_(acceptor_.local_endpoint()), + socket_(io_context_), + thread_(bindns::bind(&connection_sink::run, this)) + { + } + + ~connection_sink() + { + io_context_.stop(); + thread_.join(); + } + + asio::ip::tcp::endpoint target_endpoint() + { + return target_endpoint_; + } + +private: + void run() + { + io_context_.run(); + } + + void handle_accept() + { + socket_.close(); + acceptor_.async_accept(socket_, + bindns::bind(&connection_sink::handle_accept, this)); + } + + asio::io_context io_context_; + asio::ip::tcp::acceptor acceptor_; + asio::ip::tcp::endpoint target_endpoint_; + asio::ip::tcp::socket socket_; + asio::detail::thread thread_; +}; + +bool true_cond_1(const asio::error_code& /*ec*/, + const asio::ip::tcp::endpoint& /*endpoint*/) +{ + return true; +} + +struct true_cond_2 +{ + template <typename Endpoint> + bool operator()(const asio::error_code& /*ec*/, + const Endpoint& /*endpoint*/) + { + return true; + } +}; + +std::vector<asio::ip::tcp::endpoint>::const_iterator legacy_true_cond_1( + const asio::error_code& /*ec*/, + std::vector<asio::ip::tcp::endpoint>::const_iterator next) +{ + return next; +} + +struct legacy_true_cond_2 +{ + template <typename Iterator> + Iterator operator()(const asio::error_code& /*ec*/, Iterator next) + { + return next; + } +}; + +bool false_cond(const asio::error_code& /*ec*/, + const asio::ip::tcp::endpoint& /*endpoint*/) +{ + return false; +} + +void range_handler(const asio::error_code& ec, + const asio::ip::tcp::endpoint& endpoint, + asio::error_code* out_ec, + asio::ip::tcp::endpoint* out_endpoint) +{ + *out_ec = ec; + *out_endpoint = endpoint; +} + +void iter_handler(const asio::error_code& ec, + std::vector<asio::ip::tcp::endpoint>::const_iterator iter, + asio::error_code* out_ec, + std::vector<asio::ip::tcp::endpoint>::const_iterator* out_iter) +{ + *out_ec = ec; + *out_iter = iter; +} + +void test_connect_range() +{ + connection_sink sink; + asio::io_context io_context; + asio::ip::tcp::socket socket(io_context); + std::vector<asio::ip::tcp::endpoint> endpoints; + asio::ip::tcp::endpoint result; + + try + { + result = asio::connect(socket, endpoints); + ASIO_CHECK(false); + } + catch (asio::system_error& e) + { + ASIO_CHECK(e.code() == asio::error::not_found); + } + + endpoints.push_back(sink.target_endpoint()); + + result = asio::connect(socket, endpoints); + ASIO_CHECK(result == endpoints[0]); + + endpoints.push_back(sink.target_endpoint()); + + result = asio::connect(socket, endpoints); + ASIO_CHECK(result == endpoints[0]); + + endpoints.insert(endpoints.begin(), asio::ip::tcp::endpoint()); + + result = asio::connect(socket, endpoints); + ASIO_CHECK(result == endpoints[1]); +} + +void test_connect_range_ec() +{ + connection_sink sink; + asio::io_context io_context; + asio::ip::tcp::socket socket(io_context); + std::vector<asio::ip::tcp::endpoint> endpoints; + asio::ip::tcp::endpoint result; + asio::error_code ec; + + result = asio::connect(socket, endpoints, ec); + ASIO_CHECK(result == asio::ip::tcp::endpoint()); + ASIO_CHECK(ec == asio::error::not_found); + + endpoints.push_back(sink.target_endpoint()); + + result = asio::connect(socket, endpoints, ec); + ASIO_CHECK(result == endpoints[0]); + ASIO_CHECK(!ec); + + endpoints.push_back(sink.target_endpoint()); + + result = asio::connect(socket, endpoints, ec); + ASIO_CHECK(result == endpoints[0]); + ASIO_CHECK(!ec); + + endpoints.insert(endpoints.begin(), asio::ip::tcp::endpoint()); + + result = asio::connect(socket, endpoints, ec); + ASIO_CHECK(result == endpoints[1]); + ASIO_CHECK(!ec); +} + +void test_connect_range_cond() +{ + connection_sink sink; + asio::io_context io_context; + asio::ip::tcp::socket socket(io_context); + std::vector<asio::ip::tcp::endpoint> endpoints; + asio::ip::tcp::endpoint result; + + try + { + result = asio::connect(socket, endpoints, true_cond_1); + ASIO_CHECK(false); + } + catch (asio::system_error& e) + { + ASIO_CHECK(e.code() == asio::error::not_found); + } + + try + { + result = asio::connect(socket, endpoints, true_cond_2()); + ASIO_CHECK(false); + } + catch (asio::system_error& e) + { + ASIO_CHECK(e.code() == asio::error::not_found); + } + + try + { + result = asio::connect(socket, endpoints, legacy_true_cond_1); + ASIO_CHECK(false); + } + catch (asio::system_error& e) + { + ASIO_CHECK(e.code() == asio::error::not_found); + } + + try + { + result = asio::connect(socket, endpoints, legacy_true_cond_2()); + ASIO_CHECK(false); + } + catch (asio::system_error& e) + { + ASIO_CHECK(e.code() == asio::error::not_found); + } + + try + { + result = asio::connect(socket, endpoints, false_cond); + ASIO_CHECK(false); + } + catch (asio::system_error& e) + { + ASIO_CHECK(e.code() == asio::error::not_found); + } + + endpoints.push_back(sink.target_endpoint()); + + result = asio::connect(socket, endpoints, true_cond_1); + ASIO_CHECK(result == endpoints[0]); + + result = asio::connect(socket, endpoints, true_cond_2()); + ASIO_CHECK(result == endpoints[0]); + + result = asio::connect(socket, endpoints, legacy_true_cond_1); + ASIO_CHECK(result == endpoints[0]); + + result = asio::connect(socket, endpoints, legacy_true_cond_2()); + ASIO_CHECK(result == endpoints[0]); + + try + { + result = asio::connect(socket, endpoints, false_cond); + ASIO_CHECK(false); + } + catch (asio::system_error& e) + { + ASIO_CHECK(e.code() == asio::error::not_found); + } + + endpoints.push_back(sink.target_endpoint()); + + result = asio::connect(socket, endpoints, true_cond_1); + ASIO_CHECK(result == endpoints[0]); + + result = asio::connect(socket, endpoints, true_cond_2()); + ASIO_CHECK(result == endpoints[0]); + + result = asio::connect(socket, endpoints, legacy_true_cond_1); + ASIO_CHECK(result == endpoints[0]); + + result = asio::connect(socket, endpoints, legacy_true_cond_2()); + ASIO_CHECK(result == endpoints[0]); + + try + { + result = asio::connect(socket, endpoints, false_cond); + ASIO_CHECK(false); + } + catch (asio::system_error& e) + { + ASIO_CHECK(e.code() == asio::error::not_found); + } + + endpoints.insert(endpoints.begin(), asio::ip::tcp::endpoint()); + + result = asio::connect(socket, endpoints, true_cond_1); + ASIO_CHECK(result == endpoints[1]); + + result = asio::connect(socket, endpoints, true_cond_2()); + ASIO_CHECK(result == endpoints[1]); + + result = asio::connect(socket, endpoints, legacy_true_cond_1); + ASIO_CHECK(result == endpoints[1]); + + result = asio::connect(socket, endpoints, legacy_true_cond_2()); + ASIO_CHECK(result == endpoints[1]); + + try + { + result = asio::connect(socket, endpoints, false_cond); + ASIO_CHECK(false); + } + catch (asio::system_error& e) + { + ASIO_CHECK(e.code() == asio::error::not_found); + } +} + +void test_connect_range_cond_ec() +{ + connection_sink sink; + asio::io_context io_context; + asio::ip::tcp::socket socket(io_context); + std::vector<asio::ip::tcp::endpoint> endpoints; + asio::ip::tcp::endpoint result; + asio::error_code ec; + + result = asio::connect(socket, endpoints, true_cond_1, ec); + ASIO_CHECK(result == asio::ip::tcp::endpoint()); + ASIO_CHECK(ec == asio::error::not_found); + + result = asio::connect(socket, endpoints, true_cond_2(), ec); + ASIO_CHECK(result == asio::ip::tcp::endpoint()); + ASIO_CHECK(ec == asio::error::not_found); + + result = asio::connect(socket, endpoints, legacy_true_cond_1, ec); + ASIO_CHECK(result == asio::ip::tcp::endpoint()); + ASIO_CHECK(ec == asio::error::not_found); + + result = asio::connect(socket, endpoints, legacy_true_cond_2(), ec); + ASIO_CHECK(result == asio::ip::tcp::endpoint()); + ASIO_CHECK(ec == asio::error::not_found); + + result = asio::connect(socket, endpoints, false_cond, ec); + ASIO_CHECK(result == asio::ip::tcp::endpoint()); + ASIO_CHECK(ec == asio::error::not_found); + + endpoints.push_back(sink.target_endpoint()); + + result = asio::connect(socket, endpoints, true_cond_1, ec); + ASIO_CHECK(result == endpoints[0]); + ASIO_CHECK(!ec); + + result = asio::connect(socket, endpoints, true_cond_2(), ec); + ASIO_CHECK(result == endpoints[0]); + ASIO_CHECK(!ec); + + result = asio::connect(socket, endpoints, legacy_true_cond_1, ec); + ASIO_CHECK(result == endpoints[0]); + ASIO_CHECK(!ec); + + result = asio::connect(socket, endpoints, legacy_true_cond_2(), ec); + ASIO_CHECK(result == endpoints[0]); + ASIO_CHECK(!ec); + + result = asio::connect(socket, endpoints, false_cond, ec); + ASIO_CHECK(result == asio::ip::tcp::endpoint()); + ASIO_CHECK(ec == asio::error::not_found); + + endpoints.push_back(sink.target_endpoint()); + + result = asio::connect(socket, endpoints, true_cond_1, ec); + ASIO_CHECK(result == endpoints[0]); + ASIO_CHECK(!ec); + + result = asio::connect(socket, endpoints, true_cond_2(), ec); + ASIO_CHECK(result == endpoints[0]); + ASIO_CHECK(!ec); + + result = asio::connect(socket, endpoints, legacy_true_cond_1, ec); + ASIO_CHECK(result == endpoints[0]); + ASIO_CHECK(!ec); + + result = asio::connect(socket, endpoints, legacy_true_cond_2(), ec); + ASIO_CHECK(result == endpoints[0]); + ASIO_CHECK(!ec); + + result = asio::connect(socket, endpoints, false_cond, ec); + ASIO_CHECK(result == asio::ip::tcp::endpoint()); + ASIO_CHECK(ec == asio::error::not_found); + + endpoints.insert(endpoints.begin(), asio::ip::tcp::endpoint()); + + result = asio::connect(socket, endpoints, true_cond_1, ec); + ASIO_CHECK(result == endpoints[1]); + ASIO_CHECK(!ec); + + result = asio::connect(socket, endpoints, true_cond_2(), ec); + ASIO_CHECK(result == endpoints[1]); + ASIO_CHECK(!ec); + + result = asio::connect(socket, endpoints, legacy_true_cond_1, ec); + ASIO_CHECK(result == endpoints[1]); + ASIO_CHECK(!ec); + + result = asio::connect(socket, endpoints, legacy_true_cond_2(), ec); + ASIO_CHECK(result == endpoints[1]); + ASIO_CHECK(!ec); + + result = asio::connect(socket, endpoints, false_cond, ec); + ASIO_CHECK(result == asio::ip::tcp::endpoint()); + ASIO_CHECK(ec == asio::error::not_found); +} + +void test_connect_iter() +{ + connection_sink sink; + asio::io_context io_context; + asio::ip::tcp::socket socket(io_context); + std::vector<asio::ip::tcp::endpoint> endpoints; + const std::vector<asio::ip::tcp::endpoint>& cendpoints = endpoints; + std::vector<asio::ip::tcp::endpoint>::const_iterator result; + + try + { + result = asio::connect(socket, cendpoints.begin(), cendpoints.end()); + ASIO_CHECK(false); + } + catch (asio::system_error& e) + { + ASIO_CHECK(e.code() == asio::error::not_found); + } + + endpoints.push_back(sink.target_endpoint()); + + result = asio::connect(socket, cendpoints.begin(), cendpoints.end()); + ASIO_CHECK(result == cendpoints.begin()); + + endpoints.push_back(sink.target_endpoint()); + + result = asio::connect(socket, cendpoints.begin(), cendpoints.end()); + ASIO_CHECK(result == cendpoints.begin()); + + endpoints.insert(endpoints.begin(), asio::ip::tcp::endpoint()); + + result = asio::connect(socket, cendpoints.begin(), cendpoints.end()); + ASIO_CHECK(result == cendpoints.begin() + 1); +} + +void test_connect_iter_ec() +{ + connection_sink sink; + asio::io_context io_context; + asio::ip::tcp::socket socket(io_context); + std::vector<asio::ip::tcp::endpoint> endpoints; + const std::vector<asio::ip::tcp::endpoint>& cendpoints = endpoints; + std::vector<asio::ip::tcp::endpoint>::const_iterator result; + asio::error_code ec; + + result = asio::connect(socket, + cendpoints.begin(), cendpoints.end(), ec); + ASIO_CHECK(result == cendpoints.end()); + ASIO_CHECK(ec == asio::error::not_found); + + endpoints.push_back(sink.target_endpoint()); + + result = asio::connect(socket, + cendpoints.begin(), cendpoints.end(), ec); + ASIO_CHECK(result == cendpoints.begin()); + ASIO_CHECK(!ec); + + endpoints.push_back(sink.target_endpoint()); + + result = asio::connect(socket, + cendpoints.begin(), cendpoints.end(), ec); + ASIO_CHECK(result == cendpoints.begin()); + ASIO_CHECK(!ec); + + endpoints.insert(endpoints.begin(), asio::ip::tcp::endpoint()); + + result = asio::connect(socket, + cendpoints.begin(), cendpoints.end(), ec); + ASIO_CHECK(result == cendpoints.begin() + 1); + ASIO_CHECK(!ec); +} + +void test_connect_iter_cond() +{ + connection_sink sink; + asio::io_context io_context; + asio::ip::tcp::socket socket(io_context); + std::vector<asio::ip::tcp::endpoint> endpoints; + const std::vector<asio::ip::tcp::endpoint>& cendpoints = endpoints; + std::vector<asio::ip::tcp::endpoint>::const_iterator result; + + try + { + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), true_cond_1); + ASIO_CHECK(false); + } + catch (asio::system_error& e) + { + ASIO_CHECK(e.code() == asio::error::not_found); + } + + try + { + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), true_cond_2()); + ASIO_CHECK(false); + } + catch (asio::system_error& e) + { + ASIO_CHECK(e.code() == asio::error::not_found); + } + + try + { + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), legacy_true_cond_1); + ASIO_CHECK(false); + } + catch (asio::system_error& e) + { + ASIO_CHECK(e.code() == asio::error::not_found); + } + + try + { + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), legacy_true_cond_2()); + ASIO_CHECK(false); + } + catch (asio::system_error& e) + { + ASIO_CHECK(e.code() == asio::error::not_found); + } + + try + { + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), false_cond); + ASIO_CHECK(false); + } + catch (asio::system_error& e) + { + ASIO_CHECK(e.code() == asio::error::not_found); + } + + endpoints.push_back(sink.target_endpoint()); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), true_cond_1); + ASIO_CHECK(result == cendpoints.begin()); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), true_cond_2()); + ASIO_CHECK(result == cendpoints.begin()); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), legacy_true_cond_1); + ASIO_CHECK(result == cendpoints.begin()); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), legacy_true_cond_2()); + ASIO_CHECK(result == cendpoints.begin()); + + try + { + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), false_cond); + ASIO_CHECK(false); + } + catch (asio::system_error& e) + { + ASIO_CHECK(e.code() == asio::error::not_found); + } + + endpoints.push_back(sink.target_endpoint()); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), true_cond_1); + ASIO_CHECK(result == cendpoints.begin()); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), true_cond_2()); + ASIO_CHECK(result == cendpoints.begin()); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), legacy_true_cond_1); + ASIO_CHECK(result == cendpoints.begin()); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), legacy_true_cond_2()); + ASIO_CHECK(result == cendpoints.begin()); + + try + { + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), false_cond); + ASIO_CHECK(false); + } + catch (asio::system_error& e) + { + ASIO_CHECK(e.code() == asio::error::not_found); + } + + endpoints.insert(endpoints.begin(), asio::ip::tcp::endpoint()); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), true_cond_1); + ASIO_CHECK(result == cendpoints.begin() + 1); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), true_cond_2()); + ASIO_CHECK(result == cendpoints.begin() + 1); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), legacy_true_cond_1); + ASIO_CHECK(result == cendpoints.begin() + 1); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), legacy_true_cond_2()); + ASIO_CHECK(result == cendpoints.begin() + 1); + + try + { + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), false_cond); + ASIO_CHECK(false); + } + catch (asio::system_error& e) + { + ASIO_CHECK(e.code() == asio::error::not_found); + } +} + +void test_connect_iter_cond_ec() +{ + connection_sink sink; + asio::io_context io_context; + asio::ip::tcp::socket socket(io_context); + std::vector<asio::ip::tcp::endpoint> endpoints; + const std::vector<asio::ip::tcp::endpoint>& cendpoints = endpoints; + std::vector<asio::ip::tcp::endpoint>::const_iterator result; + asio::error_code ec; + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), true_cond_1, ec); + ASIO_CHECK(result == cendpoints.end()); + ASIO_CHECK(ec == asio::error::not_found); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), true_cond_2(), ec); + ASIO_CHECK(result == cendpoints.end()); + ASIO_CHECK(ec == asio::error::not_found); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), legacy_true_cond_1, ec); + ASIO_CHECK(result == cendpoints.end()); + ASIO_CHECK(ec == asio::error::not_found); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), legacy_true_cond_2(), ec); + ASIO_CHECK(result == cendpoints.end()); + ASIO_CHECK(ec == asio::error::not_found); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), false_cond, ec); + ASIO_CHECK(result == cendpoints.end()); + ASIO_CHECK(ec == asio::error::not_found); + + endpoints.push_back(sink.target_endpoint()); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), true_cond_1, ec); + ASIO_CHECK(result == cendpoints.begin()); + ASIO_CHECK(!ec); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), true_cond_2(), ec); + ASIO_CHECK(result == cendpoints.begin()); + ASIO_CHECK(!ec); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), legacy_true_cond_1, ec); + ASIO_CHECK(result == cendpoints.begin()); + ASIO_CHECK(!ec); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), legacy_true_cond_2(), ec); + ASIO_CHECK(result == cendpoints.begin()); + ASIO_CHECK(!ec); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), false_cond, ec); + ASIO_CHECK(result == cendpoints.end()); + ASIO_CHECK(ec == asio::error::not_found); + + endpoints.push_back(sink.target_endpoint()); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), true_cond_1, ec); + ASIO_CHECK(result == cendpoints.begin()); + ASIO_CHECK(!ec); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), true_cond_2(), ec); + ASIO_CHECK(result == cendpoints.begin()); + ASIO_CHECK(!ec); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), legacy_true_cond_1, ec); + ASIO_CHECK(result == cendpoints.begin()); + ASIO_CHECK(!ec); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), legacy_true_cond_2(), ec); + ASIO_CHECK(result == cendpoints.begin()); + ASIO_CHECK(!ec); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), false_cond, ec); + ASIO_CHECK(result == cendpoints.end()); + ASIO_CHECK(ec == asio::error::not_found); + + endpoints.insert(endpoints.begin(), asio::ip::tcp::endpoint()); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), true_cond_1, ec); + ASIO_CHECK(result == cendpoints.begin() + 1); + ASIO_CHECK(!ec); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), true_cond_2(), ec); + ASIO_CHECK(result == cendpoints.begin() + 1); + ASIO_CHECK(!ec); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), legacy_true_cond_1, ec); + ASIO_CHECK(result == cendpoints.begin() + 1); + ASIO_CHECK(!ec); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), legacy_true_cond_2(), ec); + ASIO_CHECK(result == cendpoints.begin() + 1); + ASIO_CHECK(!ec); + + result = asio::connect(socket, cendpoints.begin(), + cendpoints.end(), false_cond, ec); + ASIO_CHECK(result == cendpoints.end()); + ASIO_CHECK(ec == asio::error::not_found); +} + +void test_async_connect_range() +{ + connection_sink sink; + asio::io_context io_context; + asio::ip::tcp::socket socket(io_context); + std::vector<asio::ip::tcp::endpoint> endpoints; + asio::ip::tcp::endpoint result; + asio::error_code ec; + + asio::async_connect(socket, endpoints, + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == asio::ip::tcp::endpoint()); + ASIO_CHECK(ec == asio::error::not_found); + + endpoints.push_back(sink.target_endpoint()); + + asio::async_connect(socket, endpoints, + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == endpoints[0]); + ASIO_CHECK(!ec); + + endpoints.push_back(sink.target_endpoint()); + + asio::async_connect(socket, endpoints, + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == endpoints[0]); + ASIO_CHECK(!ec); + + endpoints.insert(endpoints.begin(), asio::ip::tcp::endpoint()); + + asio::async_connect(socket, endpoints, + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == endpoints[1]); + ASIO_CHECK(!ec); +} + +void test_async_connect_range_cond() +{ + connection_sink sink; + asio::io_context io_context; + asio::ip::tcp::socket socket(io_context); + std::vector<asio::ip::tcp::endpoint> endpoints; + asio::ip::tcp::endpoint result; + asio::error_code ec; + + asio::async_connect(socket, endpoints, true_cond_1, + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == asio::ip::tcp::endpoint()); + ASIO_CHECK(ec == asio::error::not_found); + + asio::async_connect(socket, endpoints, true_cond_2(), + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == asio::ip::tcp::endpoint()); + ASIO_CHECK(ec == asio::error::not_found); + + asio::async_connect(socket, endpoints, legacy_true_cond_1, + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == asio::ip::tcp::endpoint()); + ASIO_CHECK(ec == asio::error::not_found); + + asio::async_connect(socket, endpoints, legacy_true_cond_2(), + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == asio::ip::tcp::endpoint()); + ASIO_CHECK(ec == asio::error::not_found); + + asio::async_connect(socket, endpoints, false_cond, + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == asio::ip::tcp::endpoint()); + ASIO_CHECK(ec == asio::error::not_found); + + endpoints.push_back(sink.target_endpoint()); + + asio::async_connect(socket, endpoints, true_cond_1, + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == endpoints[0]); + ASIO_CHECK(!ec); + + asio::async_connect(socket, endpoints, true_cond_2(), + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == endpoints[0]); + ASIO_CHECK(!ec); + + asio::async_connect(socket, endpoints, legacy_true_cond_1, + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == endpoints[0]); + ASIO_CHECK(!ec); + + asio::async_connect(socket, endpoints, legacy_true_cond_2(), + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == endpoints[0]); + ASIO_CHECK(!ec); + + asio::async_connect(socket, endpoints, false_cond, + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == asio::ip::tcp::endpoint()); + ASIO_CHECK(ec == asio::error::not_found); + + endpoints.push_back(sink.target_endpoint()); + + asio::async_connect(socket, endpoints, true_cond_1, + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == endpoints[0]); + ASIO_CHECK(!ec); + + asio::async_connect(socket, endpoints, true_cond_2(), + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == endpoints[0]); + ASIO_CHECK(!ec); + + asio::async_connect(socket, endpoints, legacy_true_cond_1, + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == endpoints[0]); + ASIO_CHECK(!ec); + + asio::async_connect(socket, endpoints, legacy_true_cond_2(), + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == endpoints[0]); + ASIO_CHECK(!ec); + + asio::async_connect(socket, endpoints, false_cond, + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == asio::ip::tcp::endpoint()); + ASIO_CHECK(ec == asio::error::not_found); + + endpoints.insert(endpoints.begin(), asio::ip::tcp::endpoint()); + + asio::async_connect(socket, endpoints, true_cond_1, + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == endpoints[1]); + ASIO_CHECK(!ec); + + asio::async_connect(socket, endpoints, true_cond_2(), + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == endpoints[1]); + ASIO_CHECK(!ec); + + asio::async_connect(socket, endpoints, legacy_true_cond_1, + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == endpoints[1]); + ASIO_CHECK(!ec); + + asio::async_connect(socket, endpoints, legacy_true_cond_2(), + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == endpoints[1]); + ASIO_CHECK(!ec); + + asio::async_connect(socket, endpoints, false_cond, + bindns::bind(range_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == asio::ip::tcp::endpoint()); + ASIO_CHECK(ec == asio::error::not_found); +} + +void test_async_connect_iter() +{ + connection_sink sink; + asio::io_context io_context; + asio::ip::tcp::socket socket(io_context); + std::vector<asio::ip::tcp::endpoint> endpoints; + const std::vector<asio::ip::tcp::endpoint>& cendpoints = endpoints; + std::vector<asio::ip::tcp::endpoint>::const_iterator result; + asio::error_code ec; + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.end()); + ASIO_CHECK(ec == asio::error::not_found); + + endpoints.push_back(sink.target_endpoint()); + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.begin()); + ASIO_CHECK(!ec); + + endpoints.push_back(sink.target_endpoint()); + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.begin()); + ASIO_CHECK(!ec); + + endpoints.insert(endpoints.begin(), asio::ip::tcp::endpoint()); + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.begin() + 1); + ASIO_CHECK(!ec); +} + +void test_async_connect_iter_cond() +{ + connection_sink sink; + asio::io_context io_context; + asio::ip::tcp::socket socket(io_context); + std::vector<asio::ip::tcp::endpoint> endpoints; + const std::vector<asio::ip::tcp::endpoint>& cendpoints = endpoints; + std::vector<asio::ip::tcp::endpoint>::const_iterator result; + asio::error_code ec; + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + true_cond_1, bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.end()); + ASIO_CHECK(ec == asio::error::not_found); + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + true_cond_2(), bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.end()); + ASIO_CHECK(ec == asio::error::not_found); + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + legacy_true_cond_1, bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.end()); + ASIO_CHECK(ec == asio::error::not_found); + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + legacy_true_cond_2(), bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.end()); + ASIO_CHECK(ec == asio::error::not_found); + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + false_cond, bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.end()); + ASIO_CHECK(ec == asio::error::not_found); + + endpoints.push_back(sink.target_endpoint()); + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + true_cond_1, bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.begin()); + ASIO_CHECK(!ec); + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + true_cond_2(), bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.begin()); + ASIO_CHECK(!ec); + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + legacy_true_cond_1, bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.begin()); + ASIO_CHECK(!ec); + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + legacy_true_cond_2(), bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.begin()); + ASIO_CHECK(!ec); + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + false_cond, bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.end()); + ASIO_CHECK(ec == asio::error::not_found); + + endpoints.push_back(sink.target_endpoint()); + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + true_cond_1, bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.begin()); + ASIO_CHECK(!ec); + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + true_cond_2(), bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.begin()); + ASIO_CHECK(!ec); + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + legacy_true_cond_1, bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.begin()); + ASIO_CHECK(!ec); + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + legacy_true_cond_2(), bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.begin()); + ASIO_CHECK(!ec); + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + false_cond, bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.end()); + ASIO_CHECK(ec == asio::error::not_found); + + endpoints.insert(endpoints.begin(), asio::ip::tcp::endpoint()); + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + true_cond_1, bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.begin() + 1); + ASIO_CHECK(!ec); + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + true_cond_2(), bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.begin() + 1); + ASIO_CHECK(!ec); + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + legacy_true_cond_1, bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.begin() + 1); + ASIO_CHECK(!ec); + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + legacy_true_cond_2(), bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.begin() + 1); + ASIO_CHECK(!ec); + + asio::async_connect(socket, cendpoints.begin(), cendpoints.end(), + false_cond, bindns::bind(iter_handler, _1, _2, &ec, &result)); + io_context.restart(); + io_context.run(); + ASIO_CHECK(result == cendpoints.end()); + ASIO_CHECK(ec == asio::error::not_found); +} + ASIO_TEST_SUITE ( "connect", - ASIO_TEST_CASE(null_test) + ASIO_TEST_CASE(test_connect_range) + ASIO_TEST_CASE(test_connect_range_ec) + ASIO_TEST_CASE(test_connect_range_cond) + ASIO_TEST_CASE(test_connect_range_cond_ec) + ASIO_TEST_CASE(test_connect_iter) + ASIO_TEST_CASE(test_connect_iter_ec) + ASIO_TEST_CASE(test_connect_iter_cond) + ASIO_TEST_CASE(test_connect_iter_cond_ec) + ASIO_TEST_CASE(test_async_connect_range) + ASIO_TEST_CASE(test_async_connect_range_cond) + ASIO_TEST_CASE(test_async_connect_iter) + ASIO_TEST_CASE(test_async_connect_iter_cond) ) diff --git a/3rdparty/asio/src/tests/unit/connect_pipe.cpp b/3rdparty/asio/src/tests/unit/connect_pipe.cpp new file mode 100644 index 00000000000..8c71a5d093c --- /dev/null +++ b/3rdparty/asio/src/tests/unit/connect_pipe.cpp @@ -0,0 +1,154 @@ +// +// connect_pipe.cpp +// ~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/connect_pipe.hpp" + +#include <functional> +#include <string> +#include "asio/io_context.hpp" +#include "asio/read.hpp" +#include "asio/readable_pipe.hpp" +#include "asio/writable_pipe.hpp" +#include "asio/write.hpp" +#include "unit_test.hpp" + +//------------------------------------------------------------------------------ + +// connect_pipe_compile test +// ~~~~~~~~~~~~~~~~~~~~~~~~~ +// The following test checks that all connect_pipe functions compile and link +// correctly. Runtime failures are ignored. + +namespace connect_pipe_compile { + +void test() +{ +#if defined(ASIO_HAS_PIPE) + using namespace asio; + + try + { + asio::io_context io_context; + asio::error_code ec1; + + readable_pipe p1(io_context); + writable_pipe p2(io_context); + connect_pipe(p1, p2); + + readable_pipe p3(io_context); + writable_pipe p4(io_context); + connect_pipe(p3, p4, ec1); + } + catch (std::exception&) + { + } +#endif // defined(ASIO_HAS_PIPE) +} + +} // namespace connect_pipe_compile + +//------------------------------------------------------------------------------ + +// connect_pipe_runtime test +// ~~~~~~~~~~~~~~~~~~~~~~~~~ +// The following test checks that connect_pipe operates correctly at runtime. + +namespace connect_pipe_runtime { + +static const char write_data[] + = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + +void handle_read(const asio::error_code& err, + size_t bytes_transferred, bool* called) +{ + *called = true; + ASIO_CHECK(!err); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); +} + +void handle_write(const asio::error_code& err, + size_t bytes_transferred, bool* called) +{ + *called = true; + ASIO_CHECK(!err); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); +} + +void test() +{ +#if defined(ASIO_HAS_PIPE) + using namespace std; // For memcmp. + using namespace asio; + + namespace bindns = std; + using bindns::placeholders::_1; + using bindns::placeholders::_2; + + try + { + asio::io_context io_context; + asio::error_code ec1; + asio::error_code ec2; + + readable_pipe p1(io_context); + writable_pipe p2(io_context); + connect_pipe(p1, p2); + + std::string data1 = write_data; + asio::write(p2, asio::buffer(data1)); + + std::string data2; + data2.resize(data1.size()); + asio::read(p1, asio::buffer(data2)); + + ASIO_CHECK(data1 == data2); + + char read_buffer[sizeof(write_data)]; + bool read_completed = false; + asio::async_read(p1, + asio::buffer(read_buffer), + bindns::bind(handle_read, + _1, _2, &read_completed)); + + bool write_completed = false; + asio::async_write(p2, + asio::buffer(write_data), + bindns::bind(handle_write, + _1, _2, &write_completed)); + + io_context.run(); + + ASIO_CHECK(read_completed); + ASIO_CHECK(write_completed); + ASIO_CHECK(memcmp(read_buffer, write_data, sizeof(write_data)) == 0); + } + catch (std::exception&) + { + ASIO_CHECK(false); + } +#endif // defined(ASIO_HAS_PIPE) +} + +} // namespace connect_pipe_compile + +//------------------------------------------------------------------------------ + +ASIO_TEST_SUITE +( + "connect_pipe", + ASIO_COMPILE_TEST_CASE(connect_pipe_compile::test) + ASIO_TEST_CASE(connect_pipe_runtime::test) +) diff --git a/3rdparty/asio/src/tests/unit/consign.cpp b/3rdparty/asio/src/tests/unit/consign.cpp new file mode 100644 index 00000000000..b24f5281c75 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/consign.cpp @@ -0,0 +1,56 @@ +// +// consign.cpp +// ~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/consign.hpp" + +#include "asio/bind_executor.hpp" +#include "asio/io_context.hpp" +#include "asio/post.hpp" +#include "asio/system_timer.hpp" +#include "unit_test.hpp" + +void consign_test() +{ + asio::io_context io1; + asio::io_context io2; + asio::system_timer timer1(io1); + int count = 0; + + timer1.expires_after(asio::chrono::seconds(0)); + timer1.async_wait( + asio::consign( + asio::bind_executor(io2.get_executor(), + [&count](asio::error_code) + { + ++count; + }), 123, 321)); + + ASIO_CHECK(count == 0); + + io1.run(); + + ASIO_CHECK(count == 0); + + io2.run(); + + ASIO_CHECK(count == 1); +} + +ASIO_TEST_SUITE +( + "consign", + ASIO_TEST_CASE(consign_test) +) diff --git a/3rdparty/asio/src/tests/unit/coroutine.cpp b/3rdparty/asio/src/tests/unit/coroutine.cpp index 162cacdbb6d..72e6953a31a 100644 --- a/3rdparty/asio/src/tests/unit/coroutine.cpp +++ b/3rdparty/asio/src/tests/unit/coroutine.cpp @@ -2,7 +2,7 @@ // coroutine.cpp // ~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/deadline_timer.cpp b/3rdparty/asio/src/tests/unit/deadline_timer.cpp index 9c48b62c69a..9bc7f16fcd2 100644 --- a/3rdparty/asio/src/tests/unit/deadline_timer.cpp +++ b/3rdparty/asio/src/tests/unit/deadline_timer.cpp @@ -2,7 +2,7 @@ // deadline_timer.cpp // ~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -20,7 +20,7 @@ #if defined(ASIO_HAS_BOOST_DATE_TIME) -#include <boost/bind.hpp> +#include <boost/bind/bind.hpp> #include "archetypes/async_result.hpp" #include "asio/executor_work_guard.hpp" #include "asio/io_context.hpp" @@ -250,21 +250,77 @@ struct custom_allocation_timer_handler custom_allocation_timer_handler(int* count) : count_(count) {} void operator()(const asio::error_code&) {} int* count_; -}; -void* asio_handler_allocate(std::size_t size, - custom_allocation_timer_handler* handler) -{ - ++(*handler->count_); - return ::operator new(size); -} - -void asio_handler_deallocate(void* pointer, std::size_t, - custom_allocation_timer_handler* handler) -{ - --(*handler->count_); - ::operator delete(pointer); -} + template <typename T> + struct allocator + { + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T* pointer; + typedef const T* const_pointer; + typedef T& reference; + typedef const T& const_reference; + typedef T value_type; + + template <typename U> + struct rebind + { + typedef allocator<U> other; + }; + + explicit allocator(int* count) noexcept + : count_(count) + { + } + + allocator(const allocator& other) noexcept + : count_(other.count_) + { + } + + template <typename U> + allocator(const allocator<U>& other) noexcept + : count_(other.count_) + { + } + + pointer allocate(size_type n, const void* = 0) + { + ++(*count_); + return static_cast<T*>(::operator new(sizeof(T) * n)); + } + + void deallocate(pointer p, size_type) + { + --(*count_); + ::operator delete(p); + } + + size_type max_size() const + { + return ~size_type(0); + } + + void construct(pointer p, const T& v) + { + new (p) T(v); + } + + void destroy(pointer p) + { + p->~T(); + } + + int* count_; + }; + + typedef allocator<int> allocator_type; + + allocator_type get_allocator() const noexcept + { + return allocator_type(count_); + } +}; void deadline_timer_custom_allocation_test() { @@ -340,7 +396,6 @@ void deadline_timer_async_result_test() ioc.run(); } -#if defined(ASIO_HAS_MOVE) asio::deadline_timer make_timer(asio::io_context& ioc, int* count) { asio::deadline_timer t(ioc); @@ -348,11 +403,9 @@ asio::deadline_timer make_timer(asio::io_context& ioc, int* count) t.async_wait(boost::bind(increment, count)); return t; } -#endif // defined(ASIO_HAS_MOVE) void deadline_timer_move_test() { -#if defined(ASIO_HAS_MOVE) asio::io_context io_context1; asio::io_context io_context2; int count = 0; @@ -370,7 +423,6 @@ void deadline_timer_move_test() io_context1.run(); ASIO_CHECK(count == 2); -#endif // defined(ASIO_HAS_MOVE) } ASIO_TEST_SUITE diff --git a/3rdparty/asio/src/tests/unit/defer.cpp b/3rdparty/asio/src/tests/unit/defer.cpp index 90163f636a5..f41c1b9f025 100644 --- a/3rdparty/asio/src/tests/unit/defer.cpp +++ b/3rdparty/asio/src/tests/unit/defer.cpp @@ -2,7 +2,7 @@ // defer.cpp // ~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/deferred.cpp b/3rdparty/asio/src/tests/unit/deferred.cpp new file mode 100644 index 00000000000..b2db70d4b3d --- /dev/null +++ b/3rdparty/asio/src/tests/unit/deferred.cpp @@ -0,0 +1,25 @@ +// +// deferred.cpp +// ~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/deferred.hpp" + +#include "unit_test.hpp" + +ASIO_TEST_SUITE +( + "experimental/deferred", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/detached.cpp b/3rdparty/asio/src/tests/unit/detached.cpp new file mode 100644 index 00000000000..506c13d8773 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/detached.cpp @@ -0,0 +1,25 @@ +// +// detached.cpp +// ~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/detached.hpp" + +#include "unit_test.hpp" + +ASIO_TEST_SUITE +( + "detached", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/dispatch.cpp b/3rdparty/asio/src/tests/unit/dispatch.cpp index 64c20354bb9..f6fb84d4f91 100644 --- a/3rdparty/asio/src/tests/unit/dispatch.cpp +++ b/3rdparty/asio/src/tests/unit/dispatch.cpp @@ -2,7 +2,7 @@ // dispatch.cpp // ~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/error.cpp b/3rdparty/asio/src/tests/unit/error.cpp index d4c9b32106b..3f8aa75efbe 100644 --- a/3rdparty/asio/src/tests/unit/error.cpp +++ b/3rdparty/asio/src/tests/unit/error.cpp @@ -2,7 +2,7 @@ // error.cpp // ~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/execution/any_executor.cpp b/3rdparty/asio/src/tests/unit/execution/any_executor.cpp new file mode 100644 index 00000000000..3e2dabdc5a5 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/execution/any_executor.cpp @@ -0,0 +1,1202 @@ +// +// any_executor.cpp +// ~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/execution/any_executor.hpp" + +#include <cstring> +#include <functional> +#include "asio/thread_pool.hpp" +#include "../unit_test.hpp" + +using namespace asio; +namespace bindns = std; + +static bool next_nothrow_new_fails = false; + +void* operator new(std::size_t n, + const std::nothrow_t&) noexcept +{ + if (next_nothrow_new_fails) + { + next_nothrow_new_fails = false; + return 0; + } + return ::operator new(n); +} + +struct fat_executor +{ + fat_executor(int id) + : id_(id) + { + std::memset(data_, 0, sizeof(data_)); + } + + template <typename F> + void execute(const F&) const + { + } + + std::size_t query(execution::occupancy_t) const + { + return 1; + } + + friend bool operator==(const fat_executor& a, + const fat_executor& b) noexcept + { + return a.id_ == b.id_; + } + + friend bool operator!=(const fat_executor& a, + const fat_executor& b) noexcept + { + return a.id_ != b.id_; + } + + int id_; + unsigned char data_[1024]; +}; + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +template <typename F> +struct execute_member<fat_executor, F> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + typedef void result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +template <> +struct query_member<fat_executor, execution::occupancy_t> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = false; + typedef std::size_t result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +template <> +struct equality_comparable<fat_executor> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +} // namespace traits +} // namespace asio + +void increment(int* count) +{ + ++(*count); +} + +void any_executor_construction_test() +{ + typedef execution::any_executor<> ex_no_props_t; + + typedef execution::any_executor< + execution::blocking_t + > ex_one_prop_t; + + typedef execution::any_executor< + execution::blocking_t, + execution::occupancy_t + > ex_two_props_t; + + thread_pool pool(1); + asio::nullptr_t null_ptr = asio::nullptr_t(); + + ex_two_props_t ex_two_props_1; + + ASIO_CHECK(ex_two_props_1.target<void>() == 0); + ASIO_CHECK(ex_two_props_1 == null_ptr); + + ex_two_props_t ex_two_props_2(null_ptr); + + ASIO_CHECK(ex_two_props_2.target<void>() == 0); + ASIO_CHECK(ex_two_props_2 == null_ptr); + ASIO_CHECK(ex_two_props_2 == ex_two_props_1); + + ex_two_props_t ex_two_props_3(pool.executor()); + + ASIO_CHECK(ex_two_props_3.target<void>() != 0); + ASIO_CHECK(ex_two_props_3 != null_ptr); + ASIO_CHECK(ex_two_props_3 != ex_two_props_1); + + ex_two_props_t ex_two_props_4(ex_two_props_1); + + ASIO_CHECK(ex_two_props_4.target<void>() == 0); + ASIO_CHECK(ex_two_props_4 == null_ptr); + ASIO_CHECK(ex_two_props_4 == ex_two_props_1); + + ex_two_props_t ex_two_props_5(ex_two_props_3); + + ASIO_CHECK(ex_two_props_5.target<void>() != 0); + ASIO_CHECK(ex_two_props_5 != null_ptr); + ASIO_CHECK(ex_two_props_5 == ex_two_props_3); + + ex_two_props_t ex_two_props_6 = fat_executor(1); + + ASIO_CHECK(ex_two_props_6.target<void>() != 0); + ASIO_CHECK(ex_two_props_6 != null_ptr); + ASIO_CHECK(ex_two_props_6 != ex_two_props_1); + + ex_two_props_t ex_two_props_7 = fat_executor(1); + + ASIO_CHECK(ex_two_props_7.target<void>() != 0); + ASIO_CHECK(ex_two_props_7 != null_ptr); + ASIO_CHECK(ex_two_props_7 != ex_two_props_1); + ASIO_CHECK(ex_two_props_7 == ex_two_props_6); + + ex_two_props_t ex_two_props_8 = fat_executor(2); + + ASIO_CHECK(ex_two_props_8.target<void>() != 0); + ASIO_CHECK(ex_two_props_8 != null_ptr); + ASIO_CHECK(ex_two_props_8 != ex_two_props_1); + ASIO_CHECK(ex_two_props_8 != ex_two_props_6); + ASIO_CHECK(ex_two_props_8 != ex_two_props_7); + + ex_two_props_t ex_two_props_9(ex_two_props_6); + + ASIO_CHECK(ex_two_props_9.target<void>() != 0); + ASIO_CHECK(ex_two_props_9 != null_ptr); + ASIO_CHECK(ex_two_props_9 != ex_two_props_1); + ASIO_CHECK(ex_two_props_9 == ex_two_props_6); + ASIO_CHECK(ex_two_props_9 == ex_two_props_7); + ASIO_CHECK(ex_two_props_9 != ex_two_props_8); + + ex_two_props_t ex_two_props_10(std::move(ex_two_props_1)); + + ASIO_CHECK(ex_two_props_10.target<void>() == 0); + ASIO_CHECK(ex_two_props_10 == null_ptr); + ASIO_CHECK(ex_two_props_1.target<void>() == 0); + ASIO_CHECK(ex_two_props_1 == null_ptr); + + ex_two_props_t ex_two_props_11(std::move(ex_two_props_3)); + + ASIO_CHECK(ex_two_props_11.target<void>() != 0); + ASIO_CHECK(ex_two_props_11 != null_ptr); + ASIO_CHECK(ex_two_props_3.target<void>() == 0); + ASIO_CHECK(ex_two_props_3 == null_ptr); + ASIO_CHECK(ex_two_props_11 == ex_two_props_5); + + ex_two_props_t ex_two_props_12(std::move(ex_two_props_7)); + + ASIO_CHECK(ex_two_props_12.target<void>() != 0); + ASIO_CHECK(ex_two_props_12 != null_ptr); + ASIO_CHECK(ex_two_props_7.target<void>() == 0); + ASIO_CHECK(ex_two_props_7 == null_ptr); + ASIO_CHECK(ex_two_props_12 == ex_two_props_6); + ASIO_CHECK(ex_two_props_12 != ex_two_props_8); + + ex_one_prop_t ex_one_prop_1; + + ASIO_CHECK(ex_one_prop_1.target<void>() == 0); + ASIO_CHECK(ex_one_prop_1 == null_ptr); + + ex_one_prop_t ex_one_prop_2(null_ptr); + + ASIO_CHECK(ex_one_prop_2.target<void>() == 0); + ASIO_CHECK(ex_one_prop_2 == null_ptr); + ASIO_CHECK(ex_one_prop_2 == ex_one_prop_1); + + ex_one_prop_t ex_one_prop_3(pool.executor()); + + ASIO_CHECK(ex_one_prop_3.target<void>() != 0); + ASIO_CHECK(ex_one_prop_3 != null_ptr); + ASIO_CHECK(ex_one_prop_3 != ex_one_prop_1); + + ex_one_prop_t ex_one_prop_4(ex_one_prop_1); + + ASIO_CHECK(ex_one_prop_4.target<void>() == 0); + ASIO_CHECK(ex_one_prop_4 == null_ptr); + ASIO_CHECK(ex_one_prop_4 == ex_one_prop_1); + + ex_one_prop_t ex_one_prop_5(ex_one_prop_3); + + ASIO_CHECK(ex_one_prop_5.target<void>() != 0); + ASIO_CHECK(ex_one_prop_5 != null_ptr); + ASIO_CHECK(ex_one_prop_5 == ex_one_prop_3); + + ex_one_prop_t ex_one_prop_6 = fat_executor(1); + + ASIO_CHECK(ex_one_prop_6.target<void>() != 0); + ASIO_CHECK(ex_one_prop_6 != null_ptr); + ASIO_CHECK(ex_one_prop_6 != ex_one_prop_1); + + ex_one_prop_t ex_one_prop_7 = fat_executor(1); + + ASIO_CHECK(ex_one_prop_7.target<void>() != 0); + ASIO_CHECK(ex_one_prop_7 != null_ptr); + ASIO_CHECK(ex_one_prop_7 != ex_one_prop_1); + ASIO_CHECK(ex_one_prop_7 == ex_one_prop_6); + + ex_one_prop_t ex_one_prop_8 = fat_executor(2); + + ASIO_CHECK(ex_one_prop_8.target<void>() != 0); + ASIO_CHECK(ex_one_prop_8 != null_ptr); + ASIO_CHECK(ex_one_prop_8 != ex_one_prop_1); + ASIO_CHECK(ex_one_prop_8 != ex_one_prop_6); + ASIO_CHECK(ex_one_prop_8 != ex_one_prop_7); + + ex_one_prop_t ex_one_prop_9(ex_one_prop_6); + + ASIO_CHECK(ex_one_prop_9.target<void>() != 0); + ASIO_CHECK(ex_one_prop_9 != null_ptr); + ASIO_CHECK(ex_one_prop_9 != ex_one_prop_1); + ASIO_CHECK(ex_one_prop_9 == ex_one_prop_6); + ASIO_CHECK(ex_one_prop_9 == ex_one_prop_7); + ASIO_CHECK(ex_one_prop_9 != ex_one_prop_8); + + ex_one_prop_t ex_one_prop_10(std::move(ex_one_prop_1)); + + ASIO_CHECK(ex_one_prop_10.target<void>() == 0); + ASIO_CHECK(ex_one_prop_10 == null_ptr); + ASIO_CHECK(ex_one_prop_1.target<void>() == 0); + ASIO_CHECK(ex_one_prop_1 == null_ptr); + + ex_one_prop_t ex_one_prop_11(std::move(ex_one_prop_3)); + + ASIO_CHECK(ex_one_prop_11.target<void>() != 0); + ASIO_CHECK(ex_one_prop_11 != null_ptr); + ASIO_CHECK(ex_one_prop_3.target<void>() == 0); + ASIO_CHECK(ex_one_prop_3 == null_ptr); + ASIO_CHECK(ex_one_prop_11 == ex_one_prop_5); + + ex_one_prop_t ex_one_prop_12(std::move(ex_one_prop_7)); + + ASIO_CHECK(ex_one_prop_12.target<void>() != 0); + ASIO_CHECK(ex_one_prop_12 != null_ptr); + ASIO_CHECK(ex_one_prop_7.target<void>() == 0); + ASIO_CHECK(ex_one_prop_7 == null_ptr); + ASIO_CHECK(ex_one_prop_12 == ex_one_prop_6); + ASIO_CHECK(ex_one_prop_12 != ex_one_prop_8); + + ex_one_prop_t ex_one_prop_13(ex_two_props_1); + + ASIO_CHECK(ex_one_prop_13.target<void>() == 0); + ASIO_CHECK(ex_one_prop_13 == null_ptr); + + ex_one_prop_t ex_one_prop_14(ex_two_props_5); + + ASIO_CHECK(ex_one_prop_14.target<void>() != 0); + ASIO_CHECK(ex_one_prop_14 != null_ptr); + + ex_one_prop_t ex_one_prop_15(ex_two_props_9); + + ASIO_CHECK(ex_one_prop_15.target<void>() != 0); + ASIO_CHECK(ex_one_prop_15 != null_ptr); + + ex_no_props_t ex_no_props_1; + + ASIO_CHECK(ex_no_props_1.target<void>() == 0); + ASIO_CHECK(ex_no_props_1 == null_ptr); + + ex_no_props_t ex_no_props_2(null_ptr); + + ASIO_CHECK(ex_no_props_2.target<void>() == 0); + ASIO_CHECK(ex_no_props_2 == null_ptr); + ASIO_CHECK(ex_no_props_2 == ex_no_props_1); + + ex_no_props_t ex_no_props_3(pool.executor()); + + ASIO_CHECK(ex_no_props_3.target<void>() != 0); + ASIO_CHECK(ex_no_props_3 != null_ptr); + ASIO_CHECK(ex_no_props_3 != ex_no_props_1); + + ex_no_props_t ex_no_props_4(ex_no_props_1); + + ASIO_CHECK(ex_no_props_4.target<void>() == 0); + ASIO_CHECK(ex_no_props_4 == null_ptr); + ASIO_CHECK(ex_no_props_4 == ex_no_props_1); + + ex_no_props_t ex_no_props_5(ex_no_props_3); + + ASIO_CHECK(ex_no_props_5.target<void>() != 0); + ASIO_CHECK(ex_no_props_5 != null_ptr); + ASIO_CHECK(ex_no_props_5 == ex_no_props_3); + + ex_no_props_t ex_no_props_6 = fat_executor(1); + + ASIO_CHECK(ex_no_props_6.target<void>() != 0); + ASIO_CHECK(ex_no_props_6 != null_ptr); + ASIO_CHECK(ex_no_props_6 != ex_no_props_1); + + ex_no_props_t ex_no_props_7 = fat_executor(1); + + ASIO_CHECK(ex_no_props_7.target<void>() != 0); + ASIO_CHECK(ex_no_props_7 != null_ptr); + ASIO_CHECK(ex_no_props_7 != ex_no_props_1); + ASIO_CHECK(ex_no_props_7 == ex_no_props_6); + + ex_no_props_t ex_no_props_8 = fat_executor(2); + + ASIO_CHECK(ex_no_props_8.target<void>() != 0); + ASIO_CHECK(ex_no_props_8 != null_ptr); + ASIO_CHECK(ex_no_props_8 != ex_no_props_1); + ASIO_CHECK(ex_no_props_8 != ex_no_props_6); + ASIO_CHECK(ex_no_props_8 != ex_no_props_7); + + ex_no_props_t ex_no_props_9(ex_no_props_6); + + ASIO_CHECK(ex_no_props_9.target<void>() != 0); + ASIO_CHECK(ex_no_props_9 != null_ptr); + ASIO_CHECK(ex_no_props_9 != ex_no_props_1); + ASIO_CHECK(ex_no_props_9 == ex_no_props_6); + ASIO_CHECK(ex_no_props_9 == ex_no_props_7); + ASIO_CHECK(ex_no_props_9 != ex_no_props_8); + + ex_no_props_t ex_no_props_10(std::move(ex_no_props_1)); + + ASIO_CHECK(ex_no_props_10.target<void>() == 0); + ASIO_CHECK(ex_no_props_10 == null_ptr); + ASIO_CHECK(ex_no_props_1.target<void>() == 0); + ASIO_CHECK(ex_no_props_1 == null_ptr); + + ex_no_props_t ex_no_props_11(std::move(ex_no_props_3)); + + ASIO_CHECK(ex_no_props_11.target<void>() != 0); + ASIO_CHECK(ex_no_props_11 != null_ptr); + ASIO_CHECK(ex_no_props_3.target<void>() == 0); + ASIO_CHECK(ex_no_props_3 == null_ptr); + ASIO_CHECK(ex_no_props_11 == ex_no_props_5); + + ex_no_props_t ex_no_props_12(std::move(ex_no_props_7)); + + ASIO_CHECK(ex_no_props_12.target<void>() != 0); + ASIO_CHECK(ex_no_props_12 != null_ptr); + ASIO_CHECK(ex_no_props_7.target<void>() == 0); + ASIO_CHECK(ex_no_props_7 == null_ptr); + ASIO_CHECK(ex_no_props_12 == ex_no_props_6); + ASIO_CHECK(ex_no_props_12 != ex_no_props_8); + + ex_no_props_t ex_no_props_13(ex_two_props_1); + + ASIO_CHECK(ex_no_props_13.target<void>() == 0); + ASIO_CHECK(ex_no_props_13 == null_ptr); + + ex_no_props_t ex_no_props_14(ex_two_props_5); + + ASIO_CHECK(ex_no_props_14.target<void>() != 0); + ASIO_CHECK(ex_no_props_14 != null_ptr); + + ex_no_props_t ex_no_props_15(ex_two_props_9); + + ASIO_CHECK(ex_no_props_15.target<void>() != 0); + ASIO_CHECK(ex_no_props_15 != null_ptr); + + ex_no_props_t ex_no_props_16(ex_one_prop_1); + + ASIO_CHECK(ex_no_props_16.target<void>() == 0); + ASIO_CHECK(ex_no_props_16 == null_ptr); + + ex_no_props_t ex_no_props_17(ex_one_prop_5); + + ASIO_CHECK(ex_no_props_17.target<void>() != 0); + ASIO_CHECK(ex_no_props_17 != null_ptr); + + ex_no_props_t ex_no_props_18(ex_one_prop_9); + + ASIO_CHECK(ex_no_props_18.target<void>() != 0); + ASIO_CHECK(ex_no_props_18 != null_ptr); +} + +void any_executor_nothrow_construction_test() +{ + typedef execution::any_executor<> ex_no_props_t; + + typedef execution::any_executor< + execution::blocking_t + > ex_one_prop_t; + + typedef execution::any_executor< + execution::blocking_t, + execution::occupancy_t + > ex_two_props_t; + + thread_pool pool(1); + asio::nullptr_t null_ptr = asio::nullptr_t(); + + ex_two_props_t ex_two_props_1; + + ASIO_CHECK(ex_two_props_1.target<void>() == 0); + ASIO_CHECK(ex_two_props_1 == null_ptr); + + ex_two_props_t ex_two_props_2(null_ptr); + + ASIO_CHECK(ex_two_props_2.target<void>() == 0); + ASIO_CHECK(ex_two_props_2 == null_ptr); + ASIO_CHECK(ex_two_props_2 == ex_two_props_1); + + ex_two_props_t ex_two_props_3(std::nothrow, pool.executor()); + + ASIO_CHECK(ex_two_props_3.target<void>() != 0); + ASIO_CHECK(ex_two_props_3 != null_ptr); + ASIO_CHECK(ex_two_props_3 != ex_two_props_1); + + ex_two_props_t ex_two_props_4(std::nothrow, ex_two_props_1); + + ASIO_CHECK(ex_two_props_4.target<void>() == 0); + ASIO_CHECK(ex_two_props_4 == null_ptr); + ASIO_CHECK(ex_two_props_4 == ex_two_props_1); + + ex_two_props_t ex_two_props_5(std::nothrow, ex_two_props_3); + + ASIO_CHECK(ex_two_props_5.target<void>() != 0); + ASIO_CHECK(ex_two_props_5 != null_ptr); + ASIO_CHECK(ex_two_props_5 == ex_two_props_3); + + ex_two_props_t ex_two_props_6(std::nothrow, fat_executor(1)); + + ASIO_CHECK(ex_two_props_6.target<void>() != 0); + ASIO_CHECK(ex_two_props_6 != null_ptr); + ASIO_CHECK(ex_two_props_6 != ex_two_props_1); + + ex_two_props_t ex_two_props_7(std::nothrow, fat_executor(1)); + + ASIO_CHECK(ex_two_props_7.target<void>() != 0); + ASIO_CHECK(ex_two_props_7 != null_ptr); + ASIO_CHECK(ex_two_props_7 != ex_two_props_1); + ASIO_CHECK(ex_two_props_7 == ex_two_props_6); + + ex_two_props_t ex_two_props_8(std::nothrow, fat_executor(2)); + + ASIO_CHECK(ex_two_props_8.target<void>() != 0); + ASIO_CHECK(ex_two_props_8 != null_ptr); + ASIO_CHECK(ex_two_props_8 != ex_two_props_1); + ASIO_CHECK(ex_two_props_8 != ex_two_props_6); + ASIO_CHECK(ex_two_props_8 != ex_two_props_7); + + ex_two_props_t ex_two_props_9(std::nothrow, ex_two_props_6); + + ASIO_CHECK(ex_two_props_9.target<void>() != 0); + ASIO_CHECK(ex_two_props_9 != null_ptr); + ASIO_CHECK(ex_two_props_9 != ex_two_props_1); + ASIO_CHECK(ex_two_props_9 == ex_two_props_6); + ASIO_CHECK(ex_two_props_9 == ex_two_props_7); + ASIO_CHECK(ex_two_props_9 != ex_two_props_8); + + ex_two_props_t ex_two_props_10(std::nothrow, std::move(ex_two_props_1)); + + ASIO_CHECK(ex_two_props_10.target<void>() == 0); + ASIO_CHECK(ex_two_props_10 == null_ptr); + ASIO_CHECK(ex_two_props_1.target<void>() == 0); + ASIO_CHECK(ex_two_props_1 == null_ptr); + + ex_two_props_t ex_two_props_11(std::nothrow, std::move(ex_two_props_3)); + + ASIO_CHECK(ex_two_props_11.target<void>() != 0); + ASIO_CHECK(ex_two_props_11 != null_ptr); + ASIO_CHECK(ex_two_props_3.target<void>() == 0); + ASIO_CHECK(ex_two_props_3 == null_ptr); + ASIO_CHECK(ex_two_props_11 == ex_two_props_5); + + ex_two_props_t ex_two_props_12(std::nothrow, std::move(ex_two_props_7)); + + ASIO_CHECK(ex_two_props_12.target<void>() != 0); + ASIO_CHECK(ex_two_props_12 != null_ptr); + ASIO_CHECK(ex_two_props_7.target<void>() == 0); + ASIO_CHECK(ex_two_props_7 == null_ptr); + ASIO_CHECK(ex_two_props_12 == ex_two_props_6); + ASIO_CHECK(ex_two_props_12 != ex_two_props_8); + + next_nothrow_new_fails = true; + ex_two_props_t ex_two_props_13(std::nothrow, fat_executor(3)); + + ASIO_CHECK(ex_two_props_13.target<void>() == 0); + ASIO_CHECK(ex_two_props_13 == null_ptr); + ASIO_CHECK(ex_two_props_13 == ex_two_props_1); + + ex_one_prop_t ex_one_prop_1; + + ASIO_CHECK(ex_one_prop_1.target<void>() == 0); + ASIO_CHECK(ex_one_prop_1 == null_ptr); + + ex_one_prop_t ex_one_prop_2(null_ptr); + + ASIO_CHECK(ex_one_prop_2.target<void>() == 0); + ASIO_CHECK(ex_one_prop_2 == null_ptr); + ASIO_CHECK(ex_one_prop_2 == ex_one_prop_1); + + ex_one_prop_t ex_one_prop_3(std::nothrow, pool.executor()); + + ASIO_CHECK(ex_one_prop_3.target<void>() != 0); + ASIO_CHECK(ex_one_prop_3 != null_ptr); + ASIO_CHECK(ex_one_prop_3 != ex_one_prop_1); + + ex_one_prop_t ex_one_prop_4(std::nothrow, ex_one_prop_1); + + ASIO_CHECK(ex_one_prop_4.target<void>() == 0); + ASIO_CHECK(ex_one_prop_4 == null_ptr); + ASIO_CHECK(ex_one_prop_4 == ex_one_prop_1); + + ex_one_prop_t ex_one_prop_5(std::nothrow, ex_one_prop_3); + + ASIO_CHECK(ex_one_prop_5.target<void>() != 0); + ASIO_CHECK(ex_one_prop_5 != null_ptr); + ASIO_CHECK(ex_one_prop_5 == ex_one_prop_3); + + ex_one_prop_t ex_one_prop_6 = fat_executor(1); + + ASIO_CHECK(ex_one_prop_6.target<void>() != 0); + ASIO_CHECK(ex_one_prop_6 != null_ptr); + ASIO_CHECK(ex_one_prop_6 != ex_one_prop_1); + + ex_one_prop_t ex_one_prop_7(std::nothrow, fat_executor(1)); + + ASIO_CHECK(ex_one_prop_7.target<void>() != 0); + ASIO_CHECK(ex_one_prop_7 != null_ptr); + ASIO_CHECK(ex_one_prop_7 != ex_one_prop_1); + ASIO_CHECK(ex_one_prop_7 == ex_one_prop_6); + + ex_one_prop_t ex_one_prop_8(std::nothrow, fat_executor(2)); + + ASIO_CHECK(ex_one_prop_8.target<void>() != 0); + ASIO_CHECK(ex_one_prop_8 != null_ptr); + ASIO_CHECK(ex_one_prop_8 != ex_one_prop_1); + ASIO_CHECK(ex_one_prop_8 != ex_one_prop_6); + ASIO_CHECK(ex_one_prop_8 != ex_one_prop_7); + + ex_one_prop_t ex_one_prop_9(std::nothrow, ex_one_prop_6); + + ASIO_CHECK(ex_one_prop_9.target<void>() != 0); + ASIO_CHECK(ex_one_prop_9 != null_ptr); + ASIO_CHECK(ex_one_prop_9 != ex_one_prop_1); + ASIO_CHECK(ex_one_prop_9 == ex_one_prop_6); + ASIO_CHECK(ex_one_prop_9 == ex_one_prop_7); + ASIO_CHECK(ex_one_prop_9 != ex_one_prop_8); + + ex_one_prop_t ex_one_prop_10(std::nothrow, std::move(ex_one_prop_1)); + + ASIO_CHECK(ex_one_prop_10.target<void>() == 0); + ASIO_CHECK(ex_one_prop_10 == null_ptr); + ASIO_CHECK(ex_one_prop_1.target<void>() == 0); + ASIO_CHECK(ex_one_prop_1 == null_ptr); + + ex_one_prop_t ex_one_prop_11(std::nothrow, std::move(ex_one_prop_3)); + + ASIO_CHECK(ex_one_prop_11.target<void>() != 0); + ASIO_CHECK(ex_one_prop_11 != null_ptr); + ASIO_CHECK(ex_one_prop_3.target<void>() == 0); + ASIO_CHECK(ex_one_prop_3 == null_ptr); + ASIO_CHECK(ex_one_prop_11 == ex_one_prop_5); + + ex_one_prop_t ex_one_prop_12(std::nothrow, std::move(ex_one_prop_7)); + + ASIO_CHECK(ex_one_prop_12.target<void>() != 0); + ASIO_CHECK(ex_one_prop_12 != null_ptr); + ASIO_CHECK(ex_one_prop_7.target<void>() == 0); + ASIO_CHECK(ex_one_prop_7 == null_ptr); + ASIO_CHECK(ex_one_prop_12 == ex_one_prop_6); + ASIO_CHECK(ex_one_prop_12 != ex_one_prop_8); + + ex_one_prop_t ex_one_prop_13(std::nothrow, ex_two_props_1); + + ASIO_CHECK(ex_one_prop_13.target<void>() == 0); + ASIO_CHECK(ex_one_prop_13 == null_ptr); + + ex_one_prop_t ex_one_prop_14(std::nothrow, ex_two_props_5); + + ASIO_CHECK(ex_one_prop_14.target<void>() != 0); + ASIO_CHECK(ex_one_prop_14 != null_ptr); + + ex_one_prop_t ex_one_prop_15(std::nothrow, ex_two_props_9); + + ASIO_CHECK(ex_one_prop_15.target<void>() != 0); + ASIO_CHECK(ex_one_prop_15 != null_ptr); + + next_nothrow_new_fails = true; + ex_one_prop_t ex_one_prop_16(std::nothrow, fat_executor(3)); + + ASIO_CHECK(ex_one_prop_16.target<void>() == 0); + ASIO_CHECK(ex_one_prop_16 == null_ptr); + ASIO_CHECK(ex_one_prop_16 == ex_one_prop_1); + + ex_no_props_t ex_no_props_1; + + ASIO_CHECK(ex_no_props_1.target<void>() == 0); + ASIO_CHECK(ex_no_props_1 == null_ptr); + + ex_no_props_t ex_no_props_2(null_ptr); + + ASIO_CHECK(ex_no_props_2.target<void>() == 0); + ASIO_CHECK(ex_no_props_2 == null_ptr); + ASIO_CHECK(ex_no_props_2 == ex_no_props_1); + + ex_no_props_t ex_no_props_3(std::nothrow, pool.executor()); + + ASIO_CHECK(ex_no_props_3.target<void>() != 0); + ASIO_CHECK(ex_no_props_3 != null_ptr); + ASIO_CHECK(ex_no_props_3 != ex_no_props_1); + + ex_no_props_t ex_no_props_4(std::nothrow, ex_no_props_1); + + ASIO_CHECK(ex_no_props_4.target<void>() == 0); + ASIO_CHECK(ex_no_props_4 == null_ptr); + ASIO_CHECK(ex_no_props_4 == ex_no_props_1); + + ex_no_props_t ex_no_props_5(std::nothrow, ex_no_props_3); + + ASIO_CHECK(ex_no_props_5.target<void>() != 0); + ASIO_CHECK(ex_no_props_5 != null_ptr); + ASIO_CHECK(ex_no_props_5 == ex_no_props_3); + + ex_no_props_t ex_no_props_6(std::nothrow, fat_executor(1)); + + ASIO_CHECK(ex_no_props_6.target<void>() != 0); + ASIO_CHECK(ex_no_props_6 != null_ptr); + ASIO_CHECK(ex_no_props_6 != ex_no_props_1); + + ex_no_props_t ex_no_props_7(std::nothrow, fat_executor(1)); + + ASIO_CHECK(ex_no_props_7.target<void>() != 0); + ASIO_CHECK(ex_no_props_7 != null_ptr); + ASIO_CHECK(ex_no_props_7 != ex_no_props_1); + ASIO_CHECK(ex_no_props_7 == ex_no_props_6); + + ex_no_props_t ex_no_props_8(std::nothrow, fat_executor(2)); + + ASIO_CHECK(ex_no_props_8.target<void>() != 0); + ASIO_CHECK(ex_no_props_8 != null_ptr); + ASIO_CHECK(ex_no_props_8 != ex_no_props_1); + ASIO_CHECK(ex_no_props_8 != ex_no_props_6); + ASIO_CHECK(ex_no_props_8 != ex_no_props_7); + + ex_no_props_t ex_no_props_9(std::nothrow, ex_no_props_6); + + ASIO_CHECK(ex_no_props_9.target<void>() != 0); + ASIO_CHECK(ex_no_props_9 != null_ptr); + ASIO_CHECK(ex_no_props_9 != ex_no_props_1); + ASIO_CHECK(ex_no_props_9 == ex_no_props_6); + ASIO_CHECK(ex_no_props_9 == ex_no_props_7); + ASIO_CHECK(ex_no_props_9 != ex_no_props_8); + + ex_no_props_t ex_no_props_10(std::nothrow, std::move(ex_no_props_1)); + + ASIO_CHECK(ex_no_props_10.target<void>() == 0); + ASIO_CHECK(ex_no_props_10 == null_ptr); + ASIO_CHECK(ex_no_props_1.target<void>() == 0); + ASIO_CHECK(ex_no_props_1 == null_ptr); + + ex_no_props_t ex_no_props_11(std::nothrow, std::move(ex_no_props_3)); + + ASIO_CHECK(ex_no_props_11.target<void>() != 0); + ASIO_CHECK(ex_no_props_11 != null_ptr); + ASIO_CHECK(ex_no_props_3.target<void>() == 0); + ASIO_CHECK(ex_no_props_3 == null_ptr); + ASIO_CHECK(ex_no_props_11 == ex_no_props_5); + + ex_no_props_t ex_no_props_12(std::nothrow, std::move(ex_no_props_7)); + + ASIO_CHECK(ex_no_props_12.target<void>() != 0); + ASIO_CHECK(ex_no_props_12 != null_ptr); + ASIO_CHECK(ex_no_props_7.target<void>() == 0); + ASIO_CHECK(ex_no_props_7 == null_ptr); + ASIO_CHECK(ex_no_props_12 == ex_no_props_6); + ASIO_CHECK(ex_no_props_12 != ex_no_props_8); + + ex_no_props_t ex_no_props_13(std::nothrow, ex_two_props_1); + + ASIO_CHECK(ex_no_props_13.target<void>() == 0); + ASIO_CHECK(ex_no_props_13 == null_ptr); + + ex_no_props_t ex_no_props_14(std::nothrow, ex_two_props_5); + + ASIO_CHECK(ex_no_props_14.target<void>() != 0); + ASIO_CHECK(ex_no_props_14 != null_ptr); + + ex_no_props_t ex_no_props_15(std::nothrow, ex_two_props_9); + + ASIO_CHECK(ex_no_props_15.target<void>() != 0); + ASIO_CHECK(ex_no_props_15 != null_ptr); + + ex_no_props_t ex_no_props_16(std::nothrow, ex_one_prop_1); + + ASIO_CHECK(ex_no_props_16.target<void>() == 0); + ASIO_CHECK(ex_no_props_16 == null_ptr); + + ex_no_props_t ex_no_props_17(std::nothrow, ex_one_prop_5); + + ASIO_CHECK(ex_no_props_17.target<void>() != 0); + ASIO_CHECK(ex_no_props_17 != null_ptr); + + ex_no_props_t ex_no_props_18(std::nothrow, ex_one_prop_9); + + ASIO_CHECK(ex_no_props_18.target<void>() != 0); + ASIO_CHECK(ex_no_props_18 != null_ptr); + + next_nothrow_new_fails = true; + ex_no_props_t ex_no_props_19(std::nothrow, fat_executor(3)); + + ASIO_CHECK(ex_no_props_19.target<void>() == 0); + ASIO_CHECK(ex_no_props_19 == null_ptr); + ASIO_CHECK(ex_no_props_19 == ex_no_props_1); +} + +void any_executor_assignment_test() +{ + typedef execution::any_executor<> ex_no_props_t; + + typedef execution::any_executor< + execution::blocking_t + > ex_one_prop_t; + + typedef execution::any_executor< + execution::blocking_t, + execution::occupancy_t + > ex_two_props_t; + + thread_pool pool(1); + asio::nullptr_t null_ptr = asio::nullptr_t(); + + ex_two_props_t ex_two_props_1; + + ex_two_props_t ex_two_props_2; + ex_two_props_2 = null_ptr; + + ASIO_CHECK(ex_two_props_2.target<void>() == 0); + + ex_two_props_t ex_two_props_3; + ex_two_props_3 = pool.executor(); + + ASIO_CHECK(ex_two_props_3.target<void>() != 0); + + ex_two_props_t ex_two_props_4; + ex_two_props_4 = ex_two_props_1; + + ASIO_CHECK(ex_two_props_4.target<void>() == 0); + ASIO_CHECK(ex_two_props_4 == ex_two_props_1); + + ex_two_props_4 = ex_two_props_3; + + ASIO_CHECK(ex_two_props_4.target<void>() != 0); + ASIO_CHECK(ex_two_props_4 == ex_two_props_3); + + ex_two_props_t ex_two_props_5; + ex_two_props_5 = fat_executor(1); + + ASIO_CHECK(ex_two_props_5.target<void>() != 0); + ASIO_CHECK(ex_two_props_5 != null_ptr); + ASIO_CHECK(ex_two_props_5 != ex_two_props_1); + + ex_two_props_t ex_two_props_6; + ex_two_props_6 = fat_executor(1); + + ASIO_CHECK(ex_two_props_6.target<void>() != 0); + ASIO_CHECK(ex_two_props_6 != null_ptr); + ASIO_CHECK(ex_two_props_6 != ex_two_props_1); + ASIO_CHECK(ex_two_props_6 == ex_two_props_5); + + ex_two_props_6 = fat_executor(2); + + ASIO_CHECK(ex_two_props_6.target<void>() != 0); + ASIO_CHECK(ex_two_props_6 != null_ptr); + ASIO_CHECK(ex_two_props_6 != ex_two_props_1); + ASIO_CHECK(ex_two_props_6 != ex_two_props_5); + + ex_two_props_t ex_two_props_7; + ex_two_props_7 = ex_two_props_5; + + ASIO_CHECK(ex_two_props_7.target<void>() != 0); + ASIO_CHECK(ex_two_props_7 != null_ptr); + ASIO_CHECK(ex_two_props_7 != ex_two_props_1); + ASIO_CHECK(ex_two_props_7 == ex_two_props_5); + ASIO_CHECK(ex_two_props_7 != ex_two_props_6); + + ex_two_props_t ex_two_props_8; + ex_two_props_8 = std::move(ex_two_props_1); + + ASIO_CHECK(ex_two_props_8.target<void>() == 0); + ASIO_CHECK(ex_two_props_1.target<void>() == 0); + + ex_two_props_8 = std::move(ex_two_props_3); + + ASIO_CHECK(ex_two_props_8.target<void>() != 0); + ASIO_CHECK(ex_two_props_3.target<void>() == 0); + ASIO_CHECK(ex_two_props_8 == ex_two_props_4); + + ex_two_props_8 = std::move(ex_two_props_5); + + ASIO_CHECK(ex_two_props_8.target<void>() != 0); + ASIO_CHECK(ex_two_props_5.target<void>() == 0); + ASIO_CHECK(ex_two_props_8 == ex_two_props_7); + + ex_one_prop_t ex_one_prop_1; + + ex_one_prop_t ex_one_prop_2; + ex_one_prop_2 = null_ptr; + + ASIO_CHECK(ex_one_prop_2.target<void>() == 0); + + ex_one_prop_t ex_one_prop_3; + ex_one_prop_3 = pool.executor(); + + ASIO_CHECK(ex_one_prop_3.target<void>() != 0); + + ex_one_prop_t ex_one_prop_4; + ex_one_prop_4 = ex_one_prop_1; + + ASIO_CHECK(ex_one_prop_4.target<void>() == 0); + ASIO_CHECK(ex_one_prop_4 == ex_one_prop_1); + + ex_one_prop_4 = ex_one_prop_3; + + ASIO_CHECK(ex_one_prop_4.target<void>() != 0); + ASIO_CHECK(ex_one_prop_4 == ex_one_prop_3); + + ex_one_prop_t ex_one_prop_5; + ex_one_prop_5 = fat_executor(1); + + ASIO_CHECK(ex_one_prop_5.target<void>() != 0); + ASIO_CHECK(ex_one_prop_5 != null_ptr); + ASIO_CHECK(ex_one_prop_5 != ex_one_prop_1); + + ex_one_prop_t ex_one_prop_6; + ex_one_prop_6 = fat_executor(1); + + ASIO_CHECK(ex_one_prop_6.target<void>() != 0); + ASIO_CHECK(ex_one_prop_6 != null_ptr); + ASIO_CHECK(ex_one_prop_6 != ex_one_prop_1); + ASIO_CHECK(ex_one_prop_6 == ex_one_prop_5); + + ex_one_prop_6 = fat_executor(2); + + ASIO_CHECK(ex_one_prop_6.target<void>() != 0); + ASIO_CHECK(ex_one_prop_6 != null_ptr); + ASIO_CHECK(ex_one_prop_6 != ex_one_prop_1); + ASIO_CHECK(ex_one_prop_6 != ex_one_prop_5); + + ex_one_prop_t ex_one_prop_7; + ex_one_prop_7 = ex_one_prop_5; + + ASIO_CHECK(ex_one_prop_7.target<void>() != 0); + ASIO_CHECK(ex_one_prop_7 != null_ptr); + ASIO_CHECK(ex_one_prop_7 != ex_one_prop_1); + ASIO_CHECK(ex_one_prop_7 == ex_one_prop_5); + ASIO_CHECK(ex_one_prop_7 != ex_one_prop_6); + + ex_one_prop_t ex_one_prop_8; + ex_one_prop_8 = std::move(ex_one_prop_1); + + ASIO_CHECK(ex_one_prop_8.target<void>() == 0); + ASIO_CHECK(ex_one_prop_1.target<void>() == 0); + + ex_one_prop_8 = std::move(ex_one_prop_3); + + ASIO_CHECK(ex_one_prop_8.target<void>() != 0); + ASIO_CHECK(ex_one_prop_3.target<void>() == 0); + ASIO_CHECK(ex_one_prop_8 == ex_one_prop_4); + + ex_one_prop_8 = std::move(ex_one_prop_5); + + ASIO_CHECK(ex_one_prop_8.target<void>() != 0); + ASIO_CHECK(ex_one_prop_5.target<void>() == 0); + ASIO_CHECK(ex_one_prop_8 == ex_one_prop_7); + + ex_one_prop_t ex_one_prop_9; + ex_one_prop_9 = ex_two_props_1; + + ASIO_CHECK(ex_one_prop_9.target<void>() == 0); + + ex_one_prop_9 = ex_two_props_4; + + ASIO_CHECK(ex_one_prop_9.target<void>() != 0); + + ex_one_prop_9 = ex_two_props_7; + + ASIO_CHECK(ex_one_prop_9.target<void>() != 0); + + ex_no_props_t ex_no_props_1; + + ex_no_props_t ex_no_props_2; + ex_no_props_2 = null_ptr; + + ASIO_CHECK(ex_no_props_2.target<void>() == 0); + + ex_no_props_t ex_no_props_3; + ex_no_props_3 = pool.executor(); + + ASIO_CHECK(ex_no_props_3.target<void>() != 0); + + ex_no_props_t ex_no_props_4; + ex_no_props_4 = ex_no_props_1; + + ASIO_CHECK(ex_no_props_4.target<void>() == 0); + ASIO_CHECK(ex_no_props_4 == ex_no_props_1); + + ex_no_props_4 = ex_no_props_3; + + ASIO_CHECK(ex_no_props_4.target<void>() != 0); + ASIO_CHECK(ex_no_props_4 == ex_no_props_3); + + ex_no_props_t ex_no_props_5; + ex_no_props_5 = fat_executor(1); + + ASIO_CHECK(ex_no_props_5.target<void>() != 0); + ASIO_CHECK(ex_no_props_5 != null_ptr); + ASIO_CHECK(ex_no_props_5 != ex_no_props_1); + + ex_no_props_t ex_no_props_6; + ex_no_props_6 = fat_executor(1); + + ASIO_CHECK(ex_no_props_6.target<void>() != 0); + ASIO_CHECK(ex_no_props_6 != null_ptr); + ASIO_CHECK(ex_no_props_6 != ex_no_props_1); + ASIO_CHECK(ex_no_props_6 == ex_no_props_5); + + ex_no_props_6 = fat_executor(2); + + ASIO_CHECK(ex_no_props_6.target<void>() != 0); + ASIO_CHECK(ex_no_props_6 != null_ptr); + ASIO_CHECK(ex_no_props_6 != ex_no_props_1); + ASIO_CHECK(ex_no_props_6 != ex_no_props_5); + + ex_no_props_t ex_no_props_7; + ex_no_props_7 = ex_no_props_5; + + ASIO_CHECK(ex_no_props_7.target<void>() != 0); + ASIO_CHECK(ex_no_props_7 != null_ptr); + ASIO_CHECK(ex_no_props_7 != ex_no_props_1); + ASIO_CHECK(ex_no_props_7 == ex_no_props_5); + ASIO_CHECK(ex_no_props_7 != ex_no_props_6); + + ex_no_props_t ex_no_props_8; + ex_no_props_8 = std::move(ex_no_props_1); + + ASIO_CHECK(ex_no_props_8.target<void>() == 0); + ASIO_CHECK(ex_no_props_1.target<void>() == 0); + + ex_no_props_8 = std::move(ex_no_props_3); + + ASIO_CHECK(ex_no_props_8.target<void>() != 0); + ASIO_CHECK(ex_no_props_3.target<void>() == 0); + ASIO_CHECK(ex_no_props_8 == ex_no_props_4); + + ex_no_props_8 = std::move(ex_no_props_5); + + ASIO_CHECK(ex_no_props_8.target<void>() != 0); + ASIO_CHECK(ex_no_props_5.target<void>() == 0); + ASIO_CHECK(ex_no_props_8 == ex_no_props_7); + + ex_no_props_t ex_no_props_9; + ex_no_props_9 = ex_two_props_1; + + ASIO_CHECK(ex_no_props_9.target<void>() == 0); + + ex_no_props_9 = ex_two_props_4; + + ASIO_CHECK(ex_no_props_9.target<void>() != 0); + + ex_no_props_9 = ex_two_props_7; + + ASIO_CHECK(ex_no_props_9.target<void>() != 0); + + ex_no_props_9 = ex_one_prop_1; + + ASIO_CHECK(ex_no_props_9.target<void>() == 0); + + ex_no_props_9 = ex_one_prop_4; + + ASIO_CHECK(ex_no_props_9.target<void>() != 0); + + ex_no_props_9 = ex_one_prop_7; + + ASIO_CHECK(ex_no_props_9.target<void>() != 0); +} + +void any_executor_swap_test() +{ + typedef execution::any_executor<> ex_no_props_t; + + typedef execution::any_executor< + execution::blocking_t + > ex_one_prop_t; + + typedef execution::any_executor< + execution::blocking_t, + execution::occupancy_t + > ex_two_props_t; + + thread_pool pool1(1); + thread_pool pool2(1); + + ex_no_props_t ex_no_props_1(pool1.executor()); + ex_no_props_t ex_no_props_2(pool2.executor()); + + ex_no_props_t ex_no_props_3(ex_no_props_1); + ex_no_props_t ex_no_props_4(ex_no_props_2); + + ASIO_CHECK(ex_no_props_3 == ex_no_props_1); + ASIO_CHECK(ex_no_props_4 == ex_no_props_2); + + ex_no_props_3.swap(ex_no_props_4); + + ASIO_CHECK(ex_no_props_3 == ex_no_props_2); + ASIO_CHECK(ex_no_props_4 == ex_no_props_1); + + execution::swap(ex_no_props_3, ex_no_props_4); + + ASIO_CHECK(ex_no_props_3 == ex_no_props_1); + ASIO_CHECK(ex_no_props_4 == ex_no_props_2); + + ex_one_prop_t ex_one_prop_1(pool1.executor()); + ex_one_prop_t ex_one_prop_2(pool2.executor()); + + ex_one_prop_t ex_one_prop_3(ex_one_prop_1); + ex_one_prop_t ex_one_prop_4(ex_one_prop_2); + + ASIO_CHECK(ex_one_prop_3 == ex_one_prop_1); + ASIO_CHECK(ex_one_prop_4 == ex_one_prop_2); + + ex_one_prop_3.swap(ex_one_prop_4); + + ASIO_CHECK(ex_one_prop_3 == ex_one_prop_2); + ASIO_CHECK(ex_one_prop_4 == ex_one_prop_1); + + execution::swap(ex_one_prop_3, ex_one_prop_4); + + ASIO_CHECK(ex_one_prop_3 == ex_one_prop_1); + ASIO_CHECK(ex_one_prop_4 == ex_one_prop_2); + + ex_two_props_t ex_two_props_1(pool1.executor()); + ex_two_props_t ex_two_props_2(pool2.executor()); + + ex_two_props_t ex_two_props_3(ex_two_props_1); + ex_two_props_t ex_two_props_4(ex_two_props_2); + + ASIO_CHECK(ex_two_props_3 == ex_two_props_1); + ASIO_CHECK(ex_two_props_4 == ex_two_props_2); + + ex_two_props_3.swap(ex_two_props_4); + + ASIO_CHECK(ex_two_props_3 == ex_two_props_2); + ASIO_CHECK(ex_two_props_4 == ex_two_props_1); + + execution::swap(ex_two_props_3, ex_two_props_4); + + ASIO_CHECK(ex_two_props_3 == ex_two_props_1); + ASIO_CHECK(ex_two_props_4 == ex_two_props_2); +} + +void any_executor_query_test() +{ + thread_pool pool(1); + execution::any_executor< + execution::blocking_t, + execution::outstanding_work_t, + execution::relationship_t, + execution::mapping_t::thread_t, + execution::occupancy_t> + ex(pool.executor()); + + ASIO_CHECK( + asio::query(ex, asio::execution::blocking) + == asio::execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ex, asio::execution::blocking.possibly) + == asio::execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ex, asio::execution::outstanding_work) + == asio::execution::outstanding_work.untracked); + + ASIO_CHECK( + asio::query(ex, asio::execution::outstanding_work.untracked) + == asio::execution::outstanding_work.untracked); + + ASIO_CHECK( + asio::query(ex, asio::execution::relationship) + == asio::execution::relationship.fork); + + ASIO_CHECK( + asio::query(ex, asio::execution::relationship.fork) + == asio::execution::relationship.fork); + + ASIO_CHECK( + asio::query(ex, asio::execution::mapping) + == asio::execution::mapping.thread); + + ASIO_CHECK( + asio::query(ex, asio::execution::occupancy) + == 1); +} + +void any_executor_execute_test() +{ + int count = 0; + thread_pool pool(1); + execution::any_executor< + execution::blocking_t::possibly_t, + execution::blocking_t::never_t, + execution::outstanding_work_t::untracked_t, + execution::outstanding_work_t::tracked_t, + execution::relationship_t::continuation_t> + ex(pool.executor()); + + ex.execute(bindns::bind(increment, &count)); + + asio::require(ex, asio::execution::blocking.possibly).execute( + bindns::bind(increment, &count)); + + asio::require(ex, asio::execution::blocking.never).execute( + bindns::bind(increment, &count)); + + asio::require(ex, + asio::execution::blocking.never, + asio::execution::outstanding_work.tracked + ).execute(bindns::bind(increment, &count)); + + asio::require(ex, + asio::execution::blocking.never, + asio::execution::outstanding_work.untracked + ).execute(bindns::bind(increment, &count)); + + asio::require(ex, + asio::execution::blocking.never, + asio::execution::outstanding_work.untracked, + asio::execution::relationship.continuation + ).execute(bindns::bind(increment, &count)); + + pool.wait(); + + ASIO_CHECK(count == 6); +} + +ASIO_TEST_SUITE +( + "any_executor", + ASIO_TEST_CASE(any_executor_construction_test) + ASIO_TEST_CASE(any_executor_nothrow_construction_test) + ASIO_TEST_CASE(any_executor_assignment_test) + ASIO_TEST_CASE(any_executor_swap_test) + ASIO_TEST_CASE(any_executor_query_test) + ASIO_TEST_CASE(any_executor_execute_test) +) diff --git a/3rdparty/asio/src/tests/unit/execution/blocking.cpp b/3rdparty/asio/src/tests/unit/execution/blocking.cpp new file mode 100644 index 00000000000..ce2ba2f8ea5 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/execution/blocking.cpp @@ -0,0 +1,1921 @@ +// +// blocking.cpp +// ~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/execution/blocking.hpp" + +#include "asio/prefer.hpp" +#include "asio/query.hpp" +#include "asio/require.hpp" +#include "../unit_test.hpp" + +namespace exec = asio::execution; + +typedef exec::blocking_t s; +typedef exec::blocking_t::possibly_t n1; +typedef exec::blocking_t::always_t n2; +typedef exec::blocking_t::never_t n3; + +struct ex_nq_nr +{ + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_nq_nr&, const ex_nq_nr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_nq_nr&, const ex_nq_nr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <> +struct is_executor<ex_nq_nr> : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +template <typename ResultType, typename ParamType, typename Result> +struct ex_cq_nr +{ + static constexpr ResultType query(ParamType) noexcept + { + return Result(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_cq_nr&, const ex_cq_nr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_cq_nr&, const ex_cq_nr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <typename ResultType, typename ParamType, typename Result> +struct is_executor<ex_cq_nr<ResultType, ParamType, Result> > + : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT) + +template <typename ResultType, typename ParamType, + typename Result, typename Param> +struct query_static_constexpr_member< + ex_cq_nr<ResultType, ParamType, Result>, Param, + typename asio::enable_if< + asio::is_convertible<Param, ParamType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef Result result_type; // Must return raw result type. + + static constexpr result_type value() + { + return Result(); + } +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename ResultType, typename ParamType, typename Result> +struct ex_mq_nr +{ + ResultType query(ParamType) const noexcept + { + return Result(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_mq_nr&, const ex_mq_nr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_mq_nr&, const ex_mq_nr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <typename ResultType, typename ParamType, typename Result> +struct is_executor<ex_mq_nr<ResultType, ParamType, Result> > + : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +template <typename ResultType, typename ParamType, + typename Result, typename Param> +struct query_member< + ex_mq_nr<ResultType, ParamType, Result>, Param, + typename asio::enable_if< + asio::is_convertible<Param, ParamType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ResultType result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename ResultType, typename ParamType, typename Result> +struct ex_fq_nr +{ + friend ResultType query(const ex_fq_nr&, ParamType) noexcept + { + return Result(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_fq_nr&, const ex_fq_nr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_fq_nr&, const ex_fq_nr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <typename ResultType, typename ParamType, typename Result> +struct is_executor<ex_fq_nr<ResultType, ParamType, Result> > + : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) + +template <typename ResultType, typename ParamType, + typename Result, typename Param> +struct query_free< + ex_fq_nr<ResultType, ParamType, Result>, Param, + typename asio::enable_if< + asio::is_convertible<Param, ParamType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ResultType result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename CurrentType, typename OtherType> +struct ex_mq_mr +{ + CurrentType query(CurrentType) const noexcept + { + return CurrentType(); + } + + CurrentType query(OtherType) const noexcept + { + return CurrentType(); + } + + ex_mq_mr<CurrentType, OtherType> require( + CurrentType) const noexcept + { + return ex_mq_mr<CurrentType, OtherType>(); + } + + ex_mq_mr<OtherType, CurrentType> require( + OtherType) const noexcept + { + return ex_mq_mr<OtherType, CurrentType>(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_mq_mr&, const ex_mq_mr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_mq_mr&, const ex_mq_mr&) noexcept + { + return false; + } +}; + +template <typename CurrentType> +struct ex_mq_mr<CurrentType, CurrentType> +{ + CurrentType query(CurrentType) const noexcept + { + return CurrentType(); + } + + ex_mq_mr<CurrentType, CurrentType> require( + CurrentType) const noexcept + { + return ex_mq_mr<CurrentType, CurrentType>(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_mq_mr&, const ex_mq_mr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_mq_mr&, const ex_mq_mr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <typename CurrentType, typename OtherType> +struct is_executor<ex_mq_mr<CurrentType, OtherType> > + : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct query_member< + ex_mq_mr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + || asio::is_convertible<Param, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef CurrentType result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct require_member< + ex_mq_mr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_mq_mr<CurrentType, OtherType> result_type; +}; + +template <typename CurrentType, typename OtherType, typename Param> +struct require_member< + ex_mq_mr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, OtherType>::value + && !asio::is_same<CurrentType, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_mq_mr<OtherType, CurrentType> result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename CurrentType, typename OtherType> +struct ex_fq_fr +{ + friend CurrentType query(const ex_fq_fr&, CurrentType) noexcept + { + return CurrentType(); + } + + friend CurrentType query(const ex_fq_fr&, OtherType) noexcept + { + return CurrentType(); + } + + friend ex_fq_fr<CurrentType, OtherType> require( + const ex_fq_fr&, CurrentType) noexcept + { + return ex_fq_fr<CurrentType, OtherType>(); + } + + friend ex_fq_fr<OtherType, CurrentType> require( + const ex_fq_fr&, OtherType) noexcept + { + return ex_fq_fr<OtherType, CurrentType>(); + } + + friend ex_fq_fr<CurrentType, OtherType> prefer( + const ex_fq_fr&, CurrentType) noexcept + { + return ex_fq_fr<CurrentType, OtherType>(); + } + + friend ex_fq_fr<OtherType, CurrentType> prefer( + const ex_fq_fr&, OtherType) noexcept + { + return ex_fq_fr<OtherType, CurrentType>(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_fq_fr&, const ex_fq_fr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_fq_fr&, const ex_fq_fr&) noexcept + { + return false; + } +}; + +template <typename CurrentType> +struct ex_fq_fr<CurrentType, CurrentType> +{ + friend CurrentType query(const ex_fq_fr&, CurrentType) noexcept + { + return CurrentType(); + } + + friend ex_fq_fr<CurrentType, CurrentType> require( + const ex_fq_fr&, CurrentType) noexcept + { + return ex_fq_fr<CurrentType, CurrentType>(); + } + + friend ex_fq_fr<CurrentType, CurrentType> prefer( + const ex_fq_fr&, CurrentType) noexcept + { + return ex_fq_fr<CurrentType, CurrentType>(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_fq_fr&, const ex_fq_fr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_fq_fr&, const ex_fq_fr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <typename CurrentType, typename OtherType> +struct is_executor<ex_fq_fr<CurrentType, OtherType> > + : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct query_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + || asio::is_convertible<Param, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef CurrentType result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_REQUIRE_FREE_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct require_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_fq_fr<CurrentType, OtherType> result_type; +}; + +template <typename CurrentType, typename OtherType, typename Param> +struct require_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, OtherType>::value + && !asio::is_same<CurrentType, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_fq_fr<OtherType, CurrentType> result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_REQUIRE_FREE_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_PREFER_FREE_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct prefer_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_fq_fr<CurrentType, OtherType> result_type; +}; + +template <typename CurrentType, typename OtherType, typename Param> +struct prefer_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, OtherType>::value + && !asio::is_same<CurrentType, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_fq_fr<OtherType, CurrentType> result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_PREFER_FREE_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename Executor, typename Param, bool ExpectedResult> +void test_can_query() +{ + constexpr bool b1 = + asio::can_query<Executor, Param>::value; + ASIO_CHECK(b1 == ExpectedResult); + + constexpr bool b2 = + asio::can_query<const Executor, Param>::value; + ASIO_CHECK(b2 == ExpectedResult); + + constexpr bool b3 = + asio::can_query<Executor&, Param>::value; + ASIO_CHECK(b3 == ExpectedResult); + + constexpr bool b4 = + asio::can_query<const Executor&, Param>::value; + ASIO_CHECK(b4 == ExpectedResult); +} + +template <typename Executor, typename Param, typename ExpectedResult> +void test_query() +{ + exec::blocking_t result1 = asio::query(Executor(), Param()); + ASIO_CHECK(result1 == ExpectedResult()); + + Executor ex1 = {}; + exec::blocking_t result2 = asio::query(ex1, Param()); + ASIO_CHECK(result2 == ExpectedResult()); + + const Executor ex2 = {}; + exec::blocking_t result3 = asio::query(ex2, Param()); + ASIO_CHECK(result3 == ExpectedResult()); +} + +template <typename Executor, typename Param, typename ExpectedResult> +void test_constexpr_query() +{ + constexpr Executor ex1 = {}; + constexpr exec::blocking_t result1 = asio::query(ex1, Param()); + ASIO_CHECK(result1 == ExpectedResult()); +} + +template <typename Executor, typename Param, bool ExpectedResult> +void test_can_require() +{ + constexpr bool b1 = + asio::can_require<Executor, Param>::value; + ASIO_CHECK(b1 == ExpectedResult); + + constexpr bool b2 = + asio::can_require<const Executor, Param>::value; + ASIO_CHECK(b2 == ExpectedResult); + + constexpr bool b3 = + asio::can_require<Executor&, Param>::value; + ASIO_CHECK(b3 == ExpectedResult); + + constexpr bool b4 = + asio::can_require<const Executor&, Param>::value; + ASIO_CHECK(b4 == ExpectedResult); +} + +template <typename Executor, typename Param, typename ExpectedResult> +void test_require() +{ + ASIO_CHECK( + asio::query( + asio::require(Executor(), Param()), + Param()) == ExpectedResult()); + + Executor ex1 = {}; + ASIO_CHECK( + asio::query( + asio::require(ex1, Param()), + Param()) == ExpectedResult()); + + const Executor ex2 = {}; + ASIO_CHECK( + asio::query( + asio::require(ex2, Param()), + Param()) == ExpectedResult()); +} + +template <typename Executor, typename Param, bool ExpectedResult> +void test_can_prefer() +{ + constexpr bool b1 = + asio::can_prefer<Executor, Param>::value; + ASIO_CHECK(b1 == ExpectedResult); + + constexpr bool b2 = + asio::can_prefer<const Executor, Param>::value; + ASIO_CHECK(b2 == ExpectedResult); + + constexpr bool b3 = + asio::can_prefer<Executor&, Param>::value; + ASIO_CHECK(b3 == ExpectedResult); + + constexpr bool b4 = + asio::can_prefer<const Executor&, Param>::value; + ASIO_CHECK(b4 == ExpectedResult); +} + +template <typename Executor, typename Param, typename ExpectedResult> +void test_prefer() +{ + ASIO_CHECK( + s(asio::query( + asio::prefer(Executor(), Param()), + s())) == s(ExpectedResult())); + + Executor ex1 = {}; + ASIO_CHECK( + s(asio::query( + asio::prefer(ex1, Param()), + s())) == s(ExpectedResult())); + + const Executor ex2 = {}; + ASIO_CHECK( + s(asio::query( + asio::prefer(ex2, Param()), + s())) == s(ExpectedResult())); +} + +void test_vars() +{ + ASIO_CHECK(s() == exec::blocking); + ASIO_CHECK(s() != exec::blocking.possibly); + ASIO_CHECK(s() != exec::blocking.always); + ASIO_CHECK(s() != exec::blocking.never); + ASIO_CHECK(n1() == exec::blocking.possibly); + ASIO_CHECK(n1() != exec::blocking.always); + ASIO_CHECK(n1() != exec::blocking.never); + ASIO_CHECK(n2() == exec::blocking.always); + ASIO_CHECK(n2() != exec::blocking.possibly); + ASIO_CHECK(n2() != exec::blocking.never); + ASIO_CHECK(n3() == exec::blocking.never); + ASIO_CHECK(n3() != exec::blocking.possibly); + ASIO_CHECK(n3() != exec::blocking.always); +} + +ASIO_TEST_SUITE +( + "blocking", + + ASIO_TEST_CASE3(test_can_query<ex_nq_nr, s, true>) + ASIO_TEST_CASE3(test_can_query<ex_nq_nr, n1, true>) + ASIO_TEST_CASE3(test_can_query<ex_nq_nr, n2, false>) + ASIO_TEST_CASE3(test_can_query<ex_nq_nr, n3, false>) + + ASIO_TEST_CASE3(test_query<ex_nq_nr, s, n1>) + ASIO_TEST_CASE3(test_query<ex_nq_nr, n1, n1>) + + ASIO_TEST_CASE3(test_constexpr_query<ex_nq_nr, s, n1>) + ASIO_TEST_CASE3(test_constexpr_query<ex_nq_nr, n1, n1>) + + ASIO_TEST_CASE3(test_can_require<ex_nq_nr, s, false>) + ASIO_TEST_CASE3(test_can_require<ex_nq_nr, n1, true>) + ASIO_TEST_CASE3(test_can_require<ex_nq_nr, n2, false>) + ASIO_TEST_CASE3(test_can_require<ex_nq_nr, n3, false>) + + ASIO_TEST_CASE3(test_require<ex_nq_nr, n1, n1>) + + ASIO_TEST_CASE3(test_can_prefer<ex_nq_nr, s, false>) + ASIO_TEST_CASE3(test_can_prefer<ex_nq_nr, n1, true>) + ASIO_TEST_CASE3(test_can_prefer<ex_nq_nr, n2, false>) + ASIO_TEST_CASE3(test_can_prefer<ex_nq_nr, n3, true>) + + ASIO_TEST_CASE3(test_prefer<ex_nq_nr, n1, n1>) + ASIO_TEST_CASE3(test_prefer<ex_nq_nr, n3, n1>) + + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n1, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n1, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n2, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n2, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n2, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n3, s, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n3, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n3, s, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n3, s, n3>, n3, true>) + + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n3>, n2, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n3>, n3, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n3>, n1, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n3>, n2, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n3, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n3, n1>, n3, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n3, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n3, n2>, n3, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n3, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n3, n3>, n3, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n1, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n1, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n2, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n2, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n2, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n3, s, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n3, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n3, s, n3>, n2, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n3, s, n3>, n3, n3>) + + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n3>, s, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n3>, n2, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n3>, n3, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n1>, s, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n2>, s, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n3>, s, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n3>, n1, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n1>, s, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n2>, s, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n3>, s, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n3>, n2, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n3, n1>, s, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n3, n1>, n3, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n3, n2>, s, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n3, n2>, n3, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n3, n3>, s, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n3, n3>, n3, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n1, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n1, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n2, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n2, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n2, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n3, s, n3>, s, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n3, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n3, s, n3>, n2, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n3, s, n3>, n3, n3>) + + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n1, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n1, s, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n2, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n2, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n2, s, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n3, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n3, s, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n3, s, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n3, s, n3>, n3, true>) + + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, s, n3>, n3, n3>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, n3, n3>, n3, n3>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<n2, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<n3, s, n3>, n3, n3>) + + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n1, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n1, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n2, s, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n2, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n3, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n3, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n3, s, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n3, s, n3>, n3, true>) + + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n3, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n3, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n3, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n3, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n3, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n3, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n1, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n2, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n3, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n3, s, n3>, n3, n3>) + + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n1, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n1, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n2, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n2, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n2, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n3, s, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n3, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n3, s, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n3, s, n3>, n3, true>) + + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n3>, n2, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n3>, n3, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n3>, n1, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n3>, n2, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n3, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n3, n1>, n3, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n3, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n3, n2>, n3, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n3, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n3, n3>, n3, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n1, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n1, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n2, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n2, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n2, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n3, s, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n3, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n3, s, n3>, n2, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n3, s, n3>, n3, n3>) + + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n1, s, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n1, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n1, s, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n2, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n2, s, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n2, s, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n3, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n3, s, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n3, s, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n3, s, n3>, n3, false>) + + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n1, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n1, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n2, s, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n2, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n3, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n3, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n3, s, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n3, s, n3>, n3, true>) + + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n3, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n3, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n3, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n3, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n3, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n3, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n1, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n2, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n3, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n3, s, n3>, n3, n3>) + + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n1, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n1, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n2, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n2, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n2, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n3, s, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n3, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n3, s, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n3, s, n3>, n3, true>) + + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n3>, n2, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n3>, n3, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n3>, n1, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n3>, n2, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n3, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n3, n1>, n3, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n3, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n3, n2>, n3, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n3, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n3, n3>, n3, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n1, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n1, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n2, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n2, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n2, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n3, s, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n3, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n3, s, n3>, n2, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n3, s, n3>, n3, n3>) + + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n1, s, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n1, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n1, s, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n2, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n2, s, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n2, s, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n3, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n3, s, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n3, s, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n3, s, n3>, n3, false>) + + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n1, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n1, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n2, s, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n2, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n3, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n3, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n3, s, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n3, s, n3>, n3, true>) + + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n3, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n3, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n3, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n3, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n3, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n3, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n1, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n2, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n3, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n3, s, n3>, n3, n3>) + + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n1>, n3, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n2>, n3, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n3>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n3>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n3>, n2, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n1>, n3, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n2>, n3, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n3>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n3>, n1, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n3>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n1>, n3, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n2>, n3, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n3>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n3>, n1, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n3>, n2, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n3>, n3, true>) + + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n1>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n2>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n3>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n3>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n1>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n2>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n2>, n2, n2>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n3>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n3>, n2, n2>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n3, n1>, s, n3>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n3, n1>, n3, n3>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n3, n2>, s, n3>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n3, n2>, n3, n3>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n3, n3>, s, n3>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n3, n3>, n3, n3>) + + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n1>, n3, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n2>, n3, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n3>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n3>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n3>, n2, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n1>, n3, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n2>, n3, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n3>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n3>, n1, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n3>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n1>, n3, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n2>, n3, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n3>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n3>, n1, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n3>, n2, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n3>, n3, true>) + + ASIO_TEST_CASE4(test_require<ex_mq_mr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n1, n2>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n1, n3>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n1, n3>, n3, n3>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n2, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n2, n2>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n2, n3>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n2, n3>, n3, n3>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n3, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n3, n1>, n3, n3>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n3, n2>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n3, n2>, n3, n3>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n3, n3>, n3, n3>) + + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n1>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n2>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n2>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n3>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n3>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n3>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n1>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n2>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n2>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n3>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n3>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n3>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n1>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n2>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n2>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n3>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n3>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n3>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n3>, n3, true>) + + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n1>, n3, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n2>, n3, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n3>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n3>, n3, n3>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n1>, n3, n2>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n2>, n1, n2>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n2>, n3, n2>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n3>, n1, n2>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n3>, n3, n3>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n3, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n3, n1>, n3, n3>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n3, n2>, n1, n3>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n3, n2>, n3, n3>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n3, n3>, n1, n3>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n3, n3>, n3, n3>) + + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n1>, n3, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n2>, n3, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n3>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n3>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n3>, n2, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n1>, n3, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n2>, n3, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n3>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n3>, n1, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n3>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n1>, n3, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n2>, n3, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n3>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n3>, n1, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n3>, n2, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n3>, n3, true>) + + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n1>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n2>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n3>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n3>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n1>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n2>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n2>, n2, n2>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n3>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n3>, n2, n2>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n3, n1>, s, n3>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n3, n1>, n3, n3>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n3, n2>, s, n3>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n3, n2>, n3, n3>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n3, n3>, s, n3>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n3, n3>, n3, n3>) + + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n1>, n3, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n2>, n3, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n3>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n3>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n3>, n2, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n1>, n3, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n2>, n3, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n3>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n3>, n1, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n3>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n1>, n3, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n2>, n3, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n3>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n3>, n1, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n3>, n2, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n3>, n3, true>) + + ASIO_TEST_CASE4(test_require<ex_fq_fr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n1, n2>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n1, n3>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n1, n3>, n3, n3>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n2, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n2, n2>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n2, n3>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n2, n3>, n3, n3>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n3, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n3, n1>, n3, n3>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n3, n2>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n3, n2>, n3, n3>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n3, n3>, n3, n3>) + + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n1>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n2>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n2>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n3>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n3>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n3>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n1>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n2>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n2>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n3>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n3>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n3>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n1>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n2>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n2>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n3>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n3>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n3>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n3>, n3, true>) + + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n1>, n3, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n2>, n3, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n3>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n3>, n3, n3>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n1>, n3, n2>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n2>, n1, n2>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n2>, n3, n2>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n3>, n1, n2>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n3>, n3, n3>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n3, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n3, n1>, n3, n3>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n3, n2>, n1, n3>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n3, n2>, n3, n3>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n3, n3>, n1, n3>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n3, n3>, n3, n3>) + + ASIO_TEST_CASE(test_vars) +) diff --git a/3rdparty/asio/src/tests/unit/execution/blocking_adaptation.cpp b/3rdparty/asio/src/tests/unit/execution/blocking_adaptation.cpp new file mode 100644 index 00000000000..b6e77dd31a9 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/execution/blocking_adaptation.cpp @@ -0,0 +1,1323 @@ +// +// blocking_adaptation.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/execution/blocking_adaptation.hpp" + +#include "asio/prefer.hpp" +#include "asio/query.hpp" +#include "asio/require.hpp" +#include "../unit_test.hpp" + +namespace exec = asio::execution; + +typedef exec::blocking_adaptation_t s; +typedef exec::blocking_adaptation_t::disallowed_t n1; +typedef exec::blocking_adaptation_t::allowed_t n2; + +struct ex_nq_nr +{ + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_nq_nr&, const ex_nq_nr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_nq_nr&, const ex_nq_nr&) noexcept + { + return false; + } +}; + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +template <> +struct equality_comparable<ex_nq_nr> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +template <typename Function> +struct execute_member<ex_nq_nr, Function> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = false; + + typedef void result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename ResultType, typename ParamType, typename Result> +struct ex_cq_nr +{ + static constexpr ResultType query(ParamType) noexcept + { + return Result(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_cq_nr&, const ex_cq_nr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_cq_nr&, const ex_cq_nr&) noexcept + { + return false; + } +}; + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +template <typename ResultType, typename ParamType, typename Result> +struct equality_comparable<ex_cq_nr<ResultType, ParamType, Result> > +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +template <typename ResultType, typename ParamType, + typename Result, typename Function> +struct execute_member<ex_cq_nr<ResultType, ParamType, Result>, Function> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = false; + + typedef void result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT) + +template <typename ResultType, typename ParamType, + typename Result, typename Param> +struct query_static_constexpr_member< + ex_cq_nr<ResultType, ParamType, Result>, Param, + typename asio::enable_if< + asio::is_convertible<Param, ParamType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef Result result_type; // Must return raw result type. + + static constexpr result_type value() + { + return Result(); + } +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename ResultType, typename ParamType, typename Result> +struct ex_mq_nr +{ + ResultType query(ParamType) const noexcept + { + return Result(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_mq_nr&, const ex_mq_nr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_mq_nr&, const ex_mq_nr&) noexcept + { + return false; + } +}; + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +template <typename ResultType, typename ParamType, typename Result> +struct equality_comparable<ex_mq_nr<ResultType, ParamType, Result> > +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +template <typename ResultType, typename ParamType, + typename Result, typename Function> +struct execute_member<ex_mq_nr<ResultType, ParamType, Result>, Function> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = false; + + typedef void result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +template <typename ResultType, typename ParamType, + typename Result, typename Param> +struct query_member< + ex_mq_nr<ResultType, ParamType, Result>, Param, + typename asio::enable_if< + asio::is_convertible<Param, ParamType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ResultType result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename ResultType, typename ParamType, typename Result> +struct ex_fq_nr +{ + friend ResultType query(const ex_fq_nr&, ParamType) noexcept + { + return Result(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_fq_nr&, const ex_fq_nr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_fq_nr&, const ex_fq_nr&) noexcept + { + return false; + } +}; + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +template <typename ResultType, typename ParamType, typename Result> +struct equality_comparable<ex_fq_nr<ResultType, ParamType, Result> > +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +template <typename ResultType, typename ParamType, + typename Result, typename Function> +struct execute_member<ex_fq_nr<ResultType, ParamType, Result>, Function> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = false; + + typedef void result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) + +template <typename ResultType, typename ParamType, + typename Result, typename Param> +struct query_free< + ex_fq_nr<ResultType, ParamType, Result>, Param, + typename asio::enable_if< + asio::is_convertible<Param, ParamType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ResultType result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename CurrentType, typename OtherType> +struct ex_mq_mr +{ + CurrentType query(CurrentType) const noexcept + { + return CurrentType(); + } + + CurrentType query(OtherType) const noexcept + { + return CurrentType(); + } + + ex_mq_mr<CurrentType, OtherType> require( + CurrentType) const noexcept + { + return ex_mq_mr<CurrentType, OtherType>(); + } + + ex_mq_mr<OtherType, CurrentType> require( + OtherType) const noexcept + { + return ex_mq_mr<OtherType, CurrentType>(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_mq_mr&, const ex_mq_mr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_mq_mr&, const ex_mq_mr&) noexcept + { + return false; + } +}; + +template <typename CurrentType> +struct ex_mq_mr<CurrentType, CurrentType> +{ + CurrentType query(CurrentType) const noexcept + { + return CurrentType(); + } + + ex_mq_mr<CurrentType, CurrentType> require( + CurrentType) const noexcept + { + return ex_mq_mr<CurrentType, CurrentType>(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_mq_mr&, const ex_mq_mr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_mq_mr&, const ex_mq_mr&) noexcept + { + return false; + } +}; + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +template <typename CurrentType, typename OtherType> +struct equality_comparable<ex_mq_mr<CurrentType, OtherType> > +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +template <typename CurrentType, typename OtherType, typename Function> +struct execute_member<ex_mq_mr<CurrentType, OtherType>, Function> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = false; + + typedef void result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct query_member< + ex_mq_mr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + || asio::is_convertible<Param, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef CurrentType result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct require_member< + ex_mq_mr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_mq_mr<CurrentType, OtherType> result_type; +}; + +template <typename CurrentType, typename OtherType, typename Param> +struct require_member< + ex_mq_mr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, OtherType>::value + && !asio::is_same<CurrentType, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_mq_mr<OtherType, CurrentType> result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename CurrentType, typename OtherType> +struct ex_fq_fr +{ + friend CurrentType query(const ex_fq_fr&, CurrentType) noexcept + { + return CurrentType(); + } + + friend CurrentType query(const ex_fq_fr&, OtherType) noexcept + { + return CurrentType(); + } + + friend ex_fq_fr<CurrentType, OtherType> require( + const ex_fq_fr&, CurrentType) noexcept + { + return ex_fq_fr<CurrentType, OtherType>(); + } + + friend ex_fq_fr<OtherType, CurrentType> require( + const ex_fq_fr&, OtherType) noexcept + { + return ex_fq_fr<OtherType, CurrentType>(); + } + + friend ex_fq_fr<CurrentType, OtherType> prefer( + const ex_fq_fr&, CurrentType) noexcept + { + return ex_fq_fr<CurrentType, OtherType>(); + } + + friend ex_fq_fr<OtherType, CurrentType> prefer( + const ex_fq_fr&, OtherType) noexcept + { + return ex_fq_fr<OtherType, CurrentType>(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_fq_fr&, const ex_fq_fr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_fq_fr&, const ex_fq_fr&) noexcept + { + return false; + } +}; + +template <typename CurrentType> +struct ex_fq_fr<CurrentType, CurrentType> +{ + friend CurrentType query(const ex_fq_fr&, CurrentType) noexcept + { + return CurrentType(); + } + + friend ex_fq_fr<CurrentType, CurrentType> require( + const ex_fq_fr&, CurrentType) noexcept + { + return ex_fq_fr<CurrentType, CurrentType>(); + } + + friend ex_fq_fr<CurrentType, CurrentType> prefer( + const ex_fq_fr&, CurrentType) noexcept + { + return ex_fq_fr<CurrentType, CurrentType>(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_fq_fr&, const ex_fq_fr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_fq_fr&, const ex_fq_fr&) noexcept + { + return false; + } +}; + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +template <typename CurrentType, typename OtherType> +struct equality_comparable<ex_fq_fr<CurrentType, OtherType> > +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +template <typename CurrentType, typename OtherType, typename Function> +struct execute_member<ex_fq_fr<CurrentType, OtherType>, Function> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = false; + + typedef void result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct query_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + || asio::is_convertible<Param, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef CurrentType result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_REQUIRE_FREE_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct require_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_fq_fr<CurrentType, OtherType> result_type; +}; + +template <typename CurrentType, typename OtherType, typename Param> +struct require_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, OtherType>::value + && !asio::is_same<CurrentType, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_fq_fr<OtherType, CurrentType> result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_REQUIRE_FREE_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_PREFER_FREE_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct prefer_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_fq_fr<CurrentType, OtherType> result_type; +}; + +template <typename CurrentType, typename OtherType, typename Param> +struct prefer_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, OtherType>::value + && !asio::is_same<CurrentType, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_fq_fr<OtherType, CurrentType> result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_PREFER_FREE_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename Executor, typename Param, bool ExpectedResult> +void test_can_query() +{ + constexpr bool b1 = + asio::can_query<Executor, Param>::value; + ASIO_CHECK(b1 == ExpectedResult); + + constexpr bool b2 = + asio::can_query<const Executor, Param>::value; + ASIO_CHECK(b2 == ExpectedResult); + + constexpr bool b3 = + asio::can_query<Executor&, Param>::value; + ASIO_CHECK(b3 == ExpectedResult); + + constexpr bool b4 = + asio::can_query<const Executor&, Param>::value; + ASIO_CHECK(b4 == ExpectedResult); +} + +template <typename Executor, typename Param, typename ExpectedResult> +void test_query() +{ + exec::blocking_adaptation_t result1 = asio::query(Executor(), Param()); + ASIO_CHECK(result1 == ExpectedResult()); + + Executor ex1 = {}; + exec::blocking_adaptation_t result2 = asio::query(ex1, Param()); + ASIO_CHECK(result2 == ExpectedResult()); + + const Executor ex2 = {}; + exec::blocking_adaptation_t result3 = asio::query(ex2, Param()); + ASIO_CHECK(result3 == ExpectedResult()); +} + +template <typename Executor, typename Param, typename ExpectedResult> +void test_constexpr_query() +{ + constexpr Executor ex1 = {}; + constexpr exec::blocking_adaptation_t result1 = asio::query(ex1, Param()); + ASIO_CHECK(result1 == ExpectedResult()); +} + +template <typename Executor, typename Param, bool ExpectedResult> +void test_can_require() +{ + constexpr bool b1 = + asio::can_require<Executor, Param>::value; + ASIO_CHECK(b1 == ExpectedResult); + + constexpr bool b2 = + asio::can_require<const Executor, Param>::value; + ASIO_CHECK(b2 == ExpectedResult); + + constexpr bool b3 = + asio::can_require<Executor&, Param>::value; + ASIO_CHECK(b3 == ExpectedResult); + + constexpr bool b4 = + asio::can_require<const Executor&, Param>::value; + ASIO_CHECK(b4 == ExpectedResult); +} + +void do_nothing() +{ +} + +template <typename Executor, typename Param, typename ExpectedResult> +void test_require() +{ + ASIO_CHECK( + asio::query( + asio::require(Executor(), Param()), + Param()) == ExpectedResult()); + + Executor ex1 = {}; + + ASIO_CHECK( + asio::query( + asio::require(ex1, Param()), + Param()) == ExpectedResult()); + + ASIO_CHECK(( + asio::execution::is_executor< + typename asio::decay< + typename asio::require_result<Executor&, Param>::type + >::type + >::value)); + + const Executor ex2 = {}; + + ASIO_CHECK( + asio::query( + asio::require(ex2, Param()), + Param()) == ExpectedResult()); + + ASIO_CHECK(( + asio::execution::is_executor< + typename asio::decay< + typename asio::require_result<const Executor&, Param>::type + >::type + >::value)); +} + +template <typename Executor, typename Param, bool ExpectedResult> +void test_can_prefer() +{ + constexpr bool b1 = + asio::can_prefer<Executor, Param>::value; + ASIO_CHECK(b1 == ExpectedResult); + + constexpr bool b2 = + asio::can_prefer<const Executor, Param>::value; + ASIO_CHECK(b2 == ExpectedResult); + + constexpr bool b3 = + asio::can_prefer<Executor&, Param>::value; + ASIO_CHECK(b3 == ExpectedResult); + + constexpr bool b4 = + asio::can_prefer<const Executor&, Param>::value; + ASIO_CHECK(b4 == ExpectedResult); +} + +template <typename Executor, typename Param, typename ExpectedResult> +void test_prefer() +{ + ASIO_CHECK( + s(asio::query( + asio::prefer(Executor(), Param()), + s())) == s(ExpectedResult())); + + Executor ex1 = {}; + ASIO_CHECK( + s(asio::query( + asio::prefer(ex1, Param()), + s())) == s(ExpectedResult())); + + const Executor ex2 = {}; + ASIO_CHECK( + s(asio::query( + asio::prefer(ex2, Param()), + s())) == s(ExpectedResult())); +} + +void test_vars() +{ + ASIO_CHECK(s() == exec::blocking_adaptation); + ASIO_CHECK(s() != exec::blocking_adaptation.disallowed); + ASIO_CHECK(s() != exec::blocking_adaptation.allowed); + ASIO_CHECK(n1() == exec::blocking_adaptation.disallowed); + ASIO_CHECK(n1() != exec::blocking_adaptation.allowed); + ASIO_CHECK(n2() == exec::blocking_adaptation.allowed); + ASIO_CHECK(n2() != exec::blocking_adaptation.disallowed); +} + +ASIO_TEST_SUITE +( + "blocking_adaptation", + + ASIO_TEST_CASE3(test_can_query<ex_nq_nr, s, true>) + ASIO_TEST_CASE3(test_can_query<ex_nq_nr, n1, true>) + ASIO_TEST_CASE3(test_can_query<ex_nq_nr, n2, false>) + + ASIO_TEST_CASE3(test_query<ex_nq_nr, s, n1>) + ASIO_TEST_CASE3(test_query<ex_nq_nr, n1, n1>) + + ASIO_TEST_CASE3(test_constexpr_query<ex_nq_nr, s, n1>) + ASIO_TEST_CASE3(test_constexpr_query<ex_nq_nr, n1, n1>) + + ASIO_TEST_CASE3(test_can_require<ex_nq_nr, s, false>) + ASIO_TEST_CASE3(test_can_require<ex_nq_nr, n1, true>) + ASIO_TEST_CASE3(test_can_require<ex_nq_nr, n2, true>) + + ASIO_TEST_CASE3(test_require<ex_nq_nr, n1, n1>) + ASIO_TEST_CASE3(test_require<ex_nq_nr, n2, n2>) + + ASIO_TEST_CASE3(test_can_prefer<ex_nq_nr, s, false>) + ASIO_TEST_CASE3(test_can_prefer<ex_nq_nr, n1, true>) + ASIO_TEST_CASE3(test_can_prefer<ex_nq_nr, n2, false>) + + ASIO_TEST_CASE3(test_prefer<ex_nq_nr, n1, n1>) + + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n1, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n2, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n2, s, n2>, n2, true>) + + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n1, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n2, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n2, s, n2>, n2, n2>) + + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n1>, s, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n2>, s, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n1>, s, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n2>, s, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n1, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n2, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n2, s, n2>, n2, n2>) + + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n2, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n2, s, n2>, n2, true>) + + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, s, n1>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, n1, n1>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, n1, n2>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, n2, n1>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<n1, s, n1>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<n2, s, n2>, n2, n2>) + + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n1, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n2, s, n2>, n2, false>) + + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n2, s, n2>, n1, n2>) + + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n1, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n2, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n2, s, n2>, n2, true>) + + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n1, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n2, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n2, s, n2>, n2, n2>) + + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n1, s, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n2, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n2, s, n2>, n2, true>) + + ASIO_TEST_CASE5(test_require<ex_mq_nr<s, s, n1>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_mq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_mq_nr<s, n1, n1>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_mq_nr<s, n1, n2>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_mq_nr<s, n2, n1>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_mq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_mq_nr<n1, s, n1>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_mq_nr<n2, s, n2>, n2, n2>) + + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n1, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n2, s, n2>, n2, false>) + + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n2, s, n2>, n1, n2>) + + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n1, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n2, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n2, s, n2>, n2, true>) + + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n1, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n2, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n2, s, n2>, n2, n2>) + + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n1, s, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n2, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n2, s, n2>, n2, true>) + + ASIO_TEST_CASE5(test_require<ex_fq_nr<s, s, n1>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_fq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_fq_nr<s, n1, n1>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_fq_nr<s, n1, n2>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_fq_nr<s, n2, n1>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_fq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_fq_nr<n1, s, n1>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_fq_nr<n2, s, n2>, n2, n2>) + + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n1, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n2, s, n2>, n2, false>) + + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n2, s, n2>, n1, n2>) + + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n2>, n2, true>) + + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n1>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n2>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n1>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n2>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n2>, n2, n2>) + + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n2>, n2, true>) + + ASIO_TEST_CASE4(test_require<ex_mq_mr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n1, n1>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n1, n2>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n2, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n2, n2>, n2, n2>) + + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n2>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n2>, n2, false>) + + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n2>, n1, n2>) + + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n2>, n2, true>) + + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n1>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n2>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n1>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n2>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n2>, n2, n2>) + + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n2>, n2, true>) + + ASIO_TEST_CASE4(test_require<ex_fq_fr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n1, n1>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n1, n2>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n2, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n2, n2>, n2, n2>) + + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n2>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n2>, n2, false>) + + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n2>, n1, n2>) + + ASIO_TEST_CASE(test_vars) +) diff --git a/3rdparty/asio/src/tests/unit/execution/context_as.cpp b/3rdparty/asio/src/tests/unit/execution/context_as.cpp new file mode 100644 index 00000000000..13311ba262b --- /dev/null +++ b/3rdparty/asio/src/tests/unit/execution/context_as.cpp @@ -0,0 +1,147 @@ +// +// context_as.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/execution/context_as.hpp" + +#include <functional> +#include "asio/execution/any_executor.hpp" +#include "asio/io_context.hpp" +#include "asio/static_thread_pool.hpp" +#include "../unit_test.hpp" + +using namespace asio; +namespace bindns = std; + +void context_as_executor_query_test() +{ + static_thread_pool pool(1); + + ASIO_CHECK( + &asio::query(pool.executor(), + execution::context_as_t<static_thread_pool&>()) + == &pool); + + execution::any_executor< + execution::context_as_t<static_thread_pool&> + > ex1 = pool.executor(); + + ASIO_CHECK( + &asio::query(ex1, + execution::context_as_t<static_thread_pool&>()) + == &pool); + + ASIO_CHECK( + &asio::query(ex1, execution::context) + == &pool); + + ASIO_CHECK( + &asio::query(pool.executor(), + execution::context_as_t<const static_thread_pool&>()) + == &pool); + + execution::any_executor< + execution::context_as_t<const static_thread_pool&> + > ex2 = pool.executor(); + + ASIO_CHECK( + &asio::query(ex2, + execution::context_as_t<const static_thread_pool&>()) + == &pool); + + ASIO_CHECK( + &asio::query(ex2, execution::context) + == &pool); + + io_context io_ctx; + + ASIO_CHECK( + &asio::query(io_ctx.get_executor(), + execution::context_as_t<io_context&>()) + == &io_ctx); + + execution::any_executor< + execution::context_as_t<io_context&> + > ex3 = io_ctx.get_executor(); + + ASIO_CHECK( + &asio::query(ex3, + execution::context_as_t<io_context&>()) + == &io_ctx); + + ASIO_CHECK( + &asio::query(ex3, execution::context) + == &io_ctx); + + ASIO_CHECK( + &asio::query(io_ctx.get_executor(), + execution::context_as_t<const io_context&>()) + == &io_ctx); + + execution::any_executor< + execution::context_as_t<const io_context&> + > ex4 = io_ctx.get_executor(); + + ASIO_CHECK( + &asio::query(ex4, + execution::context_as_t<const io_context&>()) + == &io_ctx); + + ASIO_CHECK( + &asio::query(ex4, execution::context) + == &io_ctx); + + ASIO_CHECK( + &asio::query(io_ctx.get_executor(), + execution::context_as_t<execution_context&>()) + == &io_ctx); + + execution::any_executor< + execution::context_as_t<execution_context&> + > ex5 = io_ctx.get_executor(); + + ASIO_CHECK( + &asio::query(ex5, + execution::context_as_t<execution_context&>()) + == &io_ctx); + + ASIO_CHECK( + &asio::query(ex5, execution::context) + == &io_ctx); + + ASIO_CHECK( + &asio::query(io_ctx.get_executor(), + execution::context_as_t<const execution_context&>()) + == &io_ctx); + + execution::any_executor< + execution::context_as_t<const execution_context&> + > ex6 = io_ctx.get_executor(); + + ASIO_CHECK( + &asio::query(ex6, + execution::context_as_t<const execution_context&>()) + == &io_ctx); + + ASIO_CHECK( + &asio::query(ex6, execution::context) + == &io_ctx); +} + +ASIO_TEST_SUITE +( + "context_as", + ASIO_TEST_CASE(context_as_executor_query_test) +) diff --git a/3rdparty/asio/src/tests/unit/execution/executor.cpp b/3rdparty/asio/src/tests/unit/execution/executor.cpp new file mode 100644 index 00000000000..8b02622bdca --- /dev/null +++ b/3rdparty/asio/src/tests/unit/execution/executor.cpp @@ -0,0 +1,106 @@ +// +// executor.cpp +// ~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/execution/executor.hpp" + +#include "../unit_test.hpp" + +struct not_an_executor +{ +}; + +struct executor +{ + executor() + { + } + + executor(const executor&) noexcept + { + } + + executor(executor&&) noexcept + { + } + + template <typename F> + void execute(F&& f) const noexcept + { + (void)f; + } + + bool operator==(const executor&) const noexcept + { + return true; + } + + bool operator!=(const executor&) const noexcept + { + return false; + } +}; + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +template <typename F> +struct execute_member<executor, F> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + typedef void result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_SET_ERROR_MEMBER_TRAIT) +#if !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +template <> +struct equality_comparable<executor> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +} // namespace traits +} // namespace asio + +void is_executor_test() +{ + ASIO_CHECK(( + !asio::execution::is_executor< + void + >::value)); + + ASIO_CHECK(( + !asio::execution::is_executor< + not_an_executor + >::value)); + + ASIO_CHECK(( + asio::execution::is_executor< + executor + >::value)); +} + +ASIO_TEST_SUITE +( + "executor", + ASIO_TEST_CASE(is_executor_test) +) diff --git a/3rdparty/asio/src/tests/unit/windows/basic_handle.cpp b/3rdparty/asio/src/tests/unit/execution/invocable_archetype.cpp index 572699e2cfa..5dbfb94d9f4 100644 --- a/3rdparty/asio/src/tests/unit/windows/basic_handle.cpp +++ b/3rdparty/asio/src/tests/unit/execution/invocable_archetype.cpp @@ -1,8 +1,8 @@ // -// basic_handle.cpp -// ~~~~~~~~~~~~~~~~ +// invocable_archetype.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -14,13 +14,12 @@ #endif // !defined(BOOST_ALL_NO_LIB) // Test that header file is self-contained. -#include "asio/windows/basic_handle.hpp" +#include "asio/execution/invocable_archetype.hpp" -#include "asio.hpp" #include "../unit_test.hpp" ASIO_TEST_SUITE ( - "windows/basic_handle", + "invocable_archetype", ASIO_TEST_CASE(null_test) ) diff --git a/3rdparty/asio/src/tests/unit/execution/mapping.cpp b/3rdparty/asio/src/tests/unit/execution/mapping.cpp new file mode 100644 index 00000000000..399aae3ea90 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/execution/mapping.cpp @@ -0,0 +1,1985 @@ +// +// mapping.cpp +// ~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/execution/mapping.hpp" + +#include "asio/prefer.hpp" +#include "asio/query.hpp" +#include "asio/require.hpp" +#include "../unit_test.hpp" + +namespace exec = asio::execution; + +typedef exec::mapping_t s; +typedef exec::mapping_t::thread_t n1; +typedef exec::mapping_t::new_thread_t n2; +typedef exec::mapping_t::other_t n3; + +struct ex_nq_nr +{ + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_nq_nr&, const ex_nq_nr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_nq_nr&, const ex_nq_nr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <> +struct is_executor<ex_nq_nr> : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +template <typename ResultType, typename ParamType, typename Result> +struct ex_cq_nr +{ + static constexpr ResultType query(ParamType) noexcept + { + return Result(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_cq_nr&, const ex_cq_nr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_cq_nr&, const ex_cq_nr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <typename ResultType, typename ParamType, typename Result> +struct is_executor<ex_cq_nr<ResultType, ParamType, Result> > + : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT) + +template <typename ResultType, typename ParamType, + typename Result, typename Param> +struct query_static_constexpr_member< + ex_cq_nr<ResultType, ParamType, Result>, Param, + typename asio::enable_if< + asio::is_convertible<Param, ParamType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef Result result_type; // Must return raw result type. + + static constexpr result_type value() + { + return Result(); + } +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename ResultType, typename ParamType, typename Result> +struct ex_mq_nr +{ + ResultType query(ParamType) const noexcept + { + return Result(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_mq_nr&, const ex_mq_nr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_mq_nr&, const ex_mq_nr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <typename ResultType, typename ParamType, typename Result> +struct is_executor<ex_mq_nr<ResultType, ParamType, Result> > + : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +template <typename ResultType, typename ParamType, + typename Result, typename Param> +struct query_member< + ex_mq_nr<ResultType, ParamType, Result>, Param, + typename asio::enable_if< + asio::is_convertible<Param, ParamType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ResultType result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename ResultType, typename ParamType, typename Result> +struct ex_fq_nr +{ + friend ResultType query(const ex_fq_nr&, ParamType) noexcept + { + return Result(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_fq_nr&, const ex_fq_nr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_fq_nr&, const ex_fq_nr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <typename ResultType, typename ParamType, typename Result> +struct is_executor<ex_fq_nr<ResultType, ParamType, Result> > + : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) + +template <typename ResultType, typename ParamType, + typename Result, typename Param> +struct query_free< + ex_fq_nr<ResultType, ParamType, Result>, Param, + typename asio::enable_if< + asio::is_convertible<Param, ParamType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ResultType result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename CurrentType, typename OtherType> +struct ex_mq_mr +{ + CurrentType query(CurrentType) const noexcept + { + return CurrentType(); + } + + CurrentType query(OtherType) const noexcept + { + return CurrentType(); + } + + ex_mq_mr<CurrentType, OtherType> require( + CurrentType) const noexcept + { + return ex_mq_mr<CurrentType, OtherType>(); + } + + ex_mq_mr<OtherType, CurrentType> require( + OtherType) const noexcept + { + return ex_mq_mr<OtherType, CurrentType>(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_mq_mr&, const ex_mq_mr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_mq_mr&, const ex_mq_mr&) noexcept + { + return false; + } +}; + +template <typename CurrentType> +struct ex_mq_mr<CurrentType, CurrentType> +{ + CurrentType query(CurrentType) const noexcept + { + return CurrentType(); + } + + ex_mq_mr<CurrentType, CurrentType> require( + CurrentType) const noexcept + { + return ex_mq_mr<CurrentType, CurrentType>(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_mq_mr&, const ex_mq_mr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_mq_mr&, const ex_mq_mr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <typename CurrentType, typename OtherType> +struct is_executor<ex_mq_mr<CurrentType, OtherType> > + : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct query_member< + ex_mq_mr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + || asio::is_convertible<Param, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef CurrentType result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct require_member< + ex_mq_mr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_mq_mr<CurrentType, OtherType> result_type; +}; + +template <typename CurrentType, typename OtherType, typename Param> +struct require_member< + ex_mq_mr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, OtherType>::value + && !asio::is_same<CurrentType, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_mq_mr<OtherType, CurrentType> result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename CurrentType, typename OtherType> +struct ex_fq_fr +{ + friend CurrentType query(const ex_fq_fr&, CurrentType) noexcept + { + return CurrentType(); + } + + friend CurrentType query(const ex_fq_fr&, OtherType) noexcept + { + return CurrentType(); + } + + friend ex_fq_fr<CurrentType, OtherType> require( + const ex_fq_fr&, CurrentType) noexcept + { + return ex_fq_fr<CurrentType, OtherType>(); + } + + friend ex_fq_fr<OtherType, CurrentType> require( + const ex_fq_fr&, OtherType) noexcept + { + return ex_fq_fr<OtherType, CurrentType>(); + } + + friend ex_fq_fr<CurrentType, OtherType> prefer( + const ex_fq_fr&, CurrentType) noexcept + { + return ex_fq_fr<CurrentType, OtherType>(); + } + + friend ex_fq_fr<OtherType, CurrentType> prefer( + const ex_fq_fr&, OtherType) noexcept + { + return ex_fq_fr<OtherType, CurrentType>(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_fq_fr&, const ex_fq_fr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_fq_fr&, const ex_fq_fr&) noexcept + { + return false; + } +}; + +template <typename CurrentType> +struct ex_fq_fr<CurrentType, CurrentType> +{ + friend CurrentType query(const ex_fq_fr&, CurrentType) noexcept + { + return CurrentType(); + } + + friend ex_fq_fr<CurrentType, CurrentType> require( + const ex_fq_fr&, CurrentType) noexcept + { + return ex_fq_fr<CurrentType, CurrentType>(); + } + + friend ex_fq_fr<CurrentType, CurrentType> prefer( + const ex_fq_fr&, CurrentType) noexcept + { + return ex_fq_fr<CurrentType, CurrentType>(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_fq_fr&, const ex_fq_fr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_fq_fr&, const ex_fq_fr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <typename CurrentType, typename OtherType> +struct is_executor<ex_fq_fr<CurrentType, OtherType> > + : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct query_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + || asio::is_convertible<Param, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef CurrentType result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_REQUIRE_FREE_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct require_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_fq_fr<CurrentType, OtherType> result_type; +}; + +template <typename CurrentType, typename OtherType, typename Param> +struct require_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, OtherType>::value + && !asio::is_same<CurrentType, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_fq_fr<OtherType, CurrentType> result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_REQUIRE_FREE_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_PREFER_FREE_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct prefer_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_fq_fr<CurrentType, OtherType> result_type; +}; + +template <typename CurrentType, typename OtherType, typename Param> +struct prefer_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, OtherType>::value + && !asio::is_same<CurrentType, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_fq_fr<OtherType, CurrentType> result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_PREFER_FREE_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename Executor, typename Param, bool ExpectedResult> +void test_can_query() +{ + constexpr bool b1 = + asio::can_query<Executor, Param>::value; + ASIO_CHECK(b1 == ExpectedResult); + + constexpr bool b2 = + asio::can_query<const Executor, Param>::value; + ASIO_CHECK(b2 == ExpectedResult); + + constexpr bool b3 = + asio::can_query<Executor&, Param>::value; + ASIO_CHECK(b3 == ExpectedResult); + + constexpr bool b4 = + asio::can_query<const Executor&, Param>::value; + ASIO_CHECK(b4 == ExpectedResult); +} + +template <typename Executor, typename Param, typename ExpectedResult> +void test_query() +{ + exec::mapping_t result1 = asio::query(Executor(), Param()); + ASIO_CHECK(result1 == ExpectedResult()); + + Executor ex1 = {}; + exec::mapping_t result2 = asio::query(ex1, Param()); + ASIO_CHECK(result2 == ExpectedResult()); + + const Executor ex2 = {}; + exec::mapping_t result3 = asio::query(ex2, Param()); + ASIO_CHECK(result3 == ExpectedResult()); +} + +template <typename Executor, typename Param, typename ExpectedResult> +void test_constexpr_query() +{ + constexpr Executor ex1 = {}; + constexpr exec::mapping_t result1 = asio::query(ex1, Param()); + ASIO_CHECK(result1 == ExpectedResult()); +} + +template <typename Executor, typename Param, bool ExpectedResult> +void test_can_require() +{ + constexpr bool b1 = + asio::can_require<Executor, Param>::value; + ASIO_CHECK(b1 == ExpectedResult); + + constexpr bool b2 = + asio::can_require<const Executor, Param>::value; + ASIO_CHECK(b2 == ExpectedResult); + + constexpr bool b3 = + asio::can_require<Executor&, Param>::value; + ASIO_CHECK(b3 == ExpectedResult); + + constexpr bool b4 = + asio::can_require<const Executor&, Param>::value; + ASIO_CHECK(b4 == ExpectedResult); +} + +template <typename Executor, typename Param, typename ExpectedResult> +void test_require() +{ + ASIO_CHECK( + asio::query( + asio::require(Executor(), Param()), + Param()) == ExpectedResult()); + + Executor ex1 = {}; + ASIO_CHECK( + asio::query( + asio::require(ex1, Param()), + Param()) == ExpectedResult()); + + const Executor ex2 = {}; + ASIO_CHECK( + asio::query( + asio::require(ex2, Param()), + Param()) == ExpectedResult()); +} + +template <typename Executor, typename Param, bool ExpectedResult> +void test_can_prefer() +{ + constexpr bool b1 = + asio::can_prefer<Executor, Param>::value; + ASIO_CHECK(b1 == ExpectedResult); + + constexpr bool b2 = + asio::can_prefer<const Executor, Param>::value; + ASIO_CHECK(b2 == ExpectedResult); + + constexpr bool b3 = + asio::can_prefer<Executor&, Param>::value; + ASIO_CHECK(b3 == ExpectedResult); + + constexpr bool b4 = + asio::can_prefer<const Executor&, Param>::value; + ASIO_CHECK(b4 == ExpectedResult); +} + +template <typename Executor, typename Param, typename ExpectedResult> +void test_prefer() +{ + ASIO_CHECK( + s(asio::query( + asio::prefer(Executor(), Param()), + s())) == s(ExpectedResult())); + + Executor ex1 = {}; + ASIO_CHECK( + s(asio::query( + asio::prefer(ex1, Param()), + s())) == s(ExpectedResult())); + + const Executor ex2 = {}; + ASIO_CHECK( + s(asio::query( + asio::prefer(ex2, Param()), + s())) == s(ExpectedResult())); +} + +void test_vars() +{ + ASIO_CHECK(s() == exec::mapping); + ASIO_CHECK(s() != exec::mapping.thread); + ASIO_CHECK(s() != exec::mapping.new_thread); + ASIO_CHECK(s() != exec::mapping.other); + ASIO_CHECK(n1() == exec::mapping.thread); + ASIO_CHECK(n1() != exec::mapping.new_thread); + ASIO_CHECK(n1() != exec::mapping.other); + ASIO_CHECK(n2() == exec::mapping.new_thread); + ASIO_CHECK(n2() != exec::mapping.thread); + ASIO_CHECK(n2() != exec::mapping.other); + ASIO_CHECK(n3() == exec::mapping.other); + ASIO_CHECK(n3() != exec::mapping.thread); + ASIO_CHECK(n3() != exec::mapping.new_thread); +} + +ASIO_TEST_SUITE +( + "mapping", + + ASIO_TEST_CASE3(test_can_query<ex_nq_nr, s, true>) + ASIO_TEST_CASE3(test_can_query<ex_nq_nr, n1, true>) + ASIO_TEST_CASE3(test_can_query<ex_nq_nr, n2, false>) + ASIO_TEST_CASE3(test_can_query<ex_nq_nr, n3, false>) + + ASIO_TEST_CASE3(test_query<ex_nq_nr, s, n1>) + ASIO_TEST_CASE3(test_query<ex_nq_nr, n1, n1>) + + ASIO_TEST_CASE3(test_constexpr_query<ex_nq_nr, s, n1>) + ASIO_TEST_CASE3(test_constexpr_query<ex_nq_nr, n1, n1>) + + ASIO_TEST_CASE3(test_can_require<ex_nq_nr, s, false>) + ASIO_TEST_CASE3(test_can_require<ex_nq_nr, n1, true>) + ASIO_TEST_CASE3(test_can_require<ex_nq_nr, n2, false>) + ASIO_TEST_CASE3(test_can_require<ex_nq_nr, n3, false>) + + ASIO_TEST_CASE3(test_require<ex_nq_nr, n1, n1>) + + ASIO_TEST_CASE3(test_can_prefer<ex_nq_nr, s, false>) + ASIO_TEST_CASE3(test_can_prefer<ex_nq_nr, n1, true>) + ASIO_TEST_CASE3(test_can_prefer<ex_nq_nr, n2, true>) + ASIO_TEST_CASE3(test_can_prefer<ex_nq_nr, n3, true>) + + ASIO_TEST_CASE3(test_prefer<ex_nq_nr, n1, n1>) + ASIO_TEST_CASE3(test_prefer<ex_nq_nr, n2, n1>) + ASIO_TEST_CASE3(test_prefer<ex_nq_nr, n3, n1>) + + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n3, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n1, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n1, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n2, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n2, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n2, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n3, s, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n3, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n3, s, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n3, s, n3>, n3, true>) + + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n3>, n2, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n3>, n3, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n3>, n1, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n3>, n2, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n3, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n3, n1>, n3, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n3, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n3, n2>, n3, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n3, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n3, n3>, n3, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n1, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n1, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n2, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n2, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n2, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n3, s, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n3, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n3, s, n3>, n2, n3>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n3, s, n3>, n3, n3>) + + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n3>, s, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n3>, n2, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n3>, n3, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n1>, s, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n2>, s, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n3>, s, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n3>, n1, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n1>, s, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n2>, s, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n3>, s, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n3>, n2, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n3, n1>, s, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n3, n1>, n3, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n3, n2>, s, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n3, n2>, n3, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n3, n3>, s, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n3, n3>, n3, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n1, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n1, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n2, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n2, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n2, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n3, s, n3>, s, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n3, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n3, s, n3>, n2, n3>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n3, s, n3>, n3, n3>) + + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n3, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n1, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n1, s, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n2, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n2, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n2, s, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n3, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n3, s, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n3, s, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n3, s, n3>, n3, true>) + + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, s, n3>, n3, n3>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, n3, n3>, n3, n3>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<n2, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<n3, s, n3>, n3, n3>) + + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n3, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n1, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n2, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n2, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n3, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n3, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n3, s, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n3, s, n3>, n3, true>) + + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n3>, n2, n3>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n3>, n2, n3>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n3>, n2, n3>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n3, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n3, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n3, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n3, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n3, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n3, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n3, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n3, n3>, n2, n3>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n3, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n1, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n2, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n2, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n3, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n3, s, n3>, n2, n3>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n3, s, n3>, n3, n3>) + + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n3, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n1, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n1, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n2, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n2, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n2, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n3, s, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n3, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n3, s, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n3, s, n3>, n3, true>) + + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n3>, n2, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n3>, n3, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n3>, n1, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n3>, n2, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n3, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n3, n1>, n3, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n3, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n3, n2>, n3, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n3, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n3, n3>, n3, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n1, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n1, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n2, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n2, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n2, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n3, s, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n3, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n3, s, n3>, n2, n3>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n3, s, n3>, n3, n3>) + + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n3, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n1, s, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n1, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n1, s, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n2, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n2, s, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n2, s, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n3, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n3, s, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n3, s, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n3, s, n3>, n3, false>) + + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n3, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n1, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n2, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n2, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n3, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n3, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n3, s, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n3, s, n3>, n3, true>) + + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n3>, n2, n3>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n3>, n2, n3>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n3>, n2, n3>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n3, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n3, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n3, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n3, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n3, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n3, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n3, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n3, n3>, n2, n3>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n3, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n1, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n2, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n2, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n3, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n3, s, n3>, n2, n3>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n3, s, n3>, n3, n3>) + + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n3, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n1, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n1, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n2, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n2, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n2, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n3, s, n3>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n3, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n3, s, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n3, s, n3>, n3, true>) + + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n3>, n2, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n3>, n3, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n3>, n1, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n3>, n2, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n3, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n3, n1>, n3, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n3, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n3, n2>, n3, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n3, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n3, n3>, n3, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n1, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n1, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n2, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n2, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n2, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n3, s, n3>, s, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n3, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n3, s, n3>, n2, n3>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n3, s, n3>, n3, n3>) + + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n3, n3>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n1, s, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n1, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n1, s, n1>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n2, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n2, s, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n2, s, n2>, n3, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n3, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n3, s, n3>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n3, s, n3>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n3, s, n3>, n3, false>) + + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n3, n3>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n1, s, n1>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n2, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n2, s, n2>, n3, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n3, s, n3>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n3, s, n3>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n3, s, n3>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n3, s, n3>, n3, true>) + + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n3>, n2, n3>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n3>, n2, n3>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n3>, n2, n3>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n3, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n3, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n3, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n3, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n3, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n3, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n3, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n3, n3>, n2, n3>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n3, n3>, n3, n3>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n1, s, n1>, n3, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n2, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n2, s, n2>, n3, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n3, s, n3>, n1, n3>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n3, s, n3>, n2, n3>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n3, s, n3>, n3, n3>) + + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n1>, n3, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n2>, n3, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n3>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n3>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n3>, n2, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n1>, n3, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n2>, n3, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n3>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n3>, n1, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n3>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n1>, n3, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n2>, n3, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n3>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n3>, n1, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n3>, n2, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n3, n3>, n3, true>) + + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n1>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n2>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n3>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n3>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n1>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n2>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n2>, n2, n2>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n3>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n3>, n2, n2>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n3, n1>, s, n3>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n3, n1>, n3, n3>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n3, n2>, s, n3>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n3, n2>, n3, n3>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n3, n3>, s, n3>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n3, n3>, n3, n3>) + + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n1>, n3, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n2>, n3, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n3>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n3>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n3>, n2, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n1>, n3, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n2>, n3, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n3>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n3>, n1, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n3>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n1>, n3, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n2>, n3, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n3>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n3>, n1, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n3>, n2, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n3, n3>, n3, true>) + + ASIO_TEST_CASE4(test_require<ex_mq_mr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n1, n2>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n1, n3>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n1, n3>, n3, n3>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n2, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n2, n2>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n2, n3>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n2, n3>, n3, n3>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n3, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n3, n1>, n3, n3>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n3, n2>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n3, n2>, n3, n3>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n3, n3>, n3, n3>) + + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n1>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n2>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n3>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n3>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n3>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n1>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n2>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n3>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n3>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n3>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n1>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n2>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n3>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n3>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n3>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n3, n3>, n3, true>) + + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n1>, n2, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n1>, n3, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n2>, n2, n2>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n2>, n3, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n3>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n3>, n2, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n3>, n3, n3>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n1>, n3, n2>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n2>, n1, n2>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n2>, n2, n2>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n2>, n3, n2>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n3>, n1, n2>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n3>, n2, n2>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n3>, n3, n3>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n3, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n3, n1>, n2, n3>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n3, n1>, n3, n3>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n3, n2>, n1, n3>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n3, n2>, n2, n2>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n3, n2>, n3, n3>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n3, n3>, n1, n3>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n3, n3>, n2, n3>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n3, n3>, n3, n3>) + + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n1>, n3, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n2>, n3, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n3>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n3>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n3>, n2, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n1>, n3, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n2>, n3, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n3>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n3>, n1, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n3>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n1>, n3, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n2>, n3, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n3>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n3>, n1, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n3>, n2, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n3, n3>, n3, true>) + + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n1>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n2>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n3>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n3>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n1>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n2>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n2>, n2, n2>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n3>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n3>, n2, n2>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n3, n1>, s, n3>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n3, n1>, n3, n3>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n3, n2>, s, n3>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n3, n2>, n3, n3>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n3, n3>, s, n3>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n3, n3>, n3, n3>) + + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n1>, n3, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n2>, n3, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n3>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n3>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n3>, n2, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n1>, n3, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n2>, n3, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n3>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n3>, n1, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n3>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n1>, n3, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n2>, n3, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n3>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n3>, n1, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n3>, n2, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n3, n3>, n3, true>) + + ASIO_TEST_CASE4(test_require<ex_fq_fr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n1, n2>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n1, n3>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n1, n3>, n3, n3>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n2, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n2, n2>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n2, n3>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n2, n3>, n3, n3>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n3, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n3, n1>, n3, n3>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n3, n2>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n3, n2>, n3, n3>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n3, n3>, n3, n3>) + + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n1>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n2>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n3>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n3>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n3>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n1>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n2>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n3>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n3>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n3>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n3>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n1>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n2>, n3, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n3>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n3>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n3>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n3, n3>, n3, true>) + + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n1>, n2, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n1>, n3, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n2>, n2, n2>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n2>, n3, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n3>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n3>, n2, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n3>, n3, n3>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n1>, n3, n2>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n2>, n1, n2>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n2>, n2, n2>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n2>, n3, n2>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n3>, n1, n2>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n3>, n2, n2>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n3>, n3, n3>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n3, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n3, n1>, n2, n3>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n3, n1>, n3, n3>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n3, n2>, n1, n3>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n3, n2>, n2, n2>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n3, n2>, n3, n3>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n3, n3>, n1, n3>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n3, n3>, n2, n3>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n3, n3>, n3, n3>) + + ASIO_TEST_CASE(test_vars) +) diff --git a/3rdparty/asio/src/tests/unit/execution/outstanding_work.cpp b/3rdparty/asio/src/tests/unit/execution/outstanding_work.cpp new file mode 100644 index 00000000000..cddd0b52c23 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/execution/outstanding_work.cpp @@ -0,0 +1,1252 @@ +// +// outstanding_work.cpp +// ~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/execution/outstanding_work.hpp" + +#include "asio/prefer.hpp" +#include "asio/query.hpp" +#include "asio/require.hpp" +#include "../unit_test.hpp" + +namespace exec = asio::execution; + +typedef exec::outstanding_work_t s; +typedef exec::outstanding_work_t::untracked_t n1; +typedef exec::outstanding_work_t::tracked_t n2; + +struct ex_nq_nr +{ + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_nq_nr&, const ex_nq_nr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_nq_nr&, const ex_nq_nr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <> +struct is_executor<ex_nq_nr> : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +template <typename ResultType, typename ParamType, typename Result> +struct ex_cq_nr +{ + static constexpr ResultType query(ParamType) noexcept + { + return Result(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_cq_nr&, const ex_cq_nr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_cq_nr&, const ex_cq_nr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <typename ResultType, typename ParamType, typename Result> +struct is_executor<ex_cq_nr<ResultType, ParamType, Result> > + : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT) + +template <typename ResultType, typename ParamType, + typename Result, typename Param> +struct query_static_constexpr_member< + ex_cq_nr<ResultType, ParamType, Result>, Param, + typename asio::enable_if< + asio::is_convertible<Param, ParamType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef Result result_type; // Must return raw result type. + + static constexpr result_type value() + { + return Result(); + } +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename ResultType, typename ParamType, typename Result> +struct ex_mq_nr +{ + ResultType query(ParamType) const noexcept + { + return Result(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_mq_nr&, const ex_mq_nr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_mq_nr&, const ex_mq_nr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <typename ResultType, typename ParamType, typename Result> +struct is_executor<ex_mq_nr<ResultType, ParamType, Result> > + : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +template <typename ResultType, typename ParamType, + typename Result, typename Param> +struct query_member< + ex_mq_nr<ResultType, ParamType, Result>, Param, + typename asio::enable_if< + asio::is_convertible<Param, ParamType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ResultType result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename ResultType, typename ParamType, typename Result> +struct ex_fq_nr +{ + friend ResultType query(const ex_fq_nr&, ParamType) noexcept + { + return Result(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_fq_nr&, const ex_fq_nr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_fq_nr&, const ex_fq_nr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <typename ResultType, typename ParamType, typename Result> +struct is_executor<ex_fq_nr<ResultType, ParamType, Result> > + : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) + +template <typename ResultType, typename ParamType, + typename Result, typename Param> +struct query_free< + ex_fq_nr<ResultType, ParamType, Result>, Param, + typename asio::enable_if< + asio::is_convertible<Param, ParamType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ResultType result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename CurrentType, typename OtherType> +struct ex_mq_mr +{ + CurrentType query(CurrentType) const noexcept + { + return CurrentType(); + } + + CurrentType query(OtherType) const noexcept + { + return CurrentType(); + } + + ex_mq_mr<CurrentType, OtherType> require( + CurrentType) const noexcept + { + return ex_mq_mr<CurrentType, OtherType>(); + } + + ex_mq_mr<OtherType, CurrentType> require( + OtherType) const noexcept + { + return ex_mq_mr<OtherType, CurrentType>(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_mq_mr&, const ex_mq_mr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_mq_mr&, const ex_mq_mr&) noexcept + { + return false; + } +}; + +template <typename CurrentType> +struct ex_mq_mr<CurrentType, CurrentType> +{ + CurrentType query(CurrentType) const noexcept + { + return CurrentType(); + } + + ex_mq_mr<CurrentType, CurrentType> require( + CurrentType) const noexcept + { + return ex_mq_mr<CurrentType, CurrentType>(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_mq_mr&, const ex_mq_mr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_mq_mr&, const ex_mq_mr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <typename CurrentType, typename OtherType> +struct is_executor<ex_mq_mr<CurrentType, OtherType> > + : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct query_member< + ex_mq_mr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + || asio::is_convertible<Param, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef CurrentType result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct require_member< + ex_mq_mr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_mq_mr<CurrentType, OtherType> result_type; +}; + +template <typename CurrentType, typename OtherType, typename Param> +struct require_member< + ex_mq_mr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, OtherType>::value + && !asio::is_same<CurrentType, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_mq_mr<OtherType, CurrentType> result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename CurrentType, typename OtherType> +struct ex_fq_fr +{ + friend CurrentType query(const ex_fq_fr&, CurrentType) noexcept + { + return CurrentType(); + } + + friend CurrentType query(const ex_fq_fr&, OtherType) noexcept + { + return CurrentType(); + } + + friend ex_fq_fr<CurrentType, OtherType> require( + const ex_fq_fr&, CurrentType) noexcept + { + return ex_fq_fr<CurrentType, OtherType>(); + } + + friend ex_fq_fr<OtherType, CurrentType> require( + const ex_fq_fr&, OtherType) noexcept + { + return ex_fq_fr<OtherType, CurrentType>(); + } + + friend ex_fq_fr<CurrentType, OtherType> prefer( + const ex_fq_fr&, CurrentType) noexcept + { + return ex_fq_fr<CurrentType, OtherType>(); + } + + friend ex_fq_fr<OtherType, CurrentType> prefer( + const ex_fq_fr&, OtherType) noexcept + { + return ex_fq_fr<OtherType, CurrentType>(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_fq_fr&, const ex_fq_fr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_fq_fr&, const ex_fq_fr&) noexcept + { + return false; + } +}; + +template <typename CurrentType> +struct ex_fq_fr<CurrentType, CurrentType> +{ + friend CurrentType query(const ex_fq_fr&, CurrentType) noexcept + { + return CurrentType(); + } + + friend ex_fq_fr<CurrentType, CurrentType> require( + const ex_fq_fr&, CurrentType) noexcept + { + return ex_fq_fr<CurrentType, CurrentType>(); + } + + friend ex_fq_fr<CurrentType, CurrentType> prefer( + const ex_fq_fr&, CurrentType) noexcept + { + return ex_fq_fr<CurrentType, CurrentType>(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_fq_fr&, const ex_fq_fr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_fq_fr&, const ex_fq_fr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <typename CurrentType, typename OtherType> +struct is_executor<ex_fq_fr<CurrentType, OtherType> > + : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct query_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + || asio::is_convertible<Param, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef CurrentType result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_REQUIRE_FREE_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct require_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_fq_fr<CurrentType, OtherType> result_type; +}; + +template <typename CurrentType, typename OtherType, typename Param> +struct require_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, OtherType>::value + && !asio::is_same<CurrentType, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_fq_fr<OtherType, CurrentType> result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_REQUIRE_FREE_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_PREFER_FREE_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct prefer_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_fq_fr<CurrentType, OtherType> result_type; +}; + +template <typename CurrentType, typename OtherType, typename Param> +struct prefer_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, OtherType>::value + && !asio::is_same<CurrentType, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_fq_fr<OtherType, CurrentType> result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_PREFER_FREE_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename Executor, typename Param, bool ExpectedResult> +void test_can_query() +{ + constexpr bool b1 = + asio::can_query<Executor, Param>::value; + ASIO_CHECK(b1 == ExpectedResult); + + constexpr bool b2 = + asio::can_query<const Executor, Param>::value; + ASIO_CHECK(b2 == ExpectedResult); + + constexpr bool b3 = + asio::can_query<Executor&, Param>::value; + ASIO_CHECK(b3 == ExpectedResult); + + constexpr bool b4 = + asio::can_query<const Executor&, Param>::value; + ASIO_CHECK(b4 == ExpectedResult); +} + +template <typename Executor, typename Param, typename ExpectedResult> +void test_query() +{ + exec::outstanding_work_t result1 = asio::query(Executor(), Param()); + ASIO_CHECK(result1 == ExpectedResult()); + + Executor ex1 = {}; + exec::outstanding_work_t result2 = asio::query(ex1, Param()); + ASIO_CHECK(result2 == ExpectedResult()); + + const Executor ex2 = {}; + exec::outstanding_work_t result3 = asio::query(ex2, Param()); + ASIO_CHECK(result3 == ExpectedResult()); +} + +template <typename Executor, typename Param, typename ExpectedResult> +void test_constexpr_query() +{ + constexpr Executor ex1 = {}; + constexpr exec::outstanding_work_t result1 = asio::query(ex1, Param()); + ASIO_CHECK(result1 == ExpectedResult()); +} + +template <typename Executor, typename Param, bool ExpectedResult> +void test_can_require() +{ + constexpr bool b1 = + asio::can_require<Executor, Param>::value; + ASIO_CHECK(b1 == ExpectedResult); + + constexpr bool b2 = + asio::can_require<const Executor, Param>::value; + ASIO_CHECK(b2 == ExpectedResult); + + constexpr bool b3 = + asio::can_require<Executor&, Param>::value; + ASIO_CHECK(b3 == ExpectedResult); + + constexpr bool b4 = + asio::can_require<const Executor&, Param>::value; + ASIO_CHECK(b4 == ExpectedResult); +} + +template <typename Executor, typename Param, typename ExpectedResult> +void test_require() +{ + ASIO_CHECK( + asio::query( + asio::require(Executor(), Param()), + Param()) == ExpectedResult()); + + Executor ex1 = {}; + ASIO_CHECK( + asio::query( + asio::require(ex1, Param()), + Param()) == ExpectedResult()); + + const Executor ex2 = {}; + ASIO_CHECK( + asio::query( + asio::require(ex2, Param()), + Param()) == ExpectedResult()); +} + +template <typename Executor, typename Param, bool ExpectedResult> +void test_can_prefer() +{ + constexpr bool b1 = + asio::can_prefer<Executor, Param>::value; + ASIO_CHECK(b1 == ExpectedResult); + + constexpr bool b2 = + asio::can_prefer<const Executor, Param>::value; + ASIO_CHECK(b2 == ExpectedResult); + + constexpr bool b3 = + asio::can_prefer<Executor&, Param>::value; + ASIO_CHECK(b3 == ExpectedResult); + + constexpr bool b4 = + asio::can_prefer<const Executor&, Param>::value; + ASIO_CHECK(b4 == ExpectedResult); +} + +template <typename Executor, typename Param, typename ExpectedResult> +void test_prefer() +{ + ASIO_CHECK( + s(asio::query( + asio::prefer(Executor(), Param()), + s())) == s(ExpectedResult())); + + Executor ex1 = {}; + ASIO_CHECK( + s(asio::query( + asio::prefer(ex1, Param()), + s())) == s(ExpectedResult())); + + const Executor ex2 = {}; + ASIO_CHECK( + s(asio::query( + asio::prefer(ex2, Param()), + s())) == s(ExpectedResult())); +} + +void test_vars() +{ + ASIO_CHECK(s() == exec::outstanding_work); + ASIO_CHECK(s() != exec::outstanding_work.untracked); + ASIO_CHECK(s() != exec::outstanding_work.tracked); + ASIO_CHECK(n1() == exec::outstanding_work.untracked); + ASIO_CHECK(n1() != exec::outstanding_work.tracked); + ASIO_CHECK(n2() == exec::outstanding_work.tracked); + ASIO_CHECK(n2() != exec::outstanding_work.untracked); +} + +ASIO_TEST_SUITE +( + "outstanding_work", + + ASIO_TEST_CASE3(test_can_query<ex_nq_nr, s, true>) + ASIO_TEST_CASE3(test_can_query<ex_nq_nr, n1, true>) + ASIO_TEST_CASE3(test_can_query<ex_nq_nr, n2, false>) + + ASIO_TEST_CASE3(test_query<ex_nq_nr, s, n1>) + ASIO_TEST_CASE3(test_query<ex_nq_nr, n1, n1>) + + ASIO_TEST_CASE3(test_constexpr_query<ex_nq_nr, s, n1>) + ASIO_TEST_CASE3(test_constexpr_query<ex_nq_nr, n1, n1>) + + ASIO_TEST_CASE3(test_can_require<ex_nq_nr, s, false>) + ASIO_TEST_CASE3(test_can_require<ex_nq_nr, n1, true>) + ASIO_TEST_CASE3(test_can_require<ex_nq_nr, n2, false>) + + ASIO_TEST_CASE3(test_require<ex_nq_nr, n1, n1>) + + ASIO_TEST_CASE3(test_can_prefer<ex_nq_nr, s, false>) + ASIO_TEST_CASE3(test_can_prefer<ex_nq_nr, n1, true>) + ASIO_TEST_CASE3(test_can_prefer<ex_nq_nr, n2, true>) + + ASIO_TEST_CASE3(test_prefer<ex_nq_nr, n1, n1>) + ASIO_TEST_CASE3(test_prefer<ex_nq_nr, n2, n1>) + + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n1, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n2, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n2, s, n2>, n2, true>) + + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n1, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n2, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n2, s, n2>, n2, n2>) + + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n1>, s, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n2>, s, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n1>, s, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n2>, s, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n1, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n2, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n2, s, n2>, n2, n2>) + + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n1, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n2, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n2, s, n2>, n2, true>) + + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<n2, s, n2>, n2, n2>) + + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n2, s, n2>, n2, true>) + + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n2, s, n2>, n2, n2>) + + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n1, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n2, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n2, s, n2>, n2, true>) + + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n1, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n2, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n2, s, n2>, n2, n2>) + + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n1, s, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n1, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n2, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n2, s, n2>, n2, false>) + + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n2, s, n2>, n2, true>) + + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n2, s, n2>, n2, n2>) + + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n1, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n2, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n2, s, n2>, n2, true>) + + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n1, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n2, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n2, s, n2>, n2, n2>) + + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n1, s, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n1, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n2, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n2, s, n2>, n2, false>) + + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n2, s, n2>, n2, true>) + + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n2, s, n2>, n2, n2>) + + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n2>, n2, true>) + + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n1>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n2>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n1>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n2>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n2>, n2, n2>) + + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n2>, n2, true>) + + ASIO_TEST_CASE4(test_require<ex_mq_mr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n1, n2>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n2, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n2, n2>, n2, n2>) + + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n2>, n2, true>) + + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n1>, n2, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n2>, n2, n2>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n2>, n1, n2>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n2>, n2, n2>) + + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n2>, n2, true>) + + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n1>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n2>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n1>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n2>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n2>, n2, n2>) + + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n2>, n2, true>) + + ASIO_TEST_CASE4(test_require<ex_fq_fr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n1, n2>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n2, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n2, n2>, n2, n2>) + + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n2>, n2, true>) + + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n1>, n2, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n2>, n2, n2>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n2>, n1, n2>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n2>, n2, n2>) + + ASIO_TEST_CASE(test_vars) +) diff --git a/3rdparty/asio/src/tests/unit/execution/prefer_only.cpp b/3rdparty/asio/src/tests/unit/execution/prefer_only.cpp new file mode 100644 index 00000000000..60500002475 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/execution/prefer_only.cpp @@ -0,0 +1,533 @@ +// +// prefer_only.cpp +// ~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/execution/prefer_only.hpp" + +#include <functional> +#include "asio/execution/any_executor.hpp" +#include "../unit_test.hpp" + +using namespace asio; +namespace bindns = std; + +static int possibly_blocking_count = 0; +static int never_blocking_count = 0; + +struct possibly_blocking_executor +{ + template <typename F> + void execute(const F&) const + { + ++possibly_blocking_count; + } + + friend bool operator==(const possibly_blocking_executor&, + const possibly_blocking_executor&) noexcept + { + return true; + } + + friend bool operator!=(const possibly_blocking_executor&, + const possibly_blocking_executor&) noexcept + { + return false; + } +}; + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +template <typename F> +struct execute_member<possibly_blocking_executor, F> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + typedef void result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +template <> +struct equality_comparable<possibly_blocking_executor> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +} // namespace traits +} // namespace asio + +struct never_blocking_executor +{ + static constexpr execution::blocking_t::never_t + query(execution::blocking_t) noexcept + { + return execution::blocking_t::never_t(); + } + + template <typename F> + void execute(const F&) const + { + ++never_blocking_count; + } + + friend bool operator==(const never_blocking_executor&, + const never_blocking_executor&) noexcept + { + return true; + } + + friend bool operator!=(const never_blocking_executor&, + const never_blocking_executor&) noexcept + { + return false; + } +}; + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +template <typename F> +struct execute_member<never_blocking_executor, F> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + typedef void result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +template <> +struct equality_comparable<never_blocking_executor> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT) + +template <typename Param> +struct query_static_constexpr_member< + never_blocking_executor, Param, + typename asio::enable_if< + asio::is_convertible<Param, execution::blocking_t>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef execution::blocking_t::never_t result_type; + + static constexpr result_type value() + { + return result_type(); + } +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT) + +} // namespace traits +} // namespace asio + +struct either_blocking_executor +{ + execution::blocking_t blocking_; + + explicit either_blocking_executor(execution::blocking_t b) + : blocking_(b) + { + } + + execution::blocking_t query(execution::blocking_t) const noexcept + { + return blocking_; + } + + either_blocking_executor require(execution::blocking_t::possibly_t) const + { + return either_blocking_executor(execution::blocking.possibly); + } + + either_blocking_executor require(execution::blocking_t::never_t) const + { + return either_blocking_executor(execution::blocking.never); + } + + template <typename F> + void execute(const F&) const + { + if (blocking_ == execution::blocking.never) + ++never_blocking_count; + else + ++possibly_blocking_count; + } + + friend bool operator==(const either_blocking_executor& a, + const either_blocking_executor& b) noexcept + { + return a.blocking_ == b.blocking_; + } + + friend bool operator!=(const either_blocking_executor& a, + const either_blocking_executor& b) noexcept + { + return a.blocking_ != b.blocking_; + } +}; + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +template <typename F> +struct execute_member<either_blocking_executor, F> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + typedef void result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +template <> +struct equality_comparable<either_blocking_executor> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +template <typename Param> +struct query_member< + either_blocking_executor, Param, + typename asio::enable_if< + asio::is_convertible<Param, execution::blocking_t>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef execution::blocking_t result_type; +}; + +#if !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT) + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +template <typename Param> +struct require_member< + either_blocking_executor, Param, + typename asio::enable_if< + asio::is_convertible<Param, execution::blocking_t>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = false; + + typedef either_blocking_executor result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +} // namespace traits +} // namespace asio + +void prefer_only_executor_query_test() +{ + typedef execution::any_executor< + execution::blocking_t, + execution::prefer_only<execution::blocking_t::possibly_t>, + execution::prefer_only<execution::blocking_t::never_t> + > executor_type; + + executor_type ex1 = possibly_blocking_executor(); + + ASIO_CHECK( + asio::query(ex1, execution::blocking) + == execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ex1, execution::blocking.possibly) + == execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ex1, execution::blocking.never) + == execution::blocking.possibly); + + executor_type ex2 = asio::prefer(ex1, execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ex2, execution::blocking) + == execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ex2, execution::blocking.possibly) + == execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ex2, execution::blocking.never) + == execution::blocking.possibly); + + executor_type ex3 = asio::prefer(ex1, execution::blocking.never); + + ASIO_CHECK( + asio::query(ex3, execution::blocking) + == execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ex3, execution::blocking.possibly) + == execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ex3, execution::blocking.never) + == execution::blocking.possibly); + + executor_type ex4 = never_blocking_executor(); + + ASIO_CHECK( + asio::query(ex4, execution::blocking) + == execution::blocking.never); + + ASIO_CHECK( + asio::query(ex4, execution::blocking.possibly) + == execution::blocking.never); + + ASIO_CHECK( + asio::query(ex4, execution::blocking.never) + == execution::blocking.never); + + executor_type ex5 = asio::prefer(ex4, execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ex5, execution::blocking) + == execution::blocking.never); + + ASIO_CHECK( + asio::query(ex5, execution::blocking.possibly) + == execution::blocking.never); + + ASIO_CHECK( + asio::query(ex5, execution::blocking.never) + == execution::blocking.never); + + executor_type ex6 = asio::prefer(ex4, execution::blocking.never); + + ASIO_CHECK( + asio::query(ex6, execution::blocking) + == execution::blocking.never); + + ASIO_CHECK( + asio::query(ex6, execution::blocking.possibly) + == execution::blocking.never); + + ASIO_CHECK( + asio::query(ex6, execution::blocking.never) + == execution::blocking.never); + + executor_type ex7 = either_blocking_executor(execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ex7, execution::blocking) + == execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ex7, execution::blocking.possibly) + == execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ex7, execution::blocking.never) + == execution::blocking.possibly); + + executor_type ex8 = asio::prefer(ex7, execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ex8, execution::blocking) + == execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ex8, execution::blocking.possibly) + == execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ex8, execution::blocking.never) + == execution::blocking.possibly); + + executor_type ex9 = asio::prefer(ex7, execution::blocking.never); + + ASIO_CHECK( + asio::query(ex9, execution::blocking) + == execution::blocking.never); + + ASIO_CHECK( + asio::query(ex9, execution::blocking.possibly) + == execution::blocking.never); + + ASIO_CHECK( + asio::query(ex9, execution::blocking.never) + == execution::blocking.never); + + executor_type ex10 = either_blocking_executor(execution::blocking.never); + + ASIO_CHECK( + asio::query(ex10, execution::blocking) + == execution::blocking.never); + + ASIO_CHECK( + asio::query(ex10, execution::blocking.possibly) + == execution::blocking.never); + + ASIO_CHECK( + asio::query(ex10, execution::blocking.never) + == execution::blocking.never); + + executor_type ex11 = asio::prefer(ex7, execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ex11, execution::blocking) + == execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ex11, execution::blocking.possibly) + == execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ex11, execution::blocking.never) + == execution::blocking.possibly); + + executor_type ex12 = asio::prefer(ex7, execution::blocking.never); + + ASIO_CHECK( + asio::query(ex12, execution::blocking) + == execution::blocking.never); + + ASIO_CHECK( + asio::query(ex12, execution::blocking.possibly) + == execution::blocking.never); + + ASIO_CHECK( + asio::query(ex12, execution::blocking.never) + == execution::blocking.never); +} + +void do_nothing() +{ +} + +void prefer_only_executor_execute_test() +{ + typedef execution::any_executor< + execution::blocking_t, + execution::prefer_only<execution::blocking_t::possibly_t>, + execution::prefer_only<execution::blocking_t::never_t> + > executor_type; + + executor_type ex1 = possibly_blocking_executor(); + + ex1.execute(&do_nothing); + ASIO_CHECK(possibly_blocking_count == 1); + ASIO_CHECK(never_blocking_count == 0); + + executor_type ex2 = asio::prefer(ex1, execution::blocking.possibly); + + ex2.execute(&do_nothing); + ASIO_CHECK(possibly_blocking_count == 2); + ASIO_CHECK(never_blocking_count == 0); + + executor_type ex3 = asio::prefer(ex1, execution::blocking.never); + + ex3.execute(&do_nothing); + ASIO_CHECK(possibly_blocking_count == 3); + ASIO_CHECK(never_blocking_count == 0); + + executor_type ex4 = never_blocking_executor(); + + ex4.execute(&do_nothing); + ASIO_CHECK(possibly_blocking_count == 3); + ASIO_CHECK(never_blocking_count == 1); + + executor_type ex5 = asio::prefer(ex4, execution::blocking.possibly); + + ex5.execute(&do_nothing); + ASIO_CHECK(possibly_blocking_count == 3); + ASIO_CHECK(never_blocking_count == 2); + + executor_type ex6 = asio::prefer(ex4, execution::blocking.never); + + ex6.execute(&do_nothing); + ASIO_CHECK(possibly_blocking_count == 3); + ASIO_CHECK(never_blocking_count == 3); + + executor_type ex7 = either_blocking_executor(execution::blocking.possibly); + + ex7.execute(&do_nothing); + ASIO_CHECK(possibly_blocking_count == 4); + ASIO_CHECK(never_blocking_count == 3); + + executor_type ex8 = asio::prefer(ex7, execution::blocking.possibly); + + ex8.execute(&do_nothing); + ASIO_CHECK(possibly_blocking_count == 5); + ASIO_CHECK(never_blocking_count == 3); + + executor_type ex9 = asio::prefer(ex7, execution::blocking.never); + + ex9.execute(&do_nothing); + ASIO_CHECK(possibly_blocking_count == 5); + ASIO_CHECK(never_blocking_count == 4); + + executor_type ex10 = either_blocking_executor(execution::blocking.never); + + ex10.execute(&do_nothing); + ASIO_CHECK(possibly_blocking_count == 5); + ASIO_CHECK(never_blocking_count == 5); + + executor_type ex11 = asio::prefer(ex7, execution::blocking.possibly); + + ex11.execute(&do_nothing); + ASIO_CHECK(possibly_blocking_count == 6); + ASIO_CHECK(never_blocking_count == 5); + + executor_type ex12 = asio::prefer(ex7, execution::blocking.never); + + ex12.execute(&do_nothing); + ASIO_CHECK(possibly_blocking_count == 6); + ASIO_CHECK(never_blocking_count == 6); +} + +ASIO_TEST_SUITE +( + "prefer_only", + ASIO_TEST_CASE(prefer_only_executor_query_test) + ASIO_TEST_CASE(prefer_only_executor_execute_test) +) diff --git a/3rdparty/asio/src/tests/unit/execution/relationship.cpp b/3rdparty/asio/src/tests/unit/execution/relationship.cpp new file mode 100644 index 00000000000..a91144e8125 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/execution/relationship.cpp @@ -0,0 +1,1252 @@ +// +// relationship.cpp +// ~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/execution/relationship.hpp" + +#include "asio/prefer.hpp" +#include "asio/query.hpp" +#include "asio/require.hpp" +#include "../unit_test.hpp" + +namespace exec = asio::execution; + +typedef exec::relationship_t s; +typedef exec::relationship_t::fork_t n1; +typedef exec::relationship_t::continuation_t n2; + +struct ex_nq_nr +{ + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_nq_nr&, const ex_nq_nr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_nq_nr&, const ex_nq_nr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <> +struct is_executor<ex_nq_nr> : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +template <typename ResultType, typename ParamType, typename Result> +struct ex_cq_nr +{ + static constexpr ResultType query(ParamType) noexcept + { + return Result(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_cq_nr&, const ex_cq_nr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_cq_nr&, const ex_cq_nr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <typename ResultType, typename ParamType, typename Result> +struct is_executor<ex_cq_nr<ResultType, ParamType, Result> > + : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT) + +template <typename ResultType, typename ParamType, + typename Result, typename Param> +struct query_static_constexpr_member< + ex_cq_nr<ResultType, ParamType, Result>, Param, + typename asio::enable_if< + asio::is_convertible<Param, ParamType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef Result result_type; // Must return raw result type. + + static constexpr result_type value() + { + return Result(); + } +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename ResultType, typename ParamType, typename Result> +struct ex_mq_nr +{ + ResultType query(ParamType) const noexcept + { + return Result(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_mq_nr&, const ex_mq_nr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_mq_nr&, const ex_mq_nr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <typename ResultType, typename ParamType, typename Result> +struct is_executor<ex_mq_nr<ResultType, ParamType, Result> > + : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +template <typename ResultType, typename ParamType, + typename Result, typename Param> +struct query_member< + ex_mq_nr<ResultType, ParamType, Result>, Param, + typename asio::enable_if< + asio::is_convertible<Param, ParamType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ResultType result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename ResultType, typename ParamType, typename Result> +struct ex_fq_nr +{ + friend ResultType query(const ex_fq_nr&, ParamType) noexcept + { + return Result(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_fq_nr&, const ex_fq_nr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_fq_nr&, const ex_fq_nr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <typename ResultType, typename ParamType, typename Result> +struct is_executor<ex_fq_nr<ResultType, ParamType, Result> > + : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) + +template <typename ResultType, typename ParamType, + typename Result, typename Param> +struct query_free< + ex_fq_nr<ResultType, ParamType, Result>, Param, + typename asio::enable_if< + asio::is_convertible<Param, ParamType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ResultType result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename CurrentType, typename OtherType> +struct ex_mq_mr +{ + CurrentType query(CurrentType) const noexcept + { + return CurrentType(); + } + + CurrentType query(OtherType) const noexcept + { + return CurrentType(); + } + + ex_mq_mr<CurrentType, OtherType> require( + CurrentType) const noexcept + { + return ex_mq_mr<CurrentType, OtherType>(); + } + + ex_mq_mr<OtherType, CurrentType> require( + OtherType) const noexcept + { + return ex_mq_mr<OtherType, CurrentType>(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_mq_mr&, const ex_mq_mr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_mq_mr&, const ex_mq_mr&) noexcept + { + return false; + } +}; + +template <typename CurrentType> +struct ex_mq_mr<CurrentType, CurrentType> +{ + CurrentType query(CurrentType) const noexcept + { + return CurrentType(); + } + + ex_mq_mr<CurrentType, CurrentType> require( + CurrentType) const noexcept + { + return ex_mq_mr<CurrentType, CurrentType>(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_mq_mr&, const ex_mq_mr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_mq_mr&, const ex_mq_mr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <typename CurrentType, typename OtherType> +struct is_executor<ex_mq_mr<CurrentType, OtherType> > + : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct query_member< + ex_mq_mr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + || asio::is_convertible<Param, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef CurrentType result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct require_member< + ex_mq_mr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_mq_mr<CurrentType, OtherType> result_type; +}; + +template <typename CurrentType, typename OtherType, typename Param> +struct require_member< + ex_mq_mr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, OtherType>::value + && !asio::is_same<CurrentType, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_mq_mr<OtherType, CurrentType> result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename CurrentType, typename OtherType> +struct ex_fq_fr +{ + friend CurrentType query(const ex_fq_fr&, CurrentType) noexcept + { + return CurrentType(); + } + + friend CurrentType query(const ex_fq_fr&, OtherType) noexcept + { + return CurrentType(); + } + + friend ex_fq_fr<CurrentType, OtherType> require( + const ex_fq_fr&, CurrentType) noexcept + { + return ex_fq_fr<CurrentType, OtherType>(); + } + + friend ex_fq_fr<OtherType, CurrentType> require( + const ex_fq_fr&, OtherType) noexcept + { + return ex_fq_fr<OtherType, CurrentType>(); + } + + friend ex_fq_fr<CurrentType, OtherType> prefer( + const ex_fq_fr&, CurrentType) noexcept + { + return ex_fq_fr<CurrentType, OtherType>(); + } + + friend ex_fq_fr<OtherType, CurrentType> prefer( + const ex_fq_fr&, OtherType) noexcept + { + return ex_fq_fr<OtherType, CurrentType>(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_fq_fr&, const ex_fq_fr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_fq_fr&, const ex_fq_fr&) noexcept + { + return false; + } +}; + +template <typename CurrentType> +struct ex_fq_fr<CurrentType, CurrentType> +{ + friend CurrentType query(const ex_fq_fr&, CurrentType) noexcept + { + return CurrentType(); + } + + friend ex_fq_fr<CurrentType, CurrentType> require( + const ex_fq_fr&, CurrentType) noexcept + { + return ex_fq_fr<CurrentType, CurrentType>(); + } + + friend ex_fq_fr<CurrentType, CurrentType> prefer( + const ex_fq_fr&, CurrentType) noexcept + { + return ex_fq_fr<CurrentType, CurrentType>(); + } + + template <typename F> + void execute(const F&) const + { + } + + friend bool operator==(const ex_fq_fr&, const ex_fq_fr&) noexcept + { + return true; + } + + friend bool operator!=(const ex_fq_fr&, const ex_fq_fr&) noexcept + { + return false; + } +}; + +#if !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace execution { + +template <typename CurrentType, typename OtherType> +struct is_executor<ex_fq_fr<CurrentType, OtherType> > + : asio::true_type +{ +}; + +} // namespace execution +} // namespace asio + +#endif // !defined(ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT) + +namespace asio { +namespace traits { + +#if !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct query_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + || asio::is_convertible<Param, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef CurrentType result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_REQUIRE_FREE_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct require_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_fq_fr<CurrentType, OtherType> result_type; +}; + +template <typename CurrentType, typename OtherType, typename Param> +struct require_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, OtherType>::value + && !asio::is_same<CurrentType, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_fq_fr<OtherType, CurrentType> result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_REQUIRE_FREE_TRAIT) + +#if !defined(ASIO_HAS_DEDUCED_PREFER_FREE_TRAIT) + +template <typename CurrentType, typename OtherType, typename Param> +struct prefer_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, CurrentType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_fq_fr<CurrentType, OtherType> result_type; +}; + +template <typename CurrentType, typename OtherType, typename Param> +struct prefer_free< + ex_fq_fr<CurrentType, OtherType>, Param, + typename asio::enable_if< + asio::is_convertible<Param, OtherType>::value + && !asio::is_same<CurrentType, OtherType>::value + >::type> +{ + static constexpr bool is_valid = true; + static constexpr bool is_noexcept = true; + + typedef ex_fq_fr<OtherType, CurrentType> result_type; +}; + +#endif // !defined(ASIO_HAS_DEDUCED_PREFER_FREE_TRAIT) + +} // namespace traits +} // namespace asio + +template <typename Executor, typename Param, bool ExpectedResult> +void test_can_query() +{ + constexpr bool b1 = + asio::can_query<Executor, Param>::value; + ASIO_CHECK(b1 == ExpectedResult); + + constexpr bool b2 = + asio::can_query<const Executor, Param>::value; + ASIO_CHECK(b2 == ExpectedResult); + + constexpr bool b3 = + asio::can_query<Executor&, Param>::value; + ASIO_CHECK(b3 == ExpectedResult); + + constexpr bool b4 = + asio::can_query<const Executor&, Param>::value; + ASIO_CHECK(b4 == ExpectedResult); +} + +template <typename Executor, typename Param, typename ExpectedResult> +void test_query() +{ + exec::relationship_t result1 = asio::query(Executor(), Param()); + ASIO_CHECK(result1 == ExpectedResult()); + + Executor ex1 = {}; + exec::relationship_t result2 = asio::query(ex1, Param()); + ASIO_CHECK(result2 == ExpectedResult()); + + const Executor ex2 = {}; + exec::relationship_t result3 = asio::query(ex2, Param()); + ASIO_CHECK(result3 == ExpectedResult()); +} + +template <typename Executor, typename Param, typename ExpectedResult> +void test_constexpr_query() +{ + constexpr Executor ex1 = {}; + constexpr exec::relationship_t result1 = asio::query(ex1, Param()); + ASIO_CHECK(result1 == ExpectedResult()); +} + +template <typename Executor, typename Param, bool ExpectedResult> +void test_can_require() +{ + constexpr bool b1 = + asio::can_require<Executor, Param>::value; + ASIO_CHECK(b1 == ExpectedResult); + + constexpr bool b2 = + asio::can_require<const Executor, Param>::value; + ASIO_CHECK(b2 == ExpectedResult); + + constexpr bool b3 = + asio::can_require<Executor&, Param>::value; + ASIO_CHECK(b3 == ExpectedResult); + + constexpr bool b4 = + asio::can_require<const Executor&, Param>::value; + ASIO_CHECK(b4 == ExpectedResult); +} + +template <typename Executor, typename Param, typename ExpectedResult> +void test_require() +{ + ASIO_CHECK( + asio::query( + asio::require(Executor(), Param()), + Param()) == ExpectedResult()); + + Executor ex1 = {}; + ASIO_CHECK( + asio::query( + asio::require(ex1, Param()), + Param()) == ExpectedResult()); + + const Executor ex2 = {}; + ASIO_CHECK( + asio::query( + asio::require(ex2, Param()), + Param()) == ExpectedResult()); +} + +template <typename Executor, typename Param, bool ExpectedResult> +void test_can_prefer() +{ + constexpr bool b1 = + asio::can_prefer<Executor, Param>::value; + ASIO_CHECK(b1 == ExpectedResult); + + constexpr bool b2 = + asio::can_prefer<const Executor, Param>::value; + ASIO_CHECK(b2 == ExpectedResult); + + constexpr bool b3 = + asio::can_prefer<Executor&, Param>::value; + ASIO_CHECK(b3 == ExpectedResult); + + constexpr bool b4 = + asio::can_prefer<const Executor&, Param>::value; + ASIO_CHECK(b4 == ExpectedResult); +} + +template <typename Executor, typename Param, typename ExpectedResult> +void test_prefer() +{ + ASIO_CHECK( + s(asio::query( + asio::prefer(Executor(), Param()), + s())) == s(ExpectedResult())); + + Executor ex1 = {}; + ASIO_CHECK( + s(asio::query( + asio::prefer(ex1, Param()), + s())) == s(ExpectedResult())); + + const Executor ex2 = {}; + ASIO_CHECK( + s(asio::query( + asio::prefer(ex2, Param()), + s())) == s(ExpectedResult())); +} + +void test_vars() +{ + ASIO_CHECK(s() == exec::relationship); + ASIO_CHECK(s() != exec::relationship.fork); + ASIO_CHECK(s() != exec::relationship.continuation); + ASIO_CHECK(n1() == exec::relationship.fork); + ASIO_CHECK(n1() != exec::relationship.continuation); + ASIO_CHECK(n2() == exec::relationship.continuation); + ASIO_CHECK(n2() != exec::relationship.fork); +} + +ASIO_TEST_SUITE +( + "relationship", + + ASIO_TEST_CASE3(test_can_query<ex_nq_nr, s, true>) + ASIO_TEST_CASE3(test_can_query<ex_nq_nr, n1, true>) + ASIO_TEST_CASE3(test_can_query<ex_nq_nr, n2, false>) + + ASIO_TEST_CASE3(test_query<ex_nq_nr, s, n1>) + ASIO_TEST_CASE3(test_query<ex_nq_nr, n1, n1>) + + ASIO_TEST_CASE3(test_constexpr_query<ex_nq_nr, s, n1>) + ASIO_TEST_CASE3(test_constexpr_query<ex_nq_nr, n1, n1>) + + ASIO_TEST_CASE3(test_can_require<ex_nq_nr, s, false>) + ASIO_TEST_CASE3(test_can_require<ex_nq_nr, n1, true>) + ASIO_TEST_CASE3(test_can_require<ex_nq_nr, n2, false>) + + ASIO_TEST_CASE3(test_require<ex_nq_nr, n1, n1>) + + ASIO_TEST_CASE3(test_can_prefer<ex_nq_nr, s, false>) + ASIO_TEST_CASE3(test_can_prefer<ex_nq_nr, n1, true>) + ASIO_TEST_CASE3(test_can_prefer<ex_nq_nr, n2, true>) + + ASIO_TEST_CASE3(test_prefer<ex_nq_nr, n1, n1>) + ASIO_TEST_CASE3(test_prefer<ex_nq_nr, n2, n1>) + + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n1, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n2, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_cq_nr<n2, s, n2>, n2, true>) + + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n1, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n2, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_cq_nr<n2, s, n2>, n2, n2>) + + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n1>, s, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n2>, s, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n1>, s, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n2>, s, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n1, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n2, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_constexpr_query<ex_cq_nr<n2, s, n2>, n2, n2>) + + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n1, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n2, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_cq_nr<n2, s, n2>, n2, true>) + + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_require<ex_cq_nr<n2, s, n2>, n2, n2>) + + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n1, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_cq_nr<n2, s, n2>, n2, true>) + + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n1, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_cq_nr<n2, s, n2>, n2, n2>) + + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n1, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n2, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_mq_nr<n2, s, n2>, n2, true>) + + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n1, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n2, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_mq_nr<n2, s, n2>, n2, n2>) + + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, s, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<s, n2, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n1, s, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n1, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n2, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_mq_nr<n2, s, n2>, n2, false>) + + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n1, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_mq_nr<n2, s, n2>, n2, true>) + + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n1, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_mq_nr<n2, s, n2>, n2, n2>) + + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n1, s, n1>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n2, s, n2>, s, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_query<ex_fq_nr<n2, s, n2>, n2, true>) + + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n1, s, n1>, s, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n2, s, n2>, s, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_query<ex_fq_nr<n2, s, n2>, n2, n2>) + + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, s, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n1, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<s, n2, n2>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n1, s, n1>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n1, s, n1>, n2, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n2, s, n2>, n1, false>) + ASIO_TEST_CASE5(test_can_require<ex_fq_nr<n2, s, n2>, n2, false>) + + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, s, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n1, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<s, n2, n2>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n1, s, n1>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n1, s, n1>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n1, s, n1>, n2, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n2, s, n2>, s, false>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n2, s, n2>, n1, true>) + ASIO_TEST_CASE5(test_can_prefer<ex_fq_nr<n2, s, n2>, n2, true>) + + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, s, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n1, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<s, n2, n2>, n2, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n1, s, n1>, n1, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n1, s, n1>, n2, n1>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n2, s, n2>, n1, n2>) + ASIO_TEST_CASE5(test_prefer<ex_fq_nr<n2, s, n2>, n2, n2>) + + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_query<ex_mq_mr<n2, n2>, n2, true>) + + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n1>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n2>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n1>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n2>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_mq_mr<n2, n2>, n2, n2>) + + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_require<ex_mq_mr<n2, n2>, n2, true>) + + ASIO_TEST_CASE4(test_require<ex_mq_mr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n1, n2>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n2, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_mq_mr<n2, n2>, n2, n2>) + + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_mq_mr<n2, n2>, n2, true>) + + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n1>, n2, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n1, n2>, n2, n2>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n2>, n1, n2>) + ASIO_TEST_CASE4(test_prefer<ex_mq_mr<n2, n2>, n2, n2>) + + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n1>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n2>, s, true>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_query<ex_fq_fr<n2, n2>, n2, true>) + + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n1>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n2>, s, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n1>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n2>, s, n2>) + ASIO_TEST_CASE4(test_query<ex_fq_fr<n2, n2>, n2, n2>) + + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n1>, n2, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n1>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n2>, s, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n2>, n1, false>) + ASIO_TEST_CASE4(test_can_require<ex_fq_fr<n2, n2>, n2, true>) + + ASIO_TEST_CASE4(test_require<ex_fq_fr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n1, n2>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n2, n1>, n1, n1>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_require<ex_fq_fr<n2, n2>, n2, n2>) + + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n1, n2>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n1>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n1>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n1>, n2, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n2>, s, false>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n2>, n1, true>) + ASIO_TEST_CASE4(test_can_prefer<ex_fq_fr<n2, n2>, n2, true>) + + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n1>, n2, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n2>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n1, n2>, n2, n2>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n1>, n1, n1>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n1>, n2, n2>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n2>, n1, n2>) + ASIO_TEST_CASE4(test_prefer<ex_fq_fr<n2, n2>, n2, n2>) + + ASIO_TEST_CASE(test_vars) +) diff --git a/3rdparty/asio/src/tests/unit/execution_context.cpp b/3rdparty/asio/src/tests/unit/execution_context.cpp index 802c483be41..cf5a499e256 100644 --- a/3rdparty/asio/src/tests/unit/execution_context.cpp +++ b/3rdparty/asio/src/tests/unit/execution_context.cpp @@ -2,7 +2,7 @@ // execution_context.cpp // ~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/executor.cpp b/3rdparty/asio/src/tests/unit/executor.cpp index 493e363c1b3..7ea75055aa4 100644 --- a/3rdparty/asio/src/tests/unit/executor.cpp +++ b/3rdparty/asio/src/tests/unit/executor.cpp @@ -2,7 +2,7 @@ // executor.cpp // ~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/executor_work_guard.cpp b/3rdparty/asio/src/tests/unit/executor_work_guard.cpp index ac62bc5427d..5d7aecd5c7c 100644 --- a/3rdparty/asio/src/tests/unit/executor_work_guard.cpp +++ b/3rdparty/asio/src/tests/unit/executor_work_guard.cpp @@ -2,7 +2,7 @@ // executor_work_guard.cpp // ~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/experimental/awaitable_operators.cpp b/3rdparty/asio/src/tests/unit/experimental/awaitable_operators.cpp new file mode 100644 index 00000000000..e79eeae3eea --- /dev/null +++ b/3rdparty/asio/src/tests/unit/experimental/awaitable_operators.cpp @@ -0,0 +1,297 @@ +// +// experimental/awaitable_operators.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Prevent link dependency on the Boost.System library. +#if !defined(BOOST_SYSTEM_NO_DEPRECATED) +#define BOOST_SYSTEM_NO_DEPRECATED +#endif // !defined(BOOST_SYSTEM_NO_DEPRECATED) + +// Test that header file is self-contained. +#include "asio/experimental/awaitable_operators.hpp" + +#include "asio/co_spawn.hpp" +#include "asio/detached.hpp" +#include "asio/io_context.hpp" +#include "asio/post.hpp" +#include "../unit_test.hpp" + +using asio::awaitable; +using namespace asio::experimental::awaitable_operators; + +struct move_only +{ + move_only(int i) : value(i) {} + move_only(const move_only&) = delete; + move_only(move_only&&) {} + move_only& operator=(const move_only&) = delete; + move_only& operator=(move_only&&) { return *this; } + int value; +}; + +awaitable<void> void_ok() +{ + co_return; +} + +awaitable<void> void_ex() +{ + throw std::runtime_error("exception"); + co_return; +} + +awaitable<void> void_post_loop() +{ + for (;;) + co_await asio::post(asio::use_awaitable); +} + +awaitable<int> int_0() +{ + co_return 0; +} + +awaitable<int> int_1() +{ + co_return 1; +} + +awaitable<int> int_2() +{ + co_return 2; +} + +awaitable<int> int_ex() +{ + throw std::runtime_error("exception"); + co_return -1; +} + +awaitable<move_only> move_only_0() +{ + co_return move_only(0); +} + +awaitable<move_only> move_only_1() +{ + co_return move_only(1); +} + +awaitable<move_only> move_only_2() +{ + co_return move_only(2); +} + +awaitable<move_only> move_only_ex() +{ + throw std::runtime_error("exception"); + co_return move_only(-1); +} + +awaitable<void> do_test_and_awaitable_operator() +{ + int i; + std::tuple<int, int> ii; + std::tuple<int, int, int> iii; + + co_await (void_ok() && void_ok()); + co_await (void_ok() && void_ok() && void_ok()); + try { co_await (void_ex() && void_ok()); } catch (...) {} + try { co_await (void_ex() && void_ok() && void_ok()); } catch (...) {} + try { co_await (void_ex() && void_post_loop()); } catch (...) {} + try { co_await (void_ex() && void_ok() && void_post_loop()); } catch (...) {} + + i = co_await (void_ok() && int_0()); + ASIO_CHECK(i == 0); + + i = co_await (void_ok() && int_1()); + ASIO_CHECK(i == 1); + + i = co_await (int_0() && void_ok()); + ASIO_CHECK(i == 0); + + ii = co_await (int_0() && int_1()); + ASIO_CHECK(std::get<0>(ii) == 0); + ASIO_CHECK(std::get<1>(ii) == 1); + + i = co_await (void_ok() && void_ok() && int_0()); + ASIO_CHECK(i == 0); + + i = co_await (void_ok() && int_0() && void_ok()); + ASIO_CHECK(i == 0); + + ii = co_await (void_ok() && int_0() && int_1()); + ASIO_CHECK(std::get<0>(ii) == 0); + ASIO_CHECK(std::get<1>(ii) == 1); + + ii = co_await (int_0() && void_ok() && int_1()); + ASIO_CHECK(std::get<0>(ii) == 0); + ASIO_CHECK(std::get<1>(ii) == 1); + + iii = co_await (int_0() && int_1() && int_2()); + ASIO_CHECK(std::get<0>(iii) == 0); + ASIO_CHECK(std::get<1>(iii) == 1); + ASIO_CHECK(std::get<2>(iii) == 2); +} + +void test_and_awaitable_operator() +{ + asio::io_context ctx; + co_spawn(ctx, do_test_and_awaitable_operator(), asio::detached); + ctx.run(); +} + +awaitable<void> do_test_or_awaitable_operator() +{ + std::variant<int, int> ii; + std::variant<int, std::monostate> iv; + std::variant<std::monostate, int> vi; + std::variant<std::monostate, std::monostate> vv; + std::variant<int, int, int> iii; + std::variant<int, int, std::monostate> iiv; + std::variant<int, std::monostate, int> ivi; + std::variant<int, std::monostate, std::monostate> ivv; + std::variant<std::monostate, int, int> vii; + std::variant<std::monostate, int, std::monostate> viv; + std::variant<std::monostate, std::monostate, int> vvi; + std::variant<std::monostate, std::monostate, std::monostate> vvv; + + vv = co_await (void_ok() || void_ok()); + ASIO_CHECK(vv.index() == 0); + + vv = co_await (void_ex() || void_ok()); + ASIO_CHECK(vv.index() == 1); + + vi = co_await (void_ok() || int_0()); + ASIO_CHECK(vi.index() == 0); + + vi = co_await (void_ex() || int_0()); + ASIO_CHECK(vi.index() == 1); + + iv = co_await (int_0() || void_ex()); + ASIO_CHECK(iv.index() == 0); + ASIO_CHECK(std::get<0>(iv) == 0); + + ii = co_await (int_0() || int_1()); + ASIO_CHECK(ii.index() == 0); + ASIO_CHECK(std::get<0>(ii) == 0); + + ii = co_await (int_ex() || int_1()); + ASIO_CHECK(ii.index() == 1); + ASIO_CHECK(std::get<1>(ii) == 1); + + vvv = co_await (void_ok() || void_ok() || void_ok()); + ASIO_CHECK(vvv.index() == 0); + + vvv = co_await (void_ex() || void_ok() || void_ok()); + ASIO_CHECK(vvv.index() == 1); + + vvv = co_await (void_ex() || void_ex() || void_ok()); + ASIO_CHECK(vvv.index() == 2); + + vvi = co_await (void_ok() || void_ok() || int_0()); + ASIO_CHECK(vvi.index() == 0); + + viv = co_await (void_ok() || int_0() || void_ok()); + ASIO_CHECK(viv.index() == 0); + + viv = co_await (void_ex() || int_0() || void_ok()); + ASIO_CHECK(viv.index() == 1); + ASIO_CHECK(std::get<1>(viv) == 0); + + vii = co_await (void_ex() || int_0() || int_1()); + ASIO_CHECK(vii.index() == 1); + ASIO_CHECK(std::get<1>(vii) == 0); + + ivv = co_await (int_0() || void_ok() || void_ok()); + ASIO_CHECK(ivv.index() == 0); + ASIO_CHECK(std::get<0>(ivv) == 0); + + ivv = co_await (int_ex() || void_ok() || void_ok()); + ASIO_CHECK(ivv.index() == 1); + + ivi = co_await (int_0() || void_ok() || int_1()); + ASIO_CHECK(ivi.index() == 0); + ASIO_CHECK(std::get<0>(ivi) == 0); + + ivi = co_await (int_ex() || void_ok() || int_1()); + ASIO_CHECK(ivi.index() == 1); + + iiv = co_await (int_0() || int_1() || void_ok()); + ASIO_CHECK(iiv.index() == 0); + ASIO_CHECK(std::get<0>(iiv) == 0); + + iiv = co_await (int_ex() || int_1() || void_ok()); + ASIO_CHECK(iiv.index() == 1); + ASIO_CHECK(std::get<0>(iiv) == 1); + + iiv = co_await (int_ex() || int_ex() || void_ok()); + ASIO_CHECK(iiv.index() == 2); + + iii = co_await (int_0() || int_1() || int_2()); + ASIO_CHECK(iii.index() == 0); + ASIO_CHECK(std::get<0>(iii) == 0); + + iii = co_await (int_ex() || int_1() || int_2()); + ASIO_CHECK(iii.index() == 1); + ASIO_CHECK(std::get<1>(iii) == 1); + + iii = co_await (int_ex() || int_ex() || int_2()); + ASIO_CHECK(iii.index() == 2); + ASIO_CHECK(std::get<2>(iii) == 2); + + std::variant<move_only, int> mi = co_await (move_only_0() || int_1()); + ASIO_CHECK(mi.index() == 0); + ASIO_CHECK(std::get<0>(mi).value == 0); + + mi = co_await (move_only_ex() || int_1()); + ASIO_CHECK(mi.index() == 1); + ASIO_CHECK(std::get<1>(mi) == 1); + + std::variant<move_only, move_only> mm = + co_await (move_only_0() || move_only_1()); + ASIO_CHECK(mm.index() == 0); + ASIO_CHECK(std::get<0>(mm).value == 0); + + mm = co_await (move_only_ex() || move_only_1()); + ASIO_CHECK(mm.index() == 1); + ASIO_CHECK(std::get<1>(mm).value == 1); + + std::variant<move_only, move_only, move_only> mmm = + co_await (move_only_0() || move_only_1() || move_only_2()); + ASIO_CHECK(mmm.index() == 0); + ASIO_CHECK(std::get<0>(mmm).value == 0); + + mmm = co_await (move_only_ex() || move_only_1() || move_only_2()); + ASIO_CHECK(mmm.index() == 1); + ASIO_CHECK(std::get<1>(mmm).value == 1); + + mmm = co_await (move_only_ex() || move_only_ex() || move_only_2()); + ASIO_CHECK(mmm.index() == 2); + ASIO_CHECK(std::get<2>(mmm).value == 2); +} + +void test_or_awaitable_operator() +{ + asio::io_context ctx; + co_spawn(ctx, do_test_or_awaitable_operator(), asio::detached); + ctx.run(); +} + +ASIO_TEST_SUITE +( + "experimental/awaitable_operators", + ASIO_TEST_CASE(test_and_awaitable_operator) + ASIO_TEST_CASE(test_or_awaitable_operator) +) diff --git a/3rdparty/asio/src/tests/unit/posix/stream_descriptor_service.cpp b/3rdparty/asio/src/tests/unit/experimental/basic_channel.cpp index be2e60e7ca3..a277efeb27c 100644 --- a/3rdparty/asio/src/tests/unit/posix/stream_descriptor_service.cpp +++ b/3rdparty/asio/src/tests/unit/experimental/basic_channel.cpp @@ -1,8 +1,8 @@ // -// stream_descriptor_service.cpp -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// experimental/basic_channel.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -14,12 +14,12 @@ #endif // !defined(BOOST_ALL_NO_LIB) // Test that header file is self-contained. -#include "asio/posix/stream_descriptor_service.hpp" +#include "asio/experimental/basic_channel.hpp" #include "../unit_test.hpp" ASIO_TEST_SUITE ( - "posix/stream_descriptor_service", + "experimental/basic_channel", ASIO_TEST_CASE(null_test) ) diff --git a/3rdparty/asio/src/tests/unit/experimental/basic_concurrent_channel.cpp b/3rdparty/asio/src/tests/unit/experimental/basic_concurrent_channel.cpp new file mode 100644 index 00000000000..413d1870bd9 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/experimental/basic_concurrent_channel.cpp @@ -0,0 +1,25 @@ +// +// experimental/basic_concurrent_channel.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/experimental/basic_concurrent_channel.hpp" + +#include "../unit_test.hpp" + +ASIO_TEST_SUITE +( + "experimental/basic_concurrent_channel", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/experimental/channel.cpp b/3rdparty/asio/src/tests/unit/experimental/channel.cpp new file mode 100644 index 00000000000..6c5b67fe570 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/experimental/channel.cpp @@ -0,0 +1,888 @@ +// +// experimental/channel.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/experimental/channel.hpp" + +#include <utility> +#include "asio/any_completion_handler.hpp" +#include "asio/bind_executor.hpp" +#include "asio/bind_immediate_executor.hpp" +#include "asio/error.hpp" +#include "asio/io_context.hpp" +#include "asio/system_executor.hpp" +#include "../unit_test.hpp" + +using namespace asio; +using namespace asio::experimental; + +void unbuffered_channel_test() +{ + io_context ctx; + + channel<void(asio::error_code, std::string)> ch1(ctx); + + ASIO_CHECK(ch1.is_open()); + ASIO_CHECK(!ch1.ready()); + + bool b1 = ch1.try_send(asio::error::eof, "hello"); + + ASIO_CHECK(!b1); + + std::string s1 = "abcdefghijklmnopqrstuvwxyz"; + bool b2 = ch1.try_send(asio::error::eof, std::move(s1)); + + ASIO_CHECK(!b2); + ASIO_CHECK(!s1.empty()); + + asio::error_code ec1; + std::string s2; + ch1.async_receive( + [&](asio::error_code ec, std::string s) + { + ec1 = ec; + s2 = std::move(s); + }); + + bool b3 = ch1.try_send(asio::error::eof, std::move(s1)); + + ASIO_CHECK(b3); + ASIO_CHECK(s1.empty()); + + ctx.run(); + + ASIO_CHECK(ec1 == asio::error::eof); + ASIO_CHECK(s2 == "abcdefghijklmnopqrstuvwxyz"); + + bool b4 = ch1.try_receive([](asio::error_code, std::string){}); + + ASIO_CHECK(!b4); + + asio::error_code ec2 = asio::error::would_block; + std::string s3 = "zyxwvutsrqponmlkjihgfedcba"; + ch1.async_send(asio::error::eof, std::move(s3), + [&](asio::error_code ec) + { + ec2 = ec; + }); + + asio::error_code ec3; + std::string s4; + bool b5 = ch1.try_receive( + [&](asio::error_code ec, std::string s) + { + ec3 = ec; + s4 = s; + }); + + ASIO_CHECK(b5); + ASIO_CHECK(ec3 == asio::error::eof); + ASIO_CHECK(s4 == "zyxwvutsrqponmlkjihgfedcba"); + + ctx.restart(); + ctx.run(); + + ASIO_CHECK(!ec2); +} + +void buffered_channel_test() +{ + io_context ctx; + + channel<void(asio::error_code, std::string)> ch1(ctx, 1); + + ASIO_CHECK(ch1.is_open()); + ASIO_CHECK(!ch1.ready()); + + bool b1 = ch1.try_send(asio::error::eof, "hello"); + + ASIO_CHECK(b1); + + std::string s1 = "abcdefghijklmnopqrstuvwxyz"; + bool b2 = ch1.try_send(asio::error::eof, std::move(s1)); + + ASIO_CHECK(!b2); + ASIO_CHECK(!s1.empty()); + + asio::error_code ec1; + std::string s2; + ch1.async_receive( + [&](asio::error_code ec, std::string s) + { + ec1 = ec; + s2 = std::move(s); + }); + + ctx.run(); + + ASIO_CHECK(ec1 == asio::error::eof); + ASIO_CHECK(s2 == "hello"); + + bool b4 = ch1.try_receive([](asio::error_code, std::string){}); + + ASIO_CHECK(!b4); + + asio::error_code ec2 = asio::error::would_block; + std::string s3 = "zyxwvutsrqponmlkjihgfedcba"; + ch1.async_send(asio::error::eof, std::move(s3), + [&](asio::error_code ec) + { + ec2 = ec; + }); + + asio::error_code ec3; + std::string s4; + bool b5 = ch1.try_receive( + [&](asio::error_code ec, std::string s) + { + ec3 = ec; + s4 = s; + }); + + ASIO_CHECK(b5); + ASIO_CHECK(ec3 == asio::error::eof); + ASIO_CHECK(s4 == "zyxwvutsrqponmlkjihgfedcba"); + + ctx.restart(); + ctx.run(); + + ASIO_CHECK(!ec2); + + bool b6 = ch1.try_send(asio::error_code(), "goodbye"); + + ASIO_CHECK(b6); + + ch1.close(); + + asio::error_code ec4; + std::string s5; + ch1.async_receive( + [&](asio::error_code ec, std::string s) + { + ec4 = ec; + s5 = std::move(s); + }); + + ctx.restart(); + ctx.run(); + + ASIO_CHECK(!ec4); + ASIO_CHECK(s5 == "goodbye"); + + asio::error_code ec5; + std::string s6; + ch1.async_receive( + [&](asio::error_code ec, std::string s) + { + ec5 = ec; + s6 = std::move(s); + }); + + ctx.restart(); + ctx.run(); + + ASIO_CHECK(ec5 == asio::experimental::channel_errc::channel_closed); + ASIO_CHECK(s6.empty()); +} + +void buffered_error_channel_test() +{ + io_context ctx; + + channel<void(asio::error_code)> ch1(ctx, 1); + + ASIO_CHECK(ch1.is_open()); + ASIO_CHECK(!ch1.ready()); + + bool b1 = ch1.try_send(asio::error::eof); + + ASIO_CHECK(b1); + + bool b2 = ch1.try_send(asio::error::eof); + + ASIO_CHECK(!b2); + + asio::error_code ec1; + ch1.async_receive( + [&](asio::error_code ec) + { + ec1 = ec; + }); + + ctx.run(); + + ASIO_CHECK(ec1 == asio::error::eof); + + bool b4 = ch1.try_receive([](asio::error_code){}); + + ASIO_CHECK(!b4); + + asio::error_code ec2 = asio::error::would_block; + ch1.async_send(asio::error::eof, + [&](asio::error_code ec) + { + ec2 = ec; + }); + + asio::error_code ec3; + bool b5 = ch1.try_receive( + [&](asio::error_code ec) + { + ec3 = ec; + }); + + ASIO_CHECK(b5); + ASIO_CHECK(ec3 == asio::error::eof); + + ctx.restart(); + ctx.run(); + + ASIO_CHECK(!ec2); +} + +void unbuffered_non_immediate_receive() +{ + io_context ctx; + + channel<void(asio::error_code, std::string)> ch1(ctx); + + asio::error_code ec1 = asio::error::would_block; + std::string s1 = "0123456789"; + ch1.async_send(asio::error::eof, std::move(s1), + [&](asio::error_code ec) + { + ec1 = ec; + }); + + ASIO_CHECK(ec1 == asio::error::would_block); + + asio::error_code ec2 = asio::error::would_block; + std::string s2; + ch1.async_receive( + [&](asio::error_code ec, std::string s) + { + ec2 = ec; + s2 = std::move(s); + }); + + ASIO_CHECK(ec2 == asio::error::would_block); + + ctx.run(); + + ASIO_CHECK(!ec1); + ASIO_CHECK(ec2 == asio::error::eof); + ASIO_CHECK(s2 == "0123456789"); +} + +void unbuffered_immediate_receive() +{ + io_context ctx; + + channel<void(asio::error_code, std::string)> ch1(ctx); + + asio::error_code ec1 = asio::error::would_block; + std::string s1 = "0123456789"; + ch1.async_send(asio::error::eof, std::move(s1), + [&](asio::error_code ec) + { + ec1 = ec; + }); + + ASIO_CHECK(ec1 == asio::error::would_block); + + asio::error_code ec2 = asio::error::would_block; + std::string s2; + ch1.async_receive( + bind_immediate_executor(system_executor(), + [&](asio::error_code ec, std::string s) + { + ec2 = ec; + s2 = std::move(s); + })); + + ASIO_CHECK(ec1 == asio::error::would_block); + ASIO_CHECK(ec2 == asio::error::eof); + ASIO_CHECK(s2 == "0123456789"); + + ctx.run(); + + ASIO_CHECK(!ec1); +} + +void unbuffered_executor_receive() +{ + io_context ctx; + io_context ctx2; + + channel<void(asio::error_code, std::string)> ch1(ctx); + + asio::error_code ec1 = asio::error::would_block; + std::string s1 = "0123456789"; + ch1.async_send(asio::error::eof, std::move(s1), + [&](asio::error_code ec) + { + ec1 = ec; + }); + + ASIO_CHECK(ec1 == asio::error::would_block); + + asio::error_code ec2 = asio::error::would_block; + std::string s2; + ch1.async_receive( + bind_executor(ctx2, + [&](asio::error_code ec, std::string s) + { + ec2 = ec; + s2 = std::move(s); + })); + + ASIO_CHECK(ec1 == asio::error::would_block); + ASIO_CHECK(ec2 == asio::error::would_block); + + ctx.run(); + + ASIO_CHECK(!ec1); + ASIO_CHECK(ec2 == asio::error::would_block); + + ctx2.run(); + + ASIO_CHECK(ec2 == asio::error::eof); + ASIO_CHECK(s2 == "0123456789"); +} + +void unbuffered_non_immediate_send() +{ + io_context ctx; + + channel<void(asio::error_code, std::string)> ch1(ctx); + + asio::error_code ec1 = asio::error::would_block; + std::string s1; + ch1.async_receive( + [&](asio::error_code ec, std::string s) + { + ec1 = ec; + s1 = std::move(s); + }); + + ASIO_CHECK(ec1 == asio::error::would_block); + + asio::error_code ec2 = asio::error::would_block; + std::string s2 = "0123456789"; + ch1.async_send(asio::error::eof, std::move(s2), + [&](asio::error_code ec) + { + ec2 = ec; + }); + + ASIO_CHECK(ec2 == asio::error::would_block); + + ctx.run(); + + ASIO_CHECK(ec1 == asio::error::eof); + ASIO_CHECK(s1 == "0123456789"); + ASIO_CHECK(!ec2); +} + +void unbuffered_immediate_send() +{ + io_context ctx; + + channel<void(asio::error_code, std::string)> ch1(ctx); + + asio::error_code ec1 = asio::error::would_block; + std::string s1; + ch1.async_receive( + [&](asio::error_code ec, std::string s) + { + ec1 = ec; + s1 = std::move(s); + }); + + ASIO_CHECK(ec1 == asio::error::would_block); + + asio::error_code ec2 = asio::error::would_block; + std::string s2 = "0123456789"; + ch1.async_send(asio::error::eof, std::move(s2), + bind_immediate_executor(system_executor(), + [&](asio::error_code ec) + { + ec2 = ec; + })); + + ASIO_CHECK(ec1 == asio::error::would_block); + ASIO_CHECK(!ec2); + + ctx.run(); + + ASIO_CHECK(ec1 == asio::error::eof); + ASIO_CHECK(s1 == "0123456789"); +} + +void unbuffered_executor_send() +{ + io_context ctx; + io_context ctx2; + + channel<void(asio::error_code, std::string)> ch1(ctx); + + asio::error_code ec1 = asio::error::would_block; + std::string s1; + ch1.async_receive( + [&](asio::error_code ec, std::string s) + { + ec1 = ec; + s1 = std::move(s); + }); + + ASIO_CHECK(ec1 == asio::error::would_block); + + asio::error_code ec2 = asio::error::would_block; + std::string s2 = "0123456789"; + ch1.async_send(asio::error::eof, std::move(s2), + bind_executor(ctx2, + [&](asio::error_code ec) + { + ec2 = ec; + })); + + ASIO_CHECK(ec1 == asio::error::would_block); + ASIO_CHECK(ec2 == asio::error::would_block); + + ctx.run(); + + ASIO_CHECK(ec1 == asio::error::eof); + ASIO_CHECK(s1 == "0123456789"); + ASIO_CHECK(ec2 == asio::error::would_block); + + ctx2.run(); + + ASIO_CHECK(!ec2); +} + +void buffered_non_immediate_receive() +{ + io_context ctx; + + channel<void(asio::error_code, std::string)> ch1(ctx, 1); + + asio::error_code ec1 = asio::error::would_block; + std::string s1 = "0123456789"; + ch1.async_send(asio::error::eof, std::move(s1), + [&](asio::error_code ec) + { + ec1 = ec; + }); + + ASIO_CHECK(ec1 == asio::error::would_block); + + ctx.run(); + + ASIO_CHECK(!ec1); + + asio::error_code ec2 = asio::error::would_block; + std::string s2; + ch1.async_receive( + [&](asio::error_code ec, std::string s) + { + ec2 = ec; + s2 = std::move(s); + }); + + ASIO_CHECK(ec2 == asio::error::would_block); + + ctx.restart(); + ctx.run(); + + ASIO_CHECK(ec2 == asio::error::eof); + ASIO_CHECK(s2 == "0123456789"); +} + +void buffered_immediate_receive() +{ + io_context ctx; + + channel<void(asio::error_code, std::string)> ch1(ctx, 1); + + asio::error_code ec1 = asio::error::would_block; + std::string s1 = "0123456789"; + ch1.async_send(asio::error::eof, std::move(s1), + [&](asio::error_code ec) + { + ec1 = ec; + }); + + ASIO_CHECK(ec1 == asio::error::would_block); + + ctx.run(); + + ASIO_CHECK(!ec1); + + asio::error_code ec2 = asio::error::would_block; + std::string s2; + ch1.async_receive( + bind_immediate_executor(system_executor(), + [&](asio::error_code ec, std::string s) + { + ec2 = ec; + s2 = std::move(s); + })); + + ASIO_CHECK(ec2 == asio::error::eof); + ASIO_CHECK(s2 == "0123456789"); + + ctx.restart(); + ctx.run(); +} + +void buffered_executor_receive() +{ + io_context ctx; + io_context ctx2; + + channel<void(asio::error_code, std::string)> ch1(ctx, 1); + + asio::error_code ec1 = asio::error::would_block; + std::string s1 = "0123456789"; + ch1.async_send(asio::error::eof, std::move(s1), + [&](asio::error_code ec) + { + ec1 = ec; + }); + + ASIO_CHECK(ec1 == asio::error::would_block); + + ctx.run(); + + ASIO_CHECK(!ec1); + + asio::error_code ec2 = asio::error::would_block; + std::string s2; + ch1.async_receive( + bind_executor(ctx2, + [&](asio::error_code ec, std::string s) + { + ec2 = ec; + s2 = std::move(s); + })); + + ASIO_CHECK(ec2 == asio::error::would_block); + + ctx.restart(); + ctx.run(); + + ASIO_CHECK(ec2 == asio::error::would_block); + + ctx2.run(); + + ASIO_CHECK(ec2 == asio::error::eof); + ASIO_CHECK(s2 == "0123456789"); +} + +void buffered_non_immediate_send() +{ + io_context ctx; + + channel<void(asio::error_code, std::string)> ch1(ctx, 1); + + asio::error_code ec1 = asio::error::would_block; + std::string s1 = "0123456789"; + ch1.async_send(asio::error::eof, std::move(s1), + [&](asio::error_code ec) + { + ec1 = ec; + }); + + ASIO_CHECK(ec1 == asio::error::would_block); + + ctx.run(); + + ASIO_CHECK(!ec1); +} + +void buffered_immediate_send() +{ + io_context ctx; + + channel<void(asio::error_code, std::string)> ch1(ctx, 1); + + asio::error_code ec1 = asio::error::would_block; + std::string s1 = "0123456789"; + ch1.async_send(asio::error::eof, std::move(s1), + bind_immediate_executor(system_executor(), + [&](asio::error_code ec) + { + ec1 = ec; + })); + + ASIO_CHECK(!ec1); + + ctx.run(); +} + +void buffered_executor_send() +{ + io_context ctx; + io_context ctx2; + + channel<void(asio::error_code, std::string)> ch1(ctx, 1); + + asio::error_code ec1 = asio::error::would_block; + std::string s1 = "0123456789"; + ch1.async_send(asio::error::eof, std::move(s1), + bind_executor(ctx2, + [&](asio::error_code ec) + { + ec1 = ec; + })); + + ASIO_CHECK(ec1 == asio::error::would_block); + + ctx.run(); + + ASIO_CHECK(ec1 == asio::error::would_block); + + ctx2.run(); + + ASIO_CHECK(!ec1); +} + +void try_send_via_dispatch() +{ + io_context ctx; + + channel<void(asio::error_code, std::string)> ch1(ctx); + + asio::error_code ec1 = asio::error::would_block; + std::string s1; + ch1.async_receive( + bind_executor(asio::system_executor(), + [&](asio::error_code ec, std::string s) + { + ec1 = ec; + s1 = std::move(s); + })); + + ASIO_CHECK(ec1 == asio::error::would_block); + + ctx.poll(); + + ASIO_CHECK(ec1 == asio::error::would_block); + + std::string s2 = "0123456789"; + ch1.try_send_via_dispatch(asio::error::eof, std::move(s2)); + + ASIO_CHECK(ec1 == asio::error::eof); + ASIO_CHECK(s1 == "0123456789"); + ASIO_CHECK(s2.empty()); +} + +void try_send_n_via_dispatch() +{ + io_context ctx; + + channel<void(asio::error_code, std::string)> ch1(ctx); + + asio::error_code ec1 = asio::error::would_block; + std::string s1; + ch1.async_receive( + bind_executor(asio::system_executor(), + [&](asio::error_code ec, std::string s) + { + ec1 = ec; + s1 = std::move(s); + })); + + ASIO_CHECK(ec1 == asio::error::would_block); + + asio::error_code ec2 = asio::error::would_block; + std::string s2; + ch1.async_receive( + bind_executor(asio::system_executor(), + [&](asio::error_code ec, std::string s) + { + ec2 = ec; + s2 = std::move(s); + })); + + ASIO_CHECK(ec1 == asio::error::would_block); + + ctx.poll(); + + ASIO_CHECK(ec1 == asio::error::would_block); + ASIO_CHECK(ec2 == asio::error::would_block); + + std::string s3 = "0123456789"; + ch1.try_send_n_via_dispatch(2, asio::error::eof, std::move(s3)); + + ASIO_CHECK(ec1 == asio::error::eof); + ASIO_CHECK(s1 == "0123456789"); + ASIO_CHECK(ec2 == asio::error::eof); + ASIO_CHECK(s2 == "0123456789"); + ASIO_CHECK(s3.empty()); +} + +struct multi_signature_handler +{ + std::string* s_; + asio::error_code* ec_; + + void operator()(std::string s) + { + *s_ = s; + } + + void operator()(asio::error_code ec) + { + *ec_ = ec; + } +}; + +void implicit_error_signature_channel_test() +{ + io_context ctx; + + channel<void(std::string)> ch1(ctx); + + ASIO_CHECK(ch1.is_open()); + ASIO_CHECK(!ch1.ready()); + + bool b1 = ch1.try_send("hello"); + + ASIO_CHECK(!b1); + + std::string s1 = "abcdefghijklmnopqrstuvwxyz"; + bool b2 = ch1.try_send(std::move(s1)); + + ASIO_CHECK(!b2); + ASIO_CHECK(!s1.empty()); + + std::string s2; + asio::error_code ec1 = asio::error::would_block; + multi_signature_handler h1 = {&s2, &ec1}; + ch1.async_receive(h1); + + bool b3 = ch1.try_send(std::move(s1)); + + ASIO_CHECK(b3); + ASIO_CHECK(s1.empty()); + + ctx.run(); + + ASIO_CHECK(s2 == "abcdefghijklmnopqrstuvwxyz"); + ASIO_CHECK(ec1 == asio::error::would_block); + + std::string s3; + asio::error_code ec2; + multi_signature_handler h2 = {&s3, &ec2}; + bool b4 = ch1.try_receive(h2); + + ASIO_CHECK(!b4); + + std::string s4 = "zyxwvutsrqponmlkjihgfedcba"; + asio::error_code ec3; + ch1.async_send(std::move(s4), + [&](asio::error_code ec) + { + ec3 = ec; + }); + + std::string s5; + asio::error_code ec4 = asio::error::would_block; + multi_signature_handler h3 = {&s5, &ec4}; + bool b5 = ch1.try_receive(h3); + + ASIO_CHECK(b5); + ASIO_CHECK(ec4 == asio::error::would_block); + ASIO_CHECK(s5 == "zyxwvutsrqponmlkjihgfedcba"); + + ctx.restart(); + ctx.run(); + + ASIO_CHECK(!ec3); + + std::string s6; + asio::error_code ec5 = asio::error::would_block; + multi_signature_handler h4 = {&s6, &ec5}; + ch1.async_receive(h4); + + ch1.close(); + + ctx.restart(); + ctx.run(); + + ASIO_CHECK(s6.empty()); + ASIO_CHECK(ec5 == asio::experimental::channel_errc::channel_closed); +} + +void channel_with_any_completion_handler_test() +{ + io_context ctx; + + channel<void(asio::error_code, std::string)> ch1(ctx); + + asio::error_code ec1 = asio::error::would_block; + std::string s1; + ch1.async_receive( + asio::any_completion_handler< + void(asio::error_code, std::string)>( + [&](asio::error_code ec, std::string s) + { + ec1 = ec; + s1 = std::move(s); + })); + + asio::error_code ec2 = asio::error::would_block; + std::string s2 = "zyxwvutsrqponmlkjihgfedcba"; + ch1.async_send(asio::error::eof, std::move(s2), + asio::any_completion_handler<void(asio::error_code)>( + [&](asio::error_code ec) + { + ec2 = ec; + })); + + ASIO_CHECK(ec1 == asio::error::would_block); + ASIO_CHECK(ec2 == asio::error::would_block); + + ctx.run(); + + ASIO_CHECK(ec1 == asio::error::eof); + ASIO_CHECK(s1 == "zyxwvutsrqponmlkjihgfedcba"); + ASIO_CHECK(!ec2); +} + +ASIO_TEST_SUITE +( + "experimental/channel", + ASIO_TEST_CASE(unbuffered_channel_test) + ASIO_TEST_CASE(buffered_channel_test) + ASIO_TEST_CASE(buffered_error_channel_test) + ASIO_TEST_CASE(unbuffered_non_immediate_receive) + ASIO_TEST_CASE(unbuffered_immediate_receive) + ASIO_TEST_CASE(unbuffered_executor_receive) + ASIO_TEST_CASE(unbuffered_non_immediate_send) + ASIO_TEST_CASE(unbuffered_immediate_send) + ASIO_TEST_CASE(unbuffered_executor_send) + ASIO_TEST_CASE(buffered_non_immediate_receive) + ASIO_TEST_CASE(buffered_immediate_receive) + ASIO_TEST_CASE(buffered_executor_receive) + ASIO_TEST_CASE(buffered_non_immediate_send) + ASIO_TEST_CASE(buffered_immediate_send) + ASIO_TEST_CASE(buffered_executor_send) + ASIO_TEST_CASE(try_send_via_dispatch) + ASIO_TEST_CASE(try_send_n_via_dispatch) + ASIO_TEST_CASE(implicit_error_signature_channel_test) + ASIO_TEST_CASE(channel_with_any_completion_handler_test) +) diff --git a/3rdparty/asio/src/tests/unit/windows/object_handle_service.cpp b/3rdparty/asio/src/tests/unit/experimental/channel_traits.cpp index 56ff1c3bde9..b1c326f874d 100644 --- a/3rdparty/asio/src/tests/unit/windows/object_handle_service.cpp +++ b/3rdparty/asio/src/tests/unit/experimental/channel_traits.cpp @@ -1,8 +1,8 @@ // -// object_handle_service.cpp -// ~~~~~~~~~~~~~~~~~~~~~~~~~ +// experimental/channel_traits.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -14,13 +14,12 @@ #endif // !defined(BOOST_ALL_NO_LIB) // Test that header file is self-contained. -#include "asio/windows/object_handle_service.hpp" +#include "asio/experimental/channel_traits.hpp" -#include "asio.hpp" #include "../unit_test.hpp" ASIO_TEST_SUITE ( - "windows/object_handle_service", + "experimental/channel_traits", ASIO_TEST_CASE(null_test) ) diff --git a/3rdparty/asio/src/tests/unit/experimental/co_composed.cpp b/3rdparty/asio/src/tests/unit/experimental/co_composed.cpp new file mode 100644 index 00000000000..755cd46d788 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/experimental/co_composed.cpp @@ -0,0 +1,518 @@ +// +// experimental/co_composed.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Prevent link dependency on the Boost.System library. +#if !defined(BOOST_SYSTEM_NO_DEPRECATED) +#define BOOST_SYSTEM_NO_DEPRECATED +#endif // !defined(BOOST_SYSTEM_NO_DEPRECATED) + +// Test that header file is self-contained. +#include "asio/experimental/co_composed.hpp" + +#include "asio/bind_cancellation_slot.hpp" +#include "asio/deferred.hpp" +#include "asio/detached.hpp" +#include "asio/io_context.hpp" +#include "asio/post.hpp" +#include "../unit_test.hpp" + +template <typename CompletionToken> +auto async_throw(CompletionToken&& token) +{ + return asio::async_initiate<CompletionToken, void()>( + [](auto) { throw 42; }, token); +} + +template <typename CompletionToken> +auto throw_first(CompletionToken&& token) +{ + return asio::async_initiate<CompletionToken, void()>( + asio::experimental::co_composed( + [](auto state) -> void + { + throw 42; + co_yield state.complete(); + }), token); +} + +void test_throw_first() +{ + try + { + throw_first(asio::detached); + ASIO_CHECK(0); + } + catch (int) + { + } +} + +template <typename CompletionToken> +auto throw_after_await(asio::io_context& ctx, CompletionToken&& token) +{ + return asio::async_initiate<CompletionToken, void()>( + asio::experimental::co_composed( + [](auto state, asio::io_context& ctx) -> void + { + co_await asio::post(ctx, asio::deferred); + throw 42; + co_yield state.complete(); + }), token, std::ref(ctx)); +} + +void test_throw_after_await() +{ + try + { + asio::io_context ctx(1); + throw_after_await(ctx, asio::detached); + ctx.run(); + ASIO_CHECK(0); + } + catch (int) + { + } +} + +template <typename CompletionToken> +auto throw_in_first_suspend(CompletionToken&& token) +{ + return asio::async_initiate<CompletionToken, void()>( + asio::experimental::co_composed( + [](auto state) -> void + { + co_await async_throw(asio::deferred); + co_yield state.complete(); + }), token); +} + +void test_throw_in_first_suspend() +{ + try + { + throw_in_first_suspend(asio::detached); + ASIO_CHECK(0); + } + catch (int) + { + } +} + +template <typename CompletionToken> +auto throw_in_suspend_after_await( + asio::io_context& ctx, CompletionToken&& token) +{ + return asio::async_initiate<CompletionToken, void()>( + asio::experimental::co_composed( + [](auto state, asio::io_context& ctx) -> void + { + co_await asio::post(ctx, asio::deferred); + co_await async_throw(asio::deferred); + co_yield state.complete(); + }), token, std::ref(ctx)); +} + +void test_throw_in_suspend_after_await() +{ + try + { + asio::io_context ctx(1); + throw_in_suspend_after_await(ctx, asio::detached); + ctx.run(); + ASIO_CHECK(0); + } + catch (int) + { + } +} + +template <typename CompletionToken> +auto post_loop(asio::io_context& ctx, CompletionToken&& token) +{ + return asio::async_initiate<CompletionToken, void(int)>( + asio::experimental::co_composed( + [](auto state, asio::io_context& ctx) -> void + { + int i = 0; + for (; i < 100; ++i) + co_await asio::post(ctx, asio::deferred); + co_yield state.complete(i); + }, ctx), token, std::ref(ctx)); +} + +void test_post_loop() +{ + asio::io_context ctx(1); + int count = 0; + post_loop(ctx, [&](int i){ count = i; }); + ctx.run(); + ASIO_CHECK(count == 100); +} + +template <typename CompletionToken> +auto nested_post(asio::io_context& ctx, CompletionToken&& token) +{ + return asio::async_initiate<CompletionToken, void()>( + asio::experimental::co_composed( + [](auto state, asio::io_context& ctx) -> void + { + co_await asio::post(ctx, asio::deferred); + co_yield state.complete(); + }, ctx), token, std::ref(ctx)); +} + +template <typename CompletionToken> +auto nested_post_loop(asio::io_context& ctx, CompletionToken&& token) +{ + return asio::async_initiate<CompletionToken, void(int)>( + asio::experimental::co_composed( + [](auto state, asio::io_context& ctx) -> void + { + int i = 0; + for (; i < 100; ++i) + co_await nested_post(ctx, asio::deferred); + co_yield state.complete(i); + }, ctx), token, std::ref(ctx)); +} + +void test_nested_post_loop() +{ + asio::io_context ctx(1); + int count = 0; + nested_post_loop(ctx, [&](int i){ count = i; }); + ctx.run(); + ASIO_CHECK(count == 100); +} + +template <typename CompletionToken> +auto post_loop_return_1_0(asio::io_context& ctx, CompletionToken&& token) +{ + return asio::async_initiate<CompletionToken, void()>( + asio::experimental::co_composed<void()>( + [](auto, asio::io_context& ctx) -> void + { + int i = 0; + for (; i < 100; ++i) + co_await asio::post(ctx, asio::deferred); + co_return {}; + }, ctx), token, std::ref(ctx)); +} + +void test_post_loop_return_1_0() +{ + asio::io_context ctx(1); + bool done = false; + post_loop_return_1_0(ctx, [&]{ done = true; }); + ctx.run(); + ASIO_CHECK(done); +} + +template <typename CompletionToken> +auto post_loop_return_1_1(asio::io_context& ctx, CompletionToken&& token) +{ + return asio::async_initiate<CompletionToken, void(int)>( + asio::experimental::co_composed<void(int)>( + [](auto, asio::io_context& ctx) -> void + { + int i = 0; + for (; i < 100; ++i) + co_await asio::post(ctx, asio::deferred); + co_return {i}; + }, ctx), token, std::ref(ctx)); +} + +void test_post_loop_return_1_1() +{ + asio::io_context ctx(1); + int count = 0; + post_loop_return_1_1(ctx, [&](int i){ count = i; }); + ctx.run(); + ASIO_CHECK(count == 100); +} + +template <typename CompletionToken> +auto post_loop_return_1_2(asio::io_context& ctx, CompletionToken&& token) +{ + return asio::async_initiate<CompletionToken, void(int, char)>( + asio::experimental::co_composed<void(int, char)>( + [](auto, asio::io_context& ctx) -> void + { + int i = 0; + for (; i < 100; ++i) + co_await asio::post(ctx, asio::deferred); + co_return {i, 'A'}; + }, ctx), token, std::ref(ctx)); +} + +void test_post_loop_return_1_2() +{ + asio::io_context ctx(1); + int count = 0; + char ch = 0; + post_loop_return_1_2(ctx, [&](int i, char c){ count = i, ch = c; }); + ctx.run(); + ASIO_CHECK(count == 100); + ASIO_CHECK(ch == 'A'); +} + +template <typename CompletionToken> +auto post_loop_return_2(asio::io_context& ctx, CompletionToken&& token) +{ + return asio::async_initiate<CompletionToken, void(), void(int)>( + asio::experimental::co_composed<void(), void(int)>( + [](auto, asio::io_context& ctx) -> void + { + int i = 0; + for (; i < 100; ++i) + co_await asio::post(ctx, asio::deferred); + co_return {i}; + }, ctx), token, std::ref(ctx)); +} + +void test_post_loop_return_2() +{ + asio::io_context ctx(1); + int count = 0; + post_loop_return_2(ctx, [&](int i = 0){ count = i; }); + ctx.run(); + ASIO_CHECK(count == 100); +} + +template <typename CompletionToken> +auto complete_on_cancel(asio::io_context& ctx, CompletionToken&& token) +{ + return asio::async_initiate< + CompletionToken, void(asio::error_code, int)>( + asio::experimental::co_composed< + void(asio::error_code, int)>( + [](auto state, asio::io_context& ctx) -> void + { + state.on_cancellation_complete_with( + asio::error::invalid_argument, 42); + int i = 0; + for (; i < 100; ++i) + co_await asio::post(ctx, asio::deferred); + co_return {asio::error::eof, i}; + }, ctx), token, std::ref(ctx)); +} + +void test_complete_on_cancel() +{ + asio::io_context ctx(1); + int count = 0; + asio::error_code ec; + asio::cancellation_signal cancel; + + complete_on_cancel(ctx, + [&](asio::error_code e, int i) + { + ec = e; + count = i; + }); + + ctx.run(); + + ASIO_CHECK(ec == asio::error::eof); + ASIO_CHECK(count == 100); + + complete_on_cancel(ctx, + asio::bind_cancellation_slot(cancel.slot(), + [&](asio::error_code e, int i) + { + ec = e; + count = i; + })); + + ctx.restart(); + ctx.run_one(); + cancel.emit(asio::cancellation_type::all); + ctx.run(); + + ASIO_CHECK(ec == asio::error::invalid_argument); + ASIO_CHECK(count == 42); + + complete_on_cancel(ctx, + asio::bind_cancellation_slot(cancel.slot(), + [&](asio::error_code e, int i) + { + ec = e; + count = i; + })); + + ctx.restart(); + ctx.run(); + + ASIO_CHECK(ec == asio::error::eof); + ASIO_CHECK(count == 100); +} + +template <typename CompletionToken> +auto complete_with_default_on_cancel( + asio::io_context& ctx, CompletionToken&& token) +{ + return asio::async_initiate< + CompletionToken, void(asio::error_code, int)>( + asio::experimental::co_composed< + void(asio::error_code, int)>( + [](auto, asio::io_context& ctx) -> void + { + int i = 0; + for (; i < 100; ++i) + co_await asio::post(ctx, asio::deferred); + co_return {asio::error::eof, i}; + }, ctx), token, std::ref(ctx)); +} + +void test_complete_with_default_on_cancel() +{ + asio::io_context ctx(1); + int count = 0; + asio::error_code ec; + asio::cancellation_signal cancel; + + complete_with_default_on_cancel(ctx, + [&](asio::error_code e, int i) + { + ec = e; + count = i; + }); + + ctx.run(); + + ASIO_CHECK(ec == asio::error::eof); + ASIO_CHECK(count == 100); + + complete_with_default_on_cancel(ctx, + asio::bind_cancellation_slot(cancel.slot(), + [&](asio::error_code e, int i) + { + ec = e; + count = i; + })); + + ctx.restart(); + ctx.run_one(); + cancel.emit(asio::cancellation_type::all); + ctx.run(); + + ASIO_CHECK(ec == asio::error::operation_aborted); + ASIO_CHECK(count == 0); + + complete_with_default_on_cancel(ctx, + asio::bind_cancellation_slot(cancel.slot(), + [&](asio::error_code e, int i) + { + ec = e; + count = i; + })); + + ctx.restart(); + ctx.run(); + + ASIO_CHECK(ec == asio::error::eof); + ASIO_CHECK(count == 100); +} + +template <typename CompletionToken> +auto throw_on_cancel(asio::io_context& ctx, CompletionToken&& token) +{ + return asio::async_initiate< + CompletionToken, void(asio::error_code, int)>( + asio::experimental::co_composed< + void(asio::error_code, int)>( + [](auto state, asio::io_context& ctx) -> void + { + try + { + state.throw_if_cancelled(true); + int i = 0; + for (; i < 100; ++i) + co_await asio::post(ctx, asio::deferred); + co_return {asio::error::eof, i}; + } + catch (...) + { + co_return {asio::error::invalid_argument, 42}; + } + }, ctx), token, std::ref(ctx)); +} + +void test_throw_on_cancel() +{ + asio::io_context ctx(1); + int count = 0; + asio::error_code ec; + asio::cancellation_signal cancel; + + throw_on_cancel(ctx, + [&](asio::error_code e, int i) + { + ec = e; + count = i; + }); + + ctx.run(); + + ASIO_CHECK(ec == asio::error::eof); + ASIO_CHECK(count == 100); + + throw_on_cancel(ctx, + asio::bind_cancellation_slot(cancel.slot(), + [&](asio::error_code e, int i) + { + ec = e; + count = i; + })); + + ctx.restart(); + ctx.run_one(); + cancel.emit(asio::cancellation_type::all); + ctx.run(); + + ASIO_CHECK(ec == asio::error::invalid_argument); + ASIO_CHECK(count == 42); + + throw_on_cancel(ctx, + asio::bind_cancellation_slot(cancel.slot(), + [&](asio::error_code e, int i) + { + ec = e; + count = i; + })); + + ctx.restart(); + ctx.run(); + + ASIO_CHECK(ec == asio::error::eof); + ASIO_CHECK(count == 100); +} + +ASIO_TEST_SUITE +( + "experimental/co_composed", + ASIO_TEST_CASE(test_throw_first) + ASIO_TEST_CASE(test_throw_after_await) + ASIO_TEST_CASE(test_throw_in_first_suspend) + ASIO_TEST_CASE(test_throw_in_suspend_after_await) + ASIO_TEST_CASE(test_post_loop) + ASIO_TEST_CASE(test_nested_post_loop) + ASIO_TEST_CASE(test_post_loop_return_1_0) + ASIO_TEST_CASE(test_post_loop_return_1_1) + ASIO_TEST_CASE(test_post_loop_return_1_2) + ASIO_TEST_CASE(test_post_loop_return_2) + ASIO_TEST_CASE(test_complete_on_cancel) + ASIO_TEST_CASE(test_complete_with_default_on_cancel) + ASIO_TEST_CASE(test_throw_on_cancel) +) diff --git a/3rdparty/asio/src/tests/unit/experimental/concurrent_channel.cpp b/3rdparty/asio/src/tests/unit/experimental/concurrent_channel.cpp new file mode 100644 index 00000000000..e64e9051638 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/experimental/concurrent_channel.cpp @@ -0,0 +1,165 @@ +// +// experimental/concurrent_channel.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/experimental/concurrent_channel.hpp" + +#include <utility> +#include "asio/error.hpp" +#include "asio/io_context.hpp" +#include "../unit_test.hpp" + +using namespace asio; +using namespace asio::experimental; + +void unbuffered_concurrent_channel_test() +{ + io_context ctx; + + concurrent_channel<void(asio::error_code, std::string)> ch1(ctx); + + ASIO_CHECK(ch1.is_open()); + ASIO_CHECK(!ch1.ready()); + + bool b1 = ch1.try_send(asio::error::eof, "hello"); + + ASIO_CHECK(!b1); + + std::string s1 = "abcdefghijklmnopqrstuvwxyz"; + bool b2 = ch1.try_send(asio::error::eof, std::move(s1)); + + ASIO_CHECK(!b2); + ASIO_CHECK(!s1.empty()); + + asio::error_code ec1; + std::string s2; + ch1.async_receive( + [&](asio::error_code ec, std::string s) + { + ec1 = ec; + s2 = std::move(s); + }); + + bool b3 = ch1.try_send(asio::error::eof, std::move(s1)); + + ASIO_CHECK(b3); + ASIO_CHECK(s1.empty()); + + ctx.run(); + + ASIO_CHECK(ec1 == asio::error::eof); + ASIO_CHECK(s2 == "abcdefghijklmnopqrstuvwxyz"); + + bool b4 = ch1.try_receive([](asio::error_code, std::string){}); + + ASIO_CHECK(!b4); + + asio::error_code ec2 = asio::error::would_block; + std::string s3 = "zyxwvutsrqponmlkjihgfedcba"; + ch1.async_send(asio::error::eof, std::move(s3), + [&](asio::error_code ec) + { + ec2 = ec; + }); + + asio::error_code ec3; + std::string s4; + bool b5 = ch1.try_receive( + [&](asio::error_code ec, std::string s) + { + ec3 = ec; + s4 = s; + }); + + ASIO_CHECK(b5); + ASIO_CHECK(ec3 == asio::error::eof); + ASIO_CHECK(s4 == "zyxwvutsrqponmlkjihgfedcba"); + + ctx.restart(); + ctx.run(); + + ASIO_CHECK(!ec2); +}; + +void buffered_concurrent_channel_test() +{ + io_context ctx; + + concurrent_channel<void(asio::error_code, std::string)> ch1(ctx, 1); + + ASIO_CHECK(ch1.is_open()); + ASIO_CHECK(!ch1.ready()); + + bool b1 = ch1.try_send(asio::error::eof, "hello"); + + ASIO_CHECK(b1); + + std::string s1 = "abcdefghijklmnopqrstuvwxyz"; + bool b2 = ch1.try_send(asio::error::eof, std::move(s1)); + + ASIO_CHECK(!b2); + ASIO_CHECK(!s1.empty()); + + asio::error_code ec1; + std::string s2; + ch1.async_receive( + [&](asio::error_code ec, std::string s) + { + ec1 = ec; + s2 = std::move(s); + }); + + ctx.run(); + + ASIO_CHECK(ec1 == asio::error::eof); + ASIO_CHECK(s2 == "hello"); + + bool b4 = ch1.try_receive([](asio::error_code, std::string){}); + + ASIO_CHECK(!b4); + + asio::error_code ec2 = asio::error::would_block; + std::string s3 = "zyxwvutsrqponmlkjihgfedcba"; + ch1.async_send(asio::error::eof, std::move(s3), + [&](asio::error_code ec) + { + ec2 = ec; + }); + + asio::error_code ec3; + std::string s4; + bool b5 = ch1.try_receive( + [&](asio::error_code ec, std::string s) + { + ec3 = ec; + s4 = s; + }); + + ASIO_CHECK(b5); + ASIO_CHECK(ec3 == asio::error::eof); + ASIO_CHECK(s4 == "zyxwvutsrqponmlkjihgfedcba"); + + ctx.restart(); + ctx.run(); + + ASIO_CHECK(!ec2); +}; + +ASIO_TEST_SUITE +( + "experimental/concurrent_channel", + ASIO_TEST_CASE(unbuffered_concurrent_channel_test) + ASIO_TEST_CASE(buffered_concurrent_channel_test) +) diff --git a/3rdparty/asio/src/tests/unit/experimental/coro/allocator.cpp b/3rdparty/asio/src/tests/unit/experimental/coro/allocator.cpp new file mode 100644 index 00000000000..845906df853 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/experimental/coro/allocator.cpp @@ -0,0 +1,113 @@ +// +// experimental/coro/partial.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2021-2023 Klemens D. Morgenstern +// (klemens dot morgenstern at gmx dot net) +// +// 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/experimental/coro.hpp" + +#include <vector> +#include "asio/io_context.hpp" +#include "../../unit_test.hpp" + +namespace exp = asio::experimental; + +namespace coro { + +template<typename Value = void> +struct tracked_allocator +{ + using value_type = Value; + std::vector<std::pair<void*, std::size_t>> & allocs, &deallocs; + + tracked_allocator(std::vector<std::pair<void*, std::size_t>> & allocs, + std::vector<std::pair<void*, std::size_t>> & deallocs) : allocs(allocs), deallocs(deallocs) {} + + + template<typename T> + tracked_allocator(const tracked_allocator<T> & a) : allocs(a.allocs), deallocs(a.deallocs) {} + + value_type* allocate(std::size_t n) + { + auto p = new char[n * sizeof(Value)]; + allocs.emplace_back(p, n); + return reinterpret_cast<value_type*>(p); + } + + void deallocate(void* p, std::size_t n) + { + deallocs.emplace_back(p, n); + delete[] static_cast<char*>(p); +// ASIO_CHECK(allocs.back() == deallocs.back()); + } + + bool operator==(const tracked_allocator & rhs) const + { + return &allocs == &rhs.allocs + && &deallocs == &rhs.deallocs; + } +}; + +exp::coro<void, void, asio::any_io_executor, tracked_allocator<void>> + alloc_test_impl(asio::io_context & ctx, int, std::allocator_arg_t, tracked_allocator<void> ta, double) +{ + co_return ; +} + +void alloc_test() +{ + std::vector<std::pair<void*, std::size_t>> allocs, deallocs; + asio::io_context ctx; + bool ran = false; + + { + auto pp = alloc_test_impl(ctx, 42, std::allocator_arg, {allocs, deallocs}, 42.); + + ASIO_CHECK(allocs.size() == 1u); + ASIO_CHECK(deallocs.empty()); + + pp.async_resume([&](auto e){ran = true; ASIO_CHECK(!e);}); + ctx.run(); + ASIO_CHECK(deallocs.size() == 0u); + } + ctx.restart(); + ctx.run(); + ASIO_CHECK(deallocs.size() == 1u); + ASIO_CHECK(allocs == deallocs); + + ASIO_CHECK(ran); + + ran = false; + + auto p = asio::experimental::detail::post_coroutine( + ctx, + asio::bind_allocator(tracked_allocator{allocs, deallocs}, [&]{ran = true;})).handle; + ASIO_CHECK(allocs.size() == 2u); + ASIO_CHECK(deallocs.size() == 1u); + p.resume(); + ASIO_CHECK(allocs.size() == 3u); + ASIO_CHECK(deallocs.size() == 2u); + ctx.restart(); + ctx.run(); + + ASIO_CHECK(allocs == deallocs); +} + +} // namespace coro + +ASIO_TEST_SUITE +( + "coro/allocate", + ASIO_TEST_CASE(::coro::alloc_test) +) diff --git a/3rdparty/asio/src/tests/unit/experimental/coro/cancel.cpp b/3rdparty/asio/src/tests/unit/experimental/coro/cancel.cpp new file mode 100644 index 00000000000..38cf1067908 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/experimental/coro/cancel.cpp @@ -0,0 +1,179 @@ +// +// experimental/coro/cancel.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2021-2023 Klemens D. Morgenstern +// (klemens dot morgenstern at gmx dot net) +// +// 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/experimental/coro.hpp" +#include <iostream> +#include "asio/bind_cancellation_slot.hpp" +#include "asio/io_context.hpp" +#include "asio/steady_timer.hpp" +#include "asio/this_coro.hpp" +#include "../../unit_test.hpp" + +using namespace asio::experimental; +namespace this_coro = asio::this_coro; + +namespace coro { + + +auto coro_simple_cancel_impl(asio::io_context& ) noexcept + -> asio::experimental::coro<void() noexcept, asio::error_code> +{ + ASIO_CHECK( + !(co_await this_coro::cancellation_state).cancelled()); + + asio::steady_timer timer{ + co_await this_coro::executor, + std::chrono::seconds(1)}; + + ASIO_CHECK( + !(co_await this_coro::cancellation_state).cancelled()); + + auto ec = co_await timer; + + ASIO_CHECK( + (co_await this_coro::cancellation_state).cancelled()); + + co_return ec; +} + +void coro_simple_cancel() +{ + asio::io_context ctx; + asio::cancellation_signal sig; + + auto k = coro_simple_cancel_impl(ctx); + + asio::error_code res_ec; + k.async_resume( + asio::bind_cancellation_slot(sig.slot(), + [&](asio::error_code ec) {res_ec = ec;})); + asio::post(ctx, [&]{sig.emit(asio::cancellation_type::all);}); + + ASIO_CHECK(!res_ec); + + ctx.run(); + + ASIO_CHECK(res_ec == asio::error::operation_aborted); +} + +auto coro_throw_cancel_impl(asio::io_context& ) + -> asio::experimental::coro<void() , void> +{ + asio::steady_timer timer{ + co_await this_coro::executor, + std::chrono::seconds(1)}; + co_await timer; +} + +void coro_throw_cancel() +{ + asio::io_context ctx; + asio::cancellation_signal sig; + + auto k = coro_throw_cancel_impl(ctx); + + std::exception_ptr res_ex; + k.async_resume( + asio::bind_cancellation_slot(sig.slot(), + [&](std::exception_ptr ex) {res_ex = ex;})); + asio::post(ctx, [&]{sig.emit(asio::cancellation_type::all);}); + + ASIO_CHECK(!res_ex); + + ctx.run(); + + ASIO_CHECK(res_ex); + try + { + if (res_ex) + std::rethrow_exception(res_ex); + } + catch (asio::system_error& se) + { + ASIO_CHECK(se.code() == asio::error::operation_aborted); + } +} + +auto coro_simple_cancel_nested_k(asio::io_context&, int& cnt) noexcept + -> asio::experimental::coro< + void() noexcept, + asio::error_code> +{ + asio::steady_timer timer{ + co_await this_coro::executor, + std::chrono::milliseconds(100)}; + + ASIO_CHECK(!(co_await this_coro::cancellation_state).cancelled()); + auto ec = co_await timer; + cnt++; + ASIO_CHECK((co_await this_coro::cancellation_state).cancelled()); + + co_return ec; +} + +auto coro_simple_cancel_nested_kouter( + asio::io_context& ctx, int& cnt) noexcept + -> asio::experimental::coro< + asio::error_code() noexcept, + asio::error_code> +{ + ASIO_CHECK(cnt == 0); + co_yield co_await coro_simple_cancel_nested_k(ctx, cnt); + ASIO_CHECK(cnt == 1); + auto ec = co_await coro_simple_cancel_nested_k(ctx, cnt); + ASIO_CHECK(cnt == 2); + co_return ec; +} + +void coro_simple_cancel_nested() +{ + asio::io_context ctx; + asio::cancellation_signal sig; + + int cnt = 0; + auto kouter = coro_simple_cancel_nested_kouter(ctx, cnt); + + asio::error_code res_ec; + kouter.async_resume( + asio::bind_cancellation_slot(sig.slot(), + [&](asio::error_code ec) {res_ec = ec;})); + asio::post(ctx, [&]{sig.emit(asio::cancellation_type::all);}); + ASIO_CHECK(!res_ec); + ctx.run(); + ASIO_CHECK(res_ec == asio::error::operation_aborted); + + ctx.restart(); + res_ec = {}; + kouter.async_resume( + asio::bind_cancellation_slot(sig.slot(), + [&](asio::error_code ec) {res_ec = ec;})); + asio::post(ctx, [&]{sig.emit(asio::cancellation_type::all);}); + ASIO_CHECK(!res_ec); + ctx.run(); + ASIO_CHECK(res_ec == asio::error::operation_aborted); + ASIO_CHECK(cnt == 2); +} + +} // namespace coro + +ASIO_TEST_SUITE +( + "coro/cancel", + ASIO_TEST_CASE(::coro::coro_simple_cancel) + ASIO_TEST_CASE(::coro::coro_throw_cancel) + ASIO_TEST_CASE(::coro::coro_simple_cancel_nested) +) diff --git a/3rdparty/asio/src/tests/unit/experimental/coro/co_spawn.cpp b/3rdparty/asio/src/tests/unit/experimental/coro/co_spawn.cpp new file mode 100644 index 00000000000..8e6586252f2 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/experimental/coro/co_spawn.cpp @@ -0,0 +1,67 @@ +// +// experimental/coro/co_spawn.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2021-2023 Klemens D. Morgenstern +// (klemens dot morgenstern at gmx dot net) +// +// 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/experimental/co_spawn.hpp" + +#include <iostream> +#include "asio/io_context.hpp" +#include "asio/steady_timer.hpp" +#include "asio/this_coro.hpp" +#include "../../unit_test.hpp" + +using namespace asio::experimental; +namespace this_coro = asio::this_coro; + +namespace coro { + +auto coro_simple_co_spawn_impl(asio::io_context& , bool &done) noexcept + -> asio::experimental::coro<void() noexcept, int> +{ + asio::steady_timer timer( + co_await this_coro::executor, + std::chrono::milliseconds(10)); + + done = true; + + co_return 42; +} + +void coro_co_spawn() +{ + asio::io_context ctx; + + bool done1 = false; + bool done2 = false; + int res = 0; + + co_spawn(coro_simple_co_spawn_impl(ctx, done1), + [&](int r){done2= true; res = r;}); + + ctx.run(); + + ASIO_CHECK(done1); + ASIO_CHECK(done2); + ASIO_CHECK(res == 42); +} + +} // namespace coro + +ASIO_TEST_SUITE +( + "coro/co_spawn", + ASIO_TEST_CASE(::coro::coro_co_spawn) +) diff --git a/3rdparty/asio/src/tests/unit/experimental/coro/exception.cpp b/3rdparty/asio/src/tests/unit/experimental/coro/exception.cpp new file mode 100644 index 00000000000..f4d782e9903 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/experimental/coro/exception.cpp @@ -0,0 +1,172 @@ +// +// experimental/coro/exception.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2021-2023 Klemens D. Morgenstern +// (klemens dot morgenstern at gmx dot net) +// +// 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/experimental/coro.hpp" + +#include "asio/co_spawn.hpp" +#include "asio/detached.hpp" +#include "asio/io_context.hpp" +#include "asio/use_awaitable.hpp" +#include "asio/awaitable.hpp" +#include "../../unit_test.hpp" + +using namespace asio::experimental; + +namespace coro { + +template <typename Func> +struct on_scope_exit +{ + Func func; + + static_assert(noexcept(func())); + + on_scope_exit(const Func &f) + : func(static_cast< Func && >(f)) + { + } + + on_scope_exit(Func &&f) + : func(f) + { + } + + on_scope_exit(const on_scope_exit &) = delete; + + ~on_scope_exit() + { + func(); + } +}; + +asio::experimental::coro<int> throwing_generator( + asio::any_io_executor, int &last, bool &destroyed) +{ + on_scope_exit x = [&]() noexcept { destroyed = true; }; + (void)x; + + int i = 0; + while (i < 3) + co_yield last = ++i; + + throw std::runtime_error("throwing-generator"); +} + +asio::awaitable<void> throwing_generator_test() +{ + int val = 0; + bool destr = false; + { + auto gi = throwing_generator( + co_await asio::this_coro::executor, + val, destr); + bool caught = false; + try + { + for (int i = 0; i < 10; i++) + { + ASIO_CHECK(val == i); + const auto next = co_await gi.async_resume(asio::use_awaitable); + ASIO_CHECK(next); + ASIO_CHECK(val == *next); + ASIO_CHECK(val == i + 1); + } + } + catch (std::runtime_error &err) + { + caught = true; + using std::operator ""sv; + ASIO_CHECK(err.what() == "throwing-generator"sv); + } + ASIO_CHECK(val == 3); + ASIO_CHECK(caught); + } + ASIO_CHECK(destr); +}; + +void run_throwing_generator_test() +{ + asio::io_context ctx; + asio::co_spawn(ctx, throwing_generator_test(), asio::detached); + ctx.run(); +} + +asio::experimental::coro<int(int)> throwing_stacked( + asio::any_io_executor exec, int &val, + bool &destroyed_inner, bool &destroyed) +{ + ASIO_CHECK((co_await asio::this_coro::throw_if_cancelled())); + + on_scope_exit x = [&]() noexcept { destroyed = true; }; + (void)x; + + auto gen = throwing_generator(exec, val, destroyed_inner); + while (auto next = co_await gen) // 1, 2, 4, 8, ... + ASIO_CHECK(42 ==(co_yield *next)); // offset is delayed by one cycle +} + +asio::awaitable<void> throwing_generator_stacked_test() +{ + int val = 0; + bool destr = false, destr_inner = false; + { + auto gi = throwing_stacked( + co_await asio::this_coro::executor, + val, destr, destr_inner); + bool caught = false; + try + { + for (int i = 0; i < 10; i++) + { + ASIO_CHECK(val == i); + const auto next = + co_await gi.async_resume(42, asio::use_awaitable); + ASIO_CHECK(next); + ASIO_CHECK(val == *next); + ASIO_CHECK(val == i + 1); + } + } + catch (std::runtime_error &err) + { + caught = true; + using std::operator ""sv; + ASIO_CHECK(err.what() == "throwing-generator"sv); + } + ASIO_CHECK(val == 3); + ASIO_CHECK(caught); + } + ASIO_CHECK(destr); + ASIO_CHECK(destr_inner); +}; + +void run_throwing_generator_stacked_test() +{ + asio::io_context ctx; + asio::co_spawn(ctx, + throwing_generator_stacked_test, + asio::detached); + ctx.run(); +} + +} // namespace coro + +ASIO_TEST_SUITE +( + "coro/exception", + ASIO_TEST_CASE(::coro::run_throwing_generator_stacked_test) + ASIO_TEST_CASE(::coro::run_throwing_generator_test) +) diff --git a/3rdparty/asio/src/tests/unit/experimental/coro/executor.cpp b/3rdparty/asio/src/tests/unit/experimental/coro/executor.cpp new file mode 100644 index 00000000000..e0893da2e50 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/experimental/coro/executor.cpp @@ -0,0 +1,116 @@ +// +// experimental/coro/executor.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2021-2023 Klemens D. Morgenstern +// (klemens dot morgenstern at gmx dot net) +// +// 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/experimental/coro.hpp" + +#include "asio/thread_pool.hpp" +#include "asio/io_context.hpp" +#include "../../unit_test.hpp" + +using namespace asio::experimental; + +namespace coro { + +#define ASIO_CHECKPOINT() \ + ASIO_TEST_IOSTREAM << __FILE__ << "(" << __LINE__ << "): " \ + << asio::detail::test_name() << ": " \ + << "Checkpoint" << std::endl; + +template <typename T> +void different_execs() +{ + asio::thread_pool th_ctx{1u}; + asio::io_context ctx; + + auto o = std::make_optional( + asio::prefer(th_ctx.get_executor(), + asio::execution::outstanding_work.tracked)); + + static bool ran_inner = false, ran_outer = false; + + struct c_inner_t + { + auto operator()(asio::any_io_executor e) -> asio::experimental::coro<T> + { + auto p = e.target<asio::thread_pool::executor_type>(); + ASIO_CHECKPOINT(); + ASIO_CHECK(p); + ASIO_CHECK(p->running_in_this_thread()); + ran_inner = true; + co_return; + }; + + }; + + c_inner_t c_inner; + + struct c_outer_t + { + + auto operator()(asio::any_io_executor e, int, + asio::experimental::coro<T> tp) + -> asio::experimental::coro<void> + { + auto p = e.target<asio::io_context::executor_type>(); + + ASIO_CHECK(p); + ASIO_CHECK(p->running_in_this_thread()); + ASIO_CHECKPOINT(); + + co_await tp; + + ASIO_CHECKPOINT(); + ASIO_CHECK(p->running_in_this_thread()); + + ran_outer = true; + }; + }; + + c_outer_t c_outer; + + bool ran = false; + std::exception_ptr ex; + + auto c = c_outer(ctx.get_executor(), 10, c_inner(th_ctx.get_executor())); + c.async_resume( + [&](std::exception_ptr e) + { + ASIO_CHECK(!e); + ASIO_CHECKPOINT(); + ran = true; + }); + + ASIO_CHECK(!ran); + ctx.run(); + o.reset(); + ASIO_CHECK(ran); + ASIO_CHECK(ran_inner); + ASIO_CHECK(ran_outer); + ASIO_CHECK(!ex); + + th_ctx.stop(); + th_ctx.join(); +} + +} // namespace coro + +ASIO_TEST_SUITE +( + "coro/partial", + ASIO_TEST_CASE(::coro::different_execs<void>) + ASIO_TEST_CASE(::coro::different_execs<int()>) +) diff --git a/3rdparty/asio/src/tests/unit/experimental/coro/partial.cpp b/3rdparty/asio/src/tests/unit/experimental/coro/partial.cpp new file mode 100644 index 00000000000..651b8292204 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/experimental/coro/partial.cpp @@ -0,0 +1,45 @@ +// +// experimental/coro/partial.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2021-2023 Klemens D. Morgenstern +// (klemens dot morgenstern at gmx dot net) +// +// 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/experimental/coro.hpp" + +#include "asio/io_context.hpp" +#include "../../unit_test.hpp" + +using namespace asio::experimental; + +namespace coro { + +void partial() +{ + asio::io_context ctx; + bool ran = false; + auto p = detail::post_coroutine(ctx, [&]{ran = true;}).handle; + ASIO_CHECK(!ran); + p.resume(); + ASIO_CHECK(!ran); + ctx.run(); + ASIO_CHECK(ran); +} + +} // namespace coro + +ASIO_TEST_SUITE +( + "coro/partial", + ASIO_TEST_CASE(::coro::partial) +) diff --git a/3rdparty/asio/src/tests/unit/experimental/coro/simple_test.cpp b/3rdparty/asio/src/tests/unit/experimental/coro/simple_test.cpp new file mode 100644 index 00000000000..5eac0688548 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/experimental/coro/simple_test.cpp @@ -0,0 +1,264 @@ +// +// experimental/coro/simple_test.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2021-2023 Klemens D. Morgenstern +// (klemens dot morgenstern at gmx dot net) +// +// 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/experimental/coro.hpp" + +#include "asio/co_spawn.hpp" +#include "asio/detached.hpp" +#include "asio/io_context.hpp" +#include "asio/use_awaitable.hpp" +#include <iostream> +#include <vector> +#include "../../unit_test.hpp" + +using namespace asio::experimental; + +namespace asio { +namespace experimental { + +template struct coro<void(), void, any_io_executor>; +template struct coro<int(), void, any_io_executor>; +template struct coro<void(), int, any_io_executor>; +template struct coro<int(int), void, any_io_executor>; +template struct coro<int(), int, any_io_executor>; +template struct coro<int(int), int, any_io_executor>; + +template struct coro<void() noexcept, void, any_io_executor>; +template struct coro<int() noexcept, void, any_io_executor>; +template struct coro<void() noexcept, int, any_io_executor>; +template struct coro<int(int) noexcept, void, any_io_executor>; +template struct coro<int() noexcept, int, any_io_executor>; +template struct coro<int(int) noexcept, int, any_io_executor>; + +} // namespace experimental +} // namespace asio + +namespace coro { + +template <typename Func> +struct on_scope_exit +{ + Func func; + + static_assert(noexcept(func())); + + on_scope_exit(const Func &f) + : func(static_cast< Func && >(f)) + { + } + + on_scope_exit(Func &&f) + : func(f) + { + } + + on_scope_exit(const on_scope_exit &) = delete; + + ~on_scope_exit() + { + func(); + } +}; + +asio::experimental::coro<int> generator_impl( + asio::any_io_executor, int& last, bool& destroyed) +{ + on_scope_exit x = [&]() noexcept { destroyed = true; }; + (void)x; + + int i = 0; + while (true) + co_yield last = ++i; +} + +asio::awaitable<void> generator_test() +{ + int val = 0; + bool destr = false; + { + auto gi = generator_impl( + co_await asio::this_coro::executor, val, destr); + + for (int i = 0; i < 10; i++) + { + ASIO_CHECK(val == i); + const auto next = co_await gi.async_resume(asio::use_awaitable); + ASIO_CHECK(next); + ASIO_CHECK(val == *next); + ASIO_CHECK(val == i + 1); + } + + ASIO_CHECK(!destr); + } + ASIO_CHECK(destr); +}; + +void run_generator_test() +{ + asio::io_context ctx; + asio::co_spawn(ctx, generator_test, asio::detached); + ctx.run(); +} + +asio::experimental::coro<void, int> task_test(asio::io_context&) +{ + co_return 42; +} + +asio::experimental::coro<void, int> task_throw(asio::io_context&) +{ + throw std::logic_error(__func__); + co_return 42; +} + +void run_task_test() +{ + asio::io_context ctx; + + bool tt1 = false; + bool tt2 = false; + bool tt3 = false; + bool tt4 = false; + auto tt = task_test(ctx); + tt.async_resume( + [&](std::exception_ptr pt, int i) + { + tt1 = true; + ASIO_CHECK(!pt); + ASIO_CHECK(i == 42); + tt.async_resume( + [&](std::exception_ptr pt, int) + { + tt2 = true; + ASIO_CHECK(pt); + }); + }); + + auto tt_2 = task_throw(ctx); + + tt_2.async_resume( + [&](std::exception_ptr pt, int) + { + tt3 = true; + ASIO_CHECK(pt); + tt.async_resume( + [&](std::exception_ptr pt, int) + { + tt4 = true; + ASIO_CHECK(pt); + }); + }); + + ctx.run(); + + ASIO_CHECK(tt1); + ASIO_CHECK(tt2); + ASIO_CHECK(tt3); + ASIO_CHECK(tt4); +} + +asio::experimental::coro<char> completion_generator_test_impl( + asio::any_io_executor, int limit) +{ + for (int i = 0; i < limit; i++) + co_yield i; +} + +asio::awaitable<void> completion_generator_test() +{ + std::vector<int> res; + auto g = completion_generator_test_impl( + co_await asio::this_coro::executor, 10); + + ASIO_CHECK(g.is_open()); + while (auto val = co_await g.async_resume(asio::use_awaitable)) + res.push_back(*val); + + ASIO_CHECK(!g.is_open()); + ASIO_CHECK((res == std::vector{0,1,2,3,4,5,6,7,8,9})); +}; + + +void run_completion_generator_test() +{ + asio::io_context ctx; + asio::co_spawn(ctx, completion_generator_test, asio::detached); + ctx.run(); +} + +asio::experimental::coro<int(int)> +symmetrical_test_impl(asio::any_io_executor) +{ + int i = 0; + while (true) + i = (co_yield i) + i; +} + +asio::awaitable<void> symmetrical_test() +{ + auto g = symmetrical_test_impl(co_await asio::this_coro::executor); + + ASIO_CHECK(g.is_open()); + + ASIO_CHECK(0 == (co_await g.async_resume(0, + asio::use_awaitable)).value_or(-1)); + + ASIO_CHECK(1 == (co_await g.async_resume(1, + asio::use_awaitable)).value_or(-1)); + + ASIO_CHECK(3 == (co_await g.async_resume(2, + asio::use_awaitable)).value_or(-1)); + + ASIO_CHECK(6 == (co_await g.async_resume(3, + asio::use_awaitable)).value_or(-1)); + + ASIO_CHECK(10 == (co_await g.async_resume(4, + asio::use_awaitable)).value_or(-1)); + + ASIO_CHECK(15 == (co_await g.async_resume(5, + asio::use_awaitable)).value_or(-1)); + + ASIO_CHECK(21 == (co_await g.async_resume(6, + asio::use_awaitable)).value_or(-1)); + + ASIO_CHECK(28 == (co_await g.async_resume(7, + asio::use_awaitable)).value_or(-1)); + + ASIO_CHECK(36 == (co_await g.async_resume(8, + asio::use_awaitable)).value_or(-1)); + + ASIO_CHECK(45 == (co_await g.async_resume(9, + asio::use_awaitable)).value_or(-1)); +}; + +void run_symmetrical_test() +{ + asio::io_context ctx; + asio::co_spawn(ctx, symmetrical_test, asio::detached); + ctx.run(); +} + +} // namespace coro + +ASIO_TEST_SUITE +( + "coro/simple_test", + ASIO_TEST_CASE(::coro::run_generator_test) + ASIO_TEST_CASE(::coro::run_task_test) + ASIO_TEST_CASE(::coro::run_symmetrical_test) + ASIO_TEST_CASE(::coro::run_completion_generator_test) +) diff --git a/3rdparty/asio/src/tests/unit/experimental/coro/stack_test.cpp b/3rdparty/asio/src/tests/unit/experimental/coro/stack_test.cpp new file mode 100644 index 00000000000..9177161afcf --- /dev/null +++ b/3rdparty/asio/src/tests/unit/experimental/coro/stack_test.cpp @@ -0,0 +1,83 @@ +// +// experimental/coro/stack_test.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2021-2023 Klemens D. Morgenstern +// (klemens dot morgenstern at gmx dot net) +// +// 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/experimental/coro.hpp" + +#include "asio/detached.hpp" +#include "asio/io_context.hpp" +#include <iostream> +#include "../../unit_test.hpp" + +using namespace asio::experimental; + +namespace coro { + +asio::experimental::coro<int()> + stack_generator(asio::any_io_executor, int i = 1) +{ + for (;;) + { + co_yield i; + i *= 2; + } +} + +asio::experimental::coro<int(int)> +stack_accumulate(asio::any_io_executor exec) +{ + auto gen = stack_generator(exec); + int offset = 0; + while (auto next = co_await gen) // 1, 2, 4, 8, ... + offset = co_yield *next + offset; // offset is delayed by one cycle +} + +asio::experimental::coro<int> +main_stack_coro(asio::io_context&, bool & done) +{ + auto g = stack_accumulate(co_await asio::this_coro::executor); + + ASIO_CHECK(g.is_open()); + ASIO_CHECK(1 == (co_await g(1000)).value_or(-1)); + ASIO_CHECK(2002 == (co_await g(2000)).value_or(-1)); + ASIO_CHECK(3004 == (co_await g(3000)).value_or(-1)); + ASIO_CHECK(4008 == (co_await g(4000)).value_or(-1)); + ASIO_CHECK(5016 == (co_await g(5000)).value_or(-1)); + ASIO_CHECK(6032 == (co_await g(6000)).value_or(-1)); + ASIO_CHECK(7064 == (co_await g(7000)).value_or(-1)); + ASIO_CHECK(8128 == (co_await g(8000)).value_or(-1)); + ASIO_CHECK(9256 == (co_await g(9000)).value_or(-1)); + ASIO_CHECK(511 == (co_await g(-1)).value_or(-1)); + done = true; +} + +void stack_test() +{ + bool done = false; + asio::io_context ctx; + auto k = main_stack_coro(ctx, done); + k.async_resume(asio::detached); + ctx.run(); + ASIO_CHECK(done); +} + +} // namespace coro + +ASIO_TEST_SUITE +( + "coro/stack_test", + ASIO_TEST_CASE(::coro::stack_test) +) diff --git a/3rdparty/asio/src/tests/unit/experimental/coro/use_coro.cpp b/3rdparty/asio/src/tests/unit/experimental/coro/use_coro.cpp new file mode 100644 index 00000000000..f2cb7adfcdd --- /dev/null +++ b/3rdparty/asio/src/tests/unit/experimental/coro/use_coro.cpp @@ -0,0 +1,77 @@ +// +// experimental/coro/use_coro.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2021-2023 Klemens D. Morgenstern +// (klemens dot morgenstern at gmx dot net) +// +// 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/experimental/use_coro.hpp" + +#include "asio/steady_timer.hpp" +#include <iostream> +#include "../../unit_test.hpp" + +using namespace asio::experimental; + +namespace coro { + +asio::experimental::coro<void(), int> +awaiter(asio::any_io_executor exec) +{ + asio::steady_timer timer{exec}; + co_await timer.async_wait(use_coro); + co_return 42; +} + +asio::experimental::coro<void() noexcept, int> +awaiter_noexcept(asio::any_io_executor exec) +{ + asio::steady_timer timer{exec}; + auto ec = co_await timer.async_wait(asio::deferred); + ASIO_CHECK(ec == asio::error_code{}); + co_return 42; +} + +void stack_test2() +{ + bool done = false; + asio::io_context ctx; + + auto k = awaiter(ctx.get_executor()); + auto k2 = awaiter_noexcept(ctx.get_executor()); + + k.async_resume( + [&](std::exception_ptr ex, int res) + { + ASIO_CHECK(!ex); + ASIO_CHECK(res == 42); + done = true; + }); + + k2.async_resume([&](int res) + { + ASIO_CHECK(res == 42); + done = true; + }); + + ctx.run(); + ASIO_CHECK(done); +} + +} // namespace coro + +ASIO_TEST_SUITE +( + "coro/use_coro", + ASIO_TEST_CASE(::coro::stack_test2) +) diff --git a/3rdparty/asio/src/tests/unit/experimental/parallel_group.cpp b/3rdparty/asio/src/tests/unit/experimental/parallel_group.cpp new file mode 100644 index 00000000000..c91c95f157d --- /dev/null +++ b/3rdparty/asio/src/tests/unit/experimental/parallel_group.cpp @@ -0,0 +1,25 @@ +// +// experimental/parallel_group.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/experimental/parallel_group.hpp" + +#include "../unit_test.hpp" + +ASIO_TEST_SUITE +( + "experimental/parallel_group", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/experimental/promise.cpp b/3rdparty/asio/src/tests/unit/experimental/promise.cpp new file mode 100644 index 00000000000..67923a4c726 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/experimental/promise.cpp @@ -0,0 +1,226 @@ +// +// promise.cpp +// ~~~~~~~~~~~ +// +// Copyright (c) 2021-2023 Klemens D. Morgenstern +// (klemens dot morgenstern at gmx dot net) +// +// 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/experimental/promise.hpp" + +#include "asio/append.hpp" +#include "asio/bind_cancellation_slot.hpp" +#include "asio/compose.hpp" +#include "asio/deferred.hpp" +#include "asio/experimental/use_promise.hpp" +#include "asio/steady_timer.hpp" +#include "../unit_test.hpp" + +namespace promise { + +void promise_tester() +{ + using namespace asio; + using namespace std::chrono; + + io_context ctx; + + steady_timer timer1{ctx}, timer2{ctx}; + + const auto started_when = steady_clock::now(); + timer1.expires_at(started_when + milliseconds(5000)); + timer2.expires_at(started_when + milliseconds(1000)); + auto p1 = timer1.async_wait(experimental::use_promise); + + steady_clock::time_point completed_when; + asio::error_code ec; + bool called = false; + + p1([&](asio::error_code ec_) + { + ec = ec_; + called = true; + completed_when = steady_clock::now(); + }); + + steady_clock::time_point timer2_done; + timer2.async_wait( + [&](asio::error_code) + { + timer2_done = steady_clock::now(); + p1.cancel(); + }); + + ctx.run(); + + static_assert( + asio::is_async_operation<decltype(p1)>::value, + "promise is async_op"); + + ASIO_CHECK(timer2_done + milliseconds(1) > started_when); + ASIO_CHECK(completed_when > timer2_done); + ASIO_CHECK(called); + ASIO_CHECK(ec == error::operation_aborted); + + timer1.expires_after(milliseconds(0)); + auto p2 = timer1.async_wait( + asio::append(experimental::use_promise, 123)); + + ec = asio::error::would_block; + called = false; + + p2([&](asio::error_code ec_, int i) + { + ASIO_CHECK(i == 123); + ec = ec_; + called = true; + }); + + ASIO_CHECK(ec == asio::error::would_block); + ASIO_CHECK(!called); + + ctx.restart(); + ctx.run(); + + static_assert( + asio::is_async_operation<decltype(p2)>::value, + "promise is async_op"); + + ASIO_CHECK(!ec); + ASIO_CHECK(called); +} + +void promise_slot_tester() +{ + using namespace asio; + using namespace std::chrono; + + io_context ctx; + + steady_timer timer1{ctx}, timer2{ctx}; + + const auto started_when = steady_clock::now(); + timer1.expires_at(started_when + milliseconds(2500)); + timer2.expires_at(started_when + milliseconds(1000)); + auto p = timer1.async_wait(experimental::use_promise); + + steady_clock::time_point completed_when; + asio::error_code ec; + bool called = false; + + asio::cancellation_signal sig; + + p(asio::bind_cancellation_slot( + sig.slot(), + [&](asio::error_code ec_) + { + ec = ec_; + called = true; + completed_when = steady_clock::now(); + })); + + steady_clock::time_point timer2_done; + timer2.async_wait( + [&](asio::error_code) + { + timer2_done = steady_clock::now(); + sig.emit(asio::cancellation_type::all); + }); + + ctx.run(); + + static_assert( + asio::is_async_operation<decltype(p)>::value, + "promise is async_op"); + + ASIO_CHECK(timer2_done + milliseconds(1) > started_when); + ASIO_CHECK(completed_when > timer2_done); + ASIO_CHECK(called); + ASIO_CHECK(ec == error::operation_aborted); +} + +void early_completion() +{ + using namespace asio; + using namespace std::chrono; + + io_context ctx; + auto p = asio::post(ctx, asio::experimental::use_promise); + ctx.run(); + + ASIO_CHECK(p.completed()); + + bool completed = false; + p([&]{completed = true;}); + ASIO_CHECK(!completed); + ctx.restart(); + ctx.run(); + ASIO_CHECK(completed); +} + +struct test_cancel_impl_op +{ + asio::steady_timer & tim; + asio::error_code &ec; + template<typename Self> + void operator()(Self& self) + { + tim.async_wait(std::forward<Self>(self)); + } + + template<typename Self> + void operator()(Self& self, asio::error_code ec_) + { + ec = ec_; + self.complete(ec_); + } +}; + +template <typename CompletionToken> +ASIO_INITFN_AUTO_RESULT_TYPE( + CompletionToken, void(asio::error_code)) +test_cancel_impl(asio::steady_timer & tim, + asio::error_code &ec, + CompletionToken&& token) +{ + return asio::async_compose<CompletionToken, void(asio::error_code)>( + test_cancel_impl_op{tim, ec}, token, tim); +} + +void test_cancel() +{ + asio::io_context ctx; + asio::steady_timer tim{ctx, std::chrono::seconds(10)}; + asio::error_code ec; + + { + auto p = test_cancel_impl( + tim, ec, asio::experimental::use_promise); + } + + ctx.run(); + + ASIO_CHECK_MESSAGE( + ec == asio::error::operation_aborted, + ec.message()); +} + +} // namespace promise + +ASIO_TEST_SUITE +( + "promise", + ASIO_TEST_CASE(promise::promise_tester) + ASIO_TEST_CASE(promise::promise_slot_tester) + ASIO_TEST_CASE(promise::early_completion) + ASIO_TEST_CASE(promise::test_cancel) +) diff --git a/3rdparty/asio/src/tests/unit/file_base.cpp b/3rdparty/asio/src/tests/unit/file_base.cpp new file mode 100644 index 00000000000..9f517fd8e37 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/file_base.cpp @@ -0,0 +1,25 @@ +// +// file_base.cpp +// ~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/post.hpp" + +#include "unit_test.hpp" + +ASIO_TEST_SUITE +( + "file_base", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/generic/.gitignore b/3rdparty/asio/src/tests/unit/generic/.gitignore deleted file mode 100644 index c0571443308..00000000000 --- a/3rdparty/asio/src/tests/unit/generic/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*.ilk -*.manifest -*.pdb -*.tds -basic_endpoint -datagram_protocol -raw_protocol -seq_packet_protocol -stream_protocol diff --git a/3rdparty/asio/src/tests/unit/generic/basic_endpoint.cpp b/3rdparty/asio/src/tests/unit/generic/basic_endpoint.cpp index ef6d2b1b82f..c02f32b8c73 100644 --- a/3rdparty/asio/src/tests/unit/generic/basic_endpoint.cpp +++ b/3rdparty/asio/src/tests/unit/generic/basic_endpoint.cpp @@ -2,7 +2,7 @@ // generic/basic_endpoint.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/generic/datagram_protocol.cpp b/3rdparty/asio/src/tests/unit/generic/datagram_protocol.cpp index 32f636ba0c7..23957a7a15d 100644 --- a/3rdparty/asio/src/tests/unit/generic/datagram_protocol.cpp +++ b/3rdparty/asio/src/tests/unit/generic/datagram_protocol.cpp @@ -2,7 +2,7 @@ // generic/datagram_protocol.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -20,6 +20,7 @@ #include "asio/io_context.hpp" #include "asio/ip/udp.hpp" #include "../unit_test.hpp" +#include "../archetypes/async_result.hpp" #if defined(__cplusplus_cli) || defined(__cplusplus_winrt) # define generic cpp_generic @@ -65,6 +66,7 @@ void test() socket_base::message_flags in_flags = 0; socket_base::send_buffer_size socket_option; socket_base::bytes_readable io_control_command; + archetypes::immediate_handler immediate; asio::error_code ec; // basic_datagram_socket constructors. @@ -78,33 +80,21 @@ void test() dp::socket socket4(ioc, dp(af_inet, ipproto_udp), native_socket1); #endif // !defined(ASIO_WINDOWS_RUNTIME) -#if defined(ASIO_HAS_MOVE) dp::socket socket5(std::move(socket4)); asio::ip::udp::socket udp_socket(ioc); dp::socket socket6(std::move(udp_socket)); -#endif // defined(ASIO_HAS_MOVE) // basic_datagram_socket operators. -#if defined(ASIO_HAS_MOVE) socket1 = dp::socket(ioc); socket1 = std::move(socket2); socket1 = asio::ip::udp::socket(ioc); -#endif // defined(ASIO_HAS_MOVE) // basic_io_object functions. dp::socket::executor_type ex = socket1.get_executor(); (void)ex; -#if !defined(ASIO_NO_DEPRECATED) - io_context& ioc_ref = socket1.get_io_context(); - (void)ioc_ref; - - io_context& ioc_ref2 = socket1.get_io_service(); - (void)ioc_ref2; -#endif // !defined(ASIO_NO_DEPRECATED) - // basic_socket functions. dp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer(); @@ -151,6 +141,7 @@ void test() socket1.connect(dp::endpoint(), ec); socket1.async_connect(dp::endpoint(), connect_handler); + socket1.async_connect(dp::endpoint(), immediate); socket1.set_option(socket_option); socket1.set_option(socket_option, ec); @@ -162,10 +153,14 @@ void test() socket1.io_control(io_control_command, ec); dp::endpoint endpoint1 = socket1.local_endpoint(); + (void)endpoint1; dp::endpoint endpoint2 = socket1.local_endpoint(ec); + (void)endpoint2; dp::endpoint endpoint3 = socket1.remote_endpoint(); + (void)endpoint3; dp::endpoint endpoint4 = socket1.remote_endpoint(ec); + (void)endpoint4; socket1.shutdown(socket_base::shutdown_both); socket1.shutdown(socket_base::shutdown_both, ec); @@ -188,6 +183,12 @@ void test() socket1.async_send(buffer(mutable_char_buffer), in_flags, send_handler); socket1.async_send(buffer(const_char_buffer), in_flags, send_handler); socket1.async_send(null_buffers(), in_flags, send_handler); + socket1.async_send(buffer(mutable_char_buffer), immediate); + socket1.async_send(buffer(const_char_buffer), immediate); + socket1.async_send(null_buffers(), immediate); + socket1.async_send(buffer(mutable_char_buffer), in_flags, immediate); + socket1.async_send(buffer(const_char_buffer), in_flags, immediate); + socket1.async_send(null_buffers(), in_flags, immediate); socket1.send_to(buffer(mutable_char_buffer), dp::endpoint()); @@ -220,6 +221,18 @@ void test() dp::endpoint(), in_flags, send_handler); socket1.async_send_to(null_buffers(), dp::endpoint(), in_flags, send_handler); + socket1.async_send_to(buffer(mutable_char_buffer), + dp::endpoint(), immediate); + socket1.async_send_to(buffer(const_char_buffer), + dp::endpoint(), immediate); + socket1.async_send_to(null_buffers(), + dp::endpoint(), immediate); + socket1.async_send_to(buffer(mutable_char_buffer), + dp::endpoint(), in_flags, immediate); + socket1.async_send_to(buffer(const_char_buffer), + dp::endpoint(), in_flags, immediate); + socket1.async_send_to(null_buffers(), + dp::endpoint(), in_flags, immediate); socket1.receive(buffer(mutable_char_buffer)); socket1.receive(null_buffers()); @@ -233,6 +246,10 @@ void test() socket1.async_receive(buffer(mutable_char_buffer), in_flags, receive_handler); socket1.async_receive(null_buffers(), in_flags, receive_handler); + socket1.async_receive(buffer(mutable_char_buffer), immediate); + socket1.async_receive(null_buffers(), immediate); + socket1.async_receive(buffer(mutable_char_buffer), in_flags, immediate); + socket1.async_receive(null_buffers(), in_flags, immediate); dp::endpoint endpoint; socket1.receive_from(buffer(mutable_char_buffer), endpoint); @@ -250,6 +267,14 @@ void test() endpoint, in_flags, receive_handler); socket1.async_receive_from(null_buffers(), endpoint, in_flags, receive_handler); + socket1.async_receive_from(buffer(mutable_char_buffer), + endpoint, immediate); + socket1.async_receive_from(null_buffers(), + endpoint, immediate); + socket1.async_receive_from(buffer(mutable_char_buffer), + endpoint, in_flags, immediate); + socket1.async_receive_from(null_buffers(), + endpoint, in_flags, immediate); } catch (std::exception&) { @@ -263,5 +288,5 @@ void test() ASIO_TEST_SUITE ( "generic/datagram_protocol", - ASIO_TEST_CASE(generic_datagram_protocol_socket_compile::test) + ASIO_COMPILE_TEST_CASE(generic_datagram_protocol_socket_compile::test) ) diff --git a/3rdparty/asio/src/tests/unit/generic/raw_protocol.cpp b/3rdparty/asio/src/tests/unit/generic/raw_protocol.cpp index 92c0efa899f..d20ef5ba870 100644 --- a/3rdparty/asio/src/tests/unit/generic/raw_protocol.cpp +++ b/3rdparty/asio/src/tests/unit/generic/raw_protocol.cpp @@ -2,7 +2,7 @@ // generic/raw_protocol.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -20,6 +20,7 @@ #include "asio/io_context.hpp" #include "asio/ip/icmp.hpp" #include "../unit_test.hpp" +#include "../archetypes/async_result.hpp" #if defined(__cplusplus_cli) || defined(__cplusplus_winrt) # define generic cpp_generic @@ -65,6 +66,7 @@ void test() socket_base::message_flags in_flags = 0; socket_base::send_buffer_size socket_option; socket_base::bytes_readable io_control_command; + archetypes::immediate_handler immediate; asio::error_code ec; // basic_raw_socket constructors. @@ -78,33 +80,21 @@ void test() rp::socket socket4(ioc, rp(af_inet, ipproto_icmp), native_socket1); #endif // !defined(ASIO_WINDOWS_RUNTIME) -#if defined(ASIO_HAS_MOVE) rp::socket socket5(std::move(socket4)); asio::ip::icmp::socket icmp_socket(ioc); rp::socket socket6(std::move(icmp_socket)); -#endif // defined(ASIO_HAS_MOVE) // basic_datagram_socket operators. -#if defined(ASIO_HAS_MOVE) socket1 = rp::socket(ioc); socket1 = std::move(socket2); socket1 = asio::ip::icmp::socket(ioc); -#endif // defined(ASIO_HAS_MOVE) // basic_io_object functions. rp::socket::executor_type ex = socket1.get_executor(); (void)ex; -#if !defined(ASIO_NO_DEPRECATED) - io_context& ioc_ref = socket1.get_io_context(); - (void)ioc_ref; - - io_context& ioc_ref2 = socket1.get_io_service(); - (void)ioc_ref2; -#endif // !defined(ASIO_NO_DEPRECATED) - // basic_socket functions. rp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer(); @@ -151,6 +141,7 @@ void test() socket1.connect(rp::endpoint(), ec); socket1.async_connect(rp::endpoint(), connect_handler); + socket1.async_connect(rp::endpoint(), immediate); socket1.set_option(socket_option); socket1.set_option(socket_option, ec); @@ -162,10 +153,14 @@ void test() socket1.io_control(io_control_command, ec); rp::endpoint endpoint1 = socket1.local_endpoint(); + (void)endpoint1; rp::endpoint endpoint2 = socket1.local_endpoint(ec); + (void)endpoint2; rp::endpoint endpoint3 = socket1.remote_endpoint(); + (void)endpoint3; rp::endpoint endpoint4 = socket1.remote_endpoint(ec); + (void)endpoint4; socket1.shutdown(socket_base::shutdown_both); socket1.shutdown(socket_base::shutdown_both, ec); @@ -188,6 +183,12 @@ void test() socket1.async_send(buffer(mutable_char_buffer), in_flags, send_handler); socket1.async_send(buffer(const_char_buffer), in_flags, send_handler); socket1.async_send(null_buffers(), in_flags, send_handler); + socket1.async_send(buffer(mutable_char_buffer), immediate); + socket1.async_send(buffer(const_char_buffer), immediate); + socket1.async_send(null_buffers(), immediate); + socket1.async_send(buffer(mutable_char_buffer), in_flags, immediate); + socket1.async_send(buffer(const_char_buffer), in_flags, immediate); + socket1.async_send(null_buffers(), in_flags, immediate); socket1.send_to(buffer(mutable_char_buffer), rp::endpoint()); @@ -220,6 +221,18 @@ void test() rp::endpoint(), in_flags, send_handler); socket1.async_send_to(null_buffers(), rp::endpoint(), in_flags, send_handler); + socket1.async_send_to(buffer(mutable_char_buffer), + rp::endpoint(), immediate); + socket1.async_send_to(buffer(const_char_buffer), + rp::endpoint(), immediate); + socket1.async_send_to(null_buffers(), + rp::endpoint(), immediate); + socket1.async_send_to(buffer(mutable_char_buffer), + rp::endpoint(), in_flags, immediate); + socket1.async_send_to(buffer(const_char_buffer), + rp::endpoint(), in_flags, immediate); + socket1.async_send_to(null_buffers(), + rp::endpoint(), in_flags, immediate); socket1.receive(buffer(mutable_char_buffer)); socket1.receive(null_buffers()); @@ -233,6 +246,11 @@ void test() socket1.async_receive(buffer(mutable_char_buffer), in_flags, receive_handler); socket1.async_receive(null_buffers(), in_flags, receive_handler); + socket1.async_receive(buffer(mutable_char_buffer), immediate); + socket1.async_receive(null_buffers(), immediate); + socket1.async_receive(buffer(mutable_char_buffer), in_flags, + immediate); + socket1.async_receive(null_buffers(), in_flags, immediate); rp::endpoint endpoint; socket1.receive_from(buffer(mutable_char_buffer), endpoint); @@ -250,6 +268,14 @@ void test() endpoint, in_flags, receive_handler); socket1.async_receive_from(null_buffers(), endpoint, in_flags, receive_handler); + socket1.async_receive_from(buffer(mutable_char_buffer), + endpoint, immediate); + socket1.async_receive_from(null_buffers(), + endpoint, immediate); + socket1.async_receive_from(buffer(mutable_char_buffer), + endpoint, in_flags, immediate); + socket1.async_receive_from(null_buffers(), + endpoint, in_flags, immediate); } catch (std::exception&) { @@ -263,5 +289,5 @@ void test() ASIO_TEST_SUITE ( "generic/raw_protocol", - ASIO_TEST_CASE(generic_raw_protocol_socket_compile::test) + ASIO_COMPILE_TEST_CASE(generic_raw_protocol_socket_compile::test) ) diff --git a/3rdparty/asio/src/tests/unit/generic/seq_packet_protocol.cpp b/3rdparty/asio/src/tests/unit/generic/seq_packet_protocol.cpp index e66012649b4..587445b1f05 100644 --- a/3rdparty/asio/src/tests/unit/generic/seq_packet_protocol.cpp +++ b/3rdparty/asio/src/tests/unit/generic/seq_packet_protocol.cpp @@ -2,7 +2,7 @@ // generic/seq_packet_protocol.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -19,6 +19,7 @@ #include <cstring> #include "asio/io_context.hpp" #include "../unit_test.hpp" +#include "../archetypes/async_result.hpp" #if defined(__cplusplus_cli) || defined(__cplusplus_winrt) # define generic cpp_generic @@ -64,6 +65,7 @@ void test() socket_base::message_flags out_flags = 0; socket_base::send_buffer_size socket_option; socket_base::bytes_readable io_control_command; + archetypes::immediate_handler immediate; asio::error_code ec; // basic_seq_packet_socket constructors. @@ -77,30 +79,18 @@ void test() spp::socket socket4(ioc, spp(af_inet, 0), native_socket1); #endif // !defined(ASIO_WINDOWS_RUNTIME) -#if defined(ASIO_HAS_MOVE) spp::socket socket5(std::move(socket4)); -#endif // defined(ASIO_HAS_MOVE) // basic_seq_packet_socket operators. -#if defined(ASIO_HAS_MOVE) socket1 = spp::socket(ioc); socket1 = std::move(socket2); -#endif // defined(ASIO_HAS_MOVE) // basic_io_object functions. spp::socket::executor_type ex = socket1.get_executor(); (void)ex; -#if !defined(ASIO_NO_DEPRECATED) - io_context& ioc_ref = socket1.get_io_context(); - (void)ioc_ref; - - io_context& ioc_ref2 = socket1.get_io_service(); - (void)ioc_ref2; -#endif // !defined(ASIO_NO_DEPRECATED) - // basic_socket functions. spp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer(); @@ -147,6 +137,7 @@ void test() socket1.connect(spp::endpoint(), ec); socket1.async_connect(spp::endpoint(), connect_handler); + socket1.async_connect(spp::endpoint(), immediate); socket1.set_option(socket_option); socket1.set_option(socket_option, ec); @@ -158,10 +149,14 @@ void test() socket1.io_control(io_control_command, ec); spp::endpoint endpoint1 = socket1.local_endpoint(); + (void)endpoint1; spp::endpoint endpoint2 = socket1.local_endpoint(ec); + (void)endpoint2; spp::endpoint endpoint3 = socket1.remote_endpoint(); + (void)endpoint3; spp::endpoint endpoint4 = socket1.remote_endpoint(ec); + (void)endpoint4; socket1.shutdown(socket_base::shutdown_both); socket1.shutdown(socket_base::shutdown_both, ec); @@ -178,6 +173,9 @@ void test() socket1.async_send(buffer(mutable_char_buffer), in_flags, send_handler); socket1.async_send(buffer(const_char_buffer), in_flags, send_handler); socket1.async_send(null_buffers(), in_flags, send_handler); + socket1.async_send(buffer(mutable_char_buffer), in_flags, immediate); + socket1.async_send(buffer(const_char_buffer), in_flags, immediate); + socket1.async_send(null_buffers(), in_flags, immediate); socket1.receive(buffer(mutable_char_buffer), out_flags); socket1.receive(null_buffers(), out_flags); @@ -192,6 +190,11 @@ void test() socket1.async_receive(buffer(mutable_char_buffer), in_flags, out_flags, receive_handler); socket1.async_receive(null_buffers(), in_flags, out_flags, receive_handler); + socket1.async_receive(buffer(mutable_char_buffer), out_flags, immediate); + socket1.async_receive(null_buffers(), out_flags, immediate); + socket1.async_receive(buffer(mutable_char_buffer), in_flags, + out_flags, immediate); + socket1.async_receive(null_buffers(), in_flags, out_flags, immediate); } catch (std::exception&) { @@ -205,5 +208,5 @@ void test() ASIO_TEST_SUITE ( "generic/seq_packet_protocol", - ASIO_TEST_CASE(generic_seq_packet_protocol_socket_compile::test) + ASIO_COMPILE_TEST_CASE(generic_seq_packet_protocol_socket_compile::test) ) diff --git a/3rdparty/asio/src/tests/unit/generic/stream_protocol.cpp b/3rdparty/asio/src/tests/unit/generic/stream_protocol.cpp index 796206917c6..dedf6d76cee 100644 --- a/3rdparty/asio/src/tests/unit/generic/stream_protocol.cpp +++ b/3rdparty/asio/src/tests/unit/generic/stream_protocol.cpp @@ -2,7 +2,7 @@ // generic/stream_protocol.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -20,6 +20,7 @@ #include "asio/io_context.hpp" #include "asio/ip/tcp.hpp" #include "../unit_test.hpp" +#include "../archetypes/async_result.hpp" #if defined(__cplusplus_cli) || defined(__cplusplus_winrt) # define generic cpp_generic @@ -73,6 +74,7 @@ void test() socket_base::message_flags in_flags = 0; socket_base::keep_alive socket_option; socket_base::bytes_readable io_control_command; + archetypes::immediate_handler immediate; asio::error_code ec; // basic_stream_socket constructors. @@ -88,33 +90,21 @@ void test() #endif // defined(ASIO_WINDOWS_RUNTIME) sp::socket socket4(ioc, sp(af_inet, ipproto_tcp), native_socket1); -#if defined(ASIO_HAS_MOVE) sp::socket socket5(std::move(socket4)); asio::ip::tcp::socket tcp_socket(ioc); sp::socket socket6(std::move(tcp_socket)); -#endif // defined(ASIO_HAS_MOVE) // basic_stream_socket operators. -#if defined(ASIO_HAS_MOVE) socket1 = sp::socket(ioc); socket1 = std::move(socket2); socket1 = asio::ip::tcp::socket(ioc); -#endif // defined(ASIO_HAS_MOVE) // basic_io_object functions. sp::socket::executor_type ex = socket1.get_executor(); (void)ex; -#if !defined(ASIO_NO_DEPRECATED) - io_context& ioc_ref = socket1.get_io_context(); - (void)ioc_ref; - - io_context& ioc_ref2 = socket1.get_io_service(); - (void)ioc_ref2; -#endif // !defined(ASIO_NO_DEPRECATED) - // basic_socket functions. sp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer(); @@ -167,6 +157,7 @@ void test() socket1.connect(sp::endpoint(), ec); socket1.async_connect(sp::endpoint(), connect_handler); + socket1.async_connect(sp::endpoint(), immediate); socket1.set_option(socket_option); socket1.set_option(socket_option, ec); @@ -178,10 +169,14 @@ void test() socket1.io_control(io_control_command, ec); sp::endpoint endpoint1 = socket1.local_endpoint(); + (void)endpoint1; sp::endpoint endpoint2 = socket1.local_endpoint(ec); + (void)endpoint2; sp::endpoint endpoint3 = socket1.remote_endpoint(); + (void)endpoint3; sp::endpoint endpoint4 = socket1.remote_endpoint(ec); + (void)endpoint4; socket1.shutdown(socket_base::shutdown_both); socket1.shutdown(socket_base::shutdown_both, ec); @@ -204,6 +199,12 @@ void test() socket1.async_send(buffer(mutable_char_buffer), in_flags, send_handler); socket1.async_send(buffer(const_char_buffer), in_flags, send_handler); socket1.async_send(null_buffers(), in_flags, send_handler); + socket1.async_send(buffer(mutable_char_buffer), immediate); + socket1.async_send(buffer(const_char_buffer), immediate); + socket1.async_send(null_buffers(), immediate); + socket1.async_send(buffer(mutable_char_buffer), in_flags, immediate); + socket1.async_send(buffer(const_char_buffer), in_flags, immediate); + socket1.async_send(null_buffers(), in_flags, immediate); socket1.receive(buffer(mutable_char_buffer)); socket1.receive(null_buffers()); @@ -217,6 +218,11 @@ void test() socket1.async_receive(buffer(mutable_char_buffer), in_flags, receive_handler); socket1.async_receive(null_buffers(), in_flags, receive_handler); + socket1.async_receive(buffer(mutable_char_buffer), immediate); + socket1.async_receive(null_buffers(), immediate); + socket1.async_receive(buffer(mutable_char_buffer), in_flags, + immediate); + socket1.async_receive(null_buffers(), in_flags, immediate); socket1.write_some(buffer(mutable_char_buffer)); socket1.write_some(buffer(const_char_buffer)); @@ -228,6 +234,9 @@ void test() socket1.async_write_some(buffer(mutable_char_buffer), write_some_handler); socket1.async_write_some(buffer(const_char_buffer), write_some_handler); socket1.async_write_some(null_buffers(), write_some_handler); + socket1.async_write_some(buffer(mutable_char_buffer), immediate); + socket1.async_write_some(buffer(const_char_buffer), immediate); + socket1.async_write_some(null_buffers(), immediate); socket1.read_some(buffer(mutable_char_buffer)); socket1.read_some(buffer(mutable_char_buffer), ec); @@ -235,6 +244,8 @@ void test() socket1.async_read_some(buffer(mutable_char_buffer), read_some_handler); socket1.async_read_some(null_buffers(), read_some_handler); + socket1.async_read_some(buffer(mutable_char_buffer), immediate); + socket1.async_read_some(null_buffers(), immediate); } catch (std::exception&) { @@ -248,5 +259,5 @@ void test() ASIO_TEST_SUITE ( "generic/stream_protocol", - ASIO_TEST_CASE(generic_stream_protocol_socket_compile::test) + ASIO_COMPILE_TEST_CASE(generic_stream_protocol_socket_compile::test) ) diff --git a/3rdparty/asio/src/tests/unit/high_resolution_timer.cpp b/3rdparty/asio/src/tests/unit/high_resolution_timer.cpp index 894bd746474..b8dd448c321 100644 --- a/3rdparty/asio/src/tests/unit/high_resolution_timer.cpp +++ b/3rdparty/asio/src/tests/unit/high_resolution_timer.cpp @@ -2,7 +2,7 @@ // high_resolution_timer.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/io_context.cpp b/3rdparty/asio/src/tests/unit/io_context.cpp index 530d1390e02..4341fb62e1e 100644 --- a/3rdparty/asio/src/tests/unit/io_context.cpp +++ b/3rdparty/asio/src/tests/unit/io_context.cpp @@ -2,7 +2,7 @@ // io_context.cpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -16,6 +16,7 @@ // Test that header file is self-contained. #include "asio/io_context.hpp" +#include <functional> #include <sstream> #include "asio/bind_executor.hpp" #include "asio/dispatch.hpp" @@ -29,24 +30,13 @@ # include "asio/steady_timer.hpp" #endif // defined(ASIO_HAS_BOOST_DATE_TIME) -#if defined(ASIO_HAS_BOOST_BIND) -# include <boost/bind.hpp> -#else // defined(ASIO_HAS_BOOST_BIND) -# include <functional> -#endif // defined(ASIO_HAS_BOOST_BIND) - using namespace asio; - -#if defined(ASIO_HAS_BOOST_BIND) -namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; -#endif #if defined(ASIO_HAS_BOOST_DATE_TIME) typedef deadline_timer timer; namespace chronons = boost::posix_time; -#elif defined(ASIO_HAS_CHRONO) +#else // defined(ASIO_HAS_BOOST_DATE_TIME) typedef steady_timer timer; namespace chronons = asio::chrono; #endif // defined(ASIO_HAS_BOOST_DATE_TIME) @@ -354,9 +344,223 @@ void io_context_service_test() ASIO_CHECK(!asio::has_service<test_service>(ioc3)); } +void io_context_executor_query_test() +{ + io_context ioc; + + ASIO_CHECK( + &asio::query(ioc.get_executor(), + asio::execution::context) + == &ioc); + + ASIO_CHECK( + asio::query(ioc.get_executor(), + asio::execution::blocking) + == asio::execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ioc.get_executor(), + asio::execution::blocking.possibly) + == asio::execution::blocking.possibly); + + ASIO_CHECK( + asio::query(ioc.get_executor(), + asio::execution::outstanding_work) + == asio::execution::outstanding_work.untracked); + + ASIO_CHECK( + asio::query(ioc.get_executor(), + asio::execution::outstanding_work.untracked) + == asio::execution::outstanding_work.untracked); + + ASIO_CHECK( + asio::query(ioc.get_executor(), + asio::execution::relationship) + == asio::execution::relationship.fork); + + ASIO_CHECK( + asio::query(ioc.get_executor(), + asio::execution::relationship.fork) + == asio::execution::relationship.fork); + + ASIO_CHECK( + asio::query(ioc.get_executor(), + asio::execution::mapping) + == asio::execution::mapping.thread); + + ASIO_CHECK( + asio::query(ioc.get_executor(), + asio::execution::allocator) + == std::allocator<void>()); +} + +void io_context_executor_execute_test() +{ + io_context ioc; + int count = 0; + + ioc.get_executor().execute(bindns::bind(increment, &count)); + + // No handlers can be called until run() is called. + ASIO_CHECK(!ioc.stopped()); + ASIO_CHECK(count == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + + count = 0; + ioc.restart(); + asio::require(ioc.get_executor(), + asio::execution::blocking.possibly + ).execute(bindns::bind(increment, &count)); + + // No handlers can be called until run() is called. + ASIO_CHECK(!ioc.stopped()); + ASIO_CHECK(count == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + + count = 0; + ioc.restart(); + asio::require(ioc.get_executor(), + asio::execution::blocking.never + ).execute(bindns::bind(increment, &count)); + + // No handlers can be called until run() is called. + ASIO_CHECK(!ioc.stopped()); + ASIO_CHECK(count == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + + count = 0; + ioc.restart(); + ASIO_CHECK(!ioc.stopped()); + + asio::require(ioc.get_executor(), + asio::execution::blocking.never, + asio::execution::outstanding_work.tracked + ).execute(bindns::bind(increment, &count)); + + // No handlers can be called until run() is called. + ASIO_CHECK(!ioc.stopped()); + ASIO_CHECK(count == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + + count = 0; + ioc.restart(); + asio::require(ioc.get_executor(), + asio::execution::blocking.never, + asio::execution::outstanding_work.untracked + ).execute(bindns::bind(increment, &count)); + + // No handlers can be called until run() is called. + ASIO_CHECK(!ioc.stopped()); + ASIO_CHECK(count == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + + count = 0; + ioc.restart(); + asio::require(ioc.get_executor(), + asio::execution::blocking.never, + asio::execution::outstanding_work.untracked, + asio::execution::relationship.fork + ).execute(bindns::bind(increment, &count)); + + // No handlers can be called until run() is called. + ASIO_CHECK(!ioc.stopped()); + ASIO_CHECK(count == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + + count = 0; + ioc.restart(); + asio::require(ioc.get_executor(), + asio::execution::blocking.never, + asio::execution::outstanding_work.untracked, + asio::execution::relationship.continuation + ).execute(bindns::bind(increment, &count)); + + // No handlers can be called until run() is called. + ASIO_CHECK(!ioc.stopped()); + ASIO_CHECK(count == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + + count = 0; + ioc.restart(); + asio::prefer( + asio::require(ioc.get_executor(), + asio::execution::blocking.never, + asio::execution::outstanding_work.untracked, + asio::execution::relationship.continuation), + asio::execution::allocator(std::allocator<void>()) + ).execute(bindns::bind(increment, &count)); + + // No handlers can be called until run() is called. + ASIO_CHECK(!ioc.stopped()); + ASIO_CHECK(count == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + + count = 0; + ioc.restart(); + asio::prefer( + asio::require(ioc.get_executor(), + asio::execution::blocking.never, + asio::execution::outstanding_work.untracked, + asio::execution::relationship.continuation), + asio::execution::allocator + ).execute(bindns::bind(increment, &count)); + + // No handlers can be called until run() is called. + ASIO_CHECK(!ioc.stopped()); + ASIO_CHECK(count == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); +} + ASIO_TEST_SUITE ( "io_context", ASIO_TEST_CASE(io_context_test) ASIO_TEST_CASE(io_context_service_test) + ASIO_TEST_CASE(io_context_executor_query_test) + ASIO_TEST_CASE(io_context_executor_execute_test) ) diff --git a/3rdparty/asio/src/tests/unit/io_context_strand.cpp b/3rdparty/asio/src/tests/unit/io_context_strand.cpp new file mode 100644 index 00000000000..be03eb40dd2 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/io_context_strand.cpp @@ -0,0 +1,316 @@ +// +// io_context_strand.cpp +// ~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/io_context_strand.hpp" + +#include <functional> +#include <sstream> +#include "asio/io_context.hpp" +#include "asio/dispatch.hpp" +#include "asio/post.hpp" +#include "asio/thread.hpp" +#include "unit_test.hpp" + +#if defined(ASIO_HAS_BOOST_DATE_TIME) +# include "asio/deadline_timer.hpp" +#else // defined(ASIO_HAS_BOOST_DATE_TIME) +# include "asio/steady_timer.hpp" +#endif // defined(ASIO_HAS_BOOST_DATE_TIME) + +using namespace asio; + +namespace bindns = std; + +#if defined(ASIO_HAS_BOOST_DATE_TIME) +typedef deadline_timer timer; +namespace chronons = boost::posix_time; +#else // defined(ASIO_HAS_BOOST_DATE_TIME) +typedef steady_timer timer; +namespace chronons = asio::chrono; +#endif // defined(ASIO_HAS_BOOST_DATE_TIME) + +void increment(int* count) +{ + ++(*count); +} + +void increment_without_lock(io_context::strand* s, int* count) +{ + ASIO_CHECK(!s->running_in_this_thread()); + + int original_count = *count; + + dispatch(*s, bindns::bind(increment, count)); + + // No other functions are currently executing through the locking dispatcher, + // so the previous call to dispatch should have successfully nested. + ASIO_CHECK(*count == original_count + 1); +} + +void increment_with_lock(io_context::strand* s, int* count) +{ + ASIO_CHECK(s->running_in_this_thread()); + + int original_count = *count; + + dispatch(*s, bindns::bind(increment, count)); + + // The current function already holds the strand's lock, so the + // previous call to dispatch should have successfully nested. + ASIO_CHECK(*count == original_count + 1); +} + +void sleep_increment(io_context* ioc, int* count) +{ + timer t(*ioc, chronons::seconds(2)); + t.wait(); + + ++(*count); +} + +void increment_by_a(int* count, int a) +{ + (*count) += a; +} + +void increment_by_a_b(int* count, int a, int b) +{ + (*count) += a + b; +} + +void increment_by_a_b_c(int* count, int a, int b, int c) +{ + (*count) += a + b + c; +} + +void increment_by_a_b_c_d(int* count, int a, int b, int c, int d) +{ + (*count) += a + b + c + d; +} + +void start_sleep_increments(io_context* ioc, io_context::strand* s, int* count) +{ + // Give all threads a chance to start. + timer t(*ioc, chronons::seconds(2)); + t.wait(); + + // Start three increments. + post(*s, bindns::bind(sleep_increment, ioc, count)); + post(*s, bindns::bind(sleep_increment, ioc, count)); + post(*s, bindns::bind(sleep_increment, ioc, count)); +} + +void throw_exception() +{ + throw 1; +} + +void io_context_run(io_context* ioc) +{ + ioc->run(); +} + +void strand_test() +{ + io_context ioc; + io_context::strand s(ioc); + int count = 0; + + post(ioc, bindns::bind(increment_without_lock, &s, &count)); + + // No handlers can be called until run() is called. + ASIO_CHECK(count == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(count == 1); + + count = 0; + ioc.restart(); + post(s, bindns::bind(increment_with_lock, &s, &count)); + + // No handlers can be called until run() is called. + ASIO_CHECK(count == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(count == 1); + + count = 0; + ioc.restart(); + post(ioc, bindns::bind(start_sleep_increments, &ioc, &s, &count)); + thread thread1(bindns::bind(io_context_run, &ioc)); + thread thread2(bindns::bind(io_context_run, &ioc)); + + // Check all events run one after another even though there are two threads. + timer timer1(ioc, chronons::seconds(3)); + timer1.wait(); + ASIO_CHECK(count == 0); +#if defined(ASIO_HAS_BOOST_DATE_TIME) + timer1.expires_at(timer1.expires_at() + chronons::seconds(2)); +#else // defined(ASIO_HAS_BOOST_DATE_TIME) + timer1.expires_at(timer1.expiry() + chronons::seconds(2)); +#endif // defined(ASIO_HAS_BOOST_DATE_TIME) + timer1.wait(); + ASIO_CHECK(count == 1); +#if defined(ASIO_HAS_BOOST_DATE_TIME) + timer1.expires_at(timer1.expires_at() + chronons::seconds(2)); +#else // defined(ASIO_HAS_BOOST_DATE_TIME) + timer1.expires_at(timer1.expiry() + chronons::seconds(2)); +#endif // defined(ASIO_HAS_BOOST_DATE_TIME) + timer1.wait(); + ASIO_CHECK(count == 2); + + thread1.join(); + thread2.join(); + + // The run() calls will not return until all work has finished. + ASIO_CHECK(count == 3); + + count = 0; + int exception_count = 0; + ioc.restart(); + post(s, throw_exception); + post(s, bindns::bind(increment, &count)); + post(s, bindns::bind(increment, &count)); + post(s, throw_exception); + post(s, bindns::bind(increment, &count)); + + // No handlers can be called until run() is called. + ASIO_CHECK(count == 0); + ASIO_CHECK(exception_count == 0); + + for (;;) + { + try + { + ioc.run(); + break; + } + catch (int) + { + ++exception_count; + } + } + + // The run() calls will not return until all work has finished. + ASIO_CHECK(count == 3); + ASIO_CHECK(exception_count == 2); + + count = 0; + ioc.restart(); + + // Check for clean shutdown when handlers posted through an orphaned strand + // are abandoned. + { + io_context::strand s2(ioc); + post(s2, bindns::bind(increment, &count)); + post(s2, bindns::bind(increment, &count)); + post(s2, bindns::bind(increment, &count)); + } + + // No handlers can be called until run() is called. + ASIO_CHECK(count == 0); +} + +void strand_wrap_test() +{ +#if !defined(ASIO_NO_DEPRECATED) + io_context ioc; + io_context::strand s(ioc); + int count = 0; + + s.wrap(bindns::bind(increment, &count))(); + + // No handlers can be called until run() is called. + ASIO_CHECK(count == 0); + + ioc.restart(); + ioc.run(); + + // The run() calls will not return until all work has finished. + ASIO_CHECK(count == 1); + + count = 0; + s.wrap(increment)(&count); + + // No handlers can be called until run() is called. + ASIO_CHECK(count == 0); + + ioc.restart(); + ioc.run(); + + // The run() calls will not return until all work has finished. + ASIO_CHECK(count == 1); + + count = 0; + s.wrap(increment_by_a)(&count, 1); + + // No handlers can be called until run() is called. + ASIO_CHECK(count == 0); + + ioc.restart(); + ioc.run(); + + // The run() calls will not return until all work has finished. + ASIO_CHECK(count == 1); + + count = 0; + s.wrap(increment_by_a_b)(&count, 1, 2); + + // No handlers can be called until run() is called. + ASIO_CHECK(count == 0); + + ioc.restart(); + ioc.run(); + + // The run() calls will not return until all work has finished. + ASIO_CHECK(count == 3); + + count = 0; + s.wrap(increment_by_a_b_c)(&count, 1, 2, 3); + + // No handlers can be called until run() is called. + ASIO_CHECK(count == 0); + + ioc.restart(); + ioc.run(); + + // The run() calls will not return until all work has finished. + ASIO_CHECK(count == 6); + + count = 0; + s.wrap(increment_by_a_b_c_d)(&count, 1, 2, 3, 4); + + // No handlers can be called until run() is called. + ASIO_CHECK(count == 0); + + ioc.restart(); + ioc.run(); + + // The run() calls will not return until all work has finished. + ASIO_CHECK(count == 10); +#endif // !defined(ASIO_NO_DEPRECATED) +} + +ASIO_TEST_SUITE +( + "strand", + ASIO_TEST_CASE(strand_test) + ASIO_TEST_CASE(strand_wrap_test) +) diff --git a/3rdparty/asio/src/tests/unit/ip/.gitignore b/3rdparty/asio/src/tests/unit/ip/.gitignore deleted file mode 100644 index 087ad80f192..00000000000 --- a/3rdparty/asio/src/tests/unit/ip/.gitignore +++ /dev/null @@ -1,28 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*.ilk -*.manifest -*.pdb -*.tds -address -address_v4* -address_v6* -basic_endpoint -basic_resolver -basic_resolver_entry -basic_resolver_iterator -basic_resolver_query -host_name -icmp -multicast -network_v4 -network_v6 -resolver_query_base -resolver_service -tcp -udp -unicast -v6_only diff --git a/3rdparty/asio/src/tests/unit/ip/address.cpp b/3rdparty/asio/src/tests/unit/ip/address.cpp index e0b61d92b8d..a13a343c8e9 100644 --- a/3rdparty/asio/src/tests/unit/ip/address.cpp +++ b/3rdparty/asio/src/tests/unit/ip/address.cpp @@ -2,7 +2,7 @@ // address.cpp // ~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -108,15 +108,15 @@ void test() addr1 = ip::make_address("127.0.0.1", ec); addr1 = ip::make_address(string_value); addr1 = ip::make_address(string_value, ec); -#if defined(ASIO_HAS_STD_STRING_VIEW) -# if defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW) - std::experimental::string_view string_view_value("127.0.0.1"); -# else // defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW) +#if defined(ASIO_HAS_STRING_VIEW) +# if defined(ASIO_HAS_STD_STRING_VIEW) std::string_view string_view_value("127.0.0.1"); +# elif defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW) + std::experimental::string_view string_view_value("127.0.0.1"); # endif // defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW) addr1 = ip::make_address(string_view_value); addr1 = ip::make_address(string_view_value, ec); -#endif // defined(ASIO_HAS_STD_STRING_VIEW) +#endif // defined(ASIO_HAS_STRING_VIEW) // address I/O. @@ -127,6 +127,9 @@ void test() std::wostringstream wos; wos << addr1; #endif // !defined(BOOST_NO_STD_WSTREAMBUF) + + std::size_t hash1 = std::hash<ip::address>()(addr1); + (void)hash1; } catch (std::exception&) { @@ -140,5 +143,5 @@ void test() ASIO_TEST_SUITE ( "ip/address", - ASIO_TEST_CASE(ip_address_compile::test) + ASIO_COMPILE_TEST_CASE(ip_address_compile::test) ) diff --git a/3rdparty/asio/src/tests/unit/ip/address_v4.cpp b/3rdparty/asio/src/tests/unit/ip/address_v4.cpp index e65f12b06a1..6fb361b9544 100644 --- a/3rdparty/asio/src/tests/unit/ip/address_v4.cpp +++ b/3rdparty/asio/src/tests/unit/ip/address_v4.cpp @@ -2,7 +2,7 @@ // address_v4.cpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -132,15 +132,15 @@ void test() addr1 = ip::make_address_v4("127.0.0.1", ec); addr1 = ip::make_address_v4(string_value); addr1 = ip::make_address_v4(string_value, ec); -#if defined(ASIO_HAS_STD_STRING_VIEW) -# if defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW) - std::experimental::string_view string_view_value("127.0.0.1"); -# else // defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW) +#if defined(ASIO_HAS_STRING_VIEW) +# if defined(ASIO_HAS_STD_STRING_VIEW) std::string_view string_view_value("127.0.0.1"); +# elif defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW) + std::experimental::string_view string_view_value("127.0.0.1"); # endif // defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW) addr1 = ip::make_address_v4(string_view_value); addr1 = ip::make_address_v4(string_view_value, ec); -#endif // defined(ASIO_HAS_STD_STRING_VIEW) +#endif // defined(ASIO_HAS_STRING_VIEW) // address_v4 I/O. @@ -151,6 +151,11 @@ void test() std::wostringstream wos; wos << addr1; #endif // !defined(BOOST_NO_STD_WSTREAMBUF) + +#if defined(ASIO_HAS_STD_HASH) + std::size_t hash1 = std::hash<ip::address_v4>()(addr1); + (void)hash1; +#endif // defined(ASIO_HAS_STD_HASH) } catch (std::exception&) { @@ -319,6 +324,6 @@ void test() ASIO_TEST_SUITE ( "ip/address_v4", - ASIO_TEST_CASE(ip_address_v4_compile::test) + ASIO_COMPILE_TEST_CASE(ip_address_v4_compile::test) ASIO_TEST_CASE(ip_address_v4_runtime::test) ) diff --git a/3rdparty/asio/src/tests/unit/ip/address_v4_iterator.cpp b/3rdparty/asio/src/tests/unit/ip/address_v4_iterator.cpp index f8917220d12..8b651b52582 100644 --- a/3rdparty/asio/src/tests/unit/ip/address_v4_iterator.cpp +++ b/3rdparty/asio/src/tests/unit/ip/address_v4_iterator.cpp @@ -2,7 +2,7 @@ // address_v4_iterator.cpp // ~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/ip/address_v4_range.cpp b/3rdparty/asio/src/tests/unit/ip/address_v4_range.cpp index 0eb652d0699..1b36744cb53 100644 --- a/3rdparty/asio/src/tests/unit/ip/address_v4_range.cpp +++ b/3rdparty/asio/src/tests/unit/ip/address_v4_range.cpp @@ -2,7 +2,7 @@ // address_v4_range.cpp // ~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/ip/address_v6.cpp b/3rdparty/asio/src/tests/unit/ip/address_v6.cpp index b73f65c1b2e..026c5fa4f9a 100644 --- a/3rdparty/asio/src/tests/unit/ip/address_v6.cpp +++ b/3rdparty/asio/src/tests/unit/ip/address_v6.cpp @@ -2,7 +2,7 @@ // address_v6.cpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -144,15 +144,15 @@ void test() addr1 = ip::make_address_v6("0::0", ec); addr1 = ip::make_address_v6(string_value); addr1 = ip::make_address_v6(string_value, ec); -#if defined(ASIO_HAS_STD_STRING_VIEW) -# if defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW) - std::experimental::string_view string_view_value("0::0"); -# else // defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW) +#if defined(ASIO_HAS_STRING_VIEW) +# if defined(ASIO_HAS_STD_STRING_VIEW) std::string_view string_view_value("0::0"); +# else // defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW) + std::experimental::string_view string_view_value("0::0"); # endif // defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW) addr1 = ip::make_address_v6(string_view_value); addr1 = ip::make_address_v6(string_view_value, ec); -#endif // defined(ASIO_HAS_STD_STRING_VIEW) +#endif // defined(ASIO_HAS_STRING_VIEW) // address_v6 IPv4-mapped conversion. #if defined(ASIO_NO_DEPRECATED) @@ -170,6 +170,11 @@ void test() std::wostringstream wos; wos << addr1; #endif // !defined(BOOST_NO_STD_WSTREAMBUF) + +#if defined(ASIO_HAS_STD_HASH) + std::size_t hash1 = std::hash<ip::address_v6>()(addr1); + (void)hash1; +#endif // defined(ASIO_HAS_STD_HASH) } catch (std::exception&) { @@ -404,6 +409,6 @@ void test() ASIO_TEST_SUITE ( "ip/address_v6", - ASIO_TEST_CASE(ip_address_v6_compile::test) + ASIO_COMPILE_TEST_CASE(ip_address_v6_compile::test) ASIO_TEST_CASE(ip_address_v6_runtime::test) ) diff --git a/3rdparty/asio/src/tests/unit/ip/address_v6_iterator.cpp b/3rdparty/asio/src/tests/unit/ip/address_v6_iterator.cpp index 16b040c7142..ef62dc645c2 100644 --- a/3rdparty/asio/src/tests/unit/ip/address_v6_iterator.cpp +++ b/3rdparty/asio/src/tests/unit/ip/address_v6_iterator.cpp @@ -2,7 +2,7 @@ // address_v6_iterator.cpp // ~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/ip/address_v6_range.cpp b/3rdparty/asio/src/tests/unit/ip/address_v6_range.cpp index 76169234620..b0477214d7e 100644 --- a/3rdparty/asio/src/tests/unit/ip/address_v6_range.cpp +++ b/3rdparty/asio/src/tests/unit/ip/address_v6_range.cpp @@ -2,7 +2,7 @@ // address_v6_range.cpp // ~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/ip/basic_endpoint.cpp b/3rdparty/asio/src/tests/unit/ip/basic_endpoint.cpp index e363ef55661..d4aadb6febc 100644 --- a/3rdparty/asio/src/tests/unit/ip/basic_endpoint.cpp +++ b/3rdparty/asio/src/tests/unit/ip/basic_endpoint.cpp @@ -2,7 +2,7 @@ // basic_endpoint.cpp // ~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/ip/basic_resolver.cpp b/3rdparty/asio/src/tests/unit/ip/basic_resolver.cpp index afe06f5e178..698a2bad25f 100644 --- a/3rdparty/asio/src/tests/unit/ip/basic_resolver.cpp +++ b/3rdparty/asio/src/tests/unit/ip/basic_resolver.cpp @@ -2,7 +2,7 @@ // basic_resolver.cpp // ~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/ip/basic_resolver_entry.cpp b/3rdparty/asio/src/tests/unit/ip/basic_resolver_entry.cpp index 2bebc825610..7de5b6fc2c0 100644 --- a/3rdparty/asio/src/tests/unit/ip/basic_resolver_entry.cpp +++ b/3rdparty/asio/src/tests/unit/ip/basic_resolver_entry.cpp @@ -2,7 +2,7 @@ // basic_resolver_entry.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/ip/basic_resolver_iterator.cpp b/3rdparty/asio/src/tests/unit/ip/basic_resolver_iterator.cpp index 9745e9eae00..df7a54a79af 100644 --- a/3rdparty/asio/src/tests/unit/ip/basic_resolver_iterator.cpp +++ b/3rdparty/asio/src/tests/unit/ip/basic_resolver_iterator.cpp @@ -2,7 +2,7 @@ // basic_resolver_iterator.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/ip/basic_resolver_query.cpp b/3rdparty/asio/src/tests/unit/ip/basic_resolver_query.cpp index 5fc5be4b150..6d10e449482 100644 --- a/3rdparty/asio/src/tests/unit/ip/basic_resolver_query.cpp +++ b/3rdparty/asio/src/tests/unit/ip/basic_resolver_query.cpp @@ -2,7 +2,7 @@ // basic_resolver_query.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/ip/host_name.cpp b/3rdparty/asio/src/tests/unit/ip/host_name.cpp index 64dad204cdf..6972cbf6f4a 100644 --- a/3rdparty/asio/src/tests/unit/ip/host_name.cpp +++ b/3rdparty/asio/src/tests/unit/ip/host_name.cpp @@ -2,7 +2,7 @@ // host_name.cpp // ~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -51,5 +51,5 @@ void test() ASIO_TEST_SUITE ( "ip/host_name", - ASIO_TEST_CASE(ip_host_name_compile::test) + ASIO_COMPILE_TEST_CASE(ip_host_name_compile::test) ) diff --git a/3rdparty/asio/src/tests/unit/ip/icmp.cpp b/3rdparty/asio/src/tests/unit/ip/icmp.cpp index 4a4f5e843f3..ec60267b30f 100644 --- a/3rdparty/asio/src/tests/unit/ip/icmp.cpp +++ b/3rdparty/asio/src/tests/unit/ip/icmp.cpp @@ -2,7 +2,7 @@ // icmp.cpp // ~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -21,7 +21,6 @@ #include "asio/placeholders.hpp" #include "../unit_test.hpp" #include "../archetypes/async_result.hpp" -#include "../archetypes/deprecated_async_result.hpp" #include "../archetypes/gettable_socket_option.hpp" #include "../archetypes/io_control_command.hpp" #include "../archetypes/settable_socket_option.hpp" @@ -39,33 +38,27 @@ struct connect_handler { connect_handler() {} void operator()(const asio::error_code&) {} -#if defined(ASIO_HAS_MOVE) connect_handler(connect_handler&&) {} private: connect_handler(const connect_handler&); -#endif // defined(ASIO_HAS_MOVE) }; struct send_handler { send_handler() {} void operator()(const asio::error_code&, std::size_t) {} -#if defined(ASIO_HAS_MOVE) send_handler(send_handler&&) {} private: send_handler(const send_handler&); -#endif // defined(ASIO_HAS_MOVE) }; struct receive_handler { receive_handler() {} void operator()(const asio::error_code&, std::size_t) {} -#if defined(ASIO_HAS_MOVE) receive_handler(receive_handler&&) {} private: receive_handler(const receive_handler&); -#endif // defined(ASIO_HAS_MOVE) }; void test() @@ -76,6 +69,7 @@ void test() try { io_context ioc; + const io_context::executor_type ioc_ex = ioc.get_executor(); char mutable_char_buffer[128] = ""; const char const_char_buffer[128] = ""; socket_base::message_flags in_flags = 0; @@ -86,10 +80,8 @@ void test() archetypes::gettable_socket_option<int> gettable_socket_option2; archetypes::gettable_socket_option<double> gettable_socket_option3; archetypes::io_control_command io_control_command; + archetypes::immediate_handler immediate; archetypes::lazy_handler lazy; -#if !defined(ASIO_NO_DEPRECATED) - archetypes::deprecated_lazy_handler dlazy; -#endif // !defined(ASIO_NO_DEPRECATED) asio::error_code ec; // basic_datagram_socket constructors. @@ -105,24 +97,26 @@ void test() ip::icmp::socket socket6(ioc, ip::icmp::v4(), native_socket1); #endif // !defined(ASIO_WINDOWS_RUNTIME) -#if defined(ASIO_HAS_MOVE) - ip::icmp::socket socket7(std::move(socket6)); -#endif // defined(ASIO_HAS_MOVE) + ip::icmp::socket socket7(ioc_ex); + ip::icmp::socket socket8(ioc_ex, ip::icmp::v4()); + ip::icmp::socket socket9(ioc_ex, ip::icmp::v6()); + ip::icmp::socket socket10(ioc_ex, ip::icmp::endpoint(ip::icmp::v4(), 0)); + ip::icmp::socket socket11(ioc_ex, ip::icmp::endpoint(ip::icmp::v6(), 0)); +#if !defined(ASIO_WINDOWS_RUNTIME) + ip::icmp::socket::native_handle_type native_socket2 + = ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + ip::icmp::socket socket12(ioc_ex, ip::icmp::v4(), native_socket2); +#endif // !defined(ASIO_WINDOWS_RUNTIME) + + ip::icmp::socket socket13(std::move(socket6)); // basic_datagram_socket operators. -#if defined(ASIO_HAS_MOVE) socket1 = ip::icmp::socket(ioc); socket1 = std::move(socket2); -#endif // defined(ASIO_HAS_MOVE) // basic_io_object functions. -#if !defined(ASIO_NO_DEPRECATED) - io_context& ioc_ref = socket1.get_io_context(); - (void)ioc_ref; -#endif // !defined(ASIO_NO_DEPRECATED) - ip::icmp::socket::executor_type ex = socket1.get_executor(); (void)ex; @@ -131,9 +125,9 @@ void test() ip::icmp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer(); (void)lowest_layer; - const ip::icmp::socket& socket8 = socket1; + const ip::icmp::socket& socket14 = socket1; const ip::icmp::socket::lowest_layer_type& lowest_layer2 - = socket8.lowest_layer(); + = socket14.lowest_layer(); (void)lowest_layer2; socket1.open(ip::icmp::v4()); @@ -142,12 +136,12 @@ void test() socket1.open(ip::icmp::v6(), ec); #if !defined(ASIO_WINDOWS_RUNTIME) - ip::icmp::socket::native_handle_type native_socket2 - = ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - socket1.assign(ip::icmp::v4(), native_socket2); ip::icmp::socket::native_handle_type native_socket3 = ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - socket1.assign(ip::icmp::v4(), native_socket3, ec); + socket1.assign(ip::icmp::v4(), native_socket3); + ip::icmp::socket::native_handle_type native_socket4 + = ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + socket1.assign(ip::icmp::v4(), native_socket4, ec); #endif // !defined(ASIO_WINDOWS_RUNTIME) bool is_open = socket1.is_open(); @@ -156,9 +150,12 @@ void test() socket1.close(); socket1.close(ec); - ip::icmp::socket::native_handle_type native_socket4 + socket1.release(); + socket1.release(ec); + + ip::icmp::socket::native_handle_type native_socket5 = socket1.native_handle(); - (void)native_socket4; + (void)native_socket5; socket1.cancel(); socket1.cancel(ec); @@ -187,18 +184,12 @@ void test() connect_handler()); socket1.async_connect(ip::icmp::endpoint(ip::icmp::v6(), 0), connect_handler()); + socket1.async_connect(ip::icmp::endpoint(ip::icmp::v4(), 0), immediate); + socket1.async_connect(ip::icmp::endpoint(ip::icmp::v6(), 0), immediate); int i1 = socket1.async_connect(ip::icmp::endpoint(ip::icmp::v4(), 0), lazy); (void)i1; int i2 = socket1.async_connect(ip::icmp::endpoint(ip::icmp::v6(), 0), lazy); (void)i2; -#if !defined(ASIO_NO_DEPRECATED) - double d1 = socket1.async_connect( - ip::icmp::endpoint(ip::icmp::v4(), 0), dlazy); - (void)d1; - double d2 = socket1.async_connect( - ip::icmp::endpoint(ip::icmp::v6(), 0), dlazy); - (void)d2; -#endif // !defined(ASIO_NO_DEPRECATED) socket1.set_option(settable_socket_option1); socket1.set_option(settable_socket_option1, ec); @@ -228,10 +219,14 @@ void test() socket1.native_non_blocking(false, ec); ip::icmp::endpoint endpoint1 = socket1.local_endpoint(); + (void)endpoint1; ip::icmp::endpoint endpoint2 = socket1.local_endpoint(ec); + (void)endpoint2; ip::icmp::endpoint endpoint3 = socket1.remote_endpoint(); + (void)endpoint3; ip::icmp::endpoint endpoint4 = socket1.remote_endpoint(ec); + (void)endpoint4; socket1.shutdown(socket_base::shutdown_both); socket1.shutdown(socket_base::shutdown_both, ec); @@ -254,6 +249,12 @@ void test() socket1.async_send(buffer(mutable_char_buffer), in_flags, send_handler()); socket1.async_send(buffer(const_char_buffer), in_flags, send_handler()); socket1.async_send(null_buffers(), in_flags, send_handler()); + socket1.async_send(buffer(mutable_char_buffer), immediate); + socket1.async_send(buffer(const_char_buffer), immediate); + socket1.async_send(null_buffers(), immediate); + socket1.async_send(buffer(mutable_char_buffer), in_flags, immediate); + socket1.async_send(buffer(const_char_buffer), in_flags, immediate); + socket1.async_send(null_buffers(), in_flags, immediate); int i3 = socket1.async_send(buffer(mutable_char_buffer), lazy); (void)i3; int i4 = socket1.async_send(buffer(const_char_buffer), lazy); @@ -266,21 +267,6 @@ void test() (void)i7; int i8 = socket1.async_send(null_buffers(), in_flags, lazy); (void)i8; -#if !defined(ASIO_NO_DEPRECATED) - double d3 = socket1.async_send(buffer(mutable_char_buffer), dlazy); - (void)d3; - double d4 = socket1.async_send(buffer(const_char_buffer), dlazy); - (void)d4; - double d5 = socket1.async_send(null_buffers(), dlazy); - (void)d5; - double d6 = socket1.async_send( - buffer(mutable_char_buffer), in_flags, dlazy); - (void)d6; - double d7 = socket1.async_send(buffer(const_char_buffer), in_flags, dlazy); - (void)d7; - double d8 = socket1.async_send(null_buffers(), in_flags, dlazy); - (void)d8; -#endif // !defined(ASIO_NO_DEPRECATED) socket1.send_to(buffer(mutable_char_buffer), ip::icmp::endpoint(ip::icmp::v4(), 0)); @@ -343,6 +329,30 @@ void test() ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, send_handler()); socket1.async_send_to(null_buffers(), ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, send_handler()); + socket1.async_send_to(buffer(mutable_char_buffer), + ip::icmp::endpoint(ip::icmp::v4(), 0), immediate); + socket1.async_send_to(buffer(mutable_char_buffer), + ip::icmp::endpoint(ip::icmp::v6(), 0), immediate); + socket1.async_send_to(buffer(const_char_buffer), + ip::icmp::endpoint(ip::icmp::v4(), 0), immediate); + socket1.async_send_to(buffer(const_char_buffer), + ip::icmp::endpoint(ip::icmp::v6(), 0), immediate); + socket1.async_send_to(null_buffers(), + ip::icmp::endpoint(ip::icmp::v4(), 0), immediate); + socket1.async_send_to(null_buffers(), + ip::icmp::endpoint(ip::icmp::v6(), 0), immediate); + socket1.async_send_to(buffer(mutable_char_buffer), + ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, immediate); + socket1.async_send_to(buffer(mutable_char_buffer), + ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, immediate); + socket1.async_send_to(buffer(const_char_buffer), + ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, immediate); + socket1.async_send_to(buffer(const_char_buffer), + ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, immediate); + socket1.async_send_to(null_buffers(), + ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, immediate); + socket1.async_send_to(null_buffers(), + ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, immediate); int i9 = socket1.async_send_to(buffer(mutable_char_buffer), ip::icmp::endpoint(ip::icmp::v4(), 0), lazy); (void)i9; @@ -379,44 +389,6 @@ void test() int i20 = socket1.async_send_to(null_buffers(), ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, lazy); (void)i20; -#if !defined(ASIO_NO_DEPRECATED) - double d9 = socket1.async_send_to(buffer(mutable_char_buffer), - ip::icmp::endpoint(ip::icmp::v4(), 0), dlazy); - (void)d9; - double d10 = socket1.async_send_to(buffer(mutable_char_buffer), - ip::icmp::endpoint(ip::icmp::v6(), 0), dlazy); - (void)d10; - double d11 = socket1.async_send_to(buffer(const_char_buffer), - ip::icmp::endpoint(ip::icmp::v4(), 0), dlazy); - (void)d11; - double d12 = socket1.async_send_to(buffer(const_char_buffer), - ip::icmp::endpoint(ip::icmp::v6(), 0), dlazy); - (void)d12; - double d13 = socket1.async_send_to(null_buffers(), - ip::icmp::endpoint(ip::icmp::v4(), 0), dlazy); - (void)d13; - double d14 = socket1.async_send_to(null_buffers(), - ip::icmp::endpoint(ip::icmp::v6(), 0), dlazy); - (void)d14; - double d15 = socket1.async_send_to(buffer(mutable_char_buffer), - ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, dlazy); - (void)d15; - double d16 = socket1.async_send_to(buffer(mutable_char_buffer), - ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, dlazy); - (void)d16; - double d17 = socket1.async_send_to(buffer(const_char_buffer), - ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, dlazy); - (void)d17; - double d18 = socket1.async_send_to(buffer(const_char_buffer), - ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, dlazy); - (void)d18; - double d19 = socket1.async_send_to(null_buffers(), - ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, dlazy); - (void)d19; - double d20 = socket1.async_send_to(null_buffers(), - ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, dlazy); - (void)d20; -#endif // !defined(ASIO_NO_DEPRECATED) socket1.receive(buffer(mutable_char_buffer)); socket1.receive(null_buffers()); @@ -430,6 +402,10 @@ void test() socket1.async_receive(buffer(mutable_char_buffer), in_flags, receive_handler()); socket1.async_receive(null_buffers(), in_flags, receive_handler()); + socket1.async_receive(buffer(mutable_char_buffer), immediate); + socket1.async_receive(null_buffers(), immediate); + socket1.async_receive(buffer(mutable_char_buffer), in_flags, immediate); + socket1.async_receive(null_buffers(), in_flags, immediate); int i21 = socket1.async_receive(buffer(mutable_char_buffer), lazy); (void)i21; int i22 = socket1.async_receive(null_buffers(), lazy); @@ -439,17 +415,6 @@ void test() (void)i23; int i24 = socket1.async_receive(null_buffers(), in_flags, lazy); (void)i24; -#if !defined(ASIO_NO_DEPRECATED) - double d21 = socket1.async_receive(buffer(mutable_char_buffer), dlazy); - (void)d21; - double d22 = socket1.async_receive(null_buffers(), dlazy); - (void)d22; - double d23 = socket1.async_receive(buffer(mutable_char_buffer), - in_flags, dlazy); - (void)d23; - double d24 = socket1.async_receive(null_buffers(), in_flags, dlazy); - (void)d24; -#endif // !defined(ASIO_NO_DEPRECATED) ip::icmp::endpoint endpoint; socket1.receive_from(buffer(mutable_char_buffer), endpoint); @@ -467,6 +432,14 @@ void test() endpoint, in_flags, receive_handler()); socket1.async_receive_from(null_buffers(), endpoint, in_flags, receive_handler()); + socket1.async_receive_from(buffer(mutable_char_buffer), + endpoint, immediate); + socket1.async_receive_from(null_buffers(), + endpoint, immediate); + socket1.async_receive_from(buffer(mutable_char_buffer), + endpoint, in_flags, immediate); + socket1.async_receive_from(null_buffers(), + endpoint, in_flags, immediate); int i25 = socket1.async_receive_from(buffer(mutable_char_buffer), endpoint, lazy); (void)i25; @@ -479,20 +452,6 @@ void test() int i28 = socket1.async_receive_from(null_buffers(), endpoint, in_flags, lazy); (void)i28; -#if !defined(ASIO_NO_DEPRECATED) - double d25 = socket1.async_receive_from(buffer(mutable_char_buffer), - endpoint, dlazy); - (void)d25; - double d26 = socket1.async_receive_from(null_buffers(), - endpoint, dlazy); - (void)d26; - double d27 = socket1.async_receive_from(buffer(mutable_char_buffer), - endpoint, in_flags, dlazy); - (void)d27; - double d28 = socket1.async_receive_from(null_buffers(), - endpoint, in_flags, dlazy); - (void)d28; -#endif // !defined(ASIO_NO_DEPRECATED) } catch (std::exception&) { @@ -515,11 +474,9 @@ struct resolve_handler resolve_handler() {} void operator()(const asio::error_code&, asio::ip::icmp::resolver::results_type) {} -#if defined(ASIO_HAS_MOVE) resolve_handler(resolve_handler&&) {} private: resolve_handler(const resolve_handler&); -#endif // defined(ASIO_HAS_MOVE) }; void test() @@ -530,10 +487,8 @@ void test() try { io_context ioc; + const io_context::executor_type ioc_ex = ioc.get_executor(); archetypes::lazy_handler lazy; -#if !defined(ASIO_NO_DEPRECATED) - archetypes::deprecated_lazy_handler dlazy; -#endif // !defined(ASIO_NO_DEPRECATED) asio::error_code ec; #if !defined(ASIO_NO_DEPRECATED) ip::icmp::resolver::query q(ip::icmp::v4(), "localhost", "0"); @@ -543,25 +498,17 @@ void test() // basic_resolver constructors. ip::icmp::resolver resolver(ioc); + ip::icmp::resolver resolver2(ioc_ex); -#if defined(ASIO_HAS_MOVE) - ip::icmp::resolver resolver2(std::move(resolver)); -#endif // defined(ASIO_HAS_MOVE) + ip::icmp::resolver resolver3(std::move(resolver)); // basic_resolver operators. -#if defined(ASIO_HAS_MOVE) resolver = ip::icmp::resolver(ioc); - resolver = std::move(resolver2); -#endif // defined(ASIO_HAS_MOVE) + resolver = std::move(resolver3); // basic_io_object functions. -#if !defined(ASIO_NO_DEPRECATED) - io_context& ioc_ref = resolver.get_io_context(); - (void)ioc_ref; -#endif // !defined(ASIO_NO_DEPRECATED) - ip::icmp::resolver::executor_type ex = resolver.get_executor(); (void)ex; @@ -617,55 +564,30 @@ void test() resolver.async_resolve(q, resolve_handler()); int i1 = resolver.async_resolve(q, lazy); (void)i1; - double d1 = resolver.async_resolve(q, dlazy); - (void)d1; #endif // !defined(ASIO_NO_DEPRECATED) resolver.async_resolve("", "", resolve_handler()); int i2 = resolver.async_resolve("", "", lazy); (void)i2; -#if !defined(ASIO_NO_DEPRECATED) - double d2 = resolver.async_resolve("", "", dlazy); - (void)d2; -#endif // !defined(ASIO_NO_DEPRECATED) resolver.async_resolve("", "", ip::icmp::resolver::flags(), resolve_handler()); int i3 = resolver.async_resolve("", "", ip::icmp::resolver::flags(), lazy); (void)i3; -#if !defined(ASIO_NO_DEPRECATED) - double d3 = resolver.async_resolve("", "", - ip::icmp::resolver::flags(), dlazy); - (void)d3; -#endif // !defined(ASIO_NO_DEPRECATED) - resolver.async_resolve(ip::icmp::v4(), "", "", resolve_handler()); int i4 = resolver.async_resolve(ip::icmp::v4(), "", "", lazy); (void)i4; -#if !defined(ASIO_NO_DEPRECATED) - double d4 = resolver.async_resolve(ip::icmp::v4(), "", "", dlazy); - (void)d4; -#endif // !defined(ASIO_NO_DEPRECATED) resolver.async_resolve(ip::icmp::v4(), "", "", ip::icmp::resolver::flags(), resolve_handler()); int i5 = resolver.async_resolve(ip::icmp::v4(), "", "", ip::icmp::resolver::flags(), lazy); (void)i5; -#if !defined(ASIO_NO_DEPRECATED) - double d5 = resolver.async_resolve(ip::icmp::v4(), - "", "", ip::icmp::resolver::flags(), dlazy); - (void)d5; -#endif // !defined(ASIO_NO_DEPRECATED) resolver.async_resolve(e, resolve_handler()); int i6 = resolver.async_resolve(e, lazy); (void)i6; -#if !defined(ASIO_NO_DEPRECATED) - double d6 = resolver.async_resolve(e, dlazy); - (void)d6; -#endif // !defined(ASIO_NO_DEPRECATED) } catch (std::exception&) { @@ -679,6 +601,6 @@ void test() ASIO_TEST_SUITE ( "ip/icmp", - ASIO_TEST_CASE(ip_icmp_socket_compile::test) - ASIO_TEST_CASE(ip_icmp_resolver_compile::test) + ASIO_COMPILE_TEST_CASE(ip_icmp_socket_compile::test) + ASIO_COMPILE_TEST_CASE(ip_icmp_resolver_compile::test) ) diff --git a/3rdparty/asio/src/tests/unit/ip/multicast.cpp b/3rdparty/asio/src/tests/unit/ip/multicast.cpp index a3cff0b778b..4f0b3f45e14 100644 --- a/3rdparty/asio/src/tests/unit/ip/multicast.cpp +++ b/3rdparty/asio/src/tests/unit/ip/multicast.cpp @@ -2,7 +2,7 @@ // multicast.cpp // ~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -358,6 +358,6 @@ void test() ASIO_TEST_SUITE ( "ip/multicast", - ASIO_TEST_CASE(ip_multicast_compile::test) + ASIO_COMPILE_TEST_CASE(ip_multicast_compile::test) ASIO_TEST_CASE(ip_multicast_runtime::test) ) diff --git a/3rdparty/asio/src/tests/unit/ip/network_v4.cpp b/3rdparty/asio/src/tests/unit/ip/network_v4.cpp index 7d07ffd6928..0b7a7a9c783 100644 --- a/3rdparty/asio/src/tests/unit/ip/network_v4.cpp +++ b/3rdparty/asio/src/tests/unit/ip/network_v4.cpp @@ -2,7 +2,7 @@ // network_v4.cpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // Copyright (c) 2014 Oliver Kowalke (oliver dot kowalke at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -95,15 +95,15 @@ void test() net1 = ip::make_network_v4("10.0.0.0/8", ec); net1 = ip::make_network_v4(s1); net1 = ip::make_network_v4(s1, ec); -#if defined(ASIO_HAS_STD_STRING_VIEW) -# if defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW) - std::experimental::string_view string_view_value("10.0.0.0/8"); -# else // defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW) +#if defined(ASIO_HAS_STRING_VIEW) +# if defined(ASIO_HAS_STD_STRING_VIEW) std::string_view string_view_value("10.0.0.0/8"); +# elif defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW) + std::experimental::string_view string_view_value("10.0.0.0/8"); # endif // defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW) net1 = ip::make_network_v4(string_view_value); net1 = ip::make_network_v4(string_view_value, ec); -#endif // defined(ASIO_HAS_STD_STRING_VIEW) +#endif // defined(ASIO_HAS_STRING_VIEW) // network_v4 I/O. @@ -220,6 +220,19 @@ void test() ASIO_CHECK(make_network_v4("192.168.77.100/24").network() == make_address_v4("192.168.77.0")); ASIO_CHECK(make_network_v4("192.168.77.128/25").network() == make_address_v4("192.168.77.128")); + // construct network from invalid string + asio::error_code ec; + make_network_v4("10.0.0.256/24", ec); + ASIO_CHECK(!!ec); + make_network_v4("10.0.0.0/33", ec); + ASIO_CHECK(!!ec); + make_network_v4("10.0.0.0/-1", ec); + ASIO_CHECK(!!ec); + make_network_v4("10.0.0.0/", ec); + ASIO_CHECK(!!ec); + make_network_v4("10.0.0.0", ec); + ASIO_CHECK(!!ec); + // prefix length ASIO_CHECK(make_network_v4("193.99.144.80/24").prefix_length() == 24); ASIO_CHECK(network_v4(make_address_v4("193.99.144.80"), 24).prefix_length() == 24); @@ -296,6 +309,6 @@ void test() ASIO_TEST_SUITE ( "ip/network_v4", - ASIO_TEST_CASE(ip_network_v4_compile::test) + ASIO_COMPILE_TEST_CASE(ip_network_v4_compile::test) ASIO_TEST_CASE(ip_network_v4_runtime::test) ) diff --git a/3rdparty/asio/src/tests/unit/ip/network_v6.cpp b/3rdparty/asio/src/tests/unit/ip/network_v6.cpp index c7e458f08f1..d80b1d447b6 100644 --- a/3rdparty/asio/src/tests/unit/ip/network_v6.cpp +++ b/3rdparty/asio/src/tests/unit/ip/network_v6.cpp @@ -2,7 +2,7 @@ // network_v6.cpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // Copyright (c) 2014 Oliver Kowalke (oliver dot kowalke at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -87,15 +87,15 @@ void test() net1 = ip::make_network_v6("10.0.0.0/8", ec); net1 = ip::make_network_v6(s1); net1 = ip::make_network_v6(s1, ec); -#if defined(ASIO_HAS_STD_STRING_VIEW) -# if defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW) - std::experimental::string_view string_view_value("0::0/8"); -# else // defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW) +#if defined(ASIO_HAS_STRING_VIEW) +# if defined(ASIO_HAS_STD_STRING_VIEW) std::string_view string_view_value("0::0/8"); +# elif defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW) + std::experimental::string_view string_view_value("0::0/8"); # endif // defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW) net1 = ip::make_network_v6(string_view_value); net1 = ip::make_network_v6(string_view_value, ec); -#endif // defined(ASIO_HAS_STD_STRING_VIEW) +#endif // defined(ASIO_STD_STRING_VIEW) // network_v6 I/O. @@ -153,6 +153,19 @@ void test() ASIO_CHECK(make_network_v6("2001:370::10:7344/64").network() == make_address_v6("2001:370::")); ASIO_CHECK(make_network_v6("2001:370::10:7344/27").network() == make_address_v6("2001:360::")); + // construct network from invalid string + asio::error_code ec; + make_network_v6("a:b/24", ec); + ASIO_CHECK(!!ec); + make_network_v6("2001:370::10:7344/129", ec); + ASIO_CHECK(!!ec); + make_network_v6("2001:370::10:7344/-1", ec); + ASIO_CHECK(!!ec); + make_network_v6("2001:370::10:7344/", ec); + ASIO_CHECK(!!ec); + make_network_v6("2001:370::10:7344", ec); + ASIO_CHECK(!!ec); + // prefix length ASIO_CHECK(make_network_v6("2001:370::10:7344/128").prefix_length() == 128); ASIO_CHECK(network_v6(make_address_v6("2001:370::10:7344"), 27).prefix_length() == 27); @@ -220,6 +233,6 @@ void test() ASIO_TEST_SUITE ( "ip/network_v6", - ASIO_TEST_CASE(ip_network_v6_compile::test) + ASIO_COMPILE_TEST_CASE(ip_network_v6_compile::test) ASIO_TEST_CASE(ip_network_v6_runtime::test) ) diff --git a/3rdparty/asio/src/tests/unit/ip/resolver_query_base.cpp b/3rdparty/asio/src/tests/unit/ip/resolver_query_base.cpp index d9bbd325583..b38f5091b53 100644 --- a/3rdparty/asio/src/tests/unit/ip/resolver_query_base.cpp +++ b/3rdparty/asio/src/tests/unit/ip/resolver_query_base.cpp @@ -2,7 +2,7 @@ // resolver_query_base.cpp // ~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/ip/tcp.cpp b/3rdparty/asio/src/tests/unit/ip/tcp.cpp index 22cee2aa042..2bbdc3a1071 100644 --- a/3rdparty/asio/src/tests/unit/ip/tcp.cpp +++ b/3rdparty/asio/src/tests/unit/ip/tcp.cpp @@ -2,7 +2,7 @@ // tcp.cpp // ~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -20,12 +20,12 @@ #include "asio/ip/tcp.hpp" #include <cstring> +#include <functional> #include "asio/io_context.hpp" #include "asio/read.hpp" #include "asio/write.hpp" #include "../unit_test.hpp" #include "../archetypes/async_result.hpp" -#include "../archetypes/deprecated_async_result.hpp" #include "../archetypes/gettable_socket_option.hpp" #include "../archetypes/io_control_command.hpp" #include "../archetypes/settable_socket_option.hpp" @@ -36,12 +36,6 @@ # include <array> #endif // defined(ASIO_HAS_BOOST_ARRAY) -#if defined(ASIO_HAS_BOOST_BIND) -# include <boost/bind.hpp> -#else // defined(ASIO_HAS_BOOST_BIND) -# include <functional> -#endif // defined(ASIO_HAS_BOOST_BIND) - //------------------------------------------------------------------------------ // ip_tcp_compile test @@ -71,6 +65,9 @@ void test() (void)static_cast<bool>(no_delay1); (void)static_cast<bool>(!no_delay1); (void)static_cast<bool>(no_delay1.value()); + + ip::tcp::endpoint ep; + (void)static_cast<std::size_t>(std::hash<ip::tcp::endpoint>()(ep)); } catch (std::exception&) { @@ -142,66 +139,54 @@ struct connect_handler { connect_handler() {} void operator()(const asio::error_code&) {} -#if defined(ASIO_HAS_MOVE) connect_handler(connect_handler&&) {} private: connect_handler(const connect_handler&); -#endif // defined(ASIO_HAS_MOVE) }; struct wait_handler { wait_handler() {} void operator()(const asio::error_code&) {} -#if defined(ASIO_HAS_MOVE) wait_handler(wait_handler&&) {} private: wait_handler(const wait_handler&); -#endif // defined(ASIO_HAS_MOVE) }; struct send_handler { send_handler() {} void operator()(const asio::error_code&, std::size_t) {} -#if defined(ASIO_HAS_MOVE) send_handler(send_handler&&) {} private: send_handler(const send_handler&); -#endif // defined(ASIO_HAS_MOVE) }; struct receive_handler { receive_handler() {} void operator()(const asio::error_code&, std::size_t) {} -#if defined(ASIO_HAS_MOVE) receive_handler(receive_handler&&) {} private: receive_handler(const receive_handler&); -#endif // defined(ASIO_HAS_MOVE) }; struct write_some_handler { write_some_handler() {} void operator()(const asio::error_code&, std::size_t) {} -#if defined(ASIO_HAS_MOVE) write_some_handler(write_some_handler&&) {} private: write_some_handler(const write_some_handler&); -#endif // defined(ASIO_HAS_MOVE) }; struct read_some_handler { read_some_handler() {} void operator()(const asio::error_code&, std::size_t) {} -#if defined(ASIO_HAS_MOVE) read_some_handler(read_some_handler&&) {} private: read_some_handler(const read_some_handler&); -#endif // defined(ASIO_HAS_MOVE) }; void test() @@ -218,6 +203,7 @@ void test() try { io_context ioc; + const io_context::executor_type ioc_ex = ioc.get_executor(); char mutable_char_buffer[128] = ""; const char const_char_buffer[128] = ""; array<asio::mutable_buffer, 2> mutable_buffers = {{ @@ -234,10 +220,8 @@ void test() archetypes::gettable_socket_option<int> gettable_socket_option2; archetypes::gettable_socket_option<double> gettable_socket_option3; archetypes::io_control_command io_control_command; + archetypes::immediate_handler immediate; archetypes::lazy_handler lazy; -#if !defined(ASIO_NO_DEPRECATED) - archetypes::deprecated_lazy_handler dlazy; -#endif // !defined(ASIO_NO_DEPRECATED) asio::error_code ec; // basic_stream_socket constructors. @@ -253,24 +237,26 @@ void test() ip::tcp::socket socket6(ioc, ip::tcp::v4(), native_socket1); #endif // !defined(ASIO_WINDOWS_RUNTIME) -#if defined(ASIO_HAS_MOVE) - ip::tcp::socket socket7(std::move(socket5)); -#endif // defined(ASIO_HAS_MOVE) + ip::tcp::socket socket7(ioc_ex); + ip::tcp::socket socket8(ioc_ex, ip::tcp::v4()); + ip::tcp::socket socket9(ioc_ex, ip::tcp::v6()); + ip::tcp::socket socket10(ioc_ex, ip::tcp::endpoint(ip::tcp::v4(), 0)); + ip::tcp::socket socket11(ioc_ex, ip::tcp::endpoint(ip::tcp::v6(), 0)); +#if !defined(ASIO_WINDOWS_RUNTIME) + ip::tcp::socket::native_handle_type native_socket2 + = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + ip::tcp::socket socket12(ioc_ex, ip::tcp::v4(), native_socket2); +#endif // !defined(ASIO_WINDOWS_RUNTIME) + + ip::tcp::socket socket13(std::move(socket5)); // basic_stream_socket operators. -#if defined(ASIO_HAS_MOVE) socket1 = ip::tcp::socket(ioc); socket1 = std::move(socket2); -#endif // defined(ASIO_HAS_MOVE) // basic_io_object functions. -#if !defined(ASIO_NO_DEPRECATED) - io_context& ioc_ref = socket1.get_io_context(); - (void)ioc_ref; -#endif // !defined(ASIO_NO_DEPRECATED) - ip::tcp::socket::executor_type ex = socket1.get_executor(); (void)ex; @@ -279,9 +265,9 @@ void test() ip::tcp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer(); (void)lowest_layer; - const ip::tcp::socket& socket8 = socket1; + const ip::tcp::socket& socket14 = socket1; const ip::tcp::socket::lowest_layer_type& lowest_layer2 - = socket8.lowest_layer(); + = socket14.lowest_layer(); (void)lowest_layer2; socket1.open(ip::tcp::v4()); @@ -290,12 +276,12 @@ void test() socket1.open(ip::tcp::v6(), ec); #if !defined(ASIO_WINDOWS_RUNTIME) - ip::tcp::socket::native_handle_type native_socket2 - = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - socket1.assign(ip::tcp::v4(), native_socket2); ip::tcp::socket::native_handle_type native_socket3 = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - socket1.assign(ip::tcp::v4(), native_socket3, ec); + socket1.assign(ip::tcp::v4(), native_socket3); + ip::tcp::socket::native_handle_type native_socket4 + = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + socket1.assign(ip::tcp::v4(), native_socket4, ec); #endif // !defined(ASIO_WINDOWS_RUNTIME) bool is_open = socket1.is_open(); @@ -304,9 +290,12 @@ void test() socket1.close(); socket1.close(ec); - ip::tcp::socket::native_handle_type native_socket4 + socket1.release(); + socket1.release(ec); + + ip::tcp::socket::native_handle_type native_socket5 = socket1.native_handle(); - (void)native_socket4; + (void)native_socket5; socket1.cancel(); socket1.cancel(ec); @@ -335,18 +324,12 @@ void test() connect_handler()); socket1.async_connect(ip::tcp::endpoint(ip::tcp::v6(), 0), connect_handler()); + socket1.async_connect(ip::tcp::endpoint(ip::tcp::v4(), 0), immediate); + socket1.async_connect(ip::tcp::endpoint(ip::tcp::v6(), 0), immediate); int i1 = socket1.async_connect(ip::tcp::endpoint(ip::tcp::v4(), 0), lazy); (void)i1; int i2 = socket1.async_connect(ip::tcp::endpoint(ip::tcp::v6(), 0), lazy); (void)i2; -#if !defined(ASIO_NO_DEPRECATED) - double d1 = socket1.async_connect( - ip::tcp::endpoint(ip::tcp::v4(), 0), dlazy); - (void)d1; - double d2 = socket1.async_connect( - ip::tcp::endpoint(ip::tcp::v6(), 0), dlazy); - (void)d2; -#endif // !defined(ASIO_NO_DEPRECATED) socket1.set_option(settable_socket_option1); socket1.set_option(settable_socket_option1, ec); @@ -376,10 +359,14 @@ void test() socket1.native_non_blocking(false, ec); ip::tcp::endpoint endpoint1 = socket1.local_endpoint(); + (void)endpoint1; ip::tcp::endpoint endpoint2 = socket1.local_endpoint(ec); + (void)endpoint2; ip::tcp::endpoint endpoint3 = socket1.remote_endpoint(); + (void)endpoint3; ip::tcp::endpoint endpoint4 = socket1.remote_endpoint(ec); + (void)endpoint4; socket1.shutdown(socket_base::shutdown_both); socket1.shutdown(socket_base::shutdown_both, ec); @@ -388,12 +375,9 @@ void test() socket1.wait(socket_base::wait_write, ec); socket1.async_wait(socket_base::wait_read, wait_handler()); + socket1.async_wait(socket_base::wait_read, immediate); int i3 = socket1.async_wait(socket_base::wait_write, lazy); (void)i3; -#if !defined(ASIO_NO_DEPRECATED) - double d3 = socket1.async_wait(socket_base::wait_write, dlazy); - (void)d3; -#endif // !defined(ASIO_NO_DEPRECATED) // basic_stream_socket functions. @@ -423,6 +407,16 @@ void test() socket1.async_send(mutable_buffers, in_flags, send_handler()); socket1.async_send(const_buffers, in_flags, send_handler()); socket1.async_send(null_buffers(), in_flags, send_handler()); + socket1.async_send(buffer(mutable_char_buffer), immediate); + socket1.async_send(buffer(const_char_buffer), immediate); + socket1.async_send(mutable_buffers, immediate); + socket1.async_send(const_buffers, immediate); + socket1.async_send(null_buffers(), immediate); + socket1.async_send(buffer(mutable_char_buffer), in_flags, immediate); + socket1.async_send(buffer(const_char_buffer), in_flags, immediate); + socket1.async_send(mutable_buffers, in_flags, immediate); + socket1.async_send(const_buffers, in_flags, immediate); + socket1.async_send(null_buffers(), in_flags, immediate); int i4 = socket1.async_send(buffer(mutable_char_buffer), lazy); (void)i4; int i5 = socket1.async_send(buffer(const_char_buffer), lazy); @@ -443,29 +437,6 @@ void test() (void)i12; int i13 = socket1.async_send(null_buffers(), in_flags, lazy); (void)i13; -#if !defined(ASIO_NO_DEPRECATED) - double d4 = socket1.async_send(buffer(mutable_char_buffer), dlazy); - (void)d4; - double d5 = socket1.async_send(buffer(const_char_buffer), dlazy); - (void)d5; - double d6 = socket1.async_send(mutable_buffers, dlazy); - (void)d6; - double d7 = socket1.async_send(const_buffers, dlazy); - (void)d7; - double d8 = socket1.async_send(null_buffers(), dlazy); - (void)d8; - double d9 = socket1.async_send( - buffer(mutable_char_buffer), in_flags, dlazy); - (void)d9; - double d10 = socket1.async_send(buffer(const_char_buffer), in_flags, dlazy); - (void)d10; - double d11 = socket1.async_send(mutable_buffers, in_flags, dlazy); - (void)d11; - double d12 = socket1.async_send(const_buffers, in_flags, dlazy); - (void)d12; - double d13 = socket1.async_send(null_buffers(), in_flags, dlazy); - (void)d13; -#endif // !defined(ASIO_NO_DEPRECATED) socket1.receive(buffer(mutable_char_buffer)); socket1.receive(mutable_buffers); @@ -484,6 +455,12 @@ void test() receive_handler()); socket1.async_receive(mutable_buffers, in_flags, receive_handler()); socket1.async_receive(null_buffers(), in_flags, receive_handler()); + socket1.async_receive(buffer(mutable_char_buffer), immediate); + socket1.async_receive(mutable_buffers, immediate); + socket1.async_receive(null_buffers(), immediate); + socket1.async_receive(buffer(mutable_char_buffer), in_flags, immediate); + socket1.async_receive(mutable_buffers, in_flags, immediate); + socket1.async_receive(null_buffers(), in_flags, immediate); int i14 = socket1.async_receive(buffer(mutable_char_buffer), lazy); (void)i14; int i15 = socket1.async_receive(mutable_buffers, lazy); @@ -497,21 +474,6 @@ void test() (void)i18; int i19 = socket1.async_receive(null_buffers(), in_flags, lazy); (void)i19; -#if !defined(ASIO_NO_DEPRECATED) - double d14 = socket1.async_receive(buffer(mutable_char_buffer), dlazy); - (void)d14; - double d15 = socket1.async_receive(mutable_buffers, dlazy); - (void)d15; - double d16 = socket1.async_receive(null_buffers(), dlazy); - (void)d16; - double d17 = socket1.async_receive(buffer(mutable_char_buffer), in_flags, - dlazy); - (void)d17; - double d18 = socket1.async_receive(mutable_buffers, in_flags, dlazy); - (void)d18; - double d19 = socket1.async_receive(null_buffers(), in_flags, dlazy); - (void)d19; -#endif // !defined(ASIO_NO_DEPRECATED) socket1.write_some(buffer(mutable_char_buffer)); socket1.write_some(buffer(const_char_buffer)); @@ -529,6 +491,11 @@ void test() socket1.async_write_some(mutable_buffers, write_some_handler()); socket1.async_write_some(const_buffers, write_some_handler()); socket1.async_write_some(null_buffers(), write_some_handler()); + socket1.async_write_some(buffer(mutable_char_buffer), immediate); + socket1.async_write_some(buffer(const_char_buffer), immediate); + socket1.async_write_some(mutable_buffers, immediate); + socket1.async_write_some(const_buffers, immediate); + socket1.async_write_some(null_buffers(), immediate); int i20 = socket1.async_write_some(buffer(mutable_char_buffer), lazy); (void)i20; int i21 = socket1.async_write_some(buffer(const_char_buffer), lazy); @@ -539,18 +506,6 @@ void test() (void)i23; int i24 = socket1.async_write_some(null_buffers(), lazy); (void)i24; -#if !defined(ASIO_NO_DEPRECATED) - double d20 = socket1.async_write_some(buffer(mutable_char_buffer), dlazy); - (void)d20; - double d21 = socket1.async_write_some(buffer(const_char_buffer), dlazy); - (void)d21; - double d22 = socket1.async_write_some(mutable_buffers, dlazy); - (void)d22; - double d23 = socket1.async_write_some(const_buffers, dlazy); - (void)d23; - double d24 = socket1.async_write_some(null_buffers(), dlazy); - (void)d24; -#endif // !defined(ASIO_NO_DEPRECATED) socket1.read_some(buffer(mutable_char_buffer)); socket1.read_some(mutable_buffers); @@ -562,20 +517,15 @@ void test() socket1.async_read_some(buffer(mutable_char_buffer), read_some_handler()); socket1.async_read_some(mutable_buffers, read_some_handler()); socket1.async_read_some(null_buffers(), read_some_handler()); + socket1.async_read_some(buffer(mutable_char_buffer), immediate); + socket1.async_read_some(mutable_buffers, immediate); + socket1.async_read_some(null_buffers(), immediate); int i25 = socket1.async_read_some(buffer(mutable_char_buffer), lazy); (void)i25; int i26 = socket1.async_read_some(mutable_buffers, lazy); (void)i26; int i27 = socket1.async_read_some(null_buffers(), lazy); (void)i27; -#if !defined(ASIO_NO_DEPRECATED) - double d25 = socket1.async_read_some(buffer(mutable_char_buffer), dlazy); - (void)d25; - double d26 = socket1.async_read_some(mutable_buffers, dlazy); - (void)d26; - double d27 = socket1.async_read_some(null_buffers(), dlazy); - (void)d27; -#endif // !defined(ASIO_NO_DEPRECATED) } catch (std::exception&) { @@ -649,13 +599,9 @@ void test() using namespace asio; namespace ip = asio::ip; -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; io_context ioc; @@ -761,25 +707,20 @@ struct wait_handler { wait_handler() {} void operator()(const asio::error_code&) {} -#if defined(ASIO_HAS_MOVE) wait_handler(wait_handler&&) {} private: wait_handler(const wait_handler&); -#endif // defined(ASIO_HAS_MOVE) }; struct accept_handler { accept_handler() {} void operator()(const asio::error_code&) {} -#if defined(ASIO_HAS_MOVE) accept_handler(accept_handler&&) {} private: accept_handler(const accept_handler&); -#endif // defined(ASIO_HAS_MOVE) }; -#if defined(ASIO_HAS_MOVE) struct move_accept_handler { move_accept_handler() {} @@ -789,7 +730,17 @@ struct move_accept_handler private: move_accept_handler(const move_accept_handler&) {} }; -#endif // defined(ASIO_HAS_MOVE) + +struct move_accept_ioc_handler +{ + move_accept_ioc_handler() {} + void operator()(const asio::error_code&, + asio::basic_stream_socket<asio::ip::tcp, + asio::io_context::executor_type>) {} + move_accept_ioc_handler(move_accept_handler&&) {} +private: + move_accept_ioc_handler(const move_accept_handler&) {} +}; void test() { @@ -799,7 +750,10 @@ void test() try { io_context ioc; - ip::tcp::socket peer_socket(ioc); + const io_context::executor_type ioc_ex = ioc.get_executor(); + ip::tcp::socket peer_socket1(ioc); + asio::basic_stream_socket<ip::tcp, + io_context::executor_type> peer_socket2(ioc); ip::tcp::endpoint peer_endpoint; archetypes::settable_socket_option<void> settable_socket_option1; archetypes::settable_socket_option<int> settable_socket_option2; @@ -808,10 +762,8 @@ void test() archetypes::gettable_socket_option<int> gettable_socket_option2; archetypes::gettable_socket_option<double> gettable_socket_option3; archetypes::io_control_command io_control_command; + archetypes::immediate_handler immediate; archetypes::lazy_handler lazy; -#if !defined(ASIO_NO_DEPRECATED) - archetypes::deprecated_lazy_handler dlazy; -#endif // !defined(ASIO_NO_DEPRECATED) asio::error_code ec; // basic_socket_acceptor constructors. @@ -827,24 +779,26 @@ void test() ip::tcp::acceptor acceptor6(ioc, ip::tcp::v4(), native_acceptor1); #endif // !defined(ASIO_WINDOWS_RUNTIME) -#if defined(ASIO_HAS_MOVE) - ip::tcp::acceptor acceptor7(std::move(acceptor5)); -#endif // defined(ASIO_HAS_MOVE) + ip::tcp::acceptor acceptor7(ioc_ex); + ip::tcp::acceptor acceptor8(ioc_ex, ip::tcp::v4()); + ip::tcp::acceptor acceptor9(ioc_ex, ip::tcp::v6()); + ip::tcp::acceptor acceptor10(ioc_ex, ip::tcp::endpoint(ip::tcp::v4(), 0)); + ip::tcp::acceptor acceptor11(ioc_ex, ip::tcp::endpoint(ip::tcp::v6(), 0)); +#if !defined(ASIO_WINDOWS_RUNTIME) + ip::tcp::acceptor::native_handle_type native_acceptor2 + = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + ip::tcp::acceptor acceptor12(ioc_ex, ip::tcp::v4(), native_acceptor2); +#endif // !defined(ASIO_WINDOWS_RUNTIME) + + ip::tcp::acceptor acceptor13(std::move(acceptor5)); // basic_socket_acceptor operators. -#if defined(ASIO_HAS_MOVE) acceptor1 = ip::tcp::acceptor(ioc); acceptor1 = std::move(acceptor2); -#endif // defined(ASIO_HAS_MOVE) // basic_io_object functions. -#if !defined(ASIO_NO_DEPRECATED) - io_context& ioc_ref = acceptor1.get_io_context(); - (void)ioc_ref; -#endif // !defined(ASIO_NO_DEPRECATED) - ip::tcp::acceptor::executor_type ex = acceptor1.get_executor(); (void)ex; @@ -856,12 +810,12 @@ void test() acceptor1.open(ip::tcp::v6(), ec); #if !defined(ASIO_WINDOWS_RUNTIME) - ip::tcp::acceptor::native_handle_type native_acceptor2 - = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - acceptor1.assign(ip::tcp::v4(), native_acceptor2); ip::tcp::acceptor::native_handle_type native_acceptor3 = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - acceptor1.assign(ip::tcp::v4(), native_acceptor3, ec); + acceptor1.assign(ip::tcp::v4(), native_acceptor3); + ip::tcp::acceptor::native_handle_type native_acceptor4 + = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + acceptor1.assign(ip::tcp::v4(), native_acceptor4, ec); #endif // !defined(ASIO_WINDOWS_RUNTIME) bool is_open = acceptor1.is_open(); @@ -870,9 +824,12 @@ void test() acceptor1.close(); acceptor1.close(ec); - ip::tcp::acceptor::native_handle_type native_acceptor4 + acceptor1.release(); + acceptor1.release(ec); + + ip::tcp::acceptor::native_handle_type native_acceptor5 = acceptor1.native_handle(); - (void)native_acceptor4; + (void)native_acceptor5; acceptor1.cancel(); acceptor1.cancel(ec); @@ -910,51 +867,74 @@ void test() acceptor1.native_non_blocking(false, ec); ip::tcp::endpoint endpoint1 = acceptor1.local_endpoint(); + (void)endpoint1; ip::tcp::endpoint endpoint2 = acceptor1.local_endpoint(ec); + (void)endpoint2; acceptor1.wait(socket_base::wait_read); acceptor1.wait(socket_base::wait_write, ec); acceptor1.async_wait(socket_base::wait_read, wait_handler()); + acceptor1.async_wait(socket_base::wait_read, immediate); int i1 = acceptor1.async_wait(socket_base::wait_write, lazy); (void)i1; -#if !defined(ASIO_NO_DEPRECATED) - double d1 = acceptor1.async_wait(socket_base::wait_write, dlazy); - (void)d1; -#endif // !defined(ASIO_NO_DEPRECATED) - acceptor1.accept(peer_socket); - acceptor1.accept(peer_socket, ec); - acceptor1.accept(peer_socket, peer_endpoint); - acceptor1.accept(peer_socket, peer_endpoint, ec); - -#if defined(ASIO_HAS_MOVE) - peer_socket = acceptor1.accept(); - peer_socket = acceptor1.accept(ioc); - peer_socket = acceptor1.accept(peer_endpoint); - peer_socket = acceptor1.accept(ioc, peer_endpoint); - (void)peer_socket; -#endif // defined(ASIO_HAS_MOVE) - - acceptor1.async_accept(peer_socket, accept_handler()); - acceptor1.async_accept(peer_socket, peer_endpoint, accept_handler()); - int i2 = acceptor1.async_accept(peer_socket, lazy); + acceptor1.accept(peer_socket1); + acceptor1.accept(peer_socket1, ec); + acceptor1.accept(peer_socket1, peer_endpoint); + acceptor1.accept(peer_socket1, peer_endpoint, ec); + + acceptor1.accept(peer_socket2); + acceptor1.accept(peer_socket2, ec); + acceptor1.accept(peer_socket2, peer_endpoint); + acceptor1.accept(peer_socket2, peer_endpoint, ec); + + peer_socket1 = acceptor1.accept(); + peer_socket1 = acceptor1.accept(ioc); + peer_socket1 = acceptor1.accept(ioc_ex); + peer_socket1 = acceptor1.accept(peer_endpoint); + peer_socket1 = acceptor1.accept(ioc, peer_endpoint); + peer_socket1 = acceptor1.accept(ioc_ex, peer_endpoint); + (void)peer_socket1; + + peer_socket2 = acceptor1.accept(ioc); + peer_socket2 = acceptor1.accept(ioc_ex); + peer_socket2 = acceptor1.accept(ioc, peer_endpoint); + peer_socket2 = acceptor1.accept(ioc_ex, peer_endpoint); + (void)peer_socket2; + + acceptor1.async_accept(peer_socket1, accept_handler()); + acceptor1.async_accept(peer_socket1, peer_endpoint, accept_handler()); + acceptor1.async_accept(peer_socket1, immediate); + acceptor1.async_accept(peer_socket1, peer_endpoint, immediate); + int i2 = acceptor1.async_accept(peer_socket1, lazy); (void)i2; - int i3 = acceptor1.async_accept(peer_socket, peer_endpoint, lazy); + int i3 = acceptor1.async_accept(peer_socket1, peer_endpoint, lazy); (void)i3; -#if !defined(ASIO_NO_DEPRECATED) - double d2 = acceptor1.async_accept(peer_socket, dlazy); - (void)d2; - double d3 = acceptor1.async_accept(peer_socket, peer_endpoint, dlazy); - (void)d3; -#endif // !defined(ASIO_NO_DEPRECATED) -#if defined(ASIO_HAS_MOVE) + acceptor1.async_accept(peer_socket2, accept_handler()); + acceptor1.async_accept(peer_socket2, peer_endpoint, accept_handler()); + acceptor1.async_accept(peer_socket2, immediate); + acceptor1.async_accept(peer_socket2, peer_endpoint, immediate); + int i4 = acceptor1.async_accept(peer_socket2, lazy); + (void)i4; + int i5 = acceptor1.async_accept(peer_socket2, peer_endpoint, lazy); + (void)i5; + acceptor1.async_accept(move_accept_handler()); acceptor1.async_accept(ioc, move_accept_handler()); + acceptor1.async_accept(ioc_ex, move_accept_handler()); + acceptor1.async_accept(ioc_ex, move_accept_ioc_handler()); acceptor1.async_accept(peer_endpoint, move_accept_handler()); acceptor1.async_accept(ioc, peer_endpoint, move_accept_handler()); -#endif // defined(ASIO_HAS_MOVE) + acceptor1.async_accept(ioc_ex, peer_endpoint, move_accept_handler()); + acceptor1.async_accept(ioc_ex, peer_endpoint, move_accept_ioc_handler()); + acceptor1.async_accept(immediate); + acceptor1.async_accept(ioc, immediate); + acceptor1.async_accept(ioc_ex, immediate); + acceptor1.async_accept(peer_endpoint, immediate); + acceptor1.async_accept(ioc, peer_endpoint, immediate); + acceptor1.async_accept(ioc_ex, peer_endpoint, immediate); } catch (std::exception&) { @@ -1056,13 +1036,23 @@ struct resolve_handler resolve_handler() {} void operator()(const asio::error_code&, asio::ip::tcp::resolver::results_type) {} -#if defined(ASIO_HAS_MOVE) resolve_handler(resolve_handler&&) {} private: resolve_handler(const resolve_handler&); -#endif // defined(ASIO_HAS_MOVE) }; +#if !defined(ASIO_NO_DEPRECATED) +struct legacy_resolve_handler +{ + legacy_resolve_handler() {} + void operator()(const asio::error_code&, + asio::ip::tcp::resolver::iterator) {} + legacy_resolve_handler(legacy_resolve_handler&&) {} +private: + legacy_resolve_handler(const legacy_resolve_handler&); +}; +#endif // !defined(ASIO_NO_DEPRECATED) + void test() { using namespace asio; @@ -1071,10 +1061,8 @@ void test() try { io_context ioc; + const io_context::executor_type ioc_ex = ioc.get_executor(); archetypes::lazy_handler lazy; -#if !defined(ASIO_NO_DEPRECATED) - archetypes::deprecated_lazy_handler dlazy; -#endif // !defined(ASIO_NO_DEPRECATED) asio::error_code ec; #if !defined(ASIO_NO_DEPRECATED) ip::tcp::resolver::query q(ip::tcp::v4(), "localhost", "0"); @@ -1084,25 +1072,17 @@ void test() // basic_resolver constructors. ip::tcp::resolver resolver(ioc); + ip::tcp::resolver resolver2(ioc_ex); -#if defined(ASIO_HAS_MOVE) - ip::tcp::resolver resolver2(std::move(resolver)); -#endif // defined(ASIO_HAS_MOVE) + ip::tcp::resolver resolver3(std::move(resolver)); // basic_resolver operators. -#if defined(ASIO_HAS_MOVE) resolver = ip::tcp::resolver(ioc); - resolver = std::move(resolver2); -#endif // defined(ASIO_HAS_MOVE) + resolver = std::move(resolver3); // basic_io_object functions. -#if !defined(ASIO_NO_DEPRECATED) - io_context& ioc_ref = resolver.get_io_context(); - (void)ioc_ref; -#endif // !defined(ASIO_NO_DEPRECATED) - ip::tcp::resolver::executor_type ex = resolver.get_executor(); (void)ex; @@ -1156,57 +1136,51 @@ void test() #if !defined(ASIO_NO_DEPRECATED) resolver.async_resolve(q, resolve_handler()); + resolver.async_resolve(q, legacy_resolve_handler()); int i1 = resolver.async_resolve(q, lazy); (void)i1; - double d1 = resolver.async_resolve(q, dlazy); - (void)d1; #endif // !defined(ASIO_NO_DEPRECATED) resolver.async_resolve("", "", resolve_handler()); - int i2 = resolver.async_resolve("", "", lazy); - (void)i2; #if !defined(ASIO_NO_DEPRECATED) - double d2 = resolver.async_resolve("", "", dlazy); - (void)d2; + resolver.async_resolve("", "", legacy_resolve_handler()); #endif // !defined(ASIO_NO_DEPRECATED) + int i2 = resolver.async_resolve("", "", lazy); + (void)i2; resolver.async_resolve("", "", ip::tcp::resolver::flags(), resolve_handler()); +#if !defined(ASIO_NO_DEPRECATED) + resolver.async_resolve("", "", + ip::tcp::resolver::flags(), legacy_resolve_handler()); +#endif // !defined(ASIO_NO_DEPRECATED) int i3 = resolver.async_resolve("", "", ip::tcp::resolver::flags(), lazy); (void)i3; -#if !defined(ASIO_NO_DEPRECATED) - double d3 = resolver.async_resolve("", "", - ip::tcp::resolver::flags(), dlazy); - (void)d3; -#endif // !defined(ASIO_NO_DEPRECATED) resolver.async_resolve(ip::tcp::v4(), "", "", resolve_handler()); - int i4 = resolver.async_resolve(ip::tcp::v4(), "", "", lazy); - (void)i4; #if !defined(ASIO_NO_DEPRECATED) - double d4 = resolver.async_resolve(ip::tcp::v4(), "", "", dlazy); - (void)d4; + resolver.async_resolve(ip::tcp::v4(), "", "", legacy_resolve_handler()); #endif // !defined(ASIO_NO_DEPRECATED) + int i4 = resolver.async_resolve(ip::tcp::v4(), "", "", lazy); + (void)i4; resolver.async_resolve(ip::tcp::v4(), "", "", ip::tcp::resolver::flags(), resolve_handler()); +#if !defined(ASIO_NO_DEPRECATED) + resolver.async_resolve(ip::tcp::v4(), + "", "", ip::tcp::resolver::flags(), legacy_resolve_handler()); +#endif // !defined(ASIO_NO_DEPRECATED) int i5 = resolver.async_resolve(ip::tcp::v4(), "", "", ip::tcp::resolver::flags(), lazy); (void)i5; -#if !defined(ASIO_NO_DEPRECATED) - double d5 = resolver.async_resolve(ip::tcp::v4(), - "", "", ip::tcp::resolver::flags(), dlazy); - (void)d5; -#endif // !defined(ASIO_NO_DEPRECATED) resolver.async_resolve(e, resolve_handler()); - int i6 = resolver.async_resolve(e, lazy); - (void)i6; #if !defined(ASIO_NO_DEPRECATED) - double d6 = resolver.async_resolve(e, dlazy); - (void)d6; + resolver.async_resolve(e, legacy_resolve_handler()); #endif // !defined(ASIO_NO_DEPRECATED) + int i6 = resolver.async_resolve(e, lazy); + (void)i6; } catch (std::exception&) { @@ -1241,9 +1215,7 @@ void test() const ip::basic_resolver_entry<ip::tcp> entry1; ip::basic_resolver_entry<ip::tcp> entry2(endpoint, host_name, service_name); ip::basic_resolver_entry<ip::tcp> entry3(entry1); -#if defined(ASIO_HAS_MOVE) ip::basic_resolver_entry<ip::tcp> entry4(std::move(entry2)); -#endif // defined(ASIO_HAS_MOVE) // basic_resolver_entry functions. @@ -1304,19 +1276,15 @@ void test() ip::tcp::iostream ios1; -#if defined(ASIO_HAS_MOVE) ip::tcp::iostream ios2(std::move(sock)); -#endif // defined(ASIO_HAS_MOVE) ip::tcp::iostream ios3("hostname", "service"); // basic_socket_iostream operators. -#if defined(ASIO_HAS_MOVE) ios1 = ip::tcp::iostream(); ios2 = std::move(ios1); -#endif // defined(ASIO_HAS_MOVE) // basic_socket_iostream members. @@ -1326,14 +1294,10 @@ void test() (void)static_cast<std::streambuf*>(ios1.rdbuf()); -#if defined(ASIO_ENABLE_OLD_SERVICES) - basic_socket<ip::tcp, stream_socket_service<ip::tcp> >& sref = ios1.socket(); -#else // defined(ASIO_ENABLE_OLD_SERVICES) basic_socket<ip::tcp>& sref = ios1.socket(); -#endif // defined(ASIO_ENABLE_OLD_SERVICES) (void)sref; - error_code ec = ios1.error(); + asio::error_code ec = ios1.error(); (void)ec; ip::tcp::iostream::time_point tp = ios1.expiry(); @@ -1341,7 +1305,7 @@ void test() ios1.expires_at(tp); - ip::tcp::iostream::duration d; + ip::tcp::iostream::duration d = ip::tcp::iostream::duration(); ios1.expires_after(d); // iostream operators. @@ -1359,14 +1323,14 @@ void test() ASIO_TEST_SUITE ( "ip/tcp", - ASIO_TEST_CASE(ip_tcp_compile::test) + ASIO_COMPILE_TEST_CASE(ip_tcp_compile::test) ASIO_TEST_CASE(ip_tcp_runtime::test) - ASIO_TEST_CASE(ip_tcp_socket_compile::test) + ASIO_COMPILE_TEST_CASE(ip_tcp_socket_compile::test) ASIO_TEST_CASE(ip_tcp_socket_runtime::test) - ASIO_TEST_CASE(ip_tcp_acceptor_compile::test) + ASIO_COMPILE_TEST_CASE(ip_tcp_acceptor_compile::test) ASIO_TEST_CASE(ip_tcp_acceptor_runtime::test) - ASIO_TEST_CASE(ip_tcp_resolver_compile::test) - ASIO_TEST_CASE(ip_tcp_resolver_entry_compile::test) - ASIO_TEST_CASE(ip_tcp_resolver_entry_compile::test) + ASIO_COMPILE_TEST_CASE(ip_tcp_resolver_compile::test) + ASIO_COMPILE_TEST_CASE(ip_tcp_resolver_entry_compile::test) + ASIO_COMPILE_TEST_CASE(ip_tcp_resolver_entry_compile::test) ASIO_COMPILE_TEST_CASE(ip_tcp_iostream_compile::test) ) diff --git a/3rdparty/asio/src/tests/unit/ip/udp.cpp b/3rdparty/asio/src/tests/unit/ip/udp.cpp index 48f9276ce4b..ae67f9c9c73 100644 --- a/3rdparty/asio/src/tests/unit/ip/udp.cpp +++ b/3rdparty/asio/src/tests/unit/ip/udp.cpp @@ -2,7 +2,7 @@ // udp.cpp // ~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -17,20 +17,14 @@ #include "asio/ip/udp.hpp" #include <cstring> +#include <functional> #include "asio/io_context.hpp" #include "../unit_test.hpp" #include "../archetypes/async_result.hpp" -#include "../archetypes/deprecated_async_result.hpp" #include "../archetypes/gettable_socket_option.hpp" #include "../archetypes/io_control_command.hpp" #include "../archetypes/settable_socket_option.hpp" -#if defined(ASIO_HAS_BOOST_BIND) -# include <boost/bind.hpp> -#else // defined(ASIO_HAS_BOOST_BIND) -# include <functional> -#endif // defined(ASIO_HAS_BOOST_BIND) - //------------------------------------------------------------------------------ // ip_udp_socket_compile test @@ -44,44 +38,36 @@ struct connect_handler { connect_handler() {} void operator()(const asio::error_code&) {} -#if defined(ASIO_HAS_MOVE) connect_handler(connect_handler&&) {} private: connect_handler(const connect_handler&); -#endif // defined(ASIO_HAS_MOVE) }; struct wait_handler { wait_handler() {} void operator()(const asio::error_code&) {} -#if defined(ASIO_HAS_MOVE) wait_handler(wait_handler&&) {} private: wait_handler(const wait_handler&); -#endif // defined(ASIO_HAS_MOVE) }; struct send_handler { send_handler() {} void operator()(const asio::error_code&, std::size_t) {} -#if defined(ASIO_HAS_MOVE) send_handler(send_handler&&) {} private: send_handler(const send_handler&); -#endif // defined(ASIO_HAS_MOVE) }; struct receive_handler { receive_handler() {} void operator()(const asio::error_code&, std::size_t) {} -#if defined(ASIO_HAS_MOVE) receive_handler(receive_handler&&) {} private: receive_handler(const receive_handler&); -#endif // defined(ASIO_HAS_MOVE) }; void test() @@ -92,6 +78,7 @@ void test() try { io_context ioc; + const io_context::executor_type ioc_ex = ioc.get_executor(); char mutable_char_buffer[128] = ""; const char const_char_buffer[128] = ""; socket_base::message_flags in_flags = 0; @@ -102,10 +89,8 @@ void test() archetypes::gettable_socket_option<int> gettable_socket_option2; archetypes::gettable_socket_option<double> gettable_socket_option3; archetypes::io_control_command io_control_command; + archetypes::immediate_handler immediate; archetypes::lazy_handler lazy; -#if !defined(ASIO_NO_DEPRECATED) - archetypes::deprecated_lazy_handler dlazy; -#endif // !defined(ASIO_NO_DEPRECATED) asio::error_code ec; // basic_datagram_socket constructors. @@ -121,24 +106,26 @@ void test() ip::udp::socket socket6(ioc, ip::udp::v4(), native_socket1); #endif // !defined(ASIO_WINDOWS_RUNTIME) -#if defined(ASIO_HAS_MOVE) - ip::udp::socket socket7(std::move(socket6)); -#endif // defined(ASIO_HAS_MOVE) + ip::udp::socket socket7(ioc_ex); + ip::udp::socket socket8(ioc_ex, ip::udp::v4()); + ip::udp::socket socket9(ioc_ex, ip::udp::v6()); + ip::udp::socket socket10(ioc_ex, ip::udp::endpoint(ip::udp::v4(), 0)); + ip::udp::socket socket11(ioc_ex, ip::udp::endpoint(ip::udp::v6(), 0)); +#if !defined(ASIO_WINDOWS_RUNTIME) + ip::udp::socket::native_handle_type native_socket2 + = ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + ip::udp::socket socket12(ioc_ex, ip::udp::v4(), native_socket2); +#endif // !defined(ASIO_WINDOWS_RUNTIME) + + ip::udp::socket socket13(std::move(socket6)); // basic_datagram_socket operators. -#if defined(ASIO_HAS_MOVE) socket1 = ip::udp::socket(ioc); socket1 = std::move(socket2); -#endif // defined(ASIO_HAS_MOVE) // basic_io_object functions. -#if !defined(ASIO_NO_DEPRECATED) - io_context& ioc_ref = socket1.get_io_context(); - (void)ioc_ref; -#endif // !defined(ASIO_NO_DEPRECATED) - ip::udp::socket::executor_type ex = socket1.get_executor(); (void)ex; @@ -147,9 +134,9 @@ void test() ip::udp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer(); (void)lowest_layer; - const ip::udp::socket& socket8 = socket1; + const ip::udp::socket& socket14 = socket1; const ip::udp::socket::lowest_layer_type& lowest_layer2 - = socket8.lowest_layer(); + = socket14.lowest_layer(); (void)lowest_layer2; socket1.open(ip::udp::v4()); @@ -158,12 +145,12 @@ void test() socket1.open(ip::udp::v6(), ec); #if !defined(ASIO_WINDOWS_RUNTIME) - ip::udp::socket::native_handle_type native_socket2 - = ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - socket1.assign(ip::udp::v4(), native_socket2); ip::udp::socket::native_handle_type native_socket3 = ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - socket1.assign(ip::udp::v4(), native_socket3, ec); + socket1.assign(ip::udp::v4(), native_socket3); + ip::udp::socket::native_handle_type native_socket4 + = ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + socket1.assign(ip::udp::v4(), native_socket4, ec); #endif // !defined(ASIO_WINDOWS_RUNTIME) bool is_open = socket1.is_open(); @@ -172,9 +159,12 @@ void test() socket1.close(); socket1.close(ec); - ip::udp::socket::native_handle_type native_socket4 + socket1.release(); + socket1.release(ec); + + ip::udp::socket::native_handle_type native_socket5 = socket1.native_handle(); - (void)native_socket4; + (void)native_socket5; socket1.cancel(); socket1.cancel(ec); @@ -203,18 +193,12 @@ void test() connect_handler()); socket1.async_connect(ip::udp::endpoint(ip::udp::v6(), 0), connect_handler()); + socket1.async_connect(ip::udp::endpoint(ip::udp::v4(), 0), immediate); + socket1.async_connect(ip::udp::endpoint(ip::udp::v6(), 0), immediate); int i1 = socket1.async_connect(ip::udp::endpoint(ip::udp::v4(), 0), lazy); (void)i1; int i2 = socket1.async_connect(ip::udp::endpoint(ip::udp::v6(), 0), lazy); (void)i2; -#if !defined(ASIO_NO_DEPRECATED) - double d1 = socket1.async_connect( - ip::udp::endpoint(ip::udp::v4(), 0), dlazy); - (void)d1; - double d2 = socket1.async_connect( - ip::udp::endpoint(ip::udp::v6(), 0), dlazy); - (void)d2; -#endif // !defined(ASIO_NO_DEPRECATED) socket1.set_option(settable_socket_option1); socket1.set_option(settable_socket_option1, ec); @@ -244,10 +228,14 @@ void test() socket1.native_non_blocking(false, ec); ip::udp::endpoint endpoint1 = socket1.local_endpoint(); + (void)endpoint1; ip::udp::endpoint endpoint2 = socket1.local_endpoint(ec); + (void)endpoint2; ip::udp::endpoint endpoint3 = socket1.remote_endpoint(); + (void)endpoint3; ip::udp::endpoint endpoint4 = socket1.remote_endpoint(ec); + (void)endpoint4; socket1.shutdown(socket_base::shutdown_both); socket1.shutdown(socket_base::shutdown_both, ec); @@ -256,12 +244,9 @@ void test() socket1.wait(socket_base::wait_write, ec); socket1.async_wait(socket_base::wait_read, wait_handler()); + socket1.async_wait(socket_base::wait_read, immediate); int i3 = socket1.async_wait(socket_base::wait_write, lazy); (void)i3; -#if !defined(ASIO_NO_DEPRECATED) - double d3 = socket1.async_wait(socket_base::wait_write, dlazy); - (void)d3; -#endif // !defined(ASIO_NO_DEPRECATED) // basic_datagram_socket functions. @@ -281,6 +266,12 @@ void test() socket1.async_send(buffer(mutable_char_buffer), in_flags, send_handler()); socket1.async_send(buffer(const_char_buffer), in_flags, send_handler()); socket1.async_send(null_buffers(), in_flags, send_handler()); + socket1.async_send(buffer(mutable_char_buffer), immediate); + socket1.async_send(buffer(const_char_buffer), immediate); + socket1.async_send(null_buffers(), immediate); + socket1.async_send(buffer(mutable_char_buffer), in_flags, immediate); + socket1.async_send(buffer(const_char_buffer), in_flags, immediate); + socket1.async_send(null_buffers(), in_flags, immediate); int i4 = socket1.async_send(buffer(mutable_char_buffer), lazy); (void)i4; int i5 = socket1.async_send(buffer(const_char_buffer), lazy); @@ -293,21 +284,6 @@ void test() (void)i8; int i9 = socket1.async_send(null_buffers(), in_flags, lazy); (void)i9; -#if !defined(ASIO_NO_DEPRECATED) - double d4 = socket1.async_send(buffer(mutable_char_buffer), dlazy); - (void)d4; - double d5 = socket1.async_send(buffer(const_char_buffer), dlazy); - (void)d5; - double d6 = socket1.async_send(null_buffers(), dlazy); - (void)d6; - double d7 = socket1.async_send( - buffer(mutable_char_buffer), in_flags, dlazy); - (void)d7; - double d8 = socket1.async_send(buffer(const_char_buffer), in_flags, dlazy); - (void)d8; - double d9 = socket1.async_send(null_buffers(), in_flags, dlazy); - (void)d9; -#endif // !defined(ASIO_NO_DEPRECATED) socket1.send_to(buffer(mutable_char_buffer), ip::udp::endpoint(ip::udp::v4(), 0)); @@ -370,6 +346,30 @@ void test() ip::udp::endpoint(ip::udp::v4(), 0), in_flags, send_handler()); socket1.async_send_to(null_buffers(), ip::udp::endpoint(ip::udp::v6(), 0), in_flags, send_handler()); + socket1.async_send_to(buffer(mutable_char_buffer), + ip::udp::endpoint(ip::udp::v4(), 0), immediate); + socket1.async_send_to(buffer(mutable_char_buffer), + ip::udp::endpoint(ip::udp::v6(), 0), immediate); + socket1.async_send_to(buffer(const_char_buffer), + ip::udp::endpoint(ip::udp::v4(), 0), immediate); + socket1.async_send_to(buffer(const_char_buffer), + ip::udp::endpoint(ip::udp::v6(), 0), immediate); + socket1.async_send_to(null_buffers(), + ip::udp::endpoint(ip::udp::v4(), 0), immediate); + socket1.async_send_to(null_buffers(), + ip::udp::endpoint(ip::udp::v6(), 0), immediate); + socket1.async_send_to(buffer(mutable_char_buffer), + ip::udp::endpoint(ip::udp::v4(), 0), in_flags, immediate); + socket1.async_send_to(buffer(mutable_char_buffer), + ip::udp::endpoint(ip::udp::v6(), 0), in_flags, immediate); + socket1.async_send_to(buffer(const_char_buffer), + ip::udp::endpoint(ip::udp::v4(), 0), in_flags, immediate); + socket1.async_send_to(buffer(const_char_buffer), + ip::udp::endpoint(ip::udp::v6(), 0), in_flags, immediate); + socket1.async_send_to(null_buffers(), + ip::udp::endpoint(ip::udp::v4(), 0), in_flags, immediate); + socket1.async_send_to(null_buffers(), + ip::udp::endpoint(ip::udp::v6(), 0), in_flags, immediate); int i10 = socket1.async_send_to(buffer(mutable_char_buffer), ip::udp::endpoint(ip::udp::v4(), 0), lazy); (void)i10; @@ -406,44 +406,6 @@ void test() int i21 = socket1.async_send_to(null_buffers(), ip::udp::endpoint(ip::udp::v6(), 0), in_flags, lazy); (void)i21; -#if !defined(ASIO_NO_DEPRECATED) - double d10 = socket1.async_send_to(buffer(mutable_char_buffer), - ip::udp::endpoint(ip::udp::v4(), 0), dlazy); - (void)d10; - double d11 = socket1.async_send_to(buffer(mutable_char_buffer), - ip::udp::endpoint(ip::udp::v6(), 0), dlazy); - (void)d11; - double d12 = socket1.async_send_to(buffer(const_char_buffer), - ip::udp::endpoint(ip::udp::v4(), 0), dlazy); - (void)d12; - double d13 = socket1.async_send_to(buffer(const_char_buffer), - ip::udp::endpoint(ip::udp::v6(), 0), dlazy); - (void)d13; - double d14 = socket1.async_send_to(null_buffers(), - ip::udp::endpoint(ip::udp::v4(), 0), dlazy); - (void)d14; - double d15 = socket1.async_send_to(null_buffers(), - ip::udp::endpoint(ip::udp::v6(), 0), dlazy); - (void)d15; - double d16 = socket1.async_send_to(buffer(mutable_char_buffer), - ip::udp::endpoint(ip::udp::v4(), 0), in_flags, dlazy); - (void)d16; - double d17 = socket1.async_send_to(buffer(mutable_char_buffer), - ip::udp::endpoint(ip::udp::v6(), 0), in_flags, dlazy); - (void)d17; - double d18 = socket1.async_send_to(buffer(const_char_buffer), - ip::udp::endpoint(ip::udp::v4(), 0), in_flags, dlazy); - (void)d18; - double d19 = socket1.async_send_to(buffer(const_char_buffer), - ip::udp::endpoint(ip::udp::v6(), 0), in_flags, dlazy); - (void)d19; - double d20 = socket1.async_send_to(null_buffers(), - ip::udp::endpoint(ip::udp::v4(), 0), in_flags, dlazy); - (void)d20; - double d21 = socket1.async_send_to(null_buffers(), - ip::udp::endpoint(ip::udp::v6(), 0), in_flags, dlazy); - (void)d21; -#endif // !defined(ASIO_NO_DEPRECATED) socket1.receive(buffer(mutable_char_buffer)); socket1.receive(null_buffers()); @@ -457,6 +419,10 @@ void test() socket1.async_receive(buffer(mutable_char_buffer), in_flags, receive_handler()); socket1.async_receive(null_buffers(), in_flags, receive_handler()); + socket1.async_receive(buffer(mutable_char_buffer), immediate); + socket1.async_receive(null_buffers(), immediate); + socket1.async_receive(buffer(mutable_char_buffer), in_flags, immediate); + socket1.async_receive(null_buffers(), in_flags, immediate); int i22 = socket1.async_receive(buffer(mutable_char_buffer), lazy); (void)i22; int i23 = socket1.async_receive(null_buffers(), lazy); @@ -466,17 +432,6 @@ void test() (void)i24; int i25 = socket1.async_receive(null_buffers(), in_flags, lazy); (void)i25; -#if !defined(ASIO_NO_DEPRECATED) - double d22 = socket1.async_receive(buffer(mutable_char_buffer), dlazy); - (void)d22; - double d23 = socket1.async_receive(null_buffers(), dlazy); - (void)d23; - double d24 = socket1.async_receive(buffer(mutable_char_buffer), - in_flags, dlazy); - (void)d24; - double d25 = socket1.async_receive(null_buffers(), in_flags, dlazy); - (void)d25; -#endif // !defined(ASIO_NO_DEPRECATED) ip::udp::endpoint endpoint; socket1.receive_from(buffer(mutable_char_buffer), endpoint); @@ -494,6 +449,14 @@ void test() endpoint, in_flags, receive_handler()); socket1.async_receive_from(null_buffers(), endpoint, in_flags, receive_handler()); + socket1.async_receive_from(buffer(mutable_char_buffer), + endpoint, immediate); + socket1.async_receive_from(null_buffers(), + endpoint, immediate); + socket1.async_receive_from(buffer(mutable_char_buffer), + endpoint, in_flags, immediate); + socket1.async_receive_from(null_buffers(), + endpoint, in_flags, immediate); int i26 = socket1.async_receive_from(buffer(mutable_char_buffer), endpoint, lazy); (void)i26; @@ -506,20 +469,6 @@ void test() int i29 = socket1.async_receive_from(null_buffers(), endpoint, in_flags, lazy); (void)i29; -#if !defined(ASIO_NO_DEPRECATED) - double d26 = socket1.async_receive_from(buffer(mutable_char_buffer), - endpoint, dlazy); - (void)d26; - double d27 = socket1.async_receive_from(null_buffers(), - endpoint, dlazy); - (void)d27; - double d28 = socket1.async_receive_from(buffer(mutable_char_buffer), - endpoint, in_flags, dlazy); - (void)d28; - double d29 = socket1.async_receive_from(null_buffers(), - endpoint, in_flags, dlazy); - (void)d29; -#endif // !defined(ASIO_NO_DEPRECATED) } catch (std::exception&) { @@ -556,13 +505,9 @@ void test() using namespace asio; namespace ip = asio::ip; -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; io_context ioc; @@ -613,11 +558,9 @@ struct resolve_handler resolve_handler() {} void operator()(const asio::error_code&, asio::ip::udp::resolver::results_type) {} -#if defined(ASIO_HAS_MOVE) resolve_handler(resolve_handler&&) {} private: resolve_handler(const resolve_handler&); -#endif // defined(ASIO_HAS_MOVE) }; void test() @@ -628,10 +571,8 @@ void test() try { io_context ioc; + const io_context::executor_type ioc_ex = ioc.get_executor(); archetypes::lazy_handler lazy; -#if !defined(ASIO_NO_DEPRECATED) - archetypes::deprecated_lazy_handler dlazy; -#endif // !defined(ASIO_NO_DEPRECATED) asio::error_code ec; #if !defined(ASIO_NO_DEPRECATED) ip::udp::resolver::query q(ip::udp::v4(), "localhost", "0"); @@ -641,25 +582,17 @@ void test() // basic_resolver constructors. ip::udp::resolver resolver(ioc); + ip::udp::resolver resolver2(ioc_ex); -#if defined(ASIO_HAS_MOVE) - ip::udp::resolver resolver2(std::move(resolver)); -#endif // defined(ASIO_HAS_MOVE) + ip::udp::resolver resolver3(std::move(resolver)); // basic_resolver operators. -#if defined(ASIO_HAS_MOVE) resolver = ip::udp::resolver(ioc); - resolver = std::move(resolver2); -#endif // defined(ASIO_HAS_MOVE) + resolver = std::move(resolver3); // basic_io_object functions. -#if !defined(ASIO_NO_DEPRECATED) - io_context& ioc_ref = resolver.get_io_context(); - (void)ioc_ref; -#endif // !defined(ASIO_NO_DEPRECATED) - ip::udp::resolver::executor_type ex = resolver.get_executor(); (void)ex; @@ -715,55 +648,31 @@ void test() resolver.async_resolve(q, resolve_handler()); int i1 = resolver.async_resolve(q, lazy); (void)i1; - double d1 = resolver.async_resolve(q, dlazy); - (void)d1; #endif // !defined(ASIO_NO_DEPRECATED) resolver.async_resolve("", "", resolve_handler()); int i2 = resolver.async_resolve("", "", lazy); (void)i2; -#if !defined(ASIO_NO_DEPRECATED) - double d2 = resolver.async_resolve("", "", dlazy); - (void)d2; -#endif // !defined(ASIO_NO_DEPRECATED) resolver.async_resolve("", "", ip::udp::resolver::flags(), resolve_handler()); int i3 = resolver.async_resolve("", "", ip::udp::resolver::flags(), lazy); (void)i3; -#if !defined(ASIO_NO_DEPRECATED) - double d3 = resolver.async_resolve("", "", - ip::udp::resolver::flags(), dlazy); - (void)d3; -#endif // !defined(ASIO_NO_DEPRECATED) resolver.async_resolve(ip::udp::v4(), "", "", resolve_handler()); int i4 = resolver.async_resolve(ip::udp::v4(), "", "", lazy); (void)i4; -#if !defined(ASIO_NO_DEPRECATED) - double d4 = resolver.async_resolve(ip::udp::v4(), "", "", dlazy); - (void)d4; -#endif // !defined(ASIO_NO_DEPRECATED) resolver.async_resolve(ip::udp::v4(), "", "", ip::udp::resolver::flags(), resolve_handler()); int i5 = resolver.async_resolve(ip::udp::v4(), "", "", ip::udp::resolver::flags(), lazy); (void)i5; -#if !defined(ASIO_NO_DEPRECATED) - double d5 = resolver.async_resolve(ip::udp::v4(), - "", "", ip::udp::resolver::flags(), dlazy); - (void)d5; -#endif // !defined(ASIO_NO_DEPRECATED) resolver.async_resolve(e, resolve_handler()); int i6 = resolver.async_resolve(e, lazy); (void)i6; -#if !defined(ASIO_NO_DEPRECATED) - double d6 = resolver.async_resolve(e, dlazy); - (void)d6; -#endif // !defined(ASIO_NO_DEPRECATED) } catch (std::exception&) { @@ -777,7 +686,7 @@ void test() ASIO_TEST_SUITE ( "ip/udp", - ASIO_TEST_CASE(ip_udp_socket_compile::test) + ASIO_COMPILE_TEST_CASE(ip_udp_socket_compile::test) ASIO_TEST_CASE(ip_udp_socket_runtime::test) - ASIO_TEST_CASE(ip_udp_resolver_compile::test) + ASIO_COMPILE_TEST_CASE(ip_udp_resolver_compile::test) ) diff --git a/3rdparty/asio/src/tests/unit/ip/unicast.cpp b/3rdparty/asio/src/tests/unit/ip/unicast.cpp index 669e2727ceb..db3497f6e1c 100644 --- a/3rdparty/asio/src/tests/unit/ip/unicast.cpp +++ b/3rdparty/asio/src/tests/unit/ip/unicast.cpp @@ -2,7 +2,7 @@ // unicast.cpp // ~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -166,6 +166,6 @@ void test() ASIO_TEST_SUITE ( "ip/unicast", - ASIO_TEST_CASE(ip_unicast_compile::test) + ASIO_COMPILE_TEST_CASE(ip_unicast_compile::test) ASIO_TEST_CASE(ip_unicast_runtime::test) ) diff --git a/3rdparty/asio/src/tests/unit/ip/v6_only.cpp b/3rdparty/asio/src/tests/unit/ip/v6_only.cpp index 951540f889b..ba37fdb3954 100644 --- a/3rdparty/asio/src/tests/unit/ip/v6_only.cpp +++ b/3rdparty/asio/src/tests/unit/ip/v6_only.cpp @@ -2,7 +2,7 @@ // v6_only.cpp // ~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -130,6 +130,6 @@ void test() ASIO_TEST_SUITE ( "ip/v6_only", - ASIO_TEST_CASE(ip_v6_only_compile::test) + ASIO_COMPILE_TEST_CASE(ip_v6_only_compile::test) ASIO_TEST_CASE(ip_v6_only_runtime::test) ) diff --git a/3rdparty/asio/src/tests/unit/is_read_buffered.cpp b/3rdparty/asio/src/tests/unit/is_read_buffered.cpp index 151e483a020..031cd0fb34d 100644 --- a/3rdparty/asio/src/tests/unit/is_read_buffered.cpp +++ b/3rdparty/asio/src/tests/unit/is_read_buffered.cpp @@ -2,7 +2,7 @@ // is_read_buffered.cpp // ~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/is_write_buffered.cpp b/3rdparty/asio/src/tests/unit/is_write_buffered.cpp index 165f6e74080..df7a9c86d79 100644 --- a/3rdparty/asio/src/tests/unit/is_write_buffered.cpp +++ b/3rdparty/asio/src/tests/unit/is_write_buffered.cpp @@ -2,7 +2,7 @@ // is_write_buffered.cpp // ~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/local/.gitignore b/3rdparty/asio/src/tests/unit/local/.gitignore deleted file mode 100644 index f2d0faff70d..00000000000 --- a/3rdparty/asio/src/tests/unit/local/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*.ilk -*.manifest -*.pdb -*.tds -basic_endpoint -connect_pair -datagram_protocol -stream_protocol diff --git a/3rdparty/asio/src/tests/unit/local/basic_endpoint.cpp b/3rdparty/asio/src/tests/unit/local/basic_endpoint.cpp index aa76637ab1e..855888e52c9 100644 --- a/3rdparty/asio/src/tests/unit/local/basic_endpoint.cpp +++ b/3rdparty/asio/src/tests/unit/local/basic_endpoint.cpp @@ -2,7 +2,7 @@ // basic_endpoint.cpp // ~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/local/connect_pair.cpp b/3rdparty/asio/src/tests/unit/local/connect_pair.cpp index 31a34af67f6..095a0d89696 100644 --- a/3rdparty/asio/src/tests/unit/local/connect_pair.cpp +++ b/3rdparty/asio/src/tests/unit/local/connect_pair.cpp @@ -2,7 +2,7 @@ // connect_pair.cpp // ~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -72,5 +72,5 @@ void test() ASIO_TEST_SUITE ( "local/connect_pair", - ASIO_TEST_CASE(local_connect_pair_compile::test) + ASIO_COMPILE_TEST_CASE(local_connect_pair_compile::test) ) diff --git a/3rdparty/asio/src/tests/unit/local/datagram_protocol.cpp b/3rdparty/asio/src/tests/unit/local/datagram_protocol.cpp index f685a8220a4..23f677d6723 100644 --- a/3rdparty/asio/src/tests/unit/local/datagram_protocol.cpp +++ b/3rdparty/asio/src/tests/unit/local/datagram_protocol.cpp @@ -2,7 +2,7 @@ // datagram_protocol.cpp // ~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -52,6 +52,7 @@ void test() try { io_context ioc; + const io_context::executor_type ioc_ex = ioc.get_executor(); char mutable_char_buffer[128] = ""; const char const_char_buffer[128] = ""; socket_base::message_flags in_flags = 0; @@ -67,12 +68,13 @@ void test() int native_socket1 = ::socket(AF_UNIX, SOCK_DGRAM, 0); dp::socket socket4(ioc, dp(), native_socket1); - // basic_io_object functions. + dp::socket socket5(ioc_ex); + dp::socket socket6(ioc_ex, dp()); + dp::socket socket7(ioc_ex, dp::endpoint("")); + int native_socket2 = ::socket(AF_UNIX, SOCK_DGRAM, 0); + dp::socket socket8(ioc_ex, dp(), native_socket2); -#if !defined(ASIO_NO_DEPRECATED) - io_context& ioc_ref = socket1.get_io_context(); - (void)ioc_ref; -#endif // !defined(ASIO_NO_DEPRECATED) + // basic_io_object functions. dp::socket::executor_type ex = socket1.get_executor(); (void)ex; @@ -85,10 +87,10 @@ void test() socket1.open(dp()); socket1.open(dp(), ec); - int native_socket2 = ::socket(AF_UNIX, SOCK_DGRAM, 0); - socket1.assign(dp(), native_socket2); int native_socket3 = ::socket(AF_UNIX, SOCK_DGRAM, 0); - socket1.assign(dp(), native_socket3, ec); + socket1.assign(dp(), native_socket3); + int native_socket4 = ::socket(AF_UNIX, SOCK_DGRAM, 0); + socket1.assign(dp(), native_socket4, ec); bool is_open = socket1.is_open(); (void)is_open; @@ -96,8 +98,8 @@ void test() socket1.close(); socket1.close(ec); - dp::socket::native_handle_type native_socket4 = socket1.native_handle(); - (void)native_socket4; + dp::socket::native_handle_type native_socket5 = socket1.native_handle(); + (void)native_socket5; socket1.cancel(); socket1.cancel(ec); @@ -130,10 +132,14 @@ void test() socket1.io_control(io_control_command, ec); dp::endpoint endpoint1 = socket1.local_endpoint(); + (void)endpoint1; dp::endpoint endpoint2 = socket1.local_endpoint(ec); + (void)endpoint2; dp::endpoint endpoint3 = socket1.remote_endpoint(); + (void)endpoint3; dp::endpoint endpoint4 = socket1.remote_endpoint(ec); + (void)endpoint4; socket1.shutdown(socket_base::shutdown_both); socket1.shutdown(socket_base::shutdown_both, ec); @@ -232,5 +238,5 @@ void test() ASIO_TEST_SUITE ( "local/datagram_protocol", - ASIO_TEST_CASE(local_datagram_protocol_socket_compile::test) + ASIO_COMPILE_TEST_CASE(local_datagram_protocol_socket_compile::test) ) diff --git a/3rdparty/asio/src/tests/unit/local/seq_packet_protocol.cpp b/3rdparty/asio/src/tests/unit/local/seq_packet_protocol.cpp new file mode 100644 index 00000000000..00934827aa6 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/local/seq_packet_protocol.cpp @@ -0,0 +1,209 @@ +// +// local/seq_packet_protocol.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/local/seq_packet_protocol.hpp" + +#include <cstring> +#include "asio/io_context.hpp" +#include "../unit_test.hpp" +#include "../archetypes/async_result.hpp" + +#if defined(__cplusplus_cli) || defined(__cplusplus_winrt) +# define local cpp_local +#endif + +//------------------------------------------------------------------------------ + +// local_seq_packet_protocol_socket_compile test +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// The following test checks that all public member functions on the class +// local::seq_packet_socket::socket compile and link correctly. Runtime +// failures are ignored. + +namespace local_seq_packet_protocol_socket_compile { + +void connect_handler(const asio::error_code&) +{ +} + +void send_handler(const asio::error_code&, std::size_t) +{ +} + +void receive_handler(const asio::error_code&, std::size_t) +{ +} + +void test() +{ + using namespace asio; + namespace local = asio::local; + typedef local::seq_packet_protocol spp; + + try + { + io_context ioc; + char mutable_char_buffer[128] = ""; + const char const_char_buffer[128] = ""; + const socket_base::message_flags in_flags = 0; + socket_base::message_flags out_flags = 0; + socket_base::send_buffer_size socket_option; + socket_base::bytes_readable io_control_command; + archetypes::immediate_handler immediate; + asio::error_code ec; + + // basic_seq_packet_socket constructors. + + spp::socket socket1(ioc); + spp::socket socket2(ioc, spp()); + spp::socket socket3(ioc, spp::endpoint()); +#if !defined(ASIO_WINDOWS_RUNTIME) + spp::socket::native_handle_type native_socket1 + = ::socket(AF_UNIX, SOCK_SEQPACKET, 0); + spp::socket socket4(ioc, spp(), native_socket1); +#endif // !defined(ASIO_WINDOWS_RUNTIME) + + spp::socket socket5(std::move(socket4)); + + // basic_seq_packet_socket operators. + + socket1 = spp::socket(ioc); + socket1 = std::move(socket2); + + // basic_io_object functions. + + spp::socket::executor_type ex = socket1.get_executor(); + (void)ex; + + // basic_socket functions. + + spp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer(); + (void)lowest_layer; + + socket1.open(spp()); + socket1.open(spp(), ec); + +#if !defined(ASIO_WINDOWS_RUNTIME) + spp::socket::native_handle_type native_socket2 + = ::socket(AF_UNIX, SOCK_SEQPACKET, 0); + socket1.assign(spp(), native_socket2); + spp::socket::native_handle_type native_socket3 + = ::socket(AF_UNIX, SOCK_SEQPACKET, 0); + socket1.assign(spp(), native_socket3, ec); +#endif // !defined(ASIO_WINDOWS_RUNTIME) + + bool is_open = socket1.is_open(); + (void)is_open; + + socket1.close(); + socket1.close(ec); + + spp::socket::native_handle_type native_socket4 = socket1.native_handle(); + (void)native_socket4; + + socket1.cancel(); + socket1.cancel(ec); + + bool at_mark1 = socket1.at_mark(); + (void)at_mark1; + bool at_mark2 = socket1.at_mark(ec); + (void)at_mark2; + + std::size_t available1 = socket1.available(); + (void)available1; + std::size_t available2 = socket1.available(ec); + (void)available2; + + socket1.bind(spp::endpoint()); + socket1.bind(spp::endpoint(), ec); + + socket1.connect(spp::endpoint()); + socket1.connect(spp::endpoint(), ec); + + socket1.async_connect(spp::endpoint(), connect_handler); + socket1.async_connect(spp::endpoint(), immediate); + + socket1.set_option(socket_option); + socket1.set_option(socket_option, ec); + + socket1.get_option(socket_option); + socket1.get_option(socket_option, ec); + + socket1.io_control(io_control_command); + socket1.io_control(io_control_command, ec); + + spp::endpoint endpoint1 = socket1.local_endpoint(); + (void)endpoint1; + spp::endpoint endpoint2 = socket1.local_endpoint(ec); + (void)endpoint2; + + spp::endpoint endpoint3 = socket1.remote_endpoint(); + (void)endpoint3; + spp::endpoint endpoint4 = socket1.remote_endpoint(ec); + (void)endpoint4; + + socket1.shutdown(socket_base::shutdown_both); + socket1.shutdown(socket_base::shutdown_both, ec); + + // basic_seq_packet_socket functions. + + socket1.send(buffer(mutable_char_buffer), in_flags); + socket1.send(buffer(const_char_buffer), in_flags); + socket1.send(null_buffers(), in_flags); + socket1.send(buffer(mutable_char_buffer), in_flags, ec); + socket1.send(buffer(const_char_buffer), in_flags, ec); + socket1.send(null_buffers(), in_flags, ec); + + socket1.async_send(buffer(mutable_char_buffer), in_flags, send_handler); + socket1.async_send(buffer(const_char_buffer), in_flags, send_handler); + socket1.async_send(null_buffers(), in_flags, send_handler); + socket1.async_send(buffer(mutable_char_buffer), in_flags, immediate); + socket1.async_send(buffer(const_char_buffer), in_flags, immediate); + socket1.async_send(null_buffers(), in_flags, immediate); + + socket1.receive(buffer(mutable_char_buffer), out_flags); + socket1.receive(null_buffers(), out_flags); + socket1.receive(buffer(mutable_char_buffer), in_flags, out_flags); + socket1.receive(null_buffers(), in_flags, out_flags); + socket1.receive(buffer(mutable_char_buffer), in_flags, out_flags, ec); + socket1.receive(null_buffers(), in_flags, out_flags, ec); + + socket1.async_receive(buffer(mutable_char_buffer), out_flags, + receive_handler); + socket1.async_receive(null_buffers(), out_flags, receive_handler); + socket1.async_receive(buffer(mutable_char_buffer), in_flags, + out_flags, receive_handler); + socket1.async_receive(null_buffers(), in_flags, out_flags, receive_handler); + socket1.async_receive(buffer(mutable_char_buffer), out_flags, immediate); + socket1.async_receive(null_buffers(), out_flags, immediate); + socket1.async_receive(buffer(mutable_char_buffer), in_flags, + out_flags, immediate); + socket1.async_receive(null_buffers(), in_flags, out_flags, immediate); + } + catch (std::exception&) + { + } +} + +} // namespace local_seq_packet_protocol_socket_compile + +//------------------------------------------------------------------------------ + +ASIO_TEST_SUITE +( + "local/seq_packet_protocol", + ASIO_COMPILE_TEST_CASE(local_seq_packet_protocol_socket_compile::test) +) diff --git a/3rdparty/asio/src/tests/unit/local/stream_protocol.cpp b/3rdparty/asio/src/tests/unit/local/stream_protocol.cpp index c22ba410cdb..985d143e412 100644 --- a/3rdparty/asio/src/tests/unit/local/stream_protocol.cpp +++ b/3rdparty/asio/src/tests/unit/local/stream_protocol.cpp @@ -2,7 +2,7 @@ // stream_protocol.cpp // ~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -60,6 +60,7 @@ void test() try { io_context ioc; + const io_context::executor_type ioc_ex = ioc.get_executor(); char mutable_char_buffer[128] = ""; const char const_char_buffer[128] = ""; socket_base::message_flags in_flags = 0; @@ -75,12 +76,13 @@ void test() int native_socket1 = ::socket(AF_UNIX, SOCK_STREAM, 0); sp::socket socket4(ioc, sp(), native_socket1); - // basic_io_object functions. + sp::socket socket5(ioc_ex); + sp::socket socket6(ioc_ex, sp()); + sp::socket socket7(ioc_ex, sp::endpoint("")); + int native_socket2 = ::socket(AF_UNIX, SOCK_STREAM, 0); + sp::socket socket8(ioc_ex, sp(), native_socket2); -#if !defined(ASIO_NO_DEPRECATED) - io_context& ioc_ref = socket1.get_io_context(); - (void)ioc_ref; -#endif // !defined(ASIO_NO_DEPRECATED) + // basic_io_object functions. sp::socket::executor_type ex = socket1.get_executor(); (void)ex; @@ -93,10 +95,10 @@ void test() socket1.open(sp()); socket1.open(sp(), ec); - int native_socket2 = ::socket(AF_UNIX, SOCK_STREAM, 0); - socket1.assign(sp(), native_socket2); int native_socket3 = ::socket(AF_UNIX, SOCK_STREAM, 0); - socket1.assign(sp(), native_socket3, ec); + socket1.assign(sp(), native_socket3); + int native_socket4 = ::socket(AF_UNIX, SOCK_STREAM, 0); + socket1.assign(sp(), native_socket4, ec); bool is_open = socket1.is_open(); (void)is_open; @@ -104,8 +106,8 @@ void test() socket1.close(); socket1.close(ec); - sp::socket::native_handle_type native_socket4 = socket1.native_handle(); - (void)native_socket4; + sp::socket::native_handle_type native_socket5 = socket1.native_handle(); + (void)native_socket5; socket1.cancel(); socket1.cancel(ec); @@ -138,10 +140,14 @@ void test() socket1.io_control(io_control_command, ec); sp::endpoint endpoint1 = socket1.local_endpoint(); + (void)endpoint1; sp::endpoint endpoint2 = socket1.local_endpoint(ec); + (void)endpoint2; sp::endpoint endpoint3 = socket1.remote_endpoint(); + (void)endpoint3; sp::endpoint endpoint4 = socket1.remote_endpoint(ec); + (void)endpoint4; socket1.shutdown(socket_base::shutdown_both); socket1.shutdown(socket_base::shutdown_both, ec); @@ -209,5 +215,5 @@ void test() ASIO_TEST_SUITE ( "local/stream_protocol", - ASIO_TEST_CASE(local_stream_protocol_socket_compile::test) + ASIO_COMPILE_TEST_CASE(local_stream_protocol_socket_compile::test) ) diff --git a/3rdparty/asio/src/tests/unit/packaged_task.cpp b/3rdparty/asio/src/tests/unit/packaged_task.cpp index bb44c77ce37..90b36d9f335 100644 --- a/3rdparty/asio/src/tests/unit/packaged_task.cpp +++ b/3rdparty/asio/src/tests/unit/packaged_task.cpp @@ -2,7 +2,7 @@ // packaged_task.cpp // ~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/placeholders.cpp b/3rdparty/asio/src/tests/unit/placeholders.cpp index 54cf62ffb41..4f27d319b73 100644 --- a/3rdparty/asio/src/tests/unit/placeholders.cpp +++ b/3rdparty/asio/src/tests/unit/placeholders.cpp @@ -2,7 +2,7 @@ // placeholders.cpp // ~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/posix/.gitignore b/3rdparty/asio/src/tests/unit/posix/.gitignore deleted file mode 100644 index 2de575abb5a..00000000000 --- a/3rdparty/asio/src/tests/unit/posix/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*.ilk -*.manifest -*.pdb -*.tds -basic_descriptor -basic_stream_descriptor -descriptor -descriptor_base -stream_descriptor -stream_descriptor_service diff --git a/3rdparty/asio/src/tests/unit/posix/basic_descriptor.cpp b/3rdparty/asio/src/tests/unit/posix/basic_descriptor.cpp index c193c0f4b0b..f05ed3153cc 100644 --- a/3rdparty/asio/src/tests/unit/posix/basic_descriptor.cpp +++ b/3rdparty/asio/src/tests/unit/posix/basic_descriptor.cpp @@ -2,7 +2,7 @@ // basic_descriptor.cpp // ~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/posix/basic_stream_descriptor.cpp b/3rdparty/asio/src/tests/unit/posix/basic_stream_descriptor.cpp index dd2f31db977..8ea66857eae 100644 --- a/3rdparty/asio/src/tests/unit/posix/basic_stream_descriptor.cpp +++ b/3rdparty/asio/src/tests/unit/posix/basic_stream_descriptor.cpp @@ -2,7 +2,7 @@ // basic_stream_descriptor.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/posix/descriptor.cpp b/3rdparty/asio/src/tests/unit/posix/descriptor.cpp index 6a52e019da6..c08ef8f4963 100644 --- a/3rdparty/asio/src/tests/unit/posix/descriptor.cpp +++ b/3rdparty/asio/src/tests/unit/posix/descriptor.cpp @@ -2,7 +2,7 @@ // descriptor.cpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/posix/descriptor_base.cpp b/3rdparty/asio/src/tests/unit/posix/descriptor_base.cpp index 6dc61f88d5d..0437c9f852c 100644 --- a/3rdparty/asio/src/tests/unit/posix/descriptor_base.cpp +++ b/3rdparty/asio/src/tests/unit/posix/descriptor_base.cpp @@ -2,7 +2,7 @@ // descriptor_base.cpp // ~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/posix/stream_descriptor.cpp b/3rdparty/asio/src/tests/unit/posix/stream_descriptor.cpp index 165db89596f..a8fdc4b2c19 100644 --- a/3rdparty/asio/src/tests/unit/posix/stream_descriptor.cpp +++ b/3rdparty/asio/src/tests/unit/posix/stream_descriptor.cpp @@ -2,7 +2,7 @@ // stream_descriptor.cpp // ~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -51,36 +51,35 @@ void test() try { io_context ioc; + const io_context::executor_type ioc_ex = ioc.get_executor(); char mutable_char_buffer[128] = ""; const char const_char_buffer[128] = ""; posix::descriptor_base::bytes_readable io_control_command; + archetypes::immediate_handler immediate; archetypes::lazy_handler lazy; asio::error_code ec; // basic_stream_descriptor constructors. posix::stream_descriptor descriptor1(ioc); + posix::stream_descriptor descriptor2(ioc_ex); int native_descriptor1 = -1; - posix::stream_descriptor descriptor2(ioc, native_descriptor1); + posix::stream_descriptor descriptor3(ioc, native_descriptor1); + posix::stream_descriptor descriptor4(ioc_ex, native_descriptor1); -#if defined(ASIO_HAS_MOVE) - posix::stream_descriptor descriptor3(std::move(descriptor2)); -#endif // defined(ASIO_HAS_MOVE) + posix::stream_descriptor descriptor5(std::move(descriptor2)); + + posix::basic_stream_descriptor<io_context::executor_type> descriptor6(ioc); + posix::stream_descriptor descriptor7(std::move(descriptor6)); // basic_stream_descriptor operators. -#if defined(ASIO_HAS_MOVE) descriptor1 = posix::stream_descriptor(ioc); descriptor1 = std::move(descriptor2); -#endif // defined(ASIO_HAS_MOVE) + descriptor1 = std::move(descriptor6); // basic_io_object functions. -#if !defined(ASIO_NO_DEPRECATED) - io_context& ioc_ref = descriptor1.get_io_context(); - (void)ioc_ref; -#endif // !defined(ASIO_NO_DEPRECATED) - posix::stream_descriptor::executor_type ex = descriptor1.get_executor(); (void)ex; @@ -90,9 +89,9 @@ void test() = descriptor1.lowest_layer(); (void)lowest_layer; - const posix::stream_descriptor& descriptor4 = descriptor1; + const posix::stream_descriptor& descriptor8 = descriptor1; const posix::stream_descriptor::lowest_layer_type& lowest_layer2 - = descriptor4.lowest_layer(); + = descriptor8.lowest_layer(); (void)lowest_layer2; int native_descriptor2 = -1; @@ -132,6 +131,7 @@ void test() descriptor1.wait(posix::descriptor_base::wait_write, ec); descriptor1.async_wait(posix::descriptor_base::wait_read, &wait_handler); + descriptor1.async_wait(posix::descriptor_base::wait_read, immediate); int i1 = descriptor1.async_wait(posix::descriptor_base::wait_write, lazy); (void)i1; @@ -150,6 +150,9 @@ void test() write_some_handler); descriptor1.async_write_some(null_buffers(), write_some_handler); + descriptor1.async_write_some(buffer(mutable_char_buffer), immediate); + descriptor1.async_write_some(buffer(const_char_buffer), immediate); + descriptor1.async_write_some(null_buffers(), immediate); int i2 = descriptor1.async_write_some(buffer(mutable_char_buffer), lazy); (void)i2; int i3 = descriptor1.async_write_some(buffer(const_char_buffer), lazy); @@ -163,6 +166,8 @@ void test() descriptor1.async_read_some(buffer(mutable_char_buffer), read_some_handler); descriptor1.async_read_some(null_buffers(), read_some_handler); + descriptor1.async_read_some(buffer(mutable_char_buffer), immediate); + descriptor1.async_read_some(null_buffers(), immediate); int i5 = descriptor1.async_read_some(buffer(mutable_char_buffer), lazy); (void)i5; int i6 = descriptor1.async_read_some(null_buffers(), lazy); @@ -181,5 +186,5 @@ void test() ASIO_TEST_SUITE ( "posix/stream_descriptor", - ASIO_TEST_CASE(posix_stream_descriptor_compile::test) + ASIO_COMPILE_TEST_CASE(posix_stream_descriptor_compile::test) ) diff --git a/3rdparty/asio/src/tests/unit/post.cpp b/3rdparty/asio/src/tests/unit/post.cpp index caf8ad53f3a..d2ef2352299 100644 --- a/3rdparty/asio/src/tests/unit/post.cpp +++ b/3rdparty/asio/src/tests/unit/post.cpp @@ -2,7 +2,7 @@ // post.cpp // ~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/prepend.cpp b/3rdparty/asio/src/tests/unit/prepend.cpp new file mode 100644 index 00000000000..cc26bf9835c --- /dev/null +++ b/3rdparty/asio/src/tests/unit/prepend.cpp @@ -0,0 +1,58 @@ +// +// prepend.cpp +// ~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/prepend.hpp" + +#include "asio/bind_executor.hpp" +#include "asio/io_context.hpp" +#include "asio/post.hpp" +#include "asio/system_timer.hpp" +#include "unit_test.hpp" + +void prepend_test() +{ + asio::io_context io1; + asio::io_context io2; + asio::system_timer timer1(io1); + int count = 0; + + timer1.expires_after(asio::chrono::seconds(0)); + timer1.async_wait( + asio::prepend( + asio::bind_executor(io2.get_executor(), + [&count](int a, int b, asio::error_code) + { + ++count; + ASIO_CHECK(a == 123); + ASIO_CHECK(b == 321); + }), 123, 321)); + + ASIO_CHECK(count == 0); + + io1.run(); + + ASIO_CHECK(count == 0); + + io2.run(); + + ASIO_CHECK(count == 1); +} + +ASIO_TEST_SUITE +( + "prepend", + ASIO_TEST_CASE(prepend_test) +) diff --git a/3rdparty/asio/src/tests/unit/random_access_file.cpp b/3rdparty/asio/src/tests/unit/random_access_file.cpp new file mode 100644 index 00000000000..be703cd395e --- /dev/null +++ b/3rdparty/asio/src/tests/unit/random_access_file.cpp @@ -0,0 +1,171 @@ +// +// random_access_file.cpp +// ~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/random_access_file.hpp" + +#include "archetypes/async_result.hpp" +#include "asio/io_context.hpp" +#include "unit_test.hpp" + +// random_access_file_compile test +// ~~~~~~~~~~~~~~~~~~~~~~~~ +// The following test checks that all public member functions on the class +// random_access_file compile and link correctly. Runtime failures are ignored. + +namespace random_access_file_compile { + +struct write_some_at_handler +{ + write_some_at_handler() {} + void operator()(const asio::error_code&, std::size_t) {} + write_some_at_handler(write_some_at_handler&&) {} +private: + write_some_at_handler(const write_some_at_handler&); +}; + +struct read_some_at_handler +{ + read_some_at_handler() {} + void operator()(const asio::error_code&, std::size_t) {} + read_some_at_handler(read_some_at_handler&&) {} +private: + read_some_at_handler(const read_some_at_handler&); +}; + +void test() +{ +#if defined(ASIO_HAS_FILE) + using namespace asio; + + try + { + io_context ioc; + const io_context::executor_type ioc_ex = ioc.get_executor(); + char mutable_char_buffer[128] = ""; + const char const_char_buffer[128] = ""; + archetypes::lazy_handler lazy; + asio::error_code ec; + const std::string path; + + // basic_random_access_file constructors. + + random_access_file file1(ioc); + random_access_file file2(ioc, "", random_access_file::read_only); + random_access_file file3(ioc, path, random_access_file::read_only); + random_access_file::native_handle_type native_file1 = file1.native_handle(); + random_access_file file4(ioc, native_file1); + + random_access_file file5(ioc_ex); + random_access_file file6(ioc_ex, "", random_access_file::read_only); + random_access_file file7(ioc_ex, path, random_access_file::read_only); + random_access_file::native_handle_type native_file2 = file1.native_handle(); + random_access_file file8(ioc_ex, native_file2); + + random_access_file file9(std::move(file8)); + + basic_random_access_file<io_context::executor_type> file10(ioc); + random_access_file file11(std::move(file10)); + + // basic_random_access_file operators. + + file1 = random_access_file(ioc); + file1 = std::move(file2); + file1 = std::move(file10); + + // basic_io_object functions. + + random_access_file::executor_type ex = file1.get_executor(); + (void)ex; + + // basic_random_access_file functions. + + file1.open("", random_access_file::read_only); + file1.open("", random_access_file::read_only, ec); + + file1.open(path, random_access_file::read_only); + file1.open(path, random_access_file::read_only, ec); + + random_access_file::native_handle_type native_file3 = file1.native_handle(); + file1.assign(native_file3); + random_access_file::native_handle_type native_file4 = file1.native_handle(); + file1.assign(native_file4, ec); + + bool is_open = file1.is_open(); + (void)is_open; + + file1.close(); + file1.close(ec); + + random_access_file::native_handle_type native_file5 = file1.native_handle(); + (void)native_file5; + + random_access_file::native_handle_type native_file6 = file1.release(); + (void)native_file6; + random_access_file::native_handle_type native_file7 = file1.release(ec); + (void)native_file7; + + file1.cancel(); + file1.cancel(ec); + + asio::uint64_t s1 = file1.size(); + (void)s1; + asio::uint64_t s2 = file1.size(ec); + (void)s2; + + file1.resize(asio::uint64_t(0)); + file1.resize(asio::uint64_t(0), ec); + + file1.sync_all(); + file1.sync_all(ec); + + file1.sync_data(); + file1.sync_data(ec); + + file1.write_some_at(0, buffer(mutable_char_buffer)); + file1.write_some_at(0, buffer(const_char_buffer)); + file1.write_some_at(0, buffer(mutable_char_buffer), ec); + file1.write_some_at(0, buffer(const_char_buffer), ec); + + file1.async_write_some_at(0, buffer(mutable_char_buffer), + write_some_at_handler()); + file1.async_write_some_at(0, buffer(const_char_buffer), + write_some_at_handler()); + int i1 = file1.async_write_some_at(0, buffer(mutable_char_buffer), lazy); + (void)i1; + int i2 = file1.async_write_some_at(0, buffer(const_char_buffer), lazy); + (void)i2; + + file1.read_some_at(0, buffer(mutable_char_buffer)); + file1.read_some_at(0, buffer(mutable_char_buffer), ec); + + file1.async_read_some_at(0, buffer(mutable_char_buffer), + read_some_at_handler()); + int i3 = file1.async_read_some_at(0, buffer(mutable_char_buffer), lazy); + (void)i3; + } + catch (std::exception&) + { + } +#endif // defined(ASIO_HAS_FILE) +} + +} // namespace random_access_file_compile + +ASIO_TEST_SUITE +( + "random_access_file", + ASIO_COMPILE_TEST_CASE(random_access_file_compile::test) +) diff --git a/3rdparty/asio/src/tests/unit/read.cpp b/3rdparty/asio/src/tests/unit/read.cpp index 077c9223667..a268c041d9b 100644 --- a/3rdparty/asio/src/tests/unit/read.cpp +++ b/3rdparty/asio/src/tests/unit/read.cpp @@ -2,7 +2,7 @@ // read.cpp // ~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -16,7 +16,9 @@ // Test that header file is self-contained. #include "asio/read.hpp" +#include <array> #include <cstring> +#include <functional> #include <vector> #include "archetypes/async_result.hpp" #include "asio/io_context.hpp" @@ -24,20 +26,10 @@ #include "asio/streambuf.hpp" #include "unit_test.hpp" -#if defined(ASIO_HAS_BOOST_BIND) -# include <boost/bind.hpp> -#else // defined(ASIO_HAS_BOOST_BIND) -# include <functional> -#endif // defined(ASIO_HAS_BOOST_BIND) - #if defined(ASIO_HAS_BOOST_ARRAY) #include <boost/array.hpp> #endif // defined(ASIO_HAS_BOOST_ARRAY) -#if defined(ASIO_HAS_STD_ARRAY) -# include <array> -#endif // defined(ASIO_HAS_STD_ARRAY) - using namespace std; // For memcmp, memcpy and memset. class test_stream @@ -53,7 +45,7 @@ public: { } - executor_type get_executor() ASIO_NOEXCEPT + executor_type get_executor() noexcept { return io_context_.get_executor(); } @@ -120,12 +112,13 @@ public: } template <typename Mutable_Buffers, typename Handler> - void async_read_some(const Mutable_Buffers& buffers, Handler handler) + void async_read_some(const Mutable_Buffers& buffers, + Handler&& handler) { size_t bytes_transferred = read_some(buffers); asio::post(get_executor(), asio::detail::bind_handler( - ASIO_MOVE_CAST(Handler)(handler), + static_cast<Handler&&>(handler), asio::error_code(), bytes_transferred)); } @@ -187,7 +180,8 @@ void test_2_arg_vector_buffers_read() char read_buf[sizeof(read_data)]; std::vector<asio::mutable_buffer> buffers; buffers.push_back(asio::buffer(read_buf, 32)); - buffers.push_back(asio::buffer(read_buf) + 32); + buffers.push_back(asio::buffer(read_buf, 39) + 32); + buffers.push_back(asio::buffer(read_buf) + 39); s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); @@ -210,8 +204,42 @@ void test_2_arg_vector_buffers_read() ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data))); } +void test_2_arg_dynamic_string_read() +{ + asio::io_context ioc; + test_stream s(ioc); + std::string data; + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb + = asio::dynamic_buffer(data, sizeof(read_data)); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + size_t bytes_transferred = asio::read(s, sb); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); +} + void test_2_arg_streambuf_read() { +#if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) asio::io_context ioc; test_stream s(ioc); asio::streambuf sb(sizeof(read_data)); @@ -238,6 +266,7 @@ void test_2_arg_streambuf_read() ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(sb.size() == sizeof(read_data)); ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data))); +#endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) } void test_3_arg_nothrow_zero_buffers_read() @@ -292,7 +321,8 @@ void test_3_arg_nothrow_vector_buffers_read() char read_buf[sizeof(read_data)]; std::vector<asio::mutable_buffer> buffers; buffers.push_back(asio::buffer(read_buf, 32)); - buffers.push_back(asio::buffer(read_buf) + 32); + buffers.push_back(asio::buffer(read_buf, 39) + 32); + buffers.push_back(asio::buffer(read_buf) + 39); s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); @@ -319,8 +349,46 @@ void test_3_arg_nothrow_vector_buffers_read() ASIO_CHECK(!error); } +void test_3_arg_nothrow_dynamic_string_read() +{ + asio::io_context ioc; + test_stream s(ioc); + std::string data; + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb + = asio::dynamic_buffer(data, sizeof(read_data)); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + asio::error_code error; + size_t bytes_transferred = asio::read(s, sb, error); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, error); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, error); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + ASIO_CHECK(!error); +} + void test_3_arg_nothrow_streambuf_read() { +#if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) asio::io_context ioc; test_stream s(ioc); asio::streambuf sb(sizeof(read_data)); @@ -351,6 +419,7 @@ void test_3_arg_nothrow_streambuf_read() ASIO_CHECK(sb.size() == sizeof(read_data)); ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data))); ASIO_CHECK(!error); +#endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) } bool old_style_transfer_all(const asio::error_code& ec, @@ -359,11 +428,16 @@ bool old_style_transfer_all(const asio::error_code& ec, return !!ec; } -size_t short_transfer(const asio::error_code& ec, - size_t /*bytes_transferred*/) +struct short_transfer { - return !!ec ? 0 : 3; -} + short_transfer() {} + short_transfer(short_transfer&&) {} + size_t operator()(const asio::error_code& ec, + size_t /*bytes_transferred*/) + { + return !!ec ? 0 : 3; + } +}; void test_3_arg_mutable_buffer_read() { @@ -556,21 +630,21 @@ void test_3_arg_mutable_buffer_read() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); - bytes_transferred = asio::read(s, buffers, short_transfer); + bytes_transferred = asio::read(s, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data))); s.reset(read_data, sizeof(read_data)); s.next_read_length(1); memset(read_buf, 0, sizeof(read_buf)); - bytes_transferred = asio::read(s, buffers, short_transfer); + bytes_transferred = asio::read(s, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data))); s.reset(read_data, sizeof(read_data)); s.next_read_length(10); memset(read_buf, 0, sizeof(read_buf)); - bytes_transferred = asio::read(s, buffers, short_transfer); + bytes_transferred = asio::read(s, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data))); } @@ -582,7 +656,8 @@ void test_3_arg_vector_buffers_read() char read_buf[sizeof(read_data)]; std::vector<asio::mutable_buffer> buffers; buffers.push_back(asio::buffer(read_buf, 32)); - buffers.push_back(asio::buffer(read_buf) + 32); + buffers.push_back(asio::buffer(read_buf, 39) + 32); + buffers.push_back(asio::buffer(read_buf) + 39); s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); @@ -767,27 +842,266 @@ void test_3_arg_vector_buffers_read() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); - bytes_transferred = asio::read(s, buffers, short_transfer); + bytes_transferred = asio::read(s, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data))); s.reset(read_data, sizeof(read_data)); s.next_read_length(1); memset(read_buf, 0, sizeof(read_buf)); - bytes_transferred = asio::read(s, buffers, short_transfer); + bytes_transferred = asio::read(s, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data))); s.reset(read_data, sizeof(read_data)); s.next_read_length(10); memset(read_buf, 0, sizeof(read_buf)); - bytes_transferred = asio::read(s, buffers, short_transfer); + bytes_transferred = asio::read(s, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data))); } +void test_3_arg_dynamic_string_read() +{ + asio::io_context ioc; + test_stream s(ioc); + std::string data; + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb + = asio::dynamic_buffer(data, sizeof(read_data)); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + size_t bytes_transferred = asio::read(s, sb, + asio::transfer_all()); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, + asio::transfer_all()); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, + asio::transfer_all()); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, + asio::transfer_at_least(1)); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, + asio::transfer_at_least(1)); + ASIO_CHECK(bytes_transferred == 1); + ASIO_CHECK(sb.size() == 1); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 1)); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, + asio::transfer_at_least(1)); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(sb.size() == 10); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10)); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, + asio::transfer_at_least(10)); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, + asio::transfer_at_least(10)); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(sb.size() == 10); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10)); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, + asio::transfer_at_least(10)); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(sb.size() == 10); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10)); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, + asio::transfer_at_least(42)); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, + asio::transfer_at_least(42)); + ASIO_CHECK(bytes_transferred == 42); + ASIO_CHECK(sb.size() == 42); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 42)); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, + asio::transfer_at_least(42)); + ASIO_CHECK(bytes_transferred == 50); + ASIO_CHECK(sb.size() == 50); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 50)); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, + asio::transfer_exactly(1)); + ASIO_CHECK(bytes_transferred == 1); + ASIO_CHECK(sb.size() == 1); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 1)); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, + asio::transfer_exactly(1)); + ASIO_CHECK(bytes_transferred == 1); + ASIO_CHECK(sb.size() == 1); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 1)); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, + asio::transfer_exactly(1)); + ASIO_CHECK(bytes_transferred == 1); + ASIO_CHECK(sb.size() == 1); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 1)); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, + asio::transfer_exactly(10)); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(sb.size() == 10); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10)); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, + asio::transfer_exactly(10)); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(sb.size() == 10); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10)); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, + asio::transfer_exactly(10)); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(sb.size() == 10); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10)); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, + asio::transfer_exactly(42)); + ASIO_CHECK(bytes_transferred == 42); + ASIO_CHECK(sb.size() == 42); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 42)); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, + asio::transfer_exactly(42)); + ASIO_CHECK(bytes_transferred == 42); + ASIO_CHECK(sb.size() == 42); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 42)); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, + asio::transfer_exactly(42)); + ASIO_CHECK(bytes_transferred == 42); + ASIO_CHECK(sb.size() == 42); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 42)); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, old_style_transfer_all); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, old_style_transfer_all); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, old_style_transfer_all); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, short_transfer()); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, short_transfer()); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, short_transfer()); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); +} + void test_3_arg_streambuf_read() { +#if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) asio::io_context ioc; test_stream s(ioc); asio::streambuf sb(sizeof(read_data)); @@ -999,7 +1313,7 @@ void test_3_arg_streambuf_read() s.reset(read_data, sizeof(read_data)); sb.consume(sb.size()); - bytes_transferred = asio::read(s, sb, short_transfer); + bytes_transferred = asio::read(s, sb, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(sb.size() == sizeof(read_data)); ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data))); @@ -1007,7 +1321,7 @@ void test_3_arg_streambuf_read() s.reset(read_data, sizeof(read_data)); s.next_read_length(1); sb.consume(sb.size()); - bytes_transferred = asio::read(s, sb, short_transfer); + bytes_transferred = asio::read(s, sb, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(sb.size() == sizeof(read_data)); ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data))); @@ -1015,10 +1329,11 @@ void test_3_arg_streambuf_read() s.reset(read_data, sizeof(read_data)); s.next_read_length(10); sb.consume(sb.size()); - bytes_transferred = asio::read(s, sb, short_transfer); + bytes_transferred = asio::read(s, sb, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(sb.size() == sizeof(read_data)); ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data))); +#endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) } void test_4_arg_mutable_buffer_read() @@ -1262,7 +1577,7 @@ void test_4_arg_mutable_buffer_read() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); - bytes_transferred = asio::read(s, buffers, short_transfer, error); + bytes_transferred = asio::read(s, buffers, short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data))); ASIO_CHECK(!error); @@ -1271,7 +1586,7 @@ void test_4_arg_mutable_buffer_read() s.next_read_length(1); memset(read_buf, 0, sizeof(read_buf)); error = asio::error_code(); - bytes_transferred = asio::read(s, buffers, short_transfer, error); + bytes_transferred = asio::read(s, buffers, short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data))); ASIO_CHECK(!error); @@ -1280,7 +1595,7 @@ void test_4_arg_mutable_buffer_read() s.next_read_length(10); memset(read_buf, 0, sizeof(read_buf)); error = asio::error_code(); - bytes_transferred = asio::read(s, buffers, short_transfer, error); + bytes_transferred = asio::read(s, buffers, short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data))); ASIO_CHECK(!error); @@ -1293,7 +1608,8 @@ void test_4_arg_vector_buffers_read() char read_buf[sizeof(read_data)]; std::vector<asio::mutable_buffer> buffers; buffers.push_back(asio::buffer(read_buf, 32)); - buffers.push_back(asio::buffer(read_buf) + 32); + buffers.push_back(asio::buffer(read_buf, 39) + 32); + buffers.push_back(asio::buffer(read_buf) + 39); s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); @@ -1528,7 +1844,7 @@ void test_4_arg_vector_buffers_read() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); - bytes_transferred = asio::read(s, buffers, short_transfer, error); + bytes_transferred = asio::read(s, buffers, short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data))); ASIO_CHECK(!error); @@ -1537,7 +1853,7 @@ void test_4_arg_vector_buffers_read() s.next_read_length(1); memset(read_buf, 0, sizeof(read_buf)); error = asio::error_code(); - bytes_transferred = asio::read(s, buffers, short_transfer, error); + bytes_transferred = asio::read(s, buffers, short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data))); ASIO_CHECK(!error); @@ -1546,14 +1862,308 @@ void test_4_arg_vector_buffers_read() s.next_read_length(10); memset(read_buf, 0, sizeof(read_buf)); error = asio::error_code(); - bytes_transferred = asio::read(s, buffers, short_transfer, error); + bytes_transferred = asio::read(s, buffers, short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data))); ASIO_CHECK(!error); } +void test_4_arg_dynamic_string_read() +{ + asio::io_context ioc; + test_stream s(ioc); + std::string data; + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb + = asio::dynamic_buffer(data, sizeof(read_data)); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + asio::error_code error; + size_t bytes_transferred = asio::read(s, sb, + asio::transfer_all(), error); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, + asio::transfer_all(), error); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, + asio::transfer_all(), error); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, + asio::transfer_at_least(1), error); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, + asio::transfer_at_least(1), error); + ASIO_CHECK(bytes_transferred == 1); + ASIO_CHECK(sb.size() == 1); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 1)); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, + asio::transfer_at_least(1), error); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(sb.size() == 10); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10)); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, + asio::transfer_at_least(10), error); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, + asio::transfer_at_least(10), error); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(sb.size() == 10); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10)); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, + asio::transfer_at_least(10), error); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(sb.size() == 10); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10)); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, + asio::transfer_at_least(42), error); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, + asio::transfer_at_least(42), error); + ASIO_CHECK(bytes_transferred == 42); + ASIO_CHECK(sb.size() == 42); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 42)); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, + asio::transfer_at_least(42), error); + ASIO_CHECK(bytes_transferred == 50); + ASIO_CHECK(sb.size() == 50); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 50)); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, + asio::transfer_exactly(1), error); + ASIO_CHECK(bytes_transferred == 1); + ASIO_CHECK(sb.size() == 1); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 1)); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, + asio::transfer_exactly(1), error); + ASIO_CHECK(bytes_transferred == 1); + ASIO_CHECK(sb.size() == 1); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 1)); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, + asio::transfer_exactly(1), error); + ASIO_CHECK(bytes_transferred == 1); + ASIO_CHECK(sb.size() == 1); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 1)); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, + asio::transfer_exactly(10), error); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(sb.size() == 10); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10)); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, + asio::transfer_exactly(10), error); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(sb.size() == 10); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10)); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, + asio::transfer_exactly(10), error); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(sb.size() == 10); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10)); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, + asio::transfer_exactly(42), error); + ASIO_CHECK(bytes_transferred == 42); + ASIO_CHECK(sb.size() == 42); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 42)); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, + asio::transfer_exactly(42), error); + ASIO_CHECK(bytes_transferred == 42); + ASIO_CHECK(sb.size() == 42); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 42)); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, + asio::transfer_exactly(42), error); + ASIO_CHECK(bytes_transferred == 42); + ASIO_CHECK(sb.size() == 42); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 42)); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, + old_style_transfer_all, error); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, + old_style_transfer_all, error); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, + old_style_transfer_all, error); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + bytes_transferred = asio::read(s, sb, short_transfer(), error); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, short_transfer(), error); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + ASIO_CHECK(!error); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + error = asio::error_code(); + bytes_transferred = asio::read(s, sb, short_transfer(), error); + ASIO_CHECK(bytes_transferred == sizeof(read_data)); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + ASIO_CHECK(!error); +} + void test_4_arg_streambuf_read() { +#if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) asio::io_context ioc; test_stream s(ioc); asio::streambuf sb(sizeof(read_data)); @@ -1815,7 +2425,7 @@ void test_4_arg_streambuf_read() s.reset(read_data, sizeof(read_data)); sb.consume(sb.size()); - bytes_transferred = asio::read(s, sb, short_transfer, error); + bytes_transferred = asio::read(s, sb, short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(sb.size() == sizeof(read_data)); ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data))); @@ -1825,7 +2435,7 @@ void test_4_arg_streambuf_read() s.next_read_length(1); sb.consume(sb.size()); error = asio::error_code(); - bytes_transferred = asio::read(s, sb, short_transfer, error); + bytes_transferred = asio::read(s, sb, short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(sb.size() == sizeof(read_data)); ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data))); @@ -1835,11 +2445,12 @@ void test_4_arg_streambuf_read() s.next_read_length(10); sb.consume(sb.size()); error = asio::error_code(); - bytes_transferred = asio::read(s, sb, short_transfer, error); + bytes_transferred = asio::read(s, sb, short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(sb.size() == sizeof(read_data)); ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data))); ASIO_CHECK(!error); +#endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) } void async_read_handler(const asio::error_code& e, @@ -1852,13 +2463,9 @@ void async_read_handler(const asio::error_code& e, void test_3_arg_mutable_buffer_async_read() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_stream s(ioc); @@ -1912,13 +2519,9 @@ void test_3_arg_mutable_buffer_async_read() void test_3_arg_boost_array_buffers_async_read() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; #if defined(ASIO_HAS_BOOST_ARRAY) asio::io_context ioc; @@ -1975,15 +2578,10 @@ void test_3_arg_boost_array_buffers_async_read() void test_3_arg_std_array_buffers_async_read() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; -#if defined(ASIO_HAS_STD_ARRAY) asio::io_context ioc; test_stream s(ioc); char read_buf[sizeof(read_data)]; @@ -2033,25 +2631,21 @@ void test_3_arg_std_array_buffers_async_read() ioc.restart(); ioc.run(); ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data))); -#endif // defined(ASIO_HAS_STD_ARRAY) } void test_3_arg_vector_buffers_async_read() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_stream s(ioc); char read_buf[sizeof(read_data)]; std::vector<asio::mutable_buffer> buffers; buffers.push_back(asio::buffer(read_buf, 32)); - buffers.push_back(asio::buffer(read_buf) + 32); + buffers.push_back(asio::buffer(read_buf, 39) + 32); + buffers.push_back(asio::buffer(read_buf) + 39); s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); @@ -2097,15 +2691,73 @@ void test_3_arg_vector_buffers_async_read() ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data))); } +void test_3_arg_dynamic_string_async_read() +{ + namespace bindns = std; + using bindns::placeholders::_1; + using bindns::placeholders::_2; + + asio::io_context ioc; + test_stream s(ioc); + std::string data; + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb + = asio::dynamic_buffer(data, sizeof(read_data)); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + bool called = false; + asio::async_read(s, sb, + bindns::bind(async_read_handler, + _1, _2, sizeof(read_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, + bindns::bind(async_read_handler, + _1, _2, sizeof(read_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, + bindns::bind(async_read_handler, + _1, _2, sizeof(read_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + int i = asio::async_read(s, sb, archetypes::lazy_handler()); + ASIO_CHECK(i == 42); + ioc.restart(); + ioc.run(); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); +} + void test_3_arg_streambuf_async_read() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) +#if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_stream s(ioc); @@ -2157,17 +2809,14 @@ void test_3_arg_streambuf_async_read() ioc.run(); ASIO_CHECK(sb.size() == sizeof(read_data)); ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data))); +#endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) } void test_4_arg_mutable_buffer_async_read() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_stream s(ioc); @@ -2458,7 +3107,7 @@ void test_4_arg_mutable_buffer_async_read() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read(s, buffers, short_transfer, + asio::async_read(s, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -2470,7 +3119,7 @@ void test_4_arg_mutable_buffer_async_read() s.next_read_length(1); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read(s, buffers, short_transfer, + asio::async_read(s, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -2482,7 +3131,7 @@ void test_4_arg_mutable_buffer_async_read() s.next_read_length(10); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read(s, buffers, short_transfer, + asio::async_read(s, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -2493,7 +3142,7 @@ void test_4_arg_mutable_buffer_async_read() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); int i = asio::async_read(s, buffers, - short_transfer, archetypes::lazy_handler()); + short_transfer(), archetypes::lazy_handler()); ASIO_CHECK(i == 42); ioc.restart(); ioc.run(); @@ -2502,13 +3151,9 @@ void test_4_arg_mutable_buffer_async_read() void test_4_arg_boost_array_buffers_async_read() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; #if defined(ASIO_HAS_BOOST_ARRAY) asio::io_context ioc; @@ -2801,7 +3446,7 @@ void test_4_arg_boost_array_buffers_async_read() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read(s, buffers, short_transfer, + asio::async_read(s, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -2813,7 +3458,7 @@ void test_4_arg_boost_array_buffers_async_read() s.next_read_length(1); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read(s, buffers, short_transfer, + asio::async_read(s, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -2825,7 +3470,7 @@ void test_4_arg_boost_array_buffers_async_read() s.next_read_length(10); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read(s, buffers, short_transfer, + asio::async_read(s, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -2836,7 +3481,7 @@ void test_4_arg_boost_array_buffers_async_read() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); int i = asio::async_read(s, buffers, - short_transfer, archetypes::lazy_handler()); + short_transfer(), archetypes::lazy_handler()); ASIO_CHECK(i == 42); ioc.restart(); ioc.run(); @@ -2846,15 +3491,10 @@ void test_4_arg_boost_array_buffers_async_read() void test_4_arg_std_array_buffers_async_read() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; -#if defined(ASIO_HAS_STD_ARRAY) asio::io_context ioc; test_stream s(ioc); char read_buf[sizeof(read_data)]; @@ -3145,7 +3785,7 @@ void test_4_arg_std_array_buffers_async_read() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read(s, buffers, short_transfer, + asio::async_read(s, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -3157,7 +3797,7 @@ void test_4_arg_std_array_buffers_async_read() s.next_read_length(1); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read(s, buffers, short_transfer, + asio::async_read(s, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -3169,7 +3809,7 @@ void test_4_arg_std_array_buffers_async_read() s.next_read_length(10); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read(s, buffers, short_transfer, + asio::async_read(s, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -3180,30 +3820,26 @@ void test_4_arg_std_array_buffers_async_read() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); int i = asio::async_read(s, buffers, - short_transfer, archetypes::lazy_handler()); + short_transfer(), archetypes::lazy_handler()); ASIO_CHECK(i == 42); ioc.restart(); ioc.run(); ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data))); -#endif // defined(ASIO_HAS_STD_ARRAY) } void test_4_arg_vector_buffers_async_read() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_stream s(ioc); char read_buf[sizeof(read_data)]; std::vector<asio::mutable_buffer> buffers; buffers.push_back(asio::buffer(read_buf, 32)); - buffers.push_back(asio::buffer(read_buf) + 32); + buffers.push_back(asio::buffer(read_buf, 39) + 32); + buffers.push_back(asio::buffer(read_buf) + 39); s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); @@ -3488,7 +4124,7 @@ void test_4_arg_vector_buffers_async_read() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read(s, buffers, short_transfer, + asio::async_read(s, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -3500,7 +4136,7 @@ void test_4_arg_vector_buffers_async_read() s.next_read_length(1); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read(s, buffers, short_transfer, + asio::async_read(s, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -3512,7 +4148,7 @@ void test_4_arg_vector_buffers_async_read() s.next_read_length(10); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read(s, buffers, short_transfer, + asio::async_read(s, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -3523,22 +4159,385 @@ void test_4_arg_vector_buffers_async_read() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); int i = asio::async_read(s, buffers, - short_transfer, archetypes::lazy_handler()); + short_transfer(), archetypes::lazy_handler()); ASIO_CHECK(i == 42); ioc.restart(); ioc.run(); ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data))); } +void test_4_arg_dynamic_string_async_read() +{ + namespace bindns = std; + using bindns::placeholders::_1; + using bindns::placeholders::_2; + + asio::io_context ioc; + test_stream s(ioc); + std::string data; + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb + = asio::dynamic_buffer(data, sizeof(read_data)); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + bool called = false; + asio::async_read(s, sb, asio::transfer_all(), + bindns::bind(async_read_handler, + _1, _2, sizeof(read_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, asio::transfer_all(), + bindns::bind(async_read_handler, + _1, _2, sizeof(read_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, asio::transfer_all(), + bindns::bind(async_read_handler, + _1, _2, sizeof(read_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, asio::transfer_at_least(1), + bindns::bind(async_read_handler, + _1, _2, sizeof(read_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, asio::transfer_at_least(1), + bindns::bind(async_read_handler, + _1, _2, 1, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == 1); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 1)); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, asio::transfer_at_least(1), + bindns::bind(async_read_handler, + _1, _2, 10, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == 10); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10)); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, asio::transfer_at_least(10), + bindns::bind(async_read_handler, + _1, _2, sizeof(read_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, asio::transfer_at_least(10), + bindns::bind(async_read_handler, + _1, _2, 10, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == 10); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10)); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, asio::transfer_at_least(10), + bindns::bind(async_read_handler, + _1, _2, 10, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == 10); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10)); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, asio::transfer_at_least(42), + bindns::bind(async_read_handler, + _1, _2, sizeof(read_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, asio::transfer_at_least(42), + bindns::bind(async_read_handler, + _1, _2, 42, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == 42); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 42)); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, asio::transfer_at_least(42), + bindns::bind(async_read_handler, + _1, _2, 50, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == 50); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 50)); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, asio::transfer_exactly(1), + bindns::bind(async_read_handler, + _1, _2, 1, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == 1); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 1)); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, asio::transfer_exactly(1), + bindns::bind(async_read_handler, + _1, _2, 1, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == 1); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 1)); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, asio::transfer_exactly(1), + bindns::bind(async_read_handler, + _1, _2, 1, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == 1); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 1)); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, asio::transfer_exactly(10), + bindns::bind(async_read_handler, + _1, _2, 10, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == 10); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10)); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, asio::transfer_exactly(10), + bindns::bind(async_read_handler, + _1, _2, 10, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == 10); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10)); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, asio::transfer_exactly(10), + bindns::bind(async_read_handler, + _1, _2, 10, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == 10); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10)); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, asio::transfer_exactly(42), + bindns::bind(async_read_handler, + _1, _2, 42, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == 42); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 42)); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, asio::transfer_exactly(42), + bindns::bind(async_read_handler, + _1, _2, 42, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == 42); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 42)); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, asio::transfer_exactly(42), + bindns::bind(async_read_handler, + _1, _2, 42, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == 42); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 42)); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, old_style_transfer_all, + bindns::bind(async_read_handler, + _1, _2, sizeof(read_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, old_style_transfer_all, + bindns::bind(async_read_handler, + _1, _2, sizeof(read_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, old_style_transfer_all, + bindns::bind(async_read_handler, + _1, _2, sizeof(read_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, short_transfer(), + bindns::bind(async_read_handler, + _1, _2, sizeof(read_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, short_transfer(), + bindns::bind(async_read_handler, + _1, _2, sizeof(read_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb.consume(sb.size()); + called = false; + asio::async_read(s, sb, short_transfer(), + bindns::bind(async_read_handler, + _1, _2, sizeof(read_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); + + s.reset(read_data, sizeof(read_data)); + sb.consume(sb.size()); + int i = asio::async_read(s, sb, + short_transfer(), archetypes::lazy_handler()); + ASIO_CHECK(i == 42); + ioc.restart(); + ioc.run(); + ASIO_CHECK(sb.size() == sizeof(read_data)); + ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data))); +} + void test_4_arg_streambuf_async_read() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) +#if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_stream s(ioc); @@ -3851,7 +4850,7 @@ void test_4_arg_streambuf_async_read() s.reset(read_data, sizeof(read_data)); sb.consume(sb.size()); called = false; - asio::async_read(s, sb, short_transfer, + asio::async_read(s, sb, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -3864,7 +4863,7 @@ void test_4_arg_streambuf_async_read() s.next_read_length(1); sb.consume(sb.size()); called = false; - asio::async_read(s, sb, short_transfer, + asio::async_read(s, sb, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -3877,7 +4876,7 @@ void test_4_arg_streambuf_async_read() s.next_read_length(10); sb.consume(sb.size()); called = false; - asio::async_read(s, sb, short_transfer, + asio::async_read(s, sb, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -3889,12 +4888,13 @@ void test_4_arg_streambuf_async_read() s.reset(read_data, sizeof(read_data)); sb.consume(sb.size()); int i = asio::async_read(s, sb, - short_transfer, archetypes::lazy_handler()); + short_transfer(), archetypes::lazy_handler()); ASIO_CHECK(i == 42); ioc.restart(); ioc.run(); ASIO_CHECK(sb.size() == sizeof(read_data)); ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data))); +#endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) } ASIO_TEST_SUITE @@ -3903,25 +4903,31 @@ ASIO_TEST_SUITE ASIO_TEST_CASE(test_2_arg_zero_buffers_read) ASIO_TEST_CASE(test_2_arg_mutable_buffer_read) ASIO_TEST_CASE(test_2_arg_vector_buffers_read) + ASIO_TEST_CASE(test_2_arg_dynamic_string_read) ASIO_TEST_CASE(test_2_arg_streambuf_read) ASIO_TEST_CASE(test_3_arg_nothrow_zero_buffers_read) ASIO_TEST_CASE(test_3_arg_nothrow_mutable_buffer_read) ASIO_TEST_CASE(test_3_arg_nothrow_vector_buffers_read) + ASIO_TEST_CASE(test_3_arg_nothrow_dynamic_string_read) ASIO_TEST_CASE(test_3_arg_nothrow_streambuf_read) ASIO_TEST_CASE(test_3_arg_mutable_buffer_read) ASIO_TEST_CASE(test_3_arg_vector_buffers_read) + ASIO_TEST_CASE(test_3_arg_dynamic_string_read) ASIO_TEST_CASE(test_3_arg_streambuf_read) ASIO_TEST_CASE(test_4_arg_mutable_buffer_read) ASIO_TEST_CASE(test_4_arg_vector_buffers_read) + ASIO_TEST_CASE(test_4_arg_dynamic_string_read) ASIO_TEST_CASE(test_4_arg_streambuf_read) ASIO_TEST_CASE(test_3_arg_mutable_buffer_async_read) ASIO_TEST_CASE(test_3_arg_boost_array_buffers_async_read) ASIO_TEST_CASE(test_3_arg_std_array_buffers_async_read) ASIO_TEST_CASE(test_3_arg_vector_buffers_async_read) + ASIO_TEST_CASE(test_3_arg_dynamic_string_async_read) ASIO_TEST_CASE(test_3_arg_streambuf_async_read) ASIO_TEST_CASE(test_4_arg_mutable_buffer_async_read) ASIO_TEST_CASE(test_4_arg_vector_buffers_async_read) ASIO_TEST_CASE(test_4_arg_boost_array_buffers_async_read) ASIO_TEST_CASE(test_4_arg_std_array_buffers_async_read) + ASIO_TEST_CASE(test_4_arg_dynamic_string_async_read) ASIO_TEST_CASE(test_4_arg_streambuf_async_read) ) diff --git a/3rdparty/asio/src/tests/unit/read_at.cpp b/3rdparty/asio/src/tests/unit/read_at.cpp index 5b2f5ebace3..72d21bc3236 100644 --- a/3rdparty/asio/src/tests/unit/read_at.cpp +++ b/3rdparty/asio/src/tests/unit/read_at.cpp @@ -2,7 +2,7 @@ // read_at.cpp // ~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -16,27 +16,19 @@ // Test that header file is self-contained. #include "asio/read_at.hpp" +#include <array> #include <cstring> +#include <functional> #include "archetypes/async_result.hpp" #include "asio/io_context.hpp" #include "asio/post.hpp" #include "asio/streambuf.hpp" #include "unit_test.hpp" -#if defined(ASIO_HAS_BOOST_BIND) -# include <boost/bind.hpp> -#else // defined(ASIO_HAS_BOOST_BIND) -# include <functional> -#endif // defined(ASIO_HAS_BOOST_BIND) - #if defined(ASIO_HAS_BOOST_ARRAY) #include <boost/array.hpp> #endif // defined(ASIO_HAS_BOOST_ARRAY) -#if defined(ASIO_HAS_STD_ARRAY) -# include <array> -#endif // defined(ASIO_HAS_STD_ARRAY) - using namespace std; // For memcmp, memcpy and memset. class test_random_access_device @@ -51,7 +43,7 @@ public: { } - executor_type get_executor() ASIO_NOEXCEPT + executor_type get_executor() noexcept { return io_context_.get_executor(); } @@ -125,12 +117,12 @@ public: template <typename Mutable_Buffers, typename Handler> void async_read_some_at(asio::uint64_t offset, - const Mutable_Buffers& buffers, Handler handler) + const Mutable_Buffers& buffers, Handler&& handler) { size_t bytes_transferred = read_some_at(offset, buffers); asio::post(get_executor(), asio::detail::bind_handler( - ASIO_MOVE_CAST(Handler)(handler), + static_cast<Handler&&>(handler), asio::error_code(), bytes_transferred)); } @@ -476,11 +468,16 @@ bool old_style_transfer_all(const asio::error_code& ec, return !!ec; } -size_t short_transfer(const asio::error_code& ec, - size_t /*bytes_transferred*/) +struct short_transfer { - return !!ec ? 0 : 3; -} + short_transfer() {} + short_transfer(short_transfer&&) {} + size_t operator()(const asio::error_code& ec, + size_t /*bytes_transferred*/) + { + return !!ec ? 0 : 3; + } +}; void test_4_arg_mutable_buffer_read_at() { @@ -860,41 +857,41 @@ void test_4_arg_mutable_buffer_read_at() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); - bytes_transferred = asio::read_at(s, 0, buffers, short_transfer); + bytes_transferred = asio::read_at(s, 0, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data))); s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); - bytes_transferred = asio::read_at(s, 1234, buffers, short_transfer); + bytes_transferred = asio::read_at(s, 1234, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data))); s.reset(read_data, sizeof(read_data)); s.next_read_length(1); memset(read_buf, 0, sizeof(read_buf)); - bytes_transferred = asio::read_at(s, 0, buffers, short_transfer); + bytes_transferred = asio::read_at(s, 0, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data))); s.reset(read_data, sizeof(read_data)); s.next_read_length(1); memset(read_buf, 0, sizeof(read_buf)); - bytes_transferred = asio::read_at(s, 1234, buffers, short_transfer); + bytes_transferred = asio::read_at(s, 1234, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data))); s.reset(read_data, sizeof(read_data)); s.next_read_length(10); memset(read_buf, 0, sizeof(read_buf)); - bytes_transferred = asio::read_at(s, 0, buffers, short_transfer); + bytes_transferred = asio::read_at(s, 0, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data))); s.reset(read_data, sizeof(read_data)); s.next_read_length(10); memset(read_buf, 0, sizeof(read_buf)); - bytes_transferred = asio::read_at(s, 1234, buffers, short_transfer); + bytes_transferred = asio::read_at(s, 1234, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data))); } @@ -1278,41 +1275,41 @@ void test_4_arg_vector_buffers_read_at() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); - bytes_transferred = asio::read_at(s, 0, buffers, short_transfer); + bytes_transferred = asio::read_at(s, 0, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data))); s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); - bytes_transferred = asio::read_at(s, 1234, buffers, short_transfer); + bytes_transferred = asio::read_at(s, 1234, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data))); s.reset(read_data, sizeof(read_data)); s.next_read_length(1); memset(read_buf, 0, sizeof(read_buf)); - bytes_transferred = asio::read_at(s, 0, buffers, short_transfer); + bytes_transferred = asio::read_at(s, 0, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data))); s.reset(read_data, sizeof(read_data)); s.next_read_length(1); memset(read_buf, 0, sizeof(read_buf)); - bytes_transferred = asio::read_at(s, 1234, buffers, short_transfer); + bytes_transferred = asio::read_at(s, 1234, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data))); s.reset(read_data, sizeof(read_data)); s.next_read_length(10); memset(read_buf, 0, sizeof(read_buf)); - bytes_transferred = asio::read_at(s, 0, buffers, short_transfer); + bytes_transferred = asio::read_at(s, 0, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data))); s.reset(read_data, sizeof(read_data)); s.next_read_length(10); memset(read_buf, 0, sizeof(read_buf)); - bytes_transferred = asio::read_at(s, 1234, buffers, short_transfer); + bytes_transferred = asio::read_at(s, 1234, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data))); } @@ -1741,14 +1738,14 @@ void test_4_arg_streambuf_read_at() s.reset(read_data, sizeof(read_data)); sb.consume(sb.size()); - bytes_transferred = asio::read_at(s, 0, sb, short_transfer); + bytes_transferred = asio::read_at(s, 0, sb, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(sb.size() == sizeof(read_data)); ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data))); s.reset(read_data, sizeof(read_data)); sb.consume(sb.size()); - bytes_transferred = asio::read_at(s, 1234, sb, short_transfer); + bytes_transferred = asio::read_at(s, 1234, sb, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(sb.size() == sizeof(read_data)); ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data))); @@ -1756,7 +1753,7 @@ void test_4_arg_streambuf_read_at() s.reset(read_data, sizeof(read_data)); s.next_read_length(1); sb.consume(sb.size()); - bytes_transferred = asio::read_at(s, 0, sb, short_transfer); + bytes_transferred = asio::read_at(s, 0, sb, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(sb.size() == sizeof(read_data)); ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data))); @@ -1764,7 +1761,7 @@ void test_4_arg_streambuf_read_at() s.reset(read_data, sizeof(read_data)); s.next_read_length(1); sb.consume(sb.size()); - bytes_transferred = asio::read_at(s, 1234, sb, short_transfer); + bytes_transferred = asio::read_at(s, 1234, sb, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(sb.size() == sizeof(read_data)); ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data))); @@ -1772,7 +1769,7 @@ void test_4_arg_streambuf_read_at() s.reset(read_data, sizeof(read_data)); s.next_read_length(10); sb.consume(sb.size()); - bytes_transferred = asio::read_at(s, 0, sb, short_transfer); + bytes_transferred = asio::read_at(s, 0, sb, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(sb.size() == sizeof(read_data)); ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data))); @@ -1780,7 +1777,7 @@ void test_4_arg_streambuf_read_at() s.reset(read_data, sizeof(read_data)); s.next_read_length(10); sb.consume(sb.size()); - bytes_transferred = asio::read_at(s, 1234, sb, short_transfer); + bytes_transferred = asio::read_at(s, 1234, sb, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(sb.size() == sizeof(read_data)); ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data))); @@ -2258,7 +2255,7 @@ void test_5_arg_mutable_buffer_read_at() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); bytes_transferred = asio::read_at(s, 0, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data))); ASIO_CHECK(!error); @@ -2266,7 +2263,7 @@ void test_5_arg_mutable_buffer_read_at() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); bytes_transferred = asio::read_at(s, 1234, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data))); ASIO_CHECK(!error); @@ -2276,7 +2273,7 @@ void test_5_arg_mutable_buffer_read_at() memset(read_buf, 0, sizeof(read_buf)); error = asio::error_code(); bytes_transferred = asio::read_at(s, 0, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data))); ASIO_CHECK(!error); @@ -2286,7 +2283,7 @@ void test_5_arg_mutable_buffer_read_at() memset(read_buf, 0, sizeof(read_buf)); error = asio::error_code(); bytes_transferred = asio::read_at(s, 1234, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data))); ASIO_CHECK(!error); @@ -2296,7 +2293,7 @@ void test_5_arg_mutable_buffer_read_at() memset(read_buf, 0, sizeof(read_buf)); error = asio::error_code(); bytes_transferred = asio::read_at(s, 0, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data))); ASIO_CHECK(!error); @@ -2306,7 +2303,7 @@ void test_5_arg_mutable_buffer_read_at() memset(read_buf, 0, sizeof(read_buf)); error = asio::error_code(); bytes_transferred = asio::read_at(s, 1234, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data))); ASIO_CHECK(!error); @@ -2785,7 +2782,7 @@ void test_5_arg_vector_buffers_read_at() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); bytes_transferred = asio::read_at(s, 0, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data))); ASIO_CHECK(!error); @@ -2793,7 +2790,7 @@ void test_5_arg_vector_buffers_read_at() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); bytes_transferred = asio::read_at(s, 1234, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data))); ASIO_CHECK(!error); @@ -2803,7 +2800,7 @@ void test_5_arg_vector_buffers_read_at() memset(read_buf, 0, sizeof(read_buf)); error = asio::error_code(); bytes_transferred = asio::read_at(s, 0, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data))); ASIO_CHECK(!error); @@ -2813,7 +2810,7 @@ void test_5_arg_vector_buffers_read_at() memset(read_buf, 0, sizeof(read_buf)); error = asio::error_code(); bytes_transferred = asio::read_at(s, 1234, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data))); ASIO_CHECK(!error); @@ -2823,7 +2820,7 @@ void test_5_arg_vector_buffers_read_at() memset(read_buf, 0, sizeof(read_buf)); error = asio::error_code(); bytes_transferred = asio::read_at(s, 0, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data))); ASIO_CHECK(!error); @@ -2833,7 +2830,7 @@ void test_5_arg_vector_buffers_read_at() memset(read_buf, 0, sizeof(read_buf)); error = asio::error_code(); bytes_transferred = asio::read_at(s, 1234, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data))); ASIO_CHECK(!error); @@ -3357,7 +3354,7 @@ void test_5_arg_streambuf_read_at() s.reset(read_data, sizeof(read_data)); sb.consume(sb.size()); bytes_transferred = asio::read_at(s, 0, sb, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(sb.size() == sizeof(read_data)); ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data))); @@ -3366,7 +3363,7 @@ void test_5_arg_streambuf_read_at() s.reset(read_data, sizeof(read_data)); sb.consume(sb.size()); bytes_transferred = asio::read_at(s, 1234, sb, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(sb.size() == sizeof(read_data)); ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data))); @@ -3377,7 +3374,7 @@ void test_5_arg_streambuf_read_at() sb.consume(sb.size()); error = asio::error_code(); bytes_transferred = asio::read_at(s, 0, sb, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(sb.size() == sizeof(read_data)); ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data))); @@ -3388,7 +3385,7 @@ void test_5_arg_streambuf_read_at() sb.consume(sb.size()); error = asio::error_code(); bytes_transferred = asio::read_at(s, 1234, sb, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(sb.size() == sizeof(read_data)); ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data))); @@ -3399,7 +3396,7 @@ void test_5_arg_streambuf_read_at() sb.consume(sb.size()); error = asio::error_code(); bytes_transferred = asio::read_at(s, 0, sb, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(sb.size() == sizeof(read_data)); ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data))); @@ -3410,7 +3407,7 @@ void test_5_arg_streambuf_read_at() sb.consume(sb.size()); error = asio::error_code(); bytes_transferred = asio::read_at(s, 1234, sb, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(read_data)); ASIO_CHECK(sb.size() == sizeof(read_data)); ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data))); @@ -3427,13 +3424,9 @@ void async_read_handler(const asio::error_code& e, void test_4_arg_mutable_buffer_async_read_at() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_random_access_device s(ioc); @@ -3523,13 +3516,9 @@ void test_4_arg_mutable_buffer_async_read_at() void test_4_arg_boost_array_buffers_async_read_at() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; #if defined(ASIO_HAS_BOOST_ARRAY) asio::io_context ioc; @@ -3622,15 +3611,10 @@ void test_4_arg_boost_array_buffers_async_read_at() void test_4_arg_std_array_buffers_async_read_at() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; -#if defined(ASIO_HAS_STD_ARRAY) asio::io_context ioc; test_random_access_device s(ioc); char read_buf[sizeof(read_data)]; @@ -3716,18 +3700,13 @@ void test_4_arg_std_array_buffers_async_read_at() ioc.restart(); ioc.run(); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data))); -#endif // defined(ASIO_HAS_STD_ARRAY) } void test_4_arg_vector_buffers_async_read_at() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_random_access_device s(ioc); @@ -3818,13 +3797,9 @@ void test_4_arg_vector_buffers_async_read_at() void test_4_arg_streambuf_async_read_at() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_random_access_device s(ioc); @@ -3918,13 +3893,9 @@ void test_4_arg_streambuf_async_read_at() void test_5_arg_mutable_buffer_async_read_at() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_random_access_device s(ioc); @@ -4537,7 +4508,7 @@ void test_5_arg_mutable_buffer_async_read_at() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 0, buffers, short_transfer, + asio::async_read_at(s, 0, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -4548,7 +4519,7 @@ void test_5_arg_mutable_buffer_async_read_at() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 1234, buffers, short_transfer, + asio::async_read_at(s, 1234, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -4560,7 +4531,7 @@ void test_5_arg_mutable_buffer_async_read_at() s.next_read_length(1); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 0, buffers, short_transfer, + asio::async_read_at(s, 0, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -4572,7 +4543,7 @@ void test_5_arg_mutable_buffer_async_read_at() s.next_read_length(1); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 1234, buffers, short_transfer, + asio::async_read_at(s, 1234, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -4584,7 +4555,7 @@ void test_5_arg_mutable_buffer_async_read_at() s.next_read_length(10); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 0, buffers, short_transfer, + asio::async_read_at(s, 0, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -4596,7 +4567,7 @@ void test_5_arg_mutable_buffer_async_read_at() s.next_read_length(10); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 1234, buffers, short_transfer, + asio::async_read_at(s, 1234, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -4607,7 +4578,7 @@ void test_5_arg_mutable_buffer_async_read_at() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); int i = asio::async_read_at(s, 1234, buffers, - short_transfer, archetypes::lazy_handler()); + short_transfer(), archetypes::lazy_handler()); ASIO_CHECK(i == 42); ioc.restart(); ioc.run(); @@ -4616,13 +4587,9 @@ void test_5_arg_mutable_buffer_async_read_at() void test_5_arg_boost_array_buffers_async_read_at() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; #if defined(ASIO_HAS_BOOST_ARRAY) asio::io_context ioc; @@ -5237,7 +5204,7 @@ void test_5_arg_boost_array_buffers_async_read_at() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 0, buffers, short_transfer, + asio::async_read_at(s, 0, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -5248,7 +5215,7 @@ void test_5_arg_boost_array_buffers_async_read_at() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 1234, buffers, short_transfer, + asio::async_read_at(s, 1234, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -5260,7 +5227,7 @@ void test_5_arg_boost_array_buffers_async_read_at() s.next_read_length(1); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 0, buffers, short_transfer, + asio::async_read_at(s, 0, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -5272,7 +5239,7 @@ void test_5_arg_boost_array_buffers_async_read_at() s.next_read_length(1); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 1234, buffers, short_transfer, + asio::async_read_at(s, 1234, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -5284,7 +5251,7 @@ void test_5_arg_boost_array_buffers_async_read_at() s.next_read_length(10); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 0, buffers, short_transfer, + asio::async_read_at(s, 0, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -5296,7 +5263,7 @@ void test_5_arg_boost_array_buffers_async_read_at() s.next_read_length(10); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 1234, buffers, short_transfer, + asio::async_read_at(s, 1234, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -5307,7 +5274,7 @@ void test_5_arg_boost_array_buffers_async_read_at() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); int i = asio::async_read_at(s, 1234, buffers, - short_transfer, archetypes::lazy_handler()); + short_transfer(), archetypes::lazy_handler()); ASIO_CHECK(i == 42); ioc.restart(); ioc.run(); @@ -5317,15 +5284,10 @@ void test_5_arg_boost_array_buffers_async_read_at() void test_5_arg_std_array_buffers_async_read_at() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; -#if defined(ASIO_HAS_STD_ARRAY) asio::io_context ioc; test_random_access_device s(ioc); char read_buf[sizeof(read_data)]; @@ -5938,7 +5900,7 @@ void test_5_arg_std_array_buffers_async_read_at() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 0, buffers, short_transfer, + asio::async_read_at(s, 0, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -5949,7 +5911,7 @@ void test_5_arg_std_array_buffers_async_read_at() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 1234, buffers, short_transfer, + asio::async_read_at(s, 1234, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -5961,7 +5923,7 @@ void test_5_arg_std_array_buffers_async_read_at() s.next_read_length(1); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 0, buffers, short_transfer, + asio::async_read_at(s, 0, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -5973,7 +5935,7 @@ void test_5_arg_std_array_buffers_async_read_at() s.next_read_length(1); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 1234, buffers, short_transfer, + asio::async_read_at(s, 1234, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -5985,7 +5947,7 @@ void test_5_arg_std_array_buffers_async_read_at() s.next_read_length(10); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 0, buffers, short_transfer, + asio::async_read_at(s, 0, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -5997,7 +5959,7 @@ void test_5_arg_std_array_buffers_async_read_at() s.next_read_length(10); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 1234, buffers, short_transfer, + asio::async_read_at(s, 1234, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -6008,23 +5970,18 @@ void test_5_arg_std_array_buffers_async_read_at() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); int i = asio::async_read_at(s, 1234, buffers, - short_transfer, archetypes::lazy_handler()); + short_transfer(), archetypes::lazy_handler()); ASIO_CHECK(i == 42); ioc.restart(); ioc.run(); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data))); -#endif // defined(ASIO_HAS_STD_ARRAY) } void test_5_arg_vector_buffers_async_read_at() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_random_access_device s(ioc); @@ -6638,7 +6595,7 @@ void test_5_arg_vector_buffers_async_read_at() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 0, buffers, short_transfer, + asio::async_read_at(s, 0, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -6649,7 +6606,7 @@ void test_5_arg_vector_buffers_async_read_at() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 1234, buffers, short_transfer, + asio::async_read_at(s, 1234, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -6661,7 +6618,7 @@ void test_5_arg_vector_buffers_async_read_at() s.next_read_length(1); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 0, buffers, short_transfer, + asio::async_read_at(s, 0, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -6673,7 +6630,7 @@ void test_5_arg_vector_buffers_async_read_at() s.next_read_length(1); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 1234, buffers, short_transfer, + asio::async_read_at(s, 1234, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -6685,7 +6642,7 @@ void test_5_arg_vector_buffers_async_read_at() s.next_read_length(10); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 0, buffers, short_transfer, + asio::async_read_at(s, 0, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -6697,7 +6654,7 @@ void test_5_arg_vector_buffers_async_read_at() s.next_read_length(10); memset(read_buf, 0, sizeof(read_buf)); called = false; - asio::async_read_at(s, 1234, buffers, short_transfer, + asio::async_read_at(s, 1234, buffers, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -6708,7 +6665,7 @@ void test_5_arg_vector_buffers_async_read_at() s.reset(read_data, sizeof(read_data)); memset(read_buf, 0, sizeof(read_buf)); int i = asio::async_read_at(s, 1234, buffers, - short_transfer, archetypes::lazy_handler()); + short_transfer(), archetypes::lazy_handler()); ASIO_CHECK(i == 42); ioc.restart(); ioc.run(); @@ -6717,13 +6674,9 @@ void test_5_arg_vector_buffers_async_read_at() void test_5_arg_streambuf_async_read_at() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_random_access_device s(ioc); @@ -7382,7 +7335,7 @@ void test_5_arg_streambuf_async_read_at() s.reset(read_data, sizeof(read_data)); sb.consume(sb.size()); called = false; - asio::async_read_at(s, 0, sb, short_transfer, + asio::async_read_at(s, 0, sb, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -7394,7 +7347,7 @@ void test_5_arg_streambuf_async_read_at() s.reset(read_data, sizeof(read_data)); sb.consume(sb.size()); called = false; - asio::async_read_at(s, 1234, sb, short_transfer, + asio::async_read_at(s, 1234, sb, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -7407,7 +7360,7 @@ void test_5_arg_streambuf_async_read_at() s.next_read_length(1); sb.consume(sb.size()); called = false; - asio::async_read_at(s, 0, sb, short_transfer, + asio::async_read_at(s, 0, sb, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -7420,7 +7373,7 @@ void test_5_arg_streambuf_async_read_at() s.next_read_length(1); sb.consume(sb.size()); called = false; - asio::async_read_at(s, 1234, sb, short_transfer, + asio::async_read_at(s, 1234, sb, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -7433,7 +7386,7 @@ void test_5_arg_streambuf_async_read_at() s.next_read_length(10); sb.consume(sb.size()); called = false; - asio::async_read_at(s, 0, sb, short_transfer, + asio::async_read_at(s, 0, sb, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -7446,7 +7399,7 @@ void test_5_arg_streambuf_async_read_at() s.next_read_length(10); sb.consume(sb.size()); called = false; - asio::async_read_at(s, 1234, sb, short_transfer, + asio::async_read_at(s, 1234, sb, short_transfer(), bindns::bind(async_read_handler, _1, _2, sizeof(read_data), &called)); ioc.restart(); @@ -7458,7 +7411,7 @@ void test_5_arg_streambuf_async_read_at() s.reset(read_data, sizeof(read_data)); sb.consume(sb.size()); int i = asio::async_read_at(s, 1234, sb, - short_transfer, archetypes::lazy_handler()); + short_transfer(), archetypes::lazy_handler()); ASIO_CHECK(i == 42); ioc.restart(); ioc.run(); diff --git a/3rdparty/asio/src/tests/unit/read_until.cpp b/3rdparty/asio/src/tests/unit/read_until.cpp index 782ac2f4b6b..139fcf6f0a9 100644 --- a/3rdparty/asio/src/tests/unit/read_until.cpp +++ b/3rdparty/asio/src/tests/unit/read_until.cpp @@ -2,7 +2,7 @@ // read_until.cpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -17,18 +17,13 @@ #include "asio/read_until.hpp" #include <cstring> +#include <functional> #include "archetypes/async_result.hpp" #include "asio/io_context.hpp" #include "asio/post.hpp" #include "asio/streambuf.hpp" #include "unit_test.hpp" -#if defined(ASIO_HAS_BOOST_BIND) -# include <boost/bind.hpp> -#else // defined(ASIO_HAS_BOOST_BIND) -# include <functional> -#endif // defined(ASIO_HAS_BOOST_BIND) - class test_stream { public: @@ -42,7 +37,7 @@ public: { } - executor_type get_executor() ASIO_NOEXCEPT + executor_type get_executor() noexcept { return io_context_.get_executor(); } @@ -88,7 +83,7 @@ public: size_t bytes_transferred = read_some(buffers); asio::post(get_executor(), asio::detail::bind_handler( - ASIO_MOVE_CAST(Handler)(handler), + static_cast<Handler&&>(handler), asio::error_code(), bytes_transferred)); } @@ -104,8 +99,98 @@ private: static const char read_data[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; -void test_char_read_until() +void test_dynamic_string_read_until_char() +{ + asio::io_context ioc; + test_stream s(ioc); + std::string data1, data2; + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb1 = asio::dynamic_buffer(data1); + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb2 = asio::dynamic_buffer(data2, 25); + asio::error_code ec; + + s.reset(read_data, sizeof(read_data)); + sb1.consume(sb1.size()); + std::size_t length = asio::read_until(s, sb1, 'Z'); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb1.consume(sb1.size()); + length = asio::read_until(s, sb1, 'Z'); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb1.consume(sb1.size()); + length = asio::read_until(s, sb1, 'Z'); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + sb1.consume(sb1.size()); + length = asio::read_until(s, sb1, 'Z', ec); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb1.consume(sb1.size()); + length = asio::read_until(s, sb1, 'Z', ec); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb1.consume(sb1.size()); + length = asio::read_until(s, sb1, 'Z', ec); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + sb2.consume(sb2.size()); + length = asio::read_until(s, sb2, 'Z', ec); + ASIO_CHECK(ec == asio::error::not_found); + ASIO_CHECK(length == 0); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb2.consume(sb2.size()); + length = asio::read_until(s, sb2, 'Z', ec); + ASIO_CHECK(ec == asio::error::not_found); + ASIO_CHECK(length == 0); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb2.consume(sb2.size()); + length = asio::read_until(s, sb2, 'Z', ec); + ASIO_CHECK(ec == asio::error::not_found); + ASIO_CHECK(length == 0); + + s.reset(read_data, sizeof(read_data)); + sb2.consume(sb2.size()); + length = asio::read_until(s, sb2, 'Y', ec); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 25); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb2.consume(sb2.size()); + length = asio::read_until(s, sb2, 'Y', ec); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 25); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb2.consume(sb2.size()); + length = asio::read_until(s, sb2, 'Y', ec); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 25); +} + +void test_streambuf_read_until_char() { +#if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) asio::io_context ioc; test_stream s(ioc); asio::streambuf sb1; @@ -188,12 +273,103 @@ void test_char_read_until() length = asio::read_until(s, sb2, 'Y', ec); ASIO_CHECK(!ec); ASIO_CHECK(length == 25); +#endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) } -void test_string_read_until() +void test_dynamic_string_read_until_string() { asio::io_context ioc; test_stream s(ioc); + std::string data1, data2; + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb1 = asio::dynamic_buffer(data1); + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb2 = asio::dynamic_buffer(data2, 25); + asio::error_code ec; + + s.reset(read_data, sizeof(read_data)); + sb1.consume(sb1.size()); + std::size_t length = asio::read_until(s, sb1, "XYZ"); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb1.consume(sb1.size()); + length = asio::read_until(s, sb1, "XYZ"); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb1.consume(sb1.size()); + length = asio::read_until(s, sb1, "XYZ"); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + sb1.consume(sb1.size()); + length = asio::read_until(s, sb1, "XYZ", ec); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb1.consume(sb1.size()); + length = asio::read_until(s, sb1, "XYZ", ec); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb1.consume(sb1.size()); + length = asio::read_until(s, sb1, "XYZ", ec); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + sb2.consume(sb2.size()); + length = asio::read_until(s, sb2, "XYZ", ec); + ASIO_CHECK(ec == asio::error::not_found); + ASIO_CHECK(length == 0); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb2.consume(sb2.size()); + length = asio::read_until(s, sb2, "XYZ", ec); + ASIO_CHECK(ec == asio::error::not_found); + ASIO_CHECK(length == 0); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb2.consume(sb2.size()); + length = asio::read_until(s, sb2, "XYZ", ec); + ASIO_CHECK(ec == asio::error::not_found); + ASIO_CHECK(length == 0); + + s.reset(read_data, sizeof(read_data)); + sb2.consume(sb2.size()); + length = asio::read_until(s, sb2, "WXY", ec); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 25); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb2.consume(sb2.size()); + length = asio::read_until(s, sb2, "WXY", ec); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 25); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb2.consume(sb2.size()); + length = asio::read_until(s, sb2, "WXY", ec); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 25); +} + +void test_streambuf_read_until_string() +{ +#if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) + asio::io_context ioc; + test_stream s(ioc); asio::streambuf sb1; asio::streambuf sb2(25); asio::error_code ec; @@ -274,6 +450,7 @@ void test_string_read_until() length = asio::read_until(s, sb2, "WXY", ec); ASIO_CHECK(!ec); ASIO_CHECK(length == 25); +#endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) } class match_char @@ -303,8 +480,98 @@ namespace asio { }; } // namespace asio -void test_match_condition_read_until() +void test_dynamic_string_read_until_match_condition() +{ + asio::io_context ioc; + test_stream s(ioc); + std::string data1, data2; + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb1 = asio::dynamic_buffer(data1); + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb2 = asio::dynamic_buffer(data2, 25); + asio::error_code ec; + + s.reset(read_data, sizeof(read_data)); + sb1.consume(sb1.size()); + std::size_t length = asio::read_until(s, sb1, match_char('Z')); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb1.consume(sb1.size()); + length = asio::read_until(s, sb1, match_char('Z')); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb1.consume(sb1.size()); + length = asio::read_until(s, sb1, match_char('Z')); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + sb1.consume(sb1.size()); + length = asio::read_until(s, sb1, match_char('Z'), ec); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb1.consume(sb1.size()); + length = asio::read_until(s, sb1, match_char('Z'), ec); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb1.consume(sb1.size()); + length = asio::read_until(s, sb1, match_char('Z'), ec); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + sb2.consume(sb2.size()); + length = asio::read_until(s, sb2, match_char('Z'), ec); + ASIO_CHECK(ec == asio::error::not_found); + ASIO_CHECK(length == 0); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb2.consume(sb2.size()); + length = asio::read_until(s, sb2, match_char('Z'), ec); + ASIO_CHECK(ec == asio::error::not_found); + ASIO_CHECK(length == 0); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb2.consume(sb2.size()); + length = asio::read_until(s, sb2, match_char('Z'), ec); + ASIO_CHECK(ec == asio::error::not_found); + ASIO_CHECK(length == 0); + + s.reset(read_data, sizeof(read_data)); + sb2.consume(sb2.size()); + length = asio::read_until(s, sb2, match_char('Y'), ec); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 25); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + sb2.consume(sb2.size()); + length = asio::read_until(s, sb2, match_char('Y'), ec); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 25); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + sb2.consume(sb2.size()); + length = asio::read_until(s, sb2, match_char('Y'), ec); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 25); +} + +void test_streambuf_read_until_match_condition() { +#if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) asio::io_context ioc; test_stream s(ioc); asio::streambuf sb1; @@ -387,6 +654,7 @@ void test_match_condition_read_until() length = asio::read_until(s, sb2, match_char('Y'), ec); ASIO_CHECK(!ec); ASIO_CHECK(length == 25); +#endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) } void async_read_handler( @@ -398,15 +666,170 @@ void async_read_handler( *called = true; } -void test_char_async_read_until() +void test_dynamic_string_async_read_until_char() +{ + namespace bindns = std; + using bindns::placeholders::_1; + using bindns::placeholders::_2; + + asio::io_context ioc; + test_stream s(ioc); + std::string data1, data2; + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb1 = asio::dynamic_buffer(data1); + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb2 = asio::dynamic_buffer(data2, 25); + asio::error_code ec; + std::size_t length; + bool called; + + s.reset(read_data, sizeof(read_data)); + ec = asio::error_code(); + length = 0; + called = false; + sb1.consume(sb1.size()); + asio::async_read_until(s, sb1, 'Z', + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + ec = asio::error_code(); + length = 0; + called = false; + sb1.consume(sb1.size()); + asio::async_read_until(s, sb1, 'Z', + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + ec = asio::error_code(); + length = 0; + called = false; + sb1.consume(sb1.size()); + asio::async_read_until(s, sb1, 'Z', + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + ec = asio::error_code(); + length = 0; + called = false; + sb2.consume(sb2.size()); + asio::async_read_until(s, sb2, 'Z', + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(ec == asio::error::not_found); + ASIO_CHECK(length == 0); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + ec = asio::error_code(); + length = 0; + called = false; + sb2.consume(sb2.size()); + asio::async_read_until(s, sb2, 'Z', + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(ec == asio::error::not_found); + ASIO_CHECK(length == 0); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + ec = asio::error_code(); + length = 0; + called = false; + sb2.consume(sb2.size()); + asio::async_read_until(s, sb2, 'Z', + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(ec == asio::error::not_found); + ASIO_CHECK(length == 0); + + s.reset(read_data, sizeof(read_data)); + ec = asio::error_code(); + length = 0; + called = false; + sb2.consume(sb2.size()); + asio::async_read_until(s, sb2, 'Y', + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 25); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + ec = asio::error_code(); + length = 0; + called = false; + sb2.consume(sb2.size()); + asio::async_read_until(s, sb2, 'Y', + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 25); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + ec = asio::error_code(); + length = 0; + called = false; + sb2.consume(sb2.size()); + asio::async_read_until(s, sb2, 'Y', + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 25); + + s.reset(read_data, sizeof(read_data)); + sb2.consume(sb2.size()); + int i = asio::async_read_until(s, sb2, 'Y', + archetypes::lazy_handler()); + ASIO_CHECK(i == 42); + ioc.restart(); + ioc.run(); +} + +void test_streambuf_async_read_until_char() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) +#if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_stream s(ioc); @@ -555,17 +978,173 @@ void test_char_async_read_until() ASIO_CHECK(i == 42); ioc.restart(); ioc.run(); +#endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) +} + +void test_dynamic_string_async_read_until_string() +{ + namespace bindns = std; + using bindns::placeholders::_1; + using bindns::placeholders::_2; + + asio::io_context ioc; + test_stream s(ioc); + std::string data1, data2; + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb1 = asio::dynamic_buffer(data1); + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb2 = asio::dynamic_buffer(data2, 25); + asio::error_code ec; + std::size_t length; + bool called; + + s.reset(read_data, sizeof(read_data)); + ec = asio::error_code(); + length = 0; + called = false; + sb1.consume(sb1.size()); + asio::async_read_until(s, sb1, "XYZ", + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + ec = asio::error_code(); + length = 0; + called = false; + sb1.consume(sb1.size()); + asio::async_read_until(s, sb1, "XYZ", + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + ec = asio::error_code(); + length = 0; + called = false; + sb1.consume(sb1.size()); + asio::async_read_until(s, sb1, "XYZ", + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + ec = asio::error_code(); + length = 0; + called = false; + sb2.consume(sb2.size()); + asio::async_read_until(s, sb2, "XYZ", + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(ec == asio::error::not_found); + ASIO_CHECK(length == 0); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + ec = asio::error_code(); + length = 0; + called = false; + sb2.consume(sb2.size()); + asio::async_read_until(s, sb2, "XYZ", + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(ec == asio::error::not_found); + ASIO_CHECK(length == 0); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + ec = asio::error_code(); + length = 0; + called = false; + sb2.consume(sb2.size()); + asio::async_read_until(s, sb2, "XYZ", + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(ec == asio::error::not_found); + ASIO_CHECK(length == 0); + + s.reset(read_data, sizeof(read_data)); + ec = asio::error_code(); + length = 0; + called = false; + sb2.consume(sb2.size()); + asio::async_read_until(s, sb2, "WXY", + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 25); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + ec = asio::error_code(); + length = 0; + called = false; + sb2.consume(sb2.size()); + asio::async_read_until(s, sb2, "WXY", + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 25); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + ec = asio::error_code(); + length = 0; + called = false; + sb2.consume(sb2.size()); + asio::async_read_until(s, sb2, "WXY", + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 25); + + s.reset(read_data, sizeof(read_data)); + sb2.consume(sb2.size()); + int i = asio::async_read_until(s, sb2, "WXY", + archetypes::lazy_handler()); + ASIO_CHECK(i == 42); + ioc.restart(); + ioc.run(); } -void test_string_async_read_until() +void test_streambuf_async_read_until_string() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) +#if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_stream s(ioc); @@ -714,17 +1293,173 @@ void test_string_async_read_until() ASIO_CHECK(i == 42); ioc.restart(); ioc.run(); +#endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) +} + +void test_dynamic_string_async_read_until_match_condition() +{ + namespace bindns = std; + using bindns::placeholders::_1; + using bindns::placeholders::_2; + + asio::io_context ioc; + test_stream s(ioc); + std::string data1, data2; + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb1 = asio::dynamic_buffer(data1); + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb2 = asio::dynamic_buffer(data2, 25); + asio::error_code ec; + std::size_t length; + bool called; + + s.reset(read_data, sizeof(read_data)); + ec = asio::error_code(); + length = 0; + called = false; + sb1.consume(sb1.size()); + asio::async_read_until(s, sb1, match_char('Z'), + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + ec = asio::error_code(); + length = 0; + called = false; + sb1.consume(sb1.size()); + asio::async_read_until(s, sb1, match_char('Z'), + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + ec = asio::error_code(); + length = 0; + called = false; + sb1.consume(sb1.size()); + asio::async_read_until(s, sb1, match_char('Z'), + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 26); + + s.reset(read_data, sizeof(read_data)); + ec = asio::error_code(); + length = 0; + called = false; + sb2.consume(sb2.size()); + asio::async_read_until(s, sb2, match_char('Z'), + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(ec == asio::error::not_found); + ASIO_CHECK(length == 0); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + ec = asio::error_code(); + length = 0; + called = false; + sb2.consume(sb2.size()); + asio::async_read_until(s, sb2, match_char('Z'), + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(ec == asio::error::not_found); + ASIO_CHECK(length == 0); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + ec = asio::error_code(); + length = 0; + called = false; + sb2.consume(sb2.size()); + asio::async_read_until(s, sb2, match_char('Z'), + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(ec == asio::error::not_found); + ASIO_CHECK(length == 0); + + s.reset(read_data, sizeof(read_data)); + ec = asio::error_code(); + length = 0; + called = false; + sb2.consume(sb2.size()); + asio::async_read_until(s, sb2, match_char('Y'), + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 25); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(1); + ec = asio::error_code(); + length = 0; + called = false; + sb2.consume(sb2.size()); + asio::async_read_until(s, sb2, match_char('Y'), + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 25); + + s.reset(read_data, sizeof(read_data)); + s.next_read_length(10); + ec = asio::error_code(); + length = 0; + called = false; + sb2.consume(sb2.size()); + asio::async_read_until(s, sb2, match_char('Y'), + bindns::bind(async_read_handler, _1, &ec, + _2, &length, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(!ec); + ASIO_CHECK(length == 25); + + s.reset(read_data, sizeof(read_data)); + sb2.consume(sb2.size()); + int i = asio::async_read_until(s, sb2, match_char('Y'), + archetypes::lazy_handler()); + ASIO_CHECK(i == 42); + ioc.restart(); + ioc.run(); } -void test_match_condition_async_read_until() +void test_streambuf_async_read_until_match_condition() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) +#if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_stream s(ioc); @@ -873,15 +1608,22 @@ void test_match_condition_async_read_until() ASIO_CHECK(i == 42); ioc.restart(); ioc.run(); +#endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) } ASIO_TEST_SUITE ( "read_until", - ASIO_TEST_CASE(test_char_read_until) - ASIO_TEST_CASE(test_string_read_until) - ASIO_TEST_CASE(test_match_condition_read_until) - ASIO_TEST_CASE(test_char_async_read_until) - ASIO_TEST_CASE(test_string_async_read_until) - ASIO_TEST_CASE(test_match_condition_async_read_until) + ASIO_TEST_CASE(test_dynamic_string_read_until_char) + ASIO_TEST_CASE(test_streambuf_read_until_char) + ASIO_TEST_CASE(test_dynamic_string_read_until_string) + ASIO_TEST_CASE(test_streambuf_read_until_string) + ASIO_TEST_CASE(test_dynamic_string_read_until_match_condition) + ASIO_TEST_CASE(test_streambuf_read_until_match_condition) + ASIO_TEST_CASE(test_dynamic_string_async_read_until_char) + ASIO_TEST_CASE(test_streambuf_async_read_until_char) + ASIO_TEST_CASE(test_dynamic_string_async_read_until_string) + ASIO_TEST_CASE(test_streambuf_async_read_until_string) + ASIO_TEST_CASE(test_dynamic_string_async_read_until_match_condition) + ASIO_TEST_CASE(test_streambuf_async_read_until_match_condition) ) diff --git a/3rdparty/asio/src/tests/unit/readable_pipe.cpp b/3rdparty/asio/src/tests/unit/readable_pipe.cpp new file mode 100644 index 00000000000..6f29710e3da --- /dev/null +++ b/3rdparty/asio/src/tests/unit/readable_pipe.cpp @@ -0,0 +1,131 @@ +// +// readable_pipe.cpp +// ~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header pipe is self-contained. +#include "asio/readable_pipe.hpp" + +#include "archetypes/async_result.hpp" +#include "asio/io_context.hpp" +#include "unit_test.hpp" + +// readable_pipe_compile test +// ~~~~~~~~~~~~~~~~~~~~~~~~~~ +// The following test checks that all public member functions on the class +// readable_pipe compile and link correctly. Runtime failures are ignored. + +namespace readable_pipe_compile { + +struct write_some_handler +{ + write_some_handler() {} + void operator()(const asio::error_code&, std::size_t) {} + write_some_handler(write_some_handler&&) {} +private: + write_some_handler(const write_some_handler&); +}; + +struct read_some_handler +{ + read_some_handler() {} + void operator()(const asio::error_code&, std::size_t) {} + read_some_handler(read_some_handler&&) {} +private: + read_some_handler(const read_some_handler&); +}; + +void test() +{ +#if defined(ASIO_HAS_PIPE) + using namespace asio; + + try + { + io_context ioc; + const io_context::executor_type ioc_ex = ioc.get_executor(); + char mutable_char_buffer[128] = ""; + archetypes::lazy_handler lazy; + asio::error_code ec; + const std::string path; + + // basic_readable_pipe constructors. + + readable_pipe pipe1(ioc); + readable_pipe::native_handle_type native_pipe1 = pipe1.native_handle(); + readable_pipe pipe2(ioc, native_pipe1); + + readable_pipe pipe3(ioc_ex); + readable_pipe::native_handle_type native_pipe2 = pipe1.native_handle(); + readable_pipe pipe4(ioc_ex, native_pipe2); + + readable_pipe pipe5(std::move(pipe4)); + + basic_readable_pipe<io_context::executor_type> pipe6(ioc); + readable_pipe pipe7(std::move(pipe6)); + + // basic_readable_pipe operators. + + pipe1 = readable_pipe(ioc); + pipe1 = std::move(pipe2); + pipe1 = std::move(pipe6); + + // basic_io_object functions. + + readable_pipe::executor_type ex = pipe1.get_executor(); + (void)ex; + + // basic_readable_pipe functions. + + readable_pipe::native_handle_type native_pipe3 = pipe1.native_handle(); + pipe1.assign(native_pipe3); + readable_pipe::native_handle_type native_pipe4 = pipe1.native_handle(); + pipe1.assign(native_pipe4, ec); + + bool is_open = pipe1.is_open(); + (void)is_open; + + pipe1.close(); + pipe1.close(ec); + + readable_pipe::native_handle_type native_pipe5 = pipe1.release(); + (void)native_pipe5; + readable_pipe::native_handle_type native_pipe6 = pipe1.release(ec); + (void)native_pipe6; + + readable_pipe::native_handle_type native_pipe7 = pipe1.native_handle(); + (void)native_pipe7; + + pipe1.cancel(); + pipe1.cancel(ec); + + pipe1.read_some(buffer(mutable_char_buffer)); + pipe1.read_some(buffer(mutable_char_buffer), ec); + + pipe1.async_read_some(buffer(mutable_char_buffer), read_some_handler()); + int i3 = pipe1.async_read_some(buffer(mutable_char_buffer), lazy); + (void)i3; + } + catch (std::exception&) + { + } +#endif // defined(ASIO_HAS_PIPE) +} + +} // namespace readable_pipe_compile + +ASIO_TEST_SUITE +( + "readable_pipe", + ASIO_COMPILE_TEST_CASE(readable_pipe_compile::test) +) diff --git a/3rdparty/asio/src/tests/unit/recycling_allocator.cpp b/3rdparty/asio/src/tests/unit/recycling_allocator.cpp new file mode 100644 index 00000000000..cc4654fc9f0 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/recycling_allocator.cpp @@ -0,0 +1,80 @@ +// +// recycling_allocator.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/recycling_allocator.hpp" + +#include "unit_test.hpp" +#include <vector> +#include "asio/detail/type_traits.hpp" + +void recycling_allocator_test() +{ + ASIO_CHECK(( + asio::is_same< + asio::recycling_allocator<int>::value_type, + int + >::value)); + + ASIO_CHECK(( + asio::is_same< + asio::recycling_allocator<void>::value_type, + void + >::value)); + + ASIO_CHECK(( + asio::is_same< + asio::recycling_allocator<int>::rebind<char>::other, + asio::recycling_allocator<char> + >::value)); + + ASIO_CHECK(( + asio::is_same< + asio::recycling_allocator<void>::rebind<char>::other, + asio::recycling_allocator<char> + >::value)); + + asio::recycling_allocator<int> a1; + asio::recycling_allocator<int> a2(a1); + + ASIO_CHECK(a1 == a2); + ASIO_CHECK(!(a1 != a2)); + + asio::recycling_allocator<void> a3; + asio::recycling_allocator<void> a4(a3); + + ASIO_CHECK(a3 == a4); + ASIO_CHECK(!(a3 != a4)); + + asio::recycling_allocator<int> a5(a4); + (void)a5; + + asio::recycling_allocator<void> a6(a5); + (void)a6; + + int* p = a1.allocate(42); + ASIO_CHECK(p != 0); + + a1.deallocate(p, 42); + + std::vector<int, asio::recycling_allocator<int> > v(42); + ASIO_CHECK(v.size() == 42); +} + +ASIO_TEST_SUITE +( + "recycling_allocator", + ASIO_TEST_CASE(recycling_allocator_test) +) diff --git a/3rdparty/asio/src/tests/unit/redirect_error.cpp b/3rdparty/asio/src/tests/unit/redirect_error.cpp new file mode 100644 index 00000000000..7a581495566 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/redirect_error.cpp @@ -0,0 +1,121 @@ +// +// redirect_error.cpp +// ~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/redirect_error.hpp" + +#include "asio/bind_executor.hpp" +#include "asio/deferred.hpp" +#include "asio/io_context.hpp" +#include "asio/post.hpp" +#include "asio/system_timer.hpp" +#include "asio/use_future.hpp" +#include "unit_test.hpp" + +struct redirect_error_handler +{ + int* count_; + + explicit redirect_error_handler(int* c) + : count_(c) + { + } + + void operator()() + { + ++(*count_); + } +}; + +void redirect_error_test() +{ + asio::io_context io1; + asio::io_context io2; + asio::system_timer timer1(io1); + asio::error_code ec = asio::error::would_block; + int count = 0; + + timer1.expires_after(asio::chrono::seconds(0)); + timer1.async_wait( + asio::redirect_error( + asio::bind_executor(io2.get_executor(), + redirect_error_handler(&count)), ec)); + + ASIO_CHECK(ec == asio::error::would_block); + ASIO_CHECK(count == 0); + + io1.run(); + + ASIO_CHECK(ec == asio::error::would_block); + ASIO_CHECK(count == 0); + + io2.run(); + + ASIO_CHECK(!ec); + ASIO_CHECK(count == 1); + + ec = asio::error::would_block; + timer1.async_wait( + asio::redirect_error( + asio::bind_executor(io2.get_executor(), + asio::deferred), ec))(redirect_error_handler(&count)); + + ASIO_CHECK(ec == asio::error::would_block); + ASIO_CHECK(count == 1); + + io1.restart(); + io1.run(); + + ASIO_CHECK(ec == asio::error::would_block); + ASIO_CHECK(count == 1); + + io2.restart(); + io2.run(); + + ASIO_CHECK(!ec); + ASIO_CHECK(count == 2); + +#if defined(ASIO_HAS_STD_FUTURE_CLASS) + ec = asio::error::would_block; + std::future<void> f = timer1.async_wait( + asio::redirect_error( + asio::bind_executor(io2.get_executor(), + asio::use_future), ec)); + + ASIO_CHECK(ec == asio::error::would_block); + ASIO_CHECK(f.wait_for(std::chrono::seconds(0)) + == std::future_status::timeout); + + io1.restart(); + io1.run(); + + ASIO_CHECK(ec == asio::error::would_block); + ASIO_CHECK(f.wait_for(std::chrono::seconds(0)) + == std::future_status::timeout); + + io2.restart(); + io2.run(); + + ASIO_CHECK(!ec); + ASIO_CHECK(f.wait_for(std::chrono::seconds(0)) + == std::future_status::ready); +#endif // defined(ASIO_HAS_STD_FUTURE_CLASS) +} + +ASIO_TEST_SUITE +( + "redirect_error", + ASIO_TEST_CASE(redirect_error_test) +) diff --git a/3rdparty/asio/src/tests/unit/registered_buffer.cpp b/3rdparty/asio/src/tests/unit/registered_buffer.cpp new file mode 100644 index 00000000000..09c33415a14 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/registered_buffer.cpp @@ -0,0 +1,111 @@ +// +// registered_buffer.cpp +// ~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/registered_buffer.hpp" + +#include "unit_test.hpp" + +//------------------------------------------------------------------------------ + +// registered_buffer_compile test +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// The following test checks that all the mutable_registered_buffer and +// const_registered_buffer classes compile and link correctly. Runtime +// failures are ignored. + +namespace registered_buffer_compile { + +using namespace asio; + +void test() +{ + try + { + // mutable_registered_buffer constructors. + + mutable_registered_buffer mb1; + mutable_registered_buffer mb2(mb1); + (void)mb2; + + // mutable_registered_buffer functions. + + mutable_buffer b1 = mb1.buffer(); + (void)b1; + + void* ptr1 = mb1.data(); + (void)ptr1; + + std::size_t n1 = mb1.size(); + (void)n1; + + registered_buffer_id id1 = mb1.id(); + (void)id1; + + // mutable_registered_buffer operators. + + mb1 += 128; + mb1 = mb2 + 128; + mb1 = 128 + mb2; + + // const_registered_buffer constructors. + + const_registered_buffer cb1; + const_registered_buffer cb2(cb1); + (void)cb2; + const_registered_buffer cb3(mb1); + (void)cb3; + + // const_registered_buffer functions. + + const_buffer b2 = cb1.buffer(); + (void)b2; + + const void* ptr2 = cb1.data(); + (void)ptr2; + + std::size_t n2 = cb1.size(); + (void)n2; + + registered_buffer_id id2 = cb1.id(); + (void)id2; + + // const_registered_buffer operators. + + cb1 += 128; + cb1 = cb2 + 128; + cb1 = 128 + cb2; + + // buffer function overloads. + + mb1 = buffer(mb2); + mb1 = buffer(mb2, 128); + cb1 = buffer(cb2); + cb1 = buffer(cb2, 128); + } + catch (std::exception&) + { + } +} + +} // namespace buffer_compile + +//------------------------------------------------------------------------------ + +ASIO_TEST_SUITE +( + "registered_buffer", + ASIO_COMPILE_TEST_CASE(registered_buffer_compile::test) +) diff --git a/3rdparty/asio/src/tests/unit/serial_port.cpp b/3rdparty/asio/src/tests/unit/serial_port.cpp index ff6e2dc261a..9bbafd34d9b 100644 --- a/3rdparty/asio/src/tests/unit/serial_port.cpp +++ b/3rdparty/asio/src/tests/unit/serial_port.cpp @@ -2,7 +2,7 @@ // serial_port.cpp // ~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -34,22 +34,18 @@ struct write_some_handler { write_some_handler() {} void operator()(const asio::error_code&, std::size_t) {} -#if defined(ASIO_HAS_MOVE) write_some_handler(write_some_handler&&) {} private: write_some_handler(const write_some_handler&); -#endif // defined(ASIO_HAS_MOVE) }; struct read_some_handler { read_some_handler() {} void operator()(const asio::error_code&, std::size_t) {} -#if defined(ASIO_HAS_MOVE) read_some_handler(read_some_handler&&) {} private: read_some_handler(const read_some_handler&); -#endif // defined(ASIO_HAS_MOVE) }; void test() @@ -60,6 +56,7 @@ void test() try { io_context ioc; + const io_context::executor_type ioc_ex = ioc.get_executor(); char mutable_char_buffer[128] = ""; const char const_char_buffer[128] = ""; serial_port::baud_rate serial_port_option; @@ -71,48 +68,49 @@ void test() serial_port port1(ioc); serial_port port2(ioc, "null"); serial_port::native_handle_type native_port1 = port1.native_handle(); +#if defined(ASIO_MSVC) && (_MSC_VER < 1910) + // Skip this on older MSVC due to mysterious ambiguous overload errors. +#else serial_port port3(ioc, native_port1); +#endif -#if defined(ASIO_HAS_MOVE) - serial_port port4(std::move(port3)); -#endif // defined(ASIO_HAS_MOVE) + serial_port port4(ioc_ex); + serial_port port5(ioc_ex, "null"); + serial_port::native_handle_type native_port2 = port1.native_handle(); + serial_port port6(ioc_ex, native_port2); + + serial_port port7(std::move(port6)); + + basic_serial_port<io_context::executor_type> port8(ioc); + serial_port port9(std::move(port8)); // basic_serial_port operators. -#if defined(ASIO_HAS_MOVE) port1 = serial_port(ioc); port1 = std::move(port2); -#endif // defined(ASIO_HAS_MOVE) + port1 = std::move(port8); // basic_io_object functions. serial_port::executor_type ex = port1.get_executor(); (void)ex; -#if !defined(ASIO_NO_DEPRECATED) - io_context& ioc_ref = port1.get_io_context(); - (void)ioc_ref; - - io_context& ioc_ref2 = port1.get_io_service(); - (void)ioc_ref2; -#endif // !defined(ASIO_NO_DEPRECATED) - // basic_serial_port functions. serial_port::lowest_layer_type& lowest_layer = port1.lowest_layer(); (void)lowest_layer; - const serial_port& port5 = port1; - const serial_port::lowest_layer_type& lowest_layer2 = port5.lowest_layer(); + const serial_port& port10 = port1; + const serial_port::lowest_layer_type& lowest_layer2 = port10.lowest_layer(); (void)lowest_layer2; port1.open("null"); port1.open("null", ec); - serial_port::native_handle_type native_port2 = port1.native_handle(); - port1.assign(native_port2); serial_port::native_handle_type native_port3 = port1.native_handle(); - port1.assign(native_port3, ec); + port1.assign(native_port3); + serial_port::native_handle_type native_port4 = port1.native_handle(); + port1.assign(native_port4, ec); bool is_open = port1.is_open(); (void)is_open; @@ -120,8 +118,8 @@ void test() port1.close(); port1.close(ec); - serial_port::native_handle_type native_port4 = port1.native_handle(); - (void)native_port4; + serial_port::native_handle_type native_port5 = port1.native_handle(); + (void)native_port5; port1.cancel(); port1.cancel(ec); @@ -167,5 +165,5 @@ void test() ASIO_TEST_SUITE ( "serial_port", - ASIO_TEST_CASE(serial_port_compile::test) + ASIO_COMPILE_TEST_CASE(serial_port_compile::test) ) diff --git a/3rdparty/asio/src/tests/unit/serial_port_base.cpp b/3rdparty/asio/src/tests/unit/serial_port_base.cpp index d05e7bbaafe..1c888ef661c 100644 --- a/3rdparty/asio/src/tests/unit/serial_port_base.cpp +++ b/3rdparty/asio/src/tests/unit/serial_port_base.cpp @@ -2,7 +2,7 @@ // serial_port_base.cpp // ~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -95,5 +95,5 @@ void test() ASIO_TEST_SUITE ( "serial_port_base", - ASIO_TEST_CASE(serial_port_base_compile::test) + ASIO_COMPILE_TEST_CASE(serial_port_base_compile::test) ) diff --git a/3rdparty/asio/src/tests/unit/serial_port_service.cpp b/3rdparty/asio/src/tests/unit/serial_port_service.cpp deleted file mode 100644 index c0c596194e7..00000000000 --- a/3rdparty/asio/src/tests/unit/serial_port_service.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// -// serial_port_service.cpp -// ~~~~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.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) -// - -// Disable autolinking for unit tests. -#if !defined(BOOST_ALL_NO_LIB) -#define BOOST_ALL_NO_LIB 1 -#endif // !defined(BOOST_ALL_NO_LIB) - -// Test that header file is self-contained. -#include "asio/serial_port_service.hpp" - -#include "unit_test.hpp" - -ASIO_TEST_SUITE -( - "serial_port_service", - ASIO_TEST_CASE(null_test) -) diff --git a/3rdparty/asio/src/tests/unit/signal_set.cpp b/3rdparty/asio/src/tests/unit/signal_set.cpp index 7118bb96ac0..962be8ba92e 100644 --- a/3rdparty/asio/src/tests/unit/signal_set.cpp +++ b/3rdparty/asio/src/tests/unit/signal_set.cpp @@ -2,7 +2,7 @@ // signal_set.cpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -40,6 +40,7 @@ void test() try { io_context ioc; + const io_context::executor_type ioc_ex = ioc.get_executor(); archetypes::lazy_handler lazy; asio::error_code ec; @@ -50,24 +51,24 @@ void test() signal_set set3(ioc, 1, 2); signal_set set4(ioc, 1, 2, 3); + signal_set set5(ioc_ex); + signal_set set6(ioc_ex, 1); + signal_set set7(ioc_ex, 1, 2); + signal_set set8(ioc_ex, 1, 2, 3); + // basic_io_object functions. signal_set::executor_type ex = set1.get_executor(); (void)ex; -#if !defined(ASIO_NO_DEPRECATED) - io_context& ioc_ref = set1.get_io_context(); - (void)ioc_ref; - - io_context& ioc_ref2 = set1.get_io_service(); - (void)ioc_ref2; -#endif // !defined(ASIO_NO_DEPRECATED) - // basic_signal_set functions. set1.add(1); set1.add(1, ec); + set1.add(1, signal_set::flags::dont_care); + set1.add(1, signal_set::flags::dont_care, ec); + set1.remove(1); set1.remove(1, ec); @@ -93,5 +94,5 @@ void test() ASIO_TEST_SUITE ( "signal_set", - ASIO_TEST_CASE(signal_set_compile::test) + ASIO_COMPILE_TEST_CASE(signal_set_compile::test) ) diff --git a/3rdparty/asio/src/tests/unit/signal_set_base.cpp b/3rdparty/asio/src/tests/unit/signal_set_base.cpp new file mode 100644 index 00000000000..7f27e8ccc2e --- /dev/null +++ b/3rdparty/asio/src/tests/unit/signal_set_base.cpp @@ -0,0 +1,30 @@ +// +// signal_set_base.cpp +// ~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Prevent link dependency on the Boost.System library. +#if !defined(BOOST_SYSTEM_NO_DEPRECATED) +#define BOOST_SYSTEM_NO_DEPRECATED +#endif // !defined(BOOST_SYSTEM_NO_DEPRECATED) + +// Test that header file is self-contained. +#include "asio/signal_set_base.hpp" + +#include "unit_test.hpp" + +ASIO_TEST_SUITE +( + "signal_set_base", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/socket_base.cpp b/3rdparty/asio/src/tests/unit/socket_base.cpp index f7170ace0e9..21f63ab433c 100644 --- a/3rdparty/asio/src/tests/unit/socket_base.cpp +++ b/3rdparty/asio/src/tests/unit/socket_base.cpp @@ -2,7 +2,7 @@ // socket_base.cpp // ~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -155,6 +155,17 @@ void test() linger1.timeout(1); (void)static_cast<int>(linger1.timeout()); + // out_of_band_inline class. + + socket_base::out_of_band_inline out_of_band_inline1(true); + sock.set_option(out_of_band_inline1); + socket_base::out_of_band_inline out_of_band_inline2; + sock.get_option(out_of_band_inline2); + out_of_band_inline1 = true; + (void)static_cast<bool>(out_of_band_inline1); + (void)static_cast<bool>(!out_of_band_inline1); + (void)static_cast<bool>(out_of_band_inline1.value()); + // enable_connection_aborted class. socket_base::enable_connection_aborted enable_connection_aborted1(true); @@ -634,6 +645,6 @@ void test() ASIO_TEST_SUITE ( "socket_base", - ASIO_TEST_CASE(socket_base_compile::test) + ASIO_COMPILE_TEST_CASE(socket_base_compile::test) ASIO_TEST_CASE(socket_base_runtime::test) ) diff --git a/3rdparty/asio/src/tests/unit/ssl/.gitignore b/3rdparty/asio/src/tests/unit/ssl/.gitignore deleted file mode 100644 index 5c2ad3eba55..00000000000 --- a/3rdparty/asio/src/tests/unit/ssl/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*.ilk -*.manifest -*.pdb -*.tds -context -context_base -rfc2818_verification -stream -stream_base diff --git a/3rdparty/asio/src/tests/unit/ssl/context.cpp b/3rdparty/asio/src/tests/unit/ssl/context.cpp index 27d63d5a9bc..621bf11c4a0 100644 --- a/3rdparty/asio/src/tests/unit/ssl/context.cpp +++ b/3rdparty/asio/src/tests/unit/ssl/context.cpp @@ -2,7 +2,7 @@ // context.cpp // ~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/ssl/context_base.cpp b/3rdparty/asio/src/tests/unit/ssl/context_base.cpp index 19ef5740d2f..9ddddad3a8e 100644 --- a/3rdparty/asio/src/tests/unit/ssl/context_base.cpp +++ b/3rdparty/asio/src/tests/unit/ssl/context_base.cpp @@ -2,7 +2,7 @@ // context_base.cpp // ~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/ip/resolver_service.cpp b/3rdparty/asio/src/tests/unit/ssl/error.cpp index 7b0ac2a9ac3..633d7b61e8f 100644 --- a/3rdparty/asio/src/tests/unit/ip/resolver_service.cpp +++ b/3rdparty/asio/src/tests/unit/ssl/error.cpp @@ -1,8 +1,8 @@ // -// resolver_service.cpp -// ~~~~~~~~~~~~~~~~~~~~ +// error.cpp +// ~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -14,12 +14,12 @@ #endif // !defined(BOOST_ALL_NO_LIB) // Test that header file is self-contained. -#include "asio/ip/resolver_service.hpp" +#include "asio/ssl/error.hpp" #include "../unit_test.hpp" ASIO_TEST_SUITE ( - "ip/resolver_service", + "ssl/error", ASIO_TEST_CASE(null_test) ) diff --git a/3rdparty/asio/src/tests/unit/waitable_timer_service.cpp b/3rdparty/asio/src/tests/unit/ssl/host_name_verification.cpp index 3aa530aab75..7126e4b083a 100644 --- a/3rdparty/asio/src/tests/unit/waitable_timer_service.cpp +++ b/3rdparty/asio/src/tests/unit/ssl/host_name_verification.cpp @@ -1,8 +1,8 @@ // -// waitable_timer_service.cpp +// host_name_verification.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -14,12 +14,12 @@ #endif // !defined(BOOST_ALL_NO_LIB) // Test that header file is self-contained. -#include "asio/waitable_timer_service.hpp" +#include "asio/ssl/host_name_verification.hpp" -#include "unit_test.hpp" +#include "../unit_test.hpp" ASIO_TEST_SUITE ( - "waitable_timer_service", + "ssl/host_name_verification", ASIO_TEST_CASE(null_test) ) diff --git a/3rdparty/asio/src/tests/unit/ssl/rfc2818_verification.cpp b/3rdparty/asio/src/tests/unit/ssl/rfc2818_verification.cpp index 15e0b5e35c3..adcfa95ded8 100644 --- a/3rdparty/asio/src/tests/unit/ssl/rfc2818_verification.cpp +++ b/3rdparty/asio/src/tests/unit/ssl/rfc2818_verification.cpp @@ -2,7 +2,7 @@ // rfc2818_verification.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/ssl/stream.cpp b/3rdparty/asio/src/tests/unit/ssl/stream.cpp index 542949eb60c..467115169b9 100644 --- a/3rdparty/asio/src/tests/unit/ssl/stream.cpp +++ b/3rdparty/asio/src/tests/unit/ssl/stream.cpp @@ -2,7 +2,7 @@ // stream.cpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -75,19 +75,19 @@ void test() ip::tcp::socket socket1(ioc, ip::tcp::v4()); ssl::stream<ip::tcp::socket&> stream2(socket1, context); + ssl::stream<ip::tcp::socket> stream3 + = ssl::stream<ip::tcp::socket>(ioc, context); + ssl::stream<ip::tcp::socket> stream4(std::move(stream3)); + + // ssl::stream assignment. + + stream3 = std::move(stream4); + // basic_io_object functions. ssl::stream<ip::tcp::socket>::executor_type ex = stream1.get_executor(); (void)ex; -#if !defined(ASIO_NO_DEPRECATED) - io_context& ioc_ref = stream1.get_io_context(); - (void)ioc_ref; - - io_context& ioc_ref2 = stream1.get_io_service(); - (void)ioc_ref2; -#endif // !defined(ASIO_NO_DEPRECATED) - // ssl::stream functions. SSL* ssl1 = stream1.native_handle(); @@ -97,9 +97,9 @@ void test() = stream1.lowest_layer(); (void)lowest_layer; - const ssl::stream<ip::tcp::socket>& stream3 = stream1; + const ssl::stream<ip::tcp::socket>& stream5 = stream1; const ssl::stream<ip::tcp::socket>::lowest_layer_type& lowest_layer2 - = stream3.lowest_layer(); + = stream5.lowest_layer(); (void)lowest_layer2; stream1.set_verify_mode(ssl::verify_none); @@ -195,5 +195,5 @@ void test() ASIO_TEST_SUITE ( "ssl/stream", - ASIO_TEST_CASE(ssl_stream_compile::test) + ASIO_COMPILE_TEST_CASE(ssl_stream_compile::test) ) diff --git a/3rdparty/asio/src/tests/unit/ssl/stream_base.cpp b/3rdparty/asio/src/tests/unit/ssl/stream_base.cpp index 4dbc9e3b232..7e6a1e62ef0 100644 --- a/3rdparty/asio/src/tests/unit/ssl/stream_base.cpp +++ b/3rdparty/asio/src/tests/unit/ssl/stream_base.cpp @@ -2,7 +2,7 @@ // stream_base.cpp // ~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/static_thread_pool.cpp b/3rdparty/asio/src/tests/unit/static_thread_pool.cpp new file mode 100644 index 00000000000..b9b050bf7ee --- /dev/null +++ b/3rdparty/asio/src/tests/unit/static_thread_pool.cpp @@ -0,0 +1,30 @@ +// +// static_thread_pool.cpp +// ~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Prevent link dependency on the Boost.System library. +#if !defined(BOOST_SYSTEM_NO_DEPRECATED) +#define BOOST_SYSTEM_NO_DEPRECATED +#endif // !defined(BOOST_SYSTEM_NO_DEPRECATED) + +// Test that header file is self-contained. +#include "asio/static_thread_pool.hpp" + +#include "unit_test.hpp" + +ASIO_TEST_SUITE +( + "static_thread_pool", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/steady_timer.cpp b/3rdparty/asio/src/tests/unit/steady_timer.cpp index 18d4a8152fe..fe2c041db4e 100644 --- a/3rdparty/asio/src/tests/unit/steady_timer.cpp +++ b/3rdparty/asio/src/tests/unit/steady_timer.cpp @@ -2,7 +2,7 @@ // steady_timer.cpp // ~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/strand.cpp b/3rdparty/asio/src/tests/unit/strand.cpp index 02a0f7d58fa..90ae2bc22a8 100644 --- a/3rdparty/asio/src/tests/unit/strand.cpp +++ b/3rdparty/asio/src/tests/unit/strand.cpp @@ -2,7 +2,7 @@ // strand.cpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -16,7 +16,9 @@ // Test that header file is self-contained. #include "asio/strand.hpp" +#include <functional> #include <sstream> +#include "asio/executor.hpp" #include "asio/io_context.hpp" #include "asio/dispatch.hpp" #include "asio/post.hpp" @@ -29,24 +31,13 @@ # include "asio/steady_timer.hpp" #endif // defined(ASIO_HAS_BOOST_DATE_TIME) -#if defined(ASIO_HAS_BOOST_BIND) -# include <boost/bind.hpp> -#else // defined(ASIO_HAS_BOOST_BIND) -# include <functional> -#endif // defined(ASIO_HAS_BOOST_BIND) - using namespace asio; - -#if defined(ASIO_HAS_BOOST_BIND) -namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; -#endif #if defined(ASIO_HAS_BOOST_DATE_TIME) typedef deadline_timer timer; namespace chronons = boost::posix_time; -#elif defined(ASIO_HAS_CHRONO) +#else // defined(ASIO_HAS_BOOST_DATE_TIME) typedef steady_timer timer; namespace chronons = asio::chrono; #endif // defined(ASIO_HAS_BOOST_DATE_TIME) @@ -56,7 +47,7 @@ void increment(int* count) ++(*count); } -void increment_without_lock(io_context::strand* s, int* count) +void increment_without_lock(strand<io_context::executor_type>* s, int* count) { ASIO_CHECK(!s->running_in_this_thread()); @@ -69,7 +60,7 @@ void increment_without_lock(io_context::strand* s, int* count) ASIO_CHECK(*count == original_count + 1); } -void increment_with_lock(io_context::strand* s, int* count) +void increment_with_lock(strand<io_context::executor_type>* s, int* count) { ASIO_CHECK(s->running_in_this_thread()); @@ -90,7 +81,28 @@ void sleep_increment(io_context* ioc, int* count) ++(*count); } -void start_sleep_increments(io_context* ioc, io_context::strand* s, int* count) +void increment_by_a(int* count, int a) +{ + (*count) += a; +} + +void increment_by_a_b(int* count, int a, int b) +{ + (*count) += a + b; +} + +void increment_by_a_b_c(int* count, int a, int b, int c) +{ + (*count) += a + b + c; +} + +void increment_by_a_b_c_d(int* count, int a, int b, int c, int d) +{ + (*count) += a + b + c + d; +} + +void start_sleep_increments(io_context* ioc, + strand<io_context::executor_type>* s, int* count) { // Give all threads a chance to start. timer t(*ioc, chronons::seconds(2)); @@ -115,7 +127,7 @@ void io_context_run(io_context* ioc) void strand_test() { io_context ioc; - io_context::strand s(ioc); + strand<io_context::executor_type> s = make_strand(ioc); int count = 0; post(ioc, bindns::bind(increment_without_lock, &s, &count)); @@ -207,7 +219,7 @@ void strand_test() // Check for clean shutdown when handlers posted through an orphaned strand // are abandoned. { - io_context::strand s2(ioc); + strand<io_context::executor_type> s2 = make_strand(ioc.get_executor()); post(s2, bindns::bind(increment, &count)); post(s2, bindns::bind(increment, &count)); post(s2, bindns::bind(increment, &count)); @@ -217,8 +229,230 @@ void strand_test() ASIO_CHECK(count == 0); } +void strand_conversion_test() +{ + io_context ioc; + strand<io_context::executor_type> s1 = make_strand(ioc); + + // Converting constructors. + + strand<executor> s2(s1); + strand<executor> s3 = strand<io_context::executor_type>(s1); + + // Converting assignment. + + s3 = s1; + s3 = strand<io_context::executor_type>(s1); +} + +void strand_query_test() +{ + io_context ioc; + strand<io_context::executor_type> s1 = make_strand(ioc); + + ASIO_CHECK( + &asio::query(s1, asio::execution::context) + == &ioc); + + ASIO_CHECK( + asio::query(s1, asio::execution::blocking) + == asio::execution::blocking.possibly); + + ASIO_CHECK( + asio::query(s1, asio::execution::blocking.possibly) + == asio::execution::blocking.possibly); + + ASIO_CHECK( + asio::query(s1, asio::execution::outstanding_work) + == asio::execution::outstanding_work.untracked); + + ASIO_CHECK( + asio::query(s1, asio::execution::outstanding_work.untracked) + == asio::execution::outstanding_work.untracked); + + ASIO_CHECK( + asio::query(s1, asio::execution::relationship) + == asio::execution::relationship.fork); + + ASIO_CHECK( + asio::query(s1, asio::execution::relationship.fork) + == asio::execution::relationship.fork); + + ASIO_CHECK( + asio::query(s1, asio::execution::mapping) + == asio::execution::mapping.thread); + + ASIO_CHECK( + asio::query(s1, asio::execution::allocator) + == std::allocator<void>()); +} + +void strand_execute_test() +{ + io_context ioc; + strand<io_context::executor_type> s1 = make_strand(ioc); + int count = 0; + + s1.execute(bindns::bind(increment, &count)); + + // No handlers can be called until run() is called. + ASIO_CHECK(!ioc.stopped()); + ASIO_CHECK(count == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + + count = 0; + ioc.restart(); + asio::require(s1, asio::execution::blocking.possibly).execute( + bindns::bind(increment, &count)); + + // No handlers can be called until run() is called. + ASIO_CHECK(!ioc.stopped()); + ASIO_CHECK(count == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + + count = 0; + ioc.restart(); + asio::require(s1, asio::execution::blocking.never).execute( + bindns::bind(increment, &count)); + + // No handlers can be called until run() is called. + ASIO_CHECK(!ioc.stopped()); + ASIO_CHECK(count == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + + count = 0; + ioc.restart(); + ASIO_CHECK(!ioc.stopped()); + + asio::require(s1, + asio::execution::blocking.never, + asio::execution::outstanding_work.tracked + ).execute(bindns::bind(increment, &count)); + + // No handlers can be called until run() is called. + ASIO_CHECK(!ioc.stopped()); + ASIO_CHECK(count == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + + count = 0; + ioc.restart(); + asio::require(s1, + asio::execution::blocking.never, + asio::execution::outstanding_work.untracked + ).execute(bindns::bind(increment, &count)); + + // No handlers can be called until run() is called. + ASIO_CHECK(!ioc.stopped()); + ASIO_CHECK(count == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + + count = 0; + ioc.restart(); + asio::require(s1, + asio::execution::blocking.never, + asio::execution::outstanding_work.untracked, + asio::execution::relationship.fork + ).execute(bindns::bind(increment, &count)); + + // No handlers can be called until run() is called. + ASIO_CHECK(!ioc.stopped()); + ASIO_CHECK(count == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + + count = 0; + ioc.restart(); + asio::require(s1, + asio::execution::blocking.never, + asio::execution::outstanding_work.untracked, + asio::execution::relationship.continuation + ).execute(bindns::bind(increment, &count)); + + // No handlers can be called until run() is called. + ASIO_CHECK(!ioc.stopped()); + ASIO_CHECK(count == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + + count = 0; + ioc.restart(); + asio::prefer( + asio::require(s1, + asio::execution::blocking.never, + asio::execution::outstanding_work.untracked, + asio::execution::relationship.continuation), + asio::execution::allocator(std::allocator<void>()) + ).execute(bindns::bind(increment, &count)); + + // No handlers can be called until run() is called. + ASIO_CHECK(!ioc.stopped()); + ASIO_CHECK(count == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); + + count = 0; + ioc.restart(); + asio::prefer( + asio::require(s1, + asio::execution::blocking.never, + asio::execution::outstanding_work.untracked, + asio::execution::relationship.continuation), + asio::execution::allocator + ).execute(bindns::bind(increment, &count)); + + // No handlers can be called until run() is called. + ASIO_CHECK(!ioc.stopped()); + ASIO_CHECK(count == 0); + + ioc.run(); + + // The run() call will not return until all work has finished. + ASIO_CHECK(ioc.stopped()); + ASIO_CHECK(count == 1); +} + ASIO_TEST_SUITE ( "strand", ASIO_TEST_CASE(strand_test) + ASIO_COMPILE_TEST_CASE(strand_conversion_test) + ASIO_TEST_CASE(strand_query_test) + ASIO_TEST_CASE(strand_execute_test) ) diff --git a/3rdparty/asio/src/tests/unit/stream_file.cpp b/3rdparty/asio/src/tests/unit/stream_file.cpp new file mode 100644 index 00000000000..a4416751cd2 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/stream_file.cpp @@ -0,0 +1,173 @@ +// +// stream_file.cpp +// ~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/stream_file.hpp" + +#include "archetypes/async_result.hpp" +#include "asio/io_context.hpp" +#include "unit_test.hpp" + +// stream_file_compile test +// ~~~~~~~~~~~~~~~~~~~~~~~~ +// The following test checks that all public member functions on the class +// stream_file compile and link correctly. Runtime failures are ignored. + +namespace stream_file_compile { + +struct write_some_handler +{ + write_some_handler() {} + void operator()(const asio::error_code&, std::size_t) {} + write_some_handler(write_some_handler&&) {} +private: + write_some_handler(const write_some_handler&); +}; + +struct read_some_handler +{ + read_some_handler() {} + void operator()(const asio::error_code&, std::size_t) {} + read_some_handler(read_some_handler&&) {} +private: + read_some_handler(const read_some_handler&); +}; + +void test() +{ +#if defined(ASIO_HAS_FILE) + using namespace asio; + + try + { + io_context ioc; + const io_context::executor_type ioc_ex = ioc.get_executor(); + char mutable_char_buffer[128] = ""; + const char const_char_buffer[128] = ""; + archetypes::lazy_handler lazy; + asio::error_code ec; + const std::string path; + + // basic_stream_file constructors. + + stream_file file1(ioc); + stream_file file2(ioc, "", stream_file::read_only); + stream_file file3(ioc, path, stream_file::read_only); + stream_file::native_handle_type native_file1 = file1.native_handle(); + stream_file file4(ioc, native_file1); + + stream_file file5(ioc_ex); + stream_file file6(ioc_ex, "", stream_file::read_only); + stream_file file7(ioc_ex, path, stream_file::read_only); + stream_file::native_handle_type native_file2 = file1.native_handle(); + stream_file file8(ioc_ex, native_file2); + + stream_file file9(std::move(file8)); + + basic_stream_file<io_context::executor_type> file10(ioc); + stream_file file11(std::move(file10)); + + // basic_stream_file operators. + + file1 = stream_file(ioc); + file1 = std::move(file2); + file1 = std::move(file10); + + // basic_io_object functions. + + stream_file::executor_type ex = file1.get_executor(); + (void)ex; + + // basic_stream_file functions. + + file1.open("", stream_file::read_only); + file1.open("", stream_file::read_only, ec); + + file1.open(path, stream_file::read_only); + file1.open(path, stream_file::read_only, ec); + + stream_file::native_handle_type native_file3 = file1.native_handle(); + file1.assign(native_file3); + stream_file::native_handle_type native_file4 = file1.native_handle(); + file1.assign(native_file4, ec); + + bool is_open = file1.is_open(); + (void)is_open; + + file1.close(); + file1.close(ec); + + stream_file::native_handle_type native_file5 = file1.native_handle(); + (void)native_file5; + + stream_file::native_handle_type native_file6 = file1.release(); + (void)native_file6; + stream_file::native_handle_type native_file7 = file1.release(ec); + (void)native_file7; + + file1.cancel(); + file1.cancel(ec); + + asio::uint64_t s1 = file1.size(); + (void)s1; + asio::uint64_t s2 = file1.size(ec); + (void)s2; + + file1.resize(asio::uint64_t(0)); + file1.resize(asio::uint64_t(0), ec); + + file1.sync_all(); + file1.sync_all(ec); + + file1.sync_data(); + file1.sync_data(ec); + + asio::uint64_t s3 = file1.seek(0, stream_file::seek_set); + (void)s3; + asio::uint64_t s4 = file1.seek(0, stream_file::seek_set, ec); + (void)s4; + + file1.write_some(buffer(mutable_char_buffer)); + file1.write_some(buffer(const_char_buffer)); + file1.write_some(buffer(mutable_char_buffer), ec); + file1.write_some(buffer(const_char_buffer), ec); + + file1.async_write_some(buffer(mutable_char_buffer), write_some_handler()); + file1.async_write_some(buffer(const_char_buffer), write_some_handler()); + int i1 = file1.async_write_some(buffer(mutable_char_buffer), lazy); + (void)i1; + int i2 = file1.async_write_some(buffer(const_char_buffer), lazy); + (void)i2; + + file1.read_some(buffer(mutable_char_buffer)); + file1.read_some(buffer(mutable_char_buffer), ec); + + file1.async_read_some(buffer(mutable_char_buffer), read_some_handler()); + int i3 = file1.async_read_some(buffer(mutable_char_buffer), lazy); + (void)i3; + } + catch (std::exception&) + { + } +#endif // defined(ASIO_HAS_FILE) +} + +} // namespace stream_file_compile + +ASIO_TEST_SUITE +( + "stream_file", + ASIO_COMPILE_TEST_CASE(stream_file_compile::test) +) diff --git a/3rdparty/asio/src/tests/unit/streambuf.cpp b/3rdparty/asio/src/tests/unit/streambuf.cpp index 5e10e726d1c..c1c8477a242 100644 --- a/3rdparty/asio/src/tests/unit/streambuf.cpp +++ b/3rdparty/asio/src/tests/unit/streambuf.cpp @@ -2,7 +2,7 @@ // streambuf.cpp // ~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/system_context.cpp b/3rdparty/asio/src/tests/unit/system_context.cpp new file mode 100644 index 00000000000..297ab6bd7c1 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/system_context.cpp @@ -0,0 +1,30 @@ +// +// system_context.cpp +// ~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Prevent link dependency on the Boost.System library. +#if !defined(BOOST_SYSTEM_NO_DEPRECATED) +#define BOOST_SYSTEM_NO_DEPRECATED +#endif // !defined(BOOST_SYSTEM_NO_DEPRECATED) + +// Test that header file is self-contained. +#include "asio/system_context.hpp" + +#include "unit_test.hpp" + +ASIO_TEST_SUITE +( + "system_context", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/system_executor.cpp b/3rdparty/asio/src/tests/unit/system_executor.cpp new file mode 100644 index 00000000000..7b811ccac0c --- /dev/null +++ b/3rdparty/asio/src/tests/unit/system_executor.cpp @@ -0,0 +1,147 @@ +// +// system_executor.cpp +// ~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Prevent link dependency on the Boost.System library. +#if !defined(BOOST_SYSTEM_NO_DEPRECATED) +#define BOOST_SYSTEM_NO_DEPRECATED +#endif // !defined(BOOST_SYSTEM_NO_DEPRECATED) + +// Test that header file is self-contained. +#include "asio/system_executor.hpp" + +#include <functional> +#include "asio/dispatch.hpp" +#include "asio/post.hpp" +#include "unit_test.hpp" + +using namespace asio; + +namespace bindns = std; + +void increment(asio::detail::atomic_count* count) +{ + ++(*count); +} + +void system_executor_query_test() +{ + ASIO_CHECK( + &asio::query(system_executor(), + asio::execution::context) + != static_cast<const system_context*>(0)); + + ASIO_CHECK( + asio::query(system_executor(), + asio::execution::blocking) + == asio::execution::blocking.possibly); + + ASIO_CHECK( + asio::query(system_executor(), + asio::execution::blocking.possibly) + == asio::execution::blocking.possibly); + + ASIO_CHECK( + asio::query(system_executor(), + asio::execution::outstanding_work) + == asio::execution::outstanding_work.untracked); + + ASIO_CHECK( + asio::query(system_executor(), + asio::execution::outstanding_work.untracked) + == asio::execution::outstanding_work.untracked); + + ASIO_CHECK( + asio::query(system_executor(), + asio::execution::relationship) + == asio::execution::relationship.fork); + + ASIO_CHECK( + asio::query(system_executor(), + asio::execution::relationship.fork) + == asio::execution::relationship.fork); + + ASIO_CHECK( + asio::query(system_executor(), + asio::execution::mapping) + == asio::execution::mapping.thread); + + ASIO_CHECK( + asio::query(system_executor(), + asio::execution::allocator) + == std::allocator<void>()); +} + +void system_executor_execute_test() +{ + asio::detail::atomic_count count(0); + + system_executor().execute(bindns::bind(increment, &count)); + + asio::require(system_executor(), + asio::execution::blocking.possibly + ).execute(bindns::bind(increment, &count)); + + asio::require(system_executor(), + asio::execution::blocking.always + ).execute(bindns::bind(increment, &count)); + + asio::require(system_executor(), + asio::execution::blocking.never + ).execute(bindns::bind(increment, &count)); + + asio::require(system_executor(), + asio::execution::blocking.never, + asio::execution::outstanding_work.untracked + ).execute(bindns::bind(increment, &count)); + + asio::require(system_executor(), + asio::execution::blocking.never, + asio::execution::outstanding_work.untracked, + asio::execution::relationship.fork + ).execute(bindns::bind(increment, &count)); + + asio::require(system_executor(), + asio::execution::blocking.never, + asio::execution::outstanding_work.untracked, + asio::execution::relationship.continuation + ).execute(bindns::bind(increment, &count)); + + asio::prefer( + asio::require(system_executor(), + asio::execution::blocking.never, + asio::execution::outstanding_work.untracked, + asio::execution::relationship.continuation), + asio::execution::allocator(std::allocator<void>()) + ).execute(bindns::bind(increment, &count)); + + asio::prefer( + asio::require(system_executor(), + asio::execution::blocking.never, + asio::execution::outstanding_work.untracked, + asio::execution::relationship.continuation), + asio::execution::allocator + ).execute(bindns::bind(increment, &count)); + + asio::query(system_executor(), execution::context).join(); + + ASIO_CHECK(count == 9); +} + +ASIO_TEST_SUITE +( + "system_executor", + ASIO_TEST_CASE(system_executor_query_test) + ASIO_TEST_CASE(system_executor_execute_test) +) diff --git a/3rdparty/asio/src/tests/unit/system_timer.cpp b/3rdparty/asio/src/tests/unit/system_timer.cpp index 3f77a2e74dc..26a5720129f 100644 --- a/3rdparty/asio/src/tests/unit/system_timer.cpp +++ b/3rdparty/asio/src/tests/unit/system_timer.cpp @@ -2,7 +2,7 @@ // system_timer.cpp // ~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -21,25 +21,15 @@ // Test that header file is self-contained. #include "asio/system_timer.hpp" -#include "unit_test.hpp" - -#if defined(ASIO_HAS_STD_CHRONO) - +#include <functional> +#include "asio/bind_cancellation_slot.hpp" +#include "asio/cancellation_signal.hpp" #include "asio/executor_work_guard.hpp" #include "asio/io_context.hpp" #include "asio/thread.hpp" +#include "unit_test.hpp" -#if defined(ASIO_HAS_BOOST_BIND) -# include <boost/bind.hpp> -#else // defined(ASIO_HAS_BOOST_BIND) -# include <functional> -#endif // defined(ASIO_HAS_BOOST_BIND) - -#if defined(ASIO_HAS_BOOST_BIND) -namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; -#endif // defined(ASIO_HAS_BOOST_BIND) void increment(int* count) { @@ -90,12 +80,11 @@ void system_timer_test() { using asio::chrono::seconds; using asio::chrono::microseconds; -#if !defined(ASIO_HAS_BOOST_BIND) - using std::placeholders::_1; - using std::placeholders::_2; -#endif // !defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; + const asio::io_context::executor_type ioc_ex = ioc.get_executor(); int count = 0; asio::system_timer::time_point start = now(); @@ -110,7 +99,7 @@ void system_timer_test() start = now(); - asio::system_timer t2(ioc, seconds(1) + microseconds(500000)); + asio::system_timer t2(ioc_ex, seconds(1) + microseconds(500000)); t2.wait(); // The timer must block until after its expiry time. @@ -236,11 +225,9 @@ struct timer_handler { timer_handler() {} void operator()(const asio::error_code&) {} -#if defined(ASIO_HAS_MOVE) timer_handler(timer_handler&&) {} private: timer_handler(const timer_handler&); -#endif // defined(ASIO_HAS_MOVE) }; void system_timer_cancel_test() @@ -271,21 +258,77 @@ struct custom_allocation_timer_handler custom_allocation_timer_handler(int* count) : count_(count) {} void operator()(const asio::error_code&) {} int* count_; -}; -void* asio_handler_allocate(std::size_t size, - custom_allocation_timer_handler* handler) -{ - ++(*handler->count_); - return ::operator new(size); -} + template <typename T> + struct allocator + { + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T* pointer; + typedef const T* const_pointer; + typedef T& reference; + typedef const T& const_reference; + typedef T value_type; + + template <typename U> + struct rebind + { + typedef allocator<U> other; + }; -void asio_handler_deallocate(void* pointer, std::size_t, - custom_allocation_timer_handler* handler) -{ - --(*handler->count_); - ::operator delete(pointer); -} + explicit allocator(int* count) noexcept + : count_(count) + { + } + + allocator(const allocator& other) noexcept + : count_(other.count_) + { + } + + template <typename U> + allocator(const allocator<U>& other) noexcept + : count_(other.count_) + { + } + + pointer allocate(size_type n, const void* = 0) + { + ++(*count_); + return static_cast<T*>(::operator new(sizeof(T) * n)); + } + + void deallocate(pointer p, size_type) + { + --(*count_); + ::operator delete(p); + } + + size_type max_size() const + { + return ~size_type(0); + } + + void construct(pointer p, const T& v) + { + new (p) T(v); + } + + void destroy(pointer p) + { + p->~T(); + } + + int* count_; + }; + + typedef allocator<int> allocator_type; + + allocator_type get_allocator() const noexcept + { + return allocator_type(count_); + } +}; void system_timer_custom_allocation_test() { @@ -349,7 +392,6 @@ void system_timer_thread_test() ASIO_CHECK(count == 1); } -#if defined(ASIO_HAS_MOVE) asio::system_timer make_timer(asio::io_context& ioc, int* count) { asio::system_timer t(ioc); @@ -357,11 +399,22 @@ asio::system_timer make_timer(asio::io_context& ioc, int* count) t.async_wait(bindns::bind(increment, count)); return t; } -#endif + +typedef asio::basic_waitable_timer< + asio::system_timer::clock_type, + asio::system_timer::traits_type, + asio::io_context::executor_type> io_context_system_timer; + +io_context_system_timer make_convertible_timer(asio::io_context& ioc, int* count) +{ + io_context_system_timer t(ioc); + t.expires_after(asio::chrono::seconds(1)); + t.async_wait(bindns::bind(increment, count)); + return t; +} void system_timer_move_test() { -#if defined(ASIO_HAS_MOVE) asio::io_context io_context1; asio::io_context io_context2; int count = 0; @@ -379,7 +432,60 @@ void system_timer_move_test() io_context1.run(); ASIO_CHECK(count == 2); -#endif // defined(ASIO_HAS_MOVE) + + asio::system_timer t4 = make_convertible_timer(io_context1, &count); + asio::system_timer t5 = make_convertible_timer(io_context2, &count); + asio::system_timer t6 = std::move(t4); + + t2 = std::move(t4); + + io_context2.restart(); + io_context2.run(); + + ASIO_CHECK(count == 3); + + io_context1.restart(); + io_context1.run(); + + ASIO_CHECK(count == 4); +} + +void system_timer_op_cancel_test() +{ + asio::cancellation_signal cancel_signal; + asio::io_context ioc; + int count = 0; + + asio::system_timer timer(ioc, asio::chrono::seconds(10)); + + timer.async_wait(bindns::bind(increment, &count)); + + timer.async_wait( + asio::bind_cancellation_slot( + cancel_signal.slot(), + bindns::bind(increment, &count))); + + timer.async_wait(bindns::bind(increment, &count)); + + ioc.poll(); + + ASIO_CHECK(count == 0); + ASIO_CHECK(!ioc.stopped()); + + cancel_signal.emit(asio::cancellation_type::all); + + ioc.run_one(); + ioc.poll(); + + ASIO_CHECK(count == 1); + ASIO_CHECK(!ioc.stopped()); + + timer.cancel(); + + ioc.run(); + + ASIO_CHECK(count == 3); + ASIO_CHECK(ioc.stopped()); } ASIO_TEST_SUITE @@ -390,11 +496,5 @@ ASIO_TEST_SUITE ASIO_TEST_CASE(system_timer_custom_allocation_test) ASIO_TEST_CASE(system_timer_thread_test) ASIO_TEST_CASE(system_timer_move_test) + ASIO_TEST_CASE(system_timer_op_cancel_test) ) -#else // defined(ASIO_HAS_STD_CHRONO) -ASIO_TEST_SUITE -( - "system_timer", - ASIO_TEST_CASE(null_test) -) -#endif // defined(ASIO_HAS_STD_CHRONO) diff --git a/3rdparty/asio/src/tests/unit/this_coro.cpp b/3rdparty/asio/src/tests/unit/this_coro.cpp new file mode 100644 index 00000000000..d1e0fc677c5 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/this_coro.cpp @@ -0,0 +1,25 @@ +// +// this_coro.cpp +// ~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/this_coro.hpp" + +#include "unit_test.hpp" + +ASIO_TEST_SUITE +( + "this_coro", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/thread.cpp b/3rdparty/asio/src/tests/unit/thread.cpp index 4096c9a7959..b84db72158e 100644 --- a/3rdparty/asio/src/tests/unit/thread.cpp +++ b/3rdparty/asio/src/tests/unit/thread.cpp @@ -2,7 +2,7 @@ // thread.cpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/thread_pool.cpp b/3rdparty/asio/src/tests/unit/thread_pool.cpp new file mode 100644 index 00000000000..f65d7963c26 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/thread_pool.cpp @@ -0,0 +1,283 @@ +// +// thread_pool.cpp +// ~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/thread_pool.hpp" + +#include <functional> +#include "asio/dispatch.hpp" +#include "asio/post.hpp" +#include "unit_test.hpp" + +using namespace asio; +namespace bindns = std; + +void increment(int* count) +{ + ++(*count); +} + +void decrement_to_zero(thread_pool* pool, int* count) +{ + if (*count > 0) + { + --(*count); + + int before_value = *count; + asio::post(*pool, bindns::bind(decrement_to_zero, pool, count)); + + // Handler execution cannot nest, so count value should remain unchanged. + ASIO_CHECK(*count == before_value); + } +} + +void nested_decrement_to_zero(thread_pool* pool, int* count) +{ + if (*count > 0) + { + --(*count); + + asio::dispatch(*pool, + bindns::bind(nested_decrement_to_zero, pool, count)); + + // Handler execution is nested, so count value should now be zero. + ASIO_CHECK(*count == 0); + } +} + +void thread_pool_test() +{ + thread_pool pool(1); + + int count1 = 0; + asio::post(pool, bindns::bind(increment, &count1)); + + int count2 = 10; + asio::post(pool, bindns::bind(decrement_to_zero, &pool, &count2)); + + int count3 = 10; + asio::post(pool, bindns::bind(nested_decrement_to_zero, &pool, &count3)); + + pool.wait(); + + ASIO_CHECK(count1 == 1); + ASIO_CHECK(count2 == 0); + ASIO_CHECK(count3 == 0); +} + +class test_service : public asio::execution_context::service +{ +public: +#if defined(ASIO_NO_TYPEID) + static asio::execution_context::id id; +#endif // defined(ASIO_NO_TYPEID) + + typedef test_service key_type; + + test_service(asio::execution_context& ctx) + : asio::execution_context::service(ctx) + { + } + +private: + virtual void shutdown() {} +}; + +#if defined(ASIO_NO_TYPEID) +asio::execution_context::id test_service::id; +#endif // defined(ASIO_NO_TYPEID) + +void thread_pool_service_test() +{ + asio::thread_pool pool1(1); + asio::thread_pool pool2(1); + asio::thread_pool pool3(1); + + // Implicit service registration. + + asio::use_service<test_service>(pool1); + + ASIO_CHECK(asio::has_service<test_service>(pool1)); + + test_service* svc1 = new test_service(pool1); + try + { + asio::add_service(pool1, svc1); + ASIO_ERROR("add_service did not throw"); + } + catch (asio::service_already_exists&) + { + } + delete svc1; + + // Explicit service registration. + + test_service& svc2 = asio::make_service<test_service>(pool2); + + ASIO_CHECK(asio::has_service<test_service>(pool2)); + ASIO_CHECK(&asio::use_service<test_service>(pool2) == &svc2); + + test_service* svc3 = new test_service(pool2); + try + { + asio::add_service(pool2, svc3); + ASIO_ERROR("add_service did not throw"); + } + catch (asio::service_already_exists&) + { + } + delete svc3; + + // Explicit registration with invalid owner. + + test_service* svc4 = new test_service(pool2); + try + { + asio::add_service(pool3, svc4); + ASIO_ERROR("add_service did not throw"); + } + catch (asio::invalid_service_owner&) + { + } + delete svc4; + + ASIO_CHECK(!asio::has_service<test_service>(pool3)); +} + +void thread_pool_executor_query_test() +{ + thread_pool pool(1); + + ASIO_CHECK( + &asio::query(pool.executor(), + asio::execution::context) + == &pool); + + ASIO_CHECK( + asio::query(pool.executor(), + asio::execution::blocking) + == asio::execution::blocking.possibly); + + ASIO_CHECK( + asio::query(pool.executor(), + asio::execution::blocking.possibly) + == asio::execution::blocking.possibly); + + ASIO_CHECK( + asio::query(pool.executor(), + asio::execution::outstanding_work) + == asio::execution::outstanding_work.untracked); + + ASIO_CHECK( + asio::query(pool.executor(), + asio::execution::outstanding_work.untracked) + == asio::execution::outstanding_work.untracked); + + ASIO_CHECK( + asio::query(pool.executor(), + asio::execution::relationship) + == asio::execution::relationship.fork); + + ASIO_CHECK( + asio::query(pool.executor(), + asio::execution::relationship.fork) + == asio::execution::relationship.fork); + + ASIO_CHECK( + asio::query(pool.executor(), + asio::execution::mapping) + == asio::execution::mapping.thread); + + ASIO_CHECK( + asio::query(pool.executor(), + asio::execution::allocator) + == std::allocator<void>()); + + ASIO_CHECK( + asio::query(pool.executor(), + asio::execution::occupancy) + == 1); +} + +void thread_pool_executor_execute_test() +{ + int count = 0; + thread_pool pool(1); + + pool.executor().execute(bindns::bind(increment, &count)); + + asio::require(pool.executor(), + asio::execution::blocking.possibly + ).execute(bindns::bind(increment, &count)); + + asio::require(pool.executor(), + asio::execution::blocking.always + ).execute(bindns::bind(increment, &count)); + + asio::require(pool.executor(), + asio::execution::blocking.never + ).execute(bindns::bind(increment, &count)); + + asio::require(pool.executor(), + asio::execution::blocking.never, + asio::execution::outstanding_work.tracked + ).execute(bindns::bind(increment, &count)); + + asio::require(pool.executor(), + asio::execution::blocking.never, + asio::execution::outstanding_work.untracked + ).execute(bindns::bind(increment, &count)); + + asio::require(pool.executor(), + asio::execution::blocking.never, + asio::execution::outstanding_work.untracked, + asio::execution::relationship.fork + ).execute(bindns::bind(increment, &count)); + + asio::require(pool.executor(), + asio::execution::blocking.never, + asio::execution::outstanding_work.untracked, + asio::execution::relationship.continuation + ).execute(bindns::bind(increment, &count)); + + asio::prefer( + asio::require(pool.executor(), + asio::execution::blocking.never, + asio::execution::outstanding_work.untracked, + asio::execution::relationship.continuation), + asio::execution::allocator(std::allocator<void>()) + ).execute(bindns::bind(increment, &count)); + + asio::prefer( + asio::require(pool.executor(), + asio::execution::blocking.never, + asio::execution::outstanding_work.untracked, + asio::execution::relationship.continuation), + asio::execution::allocator + ).execute(bindns::bind(increment, &count)); + + pool.wait(); + + ASIO_CHECK(count == 10); +} + +ASIO_TEST_SUITE +( + "thread_pool", + ASIO_TEST_CASE(thread_pool_test) + ASIO_TEST_CASE(thread_pool_service_test) + ASIO_TEST_CASE(thread_pool_executor_query_test) + ASIO_TEST_CASE(thread_pool_executor_execute_test) +) diff --git a/3rdparty/asio/src/tests/unit/time_traits.cpp b/3rdparty/asio/src/tests/unit/time_traits.cpp index 64a35a13a2b..2763d9ecc30 100644 --- a/3rdparty/asio/src/tests/unit/time_traits.cpp +++ b/3rdparty/asio/src/tests/unit/time_traits.cpp @@ -2,7 +2,7 @@ // time_traits.cpp // ~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/ts/buffer.cpp b/3rdparty/asio/src/tests/unit/ts/buffer.cpp new file mode 100644 index 00000000000..8f09c4fecc9 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/ts/buffer.cpp @@ -0,0 +1,30 @@ +// +// buffer.cpp +// ~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Prevent link dependency on the Boost.System library. +#if !defined(BOOST_SYSTEM_NO_DEPRECATED) +#define BOOST_SYSTEM_NO_DEPRECATED +#endif // !defined(BOOST_SYSTEM_NO_DEPRECATED) + +// Test that header file is self-contained. +#include "asio/ts/buffer.hpp" + +#include "../unit_test.hpp" + +ASIO_TEST_SUITE +( + "ts/buffer", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/ts/executor.cpp b/3rdparty/asio/src/tests/unit/ts/executor.cpp new file mode 100644 index 00000000000..9e318d93dbd --- /dev/null +++ b/3rdparty/asio/src/tests/unit/ts/executor.cpp @@ -0,0 +1,30 @@ +// +// executor.cpp +// ~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Prevent link dependency on the Boost.System library. +#if !defined(BOOST_SYSTEM_NO_DEPRECATED) +#define BOOST_SYSTEM_NO_DEPRECATED +#endif // !defined(BOOST_SYSTEM_NO_DEPRECATED) + +// Test that header file is self-contained. +#include "asio/ts/executor.hpp" + +#include "../unit_test.hpp" + +ASIO_TEST_SUITE +( + "ts/executor", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/ts/internet.cpp b/3rdparty/asio/src/tests/unit/ts/internet.cpp new file mode 100644 index 00000000000..1ee8320d9d7 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/ts/internet.cpp @@ -0,0 +1,30 @@ +// +// internet.cpp +// ~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Prevent link dependency on the Boost.System library. +#if !defined(BOOST_SYSTEM_NO_DEPRECATED) +#define BOOST_SYSTEM_NO_DEPRECATED +#endif // !defined(BOOST_SYSTEM_NO_DEPRECATED) + +// Test that header file is self-contained. +#include "asio/ts/internet.hpp" + +#include "../unit_test.hpp" + +ASIO_TEST_SUITE +( + "ts/internet", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/ts/io_context.cpp b/3rdparty/asio/src/tests/unit/ts/io_context.cpp new file mode 100644 index 00000000000..365e2579e8c --- /dev/null +++ b/3rdparty/asio/src/tests/unit/ts/io_context.cpp @@ -0,0 +1,30 @@ +// +// io_context.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Prevent link dependency on the Boost.System library. +#if !defined(BOOST_SYSTEM_NO_DEPRECATED) +#define BOOST_SYSTEM_NO_DEPRECATED +#endif // !defined(BOOST_SYSTEM_NO_DEPRECATED) + +// Test that header file is self-contained. +#include "asio/ts/io_context.hpp" + +#include "../unit_test.hpp" + +ASIO_TEST_SUITE +( + "ts/io_context", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/ts/net.cpp b/3rdparty/asio/src/tests/unit/ts/net.cpp new file mode 100644 index 00000000000..25f65030994 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/ts/net.cpp @@ -0,0 +1,30 @@ +// +// net.cpp +// ~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Prevent link dependency on the Boost.System library. +#if !defined(BOOST_SYSTEM_NO_DEPRECATED) +#define BOOST_SYSTEM_NO_DEPRECATED +#endif // !defined(BOOST_SYSTEM_NO_DEPRECATED) + +// Test that header file is self-contained. +#include "asio/ts/net.hpp" + +#include "../unit_test.hpp" + +ASIO_TEST_SUITE +( + "ts/net", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/ts/netfwd.cpp b/3rdparty/asio/src/tests/unit/ts/netfwd.cpp new file mode 100644 index 00000000000..55af93c87c3 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/ts/netfwd.cpp @@ -0,0 +1,33 @@ +// +// netfwd.cpp +// ~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Prevent link dependency on the Boost.System library. +#if !defined(BOOST_SYSTEM_NO_DEPRECATED) +#define BOOST_SYSTEM_NO_DEPRECATED +#endif // !defined(BOOST_SYSTEM_NO_DEPRECATED) + +// Test that header file is self-contained. +#include "asio/ts/netfwd.hpp" + +// Test that forward declarations don't conflict with full declarations. +#include "asio/ts/net.hpp" + +#include "../unit_test.hpp" + +ASIO_TEST_SUITE +( + "ts/netfwd", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/ts/socket.cpp b/3rdparty/asio/src/tests/unit/ts/socket.cpp new file mode 100644 index 00000000000..4656fa2eb5a --- /dev/null +++ b/3rdparty/asio/src/tests/unit/ts/socket.cpp @@ -0,0 +1,30 @@ +// +// socket.cpp +// ~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Prevent link dependency on the Boost.System library. +#if !defined(BOOST_SYSTEM_NO_DEPRECATED) +#define BOOST_SYSTEM_NO_DEPRECATED +#endif // !defined(BOOST_SYSTEM_NO_DEPRECATED) + +// Test that header file is self-contained. +#include "asio/ts/socket.hpp" + +#include "../unit_test.hpp" + +ASIO_TEST_SUITE +( + "ts/socket", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/ts/timer.cpp b/3rdparty/asio/src/tests/unit/ts/timer.cpp new file mode 100644 index 00000000000..e956bd463d5 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/ts/timer.cpp @@ -0,0 +1,30 @@ +// +// timer.cpp +// ~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Prevent link dependency on the Boost.System library. +#if !defined(BOOST_SYSTEM_NO_DEPRECATED) +#define BOOST_SYSTEM_NO_DEPRECATED +#endif // !defined(BOOST_SYSTEM_NO_DEPRECATED) + +// Test that header file is self-contained. +#include "asio/ts/timer.hpp" + +#include "../unit_test.hpp" + +ASIO_TEST_SUITE +( + "ts/timer", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/unit_test.hpp b/3rdparty/asio/src/tests/unit/unit_test.hpp index b74c3d4ec41..8efae9987e6 100644 --- a/3rdparty/asio/src/tests/unit/unit_test.hpp +++ b/3rdparty/asio/src/tests/unit/unit_test.hpp @@ -2,7 +2,7 @@ // unit_test.hpp // ~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -19,7 +19,7 @@ # include <stdlib.h> // Needed for lrand48. #endif // defined(__sun) -#if defined(__BORLANDC__) +#if defined(__BORLANDC__) && !defined(__clang__) // Prevent use of intrinsic for strcmp. # include <cstring> @@ -28,7 +28,7 @@ // Suppress error about condition always being true. # pragma option -w-ccc -#endif // defined(__BORLANDC__) +#endif // defined(__BORLANDC__) && !defined(__clang__) #if defined(ASIO_MSVC) # pragma warning (disable:4127) @@ -152,6 +152,21 @@ void throw_exception(const T& t) #define ASIO_TEST_CASE(test) \ asio::detail::run_test<&test>(#test); +#define ASIO_TEST_CASE2(test1, test2) \ + asio::detail::run_test<&test1, test2>(#test1 "," #test2); + +#define ASIO_TEST_CASE3(test1, test2, test3) \ + asio::detail::run_test<&test1, test2, test3>( \ + #test1 "," #test2 "," #test3); + +#define ASIO_TEST_CASE4(test1, test2, test3, test4) \ + asio::detail::run_test<&test1, test2, test3, test4>( \ + #test1 "," #test2 "," #test3 "," #test4); + +#define ASIO_TEST_CASE5(test1, test2, test3, test4, test5) \ + asio::detail::run_test<&test1, test2, test3, test4, test5>( \ + #test1 "," #test2 "," #test3 "," #test4 "," #test5); + #define ASIO_COMPILE_TEST_CASE(test) \ asio::detail::compile_test<&test>(#test); diff --git a/3rdparty/asio/src/tests/unit/use_awaitable.cpp b/3rdparty/asio/src/tests/unit/use_awaitable.cpp new file mode 100644 index 00000000000..815f57ebb1c --- /dev/null +++ b/3rdparty/asio/src/tests/unit/use_awaitable.cpp @@ -0,0 +1,25 @@ +// +// use_awaitable.cpp +// ~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header file is self-contained. +#include "asio/use_awaitable.hpp" + +#include "unit_test.hpp" + +ASIO_TEST_SUITE +( + "use_awaitable", + ASIO_TEST_CASE(null_test) +) diff --git a/3rdparty/asio/src/tests/unit/use_future.cpp b/3rdparty/asio/src/tests/unit/use_future.cpp index bc6e3b859b6..ac12f7caa23 100644 --- a/3rdparty/asio/src/tests/unit/use_future.cpp +++ b/3rdparty/asio/src/tests/unit/use_future.cpp @@ -2,7 +2,7 @@ // use_future.cpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -19,10 +19,9 @@ #include <string> #include "unit_test.hpp" -#if defined(ASIO_HAS_STD_FUTURE) +#if defined(ASIO_HAS_STD_FUTURE_CLASS) #include "archetypes/async_ops.hpp" -#include "archetypes/deprecated_async_ops.hpp" void use_future_0_test() { @@ -647,673 +646,6 @@ void use_future_package_3_test() } } -void deprecated_use_future_0_test() -{ -#if !defined(ASIO_NO_DEPRECATED) - using asio::use_future; - using namespace archetypes; - - std::future<void> f; - asio::io_context ctx; - - f = deprecated_async_op_0(ctx, use_future); - ctx.restart(); - ctx.run(); - try - { - f.get(); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ec_0(ctx, true, use_future); - ctx.restart(); - ctx.run(); - try - { - f.get(); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ec_0(ctx, false, use_future); - ctx.restart(); - ctx.run(); - try - { - f.get(); - ASIO_CHECK(false); - } - catch (asio::system_error& e) - { - ASIO_CHECK(e.code() == asio::error::operation_aborted); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = async_op_ex_0(true, use_future); - ctx.restart(); - ctx.run(); - try - { - f.get(); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = async_op_ex_0(false, use_future); - ctx.restart(); - ctx.run(); - try - { - f.get(); - ASIO_CHECK(false); - } - catch (std::exception& e) - { - ASIO_CHECK(e.what() == std::string("blah")); - } - catch (...) - { - ASIO_CHECK(false); - } -#endif // !defined(ASIO_NO_DEPRECATED) -} - -void deprecated_use_future_1_test() -{ -#if !defined(ASIO_NO_DEPRECATED) - using asio::use_future; - using namespace archetypes; - - std::future<int> f; - asio::io_context ctx; - - f = deprecated_async_op_1(ctx, use_future); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(i == 42); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ec_1(ctx, true, use_future); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(i == 42); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ec_1(ctx, false, use_future); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(false); - (void)i; - } - catch (asio::system_error& e) - { - ASIO_CHECK(e.code() == asio::error::operation_aborted); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ex_1(ctx, true, use_future); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(i == 42); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ex_1(ctx, false, use_future); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(false); - (void)i; - } - catch (std::exception& e) - { - ASIO_CHECK(e.what() == std::string("blah")); - } - catch (...) - { - ASIO_CHECK(false); - } -#endif // !defined(ASIO_NO_DEPRECATED) -} - -void deprecated_use_future_2_test() -{ -#if !defined(ASIO_NO_DEPRECATED) - using asio::use_future; - using namespace archetypes; - - std::future<std::tuple<int, double>> f; - asio::io_context ctx; - - f = deprecated_async_op_2(ctx, use_future); - ctx.restart(); - ctx.run(); - try - { - int i; - double d; - std::tie(i, d) = f.get(); - ASIO_CHECK(i == 42); - ASIO_CHECK(d == 2.0); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ec_2(ctx, true, use_future); - ctx.restart(); - ctx.run(); - try - { - int i; - double d; - std::tie(i, d) = f.get(); - ASIO_CHECK(i == 42); - ASIO_CHECK(d == 2.0); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ec_2(ctx, false, use_future); - ctx.restart(); - ctx.run(); - try - { - std::tuple<int, double> t = f.get(); - ASIO_CHECK(false); - (void)t; - } - catch (asio::system_error& e) - { - ASIO_CHECK(e.code() == asio::error::operation_aborted); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ex_2(ctx, true, use_future); - ctx.restart(); - ctx.run(); - try - { - int i; - double d; - std::tie(i, d) = f.get(); - ASIO_CHECK(i == 42); - ASIO_CHECK(d == 2.0); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ex_2(ctx, false, use_future); - ctx.restart(); - ctx.run(); - try - { - std::tuple<int, double> t = f.get(); - ASIO_CHECK(false); - (void)t; - } - catch (std::exception& e) - { - ASIO_CHECK(e.what() == std::string("blah")); - } - catch (...) - { - ASIO_CHECK(false); - } -#endif // !defined(ASIO_NO_DEPRECATED) -} - -void deprecated_use_future_3_test() -{ -#if !defined(ASIO_NO_DEPRECATED) - using asio::use_future; - using namespace archetypes; - - std::future<std::tuple<int, double, char>> f; - asio::io_context ctx; - - f = deprecated_async_op_3(ctx, use_future); - ctx.restart(); - ctx.run(); - try - { - int i; - double d; - char c; - std::tie(i, d, c) = f.get(); - ASIO_CHECK(i == 42); - ASIO_CHECK(d == 2.0); - ASIO_CHECK(c == 'a'); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ec_3(ctx, true, use_future); - ctx.restart(); - ctx.run(); - try - { - int i; - double d; - char c; - std::tie(i, d, c) = f.get(); - ASIO_CHECK(i == 42); - ASIO_CHECK(d == 2.0); - ASIO_CHECK(c == 'a'); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ec_3(ctx, false, use_future); - ctx.restart(); - ctx.run(); - try - { - std::tuple<int, double, char> t = f.get(); - ASIO_CHECK(false); - (void)t; - } - catch (asio::system_error& e) - { - ASIO_CHECK(e.code() == asio::error::operation_aborted); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ex_3(ctx, true, use_future); - ctx.restart(); - ctx.run(); - try - { - int i; - double d; - char c; - std::tie(i, d, c) = f.get(); - ASIO_CHECK(i == 42); - ASIO_CHECK(d == 2.0); - ASIO_CHECK(c == 'a'); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ex_3(ctx, false, use_future); - ctx.restart(); - ctx.run(); - try - { - std::tuple<int, double, char> t = f.get(); - ASIO_CHECK(false); - (void)t; - } - catch (std::exception& e) - { - ASIO_CHECK(e.what() == std::string("blah")); - } - catch (...) - { - ASIO_CHECK(false); - } -#endif // !defined(ASIO_NO_DEPRECATED) -} - -void deprecated_use_future_package_0_test() -{ -#if !defined(ASIO_NO_DEPRECATED) - using asio::use_future; - using namespace archetypes; - - std::future<int> f; - asio::io_context ctx; - - f = deprecated_async_op_0(ctx, use_future(package_0)); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(i == 42); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ec_0(ctx, true, use_future(&package_ec_0)); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(i == 42); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ec_0(ctx, false, use_future(package_ec_0)); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(i == 0); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ex_0(ctx, true, use_future(package_ex_0)); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(i == 42); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ex_0(ctx, false, use_future(package_ex_0)); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(i == 0); - } - catch (...) - { - ASIO_CHECK(false); - } -#endif // !defined(ASIO_NO_DEPRECATED) -} - -void deprecated_use_future_package_1_test() -{ -#if !defined(ASIO_NO_DEPRECATED) - using asio::use_future; - using namespace archetypes; - - std::future<int> f; - asio::io_context ctx; - - f = deprecated_async_op_1(ctx, use_future(package_1)); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(i == 42); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ec_1(ctx, true, use_future(package_ec_1)); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(i == 42); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ec_1(ctx, false, use_future(package_ec_1)); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(i == 0); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ex_1(ctx, true, use_future(package_ex_1)); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(i == 42); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ex_1(ctx, false, use_future(package_ex_1)); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(i == 0); - } - catch (...) - { - ASIO_CHECK(false); - } -#endif // !defined(ASIO_NO_DEPRECATED) -} - -void deprecated_use_future_package_2_test() -{ -#if !defined(ASIO_NO_DEPRECATED) - using asio::use_future; - using namespace archetypes; - - std::future<int> f; - asio::io_context ctx; - - f = deprecated_async_op_2(ctx, use_future(package_2)); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(i == 42); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ec_2(ctx, true, use_future(package_ec_2)); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(i == 42); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ec_2(ctx, false, use_future(package_ec_2)); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(i == 0); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ex_2(ctx, true, use_future(package_ex_2)); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(i == 42); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ex_2(ctx, false, use_future(package_ex_2)); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(i == 0); - } - catch (...) - { - ASIO_CHECK(false); - } -#endif // !defined(ASIO_NO_DEPRECATED) -} - -void deprecated_use_future_package_3_test() -{ -#if !defined(ASIO_NO_DEPRECATED) - using asio::use_future; - using namespace archetypes; - - std::future<int> f; - asio::io_context ctx; - - f = deprecated_async_op_3(ctx, use_future(package_3)); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(i == 42); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ec_3(ctx, true, use_future(package_ec_3)); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(i == 42); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ec_3(ctx, false, use_future(package_ec_3)); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(i == 0); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ex_3(ctx, true, use_future(package_ex_3)); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(i == 42); - } - catch (...) - { - ASIO_CHECK(false); - } - - f = deprecated_async_op_ex_3(ctx, false, use_future(package_ex_3)); - ctx.restart(); - ctx.run(); - try - { - int i = f.get(); - ASIO_CHECK(i == 0); - } - catch (...) - { - ASIO_CHECK(false); - } -#endif // !defined(ASIO_NO_DEPRECATED) -} - ASIO_TEST_SUITE ( "use_future", @@ -1325,17 +657,9 @@ ASIO_TEST_SUITE ASIO_TEST_CASE(use_future_package_1_test) ASIO_TEST_CASE(use_future_package_2_test) ASIO_TEST_CASE(use_future_package_3_test) - ASIO_TEST_CASE(deprecated_use_future_0_test) - ASIO_TEST_CASE(deprecated_use_future_1_test) - ASIO_TEST_CASE(deprecated_use_future_2_test) - ASIO_TEST_CASE(deprecated_use_future_3_test) - ASIO_TEST_CASE(deprecated_use_future_package_0_test) - ASIO_TEST_CASE(deprecated_use_future_package_1_test) - ASIO_TEST_CASE(deprecated_use_future_package_2_test) - ASIO_TEST_CASE(deprecated_use_future_package_3_test) ) -#else // defined(ASIO_HAS_STD_FUTURE) +#else // defined(ASIO_HAS_STD_FUTURE_CLASS) ASIO_TEST_SUITE ( @@ -1343,4 +667,4 @@ ASIO_TEST_SUITE ASIO_TEST_CASE(null_test) ) -#endif // defined(ASIO_HAS_STD_FUTURE) +#endif // defined(ASIO_HAS_STD_FUTURE_CLASS) diff --git a/3rdparty/asio/src/tests/unit/uses_executor.cpp b/3rdparty/asio/src/tests/unit/uses_executor.cpp index cb1e2918b13..f3d52c1d8fc 100644 --- a/3rdparty/asio/src/tests/unit/uses_executor.cpp +++ b/3rdparty/asio/src/tests/unit/uses_executor.cpp @@ -2,7 +2,7 @@ // uses_executor.cpp // ~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/wait_traits.cpp b/3rdparty/asio/src/tests/unit/wait_traits.cpp index eed0161273c..4bdb498d7bf 100644 --- a/3rdparty/asio/src/tests/unit/wait_traits.cpp +++ b/3rdparty/asio/src/tests/unit/wait_traits.cpp @@ -2,7 +2,7 @@ // wait_traits.cpp // ~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/windows/.gitignore b/3rdparty/asio/src/tests/unit/windows/.gitignore deleted file mode 100644 index d225c81cd76..00000000000 --- a/3rdparty/asio/src/tests/unit/windows/.gitignore +++ /dev/null @@ -1,21 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*.ilk -*.manifest -*.pdb -*.tds -basic_handle -basic_object_handle -basic_random_access_handle -basic_stream_handle -object_handle -object_handle_service -overlapped_handle -overlapped_ptr -random_access_handle -random_access_handle_service -stream_handle -stream_handle_service diff --git a/3rdparty/asio/src/tests/unit/windows/basic_object_handle.cpp b/3rdparty/asio/src/tests/unit/windows/basic_object_handle.cpp index 4c27e14e488..d4d6def159a 100644 --- a/3rdparty/asio/src/tests/unit/windows/basic_object_handle.cpp +++ b/3rdparty/asio/src/tests/unit/windows/basic_object_handle.cpp @@ -2,7 +2,7 @@ // basic_object_handle.cpp // ~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -16,11 +16,10 @@ // Test that header file is self-contained. #include "asio/windows/basic_object_handle.hpp" -#include "asio.hpp" #include "../unit_test.hpp" ASIO_TEST_SUITE ( - "windows/basic_object_handle", + "basic_object_handle", ASIO_TEST_CASE(null_test) ) diff --git a/3rdparty/asio/src/tests/unit/socket_acceptor_service.cpp b/3rdparty/asio/src/tests/unit/windows/basic_overlapped_handle.cpp index 772218631a6..62b5419c69f 100644 --- a/3rdparty/asio/src/tests/unit/socket_acceptor_service.cpp +++ b/3rdparty/asio/src/tests/unit/windows/basic_overlapped_handle.cpp @@ -1,8 +1,8 @@ // -// socket_acceptor_service.cpp +// basic_overlapped_handle.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -14,12 +14,12 @@ #endif // !defined(BOOST_ALL_NO_LIB) // Test that header file is self-contained. -#include "asio/socket_acceptor_service.hpp" +#include "asio/windows/basic_overlapped_handle.hpp" -#include "unit_test.hpp" +#include "../unit_test.hpp" ASIO_TEST_SUITE ( - "socket_acceptor_service", + "basic_overlapped_handle", ASIO_TEST_CASE(null_test) ) diff --git a/3rdparty/asio/src/tests/unit/windows/basic_random_access_handle.cpp b/3rdparty/asio/src/tests/unit/windows/basic_random_access_handle.cpp index 720cf76b749..4a2605ea335 100644 --- a/3rdparty/asio/src/tests/unit/windows/basic_random_access_handle.cpp +++ b/3rdparty/asio/src/tests/unit/windows/basic_random_access_handle.cpp @@ -2,7 +2,7 @@ // basic_random_access_handle.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -16,11 +16,10 @@ // Test that header file is self-contained. #include "asio/windows/basic_random_access_handle.hpp" -#include "asio.hpp" #include "../unit_test.hpp" ASIO_TEST_SUITE ( - "windows/basic_random_access_handle", + "basic_random_access_handle", ASIO_TEST_CASE(null_test) ) diff --git a/3rdparty/asio/src/tests/unit/windows/basic_stream_handle.cpp b/3rdparty/asio/src/tests/unit/windows/basic_stream_handle.cpp index 2151dafb709..9cdf0bd5c20 100644 --- a/3rdparty/asio/src/tests/unit/windows/basic_stream_handle.cpp +++ b/3rdparty/asio/src/tests/unit/windows/basic_stream_handle.cpp @@ -2,7 +2,7 @@ // basic_stream_handle.cpp // ~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -16,11 +16,10 @@ // Test that header file is self-contained. #include "asio/windows/basic_stream_handle.hpp" -#include "asio.hpp" #include "../unit_test.hpp" ASIO_TEST_SUITE ( - "windows/basic_stream_handle", + "basic_stream_handle", ASIO_TEST_CASE(null_test) ) diff --git a/3rdparty/asio/src/tests/unit/windows/object_handle.cpp b/3rdparty/asio/src/tests/unit/windows/object_handle.cpp index 32a836ef208..0784ba9fdb7 100644 --- a/3rdparty/asio/src/tests/unit/windows/object_handle.cpp +++ b/3rdparty/asio/src/tests/unit/windows/object_handle.cpp @@ -2,7 +2,7 @@ // object_handle.cpp // ~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -43,6 +43,7 @@ void test() try { io_context ioc; + const io_context::executor_type ioc_ex = ioc.get_executor(); archetypes::lazy_handler lazy; asio::error_code ec; @@ -50,27 +51,30 @@ void test() win::object_handle handle1(ioc); HANDLE native_handle1 = INVALID_HANDLE_VALUE; +#if defined(ASIO_MSVC) && (_MSC_VER < 1910) + // Skip this on older MSVC due to mysterious ambiguous overload errors. +#else win::object_handle handle2(ioc, native_handle1); +#endif -#if defined(ASIO_HAS_MOVE) - win::object_handle handle3(std::move(handle2)); -#endif // defined(ASIO_HAS_MOVE) + win::object_handle handle3(ioc_ex); + HANDLE native_handle2 = INVALID_HANDLE_VALUE; + win::object_handle handle4(ioc_ex, native_handle2); + + win::object_handle handle5(std::move(handle4)); + + win::basic_object_handle<io_context::executor_type> handle6(ioc); + win::object_handle handle7(std::move(handle6)); // basic_object_handle operators. -#if defined(ASIO_HAS_MOVE) handle1 = win::object_handle(ioc); - handle1 = std::move(handle2); -#endif // defined(ASIO_HAS_MOVE) + handle1 = std::move(handle3); + handle1 = std::move(handle6); // basic_io_object functions. -#if !defined(ASIO_NO_DEPRECATED) - io_context& ioc_ref = handle1.get_io_context(); - (void)ioc_ref; -#endif !defined(ASIO_NO_DEPRECATED) - - io_context::executor_type ex = handle1.get_executor(); + win::object_handle::executor_type ex = handle1.get_executor(); (void)ex; // basic_handle functions. @@ -79,13 +83,13 @@ void test() = handle1.lowest_layer(); (void)lowest_layer; - const win::object_handle& handle4 = handle1; - const win::object_handle::lowest_layer_type& lowest_layer2 - = handle4.lowest_layer(); - (void)lowest_layer2; + const win::object_handle& handle8 = handle1; + const win::object_handle::lowest_layer_type& lowest_layer3 + = handle8.lowest_layer(); + (void)lowest_layer3; - HANDLE native_handle2 = INVALID_HANDLE_VALUE; - handle1.assign(native_handle2); + HANDLE native_handle4 = INVALID_HANDLE_VALUE; + handle1.assign(native_handle4); bool is_open = handle1.is_open(); (void)is_open; @@ -122,5 +126,5 @@ void test() ASIO_TEST_SUITE ( "windows/object_handle", - ASIO_TEST_CASE(windows_object_handle_compile::test) + ASIO_COMPILE_TEST_CASE(windows_object_handle_compile::test) ) diff --git a/3rdparty/asio/src/tests/unit/windows/overlapped_handle.cpp b/3rdparty/asio/src/tests/unit/windows/overlapped_handle.cpp index fbc8fb4e88b..5cdd3da2db1 100644 --- a/3rdparty/asio/src/tests/unit/windows/overlapped_handle.cpp +++ b/3rdparty/asio/src/tests/unit/windows/overlapped_handle.cpp @@ -2,7 +2,7 @@ // overlapped_handle.cpp // ~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) diff --git a/3rdparty/asio/src/tests/unit/windows/overlapped_ptr.cpp b/3rdparty/asio/src/tests/unit/windows/overlapped_ptr.cpp index 261ece6f531..fda1b2cbd98 100644 --- a/3rdparty/asio/src/tests/unit/windows/overlapped_ptr.cpp +++ b/3rdparty/asio/src/tests/unit/windows/overlapped_ptr.cpp @@ -2,7 +2,7 @@ // overlapped_ptr.cpp // ~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -16,6 +16,8 @@ // Test that header file is self-contained. #include "asio/windows/overlapped_ptr.hpp" +#include "asio/any_io_executor.hpp" +#include "asio/executor.hpp" #include "asio/io_context.hpp" #include "../unit_test.hpp" @@ -49,6 +51,10 @@ void test() try { io_context ioc; + asio::any_io_executor ex1(ioc.get_executor()); +#if !defined(ASIO_NO_TS_EXECUTORS) + asio::executor ex2(ioc.get_executor()); +#endif // !defined(ASIO_NO_TS_EXECUTORS) // basic_overlapped_ptr constructors. @@ -57,6 +63,15 @@ void test() win::overlapped_ptr ptr2(ioc, &overlapped_handler_1); win::overlapped_ptr ptr3(ioc, overlapped_handler_2()); + win::overlapped_ptr ptr4(ioc.get_executor(), &overlapped_handler_1); + win::overlapped_ptr ptr5(ioc.get_executor(), overlapped_handler_2()); + win::overlapped_ptr ptr6(ex1, &overlapped_handler_1); + win::overlapped_ptr ptr7(ex1, overlapped_handler_2()); +#if !defined(ASIO_NO_TS_EXECUTORS) + win::overlapped_ptr ptr8(ex2, &overlapped_handler_1); + win::overlapped_ptr ptr9(ex2, overlapped_handler_2()); +#endif // !defined(ASIO_NO_TS_EXECUTORS) + // overlapped_ptr functions. ptr1.reset(); @@ -64,11 +79,20 @@ void test() ptr2.reset(ioc, &overlapped_handler_1); ptr3.reset(ioc, overlapped_handler_2()); + ptr2.reset(ioc.get_executor(), &overlapped_handler_1); + ptr3.reset(ioc.get_executor(), overlapped_handler_2()); + ptr2.reset(ex1, &overlapped_handler_1); + ptr3.reset(ex1, overlapped_handler_2()); +#if !defined(ASIO_NO_TS_EXECUTORS) + ptr3.reset(ex2, &overlapped_handler_1); + ptr3.reset(ex2, overlapped_handler_2()); +#endif // !defined(ASIO_NO_TS_EXECUTORS) + OVERLAPPED* ov1 = ptr1.get(); (void)ov1; - const win::overlapped_ptr& ptr4(ptr1); - const OVERLAPPED* ov2 = ptr4.get(); + const win::overlapped_ptr& ptr10(ptr1); + const OVERLAPPED* ov2 = ptr10.get(); (void)ov2; OVERLAPPED* ov3 = ptr1.release(); @@ -91,5 +115,5 @@ void test() ASIO_TEST_SUITE ( "windows/overlapped_ptr", - ASIO_TEST_CASE(windows_overlapped_ptr_compile::test) + ASIO_COMPILE_TEST_CASE(windows_overlapped_ptr_compile::test) ) diff --git a/3rdparty/asio/src/tests/unit/windows/random_access_handle.cpp b/3rdparty/asio/src/tests/unit/windows/random_access_handle.cpp index fbd88209972..613732c5128 100644 --- a/3rdparty/asio/src/tests/unit/windows/random_access_handle.cpp +++ b/3rdparty/asio/src/tests/unit/windows/random_access_handle.cpp @@ -2,7 +2,7 @@ // random_access_handle.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -47,6 +47,7 @@ void test() try { io_context ioc; + const io_context::executor_type ioc_ex = ioc.get_executor(); char mutable_char_buffer[128] = ""; const char const_char_buffer[128] = ""; asio::uint64_t offset = 0; @@ -57,42 +58,45 @@ void test() win::random_access_handle handle1(ioc); HANDLE native_handle1 = INVALID_HANDLE_VALUE; +#if defined(ASIO_MSVC) && (_MSC_VER < 1910) + // Skip this on older MSVC due to mysterious ambiguous overload errors. +#else win::random_access_handle handle2(ioc, native_handle1); +#endif -#if defined(ASIO_HAS_MOVE) - win::random_access_handle handle3(std::move(handle2)); -#endif // defined(ASIO_HAS_MOVE) + win::random_access_handle handle3(ioc_ex); + HANDLE native_handle2 = INVALID_HANDLE_VALUE; + win::random_access_handle handle4(ioc_ex, native_handle2); + + win::random_access_handle handle5(std::move(handle4)); + + win::basic_random_access_handle<io_context::executor_type> handle6(ioc); + win::random_access_handle handle7(std::move(handle6)); // basic_random_access_handle operators. -#if defined(ASIO_HAS_MOVE) handle1 = win::random_access_handle(ioc); - handle1 = std::move(handle2); -#endif // defined(ASIO_HAS_MOVE) + handle1 = std::move(handle4); + handle1 = std::move(handle6); // basic_io_object functions. -#if !defined(ASIO_NO_DEPRECATED) - io_context& ioc_ref = handle1.get_io_context(); - (void)ioc_ref; -#endif !defined(ASIO_NO_DEPRECATED) - - io_context::executor_type ex = handle1.get_executor(); + windows::random_access_handle::executor_type ex = handle1.get_executor(); (void)ex; - // basic_handle functions. + // basic_overlapped_handle functions. win::random_access_handle::lowest_layer_type& lowest_layer = handle1.lowest_layer(); (void)lowest_layer; - const win::random_access_handle& handle4 = handle1; + const win::random_access_handle& handle8 = handle1; const win::random_access_handle::lowest_layer_type& lowest_layer2 - = handle4.lowest_layer(); + = handle8.lowest_layer(); (void)lowest_layer2; - HANDLE native_handle2 = INVALID_HANDLE_VALUE; - handle1.assign(native_handle2); + HANDLE native_handle3 = INVALID_HANDLE_VALUE; + handle1.assign(native_handle3); bool is_open = handle1.is_open(); (void)is_open; @@ -100,9 +104,16 @@ void test() handle1.close(); handle1.close(ec); - win::random_access_handle::native_handle_type native_handle3 + win::random_access_handle::native_handle_type native_handle4 + = handle1.release(); + (void)native_handle4; + win::random_access_handle::native_handle_type native_handle5 + = handle1.release(ec); + (void)native_handle5; + + win::random_access_handle::native_handle_type native_handle6 = handle1.native_handle(); - (void)native_handle3; + (void)native_handle6; handle1.cancel(); handle1.cancel(ec); @@ -147,5 +158,5 @@ void test() ASIO_TEST_SUITE ( "windows/random_access_handle", - ASIO_TEST_CASE(windows_random_access_handle_compile::test) + ASIO_COMPILE_TEST_CASE(windows_random_access_handle_compile::test) ) diff --git a/3rdparty/asio/src/tests/unit/windows/random_access_handle_service.cpp b/3rdparty/asio/src/tests/unit/windows/random_access_handle_service.cpp deleted file mode 100644 index 0895864d5b8..00000000000 --- a/3rdparty/asio/src/tests/unit/windows/random_access_handle_service.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// -// random_access_handle_service.cpp -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 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) -// - -// Disable autolinking for unit tests. -#if !defined(BOOST_ALL_NO_LIB) -#define BOOST_ALL_NO_LIB 1 -#endif // !defined(BOOST_ALL_NO_LIB) - -// Test that header file is self-contained. -#include "asio/windows/random_access_handle_service.hpp" - -#include "asio.hpp" -#include "../unit_test.hpp" - -ASIO_TEST_SUITE -( - "windows/random_access_handle_service", - ASIO_TEST_CASE(null_test) -) diff --git a/3rdparty/asio/src/tests/unit/windows/stream_handle.cpp b/3rdparty/asio/src/tests/unit/windows/stream_handle.cpp index 499ed354b04..1668dcea69a 100644 --- a/3rdparty/asio/src/tests/unit/windows/stream_handle.cpp +++ b/3rdparty/asio/src/tests/unit/windows/stream_handle.cpp @@ -2,7 +2,7 @@ // stream_handle.cpp // ~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -47,6 +47,7 @@ void test() try { io_context ioc; + const io_context::executor_type ioc_ex = ioc.get_executor(); char mutable_char_buffer[128] = ""; const char const_char_buffer[128] = ""; archetypes::lazy_handler lazy; @@ -56,42 +57,45 @@ void test() win::stream_handle handle1(ioc); HANDLE native_handle1 = INVALID_HANDLE_VALUE; +#if defined(ASIO_MSVC) && (_MSC_VER < 1910) + // Skip this on older MSVC due to mysterious ambiguous overload errors. +#else win::stream_handle handle2(ioc, native_handle1); +#endif -#if defined(ASIO_HAS_MOVE) - win::stream_handle handle3(std::move(handle2)); -#endif // defined(ASIO_HAS_MOVE) + win::stream_handle handle3(ioc_ex); + HANDLE native_handle2 = INVALID_HANDLE_VALUE; + win::stream_handle handle4(ioc_ex, native_handle2); + + win::stream_handle handle5(std::move(handle4)); + + win::basic_stream_handle<io_context::executor_type> handle6(ioc); + win::stream_handle handle7(std::move(handle6)); // basic_stream_handle operators. -#if defined(ASIO_HAS_MOVE) handle1 = win::stream_handle(ioc); - handle1 = std::move(handle2); -#endif // defined(ASIO_HAS_MOVE) + handle1 = std::move(handle4); + handle1 = std::move(handle6); // basic_io_object functions. -#if !defined(ASIO_NO_DEPRECATED) - io_context& ioc_ref = handle1.get_io_context(); - (void)ioc_ref; -#endif !defined(ASIO_NO_DEPRECATED) - - io_context::executor_type ex = handle1.get_executor(); + windows::stream_handle::executor_type ex = handle1.get_executor(); (void)ex; - // basic_handle functions. + // basic_overlapped_handle functions. win::stream_handle::lowest_layer_type& lowest_layer = handle1.lowest_layer(); (void)lowest_layer; - const win::stream_handle& handle4 = handle1; + const win::stream_handle& handle8 = handle1; const win::stream_handle::lowest_layer_type& lowest_layer2 - = handle4.lowest_layer(); + = handle8.lowest_layer(); (void)lowest_layer2; - HANDLE native_handle2 = INVALID_HANDLE_VALUE; - handle1.assign(native_handle2); + HANDLE native_handle3 = INVALID_HANDLE_VALUE; + handle1.assign(native_handle3); bool is_open = handle1.is_open(); (void)is_open; @@ -99,9 +103,16 @@ void test() handle1.close(); handle1.close(ec); - win::stream_handle::native_handle_type native_handle3 + win::stream_handle::native_handle_type native_handle4 + = handle1.release(); + (void)native_handle4; + win::stream_handle::native_handle_type native_handle5 + = handle1.release(ec); + (void)native_handle5; + + win::stream_handle::native_handle_type native_handle6 = handle1.native_handle(); - (void)native_handle3; + (void)native_handle6; handle1.cancel(); handle1.cancel(ec); @@ -140,5 +151,5 @@ void test() ASIO_TEST_SUITE ( "windows/stream_handle", - ASIO_TEST_CASE(windows_stream_handle_compile::test) + ASIO_COMPILE_TEST_CASE(windows_stream_handle_compile::test) ) diff --git a/3rdparty/asio/src/tests/unit/windows/stream_handle_service.cpp b/3rdparty/asio/src/tests/unit/windows/stream_handle_service.cpp deleted file mode 100644 index 4281ee06b4f..00000000000 --- a/3rdparty/asio/src/tests/unit/windows/stream_handle_service.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// -// stream_handle_service.cpp -// ~~~~~~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 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) -// - -// Disable autolinking for unit tests. -#if !defined(BOOST_ALL_NO_LIB) -#define BOOST_ALL_NO_LIB 1 -#endif // !defined(BOOST_ALL_NO_LIB) - -// Test that header file is self-contained. -#include "asio/windows/stream_handle_service.hpp" - -#include "asio.hpp" -#include "../unit_test.hpp" - -ASIO_TEST_SUITE -( - "windows/stream_handle_service", - ASIO_TEST_CASE(null_test) -) diff --git a/3rdparty/asio/src/tests/unit/writable_pipe.cpp b/3rdparty/asio/src/tests/unit/writable_pipe.cpp new file mode 100644 index 00000000000..0cea7547aa2 --- /dev/null +++ b/3rdparty/asio/src/tests/unit/writable_pipe.cpp @@ -0,0 +1,136 @@ +// +// writable_pipe.cpp +// ~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 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) +// + +// Disable autolinking for unit tests. +#if !defined(BOOST_ALL_NO_LIB) +#define BOOST_ALL_NO_LIB 1 +#endif // !defined(BOOST_ALL_NO_LIB) + +// Test that header pipe is self-contained. +#include "asio/writable_pipe.hpp" + +#include "archetypes/async_result.hpp" +#include "asio/io_context.hpp" +#include "unit_test.hpp" + +// writable_pipe_compile test +// ~~~~~~~~~~~~~~~~~~~~~~~~~~ +// The following test checks that all public member functions on the class +// writable_pipe compile and link correctly. Runtime failures are ignored. + +namespace writable_pipe_compile { + +struct write_some_handler +{ + write_some_handler() {} + void operator()(const asio::error_code&, std::size_t) {} + write_some_handler(write_some_handler&&) {} +private: + write_some_handler(const write_some_handler&); +}; + +struct read_some_handler +{ + read_some_handler() {} + void operator()(const asio::error_code&, std::size_t) {} + read_some_handler(read_some_handler&&) {} +private: + read_some_handler(const read_some_handler&); +}; + +void test() +{ +#if defined(ASIO_HAS_PIPE) + using namespace asio; + + try + { + io_context ioc; + const io_context::executor_type ioc_ex = ioc.get_executor(); + char mutable_char_buffer[128] = ""; + const char const_char_buffer[128] = ""; + archetypes::lazy_handler lazy; + asio::error_code ec; + + // basic_writable_pipe constructors. + + writable_pipe pipe1(ioc); + writable_pipe::native_handle_type native_pipe1 = pipe1.native_handle(); + writable_pipe pipe2(ioc, native_pipe1); + + writable_pipe pipe3(ioc_ex); + writable_pipe::native_handle_type native_pipe2 = pipe1.native_handle(); + writable_pipe pipe4(ioc_ex, native_pipe2); + + writable_pipe pipe5(std::move(pipe4)); + + basic_writable_pipe<io_context::executor_type> pipe6(ioc); + writable_pipe pipe7(std::move(pipe6)); + + // basic_writable_pipe operators. + + pipe1 = writable_pipe(ioc); + pipe1 = std::move(pipe2); + pipe1 = std::move(pipe6); + + // basic_io_object functions. + + writable_pipe::executor_type ex = pipe1.get_executor(); + (void)ex; + + // basic_writable_pipe functions. + + writable_pipe::native_handle_type native_pipe3 = pipe1.native_handle(); + pipe1.assign(native_pipe3); + writable_pipe::native_handle_type native_pipe4 = pipe1.native_handle(); + pipe1.assign(native_pipe4, ec); + + bool is_open = pipe1.is_open(); + (void)is_open; + + pipe1.close(); + pipe1.close(ec); + + writable_pipe::native_handle_type native_pipe5 = pipe1.release(); + (void)native_pipe5; + writable_pipe::native_handle_type native_pipe6 = pipe1.release(ec); + (void)native_pipe6; + + writable_pipe::native_handle_type native_pipe7 = pipe1.native_handle(); + (void)native_pipe7; + + pipe1.cancel(); + pipe1.cancel(ec); + + pipe1.write_some(buffer(mutable_char_buffer)); + pipe1.write_some(buffer(const_char_buffer)); + pipe1.write_some(buffer(mutable_char_buffer), ec); + pipe1.write_some(buffer(const_char_buffer), ec); + + pipe1.async_write_some(buffer(mutable_char_buffer), write_some_handler()); + pipe1.async_write_some(buffer(const_char_buffer), write_some_handler()); + int i1 = pipe1.async_write_some(buffer(mutable_char_buffer), lazy); + (void)i1; + int i2 = pipe1.async_write_some(buffer(const_char_buffer), lazy); + (void)i2; + } + catch (std::exception&) + { + } +#endif // defined(ASIO_HAS_PIPE) +} + +} // namespace writable_pipe_compile + +ASIO_TEST_SUITE +( + "writable_pipe", + ASIO_COMPILE_TEST_CASE(writable_pipe_compile::test) +) diff --git a/3rdparty/asio/src/tests/unit/write.cpp b/3rdparty/asio/src/tests/unit/write.cpp index a60ee11ae45..470972217c1 100644 --- a/3rdparty/asio/src/tests/unit/write.cpp +++ b/3rdparty/asio/src/tests/unit/write.cpp @@ -2,7 +2,7 @@ // write.cpp // ~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -16,7 +16,9 @@ // Test that header file is self-contained. #include "asio/write.hpp" +#include <array> #include <cstring> +#include <functional> #include <vector> #include "archetypes/async_result.hpp" #include "asio/io_context.hpp" @@ -24,20 +26,10 @@ #include "asio/streambuf.hpp" #include "unit_test.hpp" -#if defined(ASIO_HAS_BOOST_BIND) -# include <boost/bind.hpp> -#else // defined(ASIO_HAS_BOOST_BIND) -# include <functional> -#endif // defined(ASIO_HAS_BOOST_BIND) - #if defined(ASIO_HAS_BOOST_ARRAY) #include <boost/array.hpp> #endif // defined(ASIO_HAS_BOOST_ARRAY) -#if defined(ASIO_HAS_STD_ARRAY) -# include <array> -#endif // defined(ASIO_HAS_STD_ARRAY) - using namespace std; // For memcmp, memcpy and memset. class test_stream @@ -54,7 +46,7 @@ public: memset(data_, 0, max_length); } - executor_type get_executor() ASIO_NOEXCEPT + executor_type get_executor() noexcept { return io_context_.get_executor(); } @@ -120,12 +112,13 @@ public: } template <typename Const_Buffers, typename Handler> - void async_write_some(const Const_Buffers& buffers, Handler handler) + void async_write_some(const Const_Buffers& buffers, + Handler&& handler) { size_t bytes_transferred = write_some(buffers); asio::post(get_executor(), asio::detail::bind_handler( - ASIO_MOVE_CAST(Handler)(handler), + static_cast<Handler&&>(handler), asio::error_code(), bytes_transferred)); } @@ -209,7 +202,8 @@ void test_2_arg_vector_buffers_write() test_stream s(ioc); std::vector<asio::const_buffer> buffers; buffers.push_back(asio::buffer(write_data, 32)); - buffers.push_back(asio::buffer(write_data) + 32); + buffers.push_back(asio::buffer(write_data, 39) + 32); + buffers.push_back(asio::buffer(write_data) + 39); s.reset(); size_t bytes_transferred = asio::write(s, buffers); @@ -229,6 +223,38 @@ void test_2_arg_vector_buffers_write() ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); } +void test_2_arg_dynamic_string_write() +{ + asio::io_context ioc; + test_stream s(ioc); + std::string data; + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb + = asio::dynamic_buffer(data, sizeof(write_data)); + asio::const_buffer buffers + = asio::buffer(write_data, sizeof(write_data)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + size_t bytes_transferred = asio::write(s, sb); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + bytes_transferred = asio::write(s, sb); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + bytes_transferred = asio::write(s, sb); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); +} + void test_3_arg_nothrow_zero_buffers_write() { asio::io_context ioc; @@ -305,7 +331,8 @@ void test_3_arg_nothrow_vector_buffers_write() test_stream s(ioc); std::vector<asio::const_buffer> buffers; buffers.push_back(asio::buffer(write_data, 32)); - buffers.push_back(asio::buffer(write_data) + 32); + buffers.push_back(asio::buffer(write_data, 39) + 32); + buffers.push_back(asio::buffer(write_data) + 39); s.reset(); asio::error_code error; @@ -329,17 +356,58 @@ void test_3_arg_nothrow_vector_buffers_write() ASIO_CHECK(!error); } +void test_3_arg_nothrow_dynamic_string_write() +{ + asio::io_context ioc; + test_stream s(ioc); + std::string data; + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb + = asio::dynamic_buffer(data, sizeof(write_data)); + asio::const_buffer buffers + = asio::buffer(write_data, sizeof(write_data)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + asio::error_code error; + size_t bytes_transferred = asio::write(s, sb, error); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + bytes_transferred = asio::write(s, sb, error); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + bytes_transferred = asio::write(s, sb, error); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + ASIO_CHECK(!error); +} + bool old_style_transfer_all(const asio::error_code& ec, size_t /*bytes_transferred*/) { return !!ec; } -size_t short_transfer(const asio::error_code& ec, - size_t /*bytes_transferred*/) +struct short_transfer { - return !!ec ? 0 : 3; -} + short_transfer() {} + short_transfer(short_transfer&&) {} + size_t operator()(const asio::error_code& ec, + size_t /*bytes_transferred*/) + { + return !!ec ? 0 : 3; + } +}; void test_3_arg_const_buffer_write() { @@ -506,19 +574,19 @@ void test_3_arg_const_buffer_write() ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); s.reset(); - bytes_transferred = asio::write(s, buffers, short_transfer); + bytes_transferred = asio::write(s, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); s.reset(); s.next_write_length(1); - bytes_transferred = asio::write(s, buffers, short_transfer); + bytes_transferred = asio::write(s, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); s.reset(); s.next_write_length(10); - bytes_transferred = asio::write(s, buffers, short_transfer); + bytes_transferred = asio::write(s, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); } @@ -688,19 +756,19 @@ void test_3_arg_mutable_buffer_write() ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data))); s.reset(); - bytes_transferred = asio::write(s, buffers, short_transfer); + bytes_transferred = asio::write(s, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data))); s.reset(); s.next_write_length(1); - bytes_transferred = asio::write(s, buffers, short_transfer); + bytes_transferred = asio::write(s, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data))); s.reset(); s.next_write_length(10); - bytes_transferred = asio::write(s, buffers, short_transfer); + bytes_transferred = asio::write(s, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data))); } @@ -711,7 +779,8 @@ void test_3_arg_vector_buffers_write() test_stream s(ioc); std::vector<asio::const_buffer> buffers; buffers.push_back(asio::buffer(write_data, 32)); - buffers.push_back(asio::buffer(write_data) + 32); + buffers.push_back(asio::buffer(write_data, 39) + 32); + buffers.push_back(asio::buffer(write_data) + 39); s.reset(); size_t bytes_transferred = asio::write(s, buffers, @@ -871,19 +940,232 @@ void test_3_arg_vector_buffers_write() ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); s.reset(); - bytes_transferred = asio::write(s, buffers, short_transfer); + bytes_transferred = asio::write(s, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); s.reset(); s.next_write_length(1); - bytes_transferred = asio::write(s, buffers, short_transfer); + bytes_transferred = asio::write(s, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); s.reset(); s.next_write_length(10); - bytes_transferred = asio::write(s, buffers, short_transfer); + bytes_transferred = asio::write(s, buffers, short_transfer()); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); +} + +void test_3_arg_dynamic_string_write() +{ + asio::io_context ioc; + test_stream s(ioc); + std::string data; + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb + = asio::dynamic_buffer(data, sizeof(write_data)); + asio::const_buffer buffers + = asio::buffer(write_data, sizeof(write_data)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + size_t bytes_transferred = asio::write(s, sb, + asio::transfer_all()); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + bytes_transferred = asio::write(s, sb, + asio::transfer_all()); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + bytes_transferred = asio::write(s, sb, + asio::transfer_all()); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + bytes_transferred = asio::write(s, sb, + asio::transfer_at_least(1)); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + bytes_transferred = asio::write(s, sb, + asio::transfer_at_least(1)); + ASIO_CHECK(bytes_transferred == 1); + ASIO_CHECK(s.check_buffers(buffers, 1)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + bytes_transferred = asio::write(s, sb, + asio::transfer_at_least(1)); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(s.check_buffers(buffers, 10)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + bytes_transferred = asio::write(s, sb, + asio::transfer_at_least(10)); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + bytes_transferred = asio::write(s, sb, + asio::transfer_at_least(10)); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(s.check_buffers(buffers, 10)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + bytes_transferred = asio::write(s, sb, + asio::transfer_at_least(10)); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(s.check_buffers(buffers, 10)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + bytes_transferred = asio::write(s, sb, + asio::transfer_at_least(42)); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + bytes_transferred = asio::write(s, sb, + asio::transfer_at_least(42)); + ASIO_CHECK(bytes_transferred == 42); + ASIO_CHECK(s.check_buffers(buffers, 42)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + bytes_transferred = asio::write(s, sb, + asio::transfer_at_least(42)); + ASIO_CHECK(bytes_transferred == 50); + ASIO_CHECK(s.check_buffers(buffers, 50)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + bytes_transferred = asio::write(s, sb, + asio::transfer_exactly(1)); + ASIO_CHECK(bytes_transferred == 1); + ASIO_CHECK(s.check_buffers(buffers, 1)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + bytes_transferred = asio::write(s, sb, + asio::transfer_exactly(1)); + ASIO_CHECK(bytes_transferred == 1); + ASIO_CHECK(s.check_buffers(buffers, 1)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + bytes_transferred = asio::write(s, sb, + asio::transfer_exactly(1)); + ASIO_CHECK(bytes_transferred == 1); + ASIO_CHECK(s.check_buffers(buffers, 1)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + bytes_transferred = asio::write(s, sb, + asio::transfer_exactly(10)); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(s.check_buffers(buffers, 10)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + bytes_transferred = asio::write(s, sb, + asio::transfer_exactly(10)); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(s.check_buffers(buffers, 10)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + bytes_transferred = asio::write(s, sb, + asio::transfer_exactly(10)); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(s.check_buffers(buffers, 10)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + bytes_transferred = asio::write(s, sb, + asio::transfer_exactly(42)); + ASIO_CHECK(bytes_transferred == 42); + ASIO_CHECK(s.check_buffers(buffers, 42)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + bytes_transferred = asio::write(s, sb, + asio::transfer_exactly(42)); + ASIO_CHECK(bytes_transferred == 42); + ASIO_CHECK(s.check_buffers(buffers, 42)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + bytes_transferred = asio::write(s, sb, + asio::transfer_exactly(42)); + ASIO_CHECK(bytes_transferred == 42); + ASIO_CHECK(s.check_buffers(buffers, 42)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + bytes_transferred = asio::write(s, sb, old_style_transfer_all); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + bytes_transferred = asio::write(s, sb, old_style_transfer_all); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + bytes_transferred = asio::write(s, sb, old_style_transfer_all); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + bytes_transferred = asio::write(s, sb, short_transfer()); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + bytes_transferred = asio::write(s, sb, short_transfer()); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + bytes_transferred = asio::write(s, sb, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); } @@ -1103,7 +1385,7 @@ void test_4_arg_const_buffer_write() ASIO_CHECK(!error); s.reset(); - bytes_transferred = asio::write(s, buffers, short_transfer, error); + bytes_transferred = asio::write(s, buffers, short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); ASIO_CHECK(!error); @@ -1111,7 +1393,7 @@ void test_4_arg_const_buffer_write() s.reset(); s.next_write_length(1); error = asio::error_code(); - bytes_transferred = asio::write(s, buffers, short_transfer, error); + bytes_transferred = asio::write(s, buffers, short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); ASIO_CHECK(!error); @@ -1119,7 +1401,7 @@ void test_4_arg_const_buffer_write() s.reset(); s.next_write_length(10); error = asio::error_code(); - bytes_transferred = asio::write(s, buffers, short_transfer, error); + bytes_transferred = asio::write(s, buffers, short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); ASIO_CHECK(!error); @@ -1340,7 +1622,7 @@ void test_4_arg_mutable_buffer_write() ASIO_CHECK(!error); s.reset(); - bytes_transferred = asio::write(s, buffers, short_transfer, error); + bytes_transferred = asio::write(s, buffers, short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data))); ASIO_CHECK(!error); @@ -1348,7 +1630,7 @@ void test_4_arg_mutable_buffer_write() s.reset(); s.next_write_length(1); error = asio::error_code(); - bytes_transferred = asio::write(s, buffers, short_transfer, error); + bytes_transferred = asio::write(s, buffers, short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data))); ASIO_CHECK(!error); @@ -1356,7 +1638,7 @@ void test_4_arg_mutable_buffer_write() s.reset(); s.next_write_length(10); error = asio::error_code(); - bytes_transferred = asio::write(s, buffers, short_transfer, error); + bytes_transferred = asio::write(s, buffers, short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data))); ASIO_CHECK(!error); @@ -1368,7 +1650,8 @@ void test_4_arg_vector_buffers_write() test_stream s(ioc); std::vector<asio::const_buffer> buffers; buffers.push_back(asio::buffer(write_data, 32)); - buffers.push_back(asio::buffer(write_data) + 32); + buffers.push_back(asio::buffer(write_data, 39) + 32); + buffers.push_back(asio::buffer(write_data) + 39); s.reset(); asio::error_code error; @@ -1578,7 +1861,7 @@ void test_4_arg_vector_buffers_write() ASIO_CHECK(!error); s.reset(); - bytes_transferred = asio::write(s, buffers, short_transfer, error); + bytes_transferred = asio::write(s, buffers, short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); ASIO_CHECK(!error); @@ -1586,7 +1869,7 @@ void test_4_arg_vector_buffers_write() s.reset(); s.next_write_length(1); error = asio::error_code(); - bytes_transferred = asio::write(s, buffers, short_transfer, error); + bytes_transferred = asio::write(s, buffers, short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); ASIO_CHECK(!error); @@ -1594,7 +1877,275 @@ void test_4_arg_vector_buffers_write() s.reset(); s.next_write_length(10); error = asio::error_code(); - bytes_transferred = asio::write(s, buffers, short_transfer, error); + bytes_transferred = asio::write(s, buffers, short_transfer(), error); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + ASIO_CHECK(!error); +} + +void test_4_arg_dynamic_string_write() +{ + asio::io_context ioc; + test_stream s(ioc); + std::string data; + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb + = asio::dynamic_buffer(data, sizeof(write_data)); + asio::const_buffer buffers + = asio::buffer(write_data, sizeof(write_data)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + asio::error_code error; + size_t bytes_transferred = asio::write(s, sb, + asio::transfer_all(), error); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, + asio::transfer_all(), error); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, + asio::transfer_all(), error); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, + asio::transfer_at_least(1), error); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, + asio::transfer_at_least(1), error); + ASIO_CHECK(bytes_transferred == 1); + ASIO_CHECK(s.check_buffers(buffers, 1)); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, + asio::transfer_at_least(1), error); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(s.check_buffers(buffers, 10)); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, + asio::transfer_at_least(10), error); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, + asio::transfer_at_least(10), error); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(s.check_buffers(buffers, 10)); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, + asio::transfer_at_least(10), error); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(s.check_buffers(buffers, 10)); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, + asio::transfer_at_least(42), error); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, + asio::transfer_at_least(42), error); + ASIO_CHECK(bytes_transferred == 42); + ASIO_CHECK(s.check_buffers(buffers, 42)); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, + asio::transfer_at_least(42), error); + ASIO_CHECK(bytes_transferred == 50); + ASIO_CHECK(s.check_buffers(buffers, 50)); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, + asio::transfer_exactly(1), error); + ASIO_CHECK(bytes_transferred == 1); + ASIO_CHECK(s.check_buffers(buffers, 1)); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, + asio::transfer_exactly(1), error); + ASIO_CHECK(bytes_transferred == 1); + ASIO_CHECK(s.check_buffers(buffers, 1)); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, + asio::transfer_exactly(1), error); + ASIO_CHECK(bytes_transferred == 1); + ASIO_CHECK(s.check_buffers(buffers, 1)); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, + asio::transfer_exactly(10), error); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(s.check_buffers(buffers, 10)); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, + asio::transfer_exactly(10), error); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(s.check_buffers(buffers, 10)); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, + asio::transfer_exactly(10), error); + ASIO_CHECK(bytes_transferred == 10); + ASIO_CHECK(s.check_buffers(buffers, 10)); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, + asio::transfer_exactly(42), error); + ASIO_CHECK(bytes_transferred == 42); + ASIO_CHECK(s.check_buffers(buffers, 42)); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, + asio::transfer_exactly(42), error); + ASIO_CHECK(bytes_transferred == 42); + ASIO_CHECK(s.check_buffers(buffers, 42)); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, + asio::transfer_exactly(42), error); + ASIO_CHECK(bytes_transferred == 42); + ASIO_CHECK(s.check_buffers(buffers, 42)); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + bytes_transferred = asio::write(s, sb, + old_style_transfer_all, error); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, + old_style_transfer_all, error); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, + old_style_transfer_all, error); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + bytes_transferred = asio::write(s, sb, short_transfer(), error); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, short_transfer(), error); + ASIO_CHECK(bytes_transferred == sizeof(write_data)); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + ASIO_CHECK(!error); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + error = asio::error_code(); + bytes_transferred = asio::write(s, sb, short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); ASIO_CHECK(!error); @@ -1610,13 +2161,9 @@ void async_write_handler(const asio::error_code& e, void test_3_arg_const_buffer_async_write() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_stream s(ioc); @@ -1665,13 +2212,9 @@ void test_3_arg_const_buffer_async_write() void test_3_arg_mutable_buffer_async_write() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_stream s(ioc); @@ -1720,13 +2263,9 @@ void test_3_arg_mutable_buffer_async_write() void test_3_arg_boost_array_buffers_async_write() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; #if defined(ASIO_HAS_BOOST_ARRAY) asio::io_context ioc; @@ -1778,15 +2317,10 @@ void test_3_arg_boost_array_buffers_async_write() void test_3_arg_std_array_buffers_async_write() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; -#if defined(ASIO_HAS_STD_ARRAY) asio::io_context ioc; test_stream s(ioc); std::array<asio::const_buffer, 2> buffers = { { @@ -1831,24 +2365,20 @@ void test_3_arg_std_array_buffers_async_write() ioc.restart(); ioc.run(); ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); -#endif // defined(ASIO_HAS_STD_ARRAY) } void test_3_arg_vector_buffers_async_write() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_stream s(ioc); std::vector<asio::const_buffer> buffers; buffers.push_back(asio::buffer(write_data, 32)); - buffers.push_back(asio::buffer(write_data) + 32); + buffers.push_back(asio::buffer(write_data, 39) + 32); + buffers.push_back(asio::buffer(write_data) + 39); s.reset(); bool called = false; @@ -1890,15 +2420,71 @@ void test_3_arg_vector_buffers_async_write() ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); } +void test_3_arg_dynamic_string_async_write() +{ + namespace bindns = std; + using bindns::placeholders::_1; + using bindns::placeholders::_2; + + asio::io_context ioc; + test_stream s(ioc); + std::string data; + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb + = asio::dynamic_buffer(data, sizeof(write_data)); + asio::const_buffer buffers + = asio::buffer(write_data, sizeof(write_data)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + bool called = false; + asio::async_write(s, sb, + bindns::bind(async_write_handler, + _1, _2, sizeof(write_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + called = false; + asio::async_write(s, sb, + bindns::bind(async_write_handler, + _1, _2, sizeof(write_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + called = false; + asio::async_write(s, sb, + bindns::bind(async_write_handler, + _1, _2, sizeof(write_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + int i = asio::async_write(s, sb, archetypes::lazy_handler()); + ASIO_CHECK(i == 42); + ioc.restart(); + ioc.run(); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); +} + void test_3_arg_streambuf_async_write() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) +#if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_stream s(ioc); @@ -1952,17 +2538,14 @@ void test_3_arg_streambuf_async_write() ioc.restart(); ioc.run(); ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); +#endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) } void test_4_arg_const_buffer_async_write() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_stream s(ioc); @@ -2227,7 +2810,7 @@ void test_4_arg_const_buffer_async_write() s.reset(); called = false; - asio::async_write(s, buffers, short_transfer, + asio::async_write(s, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -2238,7 +2821,7 @@ void test_4_arg_const_buffer_async_write() s.reset(); s.next_write_length(1); called = false; - asio::async_write(s, buffers, short_transfer, + asio::async_write(s, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -2249,7 +2832,7 @@ void test_4_arg_const_buffer_async_write() s.reset(); s.next_write_length(10); called = false; - asio::async_write(s, buffers, short_transfer, + asio::async_write(s, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -2258,7 +2841,7 @@ void test_4_arg_const_buffer_async_write() ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); s.reset(); - int i = asio::async_write(s, buffers, short_transfer, + int i = asio::async_write(s, buffers, short_transfer(), archetypes::lazy_handler()); ASIO_CHECK(i == 42); ioc.restart(); @@ -2268,13 +2851,9 @@ void test_4_arg_const_buffer_async_write() void test_4_arg_mutable_buffer_async_write() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_stream s(ioc); @@ -2539,7 +3118,7 @@ void test_4_arg_mutable_buffer_async_write() s.reset(); called = false; - asio::async_write(s, buffers, short_transfer, + asio::async_write(s, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(mutable_write_data), &called)); ioc.restart(); @@ -2550,7 +3129,7 @@ void test_4_arg_mutable_buffer_async_write() s.reset(); s.next_write_length(1); called = false; - asio::async_write(s, buffers, short_transfer, + asio::async_write(s, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(mutable_write_data), &called)); ioc.restart(); @@ -2561,7 +3140,7 @@ void test_4_arg_mutable_buffer_async_write() s.reset(); s.next_write_length(10); called = false; - asio::async_write(s, buffers, short_transfer, + asio::async_write(s, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(mutable_write_data), &called)); ioc.restart(); @@ -2570,7 +3149,7 @@ void test_4_arg_mutable_buffer_async_write() ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data))); s.reset(); - int i = asio::async_write(s, buffers, short_transfer, + int i = asio::async_write(s, buffers, short_transfer(), archetypes::lazy_handler()); ASIO_CHECK(i == 42); ioc.restart(); @@ -2580,13 +3159,9 @@ void test_4_arg_mutable_buffer_async_write() void test_4_arg_boost_array_buffers_async_write() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; #if defined(ASIO_HAS_BOOST_ARRAY) asio::io_context ioc; @@ -2853,7 +3428,7 @@ void test_4_arg_boost_array_buffers_async_write() s.reset(); called = false; - asio::async_write(s, buffers, short_transfer, + asio::async_write(s, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -2864,7 +3439,7 @@ void test_4_arg_boost_array_buffers_async_write() s.reset(); s.next_write_length(1); called = false; - asio::async_write(s, buffers, short_transfer, + asio::async_write(s, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -2875,7 +3450,7 @@ void test_4_arg_boost_array_buffers_async_write() s.reset(); s.next_write_length(10); called = false; - asio::async_write(s, buffers, short_transfer, + asio::async_write(s, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -2884,7 +3459,7 @@ void test_4_arg_boost_array_buffers_async_write() ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); s.reset(); - int i = asio::async_write(s, buffers, short_transfer, + int i = asio::async_write(s, buffers, short_transfer(), archetypes::lazy_handler()); ASIO_CHECK(i == 42); ioc.restart(); @@ -2895,15 +3470,10 @@ void test_4_arg_boost_array_buffers_async_write() void test_4_arg_std_array_buffers_async_write() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; -#if defined(ASIO_HAS_STD_ARRAY) asio::io_context ioc; test_stream s(ioc); std::array<asio::const_buffer, 2> buffers = { { @@ -3168,7 +3738,7 @@ void test_4_arg_std_array_buffers_async_write() s.reset(); called = false; - asio::async_write(s, buffers, short_transfer, + asio::async_write(s, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -3179,7 +3749,7 @@ void test_4_arg_std_array_buffers_async_write() s.reset(); s.next_write_length(1); called = false; - asio::async_write(s, buffers, short_transfer, + asio::async_write(s, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -3190,7 +3760,7 @@ void test_4_arg_std_array_buffers_async_write() s.reset(); s.next_write_length(10); called = false; - asio::async_write(s, buffers, short_transfer, + asio::async_write(s, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -3199,30 +3769,26 @@ void test_4_arg_std_array_buffers_async_write() ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); s.reset(); - int i = asio::async_write(s, buffers, short_transfer, + int i = asio::async_write(s, buffers, short_transfer(), archetypes::lazy_handler()); ASIO_CHECK(i == 42); ioc.restart(); ioc.run(); ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); -#endif // defined(ASIO_HAS_STD_ARRAY) } void test_4_arg_vector_buffers_async_write() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_stream s(ioc); std::vector<asio::const_buffer> buffers; buffers.push_back(asio::buffer(write_data, 32)); - buffers.push_back(asio::buffer(write_data) + 32); + buffers.push_back(asio::buffer(write_data, 39) + 32); + buffers.push_back(asio::buffer(write_data) + 39); s.reset(); bool called = false; @@ -3482,7 +4048,344 @@ void test_4_arg_vector_buffers_async_write() s.reset(); called = false; - asio::async_write(s, buffers, short_transfer, + asio::async_write(s, buffers, short_transfer(), + bindns::bind(async_write_handler, + _1, _2, sizeof(write_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + s.next_write_length(1); + called = false; + asio::async_write(s, buffers, short_transfer(), + bindns::bind(async_write_handler, + _1, _2, sizeof(write_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + s.next_write_length(10); + called = false; + asio::async_write(s, buffers, short_transfer(), + bindns::bind(async_write_handler, + _1, _2, sizeof(write_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + int i = asio::async_write(s, buffers, short_transfer(), + archetypes::lazy_handler()); + ASIO_CHECK(i == 42); + ioc.restart(); + ioc.run(); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); +} + +void test_4_arg_dynamic_string_async_write() +{ + namespace bindns = std; + using bindns::placeholders::_1; + using bindns::placeholders::_2; + + asio::io_context ioc; + test_stream s(ioc); + std::string data; + asio::dynamic_string_buffer<char, std::string::traits_type, + std::string::allocator_type> sb + = asio::dynamic_buffer(data, sizeof(write_data)); + asio::const_buffer buffers + = asio::buffer(write_data, sizeof(write_data)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + bool called = false; + asio::async_write(s, sb, asio::transfer_all(), + bindns::bind(async_write_handler, + _1, _2, sizeof(write_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + called = false; + asio::async_write(s, sb, asio::transfer_all(), + bindns::bind(async_write_handler, + _1, _2, sizeof(write_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + called = false; + asio::async_write(s, sb, asio::transfer_all(), + bindns::bind(async_write_handler, + _1, _2, sizeof(write_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + called = false; + asio::async_write(s, sb, asio::transfer_at_least(1), + bindns::bind(async_write_handler, + _1, _2, sizeof(write_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + called = false; + asio::async_write(s, sb, asio::transfer_at_least(1), + bindns::bind(async_write_handler, + _1, _2, 1, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, 1)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + called = false; + asio::async_write(s, sb, asio::transfer_at_least(1), + bindns::bind(async_write_handler, + _1, _2, 10, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, 10)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + called = false; + asio::async_write(s, sb, asio::transfer_at_least(10), + bindns::bind(async_write_handler, + _1, _2, sizeof(write_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + called = false; + asio::async_write(s, sb, asio::transfer_at_least(10), + bindns::bind(async_write_handler, + _1, _2, 10, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, 10)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + called = false; + asio::async_write(s, sb, asio::transfer_at_least(10), + bindns::bind(async_write_handler, + _1, _2, 10, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, 10)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + called = false; + asio::async_write(s, sb, asio::transfer_at_least(42), + bindns::bind(async_write_handler, + _1, _2, sizeof(write_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + called = false; + asio::async_write(s, sb, asio::transfer_at_least(42), + bindns::bind(async_write_handler, + _1, _2, 42, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, 42)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + called = false; + asio::async_write(s, sb, asio::transfer_at_least(42), + bindns::bind(async_write_handler, + _1, _2, 50, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, 50)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + called = false; + asio::async_write(s, sb, asio::transfer_exactly(1), + bindns::bind(async_write_handler, + _1, _2, 1, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, 1)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + called = false; + asio::async_write(s, sb, asio::transfer_exactly(1), + bindns::bind(async_write_handler, + _1, _2, 1, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, 1)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + called = false; + asio::async_write(s, sb, asio::transfer_exactly(1), + bindns::bind(async_write_handler, + _1, _2, 1, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, 1)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + called = false; + asio::async_write(s, sb, asio::transfer_exactly(10), + bindns::bind(async_write_handler, + _1, _2, 10, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, 10)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + called = false; + asio::async_write(s, sb, asio::transfer_exactly(10), + bindns::bind(async_write_handler, + _1, _2, 10, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, 10)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + called = false; + asio::async_write(s, sb, asio::transfer_exactly(10), + bindns::bind(async_write_handler, + _1, _2, 10, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, 10)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + called = false; + asio::async_write(s, sb, asio::transfer_exactly(42), + bindns::bind(async_write_handler, + _1, _2, 42, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, 42)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + called = false; + asio::async_write(s, sb, asio::transfer_exactly(42), + bindns::bind(async_write_handler, + _1, _2, 42, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, 42)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + called = false; + asio::async_write(s, sb, asio::transfer_exactly(42), + bindns::bind(async_write_handler, + _1, _2, 42, &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, 42)); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + called = false; + asio::async_write(s, sb, old_style_transfer_all, + bindns::bind(async_write_handler, + _1, _2, sizeof(write_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(1); + called = false; + asio::async_write(s, sb, old_style_transfer_all, + bindns::bind(async_write_handler, + _1, _2, sizeof(write_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + s.next_write_length(10); + called = false; + asio::async_write(s, sb, old_style_transfer_all, + bindns::bind(async_write_handler, + _1, _2, sizeof(write_data), &called)); + ioc.restart(); + ioc.run(); + ASIO_CHECK(called); + ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); + + s.reset(); + data.assign(write_data, sizeof(write_data)); + called = false; + asio::async_write(s, sb, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -3491,9 +4394,10 @@ void test_4_arg_vector_buffers_async_write() ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); s.reset(); + data.assign(write_data, sizeof(write_data)); s.next_write_length(1); called = false; - asio::async_write(s, buffers, short_transfer, + asio::async_write(s, sb, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -3502,9 +4406,10 @@ void test_4_arg_vector_buffers_async_write() ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); s.reset(); + data.assign(write_data, sizeof(write_data)); s.next_write_length(10); called = false; - asio::async_write(s, buffers, short_transfer, + asio::async_write(s, sb, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -3513,7 +4418,8 @@ void test_4_arg_vector_buffers_async_write() ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); s.reset(); - int i = asio::async_write(s, buffers, short_transfer, + data.assign(write_data, sizeof(write_data)); + int i = asio::async_write(s, sb, short_transfer(), archetypes::lazy_handler()); ASIO_CHECK(i == 42); ioc.restart(); @@ -3523,13 +4429,10 @@ void test_4_arg_vector_buffers_async_write() void test_4_arg_streambuf_async_write() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) +#if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_stream s(ioc); @@ -3845,7 +4748,7 @@ void test_4_arg_streambuf_async_write() sb.consume(sb.size()); sb.sputn(write_data, sizeof(write_data)); called = false; - asio::async_write(s, sb, short_transfer, + asio::async_write(s, sb, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -3858,7 +4761,7 @@ void test_4_arg_streambuf_async_write() sb.sputn(write_data, sizeof(write_data)); s.next_write_length(1); called = false; - asio::async_write(s, sb, short_transfer, + asio::async_write(s, sb, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -3871,7 +4774,7 @@ void test_4_arg_streambuf_async_write() sb.sputn(write_data, sizeof(write_data)); s.next_write_length(10); called = false; - asio::async_write(s, sb, short_transfer, + asio::async_write(s, sb, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -3882,12 +4785,13 @@ void test_4_arg_streambuf_async_write() s.reset(); sb.consume(sb.size()); sb.sputn(write_data, sizeof(write_data)); - int i = asio::async_write(s, sb, short_transfer, + int i = asio::async_write(s, sb, short_transfer(), archetypes::lazy_handler()); ASIO_CHECK(i == 42); ioc.restart(); ioc.run(); ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data))); +#endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) } ASIO_TEST_SUITE @@ -3897,26 +4801,32 @@ ASIO_TEST_SUITE ASIO_TEST_CASE(test_2_arg_const_buffer_write) ASIO_TEST_CASE(test_2_arg_mutable_buffer_write) ASIO_TEST_CASE(test_2_arg_vector_buffers_write) + ASIO_TEST_CASE(test_2_arg_dynamic_string_write) ASIO_TEST_CASE(test_3_arg_nothrow_zero_buffers_write) ASIO_TEST_CASE(test_3_arg_nothrow_const_buffer_write) ASIO_TEST_CASE(test_3_arg_nothrow_mutable_buffer_write) ASIO_TEST_CASE(test_3_arg_nothrow_vector_buffers_write) + ASIO_TEST_CASE(test_3_arg_nothrow_dynamic_string_write) ASIO_TEST_CASE(test_3_arg_const_buffer_write) ASIO_TEST_CASE(test_3_arg_mutable_buffer_write) ASIO_TEST_CASE(test_3_arg_vector_buffers_write) + ASIO_TEST_CASE(test_3_arg_dynamic_string_write) ASIO_TEST_CASE(test_4_arg_const_buffer_write) ASIO_TEST_CASE(test_4_arg_mutable_buffer_write) ASIO_TEST_CASE(test_4_arg_vector_buffers_write) + ASIO_TEST_CASE(test_4_arg_dynamic_string_write) ASIO_TEST_CASE(test_3_arg_const_buffer_async_write) ASIO_TEST_CASE(test_3_arg_mutable_buffer_async_write) ASIO_TEST_CASE(test_3_arg_boost_array_buffers_async_write) ASIO_TEST_CASE(test_3_arg_std_array_buffers_async_write) ASIO_TEST_CASE(test_3_arg_vector_buffers_async_write) + ASIO_TEST_CASE(test_3_arg_dynamic_string_async_write) ASIO_TEST_CASE(test_3_arg_streambuf_async_write) ASIO_TEST_CASE(test_4_arg_const_buffer_async_write) ASIO_TEST_CASE(test_4_arg_mutable_buffer_async_write) ASIO_TEST_CASE(test_4_arg_boost_array_buffers_async_write) ASIO_TEST_CASE(test_4_arg_std_array_buffers_async_write) ASIO_TEST_CASE(test_4_arg_vector_buffers_async_write) + ASIO_TEST_CASE(test_4_arg_dynamic_string_async_write) ASIO_TEST_CASE(test_4_arg_streambuf_async_write) ) diff --git a/3rdparty/asio/src/tests/unit/write_at.cpp b/3rdparty/asio/src/tests/unit/write_at.cpp index a8e55e87d90..adc684d0e4f 100644 --- a/3rdparty/asio/src/tests/unit/write_at.cpp +++ b/3rdparty/asio/src/tests/unit/write_at.cpp @@ -2,7 +2,7 @@ // write_at.cpp // ~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 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) @@ -16,27 +16,19 @@ // Test that header file is self-contained. #include "asio/write_at.hpp" +#include <array> #include <cstring> +#include <functional> #include "archetypes/async_result.hpp" #include "asio/io_context.hpp" #include "asio/post.hpp" #include "asio/streambuf.hpp" #include "unit_test.hpp" -#if defined(ASIO_HAS_BOOST_BIND) -# include <boost/bind.hpp> -#else // defined(ASIO_HAS_BOOST_BIND) -# include <functional> -#endif // defined(ASIO_HAS_BOOST_BIND) - #if defined(ASIO_HAS_BOOST_ARRAY) #include <boost/array.hpp> #endif // defined(ASIO_HAS_BOOST_ARRAY) -#if defined(ASIO_HAS_STD_ARRAY) -# include <array> -#endif // defined(ASIO_HAS_STD_ARRAY) - using namespace std; // For memcmp, memcpy and memset. class test_random_access_device @@ -52,7 +44,7 @@ public: memset(data_, 0, max_length); } - executor_type get_executor() ASIO_NOEXCEPT + executor_type get_executor() noexcept { return io_context_.get_executor(); } @@ -118,12 +110,12 @@ public: template <typename Const_Buffers, typename Handler> void async_write_some_at(asio::uint64_t offset, - const Const_Buffers& buffers, Handler handler) + const Const_Buffers& buffers, Handler&& handler) { size_t bytes_transferred = write_some_at(offset, buffers); asio::post(get_executor(), asio::detail::bind_handler( - ASIO_MOVE_CAST(Handler)(handler), + static_cast<Handler&&>(handler), asio::error_code(), bytes_transferred)); } @@ -421,11 +413,16 @@ bool old_style_transfer_all(const asio::error_code& ec, return !!ec; } -size_t short_transfer(const asio::error_code& ec, - size_t /*bytes_transferred*/) +struct short_transfer { - return !!ec ? 0 : 3; -} + short_transfer() {} + short_transfer(short_transfer&&) {} + size_t operator()(const asio::error_code& ec, + size_t /*bytes_transferred*/) + { + return !!ec ? 0 : 3; + } +}; void test_4_arg_const_buffer_write_at() { @@ -755,36 +752,36 @@ void test_4_arg_const_buffer_write_at() ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data))); s.reset(); - bytes_transferred = asio::write_at(s, 0, buffers, short_transfer); + bytes_transferred = asio::write_at(s, 0, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data))); s.reset(); - bytes_transferred = asio::write_at(s, 1234, buffers, short_transfer); + bytes_transferred = asio::write_at(s, 1234, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data))); s.reset(); s.next_write_length(1); - bytes_transferred = asio::write_at(s, 0, buffers, short_transfer); + bytes_transferred = asio::write_at(s, 0, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data))); s.reset(); s.next_write_length(1); - bytes_transferred = asio::write_at(s, 1234, buffers, short_transfer); + bytes_transferred = asio::write_at(s, 1234, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data))); s.reset(); s.next_write_length(10); - bytes_transferred = asio::write_at(s, 0, buffers, short_transfer); + bytes_transferred = asio::write_at(s, 0, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data))); s.reset(); s.next_write_length(10); - bytes_transferred = asio::write_at(s, 1234, buffers, short_transfer); + bytes_transferred = asio::write_at(s, 1234, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data))); } @@ -1117,36 +1114,36 @@ void test_4_arg_mutable_buffer_write_at() ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data))); s.reset(); - bytes_transferred = asio::write_at(s, 0, buffers, short_transfer); + bytes_transferred = asio::write_at(s, 0, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data))); s.reset(); - bytes_transferred = asio::write_at(s, 1234, buffers, short_transfer); + bytes_transferred = asio::write_at(s, 1234, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data))); s.reset(); s.next_write_length(1); - bytes_transferred = asio::write_at(s, 0, buffers, short_transfer); + bytes_transferred = asio::write_at(s, 0, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data))); s.reset(); s.next_write_length(1); - bytes_transferred = asio::write_at(s, 1234, buffers, short_transfer); + bytes_transferred = asio::write_at(s, 1234, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data))); s.reset(); s.next_write_length(10); - bytes_transferred = asio::write_at(s, 0, buffers, short_transfer); + bytes_transferred = asio::write_at(s, 0, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data))); s.reset(); s.next_write_length(10); - bytes_transferred = asio::write_at(s, 1234, buffers, short_transfer); + bytes_transferred = asio::write_at(s, 1234, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data))); } @@ -1480,36 +1477,36 @@ void test_4_arg_vector_buffers_write_at() ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data))); s.reset(); - bytes_transferred = asio::write_at(s, 0, buffers, short_transfer); + bytes_transferred = asio::write_at(s, 0, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data))); s.reset(); - bytes_transferred = asio::write_at(s, 1234, buffers, short_transfer); + bytes_transferred = asio::write_at(s, 1234, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data))); s.reset(); s.next_write_length(1); - bytes_transferred = asio::write_at(s, 0, buffers, short_transfer); + bytes_transferred = asio::write_at(s, 0, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data))); s.reset(); s.next_write_length(1); - bytes_transferred = asio::write_at(s, 1234, buffers, short_transfer); + bytes_transferred = asio::write_at(s, 1234, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data))); s.reset(); s.next_write_length(10); - bytes_transferred = asio::write_at(s, 0, buffers, short_transfer); + bytes_transferred = asio::write_at(s, 0, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data))); s.reset(); s.next_write_length(10); - bytes_transferred = asio::write_at(s, 1234, buffers, short_transfer); + bytes_transferred = asio::write_at(s, 1234, buffers, short_transfer()); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data))); } @@ -1936,14 +1933,14 @@ void test_5_arg_const_buffer_write_at() s.reset(); bytes_transferred = asio::write_at(s, 0, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data))); ASIO_CHECK(!error); s.reset(); bytes_transferred = asio::write_at(s, 1234, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data))); ASIO_CHECK(!error); @@ -1952,7 +1949,7 @@ void test_5_arg_const_buffer_write_at() s.next_write_length(1); error = asio::error_code(); bytes_transferred = asio::write_at(s, 0, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data))); ASIO_CHECK(!error); @@ -1961,7 +1958,7 @@ void test_5_arg_const_buffer_write_at() s.next_write_length(1); error = asio::error_code(); bytes_transferred = asio::write_at(s, 1234, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data))); ASIO_CHECK(!error); @@ -1970,7 +1967,7 @@ void test_5_arg_const_buffer_write_at() s.next_write_length(10); error = asio::error_code(); bytes_transferred = asio::write_at(s, 0, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data))); ASIO_CHECK(!error); @@ -1979,7 +1976,7 @@ void test_5_arg_const_buffer_write_at() s.next_write_length(10); error = asio::error_code(); bytes_transferred = asio::write_at(s, 1234, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data))); ASIO_CHECK(!error); @@ -2407,14 +2404,14 @@ void test_5_arg_mutable_buffer_write_at() s.reset(); bytes_transferred = asio::write_at(s, 0, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data))); ASIO_CHECK(!error); s.reset(); bytes_transferred = asio::write_at(s, 1234, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data))); ASIO_CHECK(!error); @@ -2423,7 +2420,7 @@ void test_5_arg_mutable_buffer_write_at() s.next_write_length(1); error = asio::error_code(); bytes_transferred = asio::write_at(s, 0, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data))); ASIO_CHECK(!error); @@ -2432,7 +2429,7 @@ void test_5_arg_mutable_buffer_write_at() s.next_write_length(1); error = asio::error_code(); bytes_transferred = asio::write_at(s, 1234, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data))); ASIO_CHECK(!error); @@ -2441,7 +2438,7 @@ void test_5_arg_mutable_buffer_write_at() s.next_write_length(10); error = asio::error_code(); bytes_transferred = asio::write_at(s, 0, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data))); ASIO_CHECK(!error); @@ -2450,7 +2447,7 @@ void test_5_arg_mutable_buffer_write_at() s.next_write_length(10); error = asio::error_code(); bytes_transferred = asio::write_at(s, 1234, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data))); ASIO_CHECK(!error); @@ -2879,14 +2876,14 @@ void test_5_arg_vector_buffers_write_at() s.reset(); bytes_transferred = asio::write_at(s, 0, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data))); ASIO_CHECK(!error); s.reset(); bytes_transferred = asio::write_at(s, 1234, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data))); ASIO_CHECK(!error); @@ -2895,7 +2892,7 @@ void test_5_arg_vector_buffers_write_at() s.next_write_length(1); error = asio::error_code(); bytes_transferred = asio::write_at(s, 0, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data))); ASIO_CHECK(!error); @@ -2904,7 +2901,7 @@ void test_5_arg_vector_buffers_write_at() s.next_write_length(1); error = asio::error_code(); bytes_transferred = asio::write_at(s, 1234, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data))); ASIO_CHECK(!error); @@ -2913,7 +2910,7 @@ void test_5_arg_vector_buffers_write_at() s.next_write_length(10); error = asio::error_code(); bytes_transferred = asio::write_at(s, 0, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data))); ASIO_CHECK(!error); @@ -2922,7 +2919,7 @@ void test_5_arg_vector_buffers_write_at() s.next_write_length(10); error = asio::error_code(); bytes_transferred = asio::write_at(s, 1234, buffers, - short_transfer, error); + short_transfer(), error); ASIO_CHECK(bytes_transferred == sizeof(write_data)); ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data))); ASIO_CHECK(!error); @@ -2938,13 +2935,9 @@ void async_write_handler(const asio::error_code& e, void test_4_arg_const_buffer_async_write_at() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_random_access_device s(ioc); @@ -3037,13 +3030,9 @@ void test_4_arg_const_buffer_async_write_at() void test_4_arg_mutable_buffer_async_write_at() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_random_access_device s(ioc); @@ -3136,13 +3125,9 @@ void test_4_arg_mutable_buffer_async_write_at() void test_4_arg_boost_array_buffers_async_write_at() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; #if defined(ASIO_HAS_BOOST_ARRAY) asio::io_context ioc; @@ -3238,15 +3223,10 @@ void test_4_arg_boost_array_buffers_async_write_at() void test_4_arg_std_array_buffers_async_write_at() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; -#if defined(ASIO_HAS_STD_ARRAY) asio::io_context ioc; test_random_access_device s(ioc); std::array<asio::const_buffer, 2> buffers = { { @@ -3335,18 +3315,13 @@ void test_4_arg_std_array_buffers_async_write_at() ioc.restart(); ioc.run(); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data))); -#endif // defined(ASIO_HAS_STD_ARRAY) } void test_4_arg_vector_buffers_async_write_at() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_random_access_device s(ioc); @@ -3440,13 +3415,9 @@ void test_4_arg_vector_buffers_async_write_at() void test_4_arg_streambuf_async_write_at() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_random_access_device s(ioc); @@ -3556,13 +3527,9 @@ void test_4_arg_streambuf_async_write_at() void test_5_arg_const_buffer_async_write_at() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_random_access_device s(ioc); @@ -4125,7 +4092,7 @@ void test_5_arg_const_buffer_async_write_at() s.reset(); called = false; - asio::async_write_at(s, 0, buffers, short_transfer, + asio::async_write_at(s, 0, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -4135,7 +4102,7 @@ void test_5_arg_const_buffer_async_write_at() s.reset(); called = false; - asio::async_write_at(s, 1234, buffers, short_transfer, + asio::async_write_at(s, 1234, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -4146,7 +4113,7 @@ void test_5_arg_const_buffer_async_write_at() s.reset(); s.next_write_length(1); called = false; - asio::async_write_at(s, 0, buffers, short_transfer, + asio::async_write_at(s, 0, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -4157,7 +4124,7 @@ void test_5_arg_const_buffer_async_write_at() s.reset(); s.next_write_length(1); called = false; - asio::async_write_at(s, 1234, buffers, short_transfer, + asio::async_write_at(s, 1234, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -4168,7 +4135,7 @@ void test_5_arg_const_buffer_async_write_at() s.reset(); s.next_write_length(10); called = false; - asio::async_write_at(s, 0, buffers, short_transfer, + asio::async_write_at(s, 0, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -4179,7 +4146,7 @@ void test_5_arg_const_buffer_async_write_at() s.reset(); s.next_write_length(10); called = false; - asio::async_write_at(s, 1234, buffers, short_transfer, + asio::async_write_at(s, 1234, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -4188,7 +4155,7 @@ void test_5_arg_const_buffer_async_write_at() ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data))); s.reset(); - int i = asio::async_write_at(s, 0, buffers, short_transfer, + int i = asio::async_write_at(s, 0, buffers, short_transfer(), archetypes::lazy_handler()); ASIO_CHECK(i == 42); ioc.restart(); @@ -4198,13 +4165,9 @@ void test_5_arg_const_buffer_async_write_at() void test_5_arg_mutable_buffer_async_write_at() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_random_access_device s(ioc); @@ -4767,7 +4730,7 @@ void test_5_arg_mutable_buffer_async_write_at() s.reset(); called = false; - asio::async_write_at(s, 0, buffers, short_transfer, + asio::async_write_at(s, 0, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(mutable_write_data), &called)); ioc.restart(); @@ -4777,7 +4740,7 @@ void test_5_arg_mutable_buffer_async_write_at() s.reset(); called = false; - asio::async_write_at(s, 1234, buffers, short_transfer, + asio::async_write_at(s, 1234, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(mutable_write_data), &called)); ioc.restart(); @@ -4788,7 +4751,7 @@ void test_5_arg_mutable_buffer_async_write_at() s.reset(); s.next_write_length(1); called = false; - asio::async_write_at(s, 0, buffers, short_transfer, + asio::async_write_at(s, 0, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(mutable_write_data), &called)); ioc.restart(); @@ -4799,7 +4762,7 @@ void test_5_arg_mutable_buffer_async_write_at() s.reset(); s.next_write_length(1); called = false; - asio::async_write_at(s, 1234, buffers, short_transfer, + asio::async_write_at(s, 1234, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(mutable_write_data), &called)); ioc.restart(); @@ -4810,7 +4773,7 @@ void test_5_arg_mutable_buffer_async_write_at() s.reset(); s.next_write_length(10); called = false; - asio::async_write_at(s, 0, buffers, short_transfer, + asio::async_write_at(s, 0, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(mutable_write_data), &called)); ioc.restart(); @@ -4821,7 +4784,7 @@ void test_5_arg_mutable_buffer_async_write_at() s.reset(); s.next_write_length(10); called = false; - asio::async_write_at(s, 1234, buffers, short_transfer, + asio::async_write_at(s, 1234, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(mutable_write_data), &called)); ioc.restart(); @@ -4830,7 +4793,7 @@ void test_5_arg_mutable_buffer_async_write_at() ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data))); s.reset(); - int i = asio::async_write_at(s, 0, buffers, short_transfer, + int i = asio::async_write_at(s, 0, buffers, short_transfer(), archetypes::lazy_handler()); ASIO_CHECK(i == 42); ioc.restart(); @@ -4840,13 +4803,9 @@ void test_5_arg_mutable_buffer_async_write_at() void test_5_arg_boost_array_buffers_async_write_at() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; #if defined(ASIO_HAS_BOOST_ARRAY) asio::io_context ioc; @@ -5411,7 +5370,7 @@ void test_5_arg_boost_array_buffers_async_write_at() s.reset(); called = false; - asio::async_write_at(s, 0, buffers, short_transfer, + asio::async_write_at(s, 0, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -5421,7 +5380,7 @@ void test_5_arg_boost_array_buffers_async_write_at() s.reset(); called = false; - asio::async_write_at(s, 1234, buffers, short_transfer, + asio::async_write_at(s, 1234, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -5432,7 +5391,7 @@ void test_5_arg_boost_array_buffers_async_write_at() s.reset(); s.next_write_length(1); called = false; - asio::async_write_at(s, 0, buffers, short_transfer, + asio::async_write_at(s, 0, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -5443,7 +5402,7 @@ void test_5_arg_boost_array_buffers_async_write_at() s.reset(); s.next_write_length(1); called = false; - asio::async_write_at(s, 1234, buffers, short_transfer, + asio::async_write_at(s, 1234, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -5454,7 +5413,7 @@ void test_5_arg_boost_array_buffers_async_write_at() s.reset(); s.next_write_length(10); called = false; - asio::async_write_at(s, 0, buffers, short_transfer, + asio::async_write_at(s, 0, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -5465,7 +5424,7 @@ void test_5_arg_boost_array_buffers_async_write_at() s.reset(); s.next_write_length(10); called = false; - asio::async_write_at(s, 1234, buffers, short_transfer, + asio::async_write_at(s, 1234, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -5474,7 +5433,7 @@ void test_5_arg_boost_array_buffers_async_write_at() ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data))); s.reset(); - int i = asio::async_write_at(s, 0, buffers, short_transfer, + int i = asio::async_write_at(s, 0, buffers, short_transfer(), archetypes::lazy_handler()); ASIO_CHECK(i == 42); ioc.restart(); @@ -5485,15 +5444,10 @@ void test_5_arg_boost_array_buffers_async_write_at() void test_5_arg_std_array_buffers_async_write_at() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; -#if defined(ASIO_HAS_STD_ARRAY) asio::io_context ioc; test_random_access_device s(ioc); std::array<asio::const_buffer, 2> buffers = { { @@ -6056,7 +6010,7 @@ void test_5_arg_std_array_buffers_async_write_at() s.reset(); called = false; - asio::async_write_at(s, 0, buffers, short_transfer, + asio::async_write_at(s, 0, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -6066,7 +6020,7 @@ void test_5_arg_std_array_buffers_async_write_at() s.reset(); called = false; - asio::async_write_at(s, 1234, buffers, short_transfer, + asio::async_write_at(s, 1234, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -6077,7 +6031,7 @@ void test_5_arg_std_array_buffers_async_write_at() s.reset(); s.next_write_length(1); called = false; - asio::async_write_at(s, 0, buffers, short_transfer, + asio::async_write_at(s, 0, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -6088,7 +6042,7 @@ void test_5_arg_std_array_buffers_async_write_at() s.reset(); s.next_write_length(1); called = false; - asio::async_write_at(s, 1234, buffers, short_transfer, + asio::async_write_at(s, 1234, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -6099,7 +6053,7 @@ void test_5_arg_std_array_buffers_async_write_at() s.reset(); s.next_write_length(10); called = false; - asio::async_write_at(s, 0, buffers, short_transfer, + asio::async_write_at(s, 0, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -6110,7 +6064,7 @@ void test_5_arg_std_array_buffers_async_write_at() s.reset(); s.next_write_length(10); called = false; - asio::async_write_at(s, 1234, buffers, short_transfer, + asio::async_write_at(s, 1234, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -6119,24 +6073,19 @@ void test_5_arg_std_array_buffers_async_write_at() ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data))); s.reset(); - int i = asio::async_write_at(s, 0, buffers, short_transfer, + int i = asio::async_write_at(s, 0, buffers, short_transfer(), archetypes::lazy_handler()); ASIO_CHECK(i == 42); ioc.restart(); ioc.run(); ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data))); -#endif // defined(ASIO_HAS_STD_ARRAY) } void test_5_arg_vector_buffers_async_write_at() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_random_access_device s(ioc); @@ -6700,7 +6649,7 @@ void test_5_arg_vector_buffers_async_write_at() s.reset(); called = false; - asio::async_write_at(s, 0, buffers, short_transfer, + asio::async_write_at(s, 0, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -6710,7 +6659,7 @@ void test_5_arg_vector_buffers_async_write_at() s.reset(); called = false; - asio::async_write_at(s, 1234, buffers, short_transfer, + asio::async_write_at(s, 1234, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -6721,7 +6670,7 @@ void test_5_arg_vector_buffers_async_write_at() s.reset(); s.next_write_length(1); called = false; - asio::async_write_at(s, 0, buffers, short_transfer, + asio::async_write_at(s, 0, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -6732,7 +6681,7 @@ void test_5_arg_vector_buffers_async_write_at() s.reset(); s.next_write_length(1); called = false; - asio::async_write_at(s, 1234, buffers, short_transfer, + asio::async_write_at(s, 1234, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -6743,7 +6692,7 @@ void test_5_arg_vector_buffers_async_write_at() s.reset(); s.next_write_length(10); called = false; - asio::async_write_at(s, 0, buffers, short_transfer, + asio::async_write_at(s, 0, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -6754,7 +6703,7 @@ void test_5_arg_vector_buffers_async_write_at() s.reset(); s.next_write_length(10); called = false; - asio::async_write_at(s, 1234, buffers, short_transfer, + asio::async_write_at(s, 1234, buffers, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -6763,7 +6712,7 @@ void test_5_arg_vector_buffers_async_write_at() ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data))); s.reset(); - int i = asio::async_write_at(s, 0, buffers, short_transfer, + int i = asio::async_write_at(s, 0, buffers, short_transfer(), archetypes::lazy_handler()); ASIO_CHECK(i == 42); ioc.restart(); @@ -6773,13 +6722,9 @@ void test_5_arg_vector_buffers_async_write_at() void test_5_arg_streambuf_async_write_at() { -#if defined(ASIO_HAS_BOOST_BIND) - namespace bindns = boost; -#else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; - using std::placeholders::_1; - using std::placeholders::_2; -#endif // defined(ASIO_HAS_BOOST_BIND) + using bindns::placeholders::_1; + using bindns::placeholders::_2; asio::io_context ioc; test_random_access_device s(ioc); @@ -7441,7 +7386,7 @@ void test_5_arg_streambuf_async_write_at() sb.consume(sb.size()); sb.sputn(write_data, sizeof(write_data)); called = false; - asio::async_write_at(s, 0, sb, short_transfer, + asio::async_write_at(s, 0, sb, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -7453,7 +7398,7 @@ void test_5_arg_streambuf_async_write_at() sb.consume(sb.size()); sb.sputn(write_data, sizeof(write_data)); called = false; - asio::async_write_at(s, 1234, sb, short_transfer, + asio::async_write_at(s, 1234, sb, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -7466,7 +7411,7 @@ void test_5_arg_streambuf_async_write_at() sb.sputn(write_data, sizeof(write_data)); s.next_write_length(1); called = false; - asio::async_write_at(s, 0, sb, short_transfer, + asio::async_write_at(s, 0, sb, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -7479,7 +7424,7 @@ void test_5_arg_streambuf_async_write_at() sb.sputn(write_data, sizeof(write_data)); s.next_write_length(1); called = false; - asio::async_write_at(s, 1234, sb, short_transfer, + asio::async_write_at(s, 1234, sb, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -7492,7 +7437,7 @@ void test_5_arg_streambuf_async_write_at() sb.sputn(write_data, sizeof(write_data)); s.next_write_length(10); called = false; - asio::async_write_at(s, 0, sb, short_transfer, + asio::async_write_at(s, 0, sb, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -7505,7 +7450,7 @@ void test_5_arg_streambuf_async_write_at() sb.sputn(write_data, sizeof(write_data)); s.next_write_length(10); called = false; - asio::async_write_at(s, 1234, sb, short_transfer, + asio::async_write_at(s, 1234, sb, short_transfer(), bindns::bind(async_write_handler, _1, _2, sizeof(write_data), &called)); ioc.restart(); @@ -7516,7 +7461,7 @@ void test_5_arg_streambuf_async_write_at() s.reset(); sb.consume(sb.size()); sb.sputn(write_data, sizeof(write_data)); - int i = asio::async_write_at(s, 0, sb, short_transfer, + int i = asio::async_write_at(s, 0, sb, short_transfer(), archetypes::lazy_handler()); ASIO_CHECK(i == 42); ioc.restart(); |