summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/asio/test
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/asio/test
parentInitial commit. (diff)
downloadceph-upstream.tar.xz
ceph-upstream.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/asio/test')
-rw-r--r--src/boost/libs/asio/test/Jamfile.v2235
-rw-r--r--src/boost/libs/asio/test/archetypes/async_ops.hpp415
-rw-r--r--src/boost/libs/asio/test/archetypes/async_result.hpp96
-rw-r--r--src/boost/libs/asio/test/archetypes/gettable_socket_option.hpp54
-rw-r--r--src/boost/libs/asio/test/archetypes/io_control_command.hpp32
-rw-r--r--src/boost/libs/asio/test/archetypes/settable_socket_option.hpp49
-rw-r--r--src/boost/libs/asio/test/associated_allocator.cpp25
-rw-r--r--src/boost/libs/asio/test/associated_executor.cpp25
-rw-r--r--src/boost/libs/asio/test/async_result.cpp25
-rw-r--r--src/boost/libs/asio/test/awaitable.cpp25
-rw-r--r--src/boost/libs/asio/test/basic_datagram_socket.cpp25
-rw-r--r--src/boost/libs/asio/test/basic_deadline_timer.cpp25
-rw-r--r--src/boost/libs/asio/test/basic_raw_socket.cpp25
-rw-r--r--src/boost/libs/asio/test/basic_seq_packet_socket.cpp25
-rw-r--r--src/boost/libs/asio/test/basic_serial_port.cpp26
-rw-r--r--src/boost/libs/asio/test/basic_signal_set.cpp25
-rw-r--r--src/boost/libs/asio/test/basic_socket.cpp25
-rw-r--r--src/boost/libs/asio/test/basic_socket_acceptor.cpp25
-rw-r--r--src/boost/libs/asio/test/basic_stream_socket.cpp25
-rw-r--r--src/boost/libs/asio/test/basic_streambuf.cpp25
-rw-r--r--src/boost/libs/asio/test/basic_waitable_timer.cpp25
-rw-r--r--src/boost/libs/asio/test/bind_executor.cpp25
-rw-r--r--src/boost/libs/asio/test/buffer.cpp830
-rw-r--r--src/boost/libs/asio/test/buffered_read_stream.cpp338
-rw-r--r--src/boost/libs/asio/test/buffered_stream.cpp364
-rw-r--r--src/boost/libs/asio/test/buffered_write_stream.cpp353
-rw-r--r--src/boost/libs/asio/test/buffers_iterator.cpp292
-rw-r--r--src/boost/libs/asio/test/co_spawn.cpp25
-rw-r--r--src/boost/libs/asio/test/completion_condition.cpp25
-rw-r--r--src/boost/libs/asio/test/compose.cpp185
-rw-r--r--src/boost/libs/asio/test/connect.cpp1190
-rw-r--r--src/boost/libs/asio/test/coroutine.cpp112
-rw-r--r--src/boost/libs/asio/test/deadline_timer.cpp392
-rw-r--r--src/boost/libs/asio/test/defer.cpp25
-rw-r--r--src/boost/libs/asio/test/detached.cpp25
-rw-r--r--src/boost/libs/asio/test/dispatch.cpp25
-rw-r--r--src/boost/libs/asio/test/error.cpp89
-rw-r--r--src/boost/libs/asio/test/execution_context.cpp25
-rw-r--r--src/boost/libs/asio/test/executor.cpp25
-rw-r--r--src/boost/libs/asio/test/executor_work_guard.cpp25
-rw-r--r--src/boost/libs/asio/test/generic/basic_endpoint.cpp25
-rw-r--r--src/boost/libs/asio/test/generic/datagram_protocol.cpp263
-rw-r--r--src/boost/libs/asio/test/generic/raw_protocol.cpp263
-rw-r--r--src/boost/libs/asio/test/generic/seq_packet_protocol.cpp205
-rw-r--r--src/boost/libs/asio/test/generic/stream_protocol.cpp248
-rw-r--r--src/boost/libs/asio/test/high_resolution_timer.cpp30
-rw-r--r--src/boost/libs/asio/test/io_context.cpp362
-rw-r--r--src/boost/libs/asio/test/io_context_strand.cpp325
-rw-r--r--src/boost/libs/asio/test/ip/address.cpp144
-rw-r--r--src/boost/libs/asio/test/ip/address_v4.cpp324
-rw-r--r--src/boost/libs/asio/test/ip/address_v4_iterator.cpp27
-rw-r--r--src/boost/libs/asio/test/ip/address_v4_range.cpp27
-rw-r--r--src/boost/libs/asio/test/ip/address_v6.cpp409
-rw-r--r--src/boost/libs/asio/test/ip/address_v6_iterator.cpp27
-rw-r--r--src/boost/libs/asio/test/ip/address_v6_range.cpp27
-rw-r--r--src/boost/libs/asio/test/ip/basic_endpoint.cpp25
-rw-r--r--src/boost/libs/asio/test/ip/basic_resolver.cpp25
-rw-r--r--src/boost/libs/asio/test/ip/basic_resolver_entry.cpp25
-rw-r--r--src/boost/libs/asio/test/ip/basic_resolver_iterator.cpp25
-rw-r--r--src/boost/libs/asio/test/ip/basic_resolver_query.cpp25
-rw-r--r--src/boost/libs/asio/test/ip/host_name.cpp55
-rw-r--r--src/boost/libs/asio/test/ip/icmp.cpp577
-rw-r--r--src/boost/libs/asio/test/ip/multicast.cpp363
-rw-r--r--src/boost/libs/asio/test/ip/network_v4.cpp314
-rw-r--r--src/boost/libs/asio/test/ip/network_v6.cpp238
-rw-r--r--src/boost/libs/asio/test/ip/resolver_query_base.cpp25
-rw-r--r--src/boost/libs/asio/test/ip/tcp.cpp1346
-rw-r--r--src/boost/libs/asio/test/ip/udp.cpp673
-rw-r--r--src/boost/libs/asio/test/ip/unicast.cpp171
-rw-r--r--src/boost/libs/asio/test/ip/v6_only.cpp135
-rw-r--r--src/boost/libs/asio/test/is_read_buffered.cpp129
-rw-r--r--src/boost/libs/asio/test/is_write_buffered.cpp129
-rw-r--r--src/boost/libs/asio/test/latency/Jamfile.v236
-rw-r--r--src/boost/libs/asio/test/latency/allocator.hpp52
-rw-r--r--src/boost/libs/asio/test/latency/high_res_clock.hpp53
-rw-r--r--src/boost/libs/asio/test/latency/tcp_client.cpp124
-rw-r--r--src/boost/libs/asio/test/latency/tcp_server.cpp114
-rw-r--r--src/boost/libs/asio/test/latency/udp_client.cpp104
-rw-r--r--src/boost/libs/asio/test/latency/udp_server.cpp125
-rw-r--r--src/boost/libs/asio/test/local/basic_endpoint.cpp25
-rw-r--r--src/boost/libs/asio/test/local/connect_pair.cpp76
-rw-r--r--src/boost/libs/asio/test/local/datagram_protocol.cpp242
-rw-r--r--src/boost/libs/asio/test/local/stream_protocol.cpp219
-rw-r--r--src/boost/libs/asio/test/packaged_task.cpp25
-rw-r--r--src/boost/libs/asio/test/placeholders.cpp25
-rw-r--r--src/boost/libs/asio/test/posix/basic_descriptor.cpp25
-rw-r--r--src/boost/libs/asio/test/posix/basic_stream_descriptor.cpp25
-rw-r--r--src/boost/libs/asio/test/posix/descriptor.cpp25
-rw-r--r--src/boost/libs/asio/test/posix/descriptor_base.cpp25
-rw-r--r--src/boost/libs/asio/test/posix/stream_descriptor.cpp183
-rw-r--r--src/boost/libs/asio/test/post.cpp25
-rw-r--r--src/boost/libs/asio/test/read.cpp4997
-rw-r--r--src/boost/libs/asio/test/read_at.cpp7502
-rw-r--r--src/boost/libs/asio/test/read_until.cpp1660
-rw-r--r--src/boost/libs/asio/test/redirect_error.cpp25
-rw-r--r--src/boost/libs/asio/test/serial_port.cpp173
-rw-r--r--src/boost/libs/asio/test/serial_port_base.cpp99
-rw-r--r--src/boost/libs/asio/test/signal_set.cpp95
-rw-r--r--src/boost/libs/asio/test/socket_base.cpp650
-rw-r--r--src/boost/libs/asio/test/ssl/Jamfile.v260
-rw-r--r--src/boost/libs/asio/test/ssl/context.cpp25
-rw-r--r--src/boost/libs/asio/test/ssl/context_base.cpp25
-rw-r--r--src/boost/libs/asio/test/ssl/error.cpp25
-rw-r--r--src/boost/libs/asio/test/ssl/host_name_verification.cpp25
-rw-r--r--src/boost/libs/asio/test/ssl/rfc2818_verification.cpp25
-rw-r--r--src/boost/libs/asio/test/ssl/stream.cpp191
-rw-r--r--src/boost/libs/asio/test/ssl/stream_base.cpp25
-rw-r--r--src/boost/libs/asio/test/steady_timer.cpp30
-rw-r--r--src/boost/libs/asio/test/strand.cpp263
-rw-r--r--src/boost/libs/asio/test/streambuf.cpp62
-rw-r--r--src/boost/libs/asio/test/system_context.cpp30
-rw-r--r--src/boost/libs/asio/test/system_executor.cpp30
-rw-r--r--src/boost/libs/asio/test/system_timer.cpp399
-rw-r--r--src/boost/libs/asio/test/this_coro.cpp25
-rw-r--r--src/boost/libs/asio/test/time_traits.cpp25
-rw-r--r--src/boost/libs/asio/test/ts/buffer.cpp30
-rw-r--r--src/boost/libs/asio/test/ts/executor.cpp30
-rw-r--r--src/boost/libs/asio/test/ts/internet.cpp30
-rw-r--r--src/boost/libs/asio/test/ts/io_context.cpp30
-rw-r--r--src/boost/libs/asio/test/ts/net.cpp30
-rw-r--r--src/boost/libs/asio/test/ts/netfwd.cpp33
-rw-r--r--src/boost/libs/asio/test/ts/socket.cpp30
-rw-r--r--src/boost/libs/asio/test/ts/timer.cpp30
-rw-r--r--src/boost/libs/asio/test/unit_test.hpp177
-rw-r--r--src/boost/libs/asio/test/use_awaitable.cpp25
-rw-r--r--src/boost/libs/asio/test/use_future.cpp670
-rw-r--r--src/boost/libs/asio/test/uses_executor.cpp25
-rw-r--r--src/boost/libs/asio/test/wait_traits.cpp25
-rw-r--r--src/boost/libs/asio/test/windows/basic_object_handle.cpp25
-rw-r--r--src/boost/libs/asio/test/windows/basic_overlapped_handle.cpp25
-rw-r--r--src/boost/libs/asio/test/windows/basic_random_access_handle.cpp25
-rw-r--r--src/boost/libs/asio/test/windows/basic_stream_handle.cpp25
-rw-r--r--src/boost/libs/asio/test/windows/object_handle.cpp130
-rw-r--r--src/boost/libs/asio/test/windows/overlapped_handle.cpp26
-rw-r--r--src/boost/libs/asio/test/windows/overlapped_ptr.cpp107
-rw-r--r--src/boost/libs/asio/test/windows/random_access_handle.cpp155
-rw-r--r--src/boost/libs/asio/test/windows/stream_handle.cpp148
-rw-r--r--src/boost/libs/asio/test/write.cpp4904
-rw-r--r--src/boost/libs/asio/test/write_at.cpp7563
139 files changed, 44905 insertions, 0 deletions
diff --git a/src/boost/libs/asio/test/Jamfile.v2 b/src/boost/libs/asio/test/Jamfile.v2
new file mode 100644
index 000000000..a9835751c
--- /dev/null
+++ b/src/boost/libs/asio/test/Jamfile.v2
@@ -0,0 +1,235 @@
+#
+# Copyright (c) 2003-2020 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)
+#
+
+import feature ;
+
+lib socket ; # SOLARIS, QNXNTO
+lib nsl ; # SOLARIS
+lib ws2_32 ; # NT
+lib mswsock ; # NT
+lib ipv6 ; # HPUX
+lib network ; # HAIKU
+
+local USE_SELECT =
+ <define>BOOST_ASIO_DISABLE_DEV_POLL
+ <define>BOOST_ASIO_DISABLE_EPOLL
+ <define>BOOST_ASIO_DISABLE_KQUEUE
+ <define>BOOST_ASIO_DISABLE_IOCP
+ ;
+
+project
+ : requirements
+ <library>/boost/date_time//boost_date_time
+ <library>/boost/system//boost_system
+ <library>/boost/chrono//boost_chrono
+ <library>/boost/regex//boost_regex
+ <define>BOOST_ALL_NO_LIB=1
+ <threading>multi
+ <target-os>linux:<define>_XOPEN_SOURCE=600
+ <target-os>linux:<define>_GNU_SOURCE=1
+ <target-os>solaris:<define>_XOPEN_SOURCE=500
+ <target-os>solaris:<define>__EXTENSIONS__
+ <target-os>solaris:<library>socket
+ <target-os>solaris:<library>nsl
+ <target-os>windows:<define>_WIN32_WINNT=0x0501
+ <target-os>windows,<toolset>cw:<library>ws2_32
+ <target-os>windows,<toolset>cw:<library>mswsock
+ <target-os>windows,<toolset>gcc:<library>ws2_32
+ <target-os>windows,<toolset>gcc:<library>mswsock
+ <target-os>windows,<toolset>gcc-cygwin:<define>__USE_W32_SOCKETS
+ <target-os>hpux,<toolset>gcc:<define>_XOPEN_SOURCE_EXTENDED
+ <target-os>hpux:<library>ipv6
+ <target-os>qnxnto:<library>socket
+ <target-os>haiku:<library>network
+ ;
+
+test-suite "asio" :
+ [ link awaitable.cpp ]
+ [ link awaitable.cpp : $(USE_SELECT) : awaitable_select ]
+ [ link basic_datagram_socket.cpp ]
+ [ link basic_datagram_socket.cpp : $(USE_SELECT) : basic_datagram_socket_select ]
+ [ link basic_deadline_timer.cpp ]
+ [ link basic_deadline_timer.cpp : $(USE_SELECT) : basic_deadline_timer_select ]
+ [ link basic_raw_socket.cpp ]
+ [ link basic_raw_socket.cpp : $(USE_SELECT) : basic_raw_socket_select ]
+ [ link basic_seq_packet_socket.cpp ]
+ [ link basic_seq_packet_socket.cpp : $(USE_SELECT) : basic_seq_packet_socket_select ]
+ [ link basic_signal_set.cpp ]
+ [ link basic_signal_set.cpp : $(USE_SELECT) : basic_signal_set_select ]
+ [ link basic_socket_acceptor.cpp ]
+ [ link basic_socket_acceptor.cpp : $(USE_SELECT) : basic_socket_acceptor_select ]
+ [ link basic_stream_socket.cpp ]
+ [ link basic_stream_socket.cpp : $(USE_SELECT) : basic_stream_socket_select ]
+ [ link basic_streambuf.cpp ]
+ [ link basic_streambuf.cpp : $(USE_SELECT) : basic_streambuf_select ]
+ [ link basic_waitable_timer.cpp ]
+ [ link basic_waitable_timer.cpp : $(USE_SELECT) : basic_waitable_timer_select ]
+ [ run buffer.cpp ]
+ [ run buffer.cpp : : : $(USE_SELECT) : buffer_select ]
+ [ run buffered_read_stream.cpp ]
+ [ run buffered_read_stream.cpp : : : $(USE_SELECT) : buffered_read_stream_select ]
+ [ run buffered_stream.cpp ]
+ [ run buffered_stream.cpp : : : $(USE_SELECT) : buffered_stream_select ]
+ [ run buffered_write_stream.cpp ]
+ [ run buffered_write_stream.cpp : : : $(USE_SELECT) : buffered_write_stream_select ]
+ [ run buffers_iterator.cpp ]
+ [ run buffers_iterator.cpp : : : $(USE_SELECT) : buffers_iterator_select ]
+ [ link co_spawn.cpp ]
+ [ link co_spawn.cpp : $(USE_SELECT) : co_spawn_select ]
+ [ link completion_condition.cpp ]
+ [ link completion_condition.cpp : $(USE_SELECT) : completion_condition_select ]
+ [ run compose.cpp ]
+ [ run compose.cpp : : : $(USE_SELECT) : compose_select ]
+ [ link connect.cpp ]
+ [ link connect.cpp : $(USE_SELECT) : connect_select ]
+ [ link coroutine.cpp ]
+ [ link coroutine.cpp : $(USE_SELECT) : coroutine_select ]
+ [ run deadline_timer.cpp ]
+ [ run deadline_timer.cpp : : : $(USE_SELECT) : deadline_timer_select ]
+ [ link detached.cpp ]
+ [ link detached.cpp : $(USE_SELECT) : detached_select ]
+ [ run error.cpp ]
+ [ run error.cpp : : : $(USE_SELECT) : error_select ]
+ [ link generic/basic_endpoint.cpp : : generic_basic_endpoint ]
+ [ link generic/basic_endpoint.cpp : $(USE_SELECT) : generic_basic_endpoint_select ]
+ [ link generic/datagram_protocol.cpp : : generic_datagram_protocol ]
+ [ link generic/datagram_protocol.cpp : $(USE_SELECT) : generic_datagram_protocol_select ]
+ [ link generic/raw_protocol.cpp : : generic_raw_protocol ]
+ [ link generic/raw_protocol.cpp : $(USE_SELECT) : generic_raw_protocol_select ]
+ [ link generic/seq_packet_protocol.cpp : : generic_seq_packet_protocol ]
+ [ link generic/seq_packet_protocol.cpp : $(USE_SELECT) : generic_seq_packet_protocol_select ]
+ [ link generic/stream_protocol.cpp : : generic_stream_protocol ]
+ [ link generic/stream_protocol.cpp : $(USE_SELECT) : generic_stream_protocol_select ]
+ [ link high_resolution_timer.cpp ]
+ [ link high_resolution_timer.cpp : $(USE_SELECT) : high_resolution_timer_select ]
+ [ run io_context.cpp ]
+ [ run io_context.cpp : : : $(USE_SELECT) : io_context_select ]
+ [ run io_context_strand.cpp ]
+ [ run io_context_strand.cpp : : : $(USE_SELECT) : io_context_strand_select ]
+ [ link ip/address.cpp : : ip_address ]
+ [ link ip/address.cpp : $(USE_SELECT) : ip_address_select ]
+ [ link ip/address_v4.cpp : : ip_address_v4 ]
+ [ link ip/address_v4.cpp : $(USE_SELECT) : ip_address_v4_select ]
+ [ link ip/address_v6.cpp : : ip_address_v6 ]
+ [ link ip/address_v6.cpp : $(USE_SELECT) : ip_address_v6_select ]
+ [ link ip/basic_endpoint.cpp : : ip_basic_endpoint ]
+ [ link ip/basic_endpoint.cpp : $(USE_SELECT) : ip_basic_endpoint_select ]
+ [ link ip/basic_resolver.cpp : : ip_basic_resolver ]
+ [ link ip/basic_resolver.cpp : $(USE_SELECT) : ip_basic_resolver_select ]
+ [ link ip/basic_resolver_entry.cpp : : ip_basic_resolver_entry ]
+ [ link ip/basic_resolver_entry.cpp : $(USE_SELECT) : ip_basic_resolver_entry_select ]
+ [ link ip/basic_resolver_iterator.cpp : : ip_basic_resolver_iterator ]
+ [ link ip/basic_resolver_iterator.cpp : $(USE_SELECT) : ip_basic_resolver_iterator_select ]
+ [ link ip/basic_resolver_query.cpp : : ip_basic_resolver_query ]
+ [ link ip/basic_resolver_query.cpp : $(USE_SELECT) : ip_basic_resolver_query_select ]
+ [ run ip/host_name.cpp : : : : ip_host_name ]
+ [ run ip/host_name.cpp : : : $(USE_SELECT) : ip_host_name_select ]
+ [ run ip/icmp.cpp : : : : ip_icmp ]
+ [ run ip/icmp.cpp : : : $(USE_SELECT) : ip_icmp_select ]
+ [ run ip/multicast.cpp : : : : ip_multicast ]
+ [ run ip/multicast.cpp : : : $(USE_SELECT) : ip_multicast_select ]
+ [ link ip/resolver_query_base.cpp : : ip_resolver_query_base ]
+ [ link ip/resolver_query_base.cpp : $(USE_SELECT) : ip_resolver_query_base_select ]
+ [ run ip/tcp.cpp : : : : ip_tcp ]
+ [ run ip/tcp.cpp : : : $(USE_SELECT) : ip_tcp_select ]
+ [ run ip/udp.cpp : : : : ip_udp ]
+ [ run ip/udp.cpp : : : $(USE_SELECT) : ip_udp_select ]
+ [ run ip/unicast.cpp : : : : ip_unicast ]
+ [ run ip/unicast.cpp : : : $(USE_SELECT) : ip_unicast_select ]
+ [ run ip/v6_only.cpp : : : : ip_v6_only ]
+ [ run ip/v6_only.cpp : : : $(USE_SELECT) : ip_v6_only_select ]
+ [ run is_read_buffered.cpp ]
+ [ run is_read_buffered.cpp : : : $(USE_SELECT) : is_read_buffered_select ]
+ [ run is_write_buffered.cpp ]
+ [ run is_write_buffered.cpp : : : $(USE_SELECT) : is_write_buffered_select ]
+ [ link local/basic_endpoint.cpp : : local_basic_endpoint ]
+ [ link local/basic_endpoint.cpp : $(USE_SELECT) : local_basic_endpoint_select ]
+ [ link local/connect_pair.cpp : : local_connect_pair ]
+ [ link local/connect_pair.cpp : $(USE_SELECT) : local_connect_pair_select ]
+ [ link local/datagram_protocol.cpp : : local_datagram_protocol ]
+ [ link local/datagram_protocol.cpp : $(USE_SELECT) : local_datagram_protocol_select ]
+ [ link local/stream_protocol.cpp : : local_stream_protocol ]
+ [ link local/stream_protocol.cpp : $(USE_SELECT) : local_stream_protocol_select ]
+ [ link placeholders.cpp ]
+ [ link placeholders.cpp : $(USE_SELECT) : placeholders_select ]
+ [ link posix/basic_descriptor.cpp : : posix_basic_descriptor ]
+ [ link posix/basic_descriptor.cpp : $(USE_SELECT) : posix_basic_descriptor_select ]
+ [ link posix/basic_stream_descriptor.cpp : : posix_basic_stream_descriptor ]
+ [ link posix/basic_stream_descriptor.cpp : $(USE_SELECT) : posix_basic_stream_descriptor_select ]
+ [ link posix/descriptor_base.cpp : : posix_descriptor_base ]
+ [ link posix/descriptor_base.cpp : $(USE_SELECT) : posix_descriptor_base_select ]
+ [ link posix/stream_descriptor.cpp : : posix_stream_descriptor ]
+ [ link posix/stream_descriptor.cpp : $(USE_SELECT) : posix_stream_descriptor_select ]
+ [ run read.cpp ]
+ [ run read.cpp : : : $(USE_SELECT) : read_select ]
+ [ run read_at.cpp ]
+ [ run read_at.cpp : : : $(USE_SELECT) : read_at_select ]
+ [ run read_until.cpp ]
+ [ run read_until.cpp : : : $(USE_SELECT) : read_until_select ]
+ [ link redirect_error.cpp ]
+ [ link redirect_error.cpp : $(USE_SELECT) : redirect_error_select ]
+ [ run signal_set.cpp ]
+ [ run signal_set.cpp : : : $(USE_SELECT) : signal_set_select ]
+ [ run socket_base.cpp ]
+ [ run socket_base.cpp : : : $(USE_SELECT) : socket_base_select ]
+ [ link steady_timer.cpp ]
+ [ link steady_timer.cpp : $(USE_SELECT) : steady_timer_select ]
+ [ run strand.cpp ]
+ [ run strand.cpp : : : $(USE_SELECT) : strand_select ]
+ [ run streambuf.cpp ]
+ [ run streambuf.cpp : : : $(USE_SELECT) : streambuf_select ]
+ [ link system_timer.cpp ]
+ [ link system_timer.cpp : $(USE_SELECT) : system_timer_select ]
+ [ link system_context.cpp ]
+ [ link system_context.cpp : $(USE_SELECT) : system_context_select ]
+ [ link system_executor.cpp ]
+ [ link system_executor.cpp : $(USE_SELECT) : system_executor_select ]
+ [ link this_coro.cpp ]
+ [ link this_coro.cpp : $(USE_SELECT) : this_coro_select ]
+ [ link time_traits.cpp ]
+ [ link time_traits.cpp : $(USE_SELECT) : time_traits_select ]
+ [ link ts/buffer.cpp : : ts_buffer ]
+ [ link ts/buffer.cpp : $(USE_SELECT) : ts_buffer_select ]
+ [ link ts/executor.cpp : : ts_executor ]
+ [ link ts/executor.cpp : $(USE_SELECT) : ts_executor_select ]
+ [ link ts/internet.cpp : : ts_internet ]
+ [ link ts/internet.cpp : $(USE_SELECT) : ts_internet_select ]
+ [ link ts/io_context.cpp : : ts_io_context ]
+ [ link ts/io_context.cpp : $(USE_SELECT) : ts_io_context_select ]
+ [ link ts/net.cpp : : ts_net ]
+ [ link ts/net.cpp : $(USE_SELECT) : ts_net_select ]
+ [ link ts/netfwd.cpp : : ts_netfwd ]
+ [ link ts/netfwd.cpp : $(USE_SELECT) : ts_netfwd_select ]
+ [ link ts/socket.cpp : : ts_socket ]
+ [ link ts/socket.cpp : $(USE_SELECT) : ts_socket_select ]
+ [ link ts/timer.cpp : : ts_timer ]
+ [ link ts/timer.cpp : $(USE_SELECT) : ts_timer_select ]
+ [ link use_awaitable.cpp ]
+ [ link use_awaitable.cpp : $(USE_SELECT) : use_awaitable_select ]
+ [ link wait_traits.cpp ]
+ [ link wait_traits.cpp : $(USE_SELECT) : wait_traits_select ]
+ [ link windows/basic_object_handle.cpp : : windows_basic_object_handle ]
+ [ link windows/basic_object_handle.cpp : $(USE_SELECT) : windows_basic_object_handle_select ]
+ [ link windows/basic_overlapped_handle.cpp : : windows_basic_overlapped_handle ]
+ [ link windows/basic_overlapped_handle.cpp : $(USE_SELECT) : windows_basic_overlapped_handle_select ]
+ [ link windows/basic_random_access_handle.cpp : : windows_basic_random_access_handle ]
+ [ link windows/basic_random_access_handle.cpp : $(USE_SELECT) : windows_basic_random_access_handle_select ]
+ [ link windows/basic_stream_handle.cpp : : windows_basic_stream_handle ]
+ [ link windows/basic_stream_handle.cpp : $(USE_SELECT) : windows_basic_stream_handle_select ]
+ [ link windows/object_handle.cpp : : windows_object_handle ]
+ [ link windows/object_handle.cpp : $(USE_SELECT) : windows_object_handle_select ]
+ [ link windows/overlapped_ptr.cpp : : windows_overlapped_ptr ]
+ [ link windows/overlapped_ptr.cpp : $(USE_SELECT) : windows_overlapped_ptr_select ]
+ [ link windows/random_access_handle.cpp : : windows_random_access_handle ]
+ [ link windows/random_access_handle.cpp : $(USE_SELECT) : windows_random_access_handle_select ]
+ [ link windows/stream_handle.cpp : : windows_stream_handle ]
+ [ link windows/stream_handle.cpp : $(USE_SELECT) : windows_stream_handle_select ]
+ [ run write.cpp ]
+ [ run write.cpp : : : $(USE_SELECT) : write_select ]
+ [ run write_at.cpp ]
+ [ run write_at.cpp : : : $(USE_SELECT) : write_at_select ]
+ ;
diff --git a/src/boost/libs/asio/test/archetypes/async_ops.hpp b/src/boost/libs/asio/test/archetypes/async_ops.hpp
new file mode 100644
index 000000000..99a33b28d
--- /dev/null
+++ b/src/boost/libs/asio/test/archetypes/async_ops.hpp
@@ -0,0 +1,415 @@
+//
+// async_ops.hpp
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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_ASYNC_OPS_HPP
+#define ARCHETYPES_ASYNC_OPS_HPP
+
+#include <boost/asio/associated_allocator.hpp>
+#include <boost/asio/associated_executor.hpp>
+#include <boost/asio/async_result.hpp>
+#include <boost/asio/error.hpp>
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <boost/bind/bind.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <functional>
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+
+namespace archetypes {
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+
+template <typename CompletionToken>
+BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void())
+async_op_0(BOOST_ASIO_MOVE_ARG(CompletionToken) token)
+{
+ typedef typename boost::asio::async_completion<CompletionToken,
+ void()>::completion_handler_type handler_type;
+
+ boost::asio::async_completion<CompletionToken,
+ void()> completion(token);
+
+ typename boost::asio::associated_allocator<handler_type>::type a
+ = boost::asio::get_associated_allocator(completion.completion_handler);
+
+ typename boost::asio::associated_executor<handler_type>::type ex
+ = boost::asio::get_associated_executor(completion.completion_handler);
+
+ ex.post(BOOST_ASIO_MOVE_CAST(handler_type)(completion.completion_handler), a);
+
+ return completion.result.get();
+}
+
+template <typename CompletionToken>
+BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void(boost::system::error_code))
+async_op_ec_0(bool ok, BOOST_ASIO_MOVE_ARG(CompletionToken) token)
+{
+ typedef typename boost::asio::async_completion<CompletionToken,
+ void(boost::system::error_code)>::completion_handler_type handler_type;
+
+ boost::asio::async_completion<CompletionToken,
+ void(boost::system::error_code)> completion(token);
+
+ typename boost::asio::associated_allocator<handler_type>::type a
+ = boost::asio::get_associated_allocator(completion.completion_handler);
+
+ typename boost::asio::associated_executor<handler_type>::type ex
+ = boost::asio::get_associated_executor(completion.completion_handler);
+
+ if (ok)
+ {
+ ex.post(
+ bindns::bind(
+ BOOST_ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ boost::system::error_code()), a);
+ }
+ else
+ {
+ ex.post(
+ bindns::bind(
+ BOOST_ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ boost::system::error_code(boost::asio::error::operation_aborted)), a);
+ }
+
+ return completion.result.get();
+}
+
+template <typename CompletionToken>
+BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void(std::exception_ptr))
+async_op_ex_0(bool ok, BOOST_ASIO_MOVE_ARG(CompletionToken) token)
+{
+ typedef typename boost::asio::async_completion<CompletionToken,
+ void(std::exception_ptr)>::completion_handler_type handler_type;
+
+ boost::asio::async_completion<CompletionToken,
+ void(std::exception_ptr)> completion(token);
+
+ typename boost::asio::associated_allocator<handler_type>::type a
+ = boost::asio::get_associated_allocator(completion.completion_handler);
+
+ typename boost::asio::associated_executor<handler_type>::type ex
+ = boost::asio::get_associated_executor(completion.completion_handler);
+
+ if (ok)
+ {
+ ex.post(
+ bindns::bind(
+ BOOST_ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ std::exception_ptr()), a);
+ }
+ else
+ {
+ ex.post(
+ bindns::bind(
+ BOOST_ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ std::make_exception_ptr(std::runtime_error("blah"))), a);
+ }
+
+ return completion.result.get();
+}
+
+template <typename CompletionToken>
+BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void(int))
+async_op_1(BOOST_ASIO_MOVE_ARG(CompletionToken) token)
+{
+ typedef typename boost::asio::async_completion<CompletionToken,
+ void(int)>::completion_handler_type handler_type;
+
+ boost::asio::async_completion<CompletionToken,
+ void(int)> completion(token);
+
+ typename boost::asio::associated_allocator<handler_type>::type a
+ = boost::asio::get_associated_allocator(completion.completion_handler);
+
+ typename boost::asio::associated_executor<handler_type>::type ex
+ = boost::asio::get_associated_executor(completion.completion_handler);
+
+ ex.post(
+ bindns::bind(
+ BOOST_ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ 42), a);
+
+ return completion.result.get();
+}
+
+template <typename CompletionToken>
+BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken,
+ void(boost::system::error_code, int))
+async_op_ec_1(bool ok, BOOST_ASIO_MOVE_ARG(CompletionToken) token)
+{
+ typedef typename boost::asio::async_completion<CompletionToken,
+ void(boost::system::error_code, int)>::completion_handler_type
+ handler_type;
+
+ boost::asio::async_completion<CompletionToken,
+ void(boost::system::error_code, int)> completion(token);
+
+ typename boost::asio::associated_allocator<handler_type>::type a
+ = boost::asio::get_associated_allocator(completion.completion_handler);
+
+ typename boost::asio::associated_executor<handler_type>::type ex
+ = boost::asio::get_associated_executor(completion.completion_handler);
+
+ if (ok)
+ {
+ ex.post(
+ bindns::bind(
+ BOOST_ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ boost::system::error_code(), 42), a);
+ }
+ else
+ {
+ ex.post(
+ bindns::bind(
+ BOOST_ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ boost::system::error_code(boost::asio::error::operation_aborted),
+ 0), a);
+ }
+
+ return completion.result.get();
+}
+
+template <typename CompletionToken>
+BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void(std::exception_ptr, int))
+async_op_ex_1(bool ok, BOOST_ASIO_MOVE_ARG(CompletionToken) token)
+{
+ typedef typename boost::asio::async_completion<CompletionToken,
+ void(std::exception_ptr, int)>::completion_handler_type
+ handler_type;
+
+ boost::asio::async_completion<CompletionToken,
+ void(std::exception_ptr, int)> completion(token);
+
+ typename boost::asio::associated_allocator<handler_type>::type a
+ = boost::asio::get_associated_allocator(completion.completion_handler);
+
+ typename boost::asio::associated_executor<handler_type>::type ex
+ = boost::asio::get_associated_executor(completion.completion_handler);
+
+ if (ok)
+ {
+ ex.post(
+ bindns::bind(
+ BOOST_ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ std::exception_ptr(), 42), a);
+ }
+ else
+ {
+ ex.post(
+ bindns::bind(
+ BOOST_ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ std::make_exception_ptr(std::runtime_error("blah")), 0), a);
+ }
+
+ return completion.result.get();
+}
+
+template <typename CompletionToken>
+BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void(int, double))
+async_op_2(BOOST_ASIO_MOVE_ARG(CompletionToken) token)
+{
+ typedef typename boost::asio::async_completion<CompletionToken,
+ void(int, double)>::completion_handler_type handler_type;
+
+ boost::asio::async_completion<CompletionToken,
+ void(int, double)> completion(token);
+
+ typename boost::asio::associated_allocator<handler_type>::type a
+ = boost::asio::get_associated_allocator(completion.completion_handler);
+
+ typename boost::asio::associated_executor<handler_type>::type ex
+ = boost::asio::get_associated_executor(completion.completion_handler);
+
+ ex.post(
+ bindns::bind(
+ BOOST_ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ 42, 2.0), a);
+
+ return completion.result.get();
+}
+
+template <typename CompletionToken>
+BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken,
+ void(boost::system::error_code, int, double))
+async_op_ec_2(bool ok, BOOST_ASIO_MOVE_ARG(CompletionToken) token)
+{
+ typedef typename boost::asio::async_completion<CompletionToken,
+ void(boost::system::error_code, int, double)>::completion_handler_type
+ handler_type;
+
+ boost::asio::async_completion<CompletionToken,
+ void(boost::system::error_code, int, double)> completion(token);
+
+ typename boost::asio::associated_allocator<handler_type>::type a
+ = boost::asio::get_associated_allocator(completion.completion_handler);
+
+ typename boost::asio::associated_executor<handler_type>::type ex
+ = boost::asio::get_associated_executor(completion.completion_handler);
+
+ if (ok)
+ {
+ ex.post(
+ bindns::bind(
+ BOOST_ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ boost::system::error_code(), 42, 2.0), a);
+ }
+ else
+ {
+ ex.post(
+ bindns::bind(
+ BOOST_ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ boost::system::error_code(boost::asio::error::operation_aborted),
+ 0, 0.0), a);
+ }
+
+ return completion.result.get();
+}
+
+template <typename CompletionToken>
+BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken,
+ void(std::exception_ptr, int, double))
+async_op_ex_2(bool ok, BOOST_ASIO_MOVE_ARG(CompletionToken) token)
+{
+ typedef typename boost::asio::async_completion<CompletionToken,
+ void(std::exception_ptr, int, double)>::completion_handler_type
+ handler_type;
+
+ boost::asio::async_completion<CompletionToken,
+ void(std::exception_ptr, int, double)> completion(token);
+
+ typename boost::asio::associated_allocator<handler_type>::type a
+ = boost::asio::get_associated_allocator(completion.completion_handler);
+
+ typename boost::asio::associated_executor<handler_type>::type ex
+ = boost::asio::get_associated_executor(completion.completion_handler);
+
+ if (ok)
+ {
+ ex.post(
+ bindns::bind(
+ BOOST_ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ std::exception_ptr(), 42, 2.0), a);
+ }
+ else
+ {
+ ex.post(
+ bindns::bind(
+ BOOST_ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ std::make_exception_ptr(std::runtime_error("blah")), 0, 0.0), a);
+ }
+
+ return completion.result.get();
+}
+
+template <typename CompletionToken>
+BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void(int, double, char))
+async_op_3(BOOST_ASIO_MOVE_ARG(CompletionToken) token)
+{
+ typedef typename boost::asio::async_completion<CompletionToken,
+ void(int, double, char)>::completion_handler_type handler_type;
+
+ boost::asio::async_completion<CompletionToken,
+ void(int, double, char)> completion(token);
+
+ typename boost::asio::associated_allocator<handler_type>::type a
+ = boost::asio::get_associated_allocator(completion.completion_handler);
+
+ typename boost::asio::associated_executor<handler_type>::type ex
+ = boost::asio::get_associated_executor(completion.completion_handler);
+
+ ex.post(
+ bindns::bind(
+ BOOST_ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ 42, 2.0, 'a'), a);
+
+ return completion.result.get();
+}
+
+template <typename CompletionToken>
+BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken,
+ void(boost::system::error_code, int, double, char))
+async_op_ec_3(bool ok, BOOST_ASIO_MOVE_ARG(CompletionToken) token)
+{
+ typedef typename boost::asio::async_completion<CompletionToken,
+ void(boost::system::error_code, int, double, char)>::completion_handler_type
+ handler_type;
+
+ boost::asio::async_completion<CompletionToken,
+ void(boost::system::error_code, int, double, char)> completion(token);
+
+ typename boost::asio::associated_allocator<handler_type>::type a
+ = boost::asio::get_associated_allocator(completion.completion_handler);
+
+ typename boost::asio::associated_executor<handler_type>::type ex
+ = boost::asio::get_associated_executor(completion.completion_handler);
+
+ if (ok)
+ {
+ ex.post(
+ bindns::bind(
+ BOOST_ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ boost::system::error_code(), 42, 2.0, 'a'), a);
+ }
+ else
+ {
+ ex.post(
+ bindns::bind(
+ BOOST_ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ boost::system::error_code(boost::asio::error::operation_aborted),
+ 0, 0.0, 'z'), a);
+ }
+
+ return completion.result.get();
+}
+
+template <typename CompletionToken>
+BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken,
+ void(std::exception_ptr, int, double, char))
+async_op_ex_3(bool ok, BOOST_ASIO_MOVE_ARG(CompletionToken) token)
+{
+ typedef typename boost::asio::async_completion<CompletionToken,
+ void(std::exception_ptr, int, double, char)>::completion_handler_type
+ handler_type;
+
+ boost::asio::async_completion<CompletionToken,
+ void(std::exception_ptr, int, double, char)> completion(token);
+
+ typename boost::asio::associated_allocator<handler_type>::type a
+ = boost::asio::get_associated_allocator(completion.completion_handler);
+
+ typename boost::asio::associated_executor<handler_type>::type ex
+ = boost::asio::get_associated_executor(completion.completion_handler);
+
+ if (ok)
+ {
+ ex.post(
+ bindns::bind(
+ BOOST_ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ std::exception_ptr(), 42, 2.0, 'a'), a);
+ }
+ else
+ {
+ ex.post(
+ bindns::bind(
+ BOOST_ASIO_MOVE_CAST(handler_type)(completion.completion_handler),
+ std::make_exception_ptr(std::runtime_error("blah")),
+ 0, 0.0, 'z'), a);
+ }
+
+ return completion.result.get();
+}
+
+} // namespace archetypes
+
+#endif // ARCHETYPES_ASYNC_OPS_HPP
diff --git a/src/boost/libs/asio/test/archetypes/async_result.hpp b/src/boost/libs/asio/test/archetypes/async_result.hpp
new file mode 100644
index 000000000..50193eca3
--- /dev/null
+++ b/src/boost/libs/asio/test/archetypes/async_result.hpp
@@ -0,0 +1,96 @@
+//
+// async_result.hpp
+// ~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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_ASYNC_RESULT_HPP
+#define ARCHETYPES_ASYNC_RESULT_HPP
+
+#include <boost/asio/async_result.hpp>
+
+namespace archetypes {
+
+struct lazy_handler
+{
+};
+
+template <typename Signature>
+struct concrete_handler;
+
+template <typename R, typename Arg1>
+struct concrete_handler<R(Arg1)>
+{
+ concrete_handler(lazy_handler)
+ {
+ }
+
+ void operator()(typename boost::asio::decay<Arg1>::type)
+ {
+ }
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ concrete_handler(concrete_handler&&) {}
+private:
+ concrete_handler(const concrete_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+
+template <typename R, typename Arg1, typename Arg2>
+struct concrete_handler<R(Arg1, Arg2)>
+{
+ concrete_handler(lazy_handler)
+ {
+ }
+
+ void operator()(typename boost::asio::decay<Arg1>::type, typename boost::asio::decay<Arg2>::type)
+ {
+ }
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ concrete_handler(concrete_handler&&) {}
+private:
+ concrete_handler(const concrete_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+
+} // namespace archetypes
+
+namespace boost {
+namespace asio {
+
+template <typename Signature>
+class async_result<archetypes::lazy_handler, Signature>
+{
+public:
+ // The concrete completion handler type.
+ typedef archetypes::concrete_handler<Signature> completion_handler_type;
+
+ // The return type of the initiating function.
+ typedef int 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.
+ return_type get()
+ {
+ return 42;
+ }
+
+private:
+ // Disallow copying and assignment.
+ async_result(const async_result&) BOOST_ASIO_DELETED;
+ async_result& operator=(const async_result&) BOOST_ASIO_DELETED;
+};
+
+} // namespace asio
+} // namespace boost
+
+#endif // ARCHETYPES_ASYNC_RESULT_HPP
diff --git a/src/boost/libs/asio/test/archetypes/gettable_socket_option.hpp b/src/boost/libs/asio/test/archetypes/gettable_socket_option.hpp
new file mode 100644
index 000000000..29a75753b
--- /dev/null
+++ b/src/boost/libs/asio/test/archetypes/gettable_socket_option.hpp
@@ -0,0 +1,54 @@
+//
+// gettable_socket_option.hpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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_GETTABLE_SOCKET_OPTION_HPP
+#define ARCHETYPES_GETTABLE_SOCKET_OPTION_HPP
+
+#include <cstddef>
+
+namespace archetypes {
+
+template <typename PointerType>
+class gettable_socket_option
+{
+public:
+ template <typename Protocol>
+ int level(const Protocol&) const
+ {
+ return 0;
+ }
+
+ template <typename Protocol>
+ int name(const Protocol&) const
+ {
+ return 0;
+ }
+
+ template <typename Protocol>
+ PointerType* data(const Protocol&)
+ {
+ return 0;
+ }
+
+ template <typename Protocol>
+ std::size_t size(const Protocol&) const
+ {
+ return 0;
+ }
+
+ template <typename Protocol>
+ void resize(const Protocol&, std::size_t)
+ {
+ }
+};
+
+} // namespace archetypes
+
+#endif // ARCHETYPES_GETTABLE_SOCKET_OPTION_HPP
diff --git a/src/boost/libs/asio/test/archetypes/io_control_command.hpp b/src/boost/libs/asio/test/archetypes/io_control_command.hpp
new file mode 100644
index 000000000..d0c329360
--- /dev/null
+++ b/src/boost/libs/asio/test/archetypes/io_control_command.hpp
@@ -0,0 +1,32 @@
+//
+// io_control_command.hpp
+// ~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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_IO_CONTROL_COMMAND_HPP
+#define ARCHETYPES_IO_CONTROL_COMMAND_HPP
+
+namespace archetypes {
+
+class io_control_command
+{
+public:
+ int name() const
+ {
+ return 0;
+ }
+
+ void* data()
+ {
+ return 0;
+ }
+};
+
+} // namespace archetypes
+
+#endif // ARCHETYPES_IO_CONTROL_COMMAND_HPP
diff --git a/src/boost/libs/asio/test/archetypes/settable_socket_option.hpp b/src/boost/libs/asio/test/archetypes/settable_socket_option.hpp
new file mode 100644
index 000000000..01eeb0d94
--- /dev/null
+++ b/src/boost/libs/asio/test/archetypes/settable_socket_option.hpp
@@ -0,0 +1,49 @@
+//
+// settable_socket_option.hpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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_SETTABLE_SOCKET_OPTION_HPP
+#define ARCHETYPES_SETTABLE_SOCKET_OPTION_HPP
+
+#include <cstddef>
+
+namespace archetypes {
+
+template <typename PointerType>
+class settable_socket_option
+{
+public:
+ template <typename Protocol>
+ int level(const Protocol&) const
+ {
+ return 0;
+ }
+
+ template <typename Protocol>
+ int name(const Protocol&) const
+ {
+ return 0;
+ }
+
+ template <typename Protocol>
+ const PointerType* data(const Protocol&) const
+ {
+ return 0;
+ }
+
+ template <typename Protocol>
+ std::size_t size(const Protocol&) const
+ {
+ return 0;
+ }
+};
+
+} // namespace archetypes
+
+#endif // ARCHETYPES_SETTABLE_SOCKET_OPTION_HPP
diff --git a/src/boost/libs/asio/test/associated_allocator.cpp b/src/boost/libs/asio/test/associated_allocator.cpp
new file mode 100644
index 000000000..5a4471e13
--- /dev/null
+++ b/src/boost/libs/asio/test/associated_allocator.cpp
@@ -0,0 +1,25 @@
+//
+// associated_allocator.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/associated_allocator.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "associated_allocator",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/associated_executor.cpp b/src/boost/libs/asio/test/associated_executor.cpp
new file mode 100644
index 000000000..b26a450ed
--- /dev/null
+++ b/src/boost/libs/asio/test/associated_executor.cpp
@@ -0,0 +1,25 @@
+//
+// associated_executor.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/associated_executor.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "associated_executor",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/async_result.cpp b/src/boost/libs/asio/test/async_result.cpp
new file mode 100644
index 000000000..8df819d53
--- /dev/null
+++ b/src/boost/libs/asio/test/async_result.cpp
@@ -0,0 +1,25 @@
+//
+// async_result.cpp
+// ~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/async_result.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "async_result",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/awaitable.cpp b/src/boost/libs/asio/test/awaitable.cpp
new file mode 100644
index 000000000..6730bce8a
--- /dev/null
+++ b/src/boost/libs/asio/test/awaitable.cpp
@@ -0,0 +1,25 @@
+//
+// awaitable.cpp
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/awaitable.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "awaitable",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/basic_datagram_socket.cpp b/src/boost/libs/asio/test/basic_datagram_socket.cpp
new file mode 100644
index 000000000..f21788543
--- /dev/null
+++ b/src/boost/libs/asio/test/basic_datagram_socket.cpp
@@ -0,0 +1,25 @@
+//
+// basic_datagram_socket.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/basic_datagram_socket.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "basic_datagram_socket",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/basic_deadline_timer.cpp b/src/boost/libs/asio/test/basic_deadline_timer.cpp
new file mode 100644
index 000000000..ac5e43e97
--- /dev/null
+++ b/src/boost/libs/asio/test/basic_deadline_timer.cpp
@@ -0,0 +1,25 @@
+//
+// basic_deadline_timer.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/basic_deadline_timer.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "basic_deadline_timer",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/basic_raw_socket.cpp b/src/boost/libs/asio/test/basic_raw_socket.cpp
new file mode 100644
index 000000000..e93d27c3d
--- /dev/null
+++ b/src/boost/libs/asio/test/basic_raw_socket.cpp
@@ -0,0 +1,25 @@
+//
+// basic_raw_socket.cpp
+// ~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/basic_raw_socket.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "basic_raw_socket",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/basic_seq_packet_socket.cpp b/src/boost/libs/asio/test/basic_seq_packet_socket.cpp
new file mode 100644
index 000000000..27268b360
--- /dev/null
+++ b/src/boost/libs/asio/test/basic_seq_packet_socket.cpp
@@ -0,0 +1,25 @@
+//
+// basic_seq_packet_socket.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/basic_seq_packet_socket.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "basic_seq_packet_socket",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/basic_serial_port.cpp b/src/boost/libs/asio/test/basic_serial_port.cpp
new file mode 100644
index 000000000..f5055317a
--- /dev/null
+++ b/src/boost/libs/asio/test/basic_serial_port.cpp
@@ -0,0 +1,26 @@
+//
+// basic_serial_port.cpp
+// ~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/basic_serial_port.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "basic_serial_port",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/basic_signal_set.cpp b/src/boost/libs/asio/test/basic_signal_set.cpp
new file mode 100644
index 000000000..d699b07f9
--- /dev/null
+++ b/src/boost/libs/asio/test/basic_signal_set.cpp
@@ -0,0 +1,25 @@
+//
+// basic_signal_set.cpp
+// ~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/basic_signal_set.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "basic_signal_set",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/basic_socket.cpp b/src/boost/libs/asio/test/basic_socket.cpp
new file mode 100644
index 000000000..9b4d13746
--- /dev/null
+++ b/src/boost/libs/asio/test/basic_socket.cpp
@@ -0,0 +1,25 @@
+//
+// basic_socket.cpp
+// ~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/basic_socket.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "basic_socket",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/basic_socket_acceptor.cpp b/src/boost/libs/asio/test/basic_socket_acceptor.cpp
new file mode 100644
index 000000000..aa6e4c113
--- /dev/null
+++ b/src/boost/libs/asio/test/basic_socket_acceptor.cpp
@@ -0,0 +1,25 @@
+//
+// basic_socket_acceptor.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/basic_socket_acceptor.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "basic_socket_acceptor",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/basic_stream_socket.cpp b/src/boost/libs/asio/test/basic_stream_socket.cpp
new file mode 100644
index 000000000..01195d315
--- /dev/null
+++ b/src/boost/libs/asio/test/basic_stream_socket.cpp
@@ -0,0 +1,25 @@
+//
+// basic_stream_socket.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/basic_stream_socket.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "basic_stream_socket",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/basic_streambuf.cpp b/src/boost/libs/asio/test/basic_streambuf.cpp
new file mode 100644
index 000000000..e9d6139cd
--- /dev/null
+++ b/src/boost/libs/asio/test/basic_streambuf.cpp
@@ -0,0 +1,25 @@
+//
+// basic_streambuf.cpp
+// ~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/basic_streambuf.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "basic_streambuf",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/basic_waitable_timer.cpp b/src/boost/libs/asio/test/basic_waitable_timer.cpp
new file mode 100644
index 000000000..2321747c9
--- /dev/null
+++ b/src/boost/libs/asio/test/basic_waitable_timer.cpp
@@ -0,0 +1,25 @@
+//
+// basic_waitable_timer.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/basic_waitable_timer.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "basic_waitable_timer",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/bind_executor.cpp b/src/boost/libs/asio/test/bind_executor.cpp
new file mode 100644
index 000000000..cc95310b5
--- /dev/null
+++ b/src/boost/libs/asio/test/bind_executor.cpp
@@ -0,0 +1,25 @@
+//
+// bind_executor.cpp
+// ~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/bind_executor.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "bind_executor",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/buffer.cpp b/src/boost/libs/asio/test/buffer.cpp
new file mode 100644
index 000000000..806856026
--- /dev/null
+++ b/src/boost/libs/asio/test/buffer.cpp
@@ -0,0 +1,830 @@
+//
+// buffer.cpp
+// ~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/buffer.hpp>
+
+#include "unit_test.hpp"
+
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+# include <boost/array.hpp>
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+
+#if defined(BOOST_ASIO_HAS_STD_ARRAY)
+# include <array>
+#endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
+
+//------------------------------------------------------------------------------
+
+// buffer_compile test
+// ~~~~~~~~~~~~~~~~~~~
+// The following test checks that all overloads of the buffer function compile
+// and link correctly. Runtime failures are ignored.
+
+namespace buffer_compile {
+
+using namespace boost::asio;
+
+void test()
+{
+ try
+ {
+ char raw_data[1024];
+ const char const_raw_data[1024] = "";
+ void* void_ptr_data = raw_data;
+ const void* const_void_ptr_data = const_raw_data;
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+ boost::array<char, 1024> array_data;
+ const boost::array<char, 1024>& const_array_data_1 = array_data;
+ boost::array<const char, 1024> const_array_data_2 = { { 0 } };
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+#if defined(BOOST_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(BOOST_ASIO_HAS_STD_ARRAY)
+ std::vector<char> vector_data(1024);
+ const std::vector<char>& const_vector_data = vector_data;
+ std::string string_data(1024, ' ');
+ const std::string const_string_data(1024, ' ');
+ std::vector<mutable_buffer> mutable_buffer_sequence;
+ std::vector<const_buffer> const_buffer_sequence;
+#if defined(BOOST_ASIO_HAS_STD_STRING_VIEW)
+ std::string_view string_view_data(string_data);
+#elif defined(BOOST_ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
+ std::experimental::string_view string_view_data(string_data);
+#endif // defined(BOOST_ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
+
+ // mutable_buffer constructors.
+
+ mutable_buffer mb1;
+ mutable_buffer mb2(void_ptr_data, 1024);
+ mutable_buffer mb3(mb1);
+ (void)mb3;
+
+ // mutable_buffer functions.
+
+ void* ptr1 = mb1.data();
+ (void)ptr1;
+
+ std::size_t n1 = mb1.size();
+ (void)n1;
+
+ // mutable_buffer operators.
+
+ mb1 += 128;
+ mb1 = mb2 + 128;
+ mb1 = 128 + mb2;
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ // mutable_buffers_1 constructors.
+
+ mutable_buffers_1 mbc1(mb1);
+ mutable_buffers_1 mbc2(mbc1);
+
+ // mutable_buffers_1 functions.
+
+ mutable_buffers_1::const_iterator iter1 = mbc1.begin();
+ (void)iter1;
+ mutable_buffers_1::const_iterator iter2 = mbc1.end();
+ (void)iter2;
+
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ // const_buffer constructors.
+
+ 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.
+
+ const void* ptr2 = cb1.data();
+ (void)ptr2;
+
+ std::size_t n2 = cb1.size();
+ (void)n2;
+
+ // const_buffer operators.
+
+ cb1 += 128;
+ cb1 = cb2 + 128;
+ cb1 = 128 + cb2;
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ // const_buffers_1 constructors.
+
+ const_buffers_1 cbc1(cb1);
+ const_buffers_1 cbc2(cbc1);
+
+ // const_buffers_1 functions.
+
+ const_buffers_1::const_iterator iter3 = cbc1.begin();
+ (void)iter3;
+ const_buffers_1::const_iterator iter4 = cbc1.end();
+ (void)iter4;
+
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ // buffer_size function overloads.
+
+ std::size_t size1 = buffer_size(mb1);
+ (void)size1;
+ std::size_t size2 = buffer_size(cb1);
+ (void)size2;
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ std::size_t size3 = buffer_size(mbc1);
+ (void)size3;
+ std::size_t size4 = buffer_size(cbc1);
+ (void)size4;
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+ std::size_t size5 = buffer_size(mutable_buffer_sequence);
+ (void)size5;
+ std::size_t size6 = buffer_size(const_buffer_sequence);
+ (void)size6;
+
+ // buffer_cast function overloads.
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ void* ptr3 = buffer_cast<void*>(mb1);
+ (void)ptr3;
+ const void* ptr4 = buffer_cast<const void*>(cb1);
+ (void)ptr4;
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ // buffer function overloads.
+
+ mb1 = buffer(mb2);
+ mb1 = buffer(mb2, 128);
+ cb1 = buffer(cb2);
+ cb1 = buffer(cb2, 128);
+ mb1 = buffer(void_ptr_data, 1024);
+ cb1 = buffer(const_void_ptr_data, 1024);
+ mb1 = buffer(raw_data);
+ mb1 = buffer(raw_data, 1024);
+ cb1 = buffer(const_raw_data);
+ cb1 = buffer(const_raw_data, 1024);
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+ mb1 = buffer(array_data);
+ mb1 = buffer(array_data, 1024);
+ cb1 = buffer(const_array_data_1);
+ cb1 = buffer(const_array_data_1, 1024);
+ cb1 = buffer(const_array_data_2);
+ cb1 = buffer(const_array_data_2, 1024);
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+#if defined(BOOST_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(BOOST_ASIO_HAS_STD_ARRAY)
+ mb1 = buffer(vector_data);
+ mb1 = buffer(vector_data, 1024);
+ cb1 = buffer(const_vector_data);
+ cb1 = buffer(const_vector_data, 1024);
+ mb1 = buffer(string_data);
+ mb1 = buffer(string_data, 1024);
+ cb1 = buffer(const_string_data);
+ cb1 = buffer(const_string_data, 1024);
+#if defined(BOOST_ASIO_HAS_STRING_VIEW)
+ cb1 = buffer(string_view_data);
+ cb1 = buffer(string_view_data, 1024);
+#endif // defined(BOOST_ASIO_HAS_STRING_VIEW)
+
+ // buffer_copy function overloads.
+
+ std::size_t size7 = buffer_copy(mb1, cb2);
+ (void)size7;
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ std::size_t size8 = buffer_copy(mb1, cbc2);
+ (void)size8;
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+ std::size_t size9 = buffer_copy(mb1, mb2);
+ (void)size9;
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ std::size_t size10 = buffer_copy(mb1, mbc2);
+ (void)size10;
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+ std::size_t size11 = buffer_copy(mb1, const_buffer_sequence);
+ (void)size11;
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ std::size_t size12 = buffer_copy(mbc1, cb2);
+ (void)size12;
+ std::size_t size13 = buffer_copy(mbc1, cbc2);
+ (void)size13;
+ std::size_t size14 = buffer_copy(mbc1, mb2);
+ (void)size14;
+ std::size_t size15 = buffer_copy(mbc1, mbc2);
+ (void)size15;
+ std::size_t size16 = buffer_copy(mbc1, const_buffer_sequence);
+ (void)size16;
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+ std::size_t size17 = buffer_copy(mutable_buffer_sequence, cb2);
+ (void)size17;
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ std::size_t size18 = buffer_copy(mutable_buffer_sequence, cbc2);
+ (void)size18;
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+ std::size_t size19 = buffer_copy(mutable_buffer_sequence, mb2);
+ (void)size19;
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ std::size_t size20 = buffer_copy(mutable_buffer_sequence, mbc2);
+ (void)size20;
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+ std::size_t size21 = buffer_copy(
+ mutable_buffer_sequence, const_buffer_sequence);
+ (void)size21;
+ std::size_t size22 = buffer_copy(mb1, cb2, 128);
+ (void)size22;
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ std::size_t size23 = buffer_copy(mb1, cbc2, 128);
+ (void)size23;
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+ std::size_t size24 = buffer_copy(mb1, mb2, 128);
+ (void)size24;
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ std::size_t size25 = buffer_copy(mb1, mbc2, 128);
+ (void)size25;
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+ std::size_t size26 = buffer_copy(mb1, const_buffer_sequence, 128);
+ (void)size26;
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ std::size_t size27 = buffer_copy(mbc1, cb2, 128);
+ (void)size27;
+ std::size_t size28 = buffer_copy(mbc1, cbc2, 128);
+ (void)size28;
+ std::size_t size29 = buffer_copy(mbc1, mb2, 128);
+ (void)size29;
+ std::size_t size30 = buffer_copy(mbc1, mbc2, 128);
+ (void)size30;
+ std::size_t size31 = buffer_copy(mbc1, const_buffer_sequence, 128);
+ (void)size31;
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+ std::size_t size32 = buffer_copy(mutable_buffer_sequence, cb2, 128);
+ (void)size32;
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ std::size_t size33 = buffer_copy(mutable_buffer_sequence, cbc2, 128);
+ (void)size33;
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+ std::size_t size34 = buffer_copy(mutable_buffer_sequence, mb2, 128);
+ (void)size34;
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ std::size_t size35 = buffer_copy(mutable_buffer_sequence, mbc2, 128);
+ (void)size35;
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+ std::size_t size36 = buffer_copy(
+ mutable_buffer_sequence, const_buffer_sequence, 128);
+ (void)size36;
+
+ // dynamic_buffer function overloads.
+
+ dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> db1 = dynamic_buffer(string_data);
+ (void)db1;
+ dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> db2 = dynamic_buffer(string_data, 1024);
+ (void)db2;
+ dynamic_vector_buffer<char, std::allocator<char> >
+ db3 = dynamic_buffer(vector_data);
+ (void)db3;
+ dynamic_vector_buffer<char, std::allocator<char> >
+ db4 = dynamic_buffer(vector_data, 1024);
+ (void)db4;
+
+ // dynamic_buffer member functions.
+
+ std::size_t size37 = db1.size();
+ (void)size37;
+ std::size_t size38 = db3.size();
+ (void)size38;
+
+ std::size_t size39 = db1.max_size();
+ (void)size39;
+ std::size_t size40 = db3.max_size();
+ (void)size40;
+
+#if !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+ dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type>::const_buffers_type
+ cb5 = db1.data();
+ (void)cb5;
+ dynamic_vector_buffer<char, std::allocator<char> >::const_buffers_type
+ cb6 = db3.data();
+ (void)cb6;
+
+ dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type>::mutable_buffers_type mb5
+ = db1.prepare(1024);
+ (void)mb5;
+ dynamic_vector_buffer<char, std::allocator<char> >::mutable_buffers_type
+ mb6 = db3.prepare(1024);
+ (void)mb6;
+
+ db1.commit(1024);
+ db3.commit(1024);
+#endif // !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+
+ dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type>::mutable_buffers_type
+ mb7 = db1.data(0, 1);
+ (void)mb7;
+ dynamic_vector_buffer<char, std::allocator<char> >::mutable_buffers_type
+ mb8 = db3.data(0, 1);
+ (void)mb8;
+
+ dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type>::const_buffers_type
+ cb7 = static_cast<const dynamic_string_buffer<char,
+ std::string::traits_type,
+ std::string::allocator_type>&>(db1).data(0, 1);
+ (void)cb7;
+ dynamic_vector_buffer<char, std::allocator<char> >::const_buffers_type
+ cb8 = static_cast<const dynamic_vector_buffer<char,
+ std::allocator<char> >&>(db3).data(0, 1);
+ (void)cb8;
+
+ db1.grow(1024);
+ db3.grow(1024);
+
+ db1.shrink(1024);
+ db3.shrink(1024);
+
+ db1.consume(0);
+ db3.consume(0);
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace buffer_compile
+
+//------------------------------------------------------------------------------
+
+namespace buffer_copy_runtime {
+
+using namespace boost::asio;
+using namespace std;
+
+void test()
+{
+ char dest_data[256];
+ char source_data[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+ memset(dest_data, 0, sizeof(dest_data));
+ mutable_buffer mb1 = boost::asio::buffer(dest_data);
+ mutable_buffer mb2 = boost::asio::buffer(source_data);
+ std::size_t n = buffer_copy(mb1, mb2);
+ BOOST_ASIO_CHECK(n == sizeof(source_data));
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+
+ memset(dest_data, 0, sizeof(dest_data));
+ mb1 = boost::asio::buffer(dest_data);
+ const_buffer cb1 = boost::asio::buffer(source_data);
+ n = buffer_copy(mb1, cb1);
+ BOOST_ASIO_CHECK(n == sizeof(source_data));
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ memset(dest_data, 0, sizeof(dest_data));
+ mb1 = boost::asio::buffer(dest_data);
+ mutable_buffers_1 mbc1 = boost::asio::buffer(source_data);
+ n = buffer_copy(mb1, mbc1);
+ BOOST_ASIO_CHECK(n == sizeof(source_data));
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+
+ memset(dest_data, 0, sizeof(dest_data));
+ mb1 = boost::asio::buffer(dest_data);
+ const_buffers_1 cbc1 = const_buffers_1(boost::asio::buffer(source_data));
+ n = buffer_copy(mb1, cbc1);
+ BOOST_ASIO_CHECK(n == sizeof(source_data));
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+
+ memset(dest_data, 0, sizeof(dest_data));
+ mbc1 = boost::asio::buffer(dest_data);
+ mb1 = boost::asio::buffer(source_data);
+ n = buffer_copy(mbc1, mb1);
+ BOOST_ASIO_CHECK(n == sizeof(source_data));
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+
+ memset(dest_data, 0, sizeof(dest_data));
+ mbc1 = boost::asio::buffer(dest_data);
+ cb1 = boost::asio::buffer(source_data);
+ n = buffer_copy(mbc1, cb1);
+ BOOST_ASIO_CHECK(n == sizeof(source_data));
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+
+ memset(dest_data, 0, sizeof(dest_data));
+ mbc1 = boost::asio::buffer(dest_data);
+ mutable_buffers_1 mbc2 = boost::asio::buffer(source_data);
+ n = buffer_copy(mbc1, mbc2);
+ BOOST_ASIO_CHECK(n == sizeof(source_data));
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+
+ memset(dest_data, 0, sizeof(dest_data));
+ mbc1 = boost::asio::buffer(dest_data);
+ cbc1 = const_buffers_1(boost::asio::buffer(source_data));
+ n = buffer_copy(mbc1, cbc1);
+ BOOST_ASIO_CHECK(n == sizeof(source_data));
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ memset(dest_data, 0, sizeof(dest_data));
+ mb1 = boost::asio::buffer(dest_data);
+ std::vector<mutable_buffer> mv1;
+ mv1.push_back(boost::asio::buffer(source_data, 5));
+ mv1.push_back(boost::asio::buffer(source_data) + 5);
+ n = buffer_copy(mb1, mv1);
+ BOOST_ASIO_CHECK(n == sizeof(source_data));
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+
+ memset(dest_data, 0, sizeof(dest_data));
+ mb1 = boost::asio::buffer(dest_data);
+ std::vector<const_buffer> cv1;
+ cv1.push_back(boost::asio::buffer(source_data, 6));
+ cv1.push_back(boost::asio::buffer(source_data) + 6);
+ n = buffer_copy(mb1, cv1);
+ BOOST_ASIO_CHECK(n == sizeof(source_data));
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+
+ memset(dest_data, 0, sizeof(dest_data));
+ mv1.clear();
+ mv1.push_back(boost::asio::buffer(dest_data, 7));
+ mv1.push_back(boost::asio::buffer(dest_data) + 7);
+ cb1 = boost::asio::buffer(source_data);
+ n = buffer_copy(mv1, cb1);
+ BOOST_ASIO_CHECK(n == sizeof(source_data));
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+
+ memset(dest_data, 0, sizeof(dest_data));
+ mv1.clear();
+ mv1.push_back(boost::asio::buffer(dest_data, 7));
+ mv1.push_back(boost::asio::buffer(dest_data) + 7);
+ cv1.clear();
+ cv1.push_back(boost::asio::buffer(source_data, 8));
+ cv1.push_back(boost::asio::buffer(source_data) + 8);
+ n = buffer_copy(mv1, cv1);
+ BOOST_ASIO_CHECK(n == sizeof(source_data));
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+
+ memset(dest_data, 0, sizeof(dest_data));
+ mb1 = boost::asio::buffer(dest_data);
+ mb2 = boost::asio::buffer(source_data);
+ n = buffer_copy(mb1, mb2, 10);
+ BOOST_ASIO_CHECK(n == 10);
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+
+ memset(dest_data, 0, sizeof(dest_data));
+ mb1 = boost::asio::buffer(dest_data);
+ cb1 = boost::asio::buffer(source_data);
+ n = buffer_copy(mb1, cb1, 10);
+ BOOST_ASIO_CHECK(n == 10);
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ memset(dest_data, 0, sizeof(dest_data));
+ mb1 = boost::asio::buffer(dest_data);
+ mbc1 = boost::asio::buffer(source_data);
+ n = buffer_copy(mb1, mbc1, 10);
+ BOOST_ASIO_CHECK(n == 10);
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+
+ memset(dest_data, 0, sizeof(dest_data));
+ mb1 = boost::asio::buffer(dest_data);
+ cbc1 = const_buffers_1(boost::asio::buffer(source_data));
+ n = buffer_copy(mb1, cbc1, 10);
+ BOOST_ASIO_CHECK(n == 10);
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+
+ memset(dest_data, 0, sizeof(dest_data));
+ mbc1 = boost::asio::buffer(dest_data);
+ mb1 = boost::asio::buffer(source_data);
+ n = buffer_copy(mbc1, mb1, 10);
+ BOOST_ASIO_CHECK(n == 10);
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+
+ memset(dest_data, 0, sizeof(dest_data));
+ mbc1 = boost::asio::buffer(dest_data);
+ cb1 = boost::asio::buffer(source_data);
+ n = buffer_copy(mbc1, cb1, 10);
+ BOOST_ASIO_CHECK(n == 10);
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+
+ memset(dest_data, 0, sizeof(dest_data));
+ mbc1 = boost::asio::buffer(dest_data);
+ mbc2 = boost::asio::buffer(source_data);
+ n = buffer_copy(mbc1, mbc2, 10);
+ BOOST_ASIO_CHECK(n == 10);
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+
+ memset(dest_data, 0, sizeof(dest_data));
+ mbc1 = boost::asio::buffer(dest_data);
+ cbc1 = const_buffers_1(boost::asio::buffer(source_data));
+ n = buffer_copy(mbc1, cbc1, 10);
+ BOOST_ASIO_CHECK(n == 10);
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ memset(dest_data, 0, sizeof(dest_data));
+ mb1 = boost::asio::buffer(dest_data);
+ mv1.clear();
+ mv1.push_back(boost::asio::buffer(source_data, 5));
+ mv1.push_back(boost::asio::buffer(source_data) + 5);
+ n = buffer_copy(mb1, mv1, 10);
+ BOOST_ASIO_CHECK(n == 10);
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+
+ memset(dest_data, 0, sizeof(dest_data));
+ mb1 = boost::asio::buffer(dest_data);
+ cv1.clear();
+ cv1.push_back(boost::asio::buffer(source_data, 6));
+ cv1.push_back(boost::asio::buffer(source_data) + 6);
+ n = buffer_copy(mb1, cv1, 10);
+ BOOST_ASIO_CHECK(n == 10);
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+
+ memset(dest_data, 0, sizeof(dest_data));
+ mv1.clear();
+ mv1.push_back(boost::asio::buffer(dest_data, 7));
+ mv1.push_back(boost::asio::buffer(dest_data) + 7);
+ cb1 = boost::asio::buffer(source_data);
+ n = buffer_copy(mv1, cb1, 10);
+ BOOST_ASIO_CHECK(n == 10);
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+
+ memset(dest_data, 0, sizeof(dest_data));
+ mv1.clear();
+ mv1.push_back(boost::asio::buffer(dest_data, 7));
+ mv1.push_back(boost::asio::buffer(dest_data) + 7);
+ cv1.clear();
+ cv1.push_back(boost::asio::buffer(source_data, 8));
+ cv1.push_back(boost::asio::buffer(source_data) + 8);
+ n = buffer_copy(mv1, cv1, 10);
+ BOOST_ASIO_CHECK(n == 10);
+ BOOST_ASIO_CHECK(memcmp(dest_data, source_data, n) == 0);
+}
+
+} // namespace buffer_copy_runtime
+
+//------------------------------------------------------------------------------
+
+namespace buffer_sequence {
+
+using namespace boost::asio;
+using namespace std;
+
+struct valid_const_a
+{
+ typedef const_buffer* const_iterator;
+ typedef const_buffer value_type;
+ const_buffer* begin() const { return 0; }
+ const_buffer* end() const { return 0; }
+};
+
+#if defined(BOOST_ASIO_HAS_DECLTYPE)
+struct valid_const_b
+{
+ const_buffer* begin() const { return 0; }
+ const_buffer* end() const { return 0; }
+};
+#endif // defined(BOOST_ASIO_HAS_DECLTYPE)
+
+struct valid_mutable_a
+{
+ typedef mutable_buffer* const_iterator;
+ typedef mutable_buffer value_type;
+ mutable_buffer* begin() const { return 0; }
+ mutable_buffer* end() const { return 0; }
+};
+
+#if defined(BOOST_ASIO_HAS_DECLTYPE)
+struct valid_mutable_b
+{
+ mutable_buffer* begin() const { return 0; }
+ mutable_buffer* end() const { return 0; }
+};
+#endif // defined(BOOST_ASIO_HAS_DECLTYPE)
+
+struct invalid_const_a
+{
+ typedef int value_type;
+ int* begin() const { return 0; }
+ const_buffer* end() const { return 0; }
+};
+
+struct invalid_const_b
+{
+ typedef const_buffer value_type;
+ const_buffer* begin() const { return 0; }
+};
+
+struct invalid_const_c
+{
+ typedef const_buffer value_type;
+ const_buffer* end() const { return 0; }
+};
+
+#if defined(BOOST_ASIO_HAS_DECLTYPE)
+struct invalid_const_d
+{
+ int* begin() const { return 0; }
+ const_buffer* end() const { return 0; }
+};
+
+struct invalid_const_e
+{
+ const_buffer* begin() const { return 0; }
+};
+
+struct invalid_const_f
+{
+ const_buffer* end() const { return 0; }
+};
+#endif // defined(BOOST_ASIO_HAS_DECLTYPE)
+
+struct invalid_mutable_a
+{
+ typedef int value_type;
+ int* begin() const { return 0; }
+ mutable_buffer* end() const { return 0; }
+};
+
+struct invalid_mutable_b
+{
+ typedef mutable_buffer value_type;
+ mutable_buffer* begin() const { return 0; }
+};
+
+struct invalid_mutable_c
+{
+ typedef mutable_buffer value_type;
+ mutable_buffer* end() const { return 0; }
+};
+
+#if defined(BOOST_ASIO_HAS_DECLTYPE)
+struct invalid_mutable_d
+{
+ int* begin() const { return 0; }
+ mutable_buffer* end() const { return 0; }
+};
+
+struct invalid_mutable_e
+{
+ mutable_buffer* begin() const { return 0; }
+};
+
+struct invalid_mutable_f
+{
+ mutable_buffer* end() const { return 0; }
+};
+#endif // defined(BOOST_ASIO_HAS_DECLTYPE)
+
+void test()
+{
+ BOOST_ASIO_CHECK(is_const_buffer_sequence<const_buffer>::value);
+ BOOST_ASIO_CHECK(!is_mutable_buffer_sequence<const_buffer>::value);
+
+ const_buffer b1;
+ BOOST_ASIO_CHECK(buffer_sequence_begin(b1) == &b1);
+ BOOST_ASIO_CHECK(buffer_sequence_end(b1) == &b1 + 1);
+
+ BOOST_ASIO_CHECK(is_const_buffer_sequence<mutable_buffer>::value);
+ BOOST_ASIO_CHECK(is_mutable_buffer_sequence<mutable_buffer>::value);
+
+ mutable_buffer b2;
+ BOOST_ASIO_CHECK(buffer_sequence_begin(b2) == &b2);
+ BOOST_ASIO_CHECK(buffer_sequence_end(b2) == &b2 + 1);
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ BOOST_ASIO_CHECK(is_const_buffer_sequence<const_buffers_1>::value);
+ BOOST_ASIO_CHECK(!is_mutable_buffer_sequence<const_buffers_1>::value);
+
+ const_buffers_1 b3(0, 0);
+ BOOST_ASIO_CHECK(buffer_sequence_begin(b3) == &b3);
+ BOOST_ASIO_CHECK(buffer_sequence_end(b3) == &b3 + 1);
+
+ BOOST_ASIO_CHECK(is_const_buffer_sequence<mutable_buffers_1>::value);
+ BOOST_ASIO_CHECK(is_mutable_buffer_sequence<mutable_buffers_1>::value);
+
+ mutable_buffers_1 b4(0, 0);
+ BOOST_ASIO_CHECK(buffer_sequence_begin(b4) == &b4);
+ BOOST_ASIO_CHECK(buffer_sequence_end(b4) == &b4 + 1);
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ BOOST_ASIO_CHECK(is_const_buffer_sequence<vector<const_buffer> >::value);
+ BOOST_ASIO_CHECK(!is_mutable_buffer_sequence<vector<const_buffer> >::value);
+
+ vector<const_buffer> b5;
+ BOOST_ASIO_CHECK(buffer_sequence_begin(b5) == b5.begin());
+ BOOST_ASIO_CHECK(buffer_sequence_end(b5) == b5.end());
+
+ BOOST_ASIO_CHECK(is_const_buffer_sequence<vector<mutable_buffer> >::value);
+ BOOST_ASIO_CHECK(is_mutable_buffer_sequence<vector<mutable_buffer> >::value);
+
+ vector<mutable_buffer> b6;
+ BOOST_ASIO_CHECK(buffer_sequence_begin(b6) == b6.begin());
+ BOOST_ASIO_CHECK(buffer_sequence_end(b6) == b6.end());
+
+ BOOST_ASIO_CHECK(is_const_buffer_sequence<valid_const_a>::value);
+ BOOST_ASIO_CHECK(!is_mutable_buffer_sequence<valid_const_a>::value);
+
+ valid_const_a b7;
+ BOOST_ASIO_CHECK(buffer_sequence_begin(b7) == b7.begin());
+ BOOST_ASIO_CHECK(buffer_sequence_end(b7) == b7.end());
+
+#if defined(BOOST_ASIO_HAS_DECLTYPE)
+ BOOST_ASIO_CHECK(is_const_buffer_sequence<valid_const_b>::value);
+ BOOST_ASIO_CHECK(!is_mutable_buffer_sequence<valid_const_b>::value);
+
+ valid_const_b b8;
+ BOOST_ASIO_CHECK(buffer_sequence_begin(b8) == b8.begin());
+ BOOST_ASIO_CHECK(buffer_sequence_end(b8) == b8.end());
+#endif // defined(BOOST_ASIO_HAS_DECLTYPE)
+
+ BOOST_ASIO_CHECK(is_const_buffer_sequence<valid_mutable_a>::value);
+ BOOST_ASIO_CHECK(is_mutable_buffer_sequence<valid_mutable_a>::value);
+
+ valid_mutable_a b9;
+ BOOST_ASIO_CHECK(buffer_sequence_begin(b9) == b9.begin());
+ BOOST_ASIO_CHECK(buffer_sequence_end(b9) == b9.end());
+
+#if defined(BOOST_ASIO_HAS_DECLTYPE)
+ BOOST_ASIO_CHECK(is_const_buffer_sequence<valid_mutable_b>::value);
+ BOOST_ASIO_CHECK(is_mutable_buffer_sequence<valid_mutable_b>::value);
+
+ valid_mutable_b b10;
+ BOOST_ASIO_CHECK(buffer_sequence_begin(b10) == b10.begin());
+ BOOST_ASIO_CHECK(buffer_sequence_end(b10) == b10.end());
+#endif // defined(BOOST_ASIO_HAS_DECLTYPE)
+
+ BOOST_ASIO_CHECK(!is_const_buffer_sequence<invalid_const_a>::value);
+ BOOST_ASIO_CHECK(!is_mutable_buffer_sequence<invalid_const_a>::value);
+
+ BOOST_ASIO_CHECK(!is_const_buffer_sequence<invalid_const_b>::value);
+ BOOST_ASIO_CHECK(!is_mutable_buffer_sequence<invalid_const_b>::value);
+
+ BOOST_ASIO_CHECK(!is_const_buffer_sequence<invalid_const_c>::value);
+ BOOST_ASIO_CHECK(!is_mutable_buffer_sequence<invalid_const_c>::value);
+
+#if defined(BOOST_ASIO_HAS_DECLTYPE)
+ BOOST_ASIO_CHECK(!is_const_buffer_sequence<invalid_const_d>::value);
+ BOOST_ASIO_CHECK(!is_mutable_buffer_sequence<invalid_const_d>::value);
+
+ BOOST_ASIO_CHECK(!is_const_buffer_sequence<invalid_const_e>::value);
+ BOOST_ASIO_CHECK(!is_mutable_buffer_sequence<invalid_const_e>::value);
+
+ BOOST_ASIO_CHECK(!is_const_buffer_sequence<invalid_const_f>::value);
+ BOOST_ASIO_CHECK(!is_mutable_buffer_sequence<invalid_const_f>::value);
+#endif // defined(BOOST_ASIO_HAS_DECLTYPE)
+
+ BOOST_ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_a>::value);
+ BOOST_ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_a>::value);
+
+ BOOST_ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_b>::value);
+ BOOST_ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_b>::value);
+
+ BOOST_ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_c>::value);
+ BOOST_ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_c>::value);
+
+#if defined(BOOST_ASIO_HAS_DECLTYPE)
+ BOOST_ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_d>::value);
+ BOOST_ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_d>::value);
+
+ BOOST_ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_e>::value);
+ BOOST_ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_e>::value);
+
+ BOOST_ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_f>::value);
+ BOOST_ASIO_CHECK(!is_mutable_buffer_sequence<invalid_mutable_f>::value);
+#endif // defined(BOOST_ASIO_HAS_DECLTYPE)
+}
+
+} // namespace buffer_sequence
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "buffer",
+ BOOST_ASIO_COMPILE_TEST_CASE(buffer_compile::test)
+ BOOST_ASIO_TEST_CASE(buffer_copy_runtime::test)
+ BOOST_ASIO_TEST_CASE(buffer_sequence::test)
+)
diff --git a/src/boost/libs/asio/test/buffered_read_stream.cpp b/src/boost/libs/asio/test/buffered_read_stream.cpp
new file mode 100644
index 000000000..0228e8caf
--- /dev/null
+++ b/src/boost/libs/asio/test/buffered_read_stream.cpp
@@ -0,0 +1,338 @@
+//
+// buffered_read_stream.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/buffered_read_stream.hpp>
+
+#include <cstring>
+#include "archetypes/async_result.hpp"
+#include <boost/asio/buffer.hpp>
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/ip/tcp.hpp>
+#include <boost/system/system_error.hpp>
+#include "unit_test.hpp"
+
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+# include <boost/array.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+# include <array>
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <boost/bind/bind.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <functional>
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+
+typedef boost::asio::buffered_read_stream<
+ boost::asio::ip::tcp::socket> stream_type;
+
+void write_some_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void fill_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void read_some_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void test_compile()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+ using boost::array;
+#else // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+ using std::array;
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+
+ using namespace boost::asio;
+
+ try
+ {
+ io_context ioc;
+ char mutable_char_buffer[128] = "";
+ const char const_char_buffer[128] = "";
+ array<boost::asio::mutable_buffer, 2> mutable_buffers = {{
+ boost::asio::buffer(mutable_char_buffer, 10),
+ boost::asio::buffer(mutable_char_buffer + 10, 10) }};
+ array<boost::asio::const_buffer, 2> const_buffers = {{
+ boost::asio::buffer(const_char_buffer, 10),
+ boost::asio::buffer(const_char_buffer + 10, 10) }};
+ archetypes::lazy_handler lazy;
+ boost::system::error_code ec;
+
+ stream_type stream1(ioc);
+ stream_type stream2(ioc, 1024);
+
+ stream_type::executor_type ex = stream1.get_executor();
+ (void)ex;
+
+ stream_type::lowest_layer_type& lowest_layer = stream1.lowest_layer();
+ (void)lowest_layer;
+
+ stream1.write_some(buffer(mutable_char_buffer));
+ stream1.write_some(buffer(const_char_buffer));
+ stream1.write_some(mutable_buffers);
+ stream1.write_some(const_buffers);
+ stream1.write_some(null_buffers());
+ stream1.write_some(buffer(mutable_char_buffer), ec);
+ stream1.write_some(buffer(const_char_buffer), ec);
+ stream1.write_some(mutable_buffers, ec);
+ stream1.write_some(const_buffers, ec);
+ stream1.write_some(null_buffers(), ec);
+
+ stream1.async_write_some(buffer(mutable_char_buffer), &write_some_handler);
+ stream1.async_write_some(buffer(const_char_buffer), &write_some_handler);
+ stream1.async_write_some(mutable_buffers, &write_some_handler);
+ stream1.async_write_some(const_buffers, &write_some_handler);
+ stream1.async_write_some(null_buffers(), &write_some_handler);
+ int i1 = stream1.async_write_some(buffer(mutable_char_buffer), lazy);
+ (void)i1;
+ int i2 = stream1.async_write_some(buffer(const_char_buffer), lazy);
+ (void)i2;
+ int i3 = stream1.async_write_some(mutable_buffers, lazy);
+ (void)i3;
+ int i4 = stream1.async_write_some(const_buffers, lazy);
+ (void)i4;
+ int i5 = stream1.async_write_some(null_buffers(), lazy);
+ (void)i5;
+
+ stream1.fill();
+ stream1.fill(ec);
+
+ stream1.async_fill(&fill_handler);
+ int i6 = stream1.async_fill(lazy);
+ (void)i6;
+
+ stream1.read_some(buffer(mutable_char_buffer));
+ stream1.read_some(mutable_buffers);
+ stream1.read_some(null_buffers());
+ stream1.read_some(buffer(mutable_char_buffer), ec);
+ stream1.read_some(mutable_buffers, ec);
+ stream1.read_some(null_buffers(), ec);
+
+ stream1.async_read_some(buffer(mutable_char_buffer), &read_some_handler);
+ stream1.async_read_some(mutable_buffers, &read_some_handler);
+ stream1.async_read_some(null_buffers(), &read_some_handler);
+ int i7 = stream1.async_read_some(buffer(mutable_char_buffer), lazy);
+ (void)i7;
+ int i8 = stream1.async_read_some(mutable_buffers, lazy);
+ (void)i8;
+ int i9 = stream1.async_read_some(null_buffers(), lazy);
+ (void)i9;
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+void test_sync_operations()
+{
+ using namespace std; // For memcmp.
+
+ boost::asio::io_context io_context;
+
+ boost::asio::ip::tcp::acceptor acceptor(io_context,
+ boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 0));
+ boost::asio::ip::tcp::endpoint server_endpoint = acceptor.local_endpoint();
+ server_endpoint.address(boost::asio::ip::address_v4::loopback());
+
+ stream_type client_socket(io_context);
+ client_socket.lowest_layer().connect(server_endpoint);
+
+ stream_type server_socket(io_context);
+ acceptor.accept(server_socket.lowest_layer());
+
+ const char write_data[]
+ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ const boost::asio::const_buffer write_buf = boost::asio::buffer(write_data);
+
+ std::size_t bytes_written = 0;
+ while (bytes_written < sizeof(write_data))
+ {
+ bytes_written += client_socket.write_some(
+ boost::asio::buffer(write_buf + bytes_written));
+ }
+
+ char read_data[sizeof(write_data)];
+ const boost::asio::mutable_buffer read_buf = boost::asio::buffer(read_data);
+
+ std::size_t bytes_read = 0;
+ while (bytes_read < sizeof(read_data))
+ {
+ bytes_read += server_socket.read_some(
+ boost::asio::buffer(read_buf + bytes_read));
+ }
+
+ BOOST_ASIO_CHECK(bytes_written == sizeof(write_data));
+ BOOST_ASIO_CHECK(bytes_read == sizeof(read_data));
+ BOOST_ASIO_CHECK(memcmp(write_data, read_data, sizeof(write_data)) == 0);
+
+ bytes_written = 0;
+ while (bytes_written < sizeof(write_data))
+ {
+ bytes_written += server_socket.write_some(
+ boost::asio::buffer(write_buf + bytes_written));
+ }
+
+ bytes_read = 0;
+ while (bytes_read < sizeof(read_data))
+ {
+ bytes_read += client_socket.read_some(
+ boost::asio::buffer(read_buf + bytes_read));
+ }
+
+ BOOST_ASIO_CHECK(bytes_written == sizeof(write_data));
+ BOOST_ASIO_CHECK(bytes_read == sizeof(read_data));
+ BOOST_ASIO_CHECK(memcmp(write_data, read_data, sizeof(write_data)) == 0);
+
+ server_socket.close();
+ boost::system::error_code error;
+ bytes_read = client_socket.read_some(
+ boost::asio::buffer(read_buf), error);
+
+ BOOST_ASIO_CHECK(bytes_read == 0);
+ BOOST_ASIO_CHECK(error == boost::asio::error::eof);
+
+ client_socket.close(error);
+}
+
+void handle_accept(const boost::system::error_code& e)
+{
+ BOOST_ASIO_CHECK(!e);
+}
+
+void handle_write(const boost::system::error_code& e,
+ std::size_t bytes_transferred,
+ std::size_t* total_bytes_written)
+{
+ BOOST_ASIO_CHECK(!e);
+ if (e)
+ throw boost::system::system_error(e); // Terminate test.
+ *total_bytes_written += bytes_transferred;
+}
+
+void handle_read(const boost::system::error_code& e,
+ std::size_t bytes_transferred,
+ std::size_t* total_bytes_read)
+{
+ BOOST_ASIO_CHECK(!e);
+ if (e)
+ throw boost::system::system_error(e); // Terminate test.
+ *total_bytes_read += bytes_transferred;
+}
+
+void handle_read_eof(const boost::system::error_code& e,
+ std::size_t bytes_transferred)
+{
+ BOOST_ASIO_CHECK(e == boost::asio::error::eof);
+ BOOST_ASIO_CHECK(bytes_transferred == 0);
+}
+
+void test_async_operations()
+{
+ using namespace std; // For memcmp.
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context io_context;
+
+ boost::asio::ip::tcp::acceptor acceptor(io_context,
+ boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 0));
+ boost::asio::ip::tcp::endpoint server_endpoint = acceptor.local_endpoint();
+ server_endpoint.address(boost::asio::ip::address_v4::loopback());
+
+ stream_type client_socket(io_context);
+ client_socket.lowest_layer().connect(server_endpoint);
+
+ stream_type server_socket(io_context);
+ acceptor.async_accept(server_socket.lowest_layer(), &handle_accept);
+ io_context.run();
+ io_context.restart();
+
+ const char write_data[]
+ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ const boost::asio::const_buffer write_buf = boost::asio::buffer(write_data);
+
+ std::size_t bytes_written = 0;
+ while (bytes_written < sizeof(write_data))
+ {
+ client_socket.async_write_some(
+ boost::asio::buffer(write_buf + bytes_written),
+ bindns::bind(handle_write, _1, _2, &bytes_written));
+ io_context.run();
+ io_context.restart();
+ }
+
+ char read_data[sizeof(write_data)];
+ const boost::asio::mutable_buffer read_buf = boost::asio::buffer(read_data);
+
+ std::size_t bytes_read = 0;
+ while (bytes_read < sizeof(read_data))
+ {
+ server_socket.async_read_some(
+ boost::asio::buffer(read_buf + bytes_read),
+ bindns::bind(handle_read, _1, _2, &bytes_read));
+ io_context.run();
+ io_context.restart();
+ }
+
+ BOOST_ASIO_CHECK(bytes_written == sizeof(write_data));
+ BOOST_ASIO_CHECK(bytes_read == sizeof(read_data));
+ BOOST_ASIO_CHECK(memcmp(write_data, read_data, sizeof(write_data)) == 0);
+
+ bytes_written = 0;
+ while (bytes_written < sizeof(write_data))
+ {
+ server_socket.async_write_some(
+ boost::asio::buffer(write_buf + bytes_written),
+ bindns::bind(handle_write, _1, _2, &bytes_written));
+ io_context.run();
+ io_context.restart();
+ }
+
+ bytes_read = 0;
+ while (bytes_read < sizeof(read_data))
+ {
+ client_socket.async_read_some(
+ boost::asio::buffer(read_buf + bytes_read),
+ bindns::bind(handle_read, _1, _2, &bytes_read));
+ io_context.run();
+ io_context.restart();
+ }
+
+ BOOST_ASIO_CHECK(bytes_written == sizeof(write_data));
+ BOOST_ASIO_CHECK(bytes_read == sizeof(read_data));
+ BOOST_ASIO_CHECK(memcmp(write_data, read_data, sizeof(write_data)) == 0);
+
+ server_socket.close();
+ client_socket.async_read_some(boost::asio::buffer(read_buf), handle_read_eof);
+}
+
+BOOST_ASIO_TEST_SUITE
+(
+ "buffered_read_stream",
+ BOOST_ASIO_TEST_CASE(test_compile)
+ BOOST_ASIO_TEST_CASE(test_sync_operations)
+ BOOST_ASIO_TEST_CASE(test_async_operations)
+)
diff --git a/src/boost/libs/asio/test/buffered_stream.cpp b/src/boost/libs/asio/test/buffered_stream.cpp
new file mode 100644
index 000000000..155c0bc5b
--- /dev/null
+++ b/src/boost/libs/asio/test/buffered_stream.cpp
@@ -0,0 +1,364 @@
+//
+// buffered_stream.cpp
+// ~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/buffered_stream.hpp>
+
+#include <cstring>
+#include "archetypes/async_result.hpp"
+#include <boost/asio/buffer.hpp>
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/ip/tcp.hpp>
+#include <boost/system/system_error.hpp>
+#include "unit_test.hpp"
+
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+# include <boost/array.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+# include <array>
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <boost/bind/bind.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <functional>
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+
+typedef boost::asio::buffered_stream<
+ boost::asio::ip::tcp::socket> stream_type;
+
+void write_some_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void flush_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void fill_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void read_some_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void test_compile()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+ using boost::array;
+#else // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+ using std::array;
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+
+ using namespace boost::asio;
+
+ try
+ {
+ io_context ioc;
+ char mutable_char_buffer[128] = "";
+ const char const_char_buffer[128] = "";
+ array<boost::asio::mutable_buffer, 2> mutable_buffers = {{
+ boost::asio::buffer(mutable_char_buffer, 10),
+ boost::asio::buffer(mutable_char_buffer + 10, 10) }};
+ array<boost::asio::const_buffer, 2> const_buffers = {{
+ boost::asio::buffer(const_char_buffer, 10),
+ boost::asio::buffer(const_char_buffer + 10, 10) }};
+ archetypes::lazy_handler lazy;
+ boost::system::error_code ec;
+
+ stream_type stream1(ioc);
+ stream_type stream2(ioc, 1024, 1024);
+
+ stream_type::executor_type ex = stream1.get_executor();
+ (void)ex;
+
+ stream_type::lowest_layer_type& lowest_layer = stream1.lowest_layer();
+ (void)lowest_layer;
+
+ stream1.write_some(buffer(mutable_char_buffer));
+ stream1.write_some(buffer(const_char_buffer));
+ stream1.write_some(mutable_buffers);
+ stream1.write_some(const_buffers);
+ stream1.write_some(null_buffers());
+ stream1.write_some(buffer(mutable_char_buffer), ec);
+ stream1.write_some(buffer(const_char_buffer), ec);
+ stream1.write_some(mutable_buffers, ec);
+ stream1.write_some(const_buffers, ec);
+ stream1.write_some(null_buffers(), ec);
+
+ stream1.async_write_some(buffer(mutable_char_buffer), &write_some_handler);
+ stream1.async_write_some(buffer(const_char_buffer), &write_some_handler);
+ stream1.async_write_some(mutable_buffers, &write_some_handler);
+ stream1.async_write_some(const_buffers, &write_some_handler);
+ stream1.async_write_some(null_buffers(), &write_some_handler);
+ int i1 = stream1.async_write_some(buffer(mutable_char_buffer), lazy);
+ (void)i1;
+ int i2 = stream1.async_write_some(buffer(const_char_buffer), lazy);
+ (void)i2;
+ int i3 = stream1.async_write_some(mutable_buffers, lazy);
+ (void)i3;
+ int i4 = stream1.async_write_some(const_buffers, lazy);
+ (void)i4;
+ int i5 = stream1.async_write_some(null_buffers(), lazy);
+ (void)i5;
+
+ stream1.flush();
+ stream1.flush(ec);
+
+ stream1.async_flush(&flush_handler);
+ int i6 = stream1.async_flush(lazy);
+ (void)i6;
+
+ stream1.fill();
+ stream1.fill(ec);
+
+ stream1.async_fill(&fill_handler);
+ int i7 = stream1.async_fill(lazy);
+ (void)i7;
+
+ stream1.read_some(buffer(mutable_char_buffer));
+ stream1.read_some(mutable_buffers);
+ stream1.read_some(null_buffers());
+ stream1.read_some(buffer(mutable_char_buffer), ec);
+ stream1.read_some(mutable_buffers, ec);
+ stream1.read_some(null_buffers(), ec);
+
+ stream1.async_read_some(buffer(mutable_char_buffer), &read_some_handler);
+ stream1.async_read_some(mutable_buffers, &read_some_handler);
+ stream1.async_read_some(null_buffers(), &read_some_handler);
+ int i8 = stream1.async_read_some(buffer(mutable_char_buffer), lazy);
+ (void)i8;
+ int i9 = stream1.async_read_some(mutable_buffers, lazy);
+ (void)i9;
+ int i10 = stream1.async_read_some(null_buffers(), lazy);
+ (void)i10;
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+void test_sync_operations()
+{
+ using namespace std; // For memcmp.
+
+ boost::asio::io_context io_context;
+
+ boost::asio::ip::tcp::acceptor acceptor(io_context,
+ boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 0));
+ boost::asio::ip::tcp::endpoint server_endpoint = acceptor.local_endpoint();
+ server_endpoint.address(boost::asio::ip::address_v4::loopback());
+
+ stream_type client_socket(io_context);
+ client_socket.lowest_layer().connect(server_endpoint);
+
+ stream_type server_socket(io_context);
+ acceptor.accept(server_socket.lowest_layer());
+
+ const char write_data[]
+ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ const boost::asio::const_buffer write_buf = boost::asio::buffer(write_data);
+
+ std::size_t bytes_written = 0;
+ while (bytes_written < sizeof(write_data))
+ {
+ bytes_written += client_socket.write_some(
+ boost::asio::buffer(write_buf + bytes_written));
+ client_socket.flush();
+ }
+
+ char read_data[sizeof(write_data)];
+ const boost::asio::mutable_buffer read_buf = boost::asio::buffer(read_data);
+
+ std::size_t bytes_read = 0;
+ while (bytes_read < sizeof(read_data))
+ {
+ bytes_read += server_socket.read_some(
+ boost::asio::buffer(read_buf + bytes_read));
+ }
+
+ BOOST_ASIO_CHECK(bytes_written == sizeof(write_data));
+ BOOST_ASIO_CHECK(bytes_read == sizeof(read_data));
+ BOOST_ASIO_CHECK(memcmp(write_data, read_data, sizeof(write_data)) == 0);
+
+ bytes_written = 0;
+ while (bytes_written < sizeof(write_data))
+ {
+ bytes_written += server_socket.write_some(
+ boost::asio::buffer(write_buf + bytes_written));
+ server_socket.flush();
+ }
+
+ bytes_read = 0;
+ while (bytes_read < sizeof(read_data))
+ {
+ bytes_read += client_socket.read_some(
+ boost::asio::buffer(read_buf + bytes_read));
+ }
+
+ BOOST_ASIO_CHECK(bytes_written == sizeof(write_data));
+ BOOST_ASIO_CHECK(bytes_read == sizeof(read_data));
+ BOOST_ASIO_CHECK(memcmp(write_data, read_data, sizeof(write_data)) == 0);
+
+ server_socket.close();
+ boost::system::error_code error;
+ bytes_read = client_socket.read_some(
+ boost::asio::buffer(read_buf), error);
+
+ BOOST_ASIO_CHECK(bytes_read == 0);
+ BOOST_ASIO_CHECK(error == boost::asio::error::eof);
+
+ client_socket.close(error);
+}
+
+void handle_accept(const boost::system::error_code& e)
+{
+ BOOST_ASIO_CHECK(!e);
+}
+
+void handle_write(const boost::system::error_code& e,
+ std::size_t bytes_transferred,
+ std::size_t* total_bytes_written)
+{
+ BOOST_ASIO_CHECK(!e);
+ if (e)
+ throw boost::system::system_error(e); // Terminate test.
+ *total_bytes_written += bytes_transferred;
+}
+
+void handle_flush(const boost::system::error_code& e)
+{
+ BOOST_ASIO_CHECK(!e);
+}
+
+void handle_read(const boost::system::error_code& e,
+ std::size_t bytes_transferred,
+ std::size_t* total_bytes_read)
+{
+ BOOST_ASIO_CHECK(!e);
+ if (e)
+ throw boost::system::system_error(e); // Terminate test.
+ *total_bytes_read += bytes_transferred;
+}
+
+void handle_read_eof(const boost::system::error_code& e,
+ std::size_t bytes_transferred)
+{
+ BOOST_ASIO_CHECK(e == boost::asio::error::eof);
+ BOOST_ASIO_CHECK(bytes_transferred == 0);
+}
+
+void test_async_operations()
+{
+ using namespace std; // For memcmp.
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context io_context;
+
+ boost::asio::ip::tcp::acceptor acceptor(io_context,
+ boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 0));
+ boost::asio::ip::tcp::endpoint server_endpoint = acceptor.local_endpoint();
+ server_endpoint.address(boost::asio::ip::address_v4::loopback());
+
+ stream_type client_socket(io_context);
+ client_socket.lowest_layer().connect(server_endpoint);
+
+ stream_type server_socket(io_context);
+ acceptor.async_accept(server_socket.lowest_layer(), &handle_accept);
+ io_context.run();
+ io_context.restart();
+
+ const char write_data[]
+ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ const boost::asio::const_buffer write_buf = boost::asio::buffer(write_data);
+
+ std::size_t bytes_written = 0;
+ while (bytes_written < sizeof(write_data))
+ {
+ client_socket.async_write_some(
+ boost::asio::buffer(write_buf + bytes_written),
+ bindns::bind(handle_write, _1, _2, &bytes_written));
+ io_context.run();
+ io_context.restart();
+ client_socket.async_flush(
+ bindns::bind(handle_flush, _1));
+ io_context.run();
+ io_context.restart();
+ }
+
+ char read_data[sizeof(write_data)];
+ const boost::asio::mutable_buffer read_buf = boost::asio::buffer(read_data);
+
+ std::size_t bytes_read = 0;
+ while (bytes_read < sizeof(read_data))
+ {
+ server_socket.async_read_some(
+ boost::asio::buffer(read_buf + bytes_read),
+ bindns::bind(handle_read, _1, _2, &bytes_read));
+ io_context.run();
+ io_context.restart();
+ }
+
+ BOOST_ASIO_CHECK(bytes_written == sizeof(write_data));
+ BOOST_ASIO_CHECK(bytes_read == sizeof(read_data));
+ BOOST_ASIO_CHECK(memcmp(write_data, read_data, sizeof(write_data)) == 0);
+
+ bytes_written = 0;
+ while (bytes_written < sizeof(write_data))
+ {
+ server_socket.async_write_some(
+ boost::asio::buffer(write_buf + bytes_written),
+ bindns::bind(handle_write, _1, _2, &bytes_written));
+ io_context.run();
+ io_context.restart();
+ server_socket.async_flush(
+ bindns::bind(handle_flush, _1));
+ io_context.run();
+ io_context.restart();
+ }
+
+ bytes_read = 0;
+ while (bytes_read < sizeof(read_data))
+ {
+ client_socket.async_read_some(
+ boost::asio::buffer(read_buf + bytes_read),
+ bindns::bind(handle_read, _1, _2, &bytes_read));
+ io_context.run();
+ io_context.restart();
+ }
+
+ BOOST_ASIO_CHECK(bytes_written == sizeof(write_data));
+ BOOST_ASIO_CHECK(bytes_read == sizeof(read_data));
+ BOOST_ASIO_CHECK(memcmp(write_data, read_data, sizeof(write_data)) == 0);
+
+ server_socket.close();
+ client_socket.async_read_some(boost::asio::buffer(read_buf), handle_read_eof);
+}
+
+BOOST_ASIO_TEST_SUITE
+(
+ "buffered_stream",
+ BOOST_ASIO_TEST_CASE(test_compile)
+ BOOST_ASIO_TEST_CASE(test_sync_operations)
+ BOOST_ASIO_TEST_CASE(test_async_operations)
+)
diff --git a/src/boost/libs/asio/test/buffered_write_stream.cpp b/src/boost/libs/asio/test/buffered_write_stream.cpp
new file mode 100644
index 000000000..98e50e43a
--- /dev/null
+++ b/src/boost/libs/asio/test/buffered_write_stream.cpp
@@ -0,0 +1,353 @@
+//
+// buffered_write_stream.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/buffered_write_stream.hpp>
+
+#include <cstring>
+#include "archetypes/async_result.hpp"
+#include <boost/asio/buffer.hpp>
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/ip/tcp.hpp>
+#include <boost/system/system_error.hpp>
+#include "unit_test.hpp"
+
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+# include <boost/array.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+# include <array>
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <boost/bind/bind.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <functional>
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+
+typedef boost::asio::buffered_write_stream<
+ boost::asio::ip::tcp::socket> stream_type;
+
+void write_some_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void flush_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void read_some_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void test_compile()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+ using boost::array;
+#else // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+ using std::array;
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+
+ using namespace boost::asio;
+
+ try
+ {
+ io_context ioc;
+ char mutable_char_buffer[128] = "";
+ const char const_char_buffer[128] = "";
+ array<boost::asio::mutable_buffer, 2> mutable_buffers = {{
+ boost::asio::buffer(mutable_char_buffer, 10),
+ boost::asio::buffer(mutable_char_buffer + 10, 10) }};
+ array<boost::asio::const_buffer, 2> const_buffers = {{
+ boost::asio::buffer(const_char_buffer, 10),
+ boost::asio::buffer(const_char_buffer + 10, 10) }};
+ archetypes::lazy_handler lazy;
+ boost::system::error_code ec;
+
+ stream_type stream1(ioc);
+ stream_type stream2(ioc, 1024);
+
+ stream_type::executor_type ex = stream1.get_executor();
+ (void)ex;
+
+ stream_type::lowest_layer_type& lowest_layer = stream1.lowest_layer();
+ (void)lowest_layer;
+
+ stream1.write_some(buffer(mutable_char_buffer));
+ stream1.write_some(buffer(const_char_buffer));
+ stream1.write_some(mutable_buffers);
+ stream1.write_some(const_buffers);
+ stream1.write_some(null_buffers());
+ stream1.write_some(buffer(mutable_char_buffer), ec);
+ stream1.write_some(buffer(const_char_buffer), ec);
+ stream1.write_some(mutable_buffers, ec);
+ stream1.write_some(const_buffers, ec);
+ stream1.write_some(null_buffers(), ec);
+
+ stream1.async_write_some(buffer(mutable_char_buffer), &write_some_handler);
+ stream1.async_write_some(buffer(const_char_buffer), &write_some_handler);
+ stream1.async_write_some(mutable_buffers, &write_some_handler);
+ stream1.async_write_some(const_buffers, &write_some_handler);
+ stream1.async_write_some(null_buffers(), &write_some_handler);
+ int i1 = stream1.async_write_some(buffer(mutable_char_buffer), lazy);
+ (void)i1;
+ int i2 = stream1.async_write_some(buffer(const_char_buffer), lazy);
+ (void)i2;
+ int i3 = stream1.async_write_some(mutable_buffers, lazy);
+ (void)i3;
+ int i4 = stream1.async_write_some(const_buffers, lazy);
+ (void)i4;
+ int i5 = stream1.async_write_some(null_buffers(), lazy);
+ (void)i5;
+
+ stream1.flush();
+ stream1.flush(ec);
+
+ stream1.async_flush(&flush_handler);
+ int i6 = stream1.async_flush(lazy);
+ (void)i6;
+
+ stream1.read_some(buffer(mutable_char_buffer));
+ stream1.read_some(mutable_buffers);
+ stream1.read_some(null_buffers());
+ stream1.read_some(buffer(mutable_char_buffer), ec);
+ stream1.read_some(mutable_buffers, ec);
+ stream1.read_some(null_buffers(), ec);
+
+ stream1.async_read_some(buffer(mutable_char_buffer), &read_some_handler);
+ stream1.async_read_some(mutable_buffers, &read_some_handler);
+ stream1.async_read_some(null_buffers(), &read_some_handler);
+ int i7 = stream1.async_read_some(buffer(mutable_char_buffer), lazy);
+ (void)i7;
+ int i8 = stream1.async_read_some(mutable_buffers, lazy);
+ (void)i8;
+ int i9 = stream1.async_read_some(null_buffers(), lazy);
+ (void)i9;
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+void test_sync_operations()
+{
+ using namespace std; // For memcmp.
+
+ boost::asio::io_context io_context;
+
+ boost::asio::ip::tcp::acceptor acceptor(io_context,
+ boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 0));
+ boost::asio::ip::tcp::endpoint server_endpoint = acceptor.local_endpoint();
+ server_endpoint.address(boost::asio::ip::address_v4::loopback());
+
+ stream_type client_socket(io_context);
+ client_socket.lowest_layer().connect(server_endpoint);
+
+ stream_type server_socket(io_context);
+ acceptor.accept(server_socket.lowest_layer());
+
+ const char write_data[]
+ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ const boost::asio::const_buffer write_buf = boost::asio::buffer(write_data);
+
+ std::size_t bytes_written = 0;
+ while (bytes_written < sizeof(write_data))
+ {
+ bytes_written += client_socket.write_some(
+ boost::asio::buffer(write_buf + bytes_written));
+ client_socket.flush();
+ }
+
+ char read_data[sizeof(write_data)];
+ const boost::asio::mutable_buffer read_buf = boost::asio::buffer(read_data);
+
+ std::size_t bytes_read = 0;
+ while (bytes_read < sizeof(read_data))
+ {
+ bytes_read += server_socket.read_some(
+ boost::asio::buffer(read_buf + bytes_read));
+ }
+
+ BOOST_ASIO_CHECK(bytes_written == sizeof(write_data));
+ BOOST_ASIO_CHECK(bytes_read == sizeof(read_data));
+ BOOST_ASIO_CHECK(memcmp(write_data, read_data, sizeof(write_data)) == 0);
+
+ bytes_written = 0;
+ while (bytes_written < sizeof(write_data))
+ {
+ bytes_written += server_socket.write_some(
+ boost::asio::buffer(write_buf + bytes_written));
+ server_socket.flush();
+ }
+
+ bytes_read = 0;
+ while (bytes_read < sizeof(read_data))
+ {
+ bytes_read += client_socket.read_some(
+ boost::asio::buffer(read_buf + bytes_read));
+ }
+
+ BOOST_ASIO_CHECK(bytes_written == sizeof(write_data));
+ BOOST_ASIO_CHECK(bytes_read == sizeof(read_data));
+ BOOST_ASIO_CHECK(memcmp(write_data, read_data, sizeof(write_data)) == 0);
+
+ server_socket.close();
+ boost::system::error_code error;
+ bytes_read = client_socket.read_some(
+ boost::asio::buffer(read_buf), error);
+
+ BOOST_ASIO_CHECK(bytes_read == 0);
+ BOOST_ASIO_CHECK(error == boost::asio::error::eof);
+
+ client_socket.close(error);
+}
+
+void handle_accept(const boost::system::error_code& e)
+{
+ BOOST_ASIO_CHECK(!e);
+}
+
+void handle_write(const boost::system::error_code& e,
+ std::size_t bytes_transferred,
+ std::size_t* total_bytes_written)
+{
+ BOOST_ASIO_CHECK(!e);
+ if (e)
+ throw boost::system::system_error(e); // Terminate test.
+ *total_bytes_written += bytes_transferred;
+}
+
+void handle_flush(const boost::system::error_code& e)
+{
+ BOOST_ASIO_CHECK(!e);
+}
+
+void handle_read(const boost::system::error_code& e,
+ std::size_t bytes_transferred,
+ std::size_t* total_bytes_read)
+{
+ BOOST_ASIO_CHECK(!e);
+ if (e)
+ throw boost::system::system_error(e); // Terminate test.
+ *total_bytes_read += bytes_transferred;
+}
+
+void handle_read_eof(const boost::system::error_code& e,
+ std::size_t bytes_transferred)
+{
+ BOOST_ASIO_CHECK(e == boost::asio::error::eof);
+ BOOST_ASIO_CHECK(bytes_transferred == 0);
+}
+
+void test_async_operations()
+{
+ using namespace std; // For memcmp.
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context io_context;
+
+ boost::asio::ip::tcp::acceptor acceptor(io_context,
+ boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 0));
+ boost::asio::ip::tcp::endpoint server_endpoint = acceptor.local_endpoint();
+ server_endpoint.address(boost::asio::ip::address_v4::loopback());
+
+ stream_type client_socket(io_context);
+ client_socket.lowest_layer().connect(server_endpoint);
+
+ stream_type server_socket(io_context);
+ acceptor.async_accept(server_socket.lowest_layer(), &handle_accept);
+ io_context.run();
+ io_context.restart();
+
+ const char write_data[]
+ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ const boost::asio::const_buffer write_buf = boost::asio::buffer(write_data);
+
+ std::size_t bytes_written = 0;
+ while (bytes_written < sizeof(write_data))
+ {
+ client_socket.async_write_some(
+ boost::asio::buffer(write_buf + bytes_written),
+ bindns::bind(handle_write, _1, _2, &bytes_written));
+ io_context.run();
+ io_context.restart();
+ client_socket.async_flush(
+ bindns::bind(handle_flush, _1));
+ io_context.run();
+ io_context.restart();
+ }
+
+ char read_data[sizeof(write_data)];
+ const boost::asio::mutable_buffer read_buf = boost::asio::buffer(read_data);
+
+ std::size_t bytes_read = 0;
+ while (bytes_read < sizeof(read_data))
+ {
+ server_socket.async_read_some(
+ boost::asio::buffer(read_buf + bytes_read),
+ bindns::bind(handle_read, _1, _2, &bytes_read));
+ io_context.run();
+ io_context.restart();
+ }
+
+ BOOST_ASIO_CHECK(bytes_written == sizeof(write_data));
+ BOOST_ASIO_CHECK(bytes_read == sizeof(read_data));
+ BOOST_ASIO_CHECK(memcmp(write_data, read_data, sizeof(write_data)) == 0);
+
+ bytes_written = 0;
+ while (bytes_written < sizeof(write_data))
+ {
+ server_socket.async_write_some(
+ boost::asio::buffer(write_buf + bytes_written),
+ bindns::bind(handle_write, _1, _2, &bytes_written));
+ io_context.run();
+ io_context.restart();
+ server_socket.async_flush(
+ bindns::bind(handle_flush, _1));
+ io_context.run();
+ io_context.restart();
+ }
+
+ bytes_read = 0;
+ while (bytes_read < sizeof(read_data))
+ {
+ client_socket.async_read_some(
+ boost::asio::buffer(read_buf + bytes_read),
+ bindns::bind(handle_read, _1, _2, &bytes_read));
+ io_context.run();
+ io_context.restart();
+ }
+
+ BOOST_ASIO_CHECK(bytes_written == sizeof(write_data));
+ BOOST_ASIO_CHECK(bytes_read == sizeof(read_data));
+ BOOST_ASIO_CHECK(memcmp(write_data, read_data, sizeof(write_data)) == 0);
+
+ server_socket.close();
+ client_socket.async_read_some(boost::asio::buffer(read_buf), handle_read_eof);
+}
+
+BOOST_ASIO_TEST_SUITE
+(
+ "buffered_write_stream",
+ BOOST_ASIO_TEST_CASE(test_compile)
+ BOOST_ASIO_TEST_CASE(test_sync_operations)
+ BOOST_ASIO_TEST_CASE(test_async_operations)
+)
diff --git a/src/boost/libs/asio/test/buffers_iterator.cpp b/src/boost/libs/asio/test/buffers_iterator.cpp
new file mode 100644
index 000000000..caedeae71
--- /dev/null
+++ b/src/boost/libs/asio/test/buffers_iterator.cpp
@@ -0,0 +1,292 @@
+//
+// buffers_iterator.cpp
+// ~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/buffers_iterator.hpp>
+
+#include <boost/asio/buffer.hpp>
+#include "unit_test.hpp"
+
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+# include <boost/array.hpp>
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+
+#if defined(BOOST_ASIO_HAS_STD_ARRAY)
+# include <array>
+#endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
+
+//------------------------------------------------------------------------------
+
+// buffers_iterator_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all operations on the buffers_iterator compile
+// and link correctly. Runtime failures are ignored.
+
+namespace buffers_iterator_compile {
+
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+using boost::array;
+#elif defined(BOOST_ASIO_HAS_STD_ARRAY)
+using std::array;
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+using std::vector;
+using namespace boost::asio;
+
+void test()
+{
+ try
+ {
+ char data1[16], data2[16];
+ const char cdata1[16] = "", cdata2[16] = "";
+ mutable_buffer mb1 = buffer(data1);
+ array<mutable_buffer, 2> mb2 = {{ buffer(data1), buffer(data2) }};
+ std::vector<mutable_buffer> mb3;
+ mb3.push_back(buffer(data1));
+ const_buffer cb1 = buffer(cdata1);
+ array<const_buffer, 2> cb2 = {{ buffer(cdata1), buffer(cdata2) }};
+ vector<const_buffer> cb3;
+ cb3.push_back(buffer(cdata1));
+
+
+ // buffers_iterator constructors.
+
+ buffers_iterator<mutable_buffer, char> bi1;
+ buffers_iterator<mutable_buffer, const char> bi2;
+ buffers_iterator<array<mutable_buffer, 2>, char> bi3;
+ buffers_iterator<array<mutable_buffer, 2>, const char> bi4;
+ buffers_iterator<vector<mutable_buffer>, char> bi5;
+ buffers_iterator<vector<mutable_buffer>, const char> bi6;
+ buffers_iterator<const_buffer, char> bi7;
+ buffers_iterator<const_buffer, const char> bi8;
+ buffers_iterator<array<const_buffer, 2>, char> bi9;
+ buffers_iterator<array<const_buffer, 2>, const char> bi10;
+ buffers_iterator<vector<const_buffer>, char> bi11;
+ buffers_iterator<vector<const_buffer>, const char> bi12;
+
+ buffers_iterator<mutable_buffer, char> bi13(
+ buffers_iterator<mutable_buffer, char>::begin(mb1));
+ buffers_iterator<mutable_buffer, const char> bi14(
+ buffers_iterator<mutable_buffer, const char>::begin(mb1));
+ buffers_iterator<array<mutable_buffer, 2>, char> bi15(
+ buffers_iterator<array<mutable_buffer, 2>, char>::begin(mb2));
+ buffers_iterator<array<mutable_buffer, 2>, const char> bi16(
+ buffers_iterator<array<mutable_buffer, 2>, const char>::begin(mb2));
+ buffers_iterator<vector<mutable_buffer>, char> bi17(
+ buffers_iterator<vector<mutable_buffer>, char>::begin(mb3));
+ buffers_iterator<vector<mutable_buffer>, const char> bi18(
+ buffers_iterator<vector<mutable_buffer>, const char>::begin(mb3));
+ buffers_iterator<const_buffer, char> bi19(
+ buffers_iterator<const_buffer, char>::begin(cb1));
+ buffers_iterator<const_buffer, const char> bi20(
+ buffers_iterator<const_buffer, const char>::begin(cb1));
+ buffers_iterator<array<const_buffer, 2>, char> bi21(
+ buffers_iterator<array<const_buffer, 2>, char>::begin(cb2));
+ buffers_iterator<array<const_buffer, 2>, const char> bi22(
+ buffers_iterator<array<const_buffer, 2>, const char>::begin(cb2));
+ buffers_iterator<vector<const_buffer>, char> bi23(
+ buffers_iterator<vector<const_buffer>, char>::begin(cb3));
+ buffers_iterator<vector<const_buffer>, const char> bi24(
+ buffers_iterator<vector<const_buffer>, const char>::begin(cb3));
+
+ // buffers_iterator member functions.
+
+ bi1 = buffers_iterator<mutable_buffer, char>::begin(mb1);
+ bi2 = buffers_iterator<mutable_buffer, const char>::begin(mb1);
+ bi3 = buffers_iterator<array<mutable_buffer, 2>, char>::begin(mb2);
+ bi4 = buffers_iterator<array<mutable_buffer, 2>, const char>::begin(mb2);
+ bi5 = buffers_iterator<vector<mutable_buffer>, char>::begin(mb3);
+ bi6 = buffers_iterator<vector<mutable_buffer>, const char>::begin(mb3);
+ bi7 = buffers_iterator<const_buffer, char>::begin(cb1);
+ bi8 = buffers_iterator<const_buffer, const char>::begin(cb1);
+ bi9 = buffers_iterator<array<const_buffer, 2>, char>::begin(cb2);
+ bi10 = buffers_iterator<array<const_buffer, 2>, const char>::begin(cb2);
+ bi11 = buffers_iterator<vector<const_buffer>, char>::begin(cb3);
+ bi12 = buffers_iterator<vector<const_buffer>, const char>::begin(cb3);
+
+ bi1 = buffers_iterator<mutable_buffer, char>::end(mb1);
+ bi2 = buffers_iterator<mutable_buffer, const char>::end(mb1);
+ bi3 = buffers_iterator<array<mutable_buffer, 2>, char>::end(mb2);
+ bi4 = buffers_iterator<array<mutable_buffer, 2>, const char>::end(mb2);
+ bi5 = buffers_iterator<vector<mutable_buffer>, char>::end(mb3);
+ bi6 = buffers_iterator<vector<mutable_buffer>, const char>::end(mb3);
+ bi7 = buffers_iterator<const_buffer, char>::end(cb1);
+ bi8 = buffers_iterator<const_buffer, const char>::end(cb1);
+ bi9 = buffers_iterator<array<const_buffer, 2>, char>::end(cb2);
+ bi10 = buffers_iterator<array<const_buffer, 2>, const char>::end(cb2);
+ bi11 = buffers_iterator<vector<const_buffer>, char>::end(cb3);
+ bi12 = buffers_iterator<vector<const_buffer>, const char>::end(cb3);
+
+ // buffers_iterator related functions.
+
+ bi1 = buffers_begin(mb1);
+ bi3 = buffers_begin(mb2);
+ bi5 = buffers_begin(mb3);
+ bi7 = buffers_begin(cb1);
+ bi9 = buffers_begin(cb2);
+ bi11 = buffers_begin(cb3);
+
+ bi1 = buffers_end(mb1);
+ bi3 = buffers_end(mb2);
+ bi5 = buffers_end(mb3);
+ bi7 = buffers_end(cb1);
+ bi9 = buffers_end(cb2);
+ bi11 = buffers_end(cb3);
+
+ // RandomAccessIterator operations.
+
+ --bi1;
+ --bi2;
+ --bi3;
+ --bi4;
+ --bi5;
+ --bi6;
+ --bi7;
+ --bi8;
+ --bi9;
+ --bi10;
+ --bi11;
+ --bi12;
+
+ ++bi1;
+ ++bi2;
+ ++bi3;
+ ++bi4;
+ ++bi5;
+ ++bi6;
+ ++bi7;
+ ++bi8;
+ ++bi9;
+ ++bi10;
+ ++bi11;
+ ++bi12;
+
+ bi1--;
+ bi2--;
+ bi3--;
+ bi4--;
+ bi5--;
+ bi6--;
+ bi7--;
+ bi8--;
+ bi9--;
+ bi10--;
+ bi11--;
+ bi12--;
+
+ bi1++;
+ bi2++;
+ bi3++;
+ bi4++;
+ bi5++;
+ bi6++;
+ bi7++;
+ bi8++;
+ bi9++;
+ bi10++;
+ bi11++;
+ bi12++;
+
+ bi1 -= 1;
+ bi2 -= 1;
+ bi3 -= 1;
+ bi4 -= 1;
+ bi5 -= 1;
+ bi6 -= 1;
+ bi7 -= 1;
+ bi8 -= 1;
+ bi9 -= 1;
+ bi10 -= 1;
+ bi11 -= 1;
+ bi12 -= 1;
+
+ bi1 += 1;
+ bi2 += 1;
+ bi3 += 1;
+ bi4 += 1;
+ bi5 += 1;
+ bi6 += 1;
+ bi7 += 1;
+ bi8 += 1;
+ bi9 += 1;
+ bi10 += 1;
+ bi11 += 1;
+ bi12 += 1;
+
+ bi1 = bi1 - 1;
+ bi2 = bi2 - 1;
+ bi3 = bi3 - 1;
+ bi4 = bi4 - 1;
+ bi5 = bi5 - 1;
+ bi6 = bi6 - 1;
+ bi7 = bi7 - 1;
+ bi8 = bi8 - 1;
+ bi9 = bi9 - 1;
+ bi10 = bi10 - 1;
+ bi11 = bi11 - 1;
+ bi12 = bi12 - 1;
+
+ bi1 = bi1 + 1;
+ bi2 = bi2 + 1;
+ bi3 = bi3 + 1;
+ bi4 = bi4 + 1;
+ bi5 = bi5 + 1;
+ bi6 = bi6 + 1;
+ bi7 = bi7 + 1;
+ bi8 = bi8 + 1;
+ bi9 = bi9 + 1;
+ bi10 = bi10 + 1;
+ bi11 = bi11 + 1;
+ bi12 = bi12 + 1;
+
+ bi1 = (-1) + bi1;
+ bi2 = (-1) + bi2;
+ bi3 = (-1) + bi3;
+ bi4 = (-1) + bi4;
+ bi5 = (-1) + bi5;
+ bi6 = (-1) + bi6;
+ bi7 = (-1) + bi7;
+ bi8 = (-1) + bi8;
+ bi9 = (-1) + bi9;
+ bi10 = (-1) + bi10;
+ bi11 = (-1) + bi11;
+ bi12 = (-1) + bi12;
+
+ (void)static_cast<std::ptrdiff_t>(bi13 - bi1);
+ (void)static_cast<std::ptrdiff_t>(bi14 - bi2);
+ (void)static_cast<std::ptrdiff_t>(bi15 - bi3);
+ (void)static_cast<std::ptrdiff_t>(bi16 - bi4);
+ (void)static_cast<std::ptrdiff_t>(bi17 - bi5);
+ (void)static_cast<std::ptrdiff_t>(bi18 - bi6);
+ (void)static_cast<std::ptrdiff_t>(bi19 - bi7);
+ (void)static_cast<std::ptrdiff_t>(bi20 - bi8);
+ (void)static_cast<std::ptrdiff_t>(bi21 - bi9);
+ (void)static_cast<std::ptrdiff_t>(bi22 - bi10);
+ (void)static_cast<std::ptrdiff_t>(bi23 - bi11);
+ (void)static_cast<std::ptrdiff_t>(bi24 - bi12);
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace buffers_iterator_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "buffers_iterator",
+ BOOST_ASIO_TEST_CASE(buffers_iterator_compile::test)
+)
diff --git a/src/boost/libs/asio/test/co_spawn.cpp b/src/boost/libs/asio/test/co_spawn.cpp
new file mode 100644
index 000000000..da88ceb55
--- /dev/null
+++ b/src/boost/libs/asio/test/co_spawn.cpp
@@ -0,0 +1,25 @@
+//
+// co_spawn.cpp
+// ~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/co_spawn.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "co_spawn",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/completion_condition.cpp b/src/boost/libs/asio/test/completion_condition.cpp
new file mode 100644
index 000000000..4f5971bca
--- /dev/null
+++ b/src/boost/libs/asio/test/completion_condition.cpp
@@ -0,0 +1,25 @@
+//
+// completion_condition.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/completion_condition.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "completion_condition",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/compose.cpp b/src/boost/libs/asio/test/compose.cpp
new file mode 100644
index 000000000..3255ef824
--- /dev/null
+++ b/src/boost/libs/asio/test/compose.cpp
@@ -0,0 +1,185 @@
+//
+// compose.cpp
+// ~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/compose.hpp>
+
+#include "unit_test.hpp"
+
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/post.hpp>
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <boost/bind/bind.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <functional>
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+
+//------------------------------------------------------------------------------
+
+class impl_0_completion_args
+{
+public:
+ explicit impl_0_completion_args(boost::asio::io_context& ioc)
+ : ioc_(ioc),
+ state_(starting)
+ {
+ }
+
+ template <typename Self>
+ void operator()(Self& self)
+ {
+ switch (state_)
+ {
+ case starting:
+ state_ = posting;
+ boost::asio::post(ioc_, BOOST_ASIO_MOVE_CAST(Self)(self));
+ break;
+ case posting:
+ self.complete();
+ break;
+ default:
+ break;
+ }
+ }
+
+private:
+ boost::asio::io_context& ioc_;
+ enum { starting, posting } state_;
+};
+
+template <typename CompletionToken>
+BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void())
+async_0_completion_args(boost::asio::io_context& ioc,
+ BOOST_ASIO_MOVE_ARG(CompletionToken) token)
+{
+ return boost::asio::async_compose<CompletionToken, void()>(
+ impl_0_completion_args(ioc), token);
+}
+
+void compose_0_args_handler(int* count)
+{
+ ++(*count);
+}
+
+void compose_0_completion_args_test()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+
+ boost::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.
+ BOOST_ASIO_CHECK(!ioc.stopped());
+ BOOST_ASIO_CHECK(count == 0);
+
+ ioc.run();
+
+ // The run() call will not return until all work has finished.
+ BOOST_ASIO_CHECK(ioc.stopped());
+ BOOST_ASIO_CHECK(count == 1);
+}
+
+//------------------------------------------------------------------------------
+
+class impl_1_completion_arg
+{
+public:
+ explicit impl_1_completion_arg(boost::asio::io_context& ioc)
+ : ioc_(ioc),
+ state_(starting)
+ {
+ }
+
+ template <typename Self>
+ void operator()(Self& self)
+ {
+ switch (state_)
+ {
+ case starting:
+ state_ = posting;
+ boost::asio::post(ioc_, BOOST_ASIO_MOVE_CAST(Self)(self));
+ break;
+ case posting:
+ self.complete(42);
+ break;
+ default:
+ break;
+ }
+ }
+
+private:
+ boost::asio::io_context& ioc_;
+ enum { starting, posting } state_;
+};
+
+template <typename CompletionToken>
+BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void(int))
+async_1_completion_arg(boost::asio::io_context& ioc,
+ BOOST_ASIO_MOVE_ARG(CompletionToken) token)
+{
+ return boost::asio::async_compose<CompletionToken, void(int)>(
+ impl_1_completion_arg(ioc), token);
+}
+
+void compose_1_args_handler(int* count, int* result_out, int result)
+{
+ ++(*count);
+ *result_out = result;
+}
+
+void compose_1_completion_arg_test()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+
+ boost::asio::io_context ioc;
+ int count = 0;
+ int result = 0;
+
+ async_1_completion_arg(ioc,
+ bindns::bind(&compose_1_args_handler, &count, &result, _1));
+
+ // No handlers can be called until run() is called.
+ BOOST_ASIO_CHECK(!ioc.stopped());
+ BOOST_ASIO_CHECK(count == 0);
+ BOOST_ASIO_CHECK(result == 0);
+
+ ioc.run();
+
+ // The run() call will not return until all work has finished.
+ BOOST_ASIO_CHECK(ioc.stopped());
+ BOOST_ASIO_CHECK(count == 1);
+ BOOST_ASIO_CHECK(result == 42);
+}
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "compose",
+ BOOST_ASIO_TEST_CASE(compose_0_completion_args_test)
+ BOOST_ASIO_TEST_CASE(compose_1_completion_arg_test)
+)
diff --git a/src/boost/libs/asio/test/connect.cpp b/src/boost/libs/asio/test/connect.cpp
new file mode 100644
index 000000000..32f9cbd15
--- /dev/null
+++ b/src/boost/libs/asio/test/connect.cpp
@@ -0,0 +1,1190 @@
+//
+// connect.cpp
+// ~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/connect.hpp>
+
+#include <vector>
+#include <boost/asio/detail/thread.hpp>
+#include <boost/asio/ip/tcp.hpp>
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <boost/bind/bind.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <functional>
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+
+#include "unit_test.hpp"
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+using bindns::placeholders::_1;
+using bindns::placeholders::_2;
+
+class connection_sink
+{
+public:
+ connection_sink()
+ : acceptor_(io_context_,
+ boost::asio::ip::tcp::endpoint(
+ boost::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();
+ }
+
+ boost::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));
+ }
+
+ boost::asio::io_context io_context_;
+ boost::asio::ip::tcp::acceptor acceptor_;
+ boost::asio::ip::tcp::endpoint target_endpoint_;
+ boost::asio::ip::tcp::socket socket_;
+ boost::asio::detail::thread thread_;
+};
+
+bool true_cond_1(const boost::system::error_code& /*ec*/,
+ const boost::asio::ip::tcp::endpoint& /*endpoint*/)
+{
+ return true;
+}
+
+struct true_cond_2
+{
+ template <typename Endpoint>
+ bool operator()(const boost::system::error_code& /*ec*/,
+ const Endpoint& /*endpoint*/)
+ {
+ return true;
+ }
+};
+
+std::vector<boost::asio::ip::tcp::endpoint>::const_iterator legacy_true_cond_1(
+ const boost::system::error_code& /*ec*/,
+ std::vector<boost::asio::ip::tcp::endpoint>::const_iterator next)
+{
+ return next;
+}
+
+struct legacy_true_cond_2
+{
+ template <typename Iterator>
+ Iterator operator()(const boost::system::error_code& /*ec*/, Iterator next)
+ {
+ return next;
+ }
+};
+
+bool false_cond(const boost::system::error_code& /*ec*/,
+ const boost::asio::ip::tcp::endpoint& /*endpoint*/)
+{
+ return false;
+}
+
+void range_handler(const boost::system::error_code& ec,
+ const boost::asio::ip::tcp::endpoint& endpoint,
+ boost::system::error_code* out_ec,
+ boost::asio::ip::tcp::endpoint* out_endpoint)
+{
+ *out_ec = ec;
+ *out_endpoint = endpoint;
+}
+
+void iter_handler(const boost::system::error_code& ec,
+ std::vector<boost::asio::ip::tcp::endpoint>::const_iterator iter,
+ boost::system::error_code* out_ec,
+ std::vector<boost::asio::ip::tcp::endpoint>::const_iterator* out_iter)
+{
+ *out_ec = ec;
+ *out_iter = iter;
+}
+
+void test_connect_range()
+{
+ connection_sink sink;
+ boost::asio::io_context io_context;
+ boost::asio::ip::tcp::socket socket(io_context);
+ std::vector<boost::asio::ip::tcp::endpoint> endpoints;
+ boost::asio::ip::tcp::endpoint result;
+
+ try
+ {
+ result = boost::asio::connect(socket, endpoints);
+ BOOST_ASIO_CHECK(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_ASIO_CHECK(e.code() == boost::asio::error::not_found);
+ }
+
+ endpoints.push_back(sink.target_endpoint());
+
+ result = boost::asio::connect(socket, endpoints);
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+
+ endpoints.push_back(sink.target_endpoint());
+
+ result = boost::asio::connect(socket, endpoints);
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+
+ endpoints.insert(endpoints.begin(), boost::asio::ip::tcp::endpoint());
+
+ result = boost::asio::connect(socket, endpoints);
+ BOOST_ASIO_CHECK(result == endpoints[1]);
+}
+
+void test_connect_range_ec()
+{
+ connection_sink sink;
+ boost::asio::io_context io_context;
+ boost::asio::ip::tcp::socket socket(io_context);
+ std::vector<boost::asio::ip::tcp::endpoint> endpoints;
+ boost::asio::ip::tcp::endpoint result;
+ boost::system::error_code ec;
+
+ result = boost::asio::connect(socket, endpoints, ec);
+ BOOST_ASIO_CHECK(result == boost::asio::ip::tcp::endpoint());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ endpoints.push_back(sink.target_endpoint());
+
+ result = boost::asio::connect(socket, endpoints, ec);
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+ BOOST_ASIO_CHECK(!ec);
+
+ endpoints.push_back(sink.target_endpoint());
+
+ result = boost::asio::connect(socket, endpoints, ec);
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+ BOOST_ASIO_CHECK(!ec);
+
+ endpoints.insert(endpoints.begin(), boost::asio::ip::tcp::endpoint());
+
+ result = boost::asio::connect(socket, endpoints, ec);
+ BOOST_ASIO_CHECK(result == endpoints[1]);
+ BOOST_ASIO_CHECK(!ec);
+}
+
+void test_connect_range_cond()
+{
+ connection_sink sink;
+ boost::asio::io_context io_context;
+ boost::asio::ip::tcp::socket socket(io_context);
+ std::vector<boost::asio::ip::tcp::endpoint> endpoints;
+ boost::asio::ip::tcp::endpoint result;
+
+ try
+ {
+ result = boost::asio::connect(socket, endpoints, true_cond_1);
+ BOOST_ASIO_CHECK(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_ASIO_CHECK(e.code() == boost::asio::error::not_found);
+ }
+
+ try
+ {
+ result = boost::asio::connect(socket, endpoints, true_cond_2());
+ BOOST_ASIO_CHECK(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_ASIO_CHECK(e.code() == boost::asio::error::not_found);
+ }
+
+ try
+ {
+ result = boost::asio::connect(socket, endpoints, legacy_true_cond_1);
+ BOOST_ASIO_CHECK(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_ASIO_CHECK(e.code() == boost::asio::error::not_found);
+ }
+
+ try
+ {
+ result = boost::asio::connect(socket, endpoints, legacy_true_cond_2());
+ BOOST_ASIO_CHECK(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_ASIO_CHECK(e.code() == boost::asio::error::not_found);
+ }
+
+ try
+ {
+ result = boost::asio::connect(socket, endpoints, false_cond);
+ BOOST_ASIO_CHECK(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_ASIO_CHECK(e.code() == boost::asio::error::not_found);
+ }
+
+ endpoints.push_back(sink.target_endpoint());
+
+ result = boost::asio::connect(socket, endpoints, true_cond_1);
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+
+ result = boost::asio::connect(socket, endpoints, true_cond_2());
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+
+ result = boost::asio::connect(socket, endpoints, legacy_true_cond_1);
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+
+ result = boost::asio::connect(socket, endpoints, legacy_true_cond_2());
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+
+ try
+ {
+ result = boost::asio::connect(socket, endpoints, false_cond);
+ BOOST_ASIO_CHECK(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_ASIO_CHECK(e.code() == boost::asio::error::not_found);
+ }
+
+ endpoints.push_back(sink.target_endpoint());
+
+ result = boost::asio::connect(socket, endpoints, true_cond_1);
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+
+ result = boost::asio::connect(socket, endpoints, true_cond_2());
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+
+ result = boost::asio::connect(socket, endpoints, legacy_true_cond_1);
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+
+ result = boost::asio::connect(socket, endpoints, legacy_true_cond_2());
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+
+ try
+ {
+ result = boost::asio::connect(socket, endpoints, false_cond);
+ BOOST_ASIO_CHECK(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_ASIO_CHECK(e.code() == boost::asio::error::not_found);
+ }
+
+ endpoints.insert(endpoints.begin(), boost::asio::ip::tcp::endpoint());
+
+ result = boost::asio::connect(socket, endpoints, true_cond_1);
+ BOOST_ASIO_CHECK(result == endpoints[1]);
+
+ result = boost::asio::connect(socket, endpoints, true_cond_2());
+ BOOST_ASIO_CHECK(result == endpoints[1]);
+
+ result = boost::asio::connect(socket, endpoints, legacy_true_cond_1);
+ BOOST_ASIO_CHECK(result == endpoints[1]);
+
+ result = boost::asio::connect(socket, endpoints, legacy_true_cond_2());
+ BOOST_ASIO_CHECK(result == endpoints[1]);
+
+ try
+ {
+ result = boost::asio::connect(socket, endpoints, false_cond);
+ BOOST_ASIO_CHECK(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_ASIO_CHECK(e.code() == boost::asio::error::not_found);
+ }
+}
+
+void test_connect_range_cond_ec()
+{
+ connection_sink sink;
+ boost::asio::io_context io_context;
+ boost::asio::ip::tcp::socket socket(io_context);
+ std::vector<boost::asio::ip::tcp::endpoint> endpoints;
+ boost::asio::ip::tcp::endpoint result;
+ boost::system::error_code ec;
+
+ result = boost::asio::connect(socket, endpoints, true_cond_1, ec);
+ BOOST_ASIO_CHECK(result == boost::asio::ip::tcp::endpoint());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ result = boost::asio::connect(socket, endpoints, true_cond_2(), ec);
+ BOOST_ASIO_CHECK(result == boost::asio::ip::tcp::endpoint());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ result = boost::asio::connect(socket, endpoints, legacy_true_cond_1, ec);
+ BOOST_ASIO_CHECK(result == boost::asio::ip::tcp::endpoint());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ result = boost::asio::connect(socket, endpoints, legacy_true_cond_2(), ec);
+ BOOST_ASIO_CHECK(result == boost::asio::ip::tcp::endpoint());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ result = boost::asio::connect(socket, endpoints, false_cond, ec);
+ BOOST_ASIO_CHECK(result == boost::asio::ip::tcp::endpoint());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ endpoints.push_back(sink.target_endpoint());
+
+ result = boost::asio::connect(socket, endpoints, true_cond_1, ec);
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, endpoints, true_cond_2(), ec);
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, endpoints, legacy_true_cond_1, ec);
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, endpoints, legacy_true_cond_2(), ec);
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, endpoints, false_cond, ec);
+ BOOST_ASIO_CHECK(result == boost::asio::ip::tcp::endpoint());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ endpoints.push_back(sink.target_endpoint());
+
+ result = boost::asio::connect(socket, endpoints, true_cond_1, ec);
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, endpoints, true_cond_2(), ec);
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, endpoints, legacy_true_cond_1, ec);
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, endpoints, legacy_true_cond_2(), ec);
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, endpoints, false_cond, ec);
+ BOOST_ASIO_CHECK(result == boost::asio::ip::tcp::endpoint());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ endpoints.insert(endpoints.begin(), boost::asio::ip::tcp::endpoint());
+
+ result = boost::asio::connect(socket, endpoints, true_cond_1, ec);
+ BOOST_ASIO_CHECK(result == endpoints[1]);
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, endpoints, true_cond_2(), ec);
+ BOOST_ASIO_CHECK(result == endpoints[1]);
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, endpoints, legacy_true_cond_1, ec);
+ BOOST_ASIO_CHECK(result == endpoints[1]);
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, endpoints, legacy_true_cond_2(), ec);
+ BOOST_ASIO_CHECK(result == endpoints[1]);
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, endpoints, false_cond, ec);
+ BOOST_ASIO_CHECK(result == boost::asio::ip::tcp::endpoint());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+}
+
+void test_connect_iter()
+{
+ connection_sink sink;
+ boost::asio::io_context io_context;
+ boost::asio::ip::tcp::socket socket(io_context);
+ std::vector<boost::asio::ip::tcp::endpoint> endpoints;
+ const std::vector<boost::asio::ip::tcp::endpoint>& cendpoints = endpoints;
+ std::vector<boost::asio::ip::tcp::endpoint>::const_iterator result;
+
+ try
+ {
+ result = boost::asio::connect(socket, cendpoints.begin(), cendpoints.end());
+ BOOST_ASIO_CHECK(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_ASIO_CHECK(e.code() == boost::asio::error::not_found);
+ }
+
+ endpoints.push_back(sink.target_endpoint());
+
+ result = boost::asio::connect(socket, cendpoints.begin(), cendpoints.end());
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+
+ endpoints.push_back(sink.target_endpoint());
+
+ result = boost::asio::connect(socket, cendpoints.begin(), cendpoints.end());
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+
+ endpoints.insert(endpoints.begin(), boost::asio::ip::tcp::endpoint());
+
+ result = boost::asio::connect(socket, cendpoints.begin(), cendpoints.end());
+ BOOST_ASIO_CHECK(result == cendpoints.begin() + 1);
+}
+
+void test_connect_iter_ec()
+{
+ connection_sink sink;
+ boost::asio::io_context io_context;
+ boost::asio::ip::tcp::socket socket(io_context);
+ std::vector<boost::asio::ip::tcp::endpoint> endpoints;
+ const std::vector<boost::asio::ip::tcp::endpoint>& cendpoints = endpoints;
+ std::vector<boost::asio::ip::tcp::endpoint>::const_iterator result;
+ boost::system::error_code ec;
+
+ result = boost::asio::connect(socket,
+ cendpoints.begin(), cendpoints.end(), ec);
+ BOOST_ASIO_CHECK(result == cendpoints.end());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ endpoints.push_back(sink.target_endpoint());
+
+ result = boost::asio::connect(socket,
+ cendpoints.begin(), cendpoints.end(), ec);
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+ BOOST_ASIO_CHECK(!ec);
+
+ endpoints.push_back(sink.target_endpoint());
+
+ result = boost::asio::connect(socket,
+ cendpoints.begin(), cendpoints.end(), ec);
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+ BOOST_ASIO_CHECK(!ec);
+
+ endpoints.insert(endpoints.begin(), boost::asio::ip::tcp::endpoint());
+
+ result = boost::asio::connect(socket,
+ cendpoints.begin(), cendpoints.end(), ec);
+ BOOST_ASIO_CHECK(result == cendpoints.begin() + 1);
+ BOOST_ASIO_CHECK(!ec);
+}
+
+void test_connect_iter_cond()
+{
+ connection_sink sink;
+ boost::asio::io_context io_context;
+ boost::asio::ip::tcp::socket socket(io_context);
+ std::vector<boost::asio::ip::tcp::endpoint> endpoints;
+ const std::vector<boost::asio::ip::tcp::endpoint>& cendpoints = endpoints;
+ std::vector<boost::asio::ip::tcp::endpoint>::const_iterator result;
+
+ try
+ {
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), true_cond_1);
+ BOOST_ASIO_CHECK(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_ASIO_CHECK(e.code() == boost::asio::error::not_found);
+ }
+
+ try
+ {
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), true_cond_2());
+ BOOST_ASIO_CHECK(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_ASIO_CHECK(e.code() == boost::asio::error::not_found);
+ }
+
+ try
+ {
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), legacy_true_cond_1);
+ BOOST_ASIO_CHECK(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_ASIO_CHECK(e.code() == boost::asio::error::not_found);
+ }
+
+ try
+ {
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), legacy_true_cond_2());
+ BOOST_ASIO_CHECK(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_ASIO_CHECK(e.code() == boost::asio::error::not_found);
+ }
+
+ try
+ {
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), false_cond);
+ BOOST_ASIO_CHECK(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_ASIO_CHECK(e.code() == boost::asio::error::not_found);
+ }
+
+ endpoints.push_back(sink.target_endpoint());
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), true_cond_1);
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), true_cond_2());
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), legacy_true_cond_1);
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), legacy_true_cond_2());
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+
+ try
+ {
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), false_cond);
+ BOOST_ASIO_CHECK(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_ASIO_CHECK(e.code() == boost::asio::error::not_found);
+ }
+
+ endpoints.push_back(sink.target_endpoint());
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), true_cond_1);
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), true_cond_2());
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), legacy_true_cond_1);
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), legacy_true_cond_2());
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+
+ try
+ {
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), false_cond);
+ BOOST_ASIO_CHECK(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_ASIO_CHECK(e.code() == boost::asio::error::not_found);
+ }
+
+ endpoints.insert(endpoints.begin(), boost::asio::ip::tcp::endpoint());
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), true_cond_1);
+ BOOST_ASIO_CHECK(result == cendpoints.begin() + 1);
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), true_cond_2());
+ BOOST_ASIO_CHECK(result == cendpoints.begin() + 1);
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), legacy_true_cond_1);
+ BOOST_ASIO_CHECK(result == cendpoints.begin() + 1);
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), legacy_true_cond_2());
+ BOOST_ASIO_CHECK(result == cendpoints.begin() + 1);
+
+ try
+ {
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), false_cond);
+ BOOST_ASIO_CHECK(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_ASIO_CHECK(e.code() == boost::asio::error::not_found);
+ }
+}
+
+void test_connect_iter_cond_ec()
+{
+ connection_sink sink;
+ boost::asio::io_context io_context;
+ boost::asio::ip::tcp::socket socket(io_context);
+ std::vector<boost::asio::ip::tcp::endpoint> endpoints;
+ const std::vector<boost::asio::ip::tcp::endpoint>& cendpoints = endpoints;
+ std::vector<boost::asio::ip::tcp::endpoint>::const_iterator result;
+ boost::system::error_code ec;
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), true_cond_1, ec);
+ BOOST_ASIO_CHECK(result == cendpoints.end());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), true_cond_2(), ec);
+ BOOST_ASIO_CHECK(result == cendpoints.end());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), legacy_true_cond_1, ec);
+ BOOST_ASIO_CHECK(result == cendpoints.end());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), legacy_true_cond_2(), ec);
+ BOOST_ASIO_CHECK(result == cendpoints.end());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), false_cond, ec);
+ BOOST_ASIO_CHECK(result == cendpoints.end());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ endpoints.push_back(sink.target_endpoint());
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), true_cond_1, ec);
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), true_cond_2(), ec);
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), legacy_true_cond_1, ec);
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), legacy_true_cond_2(), ec);
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), false_cond, ec);
+ BOOST_ASIO_CHECK(result == cendpoints.end());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ endpoints.push_back(sink.target_endpoint());
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), true_cond_1, ec);
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), true_cond_2(), ec);
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), legacy_true_cond_1, ec);
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), legacy_true_cond_2(), ec);
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), false_cond, ec);
+ BOOST_ASIO_CHECK(result == cendpoints.end());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ endpoints.insert(endpoints.begin(), boost::asio::ip::tcp::endpoint());
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), true_cond_1, ec);
+ BOOST_ASIO_CHECK(result == cendpoints.begin() + 1);
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), true_cond_2(), ec);
+ BOOST_ASIO_CHECK(result == cendpoints.begin() + 1);
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), legacy_true_cond_1, ec);
+ BOOST_ASIO_CHECK(result == cendpoints.begin() + 1);
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), legacy_true_cond_2(), ec);
+ BOOST_ASIO_CHECK(result == cendpoints.begin() + 1);
+ BOOST_ASIO_CHECK(!ec);
+
+ result = boost::asio::connect(socket, cendpoints.begin(),
+ cendpoints.end(), false_cond, ec);
+ BOOST_ASIO_CHECK(result == cendpoints.end());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+}
+
+void test_async_connect_range()
+{
+ connection_sink sink;
+ boost::asio::io_context io_context;
+ boost::asio::ip::tcp::socket socket(io_context);
+ std::vector<boost::asio::ip::tcp::endpoint> endpoints;
+ boost::asio::ip::tcp::endpoint result;
+ boost::system::error_code ec;
+
+ boost::asio::async_connect(socket, endpoints,
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == boost::asio::ip::tcp::endpoint());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ endpoints.push_back(sink.target_endpoint());
+
+ boost::asio::async_connect(socket, endpoints,
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+ BOOST_ASIO_CHECK(!ec);
+
+ endpoints.push_back(sink.target_endpoint());
+
+ boost::asio::async_connect(socket, endpoints,
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+ BOOST_ASIO_CHECK(!ec);
+
+ endpoints.insert(endpoints.begin(), boost::asio::ip::tcp::endpoint());
+
+ boost::asio::async_connect(socket, endpoints,
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == endpoints[1]);
+ BOOST_ASIO_CHECK(!ec);
+}
+
+void test_async_connect_range_cond()
+{
+ connection_sink sink;
+ boost::asio::io_context io_context;
+ boost::asio::ip::tcp::socket socket(io_context);
+ std::vector<boost::asio::ip::tcp::endpoint> endpoints;
+ boost::asio::ip::tcp::endpoint result;
+ boost::system::error_code ec;
+
+ boost::asio::async_connect(socket, endpoints, true_cond_1,
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == boost::asio::ip::tcp::endpoint());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ boost::asio::async_connect(socket, endpoints, true_cond_2(),
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == boost::asio::ip::tcp::endpoint());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ boost::asio::async_connect(socket, endpoints, legacy_true_cond_1,
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == boost::asio::ip::tcp::endpoint());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ boost::asio::async_connect(socket, endpoints, legacy_true_cond_2(),
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == boost::asio::ip::tcp::endpoint());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ boost::asio::async_connect(socket, endpoints, false_cond,
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == boost::asio::ip::tcp::endpoint());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ endpoints.push_back(sink.target_endpoint());
+
+ boost::asio::async_connect(socket, endpoints, true_cond_1,
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::asio::async_connect(socket, endpoints, true_cond_2(),
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::asio::async_connect(socket, endpoints, legacy_true_cond_1,
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::asio::async_connect(socket, endpoints, legacy_true_cond_2(),
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::asio::async_connect(socket, endpoints, false_cond,
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == boost::asio::ip::tcp::endpoint());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ endpoints.push_back(sink.target_endpoint());
+
+ boost::asio::async_connect(socket, endpoints, true_cond_1,
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::asio::async_connect(socket, endpoints, true_cond_2(),
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::asio::async_connect(socket, endpoints, legacy_true_cond_1,
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::asio::async_connect(socket, endpoints, legacy_true_cond_2(),
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == endpoints[0]);
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::asio::async_connect(socket, endpoints, false_cond,
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == boost::asio::ip::tcp::endpoint());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ endpoints.insert(endpoints.begin(), boost::asio::ip::tcp::endpoint());
+
+ boost::asio::async_connect(socket, endpoints, true_cond_1,
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == endpoints[1]);
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::asio::async_connect(socket, endpoints, true_cond_2(),
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == endpoints[1]);
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::asio::async_connect(socket, endpoints, legacy_true_cond_1,
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == endpoints[1]);
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::asio::async_connect(socket, endpoints, legacy_true_cond_2(),
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == endpoints[1]);
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::asio::async_connect(socket, endpoints, false_cond,
+ bindns::bind(range_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == boost::asio::ip::tcp::endpoint());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+}
+
+void test_async_connect_iter()
+{
+ connection_sink sink;
+ boost::asio::io_context io_context;
+ boost::asio::ip::tcp::socket socket(io_context);
+ std::vector<boost::asio::ip::tcp::endpoint> endpoints;
+ const std::vector<boost::asio::ip::tcp::endpoint>& cendpoints = endpoints;
+ std::vector<boost::asio::ip::tcp::endpoint>::const_iterator result;
+ boost::system::error_code ec;
+
+ boost::asio::async_connect(socket, cendpoints.begin(), cendpoints.end(),
+ bindns::bind(iter_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == cendpoints.end());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ endpoints.push_back(sink.target_endpoint());
+
+ boost::asio::async_connect(socket, cendpoints.begin(), cendpoints.end(),
+ bindns::bind(iter_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+ BOOST_ASIO_CHECK(!ec);
+
+ endpoints.push_back(sink.target_endpoint());
+
+ boost::asio::async_connect(socket, cendpoints.begin(), cendpoints.end(),
+ bindns::bind(iter_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+ BOOST_ASIO_CHECK(!ec);
+
+ endpoints.insert(endpoints.begin(), boost::asio::ip::tcp::endpoint());
+
+ boost::asio::async_connect(socket, cendpoints.begin(), cendpoints.end(),
+ bindns::bind(iter_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == cendpoints.begin() + 1);
+ BOOST_ASIO_CHECK(!ec);
+}
+
+void test_async_connect_iter_cond()
+{
+ connection_sink sink;
+ boost::asio::io_context io_context;
+ boost::asio::ip::tcp::socket socket(io_context);
+ std::vector<boost::asio::ip::tcp::endpoint> endpoints;
+ const std::vector<boost::asio::ip::tcp::endpoint>& cendpoints = endpoints;
+ std::vector<boost::asio::ip::tcp::endpoint>::const_iterator result;
+ boost::system::error_code ec;
+
+ boost::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();
+ BOOST_ASIO_CHECK(result == cendpoints.end());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ boost::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();
+ BOOST_ASIO_CHECK(result == cendpoints.end());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ boost::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();
+ BOOST_ASIO_CHECK(result == cendpoints.end());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ boost::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();
+ BOOST_ASIO_CHECK(result == cendpoints.end());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ boost::asio::async_connect(socket, cendpoints.begin(), cendpoints.end(),
+ false_cond, bindns::bind(iter_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == cendpoints.end());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ endpoints.push_back(sink.target_endpoint());
+
+ boost::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();
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::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();
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::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();
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::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();
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::asio::async_connect(socket, cendpoints.begin(), cendpoints.end(),
+ false_cond, bindns::bind(iter_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == cendpoints.end());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ endpoints.push_back(sink.target_endpoint());
+
+ boost::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();
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::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();
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::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();
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::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();
+ BOOST_ASIO_CHECK(result == cendpoints.begin());
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::asio::async_connect(socket, cendpoints.begin(), cendpoints.end(),
+ false_cond, bindns::bind(iter_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == cendpoints.end());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+
+ endpoints.insert(endpoints.begin(), boost::asio::ip::tcp::endpoint());
+
+ boost::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();
+ BOOST_ASIO_CHECK(result == cendpoints.begin() + 1);
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::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();
+ BOOST_ASIO_CHECK(result == cendpoints.begin() + 1);
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::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();
+ BOOST_ASIO_CHECK(result == cendpoints.begin() + 1);
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::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();
+ BOOST_ASIO_CHECK(result == cendpoints.begin() + 1);
+ BOOST_ASIO_CHECK(!ec);
+
+ boost::asio::async_connect(socket, cendpoints.begin(), cendpoints.end(),
+ false_cond, bindns::bind(iter_handler, _1, _2, &ec, &result));
+ io_context.restart();
+ io_context.run();
+ BOOST_ASIO_CHECK(result == cendpoints.end());
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+}
+
+BOOST_ASIO_TEST_SUITE
+(
+ "connect",
+ BOOST_ASIO_TEST_CASE(test_connect_range)
+ BOOST_ASIO_TEST_CASE(test_connect_range_ec)
+ BOOST_ASIO_TEST_CASE(test_connect_range_cond)
+ BOOST_ASIO_TEST_CASE(test_connect_range_cond_ec)
+ BOOST_ASIO_TEST_CASE(test_connect_iter)
+ BOOST_ASIO_TEST_CASE(test_connect_iter_ec)
+ BOOST_ASIO_TEST_CASE(test_connect_iter_cond)
+ BOOST_ASIO_TEST_CASE(test_connect_iter_cond_ec)
+ BOOST_ASIO_TEST_CASE(test_async_connect_range)
+ BOOST_ASIO_TEST_CASE(test_async_connect_range_cond)
+ BOOST_ASIO_TEST_CASE(test_async_connect_iter)
+ BOOST_ASIO_TEST_CASE(test_async_connect_iter_cond)
+)
diff --git a/src/boost/libs/asio/test/coroutine.cpp b/src/boost/libs/asio/test/coroutine.cpp
new file mode 100644
index 000000000..703feb67d
--- /dev/null
+++ b/src/boost/libs/asio/test/coroutine.cpp
@@ -0,0 +1,112 @@
+//
+// coroutine.cpp
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/coroutine.hpp>
+
+#include "unit_test.hpp"
+
+// Must come after all other headers.
+#include <boost/asio/yield.hpp>
+
+//------------------------------------------------------------------------------
+
+// Coroutine completes via yield break.
+
+void yield_break_coro(boost::asio::coroutine& coro)
+{
+ reenter (coro)
+ {
+ yield return;
+ yield break;
+ }
+}
+
+void yield_break_test()
+{
+ boost::asio::coroutine coro;
+ BOOST_ASIO_CHECK(!coro.is_complete());
+ yield_break_coro(coro);
+ BOOST_ASIO_CHECK(!coro.is_complete());
+ yield_break_coro(coro);
+ BOOST_ASIO_CHECK(coro.is_complete());
+}
+
+//------------------------------------------------------------------------------
+
+// Coroutine completes via return.
+
+void return_coro(boost::asio::coroutine& coro)
+{
+ reenter (coro)
+ {
+ return;
+ }
+}
+
+void return_test()
+{
+ boost::asio::coroutine coro;
+ return_coro(coro);
+ BOOST_ASIO_CHECK(coro.is_complete());
+}
+
+//------------------------------------------------------------------------------
+
+// Coroutine completes via exception.
+
+void exception_coro(boost::asio::coroutine& coro)
+{
+ reenter (coro)
+ {
+ throw 1;
+ }
+}
+
+void exception_test()
+{
+ boost::asio::coroutine coro;
+ try { exception_coro(coro); } catch (int) {}
+ BOOST_ASIO_CHECK(coro.is_complete());
+}
+
+//------------------------------------------------------------------------------
+
+// Coroutine completes by falling off the end.
+
+void fall_off_end_coro(boost::asio::coroutine& coro)
+{
+ reenter (coro)
+ {
+ }
+}
+
+void fall_off_end_test()
+{
+ boost::asio::coroutine coro;
+ fall_off_end_coro(coro);
+ BOOST_ASIO_CHECK(coro.is_complete());
+}
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "coroutine",
+ BOOST_ASIO_TEST_CASE(yield_break_test)
+ BOOST_ASIO_TEST_CASE(return_test)
+ BOOST_ASIO_TEST_CASE(exception_test)
+ BOOST_ASIO_TEST_CASE(fall_off_end_test)
+)
diff --git a/src/boost/libs/asio/test/deadline_timer.cpp b/src/boost/libs/asio/test/deadline_timer.cpp
new file mode 100644
index 000000000..0ff0d9bd8
--- /dev/null
+++ b/src/boost/libs/asio/test/deadline_timer.cpp
@@ -0,0 +1,392 @@
+//
+// deadline_timer.cpp
+// ~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/deadline_timer.hpp>
+
+#include "unit_test.hpp"
+
+#if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+
+#include <boost/bind/bind.hpp>
+#include "archetypes/async_result.hpp"
+#include <boost/asio/executor_work_guard.hpp>
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/placeholders.hpp>
+#include <boost/asio/detail/thread.hpp>
+
+using namespace boost::posix_time;
+
+void increment(int* count)
+{
+ ++(*count);
+}
+
+void decrement_to_zero(boost::asio::deadline_timer* t, int* count)
+{
+ if (*count > 0)
+ {
+ --(*count);
+
+ int before_value = *count;
+
+ t->expires_at(t->expires_at() + seconds(1));
+ t->async_wait(boost::bind(decrement_to_zero, t, count));
+
+ // Completion cannot nest, so count value should remain unchanged.
+ BOOST_ASIO_CHECK(*count == before_value);
+ }
+}
+
+void increment_if_not_cancelled(int* count,
+ const boost::system::error_code& ec)
+{
+ if (!ec)
+ ++(*count);
+}
+
+void cancel_timer(boost::asio::deadline_timer* t)
+{
+ std::size_t num_cancelled = t->cancel();
+ BOOST_ASIO_CHECK(num_cancelled == 1);
+}
+
+void cancel_one_timer(boost::asio::deadline_timer* t)
+{
+ std::size_t num_cancelled = t->cancel_one();
+ BOOST_ASIO_CHECK(num_cancelled == 1);
+}
+
+ptime now()
+{
+#if defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK)
+ return microsec_clock::universal_time();
+#else // defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK)
+ return second_clock::universal_time();
+#endif // defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK)
+}
+
+void deadline_timer_test()
+{
+ boost::asio::io_context ioc;
+ int count = 0;
+
+ ptime start = now();
+
+ boost::asio::deadline_timer t1(ioc, seconds(1));
+ t1.wait();
+
+ // The timer must block until after its expiry time.
+ ptime end = now();
+ ptime expected_end = start + seconds(1);
+ BOOST_ASIO_CHECK(expected_end < end || expected_end == end);
+
+ start = now();
+
+ boost::asio::deadline_timer t2(ioc, seconds(1) + microseconds(500000));
+ t2.wait();
+
+ // The timer must block until after its expiry time.
+ end = now();
+ expected_end = start + seconds(1) + microseconds(500000);
+ BOOST_ASIO_CHECK(expected_end < end || expected_end == end);
+
+ t2.expires_at(t2.expires_at() + seconds(1));
+ t2.wait();
+
+ // The timer must block until after its expiry time.
+ end = now();
+ expected_end += seconds(1);
+ BOOST_ASIO_CHECK(expected_end < end || expected_end == end);
+
+ start = now();
+
+ t2.expires_from_now(seconds(1) + microseconds(200000));
+ t2.wait();
+
+ // The timer must block until after its expiry time.
+ end = now();
+ expected_end = start + seconds(1) + microseconds(200000);
+ BOOST_ASIO_CHECK(expected_end < end || expected_end == end);
+
+ start = now();
+
+ boost::asio::deadline_timer t3(ioc, seconds(5));
+ t3.async_wait(boost::bind(increment, &count));
+
+ // No completions can be delivered until run() is called.
+ BOOST_ASIO_CHECK(count == 0);
+
+ ioc.run();
+
+ // The run() call will not return until all operations have finished, and
+ // this should not be until after the timer's expiry time.
+ BOOST_ASIO_CHECK(count == 1);
+ end = now();
+ expected_end = start + seconds(1);
+ BOOST_ASIO_CHECK(expected_end < end || expected_end == end);
+
+ count = 3;
+ start = now();
+
+ boost::asio::deadline_timer t4(ioc, seconds(1));
+ t4.async_wait(boost::bind(decrement_to_zero, &t4, &count));
+
+ // No completions can be delivered until run() is called.
+ BOOST_ASIO_CHECK(count == 3);
+
+ ioc.restart();
+ ioc.run();
+
+ // The run() call will not return until all operations have finished, and
+ // this should not be until after the timer's final expiry time.
+ BOOST_ASIO_CHECK(count == 0);
+ end = now();
+ expected_end = start + seconds(3);
+ BOOST_ASIO_CHECK(expected_end < end || expected_end == end);
+
+ count = 0;
+ start = now();
+
+ boost::asio::deadline_timer t5(ioc, seconds(10));
+ t5.async_wait(boost::bind(increment_if_not_cancelled, &count,
+ boost::asio::placeholders::error));
+ boost::asio::deadline_timer t6(ioc, seconds(1));
+ t6.async_wait(boost::bind(cancel_timer, &t5));
+
+ // No completions can be delivered until run() is called.
+ BOOST_ASIO_CHECK(count == 0);
+
+ ioc.restart();
+ ioc.run();
+
+ // The timer should have been cancelled, so count should not have changed.
+ // The total run time should not have been much more than 1 second (and
+ // certainly far less than 10 seconds).
+ BOOST_ASIO_CHECK(count == 0);
+ end = now();
+ expected_end = start + seconds(2);
+ BOOST_ASIO_CHECK(end < expected_end);
+
+ // Wait on the timer again without cancelling it. This time the asynchronous
+ // wait should run to completion and increment the counter.
+ t5.async_wait(boost::bind(increment_if_not_cancelled, &count,
+ boost::asio::placeholders::error));
+
+ ioc.restart();
+ ioc.run();
+
+ // The timer should not have been cancelled, so count should have changed.
+ // The total time since the timer was created should be more than 10 seconds.
+ BOOST_ASIO_CHECK(count == 1);
+ end = now();
+ expected_end = start + seconds(10);
+ BOOST_ASIO_CHECK(expected_end < end || expected_end == end);
+
+ count = 0;
+ start = now();
+
+ // Start two waits on a timer, one of which will be cancelled. The one
+ // which is not cancelled should still run to completion and increment the
+ // counter.
+ boost::asio::deadline_timer t7(ioc, seconds(3));
+ t7.async_wait(boost::bind(increment_if_not_cancelled, &count,
+ boost::asio::placeholders::error));
+ t7.async_wait(boost::bind(increment_if_not_cancelled, &count,
+ boost::asio::placeholders::error));
+ boost::asio::deadline_timer t8(ioc, seconds(1));
+ t8.async_wait(boost::bind(cancel_one_timer, &t7));
+
+ ioc.restart();
+ ioc.run();
+
+ // One of the waits should not have been cancelled, so count should have
+ // changed. The total time since the timer was created should be more than 3
+ // seconds.
+ BOOST_ASIO_CHECK(count == 1);
+ end = now();
+ expected_end = start + seconds(3);
+ BOOST_ASIO_CHECK(expected_end < end || expected_end == end);
+}
+
+void timer_handler(const boost::system::error_code&)
+{
+}
+
+void deadline_timer_cancel_test()
+{
+ static boost::asio::io_context io_context;
+ struct timer
+ {
+ boost::asio::deadline_timer t;
+ timer() : t(io_context) { t.expires_at(boost::posix_time::pos_infin); }
+ } timers[50];
+
+ timers[2].t.async_wait(&timer_handler);
+ timers[41].t.async_wait(&timer_handler);
+ for (int i = 10; i < 20; ++i)
+ timers[i].t.async_wait(&timer_handler);
+
+ BOOST_ASIO_CHECK(timers[2].t.cancel() == 1);
+ BOOST_ASIO_CHECK(timers[41].t.cancel() == 1);
+ for (int i = 10; i < 20; ++i)
+ BOOST_ASIO_CHECK(timers[i].t.cancel() == 1);
+}
+
+struct custom_allocation_timer_handler
+{
+ custom_allocation_timer_handler(int* count) : count_(count) {}
+ void operator()(const boost::system::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);
+}
+
+void deadline_timer_custom_allocation_test()
+{
+ static boost::asio::io_context io_context;
+ struct timer
+ {
+ boost::asio::deadline_timer t;
+ timer() : t(io_context) {}
+ } timers[100];
+
+ int allocation_count = 0;
+
+ for (int i = 0; i < 50; ++i)
+ {
+ timers[i].t.expires_at(boost::posix_time::pos_infin);
+ timers[i].t.async_wait(custom_allocation_timer_handler(&allocation_count));
+ }
+
+ for (int i = 50; i < 100; ++i)
+ {
+ timers[i].t.expires_at(boost::posix_time::neg_infin);
+ timers[i].t.async_wait(custom_allocation_timer_handler(&allocation_count));
+ }
+
+ for (int i = 0; i < 50; ++i)
+ timers[i].t.cancel();
+
+ io_context.run();
+
+ BOOST_ASIO_CHECK(allocation_count == 0);
+}
+
+void io_context_run(boost::asio::io_context* ioc)
+{
+ ioc->run();
+}
+
+void deadline_timer_thread_test()
+{
+ boost::asio::io_context ioc;
+ boost::asio::executor_work_guard<boost::asio::io_context::executor_type> work
+ = boost::asio::make_work_guard(ioc);
+ boost::asio::deadline_timer t1(ioc);
+ boost::asio::deadline_timer t2(ioc);
+ int count = 0;
+
+ boost::asio::detail::thread th(boost::bind(io_context_run, &ioc));
+
+ t2.expires_from_now(boost::posix_time::seconds(2));
+ t2.wait();
+
+ t1.expires_from_now(boost::posix_time::seconds(2));
+ t1.async_wait(boost::bind(increment, &count));
+
+ t2.expires_from_now(boost::posix_time::seconds(4));
+ t2.wait();
+
+ ioc.stop();
+ th.join();
+
+ BOOST_ASIO_CHECK(count == 1);
+}
+
+void deadline_timer_async_result_test()
+{
+ boost::asio::io_context ioc;
+ boost::asio::deadline_timer t1(ioc);
+
+ t1.expires_from_now(boost::posix_time::seconds(1));
+ int i = t1.async_wait(archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+
+ ioc.run();
+}
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+boost::asio::deadline_timer make_timer(boost::asio::io_context& ioc, int* count)
+{
+ boost::asio::deadline_timer t(ioc);
+ t.expires_from_now(boost::posix_time::seconds(1));
+ t.async_wait(boost::bind(increment, count));
+ return t;
+}
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+void deadline_timer_move_test()
+{
+#if defined(BOOST_ASIO_HAS_MOVE)
+ boost::asio::io_context io_context1;
+ boost::asio::io_context io_context2;
+ int count = 0;
+
+ boost::asio::deadline_timer t1 = make_timer(io_context1, &count);
+ boost::asio::deadline_timer t2 = make_timer(io_context2, &count);
+ boost::asio::deadline_timer t3 = std::move(t1);
+
+ t2 = std::move(t1);
+
+ io_context2.run();
+
+ BOOST_ASIO_CHECK(count == 1);
+
+ io_context1.run();
+
+ BOOST_ASIO_CHECK(count == 2);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+}
+
+BOOST_ASIO_TEST_SUITE
+(
+ "deadline_timer",
+ BOOST_ASIO_TEST_CASE(deadline_timer_test)
+ BOOST_ASIO_TEST_CASE(deadline_timer_cancel_test)
+ BOOST_ASIO_TEST_CASE(deadline_timer_custom_allocation_test)
+ BOOST_ASIO_TEST_CASE(deadline_timer_thread_test)
+ BOOST_ASIO_TEST_CASE(deadline_timer_async_result_test)
+ BOOST_ASIO_TEST_CASE(deadline_timer_move_test)
+)
+#else // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+BOOST_ASIO_TEST_SUITE
+(
+ "deadline_timer",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
+#endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
diff --git a/src/boost/libs/asio/test/defer.cpp b/src/boost/libs/asio/test/defer.cpp
new file mode 100644
index 000000000..49e85fe24
--- /dev/null
+++ b/src/boost/libs/asio/test/defer.cpp
@@ -0,0 +1,25 @@
+//
+// defer.cpp
+// ~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/defer.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "defer",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/detached.cpp b/src/boost/libs/asio/test/detached.cpp
new file mode 100644
index 000000000..2c62e6d66
--- /dev/null
+++ b/src/boost/libs/asio/test/detached.cpp
@@ -0,0 +1,25 @@
+//
+// detached.cpp
+// ~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/detached.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "detached",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/dispatch.cpp b/src/boost/libs/asio/test/dispatch.cpp
new file mode 100644
index 000000000..f97531469
--- /dev/null
+++ b/src/boost/libs/asio/test/dispatch.cpp
@@ -0,0 +1,25 @@
+//
+// dispatch.cpp
+// ~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/dispatch.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "dispatch",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/error.cpp b/src/boost/libs/asio/test/error.cpp
new file mode 100644
index 000000000..5be958401
--- /dev/null
+++ b/src/boost/libs/asio/test/error.cpp
@@ -0,0 +1,89 @@
+//
+// error.cpp
+// ~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/error.hpp>
+
+#include <sstream>
+#include "unit_test.hpp"
+
+void test_error_code(const boost::system::error_code& code)
+{
+ boost::system::error_code error(code);
+ BOOST_ASIO_CHECK(code == error);
+
+ BOOST_ASIO_CHECK(!code || error);
+ BOOST_ASIO_CHECK(!code || !!error);
+
+ boost::system::error_code error2(error);
+ BOOST_ASIO_CHECK(error == error2);
+ BOOST_ASIO_CHECK(!(error != error2));
+
+ boost::system::error_code error3;
+ error3 = error;
+ BOOST_ASIO_CHECK(error == error3);
+ BOOST_ASIO_CHECK(!(error != error3));
+
+ std::ostringstream os;
+ os << error;
+ BOOST_ASIO_CHECK(!os.str().empty());
+}
+
+void error_test()
+{
+ test_error_code(boost::asio::error::access_denied);
+ test_error_code(boost::asio::error::address_family_not_supported);
+ test_error_code(boost::asio::error::address_in_use);
+ test_error_code(boost::asio::error::already_connected);
+ test_error_code(boost::asio::error::already_started);
+ test_error_code(boost::asio::error::connection_aborted);
+ test_error_code(boost::asio::error::connection_refused);
+ test_error_code(boost::asio::error::connection_reset);
+ test_error_code(boost::asio::error::bad_descriptor);
+ test_error_code(boost::asio::error::eof);
+ test_error_code(boost::asio::error::fault);
+ test_error_code(boost::asio::error::host_not_found);
+ test_error_code(boost::asio::error::host_not_found_try_again);
+ test_error_code(boost::asio::error::host_unreachable);
+ test_error_code(boost::asio::error::in_progress);
+ test_error_code(boost::asio::error::interrupted);
+ test_error_code(boost::asio::error::invalid_argument);
+ test_error_code(boost::asio::error::message_size);
+ test_error_code(boost::asio::error::network_down);
+ test_error_code(boost::asio::error::network_reset);
+ test_error_code(boost::asio::error::network_unreachable);
+ test_error_code(boost::asio::error::no_descriptors);
+ test_error_code(boost::asio::error::no_buffer_space);
+ test_error_code(boost::asio::error::no_data);
+ test_error_code(boost::asio::error::no_memory);
+ test_error_code(boost::asio::error::no_permission);
+ test_error_code(boost::asio::error::no_protocol_option);
+ test_error_code(boost::asio::error::no_recovery);
+ test_error_code(boost::asio::error::not_connected);
+ test_error_code(boost::asio::error::not_socket);
+ test_error_code(boost::asio::error::operation_aborted);
+ test_error_code(boost::asio::error::operation_not_supported);
+ test_error_code(boost::asio::error::service_not_found);
+ test_error_code(boost::asio::error::shut_down);
+ test_error_code(boost::asio::error::timed_out);
+ test_error_code(boost::asio::error::try_again);
+ test_error_code(boost::asio::error::would_block);
+}
+
+BOOST_ASIO_TEST_SUITE
+(
+ "error",
+ BOOST_ASIO_TEST_CASE(error_test)
+)
diff --git a/src/boost/libs/asio/test/execution_context.cpp b/src/boost/libs/asio/test/execution_context.cpp
new file mode 100644
index 000000000..feea39c87
--- /dev/null
+++ b/src/boost/libs/asio/test/execution_context.cpp
@@ -0,0 +1,25 @@
+//
+// execution_context.cpp
+// ~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/execution_context.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "execution_context",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/executor.cpp b/src/boost/libs/asio/test/executor.cpp
new file mode 100644
index 000000000..4b6bd7aa4
--- /dev/null
+++ b/src/boost/libs/asio/test/executor.cpp
@@ -0,0 +1,25 @@
+//
+// executor.cpp
+// ~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/executor.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "executor",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/executor_work_guard.cpp b/src/boost/libs/asio/test/executor_work_guard.cpp
new file mode 100644
index 000000000..b27df7bd4
--- /dev/null
+++ b/src/boost/libs/asio/test/executor_work_guard.cpp
@@ -0,0 +1,25 @@
+//
+// executor_work_guard.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/executor_work_guard.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "executor_work_guard",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/generic/basic_endpoint.cpp b/src/boost/libs/asio/test/generic/basic_endpoint.cpp
new file mode 100644
index 000000000..c9522a7d0
--- /dev/null
+++ b/src/boost/libs/asio/test/generic/basic_endpoint.cpp
@@ -0,0 +1,25 @@
+//
+// generic/basic_endpoint.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/generic/basic_endpoint.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "generic/basic_endpoint",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/generic/datagram_protocol.cpp b/src/boost/libs/asio/test/generic/datagram_protocol.cpp
new file mode 100644
index 000000000..76184edf2
--- /dev/null
+++ b/src/boost/libs/asio/test/generic/datagram_protocol.cpp
@@ -0,0 +1,263 @@
+//
+// generic/datagram_protocol.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/generic/datagram_protocol.hpp>
+
+#include <cstring>
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/ip/udp.hpp>
+#include "../unit_test.hpp"
+
+#if defined(__cplusplus_cli) || defined(__cplusplus_winrt)
+# define generic cpp_generic
+#endif
+
+//------------------------------------------------------------------------------
+
+// generic_datagram_protocol_socket_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// generic::datagram_socket::socket compile and link correctly. Runtime
+// failures are ignored.
+
+namespace generic_datagram_protocol_socket_compile {
+
+void connect_handler(const boost::system::error_code&)
+{
+}
+
+void send_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void receive_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void test()
+{
+ using namespace boost::asio;
+ namespace generic = boost::asio::generic;
+ typedef generic::datagram_protocol dp;
+
+ const int af_inet = BOOST_ASIO_OS_DEF(AF_INET);
+ const int ipproto_udp = BOOST_ASIO_OS_DEF(IPPROTO_UDP);
+ const int sock_dgram = BOOST_ASIO_OS_DEF(SOCK_DGRAM);
+
+ try
+ {
+ io_context ioc;
+ char mutable_char_buffer[128] = "";
+ const char const_char_buffer[128] = "";
+ socket_base::message_flags in_flags = 0;
+ socket_base::send_buffer_size socket_option;
+ socket_base::bytes_readable io_control_command;
+ boost::system::error_code ec;
+
+ // basic_datagram_socket constructors.
+
+ dp::socket socket1(ioc);
+ dp::socket socket2(ioc, dp(af_inet, ipproto_udp));
+ dp::socket socket3(ioc, dp::endpoint());
+#if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
+ dp::socket::native_handle_type native_socket1
+ = ::socket(af_inet, sock_dgram, 0);
+ dp::socket socket4(ioc, dp(af_inet, ipproto_udp), native_socket1);
+#endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME)
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ dp::socket socket5(std::move(socket4));
+ boost::asio::ip::udp::socket udp_socket(ioc);
+ dp::socket socket6(std::move(udp_socket));
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_datagram_socket operators.
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ socket1 = dp::socket(ioc);
+ socket1 = std::move(socket2);
+ socket1 = boost::asio::ip::udp::socket(ioc);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_io_object functions.
+
+ dp::socket::executor_type ex = socket1.get_executor();
+ (void)ex;
+
+ // basic_socket functions.
+
+ dp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer();
+ (void)lowest_layer;
+
+ socket1.open(dp(af_inet, ipproto_udp));
+ socket1.open(dp(af_inet, ipproto_udp), ec);
+
+#if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
+ dp::socket::native_handle_type native_socket2
+ = ::socket(af_inet, sock_dgram, 0);
+ socket1.assign(dp(af_inet, ipproto_udp), native_socket2);
+ dp::socket::native_handle_type native_socket3
+ = ::socket(af_inet, sock_dgram, 0);
+ socket1.assign(dp(af_inet, ipproto_udp), native_socket3, ec);
+#endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME)
+
+ bool is_open = socket1.is_open();
+ (void)is_open;
+
+ socket1.close();
+ socket1.close(ec);
+
+ dp::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(dp::endpoint());
+ socket1.bind(dp::endpoint(), ec);
+
+ socket1.connect(dp::endpoint());
+ socket1.connect(dp::endpoint(), ec);
+
+ socket1.async_connect(dp::endpoint(), connect_handler);
+
+ 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);
+
+ 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);
+
+ // basic_datagram_socket functions.
+
+ socket1.send(buffer(mutable_char_buffer));
+ socket1.send(buffer(const_char_buffer));
+ socket1.send(null_buffers());
+ 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), send_handler);
+ socket1.async_send(buffer(const_char_buffer), send_handler);
+ socket1.async_send(null_buffers(), send_handler);
+ 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.send_to(buffer(mutable_char_buffer),
+ dp::endpoint());
+ socket1.send_to(buffer(const_char_buffer),
+ dp::endpoint());
+ socket1.send_to(null_buffers(),
+ dp::endpoint());
+ socket1.send_to(buffer(mutable_char_buffer),
+ dp::endpoint(), in_flags);
+ socket1.send_to(buffer(const_char_buffer),
+ dp::endpoint(), in_flags);
+ socket1.send_to(null_buffers(),
+ dp::endpoint(), in_flags);
+ socket1.send_to(buffer(mutable_char_buffer),
+ dp::endpoint(), in_flags, ec);
+ socket1.send_to(buffer(const_char_buffer),
+ dp::endpoint(), in_flags, ec);
+ socket1.send_to(null_buffers(),
+ dp::endpoint(), in_flags, ec);
+
+ socket1.async_send_to(buffer(mutable_char_buffer),
+ dp::endpoint(), send_handler);
+ socket1.async_send_to(buffer(const_char_buffer),
+ dp::endpoint(), send_handler);
+ socket1.async_send_to(null_buffers(),
+ dp::endpoint(), send_handler);
+ socket1.async_send_to(buffer(mutable_char_buffer),
+ dp::endpoint(), in_flags, send_handler);
+ socket1.async_send_to(buffer(const_char_buffer),
+ dp::endpoint(), in_flags, send_handler);
+ socket1.async_send_to(null_buffers(),
+ dp::endpoint(), in_flags, send_handler);
+
+ socket1.receive(buffer(mutable_char_buffer));
+ socket1.receive(null_buffers());
+ socket1.receive(buffer(mutable_char_buffer), in_flags);
+ socket1.receive(null_buffers(), in_flags);
+ socket1.receive(buffer(mutable_char_buffer), in_flags, ec);
+ socket1.receive(null_buffers(), in_flags, ec);
+
+ socket1.async_receive(buffer(mutable_char_buffer), receive_handler);
+ socket1.async_receive(null_buffers(), receive_handler);
+ socket1.async_receive(buffer(mutable_char_buffer), in_flags,
+ receive_handler);
+ socket1.async_receive(null_buffers(), in_flags, receive_handler);
+
+ dp::endpoint endpoint;
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint);
+ socket1.receive_from(null_buffers(), endpoint);
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint, in_flags);
+ socket1.receive_from(null_buffers(), endpoint, in_flags);
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint, in_flags, ec);
+ socket1.receive_from(null_buffers(), endpoint, in_flags, ec);
+
+ socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, receive_handler);
+ socket1.async_receive_from(null_buffers(),
+ endpoint, receive_handler);
+ socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, in_flags, receive_handler);
+ socket1.async_receive_from(null_buffers(),
+ endpoint, in_flags, receive_handler);
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace generic_datagram_protocol_socket_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "generic/datagram_protocol",
+ BOOST_ASIO_TEST_CASE(generic_datagram_protocol_socket_compile::test)
+)
diff --git a/src/boost/libs/asio/test/generic/raw_protocol.cpp b/src/boost/libs/asio/test/generic/raw_protocol.cpp
new file mode 100644
index 000000000..35bb98636
--- /dev/null
+++ b/src/boost/libs/asio/test/generic/raw_protocol.cpp
@@ -0,0 +1,263 @@
+//
+// generic/raw_protocol.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/generic/raw_protocol.hpp>
+
+#include <cstring>
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/ip/icmp.hpp>
+#include "../unit_test.hpp"
+
+#if defined(__cplusplus_cli) || defined(__cplusplus_winrt)
+# define generic cpp_generic
+#endif
+
+//------------------------------------------------------------------------------
+
+// generic_raw_protocol_socket_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// generic::raw_socket::socket compile and link correctly. Runtime failures
+// are ignored.
+
+namespace generic_raw_protocol_socket_compile {
+
+void connect_handler(const boost::system::error_code&)
+{
+}
+
+void send_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void receive_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void test()
+{
+ using namespace boost::asio;
+ namespace generic = boost::asio::generic;
+ typedef generic::raw_protocol rp;
+
+ const int af_inet = BOOST_ASIO_OS_DEF(AF_INET);
+ const int ipproto_icmp = BOOST_ASIO_OS_DEF(IPPROTO_ICMP);
+ const int sock_raw = BOOST_ASIO_OS_DEF(SOCK_RAW);
+
+ try
+ {
+ io_context ioc;
+ char mutable_char_buffer[128] = "";
+ const char const_char_buffer[128] = "";
+ socket_base::message_flags in_flags = 0;
+ socket_base::send_buffer_size socket_option;
+ socket_base::bytes_readable io_control_command;
+ boost::system::error_code ec;
+
+ // basic_raw_socket constructors.
+
+ rp::socket socket1(ioc);
+ rp::socket socket2(ioc, rp(af_inet, ipproto_icmp));
+ rp::socket socket3(ioc, rp::endpoint());
+#if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
+ rp::socket::native_handle_type native_socket1
+ = ::socket(af_inet, sock_raw, 0);
+ rp::socket socket4(ioc, rp(af_inet, ipproto_icmp), native_socket1);
+#endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME)
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ rp::socket socket5(std::move(socket4));
+ boost::asio::ip::icmp::socket icmp_socket(ioc);
+ rp::socket socket6(std::move(icmp_socket));
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_datagram_socket operators.
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ socket1 = rp::socket(ioc);
+ socket1 = std::move(socket2);
+ socket1 = boost::asio::ip::icmp::socket(ioc);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_io_object functions.
+
+ rp::socket::executor_type ex = socket1.get_executor();
+ (void)ex;
+
+ // basic_socket functions.
+
+ rp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer();
+ (void)lowest_layer;
+
+ socket1.open(rp(af_inet, ipproto_icmp));
+ socket1.open(rp(af_inet, ipproto_icmp), ec);
+
+#if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
+ rp::socket::native_handle_type native_socket2
+ = ::socket(af_inet, sock_raw, 0);
+ socket1.assign(rp(af_inet, ipproto_icmp), native_socket2);
+ rp::socket::native_handle_type native_socket3
+ = ::socket(af_inet, sock_raw, 0);
+ socket1.assign(rp(af_inet, ipproto_icmp), native_socket3, ec);
+#endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME)
+
+ bool is_open = socket1.is_open();
+ (void)is_open;
+
+ socket1.close();
+ socket1.close(ec);
+
+ rp::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(rp::endpoint());
+ socket1.bind(rp::endpoint(), ec);
+
+ socket1.connect(rp::endpoint());
+ socket1.connect(rp::endpoint(), ec);
+
+ socket1.async_connect(rp::endpoint(), connect_handler);
+
+ 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);
+
+ 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);
+
+ // basic_raw_socket functions.
+
+ socket1.send(buffer(mutable_char_buffer));
+ socket1.send(buffer(const_char_buffer));
+ socket1.send(null_buffers());
+ 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), send_handler);
+ socket1.async_send(buffer(const_char_buffer), send_handler);
+ socket1.async_send(null_buffers(), send_handler);
+ 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.send_to(buffer(mutable_char_buffer),
+ rp::endpoint());
+ socket1.send_to(buffer(const_char_buffer),
+ rp::endpoint());
+ socket1.send_to(null_buffers(),
+ rp::endpoint());
+ socket1.send_to(buffer(mutable_char_buffer),
+ rp::endpoint(), in_flags);
+ socket1.send_to(buffer(const_char_buffer),
+ rp::endpoint(), in_flags);
+ socket1.send_to(null_buffers(),
+ rp::endpoint(), in_flags);
+ socket1.send_to(buffer(mutable_char_buffer),
+ rp::endpoint(), in_flags, ec);
+ socket1.send_to(buffer(const_char_buffer),
+ rp::endpoint(), in_flags, ec);
+ socket1.send_to(null_buffers(),
+ rp::endpoint(), in_flags, ec);
+
+ socket1.async_send_to(buffer(mutable_char_buffer),
+ rp::endpoint(), send_handler);
+ socket1.async_send_to(buffer(const_char_buffer),
+ rp::endpoint(), send_handler);
+ socket1.async_send_to(null_buffers(),
+ rp::endpoint(), send_handler);
+ socket1.async_send_to(buffer(mutable_char_buffer),
+ rp::endpoint(), in_flags, send_handler);
+ socket1.async_send_to(buffer(const_char_buffer),
+ rp::endpoint(), in_flags, send_handler);
+ socket1.async_send_to(null_buffers(),
+ rp::endpoint(), in_flags, send_handler);
+
+ socket1.receive(buffer(mutable_char_buffer));
+ socket1.receive(null_buffers());
+ socket1.receive(buffer(mutable_char_buffer), in_flags);
+ socket1.receive(null_buffers(), in_flags);
+ socket1.receive(buffer(mutable_char_buffer), in_flags, ec);
+ socket1.receive(null_buffers(), in_flags, ec);
+
+ socket1.async_receive(buffer(mutable_char_buffer), receive_handler);
+ socket1.async_receive(null_buffers(), receive_handler);
+ socket1.async_receive(buffer(mutable_char_buffer), in_flags,
+ receive_handler);
+ socket1.async_receive(null_buffers(), in_flags, receive_handler);
+
+ rp::endpoint endpoint;
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint);
+ socket1.receive_from(null_buffers(), endpoint);
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint, in_flags);
+ socket1.receive_from(null_buffers(), endpoint, in_flags);
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint, in_flags, ec);
+ socket1.receive_from(null_buffers(), endpoint, in_flags, ec);
+
+ socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, receive_handler);
+ socket1.async_receive_from(null_buffers(),
+ endpoint, receive_handler);
+ socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, in_flags, receive_handler);
+ socket1.async_receive_from(null_buffers(),
+ endpoint, in_flags, receive_handler);
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace generic_raw_protocol_socket_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "generic/raw_protocol",
+ BOOST_ASIO_TEST_CASE(generic_raw_protocol_socket_compile::test)
+)
diff --git a/src/boost/libs/asio/test/generic/seq_packet_protocol.cpp b/src/boost/libs/asio/test/generic/seq_packet_protocol.cpp
new file mode 100644
index 000000000..bf6135654
--- /dev/null
+++ b/src/boost/libs/asio/test/generic/seq_packet_protocol.cpp
@@ -0,0 +1,205 @@
+//
+// generic/seq_packet_protocol.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/generic/seq_packet_protocol.hpp>
+
+#include <cstring>
+#include <boost/asio/io_context.hpp>
+#include "../unit_test.hpp"
+
+#if defined(__cplusplus_cli) || defined(__cplusplus_winrt)
+# define generic cpp_generic
+#endif
+
+//------------------------------------------------------------------------------
+
+// generic_seq_packet_protocol_socket_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// generic::seq_packet_socket::socket compile and link correctly. Runtime
+// failures are ignored.
+
+namespace generic_seq_packet_protocol_socket_compile {
+
+void connect_handler(const boost::system::error_code&)
+{
+}
+
+void send_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void receive_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void test()
+{
+ using namespace boost::asio;
+ namespace generic = boost::asio::generic;
+ typedef generic::seq_packet_protocol spp;
+
+ const int af_inet = BOOST_ASIO_OS_DEF(AF_INET);
+ const int sock_seqpacket = BOOST_ASIO_OS_DEF(SOCK_SEQPACKET);
+
+ 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;
+ boost::system::error_code ec;
+
+ // basic_seq_packet_socket constructors.
+
+ spp::socket socket1(ioc);
+ spp::socket socket2(ioc, spp(af_inet, 0));
+ spp::socket socket3(ioc, spp::endpoint());
+#if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
+ spp::socket::native_handle_type native_socket1
+ = ::socket(af_inet, sock_seqpacket, 0);
+ spp::socket socket4(ioc, spp(af_inet, 0), native_socket1);
+#endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME)
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ spp::socket socket5(std::move(socket4));
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_seq_packet_socket operators.
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ socket1 = spp::socket(ioc);
+ socket1 = std::move(socket2);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // 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(af_inet, 0));
+ socket1.open(spp(af_inet, 0), ec);
+
+#if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
+ spp::socket::native_handle_type native_socket2
+ = ::socket(af_inet, sock_seqpacket, 0);
+ socket1.assign(spp(af_inet, 0), native_socket2);
+ spp::socket::native_handle_type native_socket3
+ = ::socket(af_inet, sock_seqpacket, 0);
+ socket1.assign(spp(af_inet, 0), native_socket3, ec);
+#endif // !defined(BOOST_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.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.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);
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace generic_seq_packet_protocol_socket_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "generic/seq_packet_protocol",
+ BOOST_ASIO_TEST_CASE(generic_seq_packet_protocol_socket_compile::test)
+)
diff --git a/src/boost/libs/asio/test/generic/stream_protocol.cpp b/src/boost/libs/asio/test/generic/stream_protocol.cpp
new file mode 100644
index 000000000..23176677b
--- /dev/null
+++ b/src/boost/libs/asio/test/generic/stream_protocol.cpp
@@ -0,0 +1,248 @@
+//
+// generic/stream_protocol.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/generic/stream_protocol.hpp>
+
+#include <cstring>
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/ip/tcp.hpp>
+#include "../unit_test.hpp"
+
+#if defined(__cplusplus_cli) || defined(__cplusplus_winrt)
+# define generic cpp_generic
+#endif
+
+//------------------------------------------------------------------------------
+
+// generic_stream_protocol_socket_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// generic::stream_protocol::socket compile and link correctly. Runtime
+// failures are ignored.
+
+namespace generic_stream_protocol_socket_compile {
+
+void connect_handler(const boost::system::error_code&)
+{
+}
+
+void send_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void receive_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void write_some_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void read_some_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void test()
+{
+ using namespace boost::asio;
+ namespace generic = boost::asio::generic;
+ typedef generic::stream_protocol sp;
+
+ const int af_inet = BOOST_ASIO_OS_DEF(AF_INET);
+ const int ipproto_tcp = BOOST_ASIO_OS_DEF(IPPROTO_TCP);
+ const int sock_stream = BOOST_ASIO_OS_DEF(SOCK_STREAM);
+
+ try
+ {
+ io_context ioc;
+ char mutable_char_buffer[128] = "";
+ const char const_char_buffer[128] = "";
+ socket_base::message_flags in_flags = 0;
+ socket_base::keep_alive socket_option;
+ socket_base::bytes_readable io_control_command;
+ boost::system::error_code ec;
+
+ // basic_stream_socket constructors.
+
+ sp::socket socket1(ioc);
+ sp::socket socket2(ioc, sp(af_inet, ipproto_tcp));
+ sp::socket socket3(ioc, sp::endpoint());
+#if defined(BOOST_ASIO_WINDOWS_RUNTIME)
+ Windows::Networking::Sockets::StreamSocket^ native_socket1 = nullptr;
+#else // defined(BOOST_ASIO_WINDOWS_RUNTIME)
+ sp::socket::native_handle_type native_socket1
+ = ::socket(af_inet, sock_stream, 0);
+#endif // defined(BOOST_ASIO_WINDOWS_RUNTIME)
+ sp::socket socket4(ioc, sp(af_inet, ipproto_tcp), native_socket1);
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ sp::socket socket5(std::move(socket4));
+ boost::asio::ip::tcp::socket tcp_socket(ioc);
+ sp::socket socket6(std::move(tcp_socket));
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_stream_socket operators.
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ socket1 = sp::socket(ioc);
+ socket1 = std::move(socket2);
+ socket1 = boost::asio::ip::tcp::socket(ioc);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_io_object functions.
+
+ sp::socket::executor_type ex = socket1.get_executor();
+ (void)ex;
+
+ // basic_socket functions.
+
+ sp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer();
+ (void)lowest_layer;
+
+ socket1.open(sp(af_inet, ipproto_tcp));
+ socket1.open(sp(af_inet, ipproto_tcp), ec);
+
+#if defined(BOOST_ASIO_WINDOWS_RUNTIME)
+ Windows::Networking::Sockets::StreamSocket^ native_socket2 = nullptr;
+#else // defined(BOOST_ASIO_WINDOWS_RUNTIME)
+ sp::socket::native_handle_type native_socket2
+ = ::socket(af_inet, sock_stream, 0);
+#endif // defined(BOOST_ASIO_WINDOWS_RUNTIME)
+ socket1.assign(sp(af_inet, ipproto_tcp), native_socket2);
+#if defined(BOOST_ASIO_WINDOWS_RUNTIME)
+ Windows::Networking::Sockets::StreamSocket^ native_socket3 = nullptr;
+#else // defined(BOOST_ASIO_WINDOWS_RUNTIME)
+ sp::socket::native_handle_type native_socket3
+ = ::socket(af_inet, sock_stream, 0);
+#endif // defined(BOOST_ASIO_WINDOWS_RUNTIME)
+ socket1.assign(sp(af_inet, ipproto_tcp), native_socket3, ec);
+
+ bool is_open = socket1.is_open();
+ (void)is_open;
+
+ socket1.close();
+ socket1.close(ec);
+
+ sp::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(sp::endpoint());
+ socket1.bind(sp::endpoint(), ec);
+
+ socket1.connect(sp::endpoint());
+ socket1.connect(sp::endpoint(), ec);
+
+ socket1.async_connect(sp::endpoint(), connect_handler);
+
+ 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);
+
+ 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);
+
+ // basic_stream_socket functions.
+
+ socket1.send(buffer(mutable_char_buffer));
+ socket1.send(buffer(const_char_buffer));
+ socket1.send(null_buffers());
+ 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), send_handler);
+ socket1.async_send(buffer(const_char_buffer), send_handler);
+ socket1.async_send(null_buffers(), send_handler);
+ 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.receive(buffer(mutable_char_buffer));
+ socket1.receive(null_buffers());
+ socket1.receive(buffer(mutable_char_buffer), in_flags);
+ socket1.receive(null_buffers(), in_flags);
+ socket1.receive(buffer(mutable_char_buffer), in_flags, ec);
+ socket1.receive(null_buffers(), in_flags, ec);
+
+ socket1.async_receive(buffer(mutable_char_buffer), receive_handler);
+ socket1.async_receive(null_buffers(), receive_handler);
+ socket1.async_receive(buffer(mutable_char_buffer), in_flags,
+ receive_handler);
+ socket1.async_receive(null_buffers(), in_flags, receive_handler);
+
+ socket1.write_some(buffer(mutable_char_buffer));
+ socket1.write_some(buffer(const_char_buffer));
+ socket1.write_some(null_buffers());
+ socket1.write_some(buffer(mutable_char_buffer), ec);
+ socket1.write_some(buffer(const_char_buffer), ec);
+ socket1.write_some(null_buffers(), ec);
+
+ 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.read_some(buffer(mutable_char_buffer));
+ socket1.read_some(buffer(mutable_char_buffer), ec);
+ socket1.read_some(null_buffers(), ec);
+
+ socket1.async_read_some(buffer(mutable_char_buffer), read_some_handler);
+ socket1.async_read_some(null_buffers(), read_some_handler);
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace generic_stream_protocol_socket_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "generic/stream_protocol",
+ BOOST_ASIO_TEST_CASE(generic_stream_protocol_socket_compile::test)
+)
diff --git a/src/boost/libs/asio/test/high_resolution_timer.cpp b/src/boost/libs/asio/test/high_resolution_timer.cpp
new file mode 100644
index 000000000..a667f872c
--- /dev/null
+++ b/src/boost/libs/asio/test/high_resolution_timer.cpp
@@ -0,0 +1,30 @@
+//
+// high_resolution_timer.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/high_resolution_timer.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "high_resolution_timer",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/io_context.cpp b/src/boost/libs/asio/test/io_context.cpp
new file mode 100644
index 000000000..7b2ff982f
--- /dev/null
+++ b/src/boost/libs/asio/test/io_context.cpp
@@ -0,0 +1,362 @@
+//
+// io_context.cpp
+// ~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/io_context.hpp>
+
+#include <sstream>
+#include <boost/asio/bind_executor.hpp>
+#include <boost/asio/dispatch.hpp>
+#include <boost/asio/post.hpp>
+#include <boost/asio/detail/thread.hpp>
+#include "unit_test.hpp"
+
+#if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+# include <boost/asio/deadline_timer.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+# include <boost/asio/steady_timer.hpp>
+#endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <boost/bind/bind.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <functional>
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+
+using namespace boost::asio;
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+namespace bindns = std;
+#endif
+
+#if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+typedef deadline_timer timer;
+namespace chronons = boost::posix_time;
+#elif defined(BOOST_ASIO_HAS_CHRONO)
+typedef steady_timer timer;
+namespace chronons = boost::asio::chrono;
+#endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+
+void increment(int* count)
+{
+ ++(*count);
+}
+
+void decrement_to_zero(io_context* ioc, int* count)
+{
+ if (*count > 0)
+ {
+ --(*count);
+
+ int before_value = *count;
+ boost::asio::post(*ioc, bindns::bind(decrement_to_zero, ioc, count));
+
+ // Handler execution cannot nest, so count value should remain unchanged.
+ BOOST_ASIO_CHECK(*count == before_value);
+ }
+}
+
+void nested_decrement_to_zero(io_context* ioc, int* count)
+{
+ if (*count > 0)
+ {
+ --(*count);
+
+ boost::asio::dispatch(*ioc,
+ bindns::bind(nested_decrement_to_zero, ioc, count));
+
+ // Handler execution is nested, so count value should now be zero.
+ BOOST_ASIO_CHECK(*count == 0);
+ }
+}
+
+void sleep_increment(io_context* ioc, int* count)
+{
+ timer t(*ioc, chronons::seconds(2));
+ t.wait();
+
+ if (++(*count) < 3)
+ boost::asio::post(*ioc, bindns::bind(sleep_increment, ioc, count));
+}
+
+void start_sleep_increments(io_context* ioc, int* count)
+{
+ // Give all threads a chance to start.
+ timer t(*ioc, chronons::seconds(2));
+ t.wait();
+
+ // Start the first of three increments.
+ boost::asio::post(*ioc, bindns::bind(sleep_increment, ioc, count));
+}
+
+void throw_exception()
+{
+ throw 1;
+}
+
+void io_context_run(io_context* ioc)
+{
+ ioc->run();
+}
+
+void io_context_test()
+{
+ io_context ioc;
+ int count = 0;
+
+ boost::asio::post(ioc, bindns::bind(increment, &count));
+
+ // No handlers can be called until run() is called.
+ BOOST_ASIO_CHECK(!ioc.stopped());
+ BOOST_ASIO_CHECK(count == 0);
+
+ ioc.run();
+
+ // The run() call will not return until all work has finished.
+ BOOST_ASIO_CHECK(ioc.stopped());
+ BOOST_ASIO_CHECK(count == 1);
+
+ count = 0;
+ ioc.restart();
+ boost::asio::post(ioc, bindns::bind(increment, &count));
+ boost::asio::post(ioc, bindns::bind(increment, &count));
+ boost::asio::post(ioc, bindns::bind(increment, &count));
+ boost::asio::post(ioc, bindns::bind(increment, &count));
+ boost::asio::post(ioc, bindns::bind(increment, &count));
+
+ // No handlers can be called until run() is called.
+ BOOST_ASIO_CHECK(!ioc.stopped());
+ BOOST_ASIO_CHECK(count == 0);
+
+ ioc.run();
+
+ // The run() call will not return until all work has finished.
+ BOOST_ASIO_CHECK(ioc.stopped());
+ BOOST_ASIO_CHECK(count == 5);
+
+ count = 0;
+ ioc.restart();
+ executor_work_guard<io_context::executor_type> w = make_work_guard(ioc);
+ boost::asio::post(ioc, bindns::bind(&io_context::stop, &ioc));
+ BOOST_ASIO_CHECK(!ioc.stopped());
+ ioc.run();
+
+ // The only operation executed should have been to stop run().
+ BOOST_ASIO_CHECK(ioc.stopped());
+ BOOST_ASIO_CHECK(count == 0);
+
+ ioc.restart();
+ boost::asio::post(ioc, bindns::bind(increment, &count));
+ w.reset();
+
+ // No handlers can be called until run() is called.
+ BOOST_ASIO_CHECK(!ioc.stopped());
+ BOOST_ASIO_CHECK(count == 0);
+
+ ioc.run();
+
+ // The run() call will not return until all work has finished.
+ BOOST_ASIO_CHECK(ioc.stopped());
+ BOOST_ASIO_CHECK(count == 1);
+
+ count = 10;
+ ioc.restart();
+ boost::asio::post(ioc, bindns::bind(decrement_to_zero, &ioc, &count));
+
+ // No handlers can be called until run() is called.
+ BOOST_ASIO_CHECK(!ioc.stopped());
+ BOOST_ASIO_CHECK(count == 10);
+
+ ioc.run();
+
+ // The run() call will not return until all work has finished.
+ BOOST_ASIO_CHECK(ioc.stopped());
+ BOOST_ASIO_CHECK(count == 0);
+
+ count = 10;
+ ioc.restart();
+ boost::asio::post(ioc, bindns::bind(nested_decrement_to_zero, &ioc, &count));
+
+ // No handlers can be called until run() is called.
+ BOOST_ASIO_CHECK(!ioc.stopped());
+ BOOST_ASIO_CHECK(count == 10);
+
+ ioc.run();
+
+ // The run() call will not return until all work has finished.
+ BOOST_ASIO_CHECK(ioc.stopped());
+ BOOST_ASIO_CHECK(count == 0);
+
+ count = 10;
+ ioc.restart();
+ boost::asio::dispatch(ioc,
+ bindns::bind(nested_decrement_to_zero, &ioc, &count));
+
+ // No handlers can be called until run() is called, even though nested
+ // delivery was specifically allowed in the previous call.
+ BOOST_ASIO_CHECK(!ioc.stopped());
+ BOOST_ASIO_CHECK(count == 10);
+
+ ioc.run();
+
+ // The run() call will not return until all work has finished.
+ BOOST_ASIO_CHECK(ioc.stopped());
+ BOOST_ASIO_CHECK(count == 0);
+
+ count = 0;
+ int count2 = 0;
+ ioc.restart();
+ BOOST_ASIO_CHECK(!ioc.stopped());
+ boost::asio::post(ioc, bindns::bind(start_sleep_increments, &ioc, &count));
+ boost::asio::post(ioc, bindns::bind(start_sleep_increments, &ioc, &count2));
+ boost::asio::detail::thread thread1(bindns::bind(io_context_run, &ioc));
+ boost::asio::detail::thread thread2(bindns::bind(io_context_run, &ioc));
+ thread1.join();
+ thread2.join();
+
+ // The run() calls will not return until all work has finished.
+ BOOST_ASIO_CHECK(ioc.stopped());
+ BOOST_ASIO_CHECK(count == 3);
+ BOOST_ASIO_CHECK(count2 == 3);
+
+ count = 10;
+ io_context ioc2;
+ boost::asio::dispatch(ioc, boost::asio::bind_executor(ioc2,
+ bindns::bind(decrement_to_zero, &ioc2, &count)));
+ ioc.restart();
+ BOOST_ASIO_CHECK(!ioc.stopped());
+ ioc.run();
+
+ // No decrement_to_zero handlers can be called until run() is called on the
+ // second io_context object.
+ BOOST_ASIO_CHECK(ioc.stopped());
+ BOOST_ASIO_CHECK(count == 10);
+
+ ioc2.run();
+
+ // The run() call will not return until all work has finished.
+ BOOST_ASIO_CHECK(count == 0);
+
+ count = 0;
+ int exception_count = 0;
+ ioc.restart();
+ boost::asio::post(ioc, &throw_exception);
+ boost::asio::post(ioc, bindns::bind(increment, &count));
+ boost::asio::post(ioc, bindns::bind(increment, &count));
+ boost::asio::post(ioc, &throw_exception);
+ boost::asio::post(ioc, bindns::bind(increment, &count));
+
+ // No handlers can be called until run() is called.
+ BOOST_ASIO_CHECK(!ioc.stopped());
+ BOOST_ASIO_CHECK(count == 0);
+ BOOST_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.
+ BOOST_ASIO_CHECK(ioc.stopped());
+ BOOST_ASIO_CHECK(count == 3);
+ BOOST_ASIO_CHECK(exception_count == 2);
+}
+
+class test_service : public boost::asio::io_context::service
+{
+public:
+ static boost::asio::io_context::id id;
+ test_service(boost::asio::io_context& s)
+ : boost::asio::io_context::service(s) {}
+private:
+ virtual void shutdown_service() {}
+};
+
+boost::asio::io_context::id test_service::id;
+
+void io_context_service_test()
+{
+ boost::asio::io_context ioc1;
+ boost::asio::io_context ioc2;
+ boost::asio::io_context ioc3;
+
+ // Implicit service registration.
+
+ boost::asio::use_service<test_service>(ioc1);
+
+ BOOST_ASIO_CHECK(boost::asio::has_service<test_service>(ioc1));
+
+ test_service* svc1 = new test_service(ioc1);
+ try
+ {
+ boost::asio::add_service(ioc1, svc1);
+ BOOST_ASIO_ERROR("add_service did not throw");
+ }
+ catch (boost::asio::service_already_exists&)
+ {
+ }
+ delete svc1;
+
+ // Explicit service registration.
+
+ test_service* svc2 = new test_service(ioc2);
+ boost::asio::add_service(ioc2, svc2);
+
+ BOOST_ASIO_CHECK(boost::asio::has_service<test_service>(ioc2));
+ BOOST_ASIO_CHECK(&boost::asio::use_service<test_service>(ioc2) == svc2);
+
+ test_service* svc3 = new test_service(ioc2);
+ try
+ {
+ boost::asio::add_service(ioc2, svc3);
+ BOOST_ASIO_ERROR("add_service did not throw");
+ }
+ catch (boost::asio::service_already_exists&)
+ {
+ }
+ delete svc3;
+
+ // Explicit registration with invalid owner.
+
+ test_service* svc4 = new test_service(ioc2);
+ try
+ {
+ boost::asio::add_service(ioc3, svc4);
+ BOOST_ASIO_ERROR("add_service did not throw");
+ }
+ catch (boost::asio::invalid_service_owner&)
+ {
+ }
+ delete svc4;
+
+ BOOST_ASIO_CHECK(!boost::asio::has_service<test_service>(ioc3));
+}
+
+BOOST_ASIO_TEST_SUITE
+(
+ "io_context",
+ BOOST_ASIO_TEST_CASE(io_context_test)
+ BOOST_ASIO_TEST_CASE(io_context_service_test)
+)
diff --git a/src/boost/libs/asio/test/io_context_strand.cpp b/src/boost/libs/asio/test/io_context_strand.cpp
new file mode 100644
index 000000000..fec4f3765
--- /dev/null
+++ b/src/boost/libs/asio/test/io_context_strand.cpp
@@ -0,0 +1,325 @@
+//
+// io_context_strand.cpp
+// ~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/io_context_strand.hpp>
+
+#include <sstream>
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/dispatch.hpp>
+#include <boost/asio/post.hpp>
+#include <boost/asio/detail/thread.hpp>
+#include "unit_test.hpp"
+
+#if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+# include <boost/asio/deadline_timer.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+# include <boost/asio/steady_timer.hpp>
+#endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <boost/bind/bind.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <functional>
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+
+using namespace boost::asio;
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+namespace bindns = std;
+#endif
+
+#if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+typedef deadline_timer timer;
+namespace chronons = boost::posix_time;
+#elif defined(BOOST_ASIO_HAS_CHRONO)
+typedef steady_timer timer;
+namespace chronons = boost::asio::chrono;
+#endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+
+void increment(int* count)
+{
+ ++(*count);
+}
+
+void increment_without_lock(io_context::strand* s, int* count)
+{
+ BOOST_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.
+ BOOST_ASIO_CHECK(*count == original_count + 1);
+}
+
+void increment_with_lock(io_context::strand* s, int* count)
+{
+ BOOST_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.
+ BOOST_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.
+ BOOST_ASIO_CHECK(count == 0);
+
+ ioc.run();
+
+ // The run() call will not return until all work has finished.
+ BOOST_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.
+ BOOST_ASIO_CHECK(count == 0);
+
+ ioc.run();
+
+ // The run() call will not return until all work has finished.
+ BOOST_ASIO_CHECK(count == 1);
+
+ count = 0;
+ ioc.restart();
+ post(ioc, bindns::bind(start_sleep_increments, &ioc, &s, &count));
+ boost::asio::detail::thread thread1(bindns::bind(io_context_run, &ioc));
+ boost::asio::detail::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();
+ BOOST_ASIO_CHECK(count == 0);
+#if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+ timer1.expires_at(timer1.expires_at() + chronons::seconds(2));
+#else // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+ timer1.expires_at(timer1.expiry() + chronons::seconds(2));
+#endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+ timer1.wait();
+ BOOST_ASIO_CHECK(count == 1);
+#if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+ timer1.expires_at(timer1.expires_at() + chronons::seconds(2));
+#else // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+ timer1.expires_at(timer1.expiry() + chronons::seconds(2));
+#endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+ timer1.wait();
+ BOOST_ASIO_CHECK(count == 2);
+
+ thread1.join();
+ thread2.join();
+
+ // The run() calls will not return until all work has finished.
+ BOOST_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.
+ BOOST_ASIO_CHECK(count == 0);
+ BOOST_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.
+ BOOST_ASIO_CHECK(count == 3);
+ BOOST_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.
+ BOOST_ASIO_CHECK(count == 0);
+}
+
+void strand_wrap_test()
+{
+#if !defined(BOOST_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.
+ BOOST_ASIO_CHECK(count == 0);
+
+ ioc.restart();
+ ioc.run();
+
+ // The run() calls will not return until all work has finished.
+ BOOST_ASIO_CHECK(count == 1);
+
+ count = 0;
+ s.wrap(increment)(&count);
+
+ // No handlers can be called until run() is called.
+ BOOST_ASIO_CHECK(count == 0);
+
+ ioc.restart();
+ ioc.run();
+
+ // The run() calls will not return until all work has finished.
+ BOOST_ASIO_CHECK(count == 1);
+
+ count = 0;
+ s.wrap(increment_by_a)(&count, 1);
+
+ // No handlers can be called until run() is called.
+ BOOST_ASIO_CHECK(count == 0);
+
+ ioc.restart();
+ ioc.run();
+
+ // The run() calls will not return until all work has finished.
+ BOOST_ASIO_CHECK(count == 1);
+
+ count = 0;
+ s.wrap(increment_by_a_b)(&count, 1, 2);
+
+ // No handlers can be called until run() is called.
+ BOOST_ASIO_CHECK(count == 0);
+
+ ioc.restart();
+ ioc.run();
+
+ // The run() calls will not return until all work has finished.
+ BOOST_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.
+ BOOST_ASIO_CHECK(count == 0);
+
+ ioc.restart();
+ ioc.run();
+
+ // The run() calls will not return until all work has finished.
+ BOOST_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.
+ BOOST_ASIO_CHECK(count == 0);
+
+ ioc.restart();
+ ioc.run();
+
+ // The run() calls will not return until all work has finished.
+ BOOST_ASIO_CHECK(count == 10);
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+}
+
+BOOST_ASIO_TEST_SUITE
+(
+ "strand",
+ BOOST_ASIO_TEST_CASE(strand_test)
+ BOOST_ASIO_TEST_CASE(strand_wrap_test)
+)
diff --git a/src/boost/libs/asio/test/ip/address.cpp b/src/boost/libs/asio/test/ip/address.cpp
new file mode 100644
index 000000000..c4fc82267
--- /dev/null
+++ b/src/boost/libs/asio/test/ip/address.cpp
@@ -0,0 +1,144 @@
+//
+// address.cpp
+// ~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ip/address.hpp>
+
+#include "../unit_test.hpp"
+#include <sstream>
+
+//------------------------------------------------------------------------------
+
+// ip_address_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// ip::address compile and link correctly. Runtime failures are ignored.
+
+namespace ip_address_compile {
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ try
+ {
+ boost::system::error_code ec;
+
+ // address constructors.
+
+ ip::address addr1;
+ const ip::address_v4 const_addr_v4;
+ ip::address addr2(const_addr_v4);
+ const ip::address_v6 const_addr_v6;
+ ip::address addr3(const_addr_v6);
+
+ // address functions.
+
+ bool b = addr1.is_v4();
+ (void)b;
+
+ b = addr1.is_v6();
+ (void)b;
+
+ b = addr1.is_loopback();
+ (void)b;
+
+ b = addr1.is_unspecified();
+ (void)b;
+
+ b = addr1.is_multicast();
+ (void)b;
+
+ ip::address_v4 addr_v4_value = addr1.to_v4();
+ (void)addr_v4_value;
+
+ ip::address_v6 addr_v6_value = addr1.to_v6();
+ (void)addr_v6_value;
+
+ std::string string_value = addr1.to_string();
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ string_value = addr1.to_string(ec);
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ // address static functions.
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ addr1 = ip::address::from_string("127.0.0.1");
+ addr1 = ip::address::from_string("127.0.0.1", ec);
+ addr1 = ip::address::from_string(string_value);
+ addr1 = ip::address::from_string(string_value, ec);
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ // address comparisons.
+
+ b = (addr1 == addr2);
+ (void)b;
+
+ b = (addr1 != addr2);
+ (void)b;
+
+ b = (addr1 < addr2);
+ (void)b;
+
+ b = (addr1 > addr2);
+ (void)b;
+
+ b = (addr1 <= addr2);
+ (void)b;
+
+ b = (addr1 >= addr2);
+ (void)b;
+
+ // address creation functions.
+
+ addr1 = ip::make_address("127.0.0.1");
+ addr1 = ip::make_address("127.0.0.1", ec);
+ addr1 = ip::make_address(string_value);
+ addr1 = ip::make_address(string_value, ec);
+#if defined(BOOST_ASIO_HAS_STRING_VIEW)
+# if defined(BOOST_ASIO_HAS_STD_STRING_VIEW)
+ std::string_view string_view_value("127.0.0.1");
+# elif defined(BOOST_ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
+ std::experimental::string_view string_view_value("127.0.0.1");
+# endif // defined(BOOST_ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
+ addr1 = ip::make_address(string_view_value);
+ addr1 = ip::make_address(string_view_value, ec);
+#endif // defined(BOOST_ASIO_HAS_STRING_VIEW)
+
+ // address I/O.
+
+ std::ostringstream os;
+ os << addr1;
+
+#if !defined(BOOST_NO_STD_WSTREAMBUF)
+ std::wostringstream wos;
+ wos << addr1;
+#endif // !defined(BOOST_NO_STD_WSTREAMBUF)
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace ip_address_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ip/address",
+ BOOST_ASIO_TEST_CASE(ip_address_compile::test)
+)
diff --git a/src/boost/libs/asio/test/ip/address_v4.cpp b/src/boost/libs/asio/test/ip/address_v4.cpp
new file mode 100644
index 000000000..abe0c34a4
--- /dev/null
+++ b/src/boost/libs/asio/test/ip/address_v4.cpp
@@ -0,0 +1,324 @@
+//
+// address_v4.cpp
+// ~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ip/address_v4.hpp>
+
+#include "../unit_test.hpp"
+#include <sstream>
+
+//------------------------------------------------------------------------------
+
+// ip_address_v4_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// ip::address_v4 compile and link correctly. Runtime failures are ignored.
+
+namespace ip_address_v4_compile {
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ try
+ {
+ boost::system::error_code ec;
+
+ // address_v4 constructors.
+
+ ip::address_v4 addr1;
+ const ip::address_v4::bytes_type const_bytes_value = { { 127, 0, 0, 1 } };
+ ip::address_v4 addr2(const_bytes_value);
+ const unsigned long const_ulong_value = 0x7F000001;
+ ip::address_v4 addr3(const_ulong_value);
+
+ // address_v4 functions.
+
+ bool b = addr1.is_loopback();
+ (void)b;
+
+ b = addr1.is_unspecified();
+ (void)b;
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ b = addr1.is_class_a();
+ (void)b;
+
+ b = addr1.is_class_b();
+ (void)b;
+
+ b = addr1.is_class_c();
+ (void)b;
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ b = addr1.is_multicast();
+ (void)b;
+
+ ip::address_v4::bytes_type bytes_value = addr1.to_bytes();
+ (void)bytes_value;
+
+ ip::address_v4::uint_type uint_value = addr1.to_uint();
+ (void)uint_value;
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ unsigned long ulong_value = addr1.to_ulong();
+ (void)ulong_value;
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ std::string string_value = addr1.to_string();
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ string_value = addr1.to_string(ec);
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ // address_v4 static functions.
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ addr1 = ip::address_v4::from_string("127.0.0.1");
+ addr1 = ip::address_v4::from_string("127.0.0.1", ec);
+ addr1 = ip::address_v4::from_string(string_value);
+ addr1 = ip::address_v4::from_string(string_value, ec);
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ addr1 = ip::address_v4::any();
+
+ addr1 = ip::address_v4::loopback();
+
+ addr1 = ip::address_v4::broadcast();
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ addr1 = ip::address_v4::broadcast(addr2, addr3);
+
+ addr1 = ip::address_v4::netmask(addr2);
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ // address_v4 comparisons.
+
+ b = (addr1 == addr2);
+ (void)b;
+
+ b = (addr1 != addr2);
+ (void)b;
+
+ b = (addr1 < addr2);
+ (void)b;
+
+ b = (addr1 > addr2);
+ (void)b;
+
+ b = (addr1 <= addr2);
+ (void)b;
+
+ b = (addr1 >= addr2);
+ (void)b;
+
+ // address_v4 creation functions.
+
+ addr1 = ip::make_address_v4(const_bytes_value);
+ addr1 = ip::make_address_v4(const_ulong_value);
+ addr1 = ip::make_address_v4("127.0.0.1");
+ 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(BOOST_ASIO_HAS_STRING_VIEW)
+# if defined(BOOST_ASIO_HAS_STD_STRING_VIEW)
+ std::string_view string_view_value("127.0.0.1");
+# elif defined(BOOST_ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
+ std::experimental::string_view string_view_value("127.0.0.1");
+# endif // defined(BOOST_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(BOOST_ASIO_HAS_STRING_VIEW)
+
+ // address_v4 I/O.
+
+ std::ostringstream os;
+ os << addr1;
+
+#if !defined(BOOST_NO_STD_WSTREAMBUF)
+ std::wostringstream wos;
+ wos << addr1;
+#endif // !defined(BOOST_NO_STD_WSTREAMBUF)
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace ip_address_v4_compile
+
+//------------------------------------------------------------------------------
+
+// ip_address_v4_runtime test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that the various public member functions meet the
+// necessary postconditions.
+
+namespace ip_address_v4_runtime {
+
+void test()
+{
+ using boost::asio::ip::address_v4;
+
+ address_v4 a1;
+ BOOST_ASIO_CHECK(a1.to_bytes()[0] == 0);
+ BOOST_ASIO_CHECK(a1.to_bytes()[1] == 0);
+ BOOST_ASIO_CHECK(a1.to_bytes()[2] == 0);
+ BOOST_ASIO_CHECK(a1.to_bytes()[3] == 0);
+ BOOST_ASIO_CHECK(a1.to_uint() == 0);
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ BOOST_ASIO_CHECK(a1.to_ulong() == 0);
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ address_v4::bytes_type b1 = {{ 1, 2, 3, 4 }};
+ address_v4 a2(b1);
+ BOOST_ASIO_CHECK(a2.to_bytes()[0] == 1);
+ BOOST_ASIO_CHECK(a2.to_bytes()[1] == 2);
+ BOOST_ASIO_CHECK(a2.to_bytes()[2] == 3);
+ BOOST_ASIO_CHECK(a2.to_bytes()[3] == 4);
+ BOOST_ASIO_CHECK(((a2.to_uint() >> 24) & 0xFF) == b1[0]);
+ BOOST_ASIO_CHECK(((a2.to_uint() >> 16) & 0xFF) == b1[1]);
+ BOOST_ASIO_CHECK(((a2.to_uint() >> 8) & 0xFF) == b1[2]);
+ BOOST_ASIO_CHECK((a2.to_uint() & 0xFF) == b1[3]);
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ BOOST_ASIO_CHECK(((a2.to_ulong() >> 24) & 0xFF) == b1[0]);
+ BOOST_ASIO_CHECK(((a2.to_ulong() >> 16) & 0xFF) == b1[1]);
+ BOOST_ASIO_CHECK(((a2.to_ulong() >> 8) & 0xFF) == b1[2]);
+ BOOST_ASIO_CHECK((a2.to_ulong() & 0xFF) == b1[3]);
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ address_v4 a3(0x01020304);
+ BOOST_ASIO_CHECK(a3.to_bytes()[0] == 1);
+ BOOST_ASIO_CHECK(a3.to_bytes()[1] == 2);
+ BOOST_ASIO_CHECK(a3.to_bytes()[2] == 3);
+ BOOST_ASIO_CHECK(a3.to_bytes()[3] == 4);
+ BOOST_ASIO_CHECK(a3.to_uint() == 0x01020304);
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ BOOST_ASIO_CHECK(a3.to_ulong() == 0x01020304);
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ BOOST_ASIO_CHECK(address_v4(0x7F000001).is_loopback());
+ BOOST_ASIO_CHECK(address_v4(0x7F000002).is_loopback());
+ BOOST_ASIO_CHECK(!address_v4(0x00000000).is_loopback());
+ BOOST_ASIO_CHECK(!address_v4(0x01020304).is_loopback());
+
+ BOOST_ASIO_CHECK(address_v4(0x00000000).is_unspecified());
+ BOOST_ASIO_CHECK(!address_v4(0x7F000001).is_unspecified());
+ BOOST_ASIO_CHECK(!address_v4(0x01020304).is_unspecified());
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ BOOST_ASIO_CHECK(address_v4(0x01000000).is_class_a());
+ BOOST_ASIO_CHECK(address_v4(0x7F000000).is_class_a());
+ BOOST_ASIO_CHECK(!address_v4(0x80000000).is_class_a());
+ BOOST_ASIO_CHECK(!address_v4(0xBFFF0000).is_class_a());
+ BOOST_ASIO_CHECK(!address_v4(0xC0000000).is_class_a());
+ BOOST_ASIO_CHECK(!address_v4(0xDFFFFF00).is_class_a());
+ BOOST_ASIO_CHECK(!address_v4(0xE0000000).is_class_a());
+ BOOST_ASIO_CHECK(!address_v4(0xEFFFFFFF).is_class_a());
+ BOOST_ASIO_CHECK(!address_v4(0xF0000000).is_class_a());
+ BOOST_ASIO_CHECK(!address_v4(0xFFFFFFFF).is_class_a());
+
+ BOOST_ASIO_CHECK(!address_v4(0x01000000).is_class_b());
+ BOOST_ASIO_CHECK(!address_v4(0x7F000000).is_class_b());
+ BOOST_ASIO_CHECK(address_v4(0x80000000).is_class_b());
+ BOOST_ASIO_CHECK(address_v4(0xBFFF0000).is_class_b());
+ BOOST_ASIO_CHECK(!address_v4(0xC0000000).is_class_b());
+ BOOST_ASIO_CHECK(!address_v4(0xDFFFFF00).is_class_b());
+ BOOST_ASIO_CHECK(!address_v4(0xE0000000).is_class_b());
+ BOOST_ASIO_CHECK(!address_v4(0xEFFFFFFF).is_class_b());
+ BOOST_ASIO_CHECK(!address_v4(0xF0000000).is_class_b());
+ BOOST_ASIO_CHECK(!address_v4(0xFFFFFFFF).is_class_b());
+
+ BOOST_ASIO_CHECK(!address_v4(0x01000000).is_class_c());
+ BOOST_ASIO_CHECK(!address_v4(0x7F000000).is_class_c());
+ BOOST_ASIO_CHECK(!address_v4(0x80000000).is_class_c());
+ BOOST_ASIO_CHECK(!address_v4(0xBFFF0000).is_class_c());
+ BOOST_ASIO_CHECK(address_v4(0xC0000000).is_class_c());
+ BOOST_ASIO_CHECK(address_v4(0xDFFFFF00).is_class_c());
+ BOOST_ASIO_CHECK(!address_v4(0xE0000000).is_class_c());
+ BOOST_ASIO_CHECK(!address_v4(0xEFFFFFFF).is_class_c());
+ BOOST_ASIO_CHECK(!address_v4(0xF0000000).is_class_c());
+ BOOST_ASIO_CHECK(!address_v4(0xFFFFFFFF).is_class_c());
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ BOOST_ASIO_CHECK(!address_v4(0x01000000).is_multicast());
+ BOOST_ASIO_CHECK(!address_v4(0x7F000000).is_multicast());
+ BOOST_ASIO_CHECK(!address_v4(0x80000000).is_multicast());
+ BOOST_ASIO_CHECK(!address_v4(0xBFFF0000).is_multicast());
+ BOOST_ASIO_CHECK(!address_v4(0xC0000000).is_multicast());
+ BOOST_ASIO_CHECK(!address_v4(0xDFFFFF00).is_multicast());
+ BOOST_ASIO_CHECK(address_v4(0xE0000000).is_multicast());
+ BOOST_ASIO_CHECK(address_v4(0xEFFFFFFF).is_multicast());
+ BOOST_ASIO_CHECK(!address_v4(0xF0000000).is_multicast());
+ BOOST_ASIO_CHECK(!address_v4(0xFFFFFFFF).is_multicast());
+
+ address_v4 a4 = address_v4::any();
+ BOOST_ASIO_CHECK(a4.to_bytes()[0] == 0);
+ BOOST_ASIO_CHECK(a4.to_bytes()[1] == 0);
+ BOOST_ASIO_CHECK(a4.to_bytes()[2] == 0);
+ BOOST_ASIO_CHECK(a4.to_bytes()[3] == 0);
+ BOOST_ASIO_CHECK(a4.to_uint() == 0);
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ BOOST_ASIO_CHECK(a4.to_ulong() == 0);
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ address_v4 a5 = address_v4::loopback();
+ BOOST_ASIO_CHECK(a5.to_bytes()[0] == 0x7F);
+ BOOST_ASIO_CHECK(a5.to_bytes()[1] == 0);
+ BOOST_ASIO_CHECK(a5.to_bytes()[2] == 0);
+ BOOST_ASIO_CHECK(a5.to_bytes()[3] == 0x01);
+ BOOST_ASIO_CHECK(a5.to_uint() == 0x7F000001);
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ BOOST_ASIO_CHECK(a5.to_ulong() == 0x7F000001);
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ address_v4 a6 = address_v4::broadcast();
+ BOOST_ASIO_CHECK(a6.to_bytes()[0] == 0xFF);
+ BOOST_ASIO_CHECK(a6.to_bytes()[1] == 0xFF);
+ BOOST_ASIO_CHECK(a6.to_bytes()[2] == 0xFF);
+ BOOST_ASIO_CHECK(a6.to_bytes()[3] == 0xFF);
+ BOOST_ASIO_CHECK(a6.to_uint() == 0xFFFFFFFF);
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ BOOST_ASIO_CHECK(a6.to_ulong() == 0xFFFFFFFF);
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ address_v4 class_a_net(0xFF000000);
+ address_v4 class_b_net(0xFFFF0000);
+ address_v4 class_c_net(0xFFFFFF00);
+ address_v4 other_net(0xFFFFFFFF);
+ BOOST_ASIO_CHECK(address_v4::netmask(address_v4(0x01000000)) == class_a_net);
+ BOOST_ASIO_CHECK(address_v4::netmask(address_v4(0x7F000000)) == class_a_net);
+ BOOST_ASIO_CHECK(address_v4::netmask(address_v4(0x80000000)) == class_b_net);
+ BOOST_ASIO_CHECK(address_v4::netmask(address_v4(0xBFFF0000)) == class_b_net);
+ BOOST_ASIO_CHECK(address_v4::netmask(address_v4(0xC0000000)) == class_c_net);
+ BOOST_ASIO_CHECK(address_v4::netmask(address_v4(0xDFFFFF00)) == class_c_net);
+ BOOST_ASIO_CHECK(address_v4::netmask(address_v4(0xE0000000)) == other_net);
+ BOOST_ASIO_CHECK(address_v4::netmask(address_v4(0xEFFFFFFF)) == other_net);
+ BOOST_ASIO_CHECK(address_v4::netmask(address_v4(0xF0000000)) == other_net);
+ BOOST_ASIO_CHECK(address_v4::netmask(address_v4(0xFFFFFFFF)) == other_net);
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+}
+
+} // namespace ip_address_v4_runtime
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ip/address_v4",
+ BOOST_ASIO_TEST_CASE(ip_address_v4_compile::test)
+ BOOST_ASIO_TEST_CASE(ip_address_v4_runtime::test)
+)
diff --git a/src/boost/libs/asio/test/ip/address_v4_iterator.cpp b/src/boost/libs/asio/test/ip/address_v4_iterator.cpp
new file mode 100644
index 000000000..94d847646
--- /dev/null
+++ b/src/boost/libs/asio/test/ip/address_v4_iterator.cpp
@@ -0,0 +1,27 @@
+//
+// address_v4_iterator.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ip/address_v4_iterator.hpp>
+
+#include "../unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ip/address_v4_iterator",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/ip/address_v4_range.cpp b/src/boost/libs/asio/test/ip/address_v4_range.cpp
new file mode 100644
index 000000000..1ecaf6d03
--- /dev/null
+++ b/src/boost/libs/asio/test/ip/address_v4_range.cpp
@@ -0,0 +1,27 @@
+//
+// address_v4_range.cpp
+// ~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ip/address_v4_range.hpp>
+
+#include "../unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ip/address_v4_range",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/ip/address_v6.cpp b/src/boost/libs/asio/test/ip/address_v6.cpp
new file mode 100644
index 000000000..7f35071d0
--- /dev/null
+++ b/src/boost/libs/asio/test/ip/address_v6.cpp
@@ -0,0 +1,409 @@
+//
+// address_v6.cpp
+// ~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ip/address_v6.hpp>
+
+#include "../unit_test.hpp"
+#include <sstream>
+
+//------------------------------------------------------------------------------
+
+// ip_address_v6_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// ip::address_v6 compile and link correctly. Runtime failures are ignored.
+
+namespace ip_address_v6_compile {
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ try
+ {
+ boost::system::error_code ec;
+
+ // address_v6 constructors.
+
+ ip::address_v6 addr1;
+ const ip::address_v6::bytes_type const_bytes_value = { { 0 } };
+ ip::address_v6 addr2(const_bytes_value);
+
+ // address_v6 functions.
+
+ unsigned long scope_id = addr1.scope_id();
+ addr1.scope_id(scope_id);
+
+ bool b = addr1.is_unspecified();
+ (void)b;
+
+ b = addr1.is_loopback();
+ (void)b;
+
+ b = addr1.is_multicast();
+ (void)b;
+
+ b = addr1.is_link_local();
+ (void)b;
+
+ b = addr1.is_site_local();
+ (void)b;
+
+ b = addr1.is_v4_mapped();
+ (void)b;
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ b = addr1.is_v4_compatible();
+ (void)b;
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ b = addr1.is_multicast_node_local();
+ (void)b;
+
+ b = addr1.is_multicast_link_local();
+ (void)b;
+
+ b = addr1.is_multicast_site_local();
+ (void)b;
+
+ b = addr1.is_multicast_org_local();
+ (void)b;
+
+ b = addr1.is_multicast_global();
+ (void)b;
+
+ ip::address_v6::bytes_type bytes_value = addr1.to_bytes();
+ (void)bytes_value;
+
+ std::string string_value = addr1.to_string();
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ string_value = addr1.to_string(ec);
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ ip::address_v4 addr3 = addr1.to_v4();
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ // address_v6 static functions.
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ addr1 = ip::address_v6::from_string("0::0");
+ addr1 = ip::address_v6::from_string("0::0", ec);
+ addr1 = ip::address_v6::from_string(string_value);
+ addr1 = ip::address_v6::from_string(string_value, ec);
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ addr1 = ip::address_v6::any();
+
+ addr1 = ip::address_v6::loopback();
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ addr1 = ip::address_v6::v4_mapped(addr3);
+
+ addr1 = ip::address_v6::v4_compatible(addr3);
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ // address_v6 comparisons.
+
+ b = (addr1 == addr2);
+ (void)b;
+
+ b = (addr1 != addr2);
+ (void)b;
+
+ b = (addr1 < addr2);
+ (void)b;
+
+ b = (addr1 > addr2);
+ (void)b;
+
+ b = (addr1 <= addr2);
+ (void)b;
+
+ b = (addr1 >= addr2);
+ (void)b;
+
+ // address_v6 creation functions.
+
+ addr1 = ip::make_address_v6(const_bytes_value, scope_id);
+ addr1 = ip::make_address_v6("0::0");
+ 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(BOOST_ASIO_HAS_STRING_VIEW)
+# if defined(BOOST_ASIO_HAS_STD_STRING_VIEW)
+ std::string_view string_view_value("0::0");
+# else // defined(BOOST_ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
+ std::experimental::string_view string_view_value("0::0");
+# endif // defined(BOOST_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(BOOST_ASIO_HAS_STRING_VIEW)
+
+ // address_v6 IPv4-mapped conversion.
+#if defined(BOOST_ASIO_NO_DEPRECATED)
+ ip::address_v4 addr3;
+#endif // defined(BOOST_ASIO_NO_DEPRECATED)
+ addr1 = ip::make_address_v6(ip::v4_mapped, addr3);
+ addr3 = ip::make_address_v4(ip::v4_mapped, addr1);
+
+ // address_v6 I/O.
+
+ std::ostringstream os;
+ os << addr1;
+
+#if !defined(BOOST_NO_STD_WSTREAMBUF)
+ std::wostringstream wos;
+ wos << addr1;
+#endif // !defined(BOOST_NO_STD_WSTREAMBUF)
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace ip_address_v6_compile
+
+//------------------------------------------------------------------------------
+
+// ip_address_v6_runtime test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that the various public member functions meet the
+// necessary postconditions.
+
+namespace ip_address_v6_runtime {
+
+void test()
+{
+ using boost::asio::ip::address_v6;
+
+ address_v6 a1;
+ BOOST_ASIO_CHECK(a1.is_unspecified());
+ BOOST_ASIO_CHECK(a1.scope_id() == 0);
+
+ address_v6::bytes_type b1 = {{ 1, 2, 3, 4, 5,
+ 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }};
+ address_v6 a2(b1, 12345);
+ BOOST_ASIO_CHECK(a2.to_bytes()[0] == 1);
+ BOOST_ASIO_CHECK(a2.to_bytes()[1] == 2);
+ BOOST_ASIO_CHECK(a2.to_bytes()[2] == 3);
+ BOOST_ASIO_CHECK(a2.to_bytes()[3] == 4);
+ BOOST_ASIO_CHECK(a2.to_bytes()[4] == 5);
+ BOOST_ASIO_CHECK(a2.to_bytes()[5] == 6);
+ BOOST_ASIO_CHECK(a2.to_bytes()[6] == 7);
+ BOOST_ASIO_CHECK(a2.to_bytes()[7] == 8);
+ BOOST_ASIO_CHECK(a2.to_bytes()[8] == 9);
+ BOOST_ASIO_CHECK(a2.to_bytes()[9] == 10);
+ BOOST_ASIO_CHECK(a2.to_bytes()[10] == 11);
+ BOOST_ASIO_CHECK(a2.to_bytes()[11] == 12);
+ BOOST_ASIO_CHECK(a2.to_bytes()[12] == 13);
+ BOOST_ASIO_CHECK(a2.to_bytes()[13] == 14);
+ BOOST_ASIO_CHECK(a2.to_bytes()[14] == 15);
+ BOOST_ASIO_CHECK(a2.to_bytes()[15] == 16);
+ BOOST_ASIO_CHECK(a2.scope_id() == 12345);
+
+ address_v6 a3;
+ a3.scope_id(12345);
+ BOOST_ASIO_CHECK(a3.scope_id() == 12345);
+
+ address_v6 unspecified_address;
+ address_v6::bytes_type loopback_bytes = {{ 0 }};
+ loopback_bytes[15] = 1;
+ address_v6 loopback_address(loopback_bytes);
+ address_v6::bytes_type link_local_bytes = {{ 0xFE, 0x80, 1 }};
+ address_v6 link_local_address(link_local_bytes);
+ address_v6::bytes_type site_local_bytes = {{ 0xFE, 0xC0, 1 }};
+ address_v6 site_local_address(site_local_bytes);
+ address_v6::bytes_type v4_mapped_bytes = {{ 0 }};
+ v4_mapped_bytes[10] = 0xFF, v4_mapped_bytes[11] = 0xFF;
+ v4_mapped_bytes[12] = 1, v4_mapped_bytes[13] = 2;
+ v4_mapped_bytes[14] = 3, v4_mapped_bytes[15] = 4;
+ address_v6 v4_mapped_address(v4_mapped_bytes);
+ address_v6::bytes_type v4_compat_bytes = {{ 0 }};
+ v4_compat_bytes[12] = 1, v4_compat_bytes[13] = 2;
+ v4_compat_bytes[14] = 3, v4_compat_bytes[15] = 4;
+ address_v6 v4_compat_address(v4_compat_bytes);
+ address_v6::bytes_type mcast_global_bytes = {{ 0xFF, 0x0E, 1 }};
+ address_v6 mcast_global_address(mcast_global_bytes);
+ address_v6::bytes_type mcast_link_local_bytes = {{ 0xFF, 0x02, 1 }};
+ address_v6 mcast_link_local_address(mcast_link_local_bytes);
+ address_v6::bytes_type mcast_node_local_bytes = {{ 0xFF, 0x01, 1 }};
+ address_v6 mcast_node_local_address(mcast_node_local_bytes);
+ address_v6::bytes_type mcast_org_local_bytes = {{ 0xFF, 0x08, 1 }};
+ address_v6 mcast_org_local_address(mcast_org_local_bytes);
+ address_v6::bytes_type mcast_site_local_bytes = {{ 0xFF, 0x05, 1 }};
+ address_v6 mcast_site_local_address(mcast_site_local_bytes);
+
+ BOOST_ASIO_CHECK(!unspecified_address.is_loopback());
+ BOOST_ASIO_CHECK(loopback_address.is_loopback());
+ BOOST_ASIO_CHECK(!link_local_address.is_loopback());
+ BOOST_ASIO_CHECK(!site_local_address.is_loopback());
+ BOOST_ASIO_CHECK(!v4_mapped_address.is_loopback());
+ BOOST_ASIO_CHECK(!v4_compat_address.is_loopback());
+ BOOST_ASIO_CHECK(!mcast_global_address.is_loopback());
+ BOOST_ASIO_CHECK(!mcast_link_local_address.is_loopback());
+ BOOST_ASIO_CHECK(!mcast_node_local_address.is_loopback());
+ BOOST_ASIO_CHECK(!mcast_org_local_address.is_loopback());
+ BOOST_ASIO_CHECK(!mcast_site_local_address.is_loopback());
+
+ BOOST_ASIO_CHECK(unspecified_address.is_unspecified());
+ BOOST_ASIO_CHECK(!loopback_address.is_unspecified());
+ BOOST_ASIO_CHECK(!link_local_address.is_unspecified());
+ BOOST_ASIO_CHECK(!site_local_address.is_unspecified());
+ BOOST_ASIO_CHECK(!v4_mapped_address.is_unspecified());
+ BOOST_ASIO_CHECK(!v4_compat_address.is_unspecified());
+ BOOST_ASIO_CHECK(!mcast_global_address.is_unspecified());
+ BOOST_ASIO_CHECK(!mcast_link_local_address.is_unspecified());
+ BOOST_ASIO_CHECK(!mcast_node_local_address.is_unspecified());
+ BOOST_ASIO_CHECK(!mcast_org_local_address.is_unspecified());
+ BOOST_ASIO_CHECK(!mcast_site_local_address.is_unspecified());
+
+ BOOST_ASIO_CHECK(!unspecified_address.is_link_local());
+ BOOST_ASIO_CHECK(!loopback_address.is_link_local());
+ BOOST_ASIO_CHECK(link_local_address.is_link_local());
+ BOOST_ASIO_CHECK(!site_local_address.is_link_local());
+ BOOST_ASIO_CHECK(!v4_mapped_address.is_link_local());
+ BOOST_ASIO_CHECK(!v4_compat_address.is_link_local());
+ BOOST_ASIO_CHECK(!mcast_global_address.is_link_local());
+ BOOST_ASIO_CHECK(!mcast_link_local_address.is_link_local());
+ BOOST_ASIO_CHECK(!mcast_node_local_address.is_link_local());
+ BOOST_ASIO_CHECK(!mcast_org_local_address.is_link_local());
+ BOOST_ASIO_CHECK(!mcast_site_local_address.is_link_local());
+
+ BOOST_ASIO_CHECK(!unspecified_address.is_site_local());
+ BOOST_ASIO_CHECK(!loopback_address.is_site_local());
+ BOOST_ASIO_CHECK(!link_local_address.is_site_local());
+ BOOST_ASIO_CHECK(site_local_address.is_site_local());
+ BOOST_ASIO_CHECK(!v4_mapped_address.is_site_local());
+ BOOST_ASIO_CHECK(!v4_compat_address.is_site_local());
+ BOOST_ASIO_CHECK(!mcast_global_address.is_site_local());
+ BOOST_ASIO_CHECK(!mcast_link_local_address.is_site_local());
+ BOOST_ASIO_CHECK(!mcast_node_local_address.is_site_local());
+ BOOST_ASIO_CHECK(!mcast_org_local_address.is_site_local());
+ BOOST_ASIO_CHECK(!mcast_site_local_address.is_site_local());
+
+ BOOST_ASIO_CHECK(!unspecified_address.is_v4_mapped());
+ BOOST_ASIO_CHECK(!loopback_address.is_v4_mapped());
+ BOOST_ASIO_CHECK(!link_local_address.is_v4_mapped());
+ BOOST_ASIO_CHECK(!site_local_address.is_v4_mapped());
+ BOOST_ASIO_CHECK(v4_mapped_address.is_v4_mapped());
+ BOOST_ASIO_CHECK(!v4_compat_address.is_v4_mapped());
+ BOOST_ASIO_CHECK(!mcast_global_address.is_v4_mapped());
+ BOOST_ASIO_CHECK(!mcast_link_local_address.is_v4_mapped());
+ BOOST_ASIO_CHECK(!mcast_node_local_address.is_v4_mapped());
+ BOOST_ASIO_CHECK(!mcast_org_local_address.is_v4_mapped());
+ BOOST_ASIO_CHECK(!mcast_site_local_address.is_v4_mapped());
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ BOOST_ASIO_CHECK(!unspecified_address.is_v4_compatible());
+ BOOST_ASIO_CHECK(!loopback_address.is_v4_compatible());
+ BOOST_ASIO_CHECK(!link_local_address.is_v4_compatible());
+ BOOST_ASIO_CHECK(!site_local_address.is_v4_compatible());
+ BOOST_ASIO_CHECK(!v4_mapped_address.is_v4_compatible());
+ BOOST_ASIO_CHECK(v4_compat_address.is_v4_compatible());
+ BOOST_ASIO_CHECK(!mcast_global_address.is_v4_compatible());
+ BOOST_ASIO_CHECK(!mcast_link_local_address.is_v4_compatible());
+ BOOST_ASIO_CHECK(!mcast_node_local_address.is_v4_compatible());
+ BOOST_ASIO_CHECK(!mcast_org_local_address.is_v4_compatible());
+ BOOST_ASIO_CHECK(!mcast_site_local_address.is_v4_compatible());
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ BOOST_ASIO_CHECK(!unspecified_address.is_multicast());
+ BOOST_ASIO_CHECK(!loopback_address.is_multicast());
+ BOOST_ASIO_CHECK(!link_local_address.is_multicast());
+ BOOST_ASIO_CHECK(!site_local_address.is_multicast());
+ BOOST_ASIO_CHECK(!v4_mapped_address.is_multicast());
+ BOOST_ASIO_CHECK(!v4_compat_address.is_multicast());
+ BOOST_ASIO_CHECK(mcast_global_address.is_multicast());
+ BOOST_ASIO_CHECK(mcast_link_local_address.is_multicast());
+ BOOST_ASIO_CHECK(mcast_node_local_address.is_multicast());
+ BOOST_ASIO_CHECK(mcast_org_local_address.is_multicast());
+ BOOST_ASIO_CHECK(mcast_site_local_address.is_multicast());
+
+ BOOST_ASIO_CHECK(!unspecified_address.is_multicast_global());
+ BOOST_ASIO_CHECK(!loopback_address.is_multicast_global());
+ BOOST_ASIO_CHECK(!link_local_address.is_multicast_global());
+ BOOST_ASIO_CHECK(!site_local_address.is_multicast_global());
+ BOOST_ASIO_CHECK(!v4_mapped_address.is_multicast_global());
+ BOOST_ASIO_CHECK(!v4_compat_address.is_multicast_global());
+ BOOST_ASIO_CHECK(mcast_global_address.is_multicast_global());
+ BOOST_ASIO_CHECK(!mcast_link_local_address.is_multicast_global());
+ BOOST_ASIO_CHECK(!mcast_node_local_address.is_multicast_global());
+ BOOST_ASIO_CHECK(!mcast_org_local_address.is_multicast_global());
+ BOOST_ASIO_CHECK(!mcast_site_local_address.is_multicast_global());
+
+ BOOST_ASIO_CHECK(!unspecified_address.is_multicast_link_local());
+ BOOST_ASIO_CHECK(!loopback_address.is_multicast_link_local());
+ BOOST_ASIO_CHECK(!link_local_address.is_multicast_link_local());
+ BOOST_ASIO_CHECK(!site_local_address.is_multicast_link_local());
+ BOOST_ASIO_CHECK(!v4_mapped_address.is_multicast_link_local());
+ BOOST_ASIO_CHECK(!v4_compat_address.is_multicast_link_local());
+ BOOST_ASIO_CHECK(!mcast_global_address.is_multicast_link_local());
+ BOOST_ASIO_CHECK(mcast_link_local_address.is_multicast_link_local());
+ BOOST_ASIO_CHECK(!mcast_node_local_address.is_multicast_link_local());
+ BOOST_ASIO_CHECK(!mcast_org_local_address.is_multicast_link_local());
+ BOOST_ASIO_CHECK(!mcast_site_local_address.is_multicast_link_local());
+
+ BOOST_ASIO_CHECK(!unspecified_address.is_multicast_node_local());
+ BOOST_ASIO_CHECK(!loopback_address.is_multicast_node_local());
+ BOOST_ASIO_CHECK(!link_local_address.is_multicast_node_local());
+ BOOST_ASIO_CHECK(!site_local_address.is_multicast_node_local());
+ BOOST_ASIO_CHECK(!v4_mapped_address.is_multicast_node_local());
+ BOOST_ASIO_CHECK(!v4_compat_address.is_multicast_node_local());
+ BOOST_ASIO_CHECK(!mcast_global_address.is_multicast_node_local());
+ BOOST_ASIO_CHECK(!mcast_link_local_address.is_multicast_node_local());
+ BOOST_ASIO_CHECK(mcast_node_local_address.is_multicast_node_local());
+ BOOST_ASIO_CHECK(!mcast_org_local_address.is_multicast_node_local());
+ BOOST_ASIO_CHECK(!mcast_site_local_address.is_multicast_node_local());
+
+ BOOST_ASIO_CHECK(!unspecified_address.is_multicast_org_local());
+ BOOST_ASIO_CHECK(!loopback_address.is_multicast_org_local());
+ BOOST_ASIO_CHECK(!link_local_address.is_multicast_org_local());
+ BOOST_ASIO_CHECK(!site_local_address.is_multicast_org_local());
+ BOOST_ASIO_CHECK(!v4_mapped_address.is_multicast_org_local());
+ BOOST_ASIO_CHECK(!v4_compat_address.is_multicast_org_local());
+ BOOST_ASIO_CHECK(!mcast_global_address.is_multicast_org_local());
+ BOOST_ASIO_CHECK(!mcast_link_local_address.is_multicast_org_local());
+ BOOST_ASIO_CHECK(!mcast_node_local_address.is_multicast_org_local());
+ BOOST_ASIO_CHECK(mcast_org_local_address.is_multicast_org_local());
+ BOOST_ASIO_CHECK(!mcast_site_local_address.is_multicast_org_local());
+
+ BOOST_ASIO_CHECK(!unspecified_address.is_multicast_site_local());
+ BOOST_ASIO_CHECK(!loopback_address.is_multicast_site_local());
+ BOOST_ASIO_CHECK(!link_local_address.is_multicast_site_local());
+ BOOST_ASIO_CHECK(!site_local_address.is_multicast_site_local());
+ BOOST_ASIO_CHECK(!v4_mapped_address.is_multicast_site_local());
+ BOOST_ASIO_CHECK(!v4_compat_address.is_multicast_site_local());
+ BOOST_ASIO_CHECK(!mcast_global_address.is_multicast_site_local());
+ BOOST_ASIO_CHECK(!mcast_link_local_address.is_multicast_site_local());
+ BOOST_ASIO_CHECK(!mcast_node_local_address.is_multicast_site_local());
+ BOOST_ASIO_CHECK(!mcast_org_local_address.is_multicast_site_local());
+ BOOST_ASIO_CHECK(mcast_site_local_address.is_multicast_site_local());
+
+ BOOST_ASIO_CHECK(address_v6::loopback().is_loopback());
+}
+
+} // namespace ip_address_v6_runtime
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ip/address_v6",
+ BOOST_ASIO_TEST_CASE(ip_address_v6_compile::test)
+ BOOST_ASIO_TEST_CASE(ip_address_v6_runtime::test)
+)
diff --git a/src/boost/libs/asio/test/ip/address_v6_iterator.cpp b/src/boost/libs/asio/test/ip/address_v6_iterator.cpp
new file mode 100644
index 000000000..3c0ef1a22
--- /dev/null
+++ b/src/boost/libs/asio/test/ip/address_v6_iterator.cpp
@@ -0,0 +1,27 @@
+//
+// address_v6_iterator.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ip/address_v6_iterator.hpp>
+
+#include "../unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ip/address_v6_iterator",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/ip/address_v6_range.cpp b/src/boost/libs/asio/test/ip/address_v6_range.cpp
new file mode 100644
index 000000000..b5210031c
--- /dev/null
+++ b/src/boost/libs/asio/test/ip/address_v6_range.cpp
@@ -0,0 +1,27 @@
+//
+// address_v6_range.cpp
+// ~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ip/address_v6_range.hpp>
+
+#include "../unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ip/address_v6_range",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/ip/basic_endpoint.cpp b/src/boost/libs/asio/test/ip/basic_endpoint.cpp
new file mode 100644
index 000000000..f678e74be
--- /dev/null
+++ b/src/boost/libs/asio/test/ip/basic_endpoint.cpp
@@ -0,0 +1,25 @@
+//
+// basic_endpoint.cpp
+// ~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ip/basic_endpoint.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ip/basic_endpoint",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/ip/basic_resolver.cpp b/src/boost/libs/asio/test/ip/basic_resolver.cpp
new file mode 100644
index 000000000..ae194bb8e
--- /dev/null
+++ b/src/boost/libs/asio/test/ip/basic_resolver.cpp
@@ -0,0 +1,25 @@
+//
+// basic_resolver.cpp
+// ~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ip/basic_resolver.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ip/basic_resolver",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/ip/basic_resolver_entry.cpp b/src/boost/libs/asio/test/ip/basic_resolver_entry.cpp
new file mode 100644
index 000000000..942a4e8e1
--- /dev/null
+++ b/src/boost/libs/asio/test/ip/basic_resolver_entry.cpp
@@ -0,0 +1,25 @@
+//
+// basic_resolver_entry.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ip/basic_resolver_entry.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ip/basic_resolver_entry",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/ip/basic_resolver_iterator.cpp b/src/boost/libs/asio/test/ip/basic_resolver_iterator.cpp
new file mode 100644
index 000000000..da15f5682
--- /dev/null
+++ b/src/boost/libs/asio/test/ip/basic_resolver_iterator.cpp
@@ -0,0 +1,25 @@
+//
+// basic_resolver_iterator.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ip/basic_resolver_iterator.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ip/basic_resolver_iterator",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/ip/basic_resolver_query.cpp b/src/boost/libs/asio/test/ip/basic_resolver_query.cpp
new file mode 100644
index 000000000..59a26caf4
--- /dev/null
+++ b/src/boost/libs/asio/test/ip/basic_resolver_query.cpp
@@ -0,0 +1,25 @@
+//
+// basic_resolver_query.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ip/basic_resolver_query.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ip/basic_resolver_query",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/ip/host_name.cpp b/src/boost/libs/asio/test/ip/host_name.cpp
new file mode 100644
index 000000000..edeeb448d
--- /dev/null
+++ b/src/boost/libs/asio/test/ip/host_name.cpp
@@ -0,0 +1,55 @@
+//
+// host_name.cpp
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ip/host_name.hpp>
+
+#include "../unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+// ip_host_name_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all host_name functions compile and link
+// correctly. Runtime failures are ignored.
+
+namespace ip_host_name_compile {
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ try
+ {
+ boost::system::error_code ec;
+
+ std::string host_name = ip::host_name();
+ std::string host_name2 = ip::host_name(ec);
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace ip_host_name_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ip/host_name",
+ BOOST_ASIO_TEST_CASE(ip_host_name_compile::test)
+)
diff --git a/src/boost/libs/asio/test/ip/icmp.cpp b/src/boost/libs/asio/test/ip/icmp.cpp
new file mode 100644
index 000000000..2dd9e331a
--- /dev/null
+++ b/src/boost/libs/asio/test/ip/icmp.cpp
@@ -0,0 +1,577 @@
+//
+// icmp.cpp
+// ~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ip/icmp.hpp>
+
+#include <cstring>
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/placeholders.hpp>
+#include "../unit_test.hpp"
+#include "../archetypes/async_result.hpp"
+#include "../archetypes/gettable_socket_option.hpp"
+#include "../archetypes/io_control_command.hpp"
+#include "../archetypes/settable_socket_option.hpp"
+
+//------------------------------------------------------------------------------
+
+// ip_icmp_socket_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// ip::icmp::socket compile and link correctly. Runtime failures are ignored.
+
+namespace ip_icmp_socket_compile {
+
+struct connect_handler
+{
+ connect_handler() {}
+ void operator()(const boost::system::error_code&) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ connect_handler(connect_handler&&) {}
+private:
+ connect_handler(const connect_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+
+struct send_handler
+{
+ send_handler() {}
+ void operator()(const boost::system::error_code&, std::size_t) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ send_handler(send_handler&&) {}
+private:
+ send_handler(const send_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+
+struct receive_handler
+{
+ receive_handler() {}
+ void operator()(const boost::system::error_code&, std::size_t) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ receive_handler(receive_handler&&) {}
+private:
+ receive_handler(const receive_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ 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;
+ archetypes::settable_socket_option<void> settable_socket_option1;
+ archetypes::settable_socket_option<int> settable_socket_option2;
+ archetypes::settable_socket_option<double> settable_socket_option3;
+ archetypes::gettable_socket_option<void> gettable_socket_option1;
+ archetypes::gettable_socket_option<int> gettable_socket_option2;
+ archetypes::gettable_socket_option<double> gettable_socket_option3;
+ archetypes::io_control_command io_control_command;
+ archetypes::lazy_handler lazy;
+ boost::system::error_code ec;
+
+ // basic_datagram_socket constructors.
+
+ ip::icmp::socket socket1(ioc);
+ ip::icmp::socket socket2(ioc, ip::icmp::v4());
+ ip::icmp::socket socket3(ioc, ip::icmp::v6());
+ ip::icmp::socket socket4(ioc, ip::icmp::endpoint(ip::icmp::v4(), 0));
+ ip::icmp::socket socket5(ioc, ip::icmp::endpoint(ip::icmp::v6(), 0));
+#if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
+ ip::icmp::socket::native_handle_type native_socket1
+ = ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ ip::icmp::socket socket6(ioc, ip::icmp::v4(), native_socket1);
+#endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME)
+
+ 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(BOOST_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(BOOST_ASIO_WINDOWS_RUNTIME)
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ ip::icmp::socket socket13(std::move(socket6));
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_datagram_socket operators.
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ socket1 = ip::icmp::socket(ioc);
+ socket1 = std::move(socket2);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_io_object functions.
+
+ ip::icmp::socket::executor_type ex = socket1.get_executor();
+ (void)ex;
+
+ // basic_socket functions.
+
+ ip::icmp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer();
+ (void)lowest_layer;
+
+ const ip::icmp::socket& socket14 = socket1;
+ const ip::icmp::socket::lowest_layer_type& lowest_layer2
+ = socket14.lowest_layer();
+ (void)lowest_layer2;
+
+ socket1.open(ip::icmp::v4());
+ socket1.open(ip::icmp::v6());
+ socket1.open(ip::icmp::v4(), ec);
+ socket1.open(ip::icmp::v6(), ec);
+
+#if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
+ ip::icmp::socket::native_handle_type native_socket3
+ = ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ 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(BOOST_ASIO_WINDOWS_RUNTIME)
+
+ bool is_open = socket1.is_open();
+ (void)is_open;
+
+ socket1.close();
+ socket1.close(ec);
+
+ socket1.release();
+ socket1.release(ec);
+
+ ip::icmp::socket::native_handle_type native_socket5
+ = socket1.native_handle();
+ (void)native_socket5;
+
+ 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(ip::icmp::endpoint(ip::icmp::v4(), 0));
+ socket1.bind(ip::icmp::endpoint(ip::icmp::v6(), 0));
+ socket1.bind(ip::icmp::endpoint(ip::icmp::v4(), 0), ec);
+ socket1.bind(ip::icmp::endpoint(ip::icmp::v6(), 0), ec);
+
+ socket1.connect(ip::icmp::endpoint(ip::icmp::v4(), 0));
+ socket1.connect(ip::icmp::endpoint(ip::icmp::v6(), 0));
+ socket1.connect(ip::icmp::endpoint(ip::icmp::v4(), 0), ec);
+ socket1.connect(ip::icmp::endpoint(ip::icmp::v6(), 0), ec);
+
+ socket1.async_connect(ip::icmp::endpoint(ip::icmp::v4(), 0),
+ connect_handler());
+ socket1.async_connect(ip::icmp::endpoint(ip::icmp::v6(), 0),
+ connect_handler());
+ 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;
+
+ socket1.set_option(settable_socket_option1);
+ socket1.set_option(settable_socket_option1, ec);
+ socket1.set_option(settable_socket_option2);
+ socket1.set_option(settable_socket_option2, ec);
+ socket1.set_option(settable_socket_option3);
+ socket1.set_option(settable_socket_option3, ec);
+
+ socket1.get_option(gettable_socket_option1);
+ socket1.get_option(gettable_socket_option1, ec);
+ socket1.get_option(gettable_socket_option2);
+ socket1.get_option(gettable_socket_option2, ec);
+ socket1.get_option(gettable_socket_option3);
+ socket1.get_option(gettable_socket_option3, ec);
+
+ socket1.io_control(io_control_command);
+ socket1.io_control(io_control_command, ec);
+
+ bool non_blocking1 = socket1.non_blocking();
+ (void)non_blocking1;
+ socket1.non_blocking(true);
+ socket1.non_blocking(false, ec);
+
+ bool non_blocking2 = socket1.native_non_blocking();
+ (void)non_blocking2;
+ socket1.native_non_blocking(true);
+ 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);
+
+ // basic_datagram_socket functions.
+
+ socket1.send(buffer(mutable_char_buffer));
+ socket1.send(buffer(const_char_buffer));
+ socket1.send(null_buffers());
+ 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), send_handler());
+ socket1.async_send(buffer(const_char_buffer), send_handler());
+ socket1.async_send(null_buffers(), send_handler());
+ 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());
+ int i3 = socket1.async_send(buffer(mutable_char_buffer), lazy);
+ (void)i3;
+ int i4 = socket1.async_send(buffer(const_char_buffer), lazy);
+ (void)i4;
+ int i5 = socket1.async_send(null_buffers(), lazy);
+ (void)i5;
+ int i6 = socket1.async_send(buffer(mutable_char_buffer), in_flags, lazy);
+ (void)i6;
+ int i7 = socket1.async_send(buffer(const_char_buffer), in_flags, lazy);
+ (void)i7;
+ int i8 = socket1.async_send(null_buffers(), in_flags, lazy);
+ (void)i8;
+
+ socket1.send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0));
+ socket1.send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0));
+ socket1.send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0));
+ socket1.send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0));
+ socket1.send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v4(), 0));
+ socket1.send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v6(), 0));
+ socket1.send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags);
+ socket1.send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags);
+ socket1.send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags);
+ socket1.send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags);
+ socket1.send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags);
+ socket1.send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags);
+ socket1.send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, ec);
+ socket1.send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, ec);
+ socket1.send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, ec);
+ socket1.send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, ec);
+ socket1.send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, ec);
+ socket1.send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, ec);
+
+ socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), send_handler());
+ socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), send_handler());
+ socket1.async_send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), send_handler());
+ socket1.async_send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), send_handler());
+ socket1.async_send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), send_handler());
+ socket1.async_send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), send_handler());
+ socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, send_handler());
+ socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, send_handler());
+ socket1.async_send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, send_handler());
+ socket1.async_send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, send_handler());
+ socket1.async_send_to(null_buffers(),
+ 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());
+ int i9 = socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), lazy);
+ (void)i9;
+ int i10 = socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), lazy);
+ (void)i10;
+ int i11 = socket1.async_send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), lazy);
+ (void)i11;
+ int i12 = socket1.async_send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), lazy);
+ (void)i12;
+ int i13 = socket1.async_send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), lazy);
+ (void)i13;
+ int i14 = socket1.async_send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), lazy);
+ (void)i14;
+ int i15 = socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, lazy);
+ (void)i15;
+ int i16 = socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, lazy);
+ (void)i16;
+ int i17 = socket1.async_send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, lazy);
+ (void)i17;
+ int i18 = socket1.async_send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, lazy);
+ (void)i18;
+ int i19 = socket1.async_send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, lazy);
+ (void)i19;
+ int i20 = socket1.async_send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, lazy);
+ (void)i20;
+
+ socket1.receive(buffer(mutable_char_buffer));
+ socket1.receive(null_buffers());
+ socket1.receive(buffer(mutable_char_buffer), in_flags);
+ socket1.receive(null_buffers(), in_flags);
+ socket1.receive(buffer(mutable_char_buffer), in_flags, ec);
+ socket1.receive(null_buffers(), in_flags, ec);
+
+ socket1.async_receive(buffer(mutable_char_buffer), receive_handler());
+ socket1.async_receive(null_buffers(), receive_handler());
+ socket1.async_receive(buffer(mutable_char_buffer), in_flags,
+ receive_handler());
+ socket1.async_receive(null_buffers(), in_flags, receive_handler());
+ int i21 = socket1.async_receive(buffer(mutable_char_buffer), lazy);
+ (void)i21;
+ int i22 = socket1.async_receive(null_buffers(), lazy);
+ (void)i22;
+ int i23 = socket1.async_receive(buffer(mutable_char_buffer),
+ in_flags, lazy);
+ (void)i23;
+ int i24 = socket1.async_receive(null_buffers(), in_flags, lazy);
+ (void)i24;
+
+ ip::icmp::endpoint endpoint;
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint);
+ socket1.receive_from(null_buffers(), endpoint);
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint, in_flags);
+ socket1.receive_from(null_buffers(), endpoint, in_flags);
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint, in_flags, ec);
+ socket1.receive_from(null_buffers(), endpoint, in_flags, ec);
+
+ socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, receive_handler());
+ socket1.async_receive_from(null_buffers(),
+ endpoint, receive_handler());
+ socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, in_flags, receive_handler());
+ socket1.async_receive_from(null_buffers(),
+ endpoint, in_flags, receive_handler());
+ int i25 = socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, lazy);
+ (void)i25;
+ int i26 = socket1.async_receive_from(null_buffers(),
+ endpoint, lazy);
+ (void)i26;
+ int i27 = socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, in_flags, lazy);
+ (void)i27;
+ int i28 = socket1.async_receive_from(null_buffers(),
+ endpoint, in_flags, lazy);
+ (void)i28;
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace ip_icmp_socket_compile
+
+//------------------------------------------------------------------------------
+
+// ip_icmp_resolver_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// ip::icmp::resolver compile and link correctly. Runtime failures are ignored.
+
+namespace ip_icmp_resolver_compile {
+
+struct resolve_handler
+{
+ resolve_handler() {}
+ void operator()(const boost::system::error_code&,
+ boost::asio::ip::icmp::resolver::results_type) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ resolve_handler(resolve_handler&&) {}
+private:
+ resolve_handler(const resolve_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ try
+ {
+ io_context ioc;
+ const io_context::executor_type ioc_ex = ioc.get_executor();
+ archetypes::lazy_handler lazy;
+ boost::system::error_code ec;
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ ip::icmp::resolver::query q(ip::icmp::v4(), "localhost", "0");
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+ ip::icmp::endpoint e(ip::address_v4::loopback(), 0);
+
+ // basic_resolver constructors.
+
+ ip::icmp::resolver resolver(ioc);
+ ip::icmp::resolver resolver2(ioc_ex);
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ ip::icmp::resolver resolver3(std::move(resolver));
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_resolver operators.
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ resolver = ip::icmp::resolver(ioc);
+ resolver = std::move(resolver3);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_io_object functions.
+
+ ip::icmp::resolver::executor_type ex = resolver.get_executor();
+ (void)ex;
+
+ // basic_resolver functions.
+
+ resolver.cancel();
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ ip::icmp::resolver::results_type results1 = resolver.resolve(q);
+ (void)results1;
+
+ ip::icmp::resolver::results_type results2 = resolver.resolve(q, ec);
+ (void)results2;
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ ip::icmp::resolver::results_type results3 = resolver.resolve("", "");
+ (void)results3;
+
+ ip::icmp::resolver::results_type results4 = resolver.resolve("", "", ec);
+ (void)results4;
+
+ ip::icmp::resolver::results_type results5 =
+ resolver.resolve("", "", ip::icmp::resolver::flags());
+ (void)results5;
+
+ ip::icmp::resolver::results_type results6 =
+ resolver.resolve("", "", ip::icmp::resolver::flags(), ec);
+ (void)results6;
+
+ ip::icmp::resolver::results_type results7 =
+ resolver.resolve(ip::icmp::v4(), "", "");
+ (void)results7;
+
+ ip::icmp::resolver::results_type results8 =
+ resolver.resolve(ip::icmp::v4(), "", "", ec);
+ (void)results8;
+
+ ip::icmp::resolver::results_type results9 =
+ resolver.resolve(ip::icmp::v4(), "", "", ip::icmp::resolver::flags());
+ (void)results9;
+
+ ip::icmp::resolver::results_type results10 =
+ resolver.resolve(ip::icmp::v4(), "", "", ip::icmp::resolver::flags(), ec);
+ (void)results10;
+
+ ip::icmp::resolver::results_type results11 = resolver.resolve(e);
+ (void)results11;
+
+ ip::icmp::resolver::results_type results12 = resolver.resolve(e, ec);
+ (void)results12;
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ resolver.async_resolve(q, resolve_handler());
+ int i1 = resolver.async_resolve(q, lazy);
+ (void)i1;
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ resolver.async_resolve("", "", resolve_handler());
+ int i2 = resolver.async_resolve("", "", lazy);
+ (void)i2;
+
+ resolver.async_resolve("", "",
+ ip::icmp::resolver::flags(), resolve_handler());
+ int i3 = resolver.async_resolve("", "",
+ ip::icmp::resolver::flags(), lazy);
+ (void)i3;
+ resolver.async_resolve(ip::icmp::v4(), "", "", resolve_handler());
+ int i4 = resolver.async_resolve(ip::icmp::v4(), "", "", lazy);
+ (void)i4;
+
+ 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;
+
+ resolver.async_resolve(e, resolve_handler());
+ int i6 = resolver.async_resolve(e, lazy);
+ (void)i6;
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace ip_icmp_resolver_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ip/icmp",
+ BOOST_ASIO_TEST_CASE(ip_icmp_socket_compile::test)
+ BOOST_ASIO_TEST_CASE(ip_icmp_resolver_compile::test)
+)
diff --git a/src/boost/libs/asio/test/ip/multicast.cpp b/src/boost/libs/asio/test/ip/multicast.cpp
new file mode 100644
index 000000000..09b0a745e
--- /dev/null
+++ b/src/boost/libs/asio/test/ip/multicast.cpp
@@ -0,0 +1,363 @@
+//
+// multicast.cpp
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ip/multicast.hpp>
+
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/ip/udp.hpp>
+#include "../unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+// ip_multicast_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all nested classes, enums and constants in
+// ip::multicast compile and link correctly. Runtime failures are ignored.
+
+namespace ip_multicast_compile {
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ try
+ {
+ io_context ioc;
+ ip::udp::socket sock(ioc);
+ const ip::address address;
+ const ip::address_v4 address_v4;
+ const ip::address_v6 address_v6;
+
+ // join_group class.
+
+ ip::multicast::join_group join_group1;
+ ip::multicast::join_group join_group2(address);
+ ip::multicast::join_group join_group3(address_v4);
+ ip::multicast::join_group join_group4(address_v4, address_v4);
+ ip::multicast::join_group join_group5(address_v6);
+ ip::multicast::join_group join_group6(address_v6, 1);
+ sock.set_option(join_group6);
+
+ // leave_group class.
+
+ ip::multicast::leave_group leave_group1;
+ ip::multicast::leave_group leave_group2(address);
+ ip::multicast::leave_group leave_group3(address_v4);
+ ip::multicast::leave_group leave_group4(address_v4, address_v4);
+ ip::multicast::leave_group leave_group5(address_v6);
+ ip::multicast::leave_group leave_group6(address_v6, 1);
+ sock.set_option(leave_group6);
+
+ // outbound_interface class.
+
+ ip::multicast::outbound_interface outbound_interface1;
+ ip::multicast::outbound_interface outbound_interface2(address_v4);
+ ip::multicast::outbound_interface outbound_interface3(1);
+ sock.set_option(outbound_interface3);
+
+ // hops class.
+
+ ip::multicast::hops hops1(1024);
+ sock.set_option(hops1);
+ ip::multicast::hops hops2;
+ sock.get_option(hops2);
+ hops1 = 1;
+ (void)static_cast<int>(hops1.value());
+
+ // enable_loopback class.
+
+ ip::multicast::enable_loopback enable_loopback1(true);
+ sock.set_option(enable_loopback1);
+ ip::multicast::enable_loopback enable_loopback2;
+ sock.get_option(enable_loopback2);
+ enable_loopback1 = true;
+ (void)static_cast<bool>(enable_loopback1);
+ (void)static_cast<bool>(!enable_loopback1);
+ (void)static_cast<bool>(enable_loopback1.value());
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace ip_multicast_compile
+
+//------------------------------------------------------------------------------
+
+// ip_multicast_runtime test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks the runtime operation of the socket options defined
+// in the ip::multicast namespace.
+
+namespace ip_multicast_runtime {
+
+#if defined(__hpux)
+// HP-UX doesn't declare this function extern "C", so it is declared again here
+// to avoid a linker error about an undefined symbol.
+extern "C" unsigned int if_nametoindex(const char*);
+#endif // defined(__hpux)
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ io_context ioc;
+ boost::system::error_code ec;
+
+ ip::udp::endpoint ep_v4(ip::address_v4::loopback(), 0);
+ ip::udp::socket sock_v4(ioc);
+ sock_v4.open(ep_v4.protocol(), ec);
+ sock_v4.bind(ep_v4, ec);
+ bool have_v4 = !ec;
+
+ ip::udp::endpoint ep_v6(ip::address_v6::loopback(), 0);
+ ip::udp::socket sock_v6(ioc);
+ sock_v6.open(ep_v6.protocol(), ec);
+ sock_v6.bind(ep_v6, ec);
+ bool have_v6 = !ec;
+
+ BOOST_ASIO_CHECK(have_v4 || have_v6);
+
+#if defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ // Windows CE seems to have problems with some multicast group addresses.
+ // The following address works on CE, but as it is not a private multicast
+ // address it will not be used on other platforms.
+ const ip::address multicast_address_v4 = ip::make_address("239.0.0.4", ec);
+#else // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ const ip::address multicast_address_v4 = ip::make_address("239.255.0.1", ec);
+#endif // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ BOOST_ASIO_CHECK(!have_v4 || !ec);
+
+#if (defined(__MACH__) && defined(__APPLE__)) \
+ || defined(__FreeBSD__) \
+ || defined(__NetBSD__) \
+ || defined(__OpenBSD__)
+ const ip::address multicast_address_v6 = ip::make_address("ff02::1%lo0", ec);
+#else // (defined(__MACH__) && defined(__APPLE__))
+ // || defined(__FreeBSD__)
+ // || defined(__NetBSD__)
+ // || defined(__OpenBSD__)
+ const ip::address multicast_address_v6 = ip::make_address("ff01::1", ec);
+#endif // (defined(__MACH__) && defined(__APPLE__))
+ // || defined(__FreeBSD__)
+ // || defined(__NetBSD__)
+ // || defined(__OpenBSD__)
+ BOOST_ASIO_CHECK(!have_v6 || !ec);
+
+ // join_group class.
+
+ if (have_v4)
+ {
+ ip::multicast::join_group join_group(multicast_address_v4);
+ sock_v4.set_option(join_group, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec || ec == error::no_such_device,
+ ec.value() << ", " << ec.message());
+
+ if (!ec)
+ {
+ // leave_group class.
+
+ ip::multicast::leave_group leave_group(multicast_address_v4);
+ sock_v4.set_option(leave_group, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ }
+ }
+
+ if (have_v6)
+ {
+ ip::multicast::join_group join_group(multicast_address_v6);
+ sock_v6.set_option(join_group, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec || ec == error::no_such_device,
+ ec.value() << ", " << ec.message());
+
+ if (!ec)
+ {
+ // leave_group class.
+
+ ip::multicast::leave_group leave_group(multicast_address_v6);
+ sock_v6.set_option(leave_group, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ }
+ }
+
+ // outbound_interface class.
+
+ if (have_v4)
+ {
+ ip::multicast::outbound_interface outbound_interface(
+ ip::address_v4::loopback());
+ sock_v4.set_option(outbound_interface, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ }
+
+ if (have_v6)
+ {
+#if defined(__hpux)
+ ip::multicast::outbound_interface outbound_interface(if_nametoindex("lo0"));
+#else
+ ip::multicast::outbound_interface outbound_interface(1);
+#endif
+ sock_v6.set_option(outbound_interface, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ }
+
+ // hops class.
+
+ if (have_v4)
+ {
+ ip::multicast::hops hops1(1);
+ BOOST_ASIO_CHECK(hops1.value() == 1);
+ sock_v4.set_option(hops1, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+
+ ip::multicast::hops hops2;
+ sock_v4.get_option(hops2, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(hops2.value() == 1);
+
+ ip::multicast::hops hops3(0);
+ BOOST_ASIO_CHECK(hops3.value() == 0);
+ sock_v4.set_option(hops3, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+
+ ip::multicast::hops hops4;
+ sock_v4.get_option(hops4, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(hops4.value() == 0);
+ }
+
+ if (have_v6)
+ {
+ ip::multicast::hops hops1(1);
+ BOOST_ASIO_CHECK(hops1.value() == 1);
+ sock_v6.set_option(hops1, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+
+ ip::multicast::hops hops2;
+ sock_v6.get_option(hops2, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(hops2.value() == 1);
+
+ ip::multicast::hops hops3(0);
+ BOOST_ASIO_CHECK(hops3.value() == 0);
+ sock_v6.set_option(hops3, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+
+ ip::multicast::hops hops4;
+ sock_v6.get_option(hops4, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(hops4.value() == 0);
+ }
+
+ // enable_loopback class.
+
+ if (have_v4)
+ {
+ ip::multicast::enable_loopback enable_loopback1(true);
+ BOOST_ASIO_CHECK(enable_loopback1.value());
+ BOOST_ASIO_CHECK(static_cast<bool>(enable_loopback1));
+ BOOST_ASIO_CHECK(!!enable_loopback1);
+ sock_v4.set_option(enable_loopback1, ec);
+#if defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ // Option is not supported under Windows CE.
+ BOOST_ASIO_CHECK_MESSAGE(ec == boost::asio::error::no_protocol_option,
+ ec.value() << ", " << ec.message());
+#else // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+#endif // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+
+ ip::multicast::enable_loopback enable_loopback2;
+ sock_v4.get_option(enable_loopback2, ec);
+#if defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ // Not supported under Windows CE but can get value.
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+#else // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(enable_loopback2.value());
+ BOOST_ASIO_CHECK(static_cast<bool>(enable_loopback2));
+ BOOST_ASIO_CHECK(!!enable_loopback2);
+#endif // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+
+ ip::multicast::enable_loopback enable_loopback3(false);
+ BOOST_ASIO_CHECK(!enable_loopback3.value());
+ BOOST_ASIO_CHECK(!static_cast<bool>(enable_loopback3));
+ BOOST_ASIO_CHECK(!enable_loopback3);
+ sock_v4.set_option(enable_loopback3, ec);
+#if defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ // Option is not supported under Windows CE.
+ BOOST_ASIO_CHECK_MESSAGE(ec == boost::asio::error::no_protocol_option,
+ ec.value() << ", " << ec.message());
+#else // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+#endif // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+
+ ip::multicast::enable_loopback enable_loopback4;
+ sock_v4.get_option(enable_loopback4, ec);
+#if defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ // Not supported under Windows CE but can get value.
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+#else // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(!enable_loopback4.value());
+ BOOST_ASIO_CHECK(!static_cast<bool>(enable_loopback4));
+ BOOST_ASIO_CHECK(!enable_loopback4);
+#endif // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ }
+
+ if (have_v6)
+ {
+ ip::multicast::enable_loopback enable_loopback1(true);
+ BOOST_ASIO_CHECK(enable_loopback1.value());
+ BOOST_ASIO_CHECK(static_cast<bool>(enable_loopback1));
+ BOOST_ASIO_CHECK(!!enable_loopback1);
+ sock_v6.set_option(enable_loopback1, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+
+ ip::multicast::enable_loopback enable_loopback2;
+ sock_v6.get_option(enable_loopback2, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(enable_loopback2.value());
+ BOOST_ASIO_CHECK(static_cast<bool>(enable_loopback2));
+ BOOST_ASIO_CHECK(!!enable_loopback2);
+
+ ip::multicast::enable_loopback enable_loopback3(false);
+ BOOST_ASIO_CHECK(!enable_loopback3.value());
+ BOOST_ASIO_CHECK(!static_cast<bool>(enable_loopback3));
+ BOOST_ASIO_CHECK(!enable_loopback3);
+ sock_v6.set_option(enable_loopback3, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+
+ ip::multicast::enable_loopback enable_loopback4;
+ sock_v6.get_option(enable_loopback4, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(!enable_loopback4.value());
+ BOOST_ASIO_CHECK(!static_cast<bool>(enable_loopback4));
+ BOOST_ASIO_CHECK(!enable_loopback4);
+ }
+}
+
+} // namespace ip_multicast_runtime
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ip/multicast",
+ BOOST_ASIO_TEST_CASE(ip_multicast_compile::test)
+ BOOST_ASIO_TEST_CASE(ip_multicast_runtime::test)
+)
diff --git a/src/boost/libs/asio/test/ip/network_v4.cpp b/src/boost/libs/asio/test/ip/network_v4.cpp
new file mode 100644
index 000000000..59d10dc31
--- /dev/null
+++ b/src/boost/libs/asio/test/ip/network_v4.cpp
@@ -0,0 +1,314 @@
+//
+// network_v4.cpp
+// ~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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
+// 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 <boost/asio/ip/network_v4.hpp>
+
+#include "../unit_test.hpp"
+#include <sstream>
+
+//------------------------------------------------------------------------------
+
+// ip_network_v4_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// ip::network_v4 compile and link correctly. Runtime failures are ignored.
+
+namespace ip_network_v4_compile {
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ try
+ {
+ boost::system::error_code ec;
+
+ // network_v4 constructors.
+
+ ip::network_v4 net1(ip::make_address_v4("192.168.1.0"), 32);
+ ip::network_v4 net2(ip::make_address_v4("192.168.1.0"),
+ ip::make_address_v4("255.255.255.0"));
+
+ // network_v4 functions.
+
+ ip::address_v4 addr1 = net1.address();
+ (void)addr1;
+
+ unsigned short prefix_len = net1.prefix_length();
+ (void)prefix_len;
+
+ ip::address_v4 addr2 = net1.netmask();
+ (void)addr2;
+
+ ip::address_v4 addr3 = net1.network();
+ (void)addr3;
+
+ ip::address_v4 addr4 = net1.broadcast();
+ (void)addr4;
+
+ ip::address_v4_range hosts = net1.hosts();
+ (void)hosts;
+
+ ip::network_v4 net3 = net1.canonical();
+ (void)net3;
+
+ bool b1 = net1.is_host();
+ (void)b1;
+
+ bool b2 = net1.is_subnet_of(net2);
+ (void)b2;
+
+ std::string s1 = net1.to_string();
+ (void)s1;
+
+ std::string s2 = net1.to_string(ec);
+ (void)s2;
+
+ // network_v4 comparisons.
+
+ bool b3 = (net1 == net2);
+ (void)b3;
+
+ bool b4 = (net1 != net2);
+ (void)b4;
+
+ // network_v4 creation functions.
+
+ net1 = ip::make_network_v4(ip::address_v4(), 24);
+ net1 = ip::make_network_v4(ip::address_v4(), ip::address_v4());
+ net1 = ip::make_network_v4("10.0.0.0/8");
+ 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(BOOST_ASIO_HAS_STRING_VIEW)
+# if defined(BOOST_ASIO_HAS_STD_STRING_VIEW)
+ std::string_view string_view_value("10.0.0.0/8");
+# elif defined(BOOST_ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
+ std::experimental::string_view string_view_value("10.0.0.0/8");
+# endif // defined(BOOST_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(BOOST_ASIO_HAS_STRING_VIEW)
+
+ // network_v4 I/O.
+
+ std::ostringstream os;
+ os << net1;
+
+#if !defined(BOOST_NO_STD_WSTREAMBUF)
+ std::wostringstream wos;
+ wos << net1;
+#endif // !defined(BOOST_NO_STD_WSTREAMBUF)
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace ip_network_v4_compile
+
+//------------------------------------------------------------------------------
+
+// ip_network_v4_runtime test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that the various public member functions meet the
+// necessary postconditions.
+
+namespace ip_network_v4_runtime {
+
+void test()
+{
+ using boost::asio::ip::address_v4;
+ using boost::asio::ip::make_address_v4;
+ using boost::asio::ip::network_v4;
+ using boost::asio::ip::make_network_v4;
+
+ address_v4 addr = make_address_v4("1.2.3.4");
+
+ // calculate prefix length
+
+ network_v4 net1(addr, make_address_v4("255.255.255.0"));
+ BOOST_ASIO_CHECK(net1.prefix_length() == 24);
+
+ network_v4 net2(addr, make_address_v4("255.255.255.192"));
+ BOOST_ASIO_CHECK(net2.prefix_length() == 26);
+
+ network_v4 net3(addr, make_address_v4("128.0.0.0"));
+ BOOST_ASIO_CHECK(net3.prefix_length() == 1);
+
+ std::string msg;
+ try
+ {
+ make_network_v4(addr, make_address_v4("255.255.255.1"));
+ }
+ catch(std::exception& ex)
+ {
+ msg = ex.what();
+ }
+ BOOST_ASIO_CHECK(msg == std::string("non-contiguous netmask"));
+
+ msg.clear();
+ try
+ {
+ make_network_v4(addr, make_address_v4("0.255.255.0"));
+ }
+ catch(std::exception& ex)
+ {
+ msg = ex.what();
+ }
+ BOOST_ASIO_CHECK(msg == std::string("non-contiguous netmask"));
+
+ // calculate netmask
+
+ network_v4 net4(addr, 23);
+ BOOST_ASIO_CHECK(net4.netmask() == make_address_v4("255.255.254.0"));
+
+ network_v4 net5(addr, 12);
+ BOOST_ASIO_CHECK(net5.netmask() == make_address_v4("255.240.0.0"));
+
+ network_v4 net6(addr, 24);
+ BOOST_ASIO_CHECK(net6.netmask() == make_address_v4("255.255.255.0"));
+
+ network_v4 net7(addr, 16);
+ BOOST_ASIO_CHECK(net7.netmask() == make_address_v4("255.255.0.0"));
+
+ network_v4 net8(addr, 8);
+ BOOST_ASIO_CHECK(net8.netmask() == make_address_v4("255.0.0.0"));
+
+ network_v4 net9(addr, 32);
+ BOOST_ASIO_CHECK(net9.netmask() == make_address_v4("255.255.255.255"));
+
+ network_v4 net10(addr, 1);
+ BOOST_ASIO_CHECK(net10.netmask() == make_address_v4("128.0.0.0"));
+
+ network_v4 net11(addr, 0);
+ BOOST_ASIO_CHECK(net11.netmask() == make_address_v4("0.0.0.0"));
+
+ msg.clear();
+ try
+ {
+ make_network_v4(addr, 33);
+ }
+ catch(std::out_of_range& ex)
+ {
+ msg = ex.what();
+ }
+ BOOST_ASIO_CHECK(msg == std::string("prefix length too large"));
+
+ // construct address range from address and prefix length
+ BOOST_ASIO_CHECK(network_v4(make_address_v4("192.168.77.100"), 32).network() == make_address_v4("192.168.77.100"));
+ BOOST_ASIO_CHECK(network_v4(make_address_v4("192.168.77.100"), 24).network() == make_address_v4("192.168.77.0"));
+ BOOST_ASIO_CHECK(network_v4(make_address_v4("192.168.77.128"), 25).network() == make_address_v4("192.168.77.128"));
+
+ // construct address range from string in CIDR notation
+ BOOST_ASIO_CHECK(make_network_v4("192.168.77.100/32").network() == make_address_v4("192.168.77.100"));
+ BOOST_ASIO_CHECK(make_network_v4("192.168.77.100/24").network() == make_address_v4("192.168.77.0"));
+ BOOST_ASIO_CHECK(make_network_v4("192.168.77.128/25").network() == make_address_v4("192.168.77.128"));
+
+ // construct network from invalid string
+ boost::system::error_code ec;
+ make_network_v4("10.0.0.256/24", ec);
+ BOOST_ASIO_CHECK(!!ec);
+ make_network_v4("10.0.0.0/33", ec);
+ BOOST_ASIO_CHECK(!!ec);
+ make_network_v4("10.0.0.0/-1", ec);
+ BOOST_ASIO_CHECK(!!ec);
+ make_network_v4("10.0.0.0/", ec);
+ BOOST_ASIO_CHECK(!!ec);
+ make_network_v4("10.0.0.0", ec);
+ BOOST_ASIO_CHECK(!!ec);
+
+ // prefix length
+ BOOST_ASIO_CHECK(make_network_v4("193.99.144.80/24").prefix_length() == 24);
+ BOOST_ASIO_CHECK(network_v4(make_address_v4("193.99.144.80"), 24).prefix_length() == 24);
+ BOOST_ASIO_CHECK(network_v4(make_address_v4("192.168.77.0"), make_address_v4("255.255.255.0")).prefix_length() == 24);
+
+ // to string
+ std::string a("192.168.77.0/32");
+ BOOST_ASIO_CHECK(make_network_v4(a.c_str()).to_string() == a);
+ BOOST_ASIO_CHECK(network_v4(make_address_v4("192.168.77.10"), 24).to_string() == std::string("192.168.77.10/24"));
+
+ // return host part
+ BOOST_ASIO_CHECK(make_network_v4("192.168.77.11/24").address() == make_address_v4("192.168.77.11"));
+
+ // return host in CIDR notation
+ BOOST_ASIO_CHECK(make_network_v4("192.168.78.30/20").address().to_string() == "192.168.78.30");
+
+ // return network in CIDR notation
+ BOOST_ASIO_CHECK(make_network_v4("192.168.78.30/20").canonical().to_string() == "192.168.64.0/20");
+
+ // is host
+ BOOST_ASIO_CHECK(make_network_v4("192.168.77.0/32").is_host());
+ BOOST_ASIO_CHECK(!make_network_v4("192.168.77.0/31").is_host());
+
+ // is real subnet of
+ BOOST_ASIO_CHECK(make_network_v4("192.168.0.192/24").is_subnet_of(make_network_v4("192.168.0.0/16")));
+ BOOST_ASIO_CHECK(make_network_v4("192.168.0.0/24").is_subnet_of(make_network_v4("192.168.192.168/16")));
+ BOOST_ASIO_CHECK(make_network_v4("192.168.0.192/24").is_subnet_of(make_network_v4("192.168.192.168/16")));
+ BOOST_ASIO_CHECK(make_network_v4("192.168.0.0/24").is_subnet_of(make_network_v4("192.168.0.0/16")));
+ BOOST_ASIO_CHECK(make_network_v4("192.168.0.0/24").is_subnet_of(make_network_v4("192.168.0.0/23")));
+ BOOST_ASIO_CHECK(make_network_v4("192.168.0.0/24").is_subnet_of(make_network_v4("192.168.0.0/0")));
+ BOOST_ASIO_CHECK(make_network_v4("192.168.0.0/32").is_subnet_of(make_network_v4("192.168.0.0/24")));
+
+ BOOST_ASIO_CHECK(!make_network_v4("192.168.0.0/32").is_subnet_of(make_network_v4("192.168.0.0/32")));
+ BOOST_ASIO_CHECK(!make_network_v4("192.168.0.0/24").is_subnet_of(make_network_v4("192.168.1.0/24")));
+ BOOST_ASIO_CHECK(!make_network_v4("192.168.0.0/16").is_subnet_of(make_network_v4("192.168.1.0/24")));
+
+ network_v4 r(make_network_v4("192.168.0.0/24"));
+ BOOST_ASIO_CHECK(!r.is_subnet_of(r));
+
+ network_v4 net12(make_network_v4("192.168.0.2/24"));
+ network_v4 net13(make_network_v4("192.168.1.1/28"));
+ network_v4 net14(make_network_v4("192.168.1.21/28"));
+ // network
+ BOOST_ASIO_CHECK(net12.network() == make_address_v4("192.168.0.0"));
+ BOOST_ASIO_CHECK(net13.network() == make_address_v4("192.168.1.0"));
+ BOOST_ASIO_CHECK(net14.network() == make_address_v4("192.168.1.16"));
+ // netmask
+ BOOST_ASIO_CHECK(net12.netmask() == make_address_v4("255.255.255.0"));
+ BOOST_ASIO_CHECK(net13.netmask() == make_address_v4("255.255.255.240"));
+ BOOST_ASIO_CHECK(net14.netmask() == make_address_v4("255.255.255.240"));
+ // broadcast
+ BOOST_ASIO_CHECK(net12.broadcast() == make_address_v4("192.168.0.255"));
+ BOOST_ASIO_CHECK(net13.broadcast() == make_address_v4("192.168.1.15"));
+ BOOST_ASIO_CHECK(net14.broadcast() == make_address_v4("192.168.1.31"));
+ // iterator
+ BOOST_ASIO_CHECK(std::distance(net12.hosts().begin(),net12.hosts().end()) == 254);
+ BOOST_ASIO_CHECK(*net12.hosts().begin() == make_address_v4("192.168.0.1"));
+ BOOST_ASIO_CHECK(net12.hosts().end() != net12.hosts().find(make_address_v4("192.168.0.10")));
+ BOOST_ASIO_CHECK(net12.hosts().end() == net12.hosts().find(make_address_v4("192.168.1.10")));
+ BOOST_ASIO_CHECK(std::distance(net13.hosts().begin(),net13.hosts().end()) == 14);
+ BOOST_ASIO_CHECK(*net13.hosts().begin() == make_address_v4("192.168.1.1"));
+ BOOST_ASIO_CHECK(net13.hosts().end() != net13.hosts().find(make_address_v4("192.168.1.14")));
+ BOOST_ASIO_CHECK(net13.hosts().end() == net13.hosts().find(make_address_v4("192.168.1.15")));
+ BOOST_ASIO_CHECK(std::distance(net14.hosts().begin(),net14.hosts().end()) == 14);
+ BOOST_ASIO_CHECK(*net14.hosts().begin() == make_address_v4("192.168.1.17"));
+ BOOST_ASIO_CHECK(net14.hosts().end() != net14.hosts().find(make_address_v4("192.168.1.30")));
+ BOOST_ASIO_CHECK(net14.hosts().end() == net14.hosts().find(make_address_v4("192.168.1.31")));
+}
+
+} // namespace ip_network_v4_runtime
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ip/network_v4",
+ BOOST_ASIO_TEST_CASE(ip_network_v4_compile::test)
+ BOOST_ASIO_TEST_CASE(ip_network_v4_runtime::test)
+)
diff --git a/src/boost/libs/asio/test/ip/network_v6.cpp b/src/boost/libs/asio/test/ip/network_v6.cpp
new file mode 100644
index 000000000..cfe97ce61
--- /dev/null
+++ b/src/boost/libs/asio/test/ip/network_v6.cpp
@@ -0,0 +1,238 @@
+//
+// network_v6.cpp
+// ~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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
+// 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 <boost/asio/ip/network_v6.hpp>
+
+#include "../unit_test.hpp"
+#include <sstream>
+
+//------------------------------------------------------------------------------
+
+// ip_network_v6_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// ip::network_v6 compile and link correctly. Runtime failures are ignored.
+
+namespace ip_network_v6_compile {
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ try
+ {
+ boost::system::error_code ec;
+
+ // network_v6 constructors.
+
+ ip::network_v6 net1(ip::make_address_v6("2001:370::10:7344"), 64);
+ ip::network_v6 net2(ip::make_address_v6("2001:370::10:7345"), 96);
+
+ // network_v6 functions.
+
+ ip::address_v6 addr1 = net1.address();
+ (void)addr1;
+
+ unsigned short prefix_len = net1.prefix_length();
+ (void)prefix_len;
+
+ ip::address_v6 addr3 = net1.network();
+ (void)addr3;
+
+ ip::address_v6_range hosts = net1.hosts();
+ (void)hosts;
+
+ ip::network_v6 net3 = net1.canonical();
+ (void)net3;
+
+ bool b1 = net1.is_host();
+ (void)b1;
+
+ bool b2 = net1.is_subnet_of(net2);
+ (void)b2;
+
+ std::string s1 = net1.to_string();
+ (void)s1;
+
+ std::string s2 = net1.to_string(ec);
+ (void)s2;
+
+ // network_v6 comparisons.
+
+ bool b3 = (net1 == net2);
+ (void)b3;
+
+ bool b4 = (net1 != net2);
+ (void)b4;
+
+ // network_v6 creation functions.
+
+ net1 = ip::make_network_v6(ip::address_v6(), 24);
+ net1 = ip::make_network_v6("10.0.0.0/8");
+ 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(BOOST_ASIO_HAS_STRING_VIEW)
+# if defined(BOOST_ASIO_HAS_STD_STRING_VIEW)
+ std::string_view string_view_value("0::0/8");
+# elif defined(BOOST_ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
+ std::experimental::string_view string_view_value("0::0/8");
+# endif // defined(BOOST_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(BOOST_ASIO_STD_STRING_VIEW)
+
+ // network_v6 I/O.
+
+ std::ostringstream os;
+ os << net1;
+
+#if !defined(BOOST_NO_STD_WSTREAMBUF)
+ std::wostringstream wos;
+ wos << net1;
+#endif // !defined(BOOST_NO_STD_WSTREAMBUF)
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace ip_network_v6_compile
+
+//------------------------------------------------------------------------------
+
+// ip_network_v6_runtime test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that the various public member functions meet the
+// necessary postconditions.
+
+namespace ip_network_v6_runtime {
+
+void test()
+{
+ using boost::asio::ip::address_v6;
+ using boost::asio::ip::make_address_v6;
+ using boost::asio::ip::network_v6;
+ using boost::asio::ip::make_network_v6;
+
+ address_v6 addr = make_address_v6("2001:370::10:7344");
+
+ std::string msg;
+ try
+ {
+ make_network_v6(addr, 129);
+ }
+ catch(std::out_of_range& ex)
+ {
+ msg = ex.what();
+ }
+ BOOST_ASIO_CHECK(msg == std::string("prefix length too large"));
+
+ // construct address range from address and prefix length
+ BOOST_ASIO_CHECK(network_v6(make_address_v6("2001:370::10:7344"), 128).network() == make_address_v6("2001:370::10:7344"));
+ BOOST_ASIO_CHECK(network_v6(make_address_v6("2001:370::10:7344"), 64).network() == make_address_v6("2001:370::"));
+ BOOST_ASIO_CHECK(network_v6(make_address_v6("2001:370::10:7344"), 27).network() == make_address_v6("2001:360::"));
+
+ // construct address range from string in CIDR notation
+ BOOST_ASIO_CHECK(make_network_v6("2001:370::10:7344/128").network() == make_address_v6("2001:370::10:7344"));
+ BOOST_ASIO_CHECK(make_network_v6("2001:370::10:7344/64").network() == make_address_v6("2001:370::"));
+ BOOST_ASIO_CHECK(make_network_v6("2001:370::10:7344/27").network() == make_address_v6("2001:360::"));
+
+ // construct network from invalid string
+ boost::system::error_code ec;
+ make_network_v6("a:b/24", ec);
+ BOOST_ASIO_CHECK(!!ec);
+ make_network_v6("2001:370::10:7344/129", ec);
+ BOOST_ASIO_CHECK(!!ec);
+ make_network_v6("2001:370::10:7344/-1", ec);
+ BOOST_ASIO_CHECK(!!ec);
+ make_network_v6("2001:370::10:7344/", ec);
+ BOOST_ASIO_CHECK(!!ec);
+ make_network_v6("2001:370::10:7344", ec);
+ BOOST_ASIO_CHECK(!!ec);
+
+ // prefix length
+ BOOST_ASIO_CHECK(make_network_v6("2001:370::10:7344/128").prefix_length() == 128);
+ BOOST_ASIO_CHECK(network_v6(make_address_v6("2001:370::10:7344"), 27).prefix_length() == 27);
+
+ // to string
+ std::string a("2001:370::10:7344/64");
+ BOOST_ASIO_CHECK(make_network_v6(a.c_str()).to_string() == a);
+ BOOST_ASIO_CHECK(network_v6(make_address_v6("2001:370::10:7344"), 27).to_string() == std::string("2001:370::10:7344/27"));
+
+ // return host part
+ BOOST_ASIO_CHECK(make_network_v6("2001:370::10:7344/64").address() == make_address_v6("2001:370::10:7344"));
+ BOOST_ASIO_CHECK(make_network_v6("2001:370::10:7344/27").address().to_string() == "2001:370::10:7344");
+
+ // return network in CIDR notation
+ BOOST_ASIO_CHECK(make_network_v6("2001:370::10:7344/27").canonical().to_string() == "2001:360::/27");
+
+ // is host
+ BOOST_ASIO_CHECK(make_network_v6("2001:370::10:7344/128").is_host());
+ BOOST_ASIO_CHECK(!make_network_v6("2001:370::10:7344/127").is_host());
+
+ // is real subnet of
+ BOOST_ASIO_CHECK(make_network_v6("2001:370::10:3744/64").is_subnet_of(make_network_v6("2001:370::/16")));
+ BOOST_ASIO_CHECK(make_network_v6("2001:370::/64").is_subnet_of(make_network_v6("2001:370::/16")));
+ BOOST_ASIO_CHECK(make_network_v6("2001:0db8:85a3::/64").is_subnet_of(make_network_v6("2001:0d00::/24")));
+
+ BOOST_ASIO_CHECK(!make_network_v6("2001:370::10:3744/128").is_subnet_of(make_network_v6("2001:370::10:3744/128")));
+ BOOST_ASIO_CHECK(make_network_v6("2001:0db8:85a3::/64").is_subnet_of(make_network_v6("2001:0dc0::/24")));
+
+ network_v6 r(make_network_v6("2001:370::/64"));
+ BOOST_ASIO_CHECK(!r.is_subnet_of(r));
+
+ network_v6 net12(make_network_v6("2001:370::10:7344/64"));
+ network_v6 net13(make_network_v6("2001:0db8::/127"));
+ network_v6 net14(make_network_v6("2001:0db8::/125"));
+ network_v6 net15(make_network_v6("2001:0db8::/119"));
+
+ // network
+ BOOST_ASIO_CHECK(net12.network() == make_address_v6("2001:370::"));
+ BOOST_ASIO_CHECK(net13.network() == make_address_v6("2001:0db8::"));
+ BOOST_ASIO_CHECK(net14.network() == make_address_v6("2001:0db8::"));
+ BOOST_ASIO_CHECK(net15.network() == make_address_v6("2001:0db8::"));
+
+ // iterator
+ //BOOST_ASIO_CHECK(std::distance(net12.hosts().begin(),net12.hosts().end()) == 18446744073709552000);
+ BOOST_ASIO_CHECK(std::distance(net13.hosts().begin(),net13.hosts().end()) == 2);
+ BOOST_ASIO_CHECK(std::distance(net14.hosts().begin(),net14.hosts().end()) == 8);
+ BOOST_ASIO_CHECK(std::distance(net15.hosts().begin(),net15.hosts().end()) == 512);
+ BOOST_ASIO_CHECK(*net12.hosts().begin() == make_address_v6("2001:0370::"));
+ BOOST_ASIO_CHECK(net12.hosts().end() != net12.hosts().find(make_address_v6("2001:0370::ffff:ffff:ffff:ffff")));
+ BOOST_ASIO_CHECK(*net13.hosts().begin() == make_address_v6("2001:0db8::"));
+ BOOST_ASIO_CHECK(net13.hosts().end() != net13.hosts().find(make_address_v6("2001:0db8::1")));
+ BOOST_ASIO_CHECK(net13.hosts().end() == net13.hosts().find(make_address_v6("2001:0db8::2")));
+ BOOST_ASIO_CHECK(*net14.hosts().begin() == make_address_v6("2001:0db8::"));
+ BOOST_ASIO_CHECK(net14.hosts().end() != net14.hosts().find(make_address_v6("2001:0db8::7")));
+ BOOST_ASIO_CHECK(net14.hosts().end() == net14.hosts().find(make_address_v6("2001:0db8::8")));
+ BOOST_ASIO_CHECK(*net15.hosts().begin() == make_address_v6("2001:0db8::"));
+ BOOST_ASIO_CHECK(net15.hosts().end() != net15.hosts().find(make_address_v6("2001:0db8::01ff")));
+ BOOST_ASIO_CHECK(net15.hosts().end() == net15.hosts().find(make_address_v6("2001:0db8::0200")));
+}
+
+} // namespace ip_network_v6_runtime
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ip/network_v6",
+ BOOST_ASIO_TEST_CASE(ip_network_v6_compile::test)
+ BOOST_ASIO_TEST_CASE(ip_network_v6_runtime::test)
+)
diff --git a/src/boost/libs/asio/test/ip/resolver_query_base.cpp b/src/boost/libs/asio/test/ip/resolver_query_base.cpp
new file mode 100644
index 000000000..d955a96ae
--- /dev/null
+++ b/src/boost/libs/asio/test/ip/resolver_query_base.cpp
@@ -0,0 +1,25 @@
+//
+// resolver_query_base.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ip/resolver_query_base.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ip/resolver_query_base",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/ip/tcp.cpp b/src/boost/libs/asio/test/ip/tcp.cpp
new file mode 100644
index 000000000..fc204ea5d
--- /dev/null
+++ b/src/boost/libs/asio/test/ip/tcp.cpp
@@ -0,0 +1,1346 @@
+//
+// tcp.cpp
+// ~~~~~~~
+//
+// Copyright (c) 2003-2020 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)
+
+// Enable cancel() support on Windows.
+#define BOOST_ASIO_ENABLE_CANCELIO 1
+
+// Test that header file is self-contained.
+#include <boost/asio/ip/tcp.hpp>
+
+#include <cstring>
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/read.hpp>
+#include <boost/asio/write.hpp>
+#include "../unit_test.hpp"
+#include "../archetypes/async_result.hpp"
+#include "../archetypes/gettable_socket_option.hpp"
+#include "../archetypes/io_control_command.hpp"
+#include "../archetypes/settable_socket_option.hpp"
+
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+# include <boost/array.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+# include <array>
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <boost/bind/bind.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <functional>
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+
+//------------------------------------------------------------------------------
+
+// ip_tcp_compile test
+// ~~~~~~~~~~~~~~~~~~~
+// The following test checks that all nested classes, enums and constants in
+// ip::tcp compile and link correctly. Runtime failures are ignored.
+
+namespace ip_tcp_compile {
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ try
+ {
+ io_context ioc;
+ ip::tcp::socket sock(ioc);
+
+ // no_delay class.
+
+ ip::tcp::no_delay no_delay1(true);
+ sock.set_option(no_delay1);
+ ip::tcp::no_delay no_delay2;
+ sock.get_option(no_delay2);
+ no_delay1 = true;
+ (void)static_cast<bool>(no_delay1);
+ (void)static_cast<bool>(!no_delay1);
+ (void)static_cast<bool>(no_delay1.value());
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace ip_tcp_compile
+
+//------------------------------------------------------------------------------
+
+// ip_tcp_runtime test
+// ~~~~~~~~~~~~~~~~~~~
+// The following test checks the runtime operation of the ip::tcp class.
+
+namespace ip_tcp_runtime {
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ io_context ioc;
+ ip::tcp::socket sock(ioc, ip::tcp::v4());
+ boost::system::error_code ec;
+
+ // no_delay class.
+
+ ip::tcp::no_delay no_delay1(true);
+ BOOST_ASIO_CHECK(no_delay1.value());
+ BOOST_ASIO_CHECK(static_cast<bool>(no_delay1));
+ BOOST_ASIO_CHECK(!!no_delay1);
+ sock.set_option(no_delay1, ec);
+ BOOST_ASIO_CHECK(!ec);
+
+ ip::tcp::no_delay no_delay2;
+ sock.get_option(no_delay2, ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(no_delay2.value());
+ BOOST_ASIO_CHECK(static_cast<bool>(no_delay2));
+ BOOST_ASIO_CHECK(!!no_delay2);
+
+ ip::tcp::no_delay no_delay3(false);
+ BOOST_ASIO_CHECK(!no_delay3.value());
+ BOOST_ASIO_CHECK(!static_cast<bool>(no_delay3));
+ BOOST_ASIO_CHECK(!no_delay3);
+ sock.set_option(no_delay3, ec);
+ BOOST_ASIO_CHECK(!ec);
+
+ ip::tcp::no_delay no_delay4;
+ sock.get_option(no_delay4, ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(!no_delay4.value());
+ BOOST_ASIO_CHECK(!static_cast<bool>(no_delay4));
+ BOOST_ASIO_CHECK(!no_delay4);
+}
+
+} // namespace ip_tcp_runtime
+
+//------------------------------------------------------------------------------
+
+// ip_tcp_socket_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// ip::tcp::socket compile and link correctly. Runtime failures are ignored.
+
+namespace ip_tcp_socket_compile {
+
+struct connect_handler
+{
+ connect_handler() {}
+ void operator()(const boost::system::error_code&) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ connect_handler(connect_handler&&) {}
+private:
+ connect_handler(const connect_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+
+struct wait_handler
+{
+ wait_handler() {}
+ void operator()(const boost::system::error_code&) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ wait_handler(wait_handler&&) {}
+private:
+ wait_handler(const wait_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+
+struct send_handler
+{
+ send_handler() {}
+ void operator()(const boost::system::error_code&, std::size_t) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ send_handler(send_handler&&) {}
+private:
+ send_handler(const send_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+
+struct receive_handler
+{
+ receive_handler() {}
+ void operator()(const boost::system::error_code&, std::size_t) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ receive_handler(receive_handler&&) {}
+private:
+ receive_handler(const receive_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+
+struct write_some_handler
+{
+ write_some_handler() {}
+ void operator()(const boost::system::error_code&, std::size_t) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ write_some_handler(write_some_handler&&) {}
+private:
+ write_some_handler(const write_some_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+
+struct read_some_handler
+{
+ read_some_handler() {}
+ void operator()(const boost::system::error_code&, std::size_t) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ read_some_handler(read_some_handler&&) {}
+private:
+ read_some_handler(const read_some_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+
+void test()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+ using boost::array;
+#else // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+ using std::array;
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ 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<boost::asio::mutable_buffer, 2> mutable_buffers = {{
+ boost::asio::buffer(mutable_char_buffer, 10),
+ boost::asio::buffer(mutable_char_buffer + 10, 10) }};
+ array<boost::asio::const_buffer, 2> const_buffers = {{
+ boost::asio::buffer(const_char_buffer, 10),
+ boost::asio::buffer(const_char_buffer + 10, 10) }};
+ socket_base::message_flags in_flags = 0;
+ archetypes::settable_socket_option<void> settable_socket_option1;
+ archetypes::settable_socket_option<int> settable_socket_option2;
+ archetypes::settable_socket_option<double> settable_socket_option3;
+ archetypes::gettable_socket_option<void> gettable_socket_option1;
+ archetypes::gettable_socket_option<int> gettable_socket_option2;
+ archetypes::gettable_socket_option<double> gettable_socket_option3;
+ archetypes::io_control_command io_control_command;
+ archetypes::lazy_handler lazy;
+ boost::system::error_code ec;
+
+ // basic_stream_socket constructors.
+
+ ip::tcp::socket socket1(ioc);
+ ip::tcp::socket socket2(ioc, ip::tcp::v4());
+ ip::tcp::socket socket3(ioc, ip::tcp::v6());
+ ip::tcp::socket socket4(ioc, ip::tcp::endpoint(ip::tcp::v4(), 0));
+ ip::tcp::socket socket5(ioc, ip::tcp::endpoint(ip::tcp::v6(), 0));
+#if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
+ ip::tcp::socket::native_handle_type native_socket1
+ = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ ip::tcp::socket socket6(ioc, ip::tcp::v4(), native_socket1);
+#endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME)
+
+ 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(BOOST_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(BOOST_ASIO_WINDOWS_RUNTIME)
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ ip::tcp::socket socket13(std::move(socket5));
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_stream_socket operators.
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ socket1 = ip::tcp::socket(ioc);
+ socket1 = std::move(socket2);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_io_object functions.
+
+ ip::tcp::socket::executor_type ex = socket1.get_executor();
+ (void)ex;
+
+ // basic_socket functions.
+
+ ip::tcp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer();
+ (void)lowest_layer;
+
+ const ip::tcp::socket& socket14 = socket1;
+ const ip::tcp::socket::lowest_layer_type& lowest_layer2
+ = socket14.lowest_layer();
+ (void)lowest_layer2;
+
+ socket1.open(ip::tcp::v4());
+ socket1.open(ip::tcp::v6());
+ socket1.open(ip::tcp::v4(), ec);
+ socket1.open(ip::tcp::v6(), ec);
+
+#if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
+ ip::tcp::socket::native_handle_type native_socket3
+ = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ 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(BOOST_ASIO_WINDOWS_RUNTIME)
+
+ bool is_open = socket1.is_open();
+ (void)is_open;
+
+ socket1.close();
+ socket1.close(ec);
+
+ socket1.release();
+ socket1.release(ec);
+
+ ip::tcp::socket::native_handle_type native_socket5
+ = socket1.native_handle();
+ (void)native_socket5;
+
+ 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(ip::tcp::endpoint(ip::tcp::v4(), 0));
+ socket1.bind(ip::tcp::endpoint(ip::tcp::v6(), 0));
+ socket1.bind(ip::tcp::endpoint(ip::tcp::v4(), 0), ec);
+ socket1.bind(ip::tcp::endpoint(ip::tcp::v6(), 0), ec);
+
+ socket1.connect(ip::tcp::endpoint(ip::tcp::v4(), 0));
+ socket1.connect(ip::tcp::endpoint(ip::tcp::v6(), 0));
+ socket1.connect(ip::tcp::endpoint(ip::tcp::v4(), 0), ec);
+ socket1.connect(ip::tcp::endpoint(ip::tcp::v6(), 0), ec);
+
+ socket1.async_connect(ip::tcp::endpoint(ip::tcp::v4(), 0),
+ connect_handler());
+ socket1.async_connect(ip::tcp::endpoint(ip::tcp::v6(), 0),
+ connect_handler());
+ 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;
+
+ socket1.set_option(settable_socket_option1);
+ socket1.set_option(settable_socket_option1, ec);
+ socket1.set_option(settable_socket_option2);
+ socket1.set_option(settable_socket_option2, ec);
+ socket1.set_option(settable_socket_option3);
+ socket1.set_option(settable_socket_option3, ec);
+
+ socket1.get_option(gettable_socket_option1);
+ socket1.get_option(gettable_socket_option1, ec);
+ socket1.get_option(gettable_socket_option2);
+ socket1.get_option(gettable_socket_option2, ec);
+ socket1.get_option(gettable_socket_option3);
+ socket1.get_option(gettable_socket_option3, ec);
+
+ socket1.io_control(io_control_command);
+ socket1.io_control(io_control_command, ec);
+
+ bool non_blocking1 = socket1.non_blocking();
+ (void)non_blocking1;
+ socket1.non_blocking(true);
+ socket1.non_blocking(false, ec);
+
+ bool non_blocking2 = socket1.native_non_blocking();
+ (void)non_blocking2;
+ socket1.native_non_blocking(true);
+ 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);
+
+ socket1.wait(socket_base::wait_read);
+ socket1.wait(socket_base::wait_write, ec);
+
+ socket1.async_wait(socket_base::wait_read, wait_handler());
+ int i3 = socket1.async_wait(socket_base::wait_write, lazy);
+ (void)i3;
+
+ // basic_stream_socket functions.
+
+ socket1.send(buffer(mutable_char_buffer));
+ socket1.send(buffer(const_char_buffer));
+ socket1.send(mutable_buffers);
+ socket1.send(const_buffers);
+ socket1.send(null_buffers());
+ socket1.send(buffer(mutable_char_buffer), in_flags);
+ socket1.send(buffer(const_char_buffer), in_flags);
+ socket1.send(mutable_buffers, in_flags);
+ socket1.send(const_buffers, 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(mutable_buffers, in_flags, ec);
+ socket1.send(const_buffers, in_flags, ec);
+ socket1.send(null_buffers(), in_flags, ec);
+
+ socket1.async_send(buffer(mutable_char_buffer), send_handler());
+ socket1.async_send(buffer(const_char_buffer), send_handler());
+ socket1.async_send(mutable_buffers, send_handler());
+ socket1.async_send(const_buffers, send_handler());
+ socket1.async_send(null_buffers(), send_handler());
+ 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(mutable_buffers, in_flags, send_handler());
+ socket1.async_send(const_buffers, in_flags, send_handler());
+ socket1.async_send(null_buffers(), in_flags, send_handler());
+ int i4 = socket1.async_send(buffer(mutable_char_buffer), lazy);
+ (void)i4;
+ int i5 = socket1.async_send(buffer(const_char_buffer), lazy);
+ (void)i5;
+ int i6 = socket1.async_send(mutable_buffers, lazy);
+ (void)i6;
+ int i7 = socket1.async_send(const_buffers, lazy);
+ (void)i7;
+ int i8 = socket1.async_send(null_buffers(), lazy);
+ (void)i8;
+ int i9 = socket1.async_send(buffer(mutable_char_buffer), in_flags, lazy);
+ (void)i9;
+ int i10 = socket1.async_send(buffer(const_char_buffer), in_flags, lazy);
+ (void)i10;
+ int i11 = socket1.async_send(mutable_buffers, in_flags, lazy);
+ (void)i11;
+ int i12 = socket1.async_send(const_buffers, in_flags, lazy);
+ (void)i12;
+ int i13 = socket1.async_send(null_buffers(), in_flags, lazy);
+ (void)i13;
+
+ socket1.receive(buffer(mutable_char_buffer));
+ socket1.receive(mutable_buffers);
+ socket1.receive(null_buffers());
+ socket1.receive(buffer(mutable_char_buffer), in_flags);
+ socket1.receive(mutable_buffers, in_flags);
+ socket1.receive(null_buffers(), in_flags);
+ socket1.receive(buffer(mutable_char_buffer), in_flags, ec);
+ socket1.receive(mutable_buffers, in_flags, ec);
+ socket1.receive(null_buffers(), in_flags, ec);
+
+ socket1.async_receive(buffer(mutable_char_buffer), receive_handler());
+ socket1.async_receive(mutable_buffers, receive_handler());
+ socket1.async_receive(null_buffers(), receive_handler());
+ socket1.async_receive(buffer(mutable_char_buffer), in_flags,
+ receive_handler());
+ socket1.async_receive(mutable_buffers, in_flags, receive_handler());
+ socket1.async_receive(null_buffers(), in_flags, receive_handler());
+ int i14 = socket1.async_receive(buffer(mutable_char_buffer), lazy);
+ (void)i14;
+ int i15 = socket1.async_receive(mutable_buffers, lazy);
+ (void)i15;
+ int i16 = socket1.async_receive(null_buffers(), lazy);
+ (void)i16;
+ int i17 = socket1.async_receive(buffer(mutable_char_buffer), in_flags,
+ lazy);
+ (void)i17;
+ int i18 = socket1.async_receive(mutable_buffers, in_flags, lazy);
+ (void)i18;
+ int i19 = socket1.async_receive(null_buffers(), in_flags, lazy);
+ (void)i19;
+
+ socket1.write_some(buffer(mutable_char_buffer));
+ socket1.write_some(buffer(const_char_buffer));
+ socket1.write_some(mutable_buffers);
+ socket1.write_some(const_buffers);
+ socket1.write_some(null_buffers());
+ socket1.write_some(buffer(mutable_char_buffer), ec);
+ socket1.write_some(buffer(const_char_buffer), ec);
+ socket1.write_some(mutable_buffers, ec);
+ socket1.write_some(const_buffers, ec);
+ socket1.write_some(null_buffers(), ec);
+
+ 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(mutable_buffers, write_some_handler());
+ socket1.async_write_some(const_buffers, write_some_handler());
+ socket1.async_write_some(null_buffers(), write_some_handler());
+ int i20 = socket1.async_write_some(buffer(mutable_char_buffer), lazy);
+ (void)i20;
+ int i21 = socket1.async_write_some(buffer(const_char_buffer), lazy);
+ (void)i21;
+ int i22 = socket1.async_write_some(mutable_buffers, lazy);
+ (void)i22;
+ int i23 = socket1.async_write_some(const_buffers, lazy);
+ (void)i23;
+ int i24 = socket1.async_write_some(null_buffers(), lazy);
+ (void)i24;
+
+ socket1.read_some(buffer(mutable_char_buffer));
+ socket1.read_some(mutable_buffers);
+ socket1.read_some(null_buffers());
+ socket1.read_some(buffer(mutable_char_buffer), ec);
+ socket1.read_some(mutable_buffers, ec);
+ socket1.read_some(null_buffers(), ec);
+
+ 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());
+ 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;
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace ip_tcp_socket_compile
+
+//------------------------------------------------------------------------------
+
+// ip_tcp_socket_runtime test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks the runtime operation of the ip::tcp::socket class.
+
+namespace ip_tcp_socket_runtime {
+
+static const char write_data[]
+ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+void handle_read_noop(const boost::system::error_code& err,
+ size_t bytes_transferred, bool* called)
+{
+ *called = true;
+ BOOST_ASIO_CHECK(!err);
+ BOOST_ASIO_CHECK(bytes_transferred == 0);
+}
+
+void handle_write_noop(const boost::system::error_code& err,
+ size_t bytes_transferred, bool* called)
+{
+ *called = true;
+ BOOST_ASIO_CHECK(!err);
+ BOOST_ASIO_CHECK(bytes_transferred == 0);
+}
+
+void handle_read(const boost::system::error_code& err,
+ size_t bytes_transferred, bool* called)
+{
+ *called = true;
+ BOOST_ASIO_CHECK(!err);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+}
+
+void handle_write(const boost::system::error_code& err,
+ size_t bytes_transferred, bool* called)
+{
+ *called = true;
+ BOOST_ASIO_CHECK(!err);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+}
+
+void handle_read_cancel(const boost::system::error_code& err,
+ size_t bytes_transferred, bool* called)
+{
+ *called = true;
+ BOOST_ASIO_CHECK(err == boost::asio::error::operation_aborted);
+ BOOST_ASIO_CHECK(bytes_transferred == 0);
+}
+
+void handle_read_eof(const boost::system::error_code& err,
+ size_t bytes_transferred, bool* called)
+{
+ *called = true;
+ BOOST_ASIO_CHECK(err == boost::asio::error::eof);
+ BOOST_ASIO_CHECK(bytes_transferred == 0);
+}
+
+void test()
+{
+ using namespace std; // For memcmp.
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ io_context ioc;
+
+ ip::tcp::acceptor acceptor(ioc, ip::tcp::endpoint(ip::tcp::v4(), 0));
+ ip::tcp::endpoint server_endpoint = acceptor.local_endpoint();
+ server_endpoint.address(ip::address_v4::loopback());
+
+ ip::tcp::socket client_side_socket(ioc);
+ ip::tcp::socket server_side_socket(ioc);
+
+ client_side_socket.connect(server_endpoint);
+ acceptor.accept(server_side_socket);
+
+ // No-op read.
+
+ bool read_noop_completed = false;
+ client_side_socket.async_read_some(
+ boost::asio::mutable_buffer(0, 0),
+ bindns::bind(handle_read_noop,
+ _1, _2, &read_noop_completed));
+
+ ioc.run();
+ BOOST_ASIO_CHECK(read_noop_completed);
+
+ // No-op write.
+
+ bool write_noop_completed = false;
+ client_side_socket.async_write_some(
+ boost::asio::const_buffer(0, 0),
+ bindns::bind(handle_write_noop,
+ _1, _2, &write_noop_completed));
+
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(write_noop_completed);
+
+ // Read and write to transfer data.
+
+ char read_buffer[sizeof(write_data)];
+ bool read_completed = false;
+ boost::asio::async_read(client_side_socket,
+ boost::asio::buffer(read_buffer),
+ bindns::bind(handle_read,
+ _1, _2, &read_completed));
+
+ bool write_completed = false;
+ boost::asio::async_write(server_side_socket,
+ boost::asio::buffer(write_data),
+ bindns::bind(handle_write,
+ _1, _2, &write_completed));
+
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(read_completed);
+ BOOST_ASIO_CHECK(write_completed);
+ BOOST_ASIO_CHECK(memcmp(read_buffer, write_data, sizeof(write_data)) == 0);
+
+ // Cancelled read.
+
+ bool read_cancel_completed = false;
+ boost::asio::async_read(server_side_socket,
+ boost::asio::buffer(read_buffer),
+ bindns::bind(handle_read_cancel,
+ _1, _2, &read_cancel_completed));
+
+ ioc.restart();
+ ioc.poll();
+ BOOST_ASIO_CHECK(!read_cancel_completed);
+
+ server_side_socket.cancel();
+
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(read_cancel_completed);
+
+ // A read when the peer closes socket should fail with eof.
+
+ bool read_eof_completed = false;
+ boost::asio::async_read(client_side_socket,
+ boost::asio::buffer(read_buffer),
+ bindns::bind(handle_read_eof,
+ _1, _2, &read_eof_completed));
+
+ server_side_socket.close();
+
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(read_eof_completed);
+}
+
+} // namespace ip_tcp_socket_runtime
+
+//------------------------------------------------------------------------------
+
+// ip_tcp_acceptor_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// ip::tcp::acceptor compile and link correctly. Runtime failures are ignored.
+
+namespace ip_tcp_acceptor_compile {
+
+struct wait_handler
+{
+ wait_handler() {}
+ void operator()(const boost::system::error_code&) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ wait_handler(wait_handler&&) {}
+private:
+ wait_handler(const wait_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+
+struct accept_handler
+{
+ accept_handler() {}
+ void operator()(const boost::system::error_code&) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ accept_handler(accept_handler&&) {}
+private:
+ accept_handler(const accept_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+struct move_accept_handler
+{
+ move_accept_handler() {}
+ void operator()(
+ const boost::system::error_code&, boost::asio::ip::tcp::socket) {}
+ move_accept_handler(move_accept_handler&&) {}
+private:
+ move_accept_handler(const move_accept_handler&) {}
+};
+
+struct move_accept_ioc_handler
+{
+ move_accept_ioc_handler() {}
+ void operator()(const boost::system::error_code&,
+ boost::asio::basic_stream_socket<boost::asio::ip::tcp,
+ boost::asio::io_context::executor_type>) {}
+ move_accept_ioc_handler(move_accept_handler&&) {}
+private:
+ move_accept_ioc_handler(const move_accept_handler&) {}
+};
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ try
+ {
+ io_context ioc;
+ const io_context::executor_type ioc_ex = ioc.get_executor();
+ ip::tcp::socket peer_socket1(ioc);
+ boost::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;
+ archetypes::settable_socket_option<double> settable_socket_option3;
+ archetypes::gettable_socket_option<void> gettable_socket_option1;
+ archetypes::gettable_socket_option<int> gettable_socket_option2;
+ archetypes::gettable_socket_option<double> gettable_socket_option3;
+ archetypes::io_control_command io_control_command;
+ archetypes::lazy_handler lazy;
+ boost::system::error_code ec;
+
+ // basic_socket_acceptor constructors.
+
+ ip::tcp::acceptor acceptor1(ioc);
+ ip::tcp::acceptor acceptor2(ioc, ip::tcp::v4());
+ ip::tcp::acceptor acceptor3(ioc, ip::tcp::v6());
+ ip::tcp::acceptor acceptor4(ioc, ip::tcp::endpoint(ip::tcp::v4(), 0));
+ ip::tcp::acceptor acceptor5(ioc, ip::tcp::endpoint(ip::tcp::v6(), 0));
+#if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
+ ip::tcp::acceptor::native_handle_type native_acceptor1
+ = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ ip::tcp::acceptor acceptor6(ioc, ip::tcp::v4(), native_acceptor1);
+#endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME)
+
+ 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(BOOST_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(BOOST_ASIO_WINDOWS_RUNTIME)
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ ip::tcp::acceptor acceptor13(std::move(acceptor5));
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_socket_acceptor operators.
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ acceptor1 = ip::tcp::acceptor(ioc);
+ acceptor1 = std::move(acceptor2);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_io_object functions.
+
+ ip::tcp::acceptor::executor_type ex = acceptor1.get_executor();
+ (void)ex;
+
+ // basic_socket_acceptor functions.
+
+ acceptor1.open(ip::tcp::v4());
+ acceptor1.open(ip::tcp::v6());
+ acceptor1.open(ip::tcp::v4(), ec);
+ acceptor1.open(ip::tcp::v6(), ec);
+
+#if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
+ ip::tcp::acceptor::native_handle_type native_acceptor3
+ = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ 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(BOOST_ASIO_WINDOWS_RUNTIME)
+
+ bool is_open = acceptor1.is_open();
+ (void)is_open;
+
+ acceptor1.close();
+ acceptor1.close(ec);
+
+ acceptor1.release();
+ acceptor1.release(ec);
+
+ ip::tcp::acceptor::native_handle_type native_acceptor5
+ = acceptor1.native_handle();
+ (void)native_acceptor5;
+
+ acceptor1.cancel();
+ acceptor1.cancel(ec);
+
+ acceptor1.bind(ip::tcp::endpoint(ip::tcp::v4(), 0));
+ acceptor1.bind(ip::tcp::endpoint(ip::tcp::v6(), 0));
+ acceptor1.bind(ip::tcp::endpoint(ip::tcp::v4(), 0), ec);
+ acceptor1.bind(ip::tcp::endpoint(ip::tcp::v6(), 0), ec);
+
+ acceptor1.set_option(settable_socket_option1);
+ acceptor1.set_option(settable_socket_option1, ec);
+ acceptor1.set_option(settable_socket_option2);
+ acceptor1.set_option(settable_socket_option2, ec);
+ acceptor1.set_option(settable_socket_option3);
+ acceptor1.set_option(settable_socket_option3, ec);
+
+ acceptor1.get_option(gettable_socket_option1);
+ acceptor1.get_option(gettable_socket_option1, ec);
+ acceptor1.get_option(gettable_socket_option2);
+ acceptor1.get_option(gettable_socket_option2, ec);
+ acceptor1.get_option(gettable_socket_option3);
+ acceptor1.get_option(gettable_socket_option3, ec);
+
+ acceptor1.io_control(io_control_command);
+ acceptor1.io_control(io_control_command, ec);
+
+ bool non_blocking1 = acceptor1.non_blocking();
+ (void)non_blocking1;
+ acceptor1.non_blocking(true);
+ acceptor1.non_blocking(false, ec);
+
+ bool non_blocking2 = acceptor1.native_non_blocking();
+ (void)non_blocking2;
+ acceptor1.native_non_blocking(true);
+ 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());
+ int i1 = acceptor1.async_wait(socket_base::wait_write, lazy);
+ (void)i1;
+
+ 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);
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ 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;
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ acceptor1.async_accept(peer_socket1, accept_handler());
+ acceptor1.async_accept(peer_socket1, peer_endpoint, accept_handler());
+ int i2 = acceptor1.async_accept(peer_socket1, lazy);
+ (void)i2;
+ int i3 = acceptor1.async_accept(peer_socket1, peer_endpoint, lazy);
+ (void)i3;
+
+ acceptor1.async_accept(peer_socket2, accept_handler());
+ acceptor1.async_accept(peer_socket2, peer_endpoint, accept_handler());
+ int i4 = acceptor1.async_accept(peer_socket2, lazy);
+ (void)i4;
+ int i5 = acceptor1.async_accept(peer_socket2, peer_endpoint, lazy);
+ (void)i5;
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ 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());
+ acceptor1.async_accept(ioc_ex, peer_endpoint, move_accept_handler());
+ acceptor1.async_accept(ioc_ex, peer_endpoint, move_accept_ioc_handler());
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace ip_tcp_acceptor_compile
+
+//------------------------------------------------------------------------------
+
+// ip_tcp_acceptor_runtime test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks the runtime operation of the ip::tcp::acceptor
+// class.
+
+namespace ip_tcp_acceptor_runtime {
+
+void handle_accept(const boost::system::error_code& err)
+{
+ BOOST_ASIO_CHECK(!err);
+}
+
+void handle_connect(const boost::system::error_code& err)
+{
+ BOOST_ASIO_CHECK(!err);
+}
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ io_context ioc;
+
+ ip::tcp::acceptor acceptor(ioc, ip::tcp::endpoint(ip::tcp::v4(), 0));
+ ip::tcp::endpoint server_endpoint = acceptor.local_endpoint();
+ server_endpoint.address(ip::address_v4::loopback());
+
+ ip::tcp::socket client_side_socket(ioc);
+ ip::tcp::socket server_side_socket(ioc);
+
+ client_side_socket.connect(server_endpoint);
+ acceptor.accept(server_side_socket);
+
+ client_side_socket.close();
+ server_side_socket.close();
+
+ client_side_socket.connect(server_endpoint);
+ ip::tcp::endpoint client_endpoint;
+ acceptor.accept(server_side_socket, client_endpoint);
+
+ ip::tcp::endpoint client_side_local_endpoint
+ = client_side_socket.local_endpoint();
+ BOOST_ASIO_CHECK(client_side_local_endpoint.port() == client_endpoint.port());
+
+ ip::tcp::endpoint server_side_remote_endpoint
+ = server_side_socket.remote_endpoint();
+ BOOST_ASIO_CHECK(server_side_remote_endpoint.port()
+ == client_endpoint.port());
+
+ client_side_socket.close();
+ server_side_socket.close();
+
+ acceptor.async_accept(server_side_socket, &handle_accept);
+ client_side_socket.async_connect(server_endpoint, &handle_connect);
+
+ ioc.run();
+
+ client_side_socket.close();
+ server_side_socket.close();
+
+ acceptor.async_accept(server_side_socket, client_endpoint, &handle_accept);
+ client_side_socket.async_connect(server_endpoint, &handle_connect);
+
+ ioc.restart();
+ ioc.run();
+
+ client_side_local_endpoint = client_side_socket.local_endpoint();
+ BOOST_ASIO_CHECK(client_side_local_endpoint.port() == client_endpoint.port());
+
+ server_side_remote_endpoint = server_side_socket.remote_endpoint();
+ BOOST_ASIO_CHECK(server_side_remote_endpoint.port()
+ == client_endpoint.port());
+}
+
+} // namespace ip_tcp_acceptor_runtime
+
+//------------------------------------------------------------------------------
+
+// ip_tcp_resolver_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// ip::tcp::resolver compile and link correctly. Runtime failures are ignored.
+
+namespace ip_tcp_resolver_compile {
+
+struct resolve_handler
+{
+ resolve_handler() {}
+ void operator()(const boost::system::error_code&,
+ boost::asio::ip::tcp::resolver::results_type) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ resolve_handler(resolve_handler&&) {}
+private:
+ resolve_handler(const resolve_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+struct legacy_resolve_handler
+{
+ legacy_resolve_handler() {}
+ void operator()(const boost::system::error_code&,
+ boost::asio::ip::tcp::resolver::iterator) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ legacy_resolve_handler(legacy_resolve_handler&&) {}
+private:
+ legacy_resolve_handler(const legacy_resolve_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ try
+ {
+ io_context ioc;
+ const io_context::executor_type ioc_ex = ioc.get_executor();
+ archetypes::lazy_handler lazy;
+ boost::system::error_code ec;
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ ip::tcp::resolver::query q(ip::tcp::v4(), "localhost", "0");
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+ ip::tcp::endpoint e(ip::address_v4::loopback(), 0);
+
+ // basic_resolver constructors.
+
+ ip::tcp::resolver resolver(ioc);
+ ip::tcp::resolver resolver2(ioc_ex);
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ ip::tcp::resolver resolver3(std::move(resolver));
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_resolver operators.
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ resolver = ip::tcp::resolver(ioc);
+ resolver = std::move(resolver3);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_io_object functions.
+
+ ip::tcp::resolver::executor_type ex = resolver.get_executor();
+ (void)ex;
+
+ // basic_resolver functions.
+
+ resolver.cancel();
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ ip::tcp::resolver::results_type results1 = resolver.resolve(q);
+ (void)results1;
+
+ ip::tcp::resolver::results_type results2 = resolver.resolve(q, ec);
+ (void)results2;
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ ip::tcp::resolver::results_type results3 = resolver.resolve("", "");
+ (void)results3;
+
+ ip::tcp::resolver::results_type results4 = resolver.resolve("", "", ec);
+ (void)results4;
+
+ ip::tcp::resolver::results_type results5 =
+ resolver.resolve("", "", ip::tcp::resolver::flags());
+ (void)results5;
+
+ ip::tcp::resolver::results_type results6 =
+ resolver.resolve("", "", ip::tcp::resolver::flags(), ec);
+ (void)results6;
+
+ ip::tcp::resolver::results_type results7 =
+ resolver.resolve(ip::tcp::v4(), "", "");
+ (void)results7;
+
+ ip::tcp::resolver::results_type results8 =
+ resolver.resolve(ip::tcp::v4(), "", "", ec);
+ (void)results8;
+
+ ip::tcp::resolver::results_type results9 =
+ resolver.resolve(ip::tcp::v4(), "", "", ip::tcp::resolver::flags());
+ (void)results9;
+
+ ip::tcp::resolver::results_type results10 =
+ resolver.resolve(ip::tcp::v4(), "", "", ip::tcp::resolver::flags(), ec);
+ (void)results10;
+
+ ip::tcp::resolver::results_type results11 = resolver.resolve(e);
+ (void)results11;
+
+ ip::tcp::resolver::results_type results12 = resolver.resolve(e, ec);
+ (void)results12;
+
+#if !defined(BOOST_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;
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ resolver.async_resolve("", "", resolve_handler());
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ resolver.async_resolve("", "", legacy_resolve_handler());
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+ int i2 = resolver.async_resolve("", "", lazy);
+ (void)i2;
+
+ resolver.async_resolve("", "",
+ ip::tcp::resolver::flags(), resolve_handler());
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ resolver.async_resolve("", "",
+ ip::tcp::resolver::flags(), legacy_resolve_handler());
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+ int i3 = resolver.async_resolve("", "",
+ ip::tcp::resolver::flags(), lazy);
+ (void)i3;
+
+ resolver.async_resolve(ip::tcp::v4(), "", "", resolve_handler());
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ resolver.async_resolve(ip::tcp::v4(), "", "", legacy_resolve_handler());
+#endif // !defined(BOOST_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(BOOST_ASIO_NO_DEPRECATED)
+ resolver.async_resolve(ip::tcp::v4(),
+ "", "", ip::tcp::resolver::flags(), legacy_resolve_handler());
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+ int i5 = resolver.async_resolve(ip::tcp::v4(),
+ "", "", ip::tcp::resolver::flags(), lazy);
+ (void)i5;
+
+ resolver.async_resolve(e, resolve_handler());
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ resolver.async_resolve(e, legacy_resolve_handler());
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+ int i6 = resolver.async_resolve(e, lazy);
+ (void)i6;
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace ip_tcp_resolver_compile
+
+//------------------------------------------------------------------------------
+
+// ip_tcp_resolver_entry_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// ip::tcp::resolver::entry compile and link correctly. Runtime failures are
+// ignored.
+
+namespace ip_tcp_resolver_entry_compile {
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+ const ip::tcp::endpoint endpoint;
+ const std::string host_name;
+ const std::string service_name;
+ const std::allocator<char> alloc;
+
+ try
+ {
+ // basic_resolver_entry constructors.
+
+ 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(BOOST_ASIO_HAS_MOVE)
+ ip::basic_resolver_entry<ip::tcp> entry4(std::move(entry2));
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_resolver_entry functions.
+
+ ip::tcp::endpoint e1 = entry1.endpoint();
+ (void)e1;
+
+ ip::tcp::endpoint e2 = entry1;
+ (void)e2;
+
+ std::string s1 = entry1.host_name();
+ (void)s1;
+
+ std::string s2 = entry1.host_name(alloc);
+ (void)s2;
+
+ std::string s3 = entry1.service_name();
+ (void)s3;
+
+ std::string s4 = entry1.service_name(alloc);
+ (void)s4;
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace ip_tcp_resolver_entry_compile
+
+//------------------------------------------------------------------------------
+
+// ip_tcp_iostream_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public types and member functions on the
+// class ip::tcp::iostream compile and link correctly. Runtime failures are
+// ignored.
+
+namespace ip_tcp_iostream_compile {
+
+void test()
+{
+#if !defined(BOOST_ASIO_NO_IOSTREAM)
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ boost::asio::io_context ioc;
+ boost::asio::ip::tcp::socket sock(ioc);
+
+ // basic_socket_iostream typedefs.
+
+ (void)static_cast<ip::tcp::iostream::protocol_type*>(0);
+ (void)static_cast<ip::tcp::iostream::endpoint_type*>(0);
+ (void)static_cast<ip::tcp::iostream::clock_type*>(0);
+ (void)static_cast<ip::tcp::iostream::time_point*>(0);
+ (void)static_cast<ip::tcp::iostream::duration*>(0);
+ (void)static_cast<ip::tcp::iostream::traits_type*>(0);
+
+ // basic_socket_iostream constructors.
+
+ ip::tcp::iostream ios1;
+
+#if defined(BOOST_ASIO_HAS_STD_IOSTREAM_MOVE)
+ ip::tcp::iostream ios2(std::move(sock));
+#endif // defined(BOOST_ASIO_HAS_STD_IOSTREAM_MOVE)
+
+ ip::tcp::iostream ios3("hostname", "service");
+
+ // basic_socket_iostream operators.
+
+#if defined(BOOST_ASIO_HAS_STD_IOSTREAM_MOVE)
+ ios1 = ip::tcp::iostream();
+
+ ios2 = std::move(ios1);
+#endif // defined(BOOST_ASIO_HAS_STD_IOSTREAM_MOVE)
+
+ // basic_socket_iostream members.
+
+ ios1.connect("hostname", "service");
+
+ ios1.close();
+
+ (void)static_cast<std::streambuf*>(ios1.rdbuf());
+
+ basic_socket<ip::tcp>& sref = ios1.socket();
+ (void)sref;
+
+ boost::system::error_code ec = ios1.error();
+ (void)ec;
+
+ ip::tcp::iostream::time_point tp = ios1.expiry();
+ (void)tp;
+
+ ios1.expires_at(tp);
+
+ ip::tcp::iostream::duration d;
+ ios1.expires_after(d);
+
+ // iostream operators.
+
+ int i = 0;
+ ios1 >> i;
+ ios1 << i;
+#endif // !defined(BOOST_ASIO_NO_IOSTREAM)
+}
+
+} // namespace ip_tcp_iostream_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ip/tcp",
+ BOOST_ASIO_TEST_CASE(ip_tcp_compile::test)
+ BOOST_ASIO_TEST_CASE(ip_tcp_runtime::test)
+ BOOST_ASIO_TEST_CASE(ip_tcp_socket_compile::test)
+ BOOST_ASIO_TEST_CASE(ip_tcp_socket_runtime::test)
+ BOOST_ASIO_TEST_CASE(ip_tcp_acceptor_compile::test)
+ BOOST_ASIO_TEST_CASE(ip_tcp_acceptor_runtime::test)
+ BOOST_ASIO_TEST_CASE(ip_tcp_resolver_compile::test)
+ BOOST_ASIO_TEST_CASE(ip_tcp_resolver_entry_compile::test)
+ BOOST_ASIO_TEST_CASE(ip_tcp_resolver_entry_compile::test)
+ BOOST_ASIO_COMPILE_TEST_CASE(ip_tcp_iostream_compile::test)
+)
diff --git a/src/boost/libs/asio/test/ip/udp.cpp b/src/boost/libs/asio/test/ip/udp.cpp
new file mode 100644
index 000000000..cd2ceb536
--- /dev/null
+++ b/src/boost/libs/asio/test/ip/udp.cpp
@@ -0,0 +1,673 @@
+//
+// udp.cpp
+// ~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ip/udp.hpp>
+
+#include <cstring>
+#include <boost/asio/io_context.hpp>
+#include "../unit_test.hpp"
+#include "../archetypes/async_result.hpp"
+#include "../archetypes/gettable_socket_option.hpp"
+#include "../archetypes/io_control_command.hpp"
+#include "../archetypes/settable_socket_option.hpp"
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <boost/bind/bind.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <functional>
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+
+//------------------------------------------------------------------------------
+
+// ip_udp_socket_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// ip::udp::socket compile and link correctly. Runtime failures are ignored.
+
+namespace ip_udp_socket_compile {
+
+struct connect_handler
+{
+ connect_handler() {}
+ void operator()(const boost::system::error_code&) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ connect_handler(connect_handler&&) {}
+private:
+ connect_handler(const connect_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+
+struct wait_handler
+{
+ wait_handler() {}
+ void operator()(const boost::system::error_code&) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ wait_handler(wait_handler&&) {}
+private:
+ wait_handler(const wait_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+
+struct send_handler
+{
+ send_handler() {}
+ void operator()(const boost::system::error_code&, std::size_t) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ send_handler(send_handler&&) {}
+private:
+ send_handler(const send_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+
+struct receive_handler
+{
+ receive_handler() {}
+ void operator()(const boost::system::error_code&, std::size_t) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ receive_handler(receive_handler&&) {}
+private:
+ receive_handler(const receive_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ 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;
+ archetypes::settable_socket_option<void> settable_socket_option1;
+ archetypes::settable_socket_option<int> settable_socket_option2;
+ archetypes::settable_socket_option<double> settable_socket_option3;
+ archetypes::gettable_socket_option<void> gettable_socket_option1;
+ archetypes::gettable_socket_option<int> gettable_socket_option2;
+ archetypes::gettable_socket_option<double> gettable_socket_option3;
+ archetypes::io_control_command io_control_command;
+ archetypes::lazy_handler lazy;
+ boost::system::error_code ec;
+
+ // basic_datagram_socket constructors.
+
+ ip::udp::socket socket1(ioc);
+ ip::udp::socket socket2(ioc, ip::udp::v4());
+ ip::udp::socket socket3(ioc, ip::udp::v6());
+ ip::udp::socket socket4(ioc, ip::udp::endpoint(ip::udp::v4(), 0));
+ ip::udp::socket socket5(ioc, ip::udp::endpoint(ip::udp::v6(), 0));
+#if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
+ ip::udp::socket::native_handle_type native_socket1
+ = ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ ip::udp::socket socket6(ioc, ip::udp::v4(), native_socket1);
+#endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME)
+
+ 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(BOOST_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(BOOST_ASIO_WINDOWS_RUNTIME)
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ ip::udp::socket socket13(std::move(socket6));
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_datagram_socket operators.
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ socket1 = ip::udp::socket(ioc);
+ socket1 = std::move(socket2);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_io_object functions.
+
+ ip::udp::socket::executor_type ex = socket1.get_executor();
+ (void)ex;
+
+ // basic_socket functions.
+
+ ip::udp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer();
+ (void)lowest_layer;
+
+ const ip::udp::socket& socket14 = socket1;
+ const ip::udp::socket::lowest_layer_type& lowest_layer2
+ = socket14.lowest_layer();
+ (void)lowest_layer2;
+
+ socket1.open(ip::udp::v4());
+ socket1.open(ip::udp::v6());
+ socket1.open(ip::udp::v4(), ec);
+ socket1.open(ip::udp::v6(), ec);
+
+#if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
+ ip::udp::socket::native_handle_type native_socket3
+ = ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ 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(BOOST_ASIO_WINDOWS_RUNTIME)
+
+ bool is_open = socket1.is_open();
+ (void)is_open;
+
+ socket1.close();
+ socket1.close(ec);
+
+ socket1.release();
+ socket1.release(ec);
+
+ ip::udp::socket::native_handle_type native_socket5
+ = socket1.native_handle();
+ (void)native_socket5;
+
+ 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(ip::udp::endpoint(ip::udp::v4(), 0));
+ socket1.bind(ip::udp::endpoint(ip::udp::v6(), 0));
+ socket1.bind(ip::udp::endpoint(ip::udp::v4(), 0), ec);
+ socket1.bind(ip::udp::endpoint(ip::udp::v6(), 0), ec);
+
+ socket1.connect(ip::udp::endpoint(ip::udp::v4(), 0));
+ socket1.connect(ip::udp::endpoint(ip::udp::v6(), 0));
+ socket1.connect(ip::udp::endpoint(ip::udp::v4(), 0), ec);
+ socket1.connect(ip::udp::endpoint(ip::udp::v6(), 0), ec);
+
+ socket1.async_connect(ip::udp::endpoint(ip::udp::v4(), 0),
+ connect_handler());
+ socket1.async_connect(ip::udp::endpoint(ip::udp::v6(), 0),
+ connect_handler());
+ 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;
+
+ socket1.set_option(settable_socket_option1);
+ socket1.set_option(settable_socket_option1, ec);
+ socket1.set_option(settable_socket_option2);
+ socket1.set_option(settable_socket_option2, ec);
+ socket1.set_option(settable_socket_option3);
+ socket1.set_option(settable_socket_option3, ec);
+
+ socket1.get_option(gettable_socket_option1);
+ socket1.get_option(gettable_socket_option1, ec);
+ socket1.get_option(gettable_socket_option2);
+ socket1.get_option(gettable_socket_option2, ec);
+ socket1.get_option(gettable_socket_option3);
+ socket1.get_option(gettable_socket_option3, ec);
+
+ socket1.io_control(io_control_command);
+ socket1.io_control(io_control_command, ec);
+
+ bool non_blocking1 = socket1.non_blocking();
+ (void)non_blocking1;
+ socket1.non_blocking(true);
+ socket1.non_blocking(false, ec);
+
+ bool non_blocking2 = socket1.native_non_blocking();
+ (void)non_blocking2;
+ socket1.native_non_blocking(true);
+ 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);
+
+ socket1.wait(socket_base::wait_read);
+ socket1.wait(socket_base::wait_write, ec);
+
+ socket1.async_wait(socket_base::wait_read, wait_handler());
+ int i3 = socket1.async_wait(socket_base::wait_write, lazy);
+ (void)i3;
+
+ // basic_datagram_socket functions.
+
+ socket1.send(buffer(mutable_char_buffer));
+ socket1.send(buffer(const_char_buffer));
+ socket1.send(null_buffers());
+ 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), send_handler());
+ socket1.async_send(buffer(const_char_buffer), send_handler());
+ socket1.async_send(null_buffers(), send_handler());
+ 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());
+ int i4 = socket1.async_send(buffer(mutable_char_buffer), lazy);
+ (void)i4;
+ int i5 = socket1.async_send(buffer(const_char_buffer), lazy);
+ (void)i5;
+ int i6 = socket1.async_send(null_buffers(), lazy);
+ (void)i6;
+ int i7 = socket1.async_send(buffer(mutable_char_buffer), in_flags, lazy);
+ (void)i7;
+ int i8 = socket1.async_send(buffer(const_char_buffer), in_flags, lazy);
+ (void)i8;
+ int i9 = socket1.async_send(null_buffers(), in_flags, lazy);
+ (void)i9;
+
+ socket1.send_to(buffer(mutable_char_buffer),
+ ip::udp::endpoint(ip::udp::v4(), 0));
+ socket1.send_to(buffer(mutable_char_buffer),
+ ip::udp::endpoint(ip::udp::v6(), 0));
+ socket1.send_to(buffer(const_char_buffer),
+ ip::udp::endpoint(ip::udp::v4(), 0));
+ socket1.send_to(buffer(const_char_buffer),
+ ip::udp::endpoint(ip::udp::v6(), 0));
+ socket1.send_to(null_buffers(),
+ ip::udp::endpoint(ip::udp::v4(), 0));
+ socket1.send_to(null_buffers(),
+ ip::udp::endpoint(ip::udp::v6(), 0));
+ socket1.send_to(buffer(mutable_char_buffer),
+ ip::udp::endpoint(ip::udp::v4(), 0), in_flags);
+ socket1.send_to(buffer(mutable_char_buffer),
+ ip::udp::endpoint(ip::udp::v6(), 0), in_flags);
+ socket1.send_to(buffer(const_char_buffer),
+ ip::udp::endpoint(ip::udp::v4(), 0), in_flags);
+ socket1.send_to(buffer(const_char_buffer),
+ ip::udp::endpoint(ip::udp::v6(), 0), in_flags);
+ socket1.send_to(null_buffers(),
+ ip::udp::endpoint(ip::udp::v4(), 0), in_flags);
+ socket1.send_to(null_buffers(),
+ ip::udp::endpoint(ip::udp::v6(), 0), in_flags);
+ socket1.send_to(buffer(mutable_char_buffer),
+ ip::udp::endpoint(ip::udp::v4(), 0), in_flags, ec);
+ socket1.send_to(buffer(mutable_char_buffer),
+ ip::udp::endpoint(ip::udp::v6(), 0), in_flags, ec);
+ socket1.send_to(buffer(const_char_buffer),
+ ip::udp::endpoint(ip::udp::v4(), 0), in_flags, ec);
+ socket1.send_to(buffer(const_char_buffer),
+ ip::udp::endpoint(ip::udp::v6(), 0), in_flags, ec);
+ socket1.send_to(null_buffers(),
+ ip::udp::endpoint(ip::udp::v4(), 0), in_flags, ec);
+ socket1.send_to(null_buffers(),
+ ip::udp::endpoint(ip::udp::v6(), 0), in_flags, ec);
+
+ socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::udp::endpoint(ip::udp::v4(), 0), send_handler());
+ socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::udp::endpoint(ip::udp::v6(), 0), send_handler());
+ socket1.async_send_to(buffer(const_char_buffer),
+ ip::udp::endpoint(ip::udp::v4(), 0), send_handler());
+ socket1.async_send_to(buffer(const_char_buffer),
+ ip::udp::endpoint(ip::udp::v6(), 0), send_handler());
+ socket1.async_send_to(null_buffers(),
+ ip::udp::endpoint(ip::udp::v4(), 0), send_handler());
+ socket1.async_send_to(null_buffers(),
+ ip::udp::endpoint(ip::udp::v6(), 0), send_handler());
+ socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::udp::endpoint(ip::udp::v4(), 0), in_flags, send_handler());
+ socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::udp::endpoint(ip::udp::v6(), 0), in_flags, send_handler());
+ socket1.async_send_to(buffer(const_char_buffer),
+ ip::udp::endpoint(ip::udp::v4(), 0), in_flags, send_handler());
+ socket1.async_send_to(buffer(const_char_buffer),
+ ip::udp::endpoint(ip::udp::v6(), 0), in_flags, send_handler());
+ socket1.async_send_to(null_buffers(),
+ 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());
+ int i10 = socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::udp::endpoint(ip::udp::v4(), 0), lazy);
+ (void)i10;
+ int i11 = socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::udp::endpoint(ip::udp::v6(), 0), lazy);
+ (void)i11;
+ int i12 = socket1.async_send_to(buffer(const_char_buffer),
+ ip::udp::endpoint(ip::udp::v4(), 0), lazy);
+ (void)i12;
+ int i13 = socket1.async_send_to(buffer(const_char_buffer),
+ ip::udp::endpoint(ip::udp::v6(), 0), lazy);
+ (void)i13;
+ int i14 = socket1.async_send_to(null_buffers(),
+ ip::udp::endpoint(ip::udp::v4(), 0), lazy);
+ (void)i14;
+ int i15 = socket1.async_send_to(null_buffers(),
+ ip::udp::endpoint(ip::udp::v6(), 0), lazy);
+ (void)i15;
+ int i16 = socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::udp::endpoint(ip::udp::v4(), 0), in_flags, lazy);
+ (void)i16;
+ int i17 = socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::udp::endpoint(ip::udp::v6(), 0), in_flags, lazy);
+ (void)i17;
+ int i18 = socket1.async_send_to(buffer(const_char_buffer),
+ ip::udp::endpoint(ip::udp::v4(), 0), in_flags, lazy);
+ (void)i18;
+ int i19 = socket1.async_send_to(buffer(const_char_buffer),
+ ip::udp::endpoint(ip::udp::v6(), 0), in_flags, lazy);
+ (void)i19;
+ int i20 = socket1.async_send_to(null_buffers(),
+ ip::udp::endpoint(ip::udp::v4(), 0), in_flags, lazy);
+ (void)i20;
+ int i21 = socket1.async_send_to(null_buffers(),
+ ip::udp::endpoint(ip::udp::v6(), 0), in_flags, lazy);
+ (void)i21;
+
+ socket1.receive(buffer(mutable_char_buffer));
+ socket1.receive(null_buffers());
+ socket1.receive(buffer(mutable_char_buffer), in_flags);
+ socket1.receive(null_buffers(), in_flags);
+ socket1.receive(buffer(mutable_char_buffer), in_flags, ec);
+ socket1.receive(null_buffers(), in_flags, ec);
+
+ socket1.async_receive(buffer(mutable_char_buffer), receive_handler());
+ socket1.async_receive(null_buffers(), receive_handler());
+ socket1.async_receive(buffer(mutable_char_buffer), in_flags,
+ receive_handler());
+ socket1.async_receive(null_buffers(), in_flags, receive_handler());
+ int i22 = socket1.async_receive(buffer(mutable_char_buffer), lazy);
+ (void)i22;
+ int i23 = socket1.async_receive(null_buffers(), lazy);
+ (void)i23;
+ int i24 = socket1.async_receive(buffer(mutable_char_buffer),
+ in_flags, lazy);
+ (void)i24;
+ int i25 = socket1.async_receive(null_buffers(), in_flags, lazy);
+ (void)i25;
+
+ ip::udp::endpoint endpoint;
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint);
+ socket1.receive_from(null_buffers(), endpoint);
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint, in_flags);
+ socket1.receive_from(null_buffers(), endpoint, in_flags);
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint, in_flags, ec);
+ socket1.receive_from(null_buffers(), endpoint, in_flags, ec);
+
+ socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, receive_handler());
+ socket1.async_receive_from(null_buffers(),
+ endpoint, receive_handler());
+ socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, in_flags, receive_handler());
+ socket1.async_receive_from(null_buffers(),
+ endpoint, in_flags, receive_handler());
+ int i26 = socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, lazy);
+ (void)i26;
+ int i27 = socket1.async_receive_from(null_buffers(),
+ endpoint, lazy);
+ (void)i27;
+ int i28 = socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, in_flags, lazy);
+ (void)i28;
+ int i29 = socket1.async_receive_from(null_buffers(),
+ endpoint, in_flags, lazy);
+ (void)i29;
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace ip_udp_socket_compile
+
+//------------------------------------------------------------------------------
+
+// ip_udp_socket_runtime test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks the runtime operation of the ip::udp::socket class.
+
+namespace ip_udp_socket_runtime {
+
+void handle_send(size_t expected_bytes_sent,
+ const boost::system::error_code& err, size_t bytes_sent)
+{
+ BOOST_ASIO_CHECK(!err);
+ BOOST_ASIO_CHECK(expected_bytes_sent == bytes_sent);
+}
+
+void handle_recv(size_t expected_bytes_recvd,
+ const boost::system::error_code& err, size_t bytes_recvd)
+{
+ BOOST_ASIO_CHECK(!err);
+ BOOST_ASIO_CHECK(expected_bytes_recvd == bytes_recvd);
+}
+
+void test()
+{
+ using namespace std; // For memcmp and memset.
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ io_context ioc;
+
+ ip::udp::socket s1(ioc, ip::udp::endpoint(ip::udp::v4(), 0));
+ ip::udp::endpoint target_endpoint = s1.local_endpoint();
+ target_endpoint.address(ip::address_v4::loopback());
+
+ ip::udp::socket s2(ioc);
+ s2.open(ip::udp::v4());
+ s2.bind(ip::udp::endpoint(ip::udp::v4(), 0));
+ char send_msg[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ s2.send_to(buffer(send_msg, sizeof(send_msg)), target_endpoint);
+
+ char recv_msg[sizeof(send_msg)];
+ ip::udp::endpoint sender_endpoint;
+ size_t bytes_recvd = s1.receive_from(buffer(recv_msg, sizeof(recv_msg)),
+ sender_endpoint);
+
+ BOOST_ASIO_CHECK(bytes_recvd == sizeof(send_msg));
+ BOOST_ASIO_CHECK(memcmp(send_msg, recv_msg, sizeof(send_msg)) == 0);
+
+ memset(recv_msg, 0, sizeof(recv_msg));
+
+ target_endpoint = sender_endpoint;
+ s1.async_send_to(buffer(send_msg, sizeof(send_msg)), target_endpoint,
+ bindns::bind(handle_send, sizeof(send_msg), _1, _2));
+ s2.async_receive_from(buffer(recv_msg, sizeof(recv_msg)), sender_endpoint,
+ bindns::bind(handle_recv, sizeof(recv_msg), _1, _2));
+
+ ioc.run();
+
+ BOOST_ASIO_CHECK(memcmp(send_msg, recv_msg, sizeof(send_msg)) == 0);
+}
+
+} // namespace ip_udp_socket_runtime
+
+//------------------------------------------------------------------------------
+
+// ip_udp_resolver_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// ip::udp::resolver compile and link correctly. Runtime failures are ignored.
+
+namespace ip_udp_resolver_compile {
+
+struct resolve_handler
+{
+ resolve_handler() {}
+ void operator()(const boost::system::error_code&,
+ boost::asio::ip::udp::resolver::results_type) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ resolve_handler(resolve_handler&&) {}
+private:
+ resolve_handler(const resolve_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ try
+ {
+ io_context ioc;
+ const io_context::executor_type ioc_ex = ioc.get_executor();
+ archetypes::lazy_handler lazy;
+ boost::system::error_code ec;
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ ip::udp::resolver::query q(ip::udp::v4(), "localhost", "0");
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+ ip::udp::endpoint e(ip::address_v4::loopback(), 0);
+
+ // basic_resolver constructors.
+
+ ip::udp::resolver resolver(ioc);
+ ip::udp::resolver resolver2(ioc_ex);
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ ip::udp::resolver resolver3(std::move(resolver));
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_resolver operators.
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ resolver = ip::udp::resolver(ioc);
+ resolver = std::move(resolver3);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_io_object functions.
+
+ ip::udp::resolver::executor_type ex = resolver.get_executor();
+ (void)ex;
+
+ // basic_resolver functions.
+
+ resolver.cancel();
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ ip::udp::resolver::results_type results1 = resolver.resolve(q);
+ (void)results1;
+
+ ip::udp::resolver::results_type results2 = resolver.resolve(q, ec);
+ (void)results2;
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ ip::udp::resolver::results_type results3 = resolver.resolve("", "");
+ (void)results3;
+
+ ip::udp::resolver::results_type results4 = resolver.resolve("", "", ec);
+ (void)results4;
+
+ ip::udp::resolver::results_type results5 =
+ resolver.resolve("", "", ip::udp::resolver::flags());
+ (void)results5;
+
+ ip::udp::resolver::results_type results6 =
+ resolver.resolve("", "", ip::udp::resolver::flags(), ec);
+ (void)results6;
+
+ ip::udp::resolver::results_type results7 =
+ resolver.resolve(ip::udp::v4(), "", "");
+ (void)results7;
+
+ ip::udp::resolver::results_type results8 =
+ resolver.resolve(ip::udp::v4(), "", "", ec);
+ (void)results8;
+
+ ip::udp::resolver::results_type results9 =
+ resolver.resolve(ip::udp::v4(), "", "", ip::udp::resolver::flags());
+ (void)results9;
+
+ ip::udp::resolver::results_type results10 =
+ resolver.resolve(ip::udp::v4(), "", "", ip::udp::resolver::flags(), ec);
+ (void)results10;
+
+ ip::udp::resolver::results_type results11 = resolver.resolve(e);
+ (void)results11;
+
+ ip::udp::resolver::results_type results12 = resolver.resolve(e, ec);
+ (void)results12;
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+ resolver.async_resolve(q, resolve_handler());
+ int i1 = resolver.async_resolve(q, lazy);
+ (void)i1;
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
+
+ resolver.async_resolve("", "", resolve_handler());
+ int i2 = resolver.async_resolve("", "", lazy);
+ (void)i2;
+
+ resolver.async_resolve("", "",
+ ip::udp::resolver::flags(), resolve_handler());
+ int i3 = resolver.async_resolve("", "",
+ ip::udp::resolver::flags(), lazy);
+ (void)i3;
+
+ resolver.async_resolve(ip::udp::v4(), "", "", resolve_handler());
+ int i4 = resolver.async_resolve(ip::udp::v4(), "", "", lazy);
+ (void)i4;
+
+ 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;
+
+ resolver.async_resolve(e, resolve_handler());
+ int i6 = resolver.async_resolve(e, lazy);
+ (void)i6;
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace ip_udp_resolver_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ip/udp",
+ BOOST_ASIO_TEST_CASE(ip_udp_socket_compile::test)
+ BOOST_ASIO_TEST_CASE(ip_udp_socket_runtime::test)
+ BOOST_ASIO_TEST_CASE(ip_udp_resolver_compile::test)
+)
diff --git a/src/boost/libs/asio/test/ip/unicast.cpp b/src/boost/libs/asio/test/ip/unicast.cpp
new file mode 100644
index 000000000..1a48fab11
--- /dev/null
+++ b/src/boost/libs/asio/test/ip/unicast.cpp
@@ -0,0 +1,171 @@
+//
+// unicast.cpp
+// ~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ip/unicast.hpp>
+
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/ip/udp.hpp>
+#include "../unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+// ip_unicast_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all nested classes, enums and constants in
+// ip::unicast compile and link correctly. Runtime failures are ignored.
+
+namespace ip_unicast_compile {
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ try
+ {
+ io_context ioc;
+ ip::udp::socket sock(ioc);
+
+ // hops class.
+
+ ip::unicast::hops hops1(1024);
+ sock.set_option(hops1);
+ ip::unicast::hops hops2;
+ sock.get_option(hops2);
+ hops1 = 1;
+ (void)static_cast<int>(hops1.value());
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace ip_unicast_compile
+
+//------------------------------------------------------------------------------
+
+// ip_unicast_runtime test
+// ~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks the runtime operation of the socket options defined
+// in the ip::unicast namespace.
+
+namespace ip_unicast_runtime {
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ io_context ioc;
+ boost::system::error_code ec;
+
+ ip::udp::endpoint ep_v4(ip::address_v4::loopback(), 0);
+ ip::udp::socket sock_v4(ioc);
+ sock_v4.open(ep_v4.protocol(), ec);
+ sock_v4.bind(ep_v4, ec);
+ bool have_v4 = !ec;
+
+ ip::udp::endpoint ep_v6(ip::address_v6::loopback(), 0);
+ ip::udp::socket sock_v6(ioc);
+ sock_v6.open(ep_v6.protocol(), ec);
+ sock_v6.bind(ep_v6, ec);
+ bool have_v6 = !ec;
+
+ BOOST_ASIO_CHECK(have_v4 || have_v6);
+
+ // hops class.
+
+ if (have_v4)
+ {
+ ip::unicast::hops hops1(1);
+ BOOST_ASIO_CHECK(hops1.value() == 1);
+ sock_v4.set_option(hops1, ec);
+#if defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ // Option is not supported under Windows CE.
+ BOOST_ASIO_CHECK_MESSAGE(ec == boost::asio::error::no_protocol_option,
+ ec.value() << ", " << ec.message());
+#else // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ BOOST_ASIO_CHECK(!ec);
+#endif // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+
+ ip::unicast::hops hops2;
+ sock_v4.get_option(hops2, ec);
+#if defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ // Option is not supported under Windows CE.
+ BOOST_ASIO_CHECK_MESSAGE(ec == boost::asio::error::no_protocol_option,
+ ec.value() << ", " << ec.message());
+#else // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(hops2.value() == 1);
+#endif // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+
+ ip::unicast::hops hops3(255);
+ BOOST_ASIO_CHECK(hops3.value() == 255);
+ sock_v4.set_option(hops3, ec);
+#if defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ // Option is not supported under Windows CE.
+ BOOST_ASIO_CHECK_MESSAGE(ec == boost::asio::error::no_protocol_option,
+ ec.value() << ", " << ec.message());
+#else // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ BOOST_ASIO_CHECK(!ec);
+#endif // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+
+ ip::unicast::hops hops4;
+ sock_v4.get_option(hops4, ec);
+#if defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ // Option is not supported under Windows CE.
+ BOOST_ASIO_CHECK_MESSAGE(ec == boost::asio::error::no_protocol_option,
+ ec.value() << ", " << ec.message());
+#else // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(hops4.value() == 255);
+#endif // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ }
+
+ if (have_v6)
+ {
+ ip::unicast::hops hops1(1);
+ BOOST_ASIO_CHECK(hops1.value() == 1);
+ sock_v6.set_option(hops1, ec);
+ BOOST_ASIO_CHECK(!ec);
+
+ ip::unicast::hops hops2;
+ sock_v6.get_option(hops2, ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(hops2.value() == 1);
+
+ ip::unicast::hops hops3(255);
+ BOOST_ASIO_CHECK(hops3.value() == 255);
+ sock_v6.set_option(hops3, ec);
+ BOOST_ASIO_CHECK(!ec);
+
+ ip::unicast::hops hops4;
+ sock_v6.get_option(hops4, ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(hops4.value() == 255);
+ }
+}
+
+} // namespace ip_unicast_runtime
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ip/unicast",
+ BOOST_ASIO_TEST_CASE(ip_unicast_compile::test)
+ BOOST_ASIO_TEST_CASE(ip_unicast_runtime::test)
+)
diff --git a/src/boost/libs/asio/test/ip/v6_only.cpp b/src/boost/libs/asio/test/ip/v6_only.cpp
new file mode 100644
index 000000000..570781266
--- /dev/null
+++ b/src/boost/libs/asio/test/ip/v6_only.cpp
@@ -0,0 +1,135 @@
+//
+// v6_only.cpp
+// ~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ip/v6_only.hpp>
+
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/ip/tcp.hpp>
+#include <boost/asio/ip/udp.hpp>
+#include "../unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+// ip_v6_only_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that the ip::v6_only socket option compiles and
+// link correctly. Runtime failures are ignored.
+
+namespace ip_v6_only_compile {
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ try
+ {
+ io_context ioc;
+ ip::udp::socket sock(ioc);
+
+ // v6_only class.
+
+ ip::v6_only v6_only1(true);
+ sock.set_option(v6_only1);
+ ip::v6_only v6_only2;
+ sock.get_option(v6_only2);
+ v6_only1 = true;
+ (void)static_cast<bool>(v6_only1);
+ (void)static_cast<bool>(!v6_only1);
+ (void)static_cast<bool>(v6_only1.value());
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace ip_v6_only_compile
+
+//------------------------------------------------------------------------------
+
+// ip_v6_only_runtime test
+// ~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks the runtime operation of the ip::v6_only socket
+// option.
+
+namespace ip_v6_only_runtime {
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ io_context ioc;
+ boost::system::error_code ec;
+
+ ip::tcp::endpoint ep_v6(ip::address_v6::loopback(), 0);
+ ip::tcp::acceptor acceptor_v6(ioc);
+ acceptor_v6.open(ep_v6.protocol(), ec);
+ acceptor_v6.bind(ep_v6, ec);
+ bool have_v6 = !ec;
+ acceptor_v6.close(ec);
+ acceptor_v6.open(ep_v6.protocol(), ec);
+
+ if (have_v6)
+ {
+ ip::v6_only v6_only1;
+ acceptor_v6.get_option(v6_only1, ec);
+ BOOST_ASIO_CHECK(!ec);
+ bool have_dual_stack = !v6_only1.value();
+
+ if (have_dual_stack)
+ {
+ ip::v6_only v6_only2(false);
+ BOOST_ASIO_CHECK(!v6_only2.value());
+ BOOST_ASIO_CHECK(!static_cast<bool>(v6_only2));
+ BOOST_ASIO_CHECK(!v6_only2);
+ acceptor_v6.set_option(v6_only2, ec);
+ BOOST_ASIO_CHECK(!ec);
+
+ ip::v6_only v6_only3;
+ acceptor_v6.get_option(v6_only3, ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(!v6_only3.value());
+ BOOST_ASIO_CHECK(!static_cast<bool>(v6_only3));
+ BOOST_ASIO_CHECK(!v6_only3);
+
+ ip::v6_only v6_only4(true);
+ BOOST_ASIO_CHECK(v6_only4.value());
+ BOOST_ASIO_CHECK(static_cast<bool>(v6_only4));
+ BOOST_ASIO_CHECK(!!v6_only4);
+ acceptor_v6.set_option(v6_only4, ec);
+ BOOST_ASIO_CHECK(!ec);
+
+ ip::v6_only v6_only5;
+ acceptor_v6.get_option(v6_only5, ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(v6_only5.value());
+ BOOST_ASIO_CHECK(static_cast<bool>(v6_only5));
+ BOOST_ASIO_CHECK(!!v6_only5);
+ }
+ }
+}
+
+} // namespace ip_v6_only_runtime
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ip/v6_only",
+ BOOST_ASIO_TEST_CASE(ip_v6_only_compile::test)
+ BOOST_ASIO_TEST_CASE(ip_v6_only_runtime::test)
+)
diff --git a/src/boost/libs/asio/test/is_read_buffered.cpp b/src/boost/libs/asio/test/is_read_buffered.cpp
new file mode 100644
index 000000000..868c64644
--- /dev/null
+++ b/src/boost/libs/asio/test/is_read_buffered.cpp
@@ -0,0 +1,129 @@
+//
+// is_read_buffered.cpp
+// ~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/is_read_buffered.hpp>
+
+#include <boost/asio/buffered_read_stream.hpp>
+#include <boost/asio/buffered_write_stream.hpp>
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/ip/tcp.hpp>
+#include "unit_test.hpp"
+
+using namespace std; // For memcmp, memcpy and memset.
+
+class test_stream
+{
+public:
+ typedef boost::asio::io_context io_context_type;
+
+ typedef test_stream lowest_layer_type;
+
+ typedef io_context_type::executor_type executor_type;
+
+ test_stream(boost::asio::io_context& io_context)
+ : io_context_(io_context)
+ {
+ }
+
+ io_context_type& io_context()
+ {
+ return io_context_;
+ }
+
+ lowest_layer_type& lowest_layer()
+ {
+ return *this;
+ }
+
+ template <typename Const_Buffers>
+ size_t write(const Const_Buffers&)
+ {
+ return 0;
+ }
+
+ template <typename Const_Buffers>
+ size_t write(const Const_Buffers&, boost::system::error_code& ec)
+ {
+ ec = boost::system::error_code();
+ return 0;
+ }
+
+ template <typename Const_Buffers, typename Handler>
+ void async_write(const Const_Buffers&, Handler handler)
+ {
+ boost::system::error_code error;
+ boost::asio::post(io_context_,
+ boost::asio::detail::bind_handler(handler, error, 0));
+ }
+
+ template <typename Mutable_Buffers>
+ size_t read(const Mutable_Buffers&)
+ {
+ return 0;
+ }
+
+ template <typename Mutable_Buffers>
+ size_t read(const Mutable_Buffers&, boost::system::error_code& ec)
+ {
+ ec = boost::system::error_code();
+ return 0;
+ }
+
+ template <typename Mutable_Buffers, typename Handler>
+ void async_read(const Mutable_Buffers&, Handler handler)
+ {
+ boost::system::error_code error;
+ boost::asio::post(io_context_,
+ boost::asio::detail::bind_handler(handler, error, 0));
+ }
+
+private:
+ io_context_type& io_context_;
+};
+
+void is_read_buffered_test()
+{
+ BOOST_ASIO_CHECK(!boost::asio::is_read_buffered<
+ boost::asio::ip::tcp::socket>::value);
+
+ BOOST_ASIO_CHECK(!!boost::asio::is_read_buffered<
+ boost::asio::buffered_read_stream<
+ boost::asio::ip::tcp::socket> >::value);
+
+ BOOST_ASIO_CHECK(!boost::asio::is_read_buffered<
+ boost::asio::buffered_write_stream<
+ boost::asio::ip::tcp::socket> >::value);
+
+ BOOST_ASIO_CHECK(!!boost::asio::is_read_buffered<
+ boost::asio::buffered_stream<boost::asio::ip::tcp::socket> >::value);
+
+ BOOST_ASIO_CHECK(!boost::asio::is_read_buffered<test_stream>::value);
+
+ BOOST_ASIO_CHECK(!!boost::asio::is_read_buffered<
+ boost::asio::buffered_read_stream<test_stream> >::value);
+
+ BOOST_ASIO_CHECK(!boost::asio::is_read_buffered<
+ boost::asio::buffered_write_stream<test_stream> >::value);
+
+ BOOST_ASIO_CHECK(!!boost::asio::is_read_buffered<
+ boost::asio::buffered_stream<test_stream> >::value);
+}
+
+BOOST_ASIO_TEST_SUITE
+(
+ "is_read_buffered",
+ BOOST_ASIO_TEST_CASE(is_read_buffered_test)
+)
diff --git a/src/boost/libs/asio/test/is_write_buffered.cpp b/src/boost/libs/asio/test/is_write_buffered.cpp
new file mode 100644
index 000000000..c00c39b4a
--- /dev/null
+++ b/src/boost/libs/asio/test/is_write_buffered.cpp
@@ -0,0 +1,129 @@
+//
+// is_write_buffered.cpp
+// ~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/is_write_buffered.hpp>
+
+#include <boost/asio/buffered_read_stream.hpp>
+#include <boost/asio/buffered_write_stream.hpp>
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/ip/tcp.hpp>
+#include "unit_test.hpp"
+
+using namespace std; // For memcmp, memcpy and memset.
+
+class test_stream
+{
+public:
+ typedef boost::asio::io_context io_context_type;
+
+ typedef test_stream lowest_layer_type;
+
+ typedef io_context_type::executor_type executor_type;
+
+ test_stream(boost::asio::io_context& io_context)
+ : io_context_(io_context)
+ {
+ }
+
+ io_context_type& io_context()
+ {
+ return io_context_;
+ }
+
+ lowest_layer_type& lowest_layer()
+ {
+ return *this;
+ }
+
+ template <typename Const_Buffers>
+ size_t write(const Const_Buffers&)
+ {
+ return 0;
+ }
+
+ template <typename Const_Buffers>
+ size_t write(const Const_Buffers&, boost::system::error_code& ec)
+ {
+ ec = boost::system::error_code();
+ return 0;
+ }
+
+ template <typename Const_Buffers, typename Handler>
+ void async_write(const Const_Buffers&, Handler handler)
+ {
+ boost::system::error_code error;
+ boost::asio::post(io_context_,
+ boost::asio::detail::bind_handler(handler, error, 0));
+ }
+
+ template <typename Mutable_Buffers>
+ size_t read(const Mutable_Buffers&)
+ {
+ return 0;
+ }
+
+ template <typename Mutable_Buffers>
+ size_t read(const Mutable_Buffers&, boost::system::error_code& ec)
+ {
+ ec = boost::system::error_code();
+ return 0;
+ }
+
+ template <typename Mutable_Buffers, typename Handler>
+ void async_read(const Mutable_Buffers&, Handler handler)
+ {
+ boost::system::error_code error;
+ boost::asio::post(io_context_,
+ boost::asio::detail::bind_handler(handler, error, 0));
+ }
+
+private:
+ io_context_type& io_context_;
+};
+
+void is_write_buffered_test()
+{
+ BOOST_ASIO_CHECK(!boost::asio::is_write_buffered<
+ boost::asio::ip::tcp::socket>::value);
+
+ BOOST_ASIO_CHECK(!boost::asio::is_write_buffered<
+ boost::asio::buffered_read_stream<
+ boost::asio::ip::tcp::socket> >::value);
+
+ BOOST_ASIO_CHECK(!!boost::asio::is_write_buffered<
+ boost::asio::buffered_write_stream<
+ boost::asio::ip::tcp::socket> >::value);
+
+ BOOST_ASIO_CHECK(!!boost::asio::is_write_buffered<
+ boost::asio::buffered_stream<boost::asio::ip::tcp::socket> >::value);
+
+ BOOST_ASIO_CHECK(!boost::asio::is_write_buffered<test_stream>::value);
+
+ BOOST_ASIO_CHECK(!boost::asio::is_write_buffered<
+ boost::asio::buffered_read_stream<test_stream> >::value);
+
+ BOOST_ASIO_CHECK(!!boost::asio::is_write_buffered<
+ boost::asio::buffered_write_stream<test_stream> >::value);
+
+ BOOST_ASIO_CHECK(!!boost::asio::is_write_buffered<
+ boost::asio::buffered_stream<test_stream> >::value);
+}
+
+BOOST_ASIO_TEST_SUITE
+(
+ "is_write_buffered",
+ BOOST_ASIO_TEST_CASE(is_write_buffered_test)
+)
diff --git a/src/boost/libs/asio/test/latency/Jamfile.v2 b/src/boost/libs/asio/test/latency/Jamfile.v2
new file mode 100644
index 000000000..cd6c88cc3
--- /dev/null
+++ b/src/boost/libs/asio/test/latency/Jamfile.v2
@@ -0,0 +1,36 @@
+#
+# Copyright (c) 2003-2020 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)
+#
+
+lib socket ; # SOLARIS
+lib nsl ; # SOLARIS
+lib ws2_32 ; # NT
+lib mswsock ; # NT
+lib ipv6 ; # HPUX
+lib network ; # HAIKU
+
+project
+ : requirements
+ <library>/boost/system//boost_system
+ <library>/boost/chrono//boost_chrono
+ <library>/boost/thread//boost_thread
+ <define>BOOST_ALL_NO_LIB=1
+ <threading>multi
+ <target-os>solaris:<library>socket
+ <target-os>solaris:<library>nsl
+ <target-os>windows:<define>_WIN32_WINNT=0x0501
+ <target-os>windows,<toolset>gcc:<library>ws2_32
+ <target-os>windows,<toolset>gcc:<library>mswsock
+ <target-os>windows,<toolset>gcc-cygwin:<define>__USE_W32_SOCKETS
+ <target-os>hpux,<toolset>gcc:<define>_XOPEN_SOURCE_EXTENDED
+ <target-os>hpux:<library>ipv6
+ <target-os>haiku:<library>network
+ ;
+
+exe tcp_server : tcp_server.cpp ;
+exe tcp_client : tcp_client.cpp ;
+exe udp_server : udp_server.cpp ;
+exe udp_client : udp_client.cpp ;
diff --git a/src/boost/libs/asio/test/latency/allocator.hpp b/src/boost/libs/asio/test/latency/allocator.hpp
new file mode 100644
index 000000000..33cdfbf8f
--- /dev/null
+++ b/src/boost/libs/asio/test/latency/allocator.hpp
@@ -0,0 +1,52 @@
+//
+// allocator.hpp
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 ALLOCATOR_HPP
+#define ALLOCATOR_HPP
+
+#include <boost/aligned_storage.hpp>
+
+// Represents a single connection from a client.
+class allocator
+{
+public:
+ allocator()
+ : in_use_(false)
+ {
+ }
+
+ void* allocate(std::size_t n)
+ {
+ if (in_use_ || n >= 1024)
+ return ::operator new(n);
+ in_use_ = true;
+ return static_cast<void*>(&space_);
+ }
+
+ void deallocate(void* p)
+ {
+ if (p != static_cast<void*>(&space_))
+ ::operator delete(p);
+ else
+ in_use_ = false;
+ }
+
+private:
+ allocator(const allocator&);
+ allocator& operator=(const allocator&);
+
+ // Whether the reusable memory space is currently in use.
+ bool in_use_;
+
+ // The reusable memory space made available by the allocator.
+ boost::aligned_storage<1024>::type space_;
+};
+
+#endif // ALLOCATOR_HPP
diff --git a/src/boost/libs/asio/test/latency/high_res_clock.hpp b/src/boost/libs/asio/test/latency/high_res_clock.hpp
new file mode 100644
index 000000000..afc33ccef
--- /dev/null
+++ b/src/boost/libs/asio/test/latency/high_res_clock.hpp
@@ -0,0 +1,53 @@
+//
+// high_res_clock.hpp
+// ~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 HIGH_RES_CLOCK_HPP
+#define HIGH_RES_CLOCK_HPP
+
+#include <boost/config.hpp>
+#include <boost/cstdint.hpp>
+
+#if defined(BOOST_ASIO_WINDOWS)
+
+inline boost::uint64_t high_res_clock()
+{
+ LARGE_INTEGER i;
+ QueryPerformanceCounter(&i);
+ return i.QuadPart;
+}
+
+#elif defined(__GNUC__) && defined(__x86_64__)
+
+inline boost::uint64_t high_res_clock()
+{
+ unsigned long low, high;
+ __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high));
+ return (((boost::uint64_t)high) << 32) | low;
+}
+
+#else
+
+#include <boost/date_time/posix_time/posix_time_types.hpp>
+
+inline boost::uint64_t high_res_clock()
+{
+ boost::posix_time::ptime now =
+ boost::posix_time::microsec_clock::universal_time();
+
+ boost::posix_time::ptime epoch(
+ boost::gregorian::date(1970, 1, 1),
+ boost::posix_time::seconds(0));
+
+ return (now - epoch).total_microseconds();
+}
+
+#endif
+
+#endif // HIGH_RES_CLOCK_HPP
diff --git a/src/boost/libs/asio/test/latency/tcp_client.cpp b/src/boost/libs/asio/test/latency/tcp_client.cpp
new file mode 100644
index 000000000..bdcdcf2df
--- /dev/null
+++ b/src/boost/libs/asio/test/latency/tcp_client.cpp
@@ -0,0 +1,124 @@
+//
+// tcp_client.cpp
+// ~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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)
+//
+
+#include <boost/asio/ip/tcp.hpp>
+#include <boost/asio/read.hpp>
+#include <boost/asio/write.hpp>
+#include <boost/date_time/posix_time/posix_time_types.hpp>
+#include <boost/shared_ptr.hpp>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <vector>
+#include "high_res_clock.hpp"
+
+using boost::asio::ip::tcp;
+using boost::posix_time::ptime;
+using boost::posix_time::microsec_clock;
+
+const int num_samples = 100000;
+
+struct transfer_all
+{
+ typedef std::size_t result_type;
+ std::size_t operator()(const boost::system::error_code& ec, std::size_t)
+ {
+ return (ec && ec != boost::asio::error::would_block) ? 0 : ~0;
+ }
+};
+
+int main(int argc, char* argv[])
+{
+ if (argc != 6)
+ {
+ std::fprintf(stderr,
+ "Usage: tcp_client <ip> <port> "
+ "<nconns> <bufsize> {spin|block}\n");
+ return 1;
+ }
+
+ const char* ip = argv[1];
+ unsigned short port = static_cast<unsigned short>(std::atoi(argv[2]));
+ int num_connections = std::atoi(argv[3]);
+ std::size_t buf_size = static_cast<std::size_t>(std::atoi(argv[4]));
+ bool spin = (std::strcmp(argv[5], "spin") == 0);
+
+ boost::asio::io_context io_context;
+ std::vector<boost::shared_ptr<tcp::socket> > sockets;
+
+ for (int i = 0; i < num_connections; ++i)
+ {
+ boost::shared_ptr<tcp::socket> s(new tcp::socket(io_context));
+
+ tcp::endpoint target(boost::asio::ip::make_address(ip), port);
+ s->connect(target);
+
+ s->set_option(tcp::no_delay(true));
+
+ if (spin)
+ {
+ s->non_blocking(true);
+ }
+
+ sockets.push_back(s);
+ }
+
+ std::vector<unsigned char> write_buf(buf_size);
+ std::vector<unsigned char> read_buf(buf_size);
+
+ ptime start = microsec_clock::universal_time();
+ boost::uint64_t start_hr = high_res_clock();
+
+ boost::uint64_t samples[num_samples];
+ for (int i = 0; i < num_samples; ++i)
+ {
+ tcp::socket& socket = *sockets[i % num_connections];
+
+ boost::uint64_t t = high_res_clock();
+
+ boost::system::error_code ec;
+ boost::asio::write(socket,
+ boost::asio::buffer(write_buf),
+ transfer_all(), ec);
+
+ boost::asio::read(socket,
+ boost::asio::buffer(read_buf),
+ transfer_all(), ec);
+
+ samples[i] = high_res_clock() - t;
+ }
+
+ ptime stop = microsec_clock::universal_time();
+ boost::uint64_t stop_hr = high_res_clock();
+ boost::uint64_t elapsed_usec = (stop - start).total_microseconds();
+ boost::uint64_t elapsed_hr = stop_hr - start_hr;
+ double scale = 1.0 * elapsed_usec / elapsed_hr;
+
+ std::sort(samples, samples + num_samples);
+ std::printf(" 0.0%%\t%f\n", samples[0] * scale);
+ std::printf(" 0.1%%\t%f\n", samples[num_samples / 1000 - 1] * scale);
+ std::printf(" 1.0%%\t%f\n", samples[num_samples / 100 - 1] * scale);
+ std::printf(" 10.0%%\t%f\n", samples[num_samples / 10 - 1] * scale);
+ std::printf(" 20.0%%\t%f\n", samples[num_samples * 2 / 10 - 1] * scale);
+ std::printf(" 30.0%%\t%f\n", samples[num_samples * 3 / 10 - 1] * scale);
+ std::printf(" 40.0%%\t%f\n", samples[num_samples * 4 / 10 - 1] * scale);
+ std::printf(" 50.0%%\t%f\n", samples[num_samples * 5 / 10 - 1] * scale);
+ std::printf(" 60.0%%\t%f\n", samples[num_samples * 6 / 10 - 1] * scale);
+ std::printf(" 70.0%%\t%f\n", samples[num_samples * 7 / 10 - 1] * scale);
+ std::printf(" 80.0%%\t%f\n", samples[num_samples * 8 / 10 - 1] * scale);
+ std::printf(" 90.0%%\t%f\n", samples[num_samples * 9 / 10 - 1] * scale);
+ std::printf(" 99.0%%\t%f\n", samples[num_samples * 99 / 100 - 1] * scale);
+ std::printf(" 99.9%%\t%f\n", samples[num_samples * 999 / 1000 - 1] * scale);
+ std::printf("100.0%%\t%f\n", samples[num_samples - 1] * scale);
+
+ double total = 0.0;
+ for (int i = 0; i < num_samples; ++i) total += samples[i] * scale;
+ std::printf(" mean\t%f\n", total / num_samples);
+}
diff --git a/src/boost/libs/asio/test/latency/tcp_server.cpp b/src/boost/libs/asio/test/latency/tcp_server.cpp
new file mode 100644
index 000000000..587d774f0
--- /dev/null
+++ b/src/boost/libs/asio/test/latency/tcp_server.cpp
@@ -0,0 +1,114 @@
+//
+// tcp_server.cpp
+// ~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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)
+//
+
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/ip/tcp.hpp>
+#include <boost/asio/read.hpp>
+#include <boost/asio/write.hpp>
+#include <boost/shared_ptr.hpp>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <vector>
+
+using boost::asio::ip::tcp;
+
+#include <boost/asio/yield.hpp>
+
+class tcp_server : boost::asio::coroutine
+{
+public:
+ tcp_server(tcp::acceptor& acceptor, std::size_t buf_size) :
+ acceptor_(acceptor),
+ socket_(acceptor_.get_executor()),
+ buffer_(buf_size)
+ {
+ }
+
+ void operator()(boost::system::error_code ec, std::size_t n = 0)
+ {
+ reenter (this) for (;;)
+ {
+ yield acceptor_.async_accept(socket_, ref(this));
+
+ while (!ec)
+ {
+ yield boost::asio::async_read(socket_,
+ boost::asio::buffer(buffer_), ref(this));
+
+ if (!ec)
+ {
+ for (std::size_t i = 0; i < n; ++i) buffer_[i] = ~buffer_[i];
+
+ yield boost::asio::async_write(socket_,
+ boost::asio::buffer(buffer_), ref(this));
+ }
+ }
+
+ socket_.close();
+ }
+ }
+
+ struct ref
+ {
+ explicit ref(tcp_server* p)
+ : p_(p)
+ {
+ }
+
+ void operator()(boost::system::error_code ec, std::size_t n = 0)
+ {
+ (*p_)(ec, n);
+ }
+
+ private:
+ tcp_server* p_;
+ };
+
+private:
+ tcp::acceptor& acceptor_;
+ tcp::socket socket_;
+ std::vector<unsigned char> buffer_;
+ tcp::endpoint sender_;
+};
+
+#include <boost/asio/unyield.hpp>
+
+int main(int argc, char* argv[])
+{
+ if (argc != 5)
+ {
+ std::fprintf(stderr,
+ "Usage: tcp_server <port> <nconns> "
+ "<bufsize> {spin|block}\n");
+ return 1;
+ }
+
+ unsigned short port = static_cast<unsigned short>(std::atoi(argv[1]));
+ int max_connections = std::atoi(argv[2]);
+ std::size_t buf_size = std::atoi(argv[3]);
+ bool spin = (std::strcmp(argv[4], "spin") == 0);
+
+ boost::asio::io_context io_context(1);
+ tcp::acceptor acceptor(io_context, tcp::endpoint(tcp::v4(), port));
+ std::vector<boost::shared_ptr<tcp_server> > servers;
+
+ for (int i = 0; i < max_connections; ++i)
+ {
+ boost::shared_ptr<tcp_server> s(new tcp_server(acceptor, buf_size));
+ servers.push_back(s);
+ (*s)(boost::system::error_code());
+ }
+
+ if (spin)
+ for (;;) io_context.poll();
+ else
+ io_context.run();
+}
diff --git a/src/boost/libs/asio/test/latency/udp_client.cpp b/src/boost/libs/asio/test/latency/udp_client.cpp
new file mode 100644
index 000000000..e2ac4396d
--- /dev/null
+++ b/src/boost/libs/asio/test/latency/udp_client.cpp
@@ -0,0 +1,104 @@
+//
+// udp_client.cpp
+// ~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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)
+//
+
+#include <boost/asio/ip/udp.hpp>
+#include <boost/date_time/posix_time/posix_time_types.hpp>
+#include <algorithm>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <vector>
+#include "high_res_clock.hpp"
+
+using boost::asio::ip::udp;
+using boost::posix_time::ptime;
+using boost::posix_time::microsec_clock;
+
+const int num_samples = 100000;
+
+int main(int argc, char* argv[])
+{
+ if (argc != 6)
+ {
+ std::fprintf(stderr,
+ "Usage: udp_client <ip> <port1> "
+ "<nports> <bufsize> {spin|block}\n");
+ return 1;
+ }
+
+ const char* ip = argv[1];
+ unsigned short first_port = static_cast<unsigned short>(std::atoi(argv[2]));
+ unsigned short num_ports = static_cast<unsigned short>(std::atoi(argv[3]));
+ std::size_t buf_size = static_cast<std::size_t>(std::atoi(argv[4]));
+ bool spin = (std::strcmp(argv[5], "spin") == 0);
+
+ boost::asio::io_context io_context;
+
+ udp::socket socket(io_context, udp::endpoint(udp::v4(), 0));
+
+ if (spin)
+ {
+ socket.non_blocking(true);
+ }
+
+ udp::endpoint target(boost::asio::ip::make_address(ip), first_port);
+ unsigned short last_port = first_port + num_ports - 1;
+ std::vector<unsigned char> write_buf(buf_size);
+ std::vector<unsigned char> read_buf(buf_size);
+
+ ptime start = microsec_clock::universal_time();
+ boost::uint64_t start_hr = high_res_clock();
+
+ boost::uint64_t samples[num_samples];
+ for (int i = 0; i < num_samples; ++i)
+ {
+ boost::uint64_t t = high_res_clock();
+
+ boost::system::error_code ec;
+ socket.send_to(boost::asio::buffer(write_buf), target, 0, ec);
+
+ do socket.receive(boost::asio::buffer(read_buf), 0, ec);
+ while (ec == boost::asio::error::would_block);
+
+ samples[i] = high_res_clock() - t;
+
+ if (target.port() == last_port)
+ target.port(first_port);
+ else
+ target.port(target.port() + 1);
+ }
+
+ ptime stop = microsec_clock::universal_time();
+ boost::uint64_t stop_hr = high_res_clock();
+ boost::uint64_t elapsed_usec = (stop - start).total_microseconds();
+ boost::uint64_t elapsed_hr = stop_hr - start_hr;
+ double scale = 1.0 * elapsed_usec / elapsed_hr;
+
+ std::sort(samples, samples + num_samples);
+ std::printf(" 0.0%%\t%f\n", samples[0] * scale);
+ std::printf(" 0.1%%\t%f\n", samples[num_samples / 1000 - 1] * scale);
+ std::printf(" 1.0%%\t%f\n", samples[num_samples / 100 - 1] * scale);
+ std::printf(" 10.0%%\t%f\n", samples[num_samples / 10 - 1] * scale);
+ std::printf(" 20.0%%\t%f\n", samples[num_samples * 2 / 10 - 1] * scale);
+ std::printf(" 30.0%%\t%f\n", samples[num_samples * 3 / 10 - 1] * scale);
+ std::printf(" 40.0%%\t%f\n", samples[num_samples * 4 / 10 - 1] * scale);
+ std::printf(" 50.0%%\t%f\n", samples[num_samples * 5 / 10 - 1] * scale);
+ std::printf(" 60.0%%\t%f\n", samples[num_samples * 6 / 10 - 1] * scale);
+ std::printf(" 70.0%%\t%f\n", samples[num_samples * 7 / 10 - 1] * scale);
+ std::printf(" 80.0%%\t%f\n", samples[num_samples * 8 / 10 - 1] * scale);
+ std::printf(" 90.0%%\t%f\n", samples[num_samples * 9 / 10 - 1] * scale);
+ std::printf(" 99.0%%\t%f\n", samples[num_samples * 99 / 100 - 1] * scale);
+ std::printf(" 99.9%%\t%f\n", samples[num_samples * 999 / 1000 - 1] * scale);
+ std::printf("100.0%%\t%f\n", samples[num_samples - 1] * scale);
+
+ double total = 0.0;
+ for (int i = 0; i < num_samples; ++i) total += samples[i] * scale;
+ std::printf(" mean\t%f\n", total / num_samples);
+}
diff --git a/src/boost/libs/asio/test/latency/udp_server.cpp b/src/boost/libs/asio/test/latency/udp_server.cpp
new file mode 100644
index 000000000..4bba70059
--- /dev/null
+++ b/src/boost/libs/asio/test/latency/udp_server.cpp
@@ -0,0 +1,125 @@
+//
+// udp_server.cpp
+// ~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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)
+//
+
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/ip/udp.hpp>
+#include <boost/shared_ptr.hpp>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <vector>
+#include "allocator.hpp"
+
+using boost::asio::ip::udp;
+
+#include <boost/asio/yield.hpp>
+
+class udp_server : boost::asio::coroutine
+{
+public:
+ udp_server(boost::asio::io_context& io_context,
+ unsigned short port, std::size_t buf_size) :
+ socket_(io_context, udp::endpoint(udp::v4(), port)),
+ buffer_(buf_size)
+ {
+ }
+
+ void operator()(boost::system::error_code ec, std::size_t n = 0)
+ {
+ reenter (this) for (;;)
+ {
+ yield socket_.async_receive_from(
+ boost::asio::buffer(buffer_),
+ sender_, ref(this));
+
+ if (!ec)
+ {
+ for (std::size_t i = 0; i < n; ++i) buffer_[i] = ~buffer_[i];
+ socket_.send_to(boost::asio::buffer(buffer_, n), sender_, 0, ec);
+ }
+ }
+ }
+
+ friend void* asio_handler_allocate(std::size_t n, udp_server* s)
+ {
+ return s->allocator_.allocate(n);
+ }
+
+ friend void asio_handler_deallocate(void* p, std::size_t, udp_server* s)
+ {
+ s->allocator_.deallocate(p);
+ }
+
+ struct ref
+ {
+ explicit ref(udp_server* p)
+ : p_(p)
+ {
+ }
+
+ void operator()(boost::system::error_code ec, std::size_t n = 0)
+ {
+ (*p_)(ec, n);
+ }
+
+ private:
+ udp_server* p_;
+
+ friend void* asio_handler_allocate(std::size_t n, ref* r)
+ {
+ return asio_handler_allocate(n, r->p_);
+ }
+
+ friend void asio_handler_deallocate(void* p, std::size_t n, ref* r)
+ {
+ asio_handler_deallocate(p, n, r->p_);
+ }
+ };
+
+private:
+ udp::socket socket_;
+ std::vector<unsigned char> buffer_;
+ udp::endpoint sender_;
+ allocator allocator_;
+};
+
+#include <boost/asio/unyield.hpp>
+
+int main(int argc, char* argv[])
+{
+ if (argc != 5)
+ {
+ std::fprintf(stderr,
+ "Usage: udp_server <port1> <nports> "
+ "<bufsize> {spin|block}\n");
+ return 1;
+ }
+
+ unsigned short first_port = static_cast<unsigned short>(std::atoi(argv[1]));
+ unsigned short num_ports = static_cast<unsigned short>(std::atoi(argv[2]));
+ std::size_t buf_size = std::atoi(argv[3]);
+ bool spin = (std::strcmp(argv[4], "spin") == 0);
+
+ boost::asio::io_context io_context(1);
+ std::vector<boost::shared_ptr<udp_server> > servers;
+
+ for (unsigned short i = 0; i < num_ports; ++i)
+ {
+ unsigned short port = first_port + i;
+ boost::shared_ptr<udp_server> s(new udp_server(io_context, port, buf_size));
+ servers.push_back(s);
+ (*s)(boost::system::error_code());
+ }
+
+ if (spin)
+ for (;;) io_context.poll();
+ else
+ io_context.run();
+}
diff --git a/src/boost/libs/asio/test/local/basic_endpoint.cpp b/src/boost/libs/asio/test/local/basic_endpoint.cpp
new file mode 100644
index 000000000..15ed7cedd
--- /dev/null
+++ b/src/boost/libs/asio/test/local/basic_endpoint.cpp
@@ -0,0 +1,25 @@
+//
+// basic_endpoint.cpp
+// ~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/local/basic_endpoint.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "local/basic_endpoint",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/local/connect_pair.cpp b/src/boost/libs/asio/test/local/connect_pair.cpp
new file mode 100644
index 000000000..a2faad90c
--- /dev/null
+++ b/src/boost/libs/asio/test/local/connect_pair.cpp
@@ -0,0 +1,76 @@
+//
+// connect_pair.cpp
+// ~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/local/connect_pair.hpp>
+
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/local/datagram_protocol.hpp>
+#include <boost/asio/local/stream_protocol.hpp>
+#include "../unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+// local_connect_pair_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all host_name functions compile and link
+// correctly. Runtime failures are ignored.
+
+namespace local_connect_pair_compile {
+
+void test()
+{
+#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
+ using namespace boost::asio;
+ namespace local = boost::asio::local;
+ typedef local::datagram_protocol dp;
+ typedef local::stream_protocol sp;
+
+ try
+ {
+ boost::asio::io_context io_context;
+ boost::system::error_code ec1;
+
+ dp::socket s1(io_context);
+ dp::socket s2(io_context);
+ local::connect_pair(s1, s2);
+
+ dp::socket s3(io_context);
+ dp::socket s4(io_context);
+ local::connect_pair(s3, s4, ec1);
+
+ sp::socket s5(io_context);
+ sp::socket s6(io_context);
+ local::connect_pair(s5, s6);
+
+ sp::socket s7(io_context);
+ sp::socket s8(io_context);
+ local::connect_pair(s7, s8, ec1);
+ }
+ catch (std::exception&)
+ {
+ }
+#endif // defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
+}
+
+} // namespace local_connect_pair_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "local/connect_pair",
+ BOOST_ASIO_TEST_CASE(local_connect_pair_compile::test)
+)
diff --git a/src/boost/libs/asio/test/local/datagram_protocol.cpp b/src/boost/libs/asio/test/local/datagram_protocol.cpp
new file mode 100644
index 000000000..d85e09ec7
--- /dev/null
+++ b/src/boost/libs/asio/test/local/datagram_protocol.cpp
@@ -0,0 +1,242 @@
+//
+// datagram_protocol.cpp
+// ~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/local/datagram_protocol.hpp>
+
+#include <cstring>
+#include <boost/asio/io_context.hpp>
+#include "../unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+// local_datagram_protocol_socket_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// local::datagram_socket::socket compile and link correctly. Runtime failures
+// are ignored.
+
+namespace local_datagram_protocol_socket_compile {
+
+void connect_handler(const boost::system::error_code&)
+{
+}
+
+void send_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void receive_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void test()
+{
+#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
+ using namespace boost::asio;
+ namespace local = boost::asio::local;
+ typedef local::datagram_protocol dp;
+
+ 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;
+ socket_base::send_buffer_size socket_option;
+ socket_base::bytes_readable io_control_command;
+ boost::system::error_code ec;
+
+ // basic_datagram_socket constructors.
+
+ dp::socket socket1(ioc);
+ dp::socket socket2(ioc, dp());
+ dp::socket socket3(ioc, dp::endpoint(""));
+ int native_socket1 = ::socket(AF_UNIX, SOCK_DGRAM, 0);
+ dp::socket socket4(ioc, dp(), native_socket1);
+
+ 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);
+
+ // basic_io_object functions.
+
+ dp::socket::executor_type ex = socket1.get_executor();
+ (void)ex;
+
+ // basic_socket functions.
+
+ dp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer();
+ (void)lowest_layer;
+
+ socket1.open(dp());
+ socket1.open(dp(), ec);
+
+ int native_socket3 = ::socket(AF_UNIX, SOCK_DGRAM, 0);
+ 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;
+
+ socket1.close();
+ socket1.close(ec);
+
+ dp::socket::native_handle_type native_socket5 = socket1.native_handle();
+ (void)native_socket5;
+
+ 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(dp::endpoint(""));
+ socket1.bind(dp::endpoint(""), ec);
+
+ socket1.connect(dp::endpoint(""));
+ socket1.connect(dp::endpoint(""), ec);
+
+ socket1.async_connect(dp::endpoint(""), connect_handler);
+
+ 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);
+
+ 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);
+
+ // basic_datagram_socket functions.
+
+ socket1.send(buffer(mutable_char_buffer));
+ socket1.send(buffer(const_char_buffer));
+ socket1.send(null_buffers());
+ 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), send_handler);
+ socket1.async_send(buffer(const_char_buffer), send_handler);
+ socket1.async_send(null_buffers(), send_handler);
+ 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.send_to(buffer(mutable_char_buffer),
+ dp::endpoint(""));
+ socket1.send_to(buffer(const_char_buffer),
+ dp::endpoint(""));
+ socket1.send_to(null_buffers(),
+ dp::endpoint(""));
+ socket1.send_to(buffer(mutable_char_buffer),
+ dp::endpoint(""), in_flags);
+ socket1.send_to(buffer(const_char_buffer),
+ dp::endpoint(""), in_flags);
+ socket1.send_to(null_buffers(),
+ dp::endpoint(""), in_flags);
+ socket1.send_to(buffer(mutable_char_buffer),
+ dp::endpoint(""), in_flags, ec);
+ socket1.send_to(buffer(const_char_buffer),
+ dp::endpoint(""), in_flags, ec);
+ socket1.send_to(null_buffers(),
+ dp::endpoint(""), in_flags, ec);
+
+ socket1.async_send_to(buffer(mutable_char_buffer),
+ dp::endpoint(""), send_handler);
+ socket1.async_send_to(buffer(const_char_buffer),
+ dp::endpoint(""), send_handler);
+ socket1.async_send_to(null_buffers(),
+ dp::endpoint(""), send_handler);
+ socket1.async_send_to(buffer(mutable_char_buffer),
+ dp::endpoint(""), in_flags, send_handler);
+ socket1.async_send_to(buffer(const_char_buffer),
+ dp::endpoint(""), in_flags, send_handler);
+ socket1.async_send_to(null_buffers(),
+ dp::endpoint(""), in_flags, send_handler);
+
+ socket1.receive(buffer(mutable_char_buffer));
+ socket1.receive(null_buffers());
+ socket1.receive(buffer(mutable_char_buffer), in_flags);
+ socket1.receive(null_buffers(), in_flags);
+ socket1.receive(buffer(mutable_char_buffer), in_flags, ec);
+ socket1.receive(null_buffers(), in_flags, ec);
+
+ socket1.async_receive(buffer(mutable_char_buffer), receive_handler);
+ socket1.async_receive(null_buffers(), receive_handler);
+ socket1.async_receive(buffer(mutable_char_buffer), in_flags,
+ receive_handler);
+ socket1.async_receive(null_buffers(), in_flags, receive_handler);
+
+ dp::endpoint endpoint;
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint);
+ socket1.receive_from(null_buffers(), endpoint);
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint, in_flags);
+ socket1.receive_from(null_buffers(), endpoint, in_flags);
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint, in_flags, ec);
+ socket1.receive_from(null_buffers(), endpoint, in_flags, ec);
+
+ socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, receive_handler);
+ socket1.async_receive_from(null_buffers(),
+ endpoint, receive_handler);
+ socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, in_flags, receive_handler);
+ socket1.async_receive_from(null_buffers(),
+ endpoint, in_flags, receive_handler);
+ }
+ catch (std::exception&)
+ {
+ }
+#endif // defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
+}
+
+} // namespace local_datagram_protocol_socket_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "local/datagram_protocol",
+ BOOST_ASIO_TEST_CASE(local_datagram_protocol_socket_compile::test)
+)
diff --git a/src/boost/libs/asio/test/local/stream_protocol.cpp b/src/boost/libs/asio/test/local/stream_protocol.cpp
new file mode 100644
index 000000000..6728393c0
--- /dev/null
+++ b/src/boost/libs/asio/test/local/stream_protocol.cpp
@@ -0,0 +1,219 @@
+//
+// stream_protocol.cpp
+// ~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/local/stream_protocol.hpp>
+
+#include <cstring>
+#include <boost/asio/io_context.hpp>
+#include "../unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+// local_stream_protocol_socket_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// local::stream_protocol::socket compile and link correctly. Runtime failures
+// are ignored.
+
+namespace local_stream_protocol_socket_compile {
+
+void connect_handler(const boost::system::error_code&)
+{
+}
+
+void send_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void receive_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void write_some_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void read_some_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void test()
+{
+#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
+ using namespace boost::asio;
+ namespace local = boost::asio::local;
+ typedef local::stream_protocol sp;
+
+ 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;
+ socket_base::keep_alive socket_option;
+ socket_base::bytes_readable io_control_command;
+ boost::system::error_code ec;
+
+ // basic_stream_socket constructors.
+
+ sp::socket socket1(ioc);
+ sp::socket socket2(ioc, sp());
+ sp::socket socket3(ioc, sp::endpoint(""));
+ int native_socket1 = ::socket(AF_UNIX, SOCK_STREAM, 0);
+ sp::socket socket4(ioc, sp(), native_socket1);
+
+ 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);
+
+ // basic_io_object functions.
+
+ sp::socket::executor_type ex = socket1.get_executor();
+ (void)ex;
+
+ // basic_socket functions.
+
+ sp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer();
+ (void)lowest_layer;
+
+ socket1.open(sp());
+ socket1.open(sp(), ec);
+
+ int native_socket3 = ::socket(AF_UNIX, SOCK_STREAM, 0);
+ 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;
+
+ socket1.close();
+ socket1.close(ec);
+
+ sp::socket::native_handle_type native_socket5 = socket1.native_handle();
+ (void)native_socket5;
+
+ 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(sp::endpoint(""));
+ socket1.bind(sp::endpoint(""), ec);
+
+ socket1.connect(sp::endpoint(""));
+ socket1.connect(sp::endpoint(""), ec);
+
+ socket1.async_connect(sp::endpoint(""), connect_handler);
+
+ 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);
+
+ 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);
+
+ // basic_stream_socket functions.
+
+ socket1.send(buffer(mutable_char_buffer));
+ socket1.send(buffer(const_char_buffer));
+ socket1.send(null_buffers());
+ 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), send_handler);
+ socket1.async_send(buffer(const_char_buffer), send_handler);
+ socket1.async_send(null_buffers(), send_handler);
+ 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.receive(buffer(mutable_char_buffer));
+ socket1.receive(null_buffers());
+ socket1.receive(buffer(mutable_char_buffer), in_flags);
+ socket1.receive(null_buffers(), in_flags);
+ socket1.receive(buffer(mutable_char_buffer), in_flags, ec);
+ socket1.receive(null_buffers(), in_flags, ec);
+
+ socket1.async_receive(buffer(mutable_char_buffer), receive_handler);
+ socket1.async_receive(null_buffers(), receive_handler);
+ socket1.async_receive(buffer(mutable_char_buffer), in_flags,
+ receive_handler);
+ socket1.async_receive(null_buffers(), in_flags, receive_handler);
+
+ socket1.write_some(buffer(mutable_char_buffer));
+ socket1.write_some(buffer(const_char_buffer));
+ socket1.write_some(null_buffers());
+ socket1.write_some(buffer(mutable_char_buffer), ec);
+ socket1.write_some(buffer(const_char_buffer), ec);
+ socket1.write_some(null_buffers(), ec);
+
+ 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.read_some(buffer(mutable_char_buffer));
+ socket1.read_some(buffer(mutable_char_buffer), ec);
+ socket1.read_some(null_buffers(), ec);
+
+ socket1.async_read_some(buffer(mutable_char_buffer), read_some_handler);
+ socket1.async_read_some(null_buffers(), read_some_handler);
+ }
+ catch (std::exception&)
+ {
+ }
+#endif // defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
+}
+
+} // namespace local_stream_protocol_socket_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "local/stream_protocol",
+ BOOST_ASIO_TEST_CASE(local_stream_protocol_socket_compile::test)
+)
diff --git a/src/boost/libs/asio/test/packaged_task.cpp b/src/boost/libs/asio/test/packaged_task.cpp
new file mode 100644
index 000000000..ba6494aed
--- /dev/null
+++ b/src/boost/libs/asio/test/packaged_task.cpp
@@ -0,0 +1,25 @@
+//
+// packaged_task.cpp
+// ~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/packaged_task.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "packaged_task",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/placeholders.cpp b/src/boost/libs/asio/test/placeholders.cpp
new file mode 100644
index 000000000..7524929da
--- /dev/null
+++ b/src/boost/libs/asio/test/placeholders.cpp
@@ -0,0 +1,25 @@
+//
+// placeholders.cpp
+// ~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/placeholders.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "placeholders",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/posix/basic_descriptor.cpp b/src/boost/libs/asio/test/posix/basic_descriptor.cpp
new file mode 100644
index 000000000..ffde113eb
--- /dev/null
+++ b/src/boost/libs/asio/test/posix/basic_descriptor.cpp
@@ -0,0 +1,25 @@
+//
+// basic_descriptor.cpp
+// ~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/posix/basic_descriptor.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "posix/basic_descriptor",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/posix/basic_stream_descriptor.cpp b/src/boost/libs/asio/test/posix/basic_stream_descriptor.cpp
new file mode 100644
index 000000000..55581a849
--- /dev/null
+++ b/src/boost/libs/asio/test/posix/basic_stream_descriptor.cpp
@@ -0,0 +1,25 @@
+//
+// basic_stream_descriptor.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/posix/basic_stream_descriptor.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "posix/basic_stream_descriptor",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/posix/descriptor.cpp b/src/boost/libs/asio/test/posix/descriptor.cpp
new file mode 100644
index 000000000..76fa56f7d
--- /dev/null
+++ b/src/boost/libs/asio/test/posix/descriptor.cpp
@@ -0,0 +1,25 @@
+//
+// descriptor.cpp
+// ~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/posix/descriptor.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "posix/descriptor",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/posix/descriptor_base.cpp b/src/boost/libs/asio/test/posix/descriptor_base.cpp
new file mode 100644
index 000000000..5e1cfa597
--- /dev/null
+++ b/src/boost/libs/asio/test/posix/descriptor_base.cpp
@@ -0,0 +1,25 @@
+//
+// descriptor_base.cpp
+// ~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/posix/descriptor_base.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "posix/descriptor_base",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/posix/stream_descriptor.cpp b/src/boost/libs/asio/test/posix/stream_descriptor.cpp
new file mode 100644
index 000000000..4d0b9c84f
--- /dev/null
+++ b/src/boost/libs/asio/test/posix/stream_descriptor.cpp
@@ -0,0 +1,183 @@
+//
+// stream_descriptor.cpp
+// ~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/posix/stream_descriptor.hpp>
+
+#include <boost/asio/io_context.hpp>
+#include "../archetypes/async_result.hpp"
+#include "../unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+// posix_stream_descriptor_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// posix::stream_descriptor compile and link correctly. Runtime failures are
+// ignored.
+
+namespace posix_stream_descriptor_compile {
+
+void wait_handler(const boost::system::error_code&)
+{
+}
+
+void write_some_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void read_some_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void test()
+{
+#if defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR)
+ using namespace boost::asio;
+ namespace posix = boost::asio::posix;
+
+ 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::lazy_handler lazy;
+ boost::system::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 descriptor3(ioc, native_descriptor1);
+ posix::stream_descriptor descriptor4(ioc_ex, native_descriptor1);
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ posix::stream_descriptor descriptor5(std::move(descriptor2));
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_stream_descriptor operators.
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ descriptor1 = posix::stream_descriptor(ioc);
+ descriptor1 = std::move(descriptor2);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_io_object functions.
+
+ posix::stream_descriptor::executor_type ex = descriptor1.get_executor();
+ (void)ex;
+
+ // basic_descriptor functions.
+
+ posix::stream_descriptor::lowest_layer_type& lowest_layer
+ = descriptor1.lowest_layer();
+ (void)lowest_layer;
+
+ const posix::stream_descriptor& descriptor6 = descriptor1;
+ const posix::stream_descriptor::lowest_layer_type& lowest_layer2
+ = descriptor6.lowest_layer();
+ (void)lowest_layer2;
+
+ int native_descriptor2 = -1;
+ descriptor1.assign(native_descriptor2);
+
+ bool is_open = descriptor1.is_open();
+ (void)is_open;
+
+ descriptor1.close();
+ descriptor1.close(ec);
+
+ posix::stream_descriptor::native_handle_type native_descriptor3
+ = descriptor1.native_handle();
+ (void)native_descriptor3;
+
+ posix::stream_descriptor::native_handle_type native_descriptor4
+ = descriptor1.release();
+ (void)native_descriptor4;
+
+ descriptor1.cancel();
+ descriptor1.cancel(ec);
+
+ descriptor1.io_control(io_control_command);
+ descriptor1.io_control(io_control_command, ec);
+
+ bool non_blocking1 = descriptor1.non_blocking();
+ (void)non_blocking1;
+ descriptor1.non_blocking(true);
+ descriptor1.non_blocking(false, ec);
+
+ bool non_blocking2 = descriptor1.native_non_blocking();
+ (void)non_blocking2;
+ descriptor1.native_non_blocking(true);
+ descriptor1.native_non_blocking(false, ec);
+
+ descriptor1.wait(posix::descriptor_base::wait_read);
+ descriptor1.wait(posix::descriptor_base::wait_write, ec);
+
+ descriptor1.async_wait(posix::descriptor_base::wait_read, &wait_handler);
+ int i1 = descriptor1.async_wait(posix::descriptor_base::wait_write, lazy);
+ (void)i1;
+
+ // basic_stream_descriptor functions.
+
+ descriptor1.write_some(buffer(mutable_char_buffer));
+ descriptor1.write_some(buffer(const_char_buffer));
+ descriptor1.write_some(null_buffers());
+ descriptor1.write_some(buffer(mutable_char_buffer), ec);
+ descriptor1.write_some(buffer(const_char_buffer), ec);
+ descriptor1.write_some(null_buffers(), ec);
+
+ descriptor1.async_write_some(buffer(mutable_char_buffer),
+ write_some_handler);
+ descriptor1.async_write_some(buffer(const_char_buffer),
+ write_some_handler);
+ descriptor1.async_write_some(null_buffers(),
+ write_some_handler);
+ int i2 = descriptor1.async_write_some(buffer(mutable_char_buffer), lazy);
+ (void)i2;
+ int i3 = descriptor1.async_write_some(buffer(const_char_buffer), lazy);
+ (void)i3;
+ int i4 = descriptor1.async_write_some(null_buffers(), lazy);
+ (void)i4;
+
+ descriptor1.read_some(buffer(mutable_char_buffer));
+ descriptor1.read_some(buffer(mutable_char_buffer), ec);
+ descriptor1.read_some(null_buffers(), ec);
+
+ descriptor1.async_read_some(buffer(mutable_char_buffer), read_some_handler);
+ descriptor1.async_read_some(null_buffers(), read_some_handler);
+ int i5 = descriptor1.async_read_some(buffer(mutable_char_buffer), lazy);
+ (void)i5;
+ int i6 = descriptor1.async_read_some(null_buffers(), lazy);
+ (void)i6;
+ }
+ catch (std::exception&)
+ {
+ }
+#endif // defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR)
+}
+
+} // namespace posix_stream_descriptor_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "posix/stream_descriptor",
+ BOOST_ASIO_TEST_CASE(posix_stream_descriptor_compile::test)
+)
diff --git a/src/boost/libs/asio/test/post.cpp b/src/boost/libs/asio/test/post.cpp
new file mode 100644
index 000000000..f02680b45
--- /dev/null
+++ b/src/boost/libs/asio/test/post.cpp
@@ -0,0 +1,25 @@
+//
+// post.cpp
+// ~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/post.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "post",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/read.cpp b/src/boost/libs/asio/test/read.cpp
new file mode 100644
index 000000000..bd099c1c2
--- /dev/null
+++ b/src/boost/libs/asio/test/read.cpp
@@ -0,0 +1,4997 @@
+//
+// read.cpp
+// ~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/read.hpp>
+
+#include <cstring>
+#include <vector>
+#include "archetypes/async_result.hpp"
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/post.hpp>
+#include <boost/asio/streambuf.hpp>
+#include "unit_test.hpp"
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <boost/bind/bind.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <functional>
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+#include <boost/array.hpp>
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+
+#if defined(BOOST_ASIO_HAS_STD_ARRAY)
+# include <array>
+#endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
+
+using namespace std; // For memcmp, memcpy and memset.
+
+class test_stream
+{
+public:
+ typedef boost::asio::io_context::executor_type executor_type;
+
+ test_stream(boost::asio::io_context& io_context)
+ : io_context_(io_context),
+ length_(0),
+ position_(0),
+ next_read_length_(0)
+ {
+ }
+
+ executor_type get_executor() BOOST_ASIO_NOEXCEPT
+ {
+ return io_context_.get_executor();
+ }
+
+ void reset(const void* data, size_t length)
+ {
+ BOOST_ASIO_CHECK(length <= max_length);
+
+ memcpy(data_, data, length);
+ length_ = length;
+ position_ = 0;
+ next_read_length_ = length;
+ }
+
+ void next_read_length(size_t length)
+ {
+ next_read_length_ = length;
+ }
+
+ template <typename Iterator>
+ bool check_buffers(Iterator begin, Iterator end, size_t length)
+ {
+ if (length != position_)
+ return false;
+
+ Iterator iter = begin;
+ size_t checked_length = 0;
+ for (; iter != end && checked_length < length; ++iter)
+ {
+ size_t buffer_length = boost::asio::buffer_size(*iter);
+ if (buffer_length > length - checked_length)
+ buffer_length = length - checked_length;
+ if (memcmp(data_ + checked_length, iter->data(), buffer_length) != 0)
+ return false;
+ checked_length += buffer_length;
+ }
+
+ return true;
+ }
+
+ template <typename Const_Buffers>
+ bool check_buffers(const Const_Buffers& buffers, size_t length)
+ {
+ return check_buffers(boost::asio::buffer_sequence_begin(buffers),
+ boost::asio::buffer_sequence_end(buffers), length);
+ }
+
+ template <typename Mutable_Buffers>
+ size_t read_some(const Mutable_Buffers& buffers)
+ {
+ size_t n = boost::asio::buffer_copy(buffers,
+ boost::asio::buffer(data_, length_) + position_,
+ next_read_length_);
+ position_ += n;
+ return n;
+ }
+
+ template <typename Mutable_Buffers>
+ size_t read_some(const Mutable_Buffers& buffers,
+ boost::system::error_code& ec)
+ {
+ ec = boost::system::error_code();
+ return read_some(buffers);
+ }
+
+ template <typename Mutable_Buffers, typename Handler>
+ void async_read_some(const Mutable_Buffers& buffers,
+ BOOST_ASIO_MOVE_ARG(Handler) handler)
+ {
+ size_t bytes_transferred = read_some(buffers);
+ boost::asio::post(get_executor(),
+ boost::asio::detail::bind_handler(
+ BOOST_ASIO_MOVE_CAST(Handler)(handler),
+ boost::system::error_code(), bytes_transferred));
+ }
+
+private:
+ boost::asio::io_context& io_context_;
+ enum { max_length = 8192 };
+ char data_[max_length];
+ size_t length_;
+ size_t position_;
+ size_t next_read_length_;
+};
+
+static const char read_data[]
+ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+void test_2_arg_zero_buffers_read()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::vector<boost::asio::mutable_buffer> buffers;
+
+ size_t bytes_transferred = boost::asio::read(s, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == 0);
+}
+
+void test_2_arg_mutable_buffer_read()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ char read_buf[sizeof(read_data)];
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(read_buf, sizeof(read_buf));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ size_t bytes_transferred = boost::asio::read(s, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+}
+
+void test_2_arg_vector_buffers_read()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ char read_buf[sizeof(read_data)];
+ std::vector<boost::asio::mutable_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(read_buf, 32));
+ buffers.push_back(boost::asio::buffer(read_buf, 39) + 32);
+ buffers.push_back(boost::asio::buffer(read_buf) + 39);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ size_t bytes_transferred = boost::asio::read(s, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+}
+
+void test_2_arg_dynamic_string_read()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::string data;
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb
+ = boost::asio::dynamic_buffer(data, sizeof(read_data));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ size_t bytes_transferred = boost::asio::read(s, sb);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, sb);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, sb);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data)));
+}
+
+void test_2_arg_streambuf_read()
+{
+#if !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::streambuf sb(sizeof(read_data));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ size_t bytes_transferred = boost::asio::read(s, sb);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+#endif // !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+}
+
+void test_3_arg_nothrow_zero_buffers_read()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::vector<boost::asio::mutable_buffer> buffers;
+
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::read(s, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == 0);
+ BOOST_ASIO_CHECK(!error);
+}
+
+void test_3_arg_nothrow_mutable_buffer_read()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ char read_buf[sizeof(read_data)];
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(read_buf, sizeof(read_buf));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::read(s, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+void test_3_arg_nothrow_vector_buffers_read()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ char read_buf[sizeof(read_data)];
+ std::vector<boost::asio::mutable_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(read_buf, 32));
+ buffers.push_back(boost::asio::buffer(read_buf, 39) + 32);
+ buffers.push_back(boost::asio::buffer(read_buf) + 39);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::read(s, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+void test_3_arg_nothrow_dynamic_string_read()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::string data;
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb
+ = boost::asio::dynamic_buffer(data, sizeof(read_data));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::read(s, sb, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+void test_3_arg_nothrow_streambuf_read()
+{
+#if !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::streambuf sb(sizeof(read_data));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::read(s, sb, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+#endif // !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+}
+
+bool old_style_transfer_all(const boost::system::error_code& ec,
+ size_t /*bytes_transferred*/)
+{
+ return !!ec;
+}
+
+struct short_transfer
+{
+ short_transfer() {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ short_transfer(short_transfer&&) {}
+#else // defined(BOOST_ASIO_HAS_MOVE)
+ short_transfer(const short_transfer&) {}
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+ size_t operator()(const boost::system::error_code& ec,
+ size_t /*bytes_transferred*/)
+ {
+ return !!ec ? 0 : 3;
+ }
+};
+
+void test_3_arg_mutable_buffer_read()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ char read_buf[sizeof(read_data)];
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(read_buf, sizeof(read_buf));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ size_t bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, buffers, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, buffers, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+}
+
+void test_3_arg_vector_buffers_read()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ char read_buf[sizeof(read_data)];
+ std::vector<boost::asio::mutable_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(read_buf, 32));
+ buffers.push_back(boost::asio::buffer(read_buf, 39) + 32);
+ buffers.push_back(boost::asio::buffer(read_buf) + 39);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ size_t bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, buffers, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, buffers, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+}
+
+void test_3_arg_dynamic_string_read()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::string data;
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb
+ = boost::asio::dynamic_buffer(data, sizeof(read_data));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ size_t bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, sb,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, sb,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_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 = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_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 = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_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 = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(sb.size() == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 50));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_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 = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_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 = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_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 = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_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 = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_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 = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_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 = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, sb, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, sb, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, sb, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, sb, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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 = boost::asio::read(s, sb, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data)));
+}
+
+void test_3_arg_streambuf_read()
+{
+#if !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::streambuf sb(sizeof(read_data));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ size_t bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(sb.size() == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 50));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+#endif // !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+}
+
+void test_4_arg_mutable_buffer_read()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ char read_buf[sizeof(read_data)];
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(read_buf, sizeof(read_buf));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+void test_4_arg_vector_buffers_read()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ char read_buf[sizeof(read_data)];
+ std::vector<boost::asio::mutable_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(read_buf, 32));
+ buffers.push_back(boost::asio::buffer(read_buf, 39) + 32);
+ buffers.push_back(boost::asio::buffer(read_buf) + 39);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read(s, buffers, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, buffers, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+void test_4_arg_dynamic_string_read()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::string data;
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb
+ = boost::asio::dynamic_buffer(data, sizeof(read_data));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(sb.size() == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 50));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+void test_4_arg_streambuf_read()
+{
+#if !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::streambuf sb(sizeof(read_data));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(sb.size() == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 50));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read(s, sb, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read(s, sb, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+#endif // !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+}
+
+void async_read_handler(const boost::system::error_code& e,
+ size_t bytes_transferred, size_t expected_bytes_transferred, bool* called)
+{
+ *called = true;
+ BOOST_ASIO_CHECK(!e);
+ BOOST_ASIO_CHECK(bytes_transferred == expected_bytes_transferred);
+}
+
+void test_3_arg_mutable_buffer_async_read()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ char read_buf[sizeof(read_data)];
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(read_buf, sizeof(read_buf));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bool called = false;
+ boost::asio::async_read(s, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read(s, buffers, archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+}
+
+void test_3_arg_boost_array_buffers_async_read()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ char read_buf[sizeof(read_data)];
+ boost::array<boost::asio::mutable_buffer, 2> buffers = { {
+ boost::asio::buffer(read_buf, 32),
+ boost::asio::buffer(read_buf) + 32 } };
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bool called = false;
+ boost::asio::async_read(s, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read(s, buffers, archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+}
+
+void test_3_arg_std_array_buffers_async_read()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+#if defined(BOOST_ASIO_HAS_STD_ARRAY)
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ char read_buf[sizeof(read_data)];
+ std::array<boost::asio::mutable_buffer, 2> buffers = { {
+ boost::asio::buffer(read_buf, 32),
+ boost::asio::buffer(read_buf) + 32 } };
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bool called = false;
+ boost::asio::async_read(s, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read(s, buffers, archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+#endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
+}
+
+void test_3_arg_vector_buffers_async_read()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ char read_buf[sizeof(read_data)];
+ std::vector<boost::asio::mutable_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(read_buf, 32));
+ buffers.push_back(boost::asio::buffer(read_buf, 39) + 32);
+ buffers.push_back(boost::asio::buffer(read_buf) + 39);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bool called = false;
+ boost::asio::async_read(s, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read(s, buffers, archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+}
+
+void test_3_arg_dynamic_string_async_read()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::string data;
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb
+ = boost::asio::dynamic_buffer(data, sizeof(read_data));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bool called = false;
+ boost::asio::async_read(s, sb,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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;
+ boost::asio::async_read(s, sb,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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;
+ boost::asio::async_read(s, sb,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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 = boost::asio::async_read(s, sb, archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data)));
+}
+
+void test_3_arg_streambuf_async_read()
+{
+#if !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::streambuf sb(sizeof(read_data));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bool called = false;
+ boost::asio::async_read(s, sb,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ int i = boost::asio::async_read(s, sb, archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+#endif // !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+}
+
+void test_4_arg_mutable_buffer_async_read()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ char read_buf[sizeof(read_data)];
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(read_buf, sizeof(read_buf));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bool called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read(s, buffers,
+ short_transfer(), archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+}
+
+void test_4_arg_boost_array_buffers_async_read()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ char read_buf[sizeof(read_data)];
+ boost::array<boost::asio::mutable_buffer, 2> buffers = { {
+ boost::asio::buffer(read_buf, 32),
+ boost::asio::buffer(read_buf) + 32 } };
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bool called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read(s, buffers,
+ short_transfer(), archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+}
+
+void test_4_arg_std_array_buffers_async_read()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+#if defined(BOOST_ASIO_HAS_STD_ARRAY)
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ char read_buf[sizeof(read_data)];
+ std::array<boost::asio::mutable_buffer, 2> buffers = { {
+ boost::asio::buffer(read_buf, 32),
+ boost::asio::buffer(read_buf) + 32 } };
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bool called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read(s, buffers,
+ short_transfer(), archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+#endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
+}
+
+void test_4_arg_vector_buffers_async_read()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ char read_buf[sizeof(read_data)];
+ std::vector<boost::asio::mutable_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(read_buf, 32));
+ buffers.push_back(boost::asio::buffer(read_buf, 39) + 32);
+ buffers.push_back(boost::asio::buffer(read_buf) + 39);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bool called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read(s, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read(s, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read(s, buffers,
+ short_transfer(), archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+}
+
+void test_4_arg_dynamic_string_async_read()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::string data;
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb
+ = boost::asio::dynamic_buffer(data, sizeof(read_data));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bool called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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;
+ boost::asio::async_read(s, sb, boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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;
+ boost::asio::async_read(s, sb, boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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;
+ boost::asio::async_read(s, sb, boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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;
+ boost::asio::async_read(s, sb, boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_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;
+ boost::asio::async_read(s, sb, boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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;
+ boost::asio::async_read(s, sb, boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_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;
+ boost::asio::async_read(s, sb, boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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;
+ boost::asio::async_read(s, sb, boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_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;
+ boost::asio::async_read(s, sb, boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 50));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_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;
+ boost::asio::async_read(s, sb, boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_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;
+ boost::asio::async_read(s, sb, boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_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;
+ boost::asio::async_read(s, sb, boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_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;
+ boost::asio::async_read(s, sb, boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_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;
+ boost::asio::async_read(s, sb, boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_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;
+ boost::asio::async_read(s, sb, boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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;
+ boost::asio::async_read(s, sb, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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;
+ boost::asio::async_read(s, sb, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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;
+ boost::asio::async_read(s, sb, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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;
+ boost::asio::async_read(s, sb, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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;
+ boost::asio::async_read(s, sb, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_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 = boost::asio::async_read(s, sb,
+ short_transfer(), archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(0, sb.size()), sizeof(read_data)));
+}
+
+void test_4_arg_streambuf_async_read()
+{
+#if !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::streambuf sb(sizeof(read_data));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bool called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 50));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read(s, sb, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ int i = boost::asio::async_read(s, sb,
+ short_transfer(), archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+#endif // !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+}
+
+BOOST_ASIO_TEST_SUITE
+(
+ "read",
+ BOOST_ASIO_TEST_CASE(test_2_arg_zero_buffers_read)
+ BOOST_ASIO_TEST_CASE(test_2_arg_mutable_buffer_read)
+ BOOST_ASIO_TEST_CASE(test_2_arg_vector_buffers_read)
+ BOOST_ASIO_TEST_CASE(test_2_arg_dynamic_string_read)
+ BOOST_ASIO_TEST_CASE(test_2_arg_streambuf_read)
+ BOOST_ASIO_TEST_CASE(test_3_arg_nothrow_zero_buffers_read)
+ BOOST_ASIO_TEST_CASE(test_3_arg_nothrow_mutable_buffer_read)
+ BOOST_ASIO_TEST_CASE(test_3_arg_nothrow_vector_buffers_read)
+ BOOST_ASIO_TEST_CASE(test_3_arg_nothrow_dynamic_string_read)
+ BOOST_ASIO_TEST_CASE(test_3_arg_nothrow_streambuf_read)
+ BOOST_ASIO_TEST_CASE(test_3_arg_mutable_buffer_read)
+ BOOST_ASIO_TEST_CASE(test_3_arg_vector_buffers_read)
+ BOOST_ASIO_TEST_CASE(test_3_arg_dynamic_string_read)
+ BOOST_ASIO_TEST_CASE(test_3_arg_streambuf_read)
+ BOOST_ASIO_TEST_CASE(test_4_arg_mutable_buffer_read)
+ BOOST_ASIO_TEST_CASE(test_4_arg_vector_buffers_read)
+ BOOST_ASIO_TEST_CASE(test_4_arg_dynamic_string_read)
+ BOOST_ASIO_TEST_CASE(test_4_arg_streambuf_read)
+ BOOST_ASIO_TEST_CASE(test_3_arg_mutable_buffer_async_read)
+ BOOST_ASIO_TEST_CASE(test_3_arg_boost_array_buffers_async_read)
+ BOOST_ASIO_TEST_CASE(test_3_arg_std_array_buffers_async_read)
+ BOOST_ASIO_TEST_CASE(test_3_arg_vector_buffers_async_read)
+ BOOST_ASIO_TEST_CASE(test_3_arg_dynamic_string_async_read)
+ BOOST_ASIO_TEST_CASE(test_3_arg_streambuf_async_read)
+ BOOST_ASIO_TEST_CASE(test_4_arg_mutable_buffer_async_read)
+ BOOST_ASIO_TEST_CASE(test_4_arg_vector_buffers_async_read)
+ BOOST_ASIO_TEST_CASE(test_4_arg_boost_array_buffers_async_read)
+ BOOST_ASIO_TEST_CASE(test_4_arg_std_array_buffers_async_read)
+ BOOST_ASIO_TEST_CASE(test_4_arg_dynamic_string_async_read)
+ BOOST_ASIO_TEST_CASE(test_4_arg_streambuf_async_read)
+)
diff --git a/src/boost/libs/asio/test/read_at.cpp b/src/boost/libs/asio/test/read_at.cpp
new file mode 100644
index 000000000..2d8abe239
--- /dev/null
+++ b/src/boost/libs/asio/test/read_at.cpp
@@ -0,0 +1,7502 @@
+//
+// read_at.cpp
+// ~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/read_at.hpp>
+
+#include <cstring>
+#include "archetypes/async_result.hpp"
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/post.hpp>
+#include <boost/asio/streambuf.hpp>
+#include "unit_test.hpp"
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <boost/bind/bind.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <functional>
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+#include <boost/array.hpp>
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+
+#if defined(BOOST_ASIO_HAS_STD_ARRAY)
+# include <array>
+#endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
+
+using namespace std; // For memcmp, memcpy and memset.
+
+class test_random_access_device
+{
+public:
+ typedef boost::asio::io_context::executor_type executor_type;
+
+ test_random_access_device(boost::asio::io_context& io_context)
+ : io_context_(io_context),
+ length_(0),
+ next_read_length_(0)
+ {
+ }
+
+ executor_type get_executor() BOOST_ASIO_NOEXCEPT
+ {
+ return io_context_.get_executor();
+ }
+
+ void reset(const void* data, size_t length)
+ {
+ BOOST_ASIO_CHECK(length <= max_length);
+
+ length_ = 0;
+ while (length_ + length < max_length)
+ {
+ memcpy(data_ + length_, data, length);
+ length_ += length;
+ }
+
+ next_read_length_ = length;
+ }
+
+ void next_read_length(size_t length)
+ {
+ next_read_length_ = length;
+ }
+
+ template <typename Iterator>
+ bool check_buffers(boost::asio::uint64_t offset,
+ Iterator begin, Iterator end, size_t length)
+ {
+ if (offset + length > max_length)
+ return false;
+
+ Iterator iter = begin;
+ size_t checked_length = 0;
+ for (; iter != end && checked_length < length; ++iter)
+ {
+ size_t buffer_length = boost::asio::buffer_size(*iter);
+ if (buffer_length > length - checked_length)
+ buffer_length = length - checked_length;
+ if (memcmp(data_ + offset + checked_length,
+ iter->data(), buffer_length) != 0)
+ return false;
+ checked_length += buffer_length;
+ }
+
+ return true;
+ }
+
+ template <typename Const_Buffers>
+ bool check_buffers(boost::asio::uint64_t offset,
+ const Const_Buffers& buffers, size_t length)
+ {
+ return check_buffers(offset, boost::asio::buffer_sequence_begin(buffers),
+ boost::asio::buffer_sequence_end(buffers), length);
+ }
+
+ template <typename Mutable_Buffers>
+ size_t read_some_at(boost::asio::uint64_t offset,
+ const Mutable_Buffers& buffers)
+ {
+ return boost::asio::buffer_copy(buffers,
+ boost::asio::buffer(data_, length_) + offset,
+ next_read_length_);
+ }
+
+ template <typename Mutable_Buffers>
+ size_t read_some_at(boost::asio::uint64_t offset,
+ const Mutable_Buffers& buffers, boost::system::error_code& ec)
+ {
+ ec = boost::system::error_code();
+ return read_some_at(offset, buffers);
+ }
+
+ template <typename Mutable_Buffers, typename Handler>
+ void async_read_some_at(boost::asio::uint64_t offset,
+ const Mutable_Buffers& buffers, BOOST_ASIO_MOVE_ARG(Handler) handler)
+ {
+ size_t bytes_transferred = read_some_at(offset, buffers);
+ boost::asio::post(get_executor(),
+ boost::asio::detail::bind_handler(
+ BOOST_ASIO_MOVE_CAST(Handler)(handler),
+ boost::system::error_code(), bytes_transferred));
+ }
+
+private:
+ boost::asio::io_context& io_context_;
+ enum { max_length = 8192 };
+ char data_[max_length];
+ size_t length_;
+ size_t next_read_length_;
+};
+
+static const char read_data[]
+ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+void test_3_arg_mutable_buffer_read_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ char read_buf[sizeof(read_data)];
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(read_buf, sizeof(read_buf));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ size_t bytes_transferred = boost::asio::read_at(s, 0, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 0, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 0, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+}
+
+void test_3_arg_vector_buffers_read_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ char read_buf[sizeof(read_data)];
+ std::vector<boost::asio::mutable_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(read_buf, 32));
+ buffers.push_back(boost::asio::buffer(read_buf) + 32);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ size_t bytes_transferred = boost::asio::read_at(s, 0, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 0, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 0, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+}
+
+void test_3_arg_streambuf_read_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ boost::asio::streambuf sb(sizeof(read_data));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ size_t bytes_transferred = boost::asio::read_at(s, 0, sb);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+}
+
+void test_4_arg_nothrow_mutable_buffer_read_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ char read_buf[sizeof(read_data)];
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(read_buf, sizeof(read_buf));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::read_at(s, 0, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+void test_4_arg_nothrow_vector_buffers_read_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ char read_buf[sizeof(read_data)];
+ std::vector<boost::asio::mutable_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(read_buf, 32));
+ buffers.push_back(boost::asio::buffer(read_buf) + 32);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::read_at(s, 0, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+void test_4_arg_nothrow_streambuf_read_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ boost::asio::streambuf sb(sizeof(read_data));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::read_at(s, 0, sb, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+bool old_style_transfer_all(const boost::system::error_code& ec,
+ size_t /*bytes_transferred*/)
+{
+ return !!ec;
+}
+
+struct short_transfer
+{
+ short_transfer() {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ short_transfer(short_transfer&&) {}
+#else // defined(BOOST_ASIO_HAS_MOVE)
+ short_transfer(const short_transfer&) {}
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+ size_t operator()(const boost::system::error_code& ec,
+ size_t /*bytes_transferred*/)
+ {
+ return !!ec ? 0 : 3;
+ }
+};
+
+void test_4_arg_mutable_buffer_read_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ char read_buf[sizeof(read_data)];
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(read_buf, sizeof(read_buf));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ size_t bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 50));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 50));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 0, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 0, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 0, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 0, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+}
+
+void test_4_arg_vector_buffers_read_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ char read_buf[sizeof(read_data)];
+ std::vector<boost::asio::mutable_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(read_buf, 32));
+ buffers.push_back(boost::asio::buffer(read_buf) + 32);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ size_t bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 50));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 50));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 0, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 0, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 0, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 0, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_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 = boost::asio::read_at(s, 1234, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+}
+
+void test_4_arg_streambuf_read_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ boost::asio::streambuf sb(sizeof(read_data));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ size_t bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(sb.size() == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 50));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(sb.size() == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 50));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+}
+
+void test_5_arg_mutable_buffer_read_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ char read_buf[sizeof(read_data)];
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(read_buf, sizeof(read_buf));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 50));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 50));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+void test_5_arg_vector_buffers_read_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ char read_buf[sizeof(read_data)];
+ std::vector<boost::asio::mutable_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(read_buf, 32));
+ buffers.push_back(boost::asio::buffer(read_buf) + 32);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 50));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 50));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+void test_5_arg_streambuf_read_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ boost::asio::streambuf sb(sizeof(read_data));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(sb.size() == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 50));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(sb.size() == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 50));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 0, sb,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::read_at(s, 1234, sb,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(read_data));
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+void async_read_handler(const boost::system::error_code& e,
+ size_t bytes_transferred, size_t expected_bytes_transferred, bool* called)
+{
+ *called = true;
+ BOOST_ASIO_CHECK(!e);
+ BOOST_ASIO_CHECK(bytes_transferred == expected_bytes_transferred);
+}
+
+void test_4_arg_mutable_buffer_async_read_at()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ char read_buf[sizeof(read_data)];
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(read_buf, sizeof(read_buf));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bool called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read_at(s, 1234, buffers,
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+}
+
+void test_4_arg_boost_array_buffers_async_read_at()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ char read_buf[sizeof(read_data)];
+ boost::array<boost::asio::mutable_buffer, 2> buffers = { {
+ boost::asio::buffer(read_buf, 32),
+ boost::asio::buffer(read_buf) + 32 } };
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bool called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read_at(s, 1234, buffers,
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+}
+
+void test_4_arg_std_array_buffers_async_read_at()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+#if defined(BOOST_ASIO_HAS_STD_ARRAY)
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ char read_buf[sizeof(read_data)];
+ std::array<boost::asio::mutable_buffer, 2> buffers = { {
+ boost::asio::buffer(read_buf, 32),
+ boost::asio::buffer(read_buf) + 32 } };
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bool called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read_at(s, 1234, buffers,
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+#endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
+}
+
+void test_4_arg_vector_buffers_async_read_at()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ char read_buf[sizeof(read_data)];
+ std::vector<boost::asio::mutable_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(read_buf, 32));
+ buffers.push_back(boost::asio::buffer(read_buf) + 32);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bool called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read_at(s, 1234, buffers,
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+}
+
+void test_4_arg_streambuf_async_read_at()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ boost::asio::streambuf sb(sizeof(read_data));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bool called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ int i = boost::asio::async_read_at(s, 1234, sb,
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+}
+
+void test_5_arg_mutable_buffer_async_read_at()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ char read_buf[sizeof(read_data)];
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(read_buf, sizeof(read_buf));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bool called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 50));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 50));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read_at(s, 1234, buffers,
+ short_transfer(), archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+}
+
+void test_5_arg_boost_array_buffers_async_read_at()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ char read_buf[sizeof(read_data)];
+ boost::array<boost::asio::mutable_buffer, 2> buffers = { {
+ boost::asio::buffer(read_buf, 32),
+ boost::asio::buffer(read_buf) + 32 } };
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bool called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 50));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 50));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read_at(s, 1234, buffers,
+ short_transfer(), archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+}
+
+void test_5_arg_std_array_buffers_async_read_at()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+#if defined(BOOST_ASIO_HAS_STD_ARRAY)
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ char read_buf[sizeof(read_data)];
+ std::array<boost::asio::mutable_buffer, 2> buffers = { {
+ boost::asio::buffer(read_buf, 32),
+ boost::asio::buffer(read_buf) + 32 } };
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bool called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 50));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 50));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read_at(s, 1234, buffers,
+ short_transfer(), archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+#endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
+}
+
+void test_5_arg_vector_buffers_async_read_at()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ char read_buf[sizeof(read_data)];
+ std::vector<boost::asio::mutable_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(read_buf, 32));
+ buffers.push_back(boost::asio::buffer(read_buf) + 32);
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ bool called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 50));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 50));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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));
+ called = false;
+ boost::asio::async_read_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read_at(s, 1234, buffers,
+ short_transfer(), archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+}
+
+void test_5_arg_streambuf_async_read_at()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ boost::asio::streambuf sb(sizeof(read_data));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ bool called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ boost::asio::transfer_all(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 50));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 50));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_read_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 1));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_read_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 10));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_read_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), 42));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb, old_style_transfer_all,
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 0, sb, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb.consume(sb.size());
+ called = false;
+ boost::asio::async_read_at(s, 1234, sb, short_transfer(),
+ bindns::bind(async_read_handler,
+ _1, _2, sizeof(read_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(sb.size() == sizeof(read_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ int i = boost::asio::async_read_at(s, 1234, sb,
+ short_transfer(), archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+}
+
+BOOST_ASIO_TEST_SUITE
+(
+ "read_at",
+ BOOST_ASIO_TEST_CASE(test_3_arg_mutable_buffer_read_at)
+ BOOST_ASIO_TEST_CASE(test_3_arg_vector_buffers_read_at)
+ BOOST_ASIO_TEST_CASE(test_3_arg_streambuf_read_at)
+ BOOST_ASIO_TEST_CASE(test_4_arg_nothrow_mutable_buffer_read_at)
+ BOOST_ASIO_TEST_CASE(test_4_arg_nothrow_vector_buffers_read_at)
+ BOOST_ASIO_TEST_CASE(test_4_arg_nothrow_streambuf_read_at)
+ BOOST_ASIO_TEST_CASE(test_4_arg_mutable_buffer_read_at)
+ BOOST_ASIO_TEST_CASE(test_4_arg_vector_buffers_read_at)
+ BOOST_ASIO_TEST_CASE(test_4_arg_streambuf_read_at)
+ BOOST_ASIO_TEST_CASE(test_5_arg_mutable_buffer_read_at)
+ BOOST_ASIO_TEST_CASE(test_5_arg_vector_buffers_read_at)
+ BOOST_ASIO_TEST_CASE(test_5_arg_streambuf_read_at)
+ BOOST_ASIO_TEST_CASE(test_4_arg_mutable_buffer_async_read_at)
+ BOOST_ASIO_TEST_CASE(test_4_arg_boost_array_buffers_async_read_at)
+ BOOST_ASIO_TEST_CASE(test_4_arg_std_array_buffers_async_read_at)
+ BOOST_ASIO_TEST_CASE(test_4_arg_vector_buffers_async_read_at)
+ BOOST_ASIO_TEST_CASE(test_4_arg_streambuf_async_read_at)
+ BOOST_ASIO_TEST_CASE(test_5_arg_mutable_buffer_async_read_at)
+ BOOST_ASIO_TEST_CASE(test_5_arg_boost_array_buffers_async_read_at)
+ BOOST_ASIO_TEST_CASE(test_5_arg_std_array_buffers_async_read_at)
+ BOOST_ASIO_TEST_CASE(test_5_arg_vector_buffers_async_read_at)
+ BOOST_ASIO_TEST_CASE(test_5_arg_streambuf_async_read_at)
+)
diff --git a/src/boost/libs/asio/test/read_until.cpp b/src/boost/libs/asio/test/read_until.cpp
new file mode 100644
index 000000000..78d3d38e9
--- /dev/null
+++ b/src/boost/libs/asio/test/read_until.cpp
@@ -0,0 +1,1660 @@
+//
+// read_until.cpp
+// ~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/read_until.hpp>
+
+#include <cstring>
+#include "archetypes/async_result.hpp"
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/post.hpp>
+#include <boost/asio/streambuf.hpp>
+#include "unit_test.hpp"
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <boost/bind/bind.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <functional>
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+
+class test_stream
+{
+public:
+ typedef boost::asio::io_context::executor_type executor_type;
+
+ test_stream(boost::asio::io_context& io_context)
+ : io_context_(io_context),
+ length_(0),
+ position_(0),
+ next_read_length_(0)
+ {
+ }
+
+ executor_type get_executor() BOOST_ASIO_NOEXCEPT
+ {
+ return io_context_.get_executor();
+ }
+
+ void reset(const void* data, size_t length)
+ {
+ using namespace std; // For memcpy.
+
+ BOOST_ASIO_CHECK(length <= max_length);
+
+ memcpy(data_, data, length);
+ length_ = length;
+ position_ = 0;
+ next_read_length_ = length;
+ }
+
+ void next_read_length(size_t length)
+ {
+ next_read_length_ = length;
+ }
+
+ template <typename Mutable_Buffers>
+ size_t read_some(const Mutable_Buffers& buffers)
+ {
+ size_t n = boost::asio::buffer_copy(buffers,
+ boost::asio::buffer(data_, length_) + position_,
+ next_read_length_);
+ position_ += n;
+ return n;
+ }
+
+ template <typename Mutable_Buffers>
+ size_t read_some(const Mutable_Buffers& buffers,
+ boost::system::error_code& ec)
+ {
+ ec = boost::system::error_code();
+ return read_some(buffers);
+ }
+
+ template <typename Mutable_Buffers, typename Handler>
+ void async_read_some(const Mutable_Buffers& buffers, Handler handler)
+ {
+ size_t bytes_transferred = read_some(buffers);
+ boost::asio::post(get_executor(),
+ boost::asio::detail::bind_handler(
+ BOOST_ASIO_MOVE_CAST(Handler)(handler),
+ boost::system::error_code(), bytes_transferred));
+ }
+
+private:
+ boost::asio::io_context& io_context_;
+ enum { max_length = 8192 };
+ char data_[max_length];
+ size_t length_;
+ size_t position_;
+ size_t next_read_length_;
+};
+
+static const char read_data[]
+ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+void test_dynamic_string_read_until_char()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::string data1, data2;
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb1 = boost::asio::dynamic_buffer(data1);
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb2 = boost::asio::dynamic_buffer(data2, 25);
+ boost::system::error_code ec;
+
+ s.reset(read_data, sizeof(read_data));
+ sb1.consume(sb1.size());
+ std::size_t length = boost::asio::read_until(s, sb1, 'Z');
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, 'Z');
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, 'Z');
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, 'Z', ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, 'Z', ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, 'Z', ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, 'Z', ec);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, 'Z', ec);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, 'Z', ec);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, 'Y', ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, 'Y', ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, 'Y', ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+}
+
+void test_streambuf_read_until_char()
+{
+#if !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::streambuf sb1;
+ boost::asio::streambuf sb2(25);
+ boost::system::error_code ec;
+
+ s.reset(read_data, sizeof(read_data));
+ sb1.consume(sb1.size());
+ std::size_t length = boost::asio::read_until(s, sb1, 'Z');
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, 'Z');
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, 'Z');
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, 'Z', ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, 'Z', ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, 'Z', ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, 'Z', ec);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, 'Z', ec);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, 'Z', ec);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, 'Y', ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, 'Y', ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, 'Y', ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+#endif // !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+}
+
+void test_dynamic_string_read_until_string()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::string data1, data2;
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb1 = boost::asio::dynamic_buffer(data1);
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb2 = boost::asio::dynamic_buffer(data2, 25);
+ boost::system::error_code ec;
+
+ s.reset(read_data, sizeof(read_data));
+ sb1.consume(sb1.size());
+ std::size_t length = boost::asio::read_until(s, sb1, "XYZ");
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, "XYZ");
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, "XYZ");
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, "XYZ", ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, "XYZ", ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, "XYZ", ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, "XYZ", ec);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, "XYZ", ec);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, "XYZ", ec);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, "WXY", ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, "WXY", ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, "WXY", ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+}
+
+void test_streambuf_read_until_string()
+{
+#if !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::streambuf sb1;
+ boost::asio::streambuf sb2(25);
+ boost::system::error_code ec;
+
+ s.reset(read_data, sizeof(read_data));
+ sb1.consume(sb1.size());
+ std::size_t length = boost::asio::read_until(s, sb1, "XYZ");
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, "XYZ");
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, "XYZ");
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, "XYZ", ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, "XYZ", ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, "XYZ", ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, "XYZ", ec);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, "XYZ", ec);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, "XYZ", ec);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, "WXY", ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, "WXY", ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, "WXY", ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+#endif // !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+}
+
+class match_char
+{
+public:
+ explicit match_char(char c) : c_(c) {}
+
+ template <typename Iterator>
+ std::pair<Iterator, bool> operator()(
+ Iterator begin, Iterator end) const
+ {
+ Iterator i = begin;
+ while (i != end)
+ if (c_ == *i++)
+ return std::make_pair(i, true);
+ return std::make_pair(i, false);
+ }
+
+private:
+ char c_;
+};
+
+namespace boost {
+namespace asio {
+ template <> struct is_match_condition<match_char>
+ {
+ enum { value = true };
+ };
+} // namespace asio
+} // namespace boost
+
+void test_dynamic_string_read_until_match_condition()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::string data1, data2;
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb1 = boost::asio::dynamic_buffer(data1);
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb2 = boost::asio::dynamic_buffer(data2, 25);
+ boost::system::error_code ec;
+
+ s.reset(read_data, sizeof(read_data));
+ sb1.consume(sb1.size());
+ std::size_t length = boost::asio::read_until(s, sb1, match_char('Z'));
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, match_char('Z'));
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, match_char('Z'));
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, match_char('Z'), ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, match_char('Z'), ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, match_char('Z'), ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, match_char('Z'), ec);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, match_char('Z'), ec);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, match_char('Z'), ec);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, match_char('Y'), ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, match_char('Y'), ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, match_char('Y'), ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+}
+
+void test_streambuf_read_until_match_condition()
+{
+#if !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::streambuf sb1;
+ boost::asio::streambuf sb2(25);
+ boost::system::error_code ec;
+
+ s.reset(read_data, sizeof(read_data));
+ sb1.consume(sb1.size());
+ std::size_t length = boost::asio::read_until(s, sb1, match_char('Z'));
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, match_char('Z'));
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, match_char('Z'));
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, match_char('Z'), ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, match_char('Z'), ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb1.consume(sb1.size());
+ length = boost::asio::read_until(s, sb1, match_char('Z'), ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, match_char('Z'), ec);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, match_char('Z'), ec);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, match_char('Z'), ec);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, match_char('Y'), ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, match_char('Y'), ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ sb2.consume(sb2.size());
+ length = boost::asio::read_until(s, sb2, match_char('Y'), ec);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+#endif // !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+}
+
+void async_read_handler(
+ const boost::system::error_code& err, boost::system::error_code* err_out,
+ std::size_t bytes_transferred, std::size_t* bytes_out, bool* called)
+{
+ *err_out = err;
+ *bytes_out = bytes_transferred;
+ *called = true;
+}
+
+void test_dynamic_string_async_read_until_char()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::string data1, data2;
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb1 = boost::asio::dynamic_buffer(data1);
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb2 = boost::asio::dynamic_buffer(data2, 25);
+ boost::system::error_code ec;
+ std::size_t length;
+ bool called;
+
+ s.reset(read_data, sizeof(read_data));
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb1.consume(sb1.size());
+ boost::asio::async_read_until(s, sb1, 'Z',
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb1.consume(sb1.size());
+ boost::asio::async_read_until(s, sb1, 'Z',
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb1.consume(sb1.size());
+ boost::asio::async_read_until(s, sb1, 'Z',
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, 'Z',
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, 'Z',
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, 'Z',
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, 'Y',
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, 'Y',
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, 'Y',
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ sb2.consume(sb2.size());
+ int i = boost::asio::async_read_until(s, sb2, 'Y',
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+}
+
+void test_streambuf_async_read_until_char()
+{
+#if !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::streambuf sb1;
+ boost::asio::streambuf sb2(25);
+ boost::system::error_code ec;
+ std::size_t length;
+ bool called;
+
+ s.reset(read_data, sizeof(read_data));
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb1.consume(sb1.size());
+ boost::asio::async_read_until(s, sb1, 'Z',
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb1.consume(sb1.size());
+ boost::asio::async_read_until(s, sb1, 'Z',
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb1.consume(sb1.size());
+ boost::asio::async_read_until(s, sb1, 'Z',
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, 'Z',
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, 'Z',
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, 'Z',
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, 'Y',
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, 'Y',
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, 'Y',
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ sb2.consume(sb2.size());
+ int i = boost::asio::async_read_until(s, sb2, 'Y',
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+#endif // !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+}
+
+void test_dynamic_string_async_read_until_string()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::string data1, data2;
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb1 = boost::asio::dynamic_buffer(data1);
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb2 = boost::asio::dynamic_buffer(data2, 25);
+ boost::system::error_code ec;
+ std::size_t length;
+ bool called;
+
+ s.reset(read_data, sizeof(read_data));
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb1.consume(sb1.size());
+ boost::asio::async_read_until(s, sb1, "XYZ",
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb1.consume(sb1.size());
+ boost::asio::async_read_until(s, sb1, "XYZ",
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb1.consume(sb1.size());
+ boost::asio::async_read_until(s, sb1, "XYZ",
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, "XYZ",
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, "XYZ",
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, "XYZ",
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, "WXY",
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, "WXY",
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, "WXY",
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ sb2.consume(sb2.size());
+ int i = boost::asio::async_read_until(s, sb2, "WXY",
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+}
+
+void test_streambuf_async_read_until_string()
+{
+#if !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::streambuf sb1;
+ boost::asio::streambuf sb2(25);
+ boost::system::error_code ec;
+ std::size_t length;
+ bool called;
+
+ s.reset(read_data, sizeof(read_data));
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb1.consume(sb1.size());
+ boost::asio::async_read_until(s, sb1, "XYZ",
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb1.consume(sb1.size());
+ boost::asio::async_read_until(s, sb1, "XYZ",
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb1.consume(sb1.size());
+ boost::asio::async_read_until(s, sb1, "XYZ",
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, "XYZ",
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, "XYZ",
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, "XYZ",
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, "WXY",
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, "WXY",
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, "WXY",
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ sb2.consume(sb2.size());
+ int i = boost::asio::async_read_until(s, sb2, "WXY",
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+#endif // !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+}
+
+void test_dynamic_string_async_read_until_match_condition()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::string data1, data2;
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb1 = boost::asio::dynamic_buffer(data1);
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb2 = boost::asio::dynamic_buffer(data2, 25);
+ boost::system::error_code ec;
+ std::size_t length;
+ bool called;
+
+ s.reset(read_data, sizeof(read_data));
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb1.consume(sb1.size());
+ boost::asio::async_read_until(s, sb1, match_char('Z'),
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb1.consume(sb1.size());
+ boost::asio::async_read_until(s, sb1, match_char('Z'),
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb1.consume(sb1.size());
+ boost::asio::async_read_until(s, sb1, match_char('Z'),
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, match_char('Z'),
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, match_char('Z'),
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, match_char('Z'),
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, match_char('Y'),
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, match_char('Y'),
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, match_char('Y'),
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ sb2.consume(sb2.size());
+ int i = boost::asio::async_read_until(s, sb2, match_char('Y'),
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+}
+
+void test_streambuf_async_read_until_match_condition()
+{
+#if !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::streambuf sb1;
+ boost::asio::streambuf sb2(25);
+ boost::system::error_code ec;
+ std::size_t length;
+ bool called;
+
+ s.reset(read_data, sizeof(read_data));
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb1.consume(sb1.size());
+ boost::asio::async_read_until(s, sb1, match_char('Z'),
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb1.consume(sb1.size());
+ boost::asio::async_read_until(s, sb1, match_char('Z'),
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb1.consume(sb1.size());
+ boost::asio::async_read_until(s, sb1, match_char('Z'),
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 26);
+
+ s.reset(read_data, sizeof(read_data));
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, match_char('Z'),
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, match_char('Z'),
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, match_char('Z'),
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(ec == boost::asio::error::not_found);
+ BOOST_ASIO_CHECK(length == 0);
+
+ s.reset(read_data, sizeof(read_data));
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, match_char('Y'),
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(1);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, match_char('Y'),
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ s.next_read_length(10);
+ ec = boost::system::error_code();
+ length = 0;
+ called = false;
+ sb2.consume(sb2.size());
+ boost::asio::async_read_until(s, sb2, match_char('Y'),
+ bindns::bind(async_read_handler, _1, &ec,
+ _2, &length, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(!ec);
+ BOOST_ASIO_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ sb2.consume(sb2.size());
+ int i = boost::asio::async_read_until(s, sb2, match_char('Y'),
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+#endif // !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+}
+
+BOOST_ASIO_TEST_SUITE
+(
+ "read_until",
+ BOOST_ASIO_TEST_CASE(test_dynamic_string_read_until_char)
+ BOOST_ASIO_TEST_CASE(test_streambuf_read_until_char)
+ BOOST_ASIO_TEST_CASE(test_dynamic_string_read_until_string)
+ BOOST_ASIO_TEST_CASE(test_streambuf_read_until_string)
+ BOOST_ASIO_TEST_CASE(test_dynamic_string_read_until_match_condition)
+ BOOST_ASIO_TEST_CASE(test_streambuf_read_until_match_condition)
+ BOOST_ASIO_TEST_CASE(test_dynamic_string_async_read_until_char)
+ BOOST_ASIO_TEST_CASE(test_streambuf_async_read_until_char)
+ BOOST_ASIO_TEST_CASE(test_dynamic_string_async_read_until_string)
+ BOOST_ASIO_TEST_CASE(test_streambuf_async_read_until_string)
+ BOOST_ASIO_TEST_CASE(test_dynamic_string_async_read_until_match_condition)
+ BOOST_ASIO_TEST_CASE(test_streambuf_async_read_until_match_condition)
+)
diff --git a/src/boost/libs/asio/test/redirect_error.cpp b/src/boost/libs/asio/test/redirect_error.cpp
new file mode 100644
index 000000000..2cbcfcbcc
--- /dev/null
+++ b/src/boost/libs/asio/test/redirect_error.cpp
@@ -0,0 +1,25 @@
+//
+// redirect_error.cpp
+// ~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/redirect_error.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "redirect_error",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/serial_port.cpp b/src/boost/libs/asio/test/serial_port.cpp
new file mode 100644
index 000000000..a75c58338
--- /dev/null
+++ b/src/boost/libs/asio/test/serial_port.cpp
@@ -0,0 +1,173 @@
+//
+// serial_port.cpp
+// ~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/serial_port.hpp>
+
+#include "archetypes/async_result.hpp"
+#include <boost/asio/io_context.hpp>
+#include "unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+// serial_port_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// serial_port compile and link correctly. Runtime failures are ignored.
+
+namespace serial_port_compile {
+
+struct write_some_handler
+{
+ write_some_handler() {}
+ void operator()(const boost::system::error_code&, std::size_t) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ write_some_handler(write_some_handler&&) {}
+private:
+ write_some_handler(const write_some_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+
+struct read_some_handler
+{
+ read_some_handler() {}
+ void operator()(const boost::system::error_code&, std::size_t) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ read_some_handler(read_some_handler&&) {}
+private:
+ read_some_handler(const read_some_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+
+void test()
+{
+#if defined(BOOST_ASIO_HAS_SERIAL_PORT)
+ using namespace boost::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] = "";
+ serial_port::baud_rate serial_port_option;
+ archetypes::lazy_handler lazy;
+ boost::system::error_code ec;
+
+ // basic_serial_port constructors.
+
+ serial_port port1(ioc);
+ serial_port port2(ioc, "null");
+ serial_port::native_handle_type native_port1 = port1.native_handle();
+#if defined(BOOST_ASIO_MSVC) && (_MSC_VER < 1910)
+ // Skip this on older MSVC due to mysterious ambiguous overload errors.
+#else
+ serial_port port3(ioc, native_port1);
+#endif
+
+ 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);
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ serial_port port7(std::move(port6));
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_serial_port operators.
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ port1 = serial_port(ioc);
+ port1 = std::move(port2);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_io_object functions.
+
+ serial_port::executor_type ex = port1.get_executor();
+ (void)ex;
+
+ // basic_serial_port functions.
+
+ serial_port::lowest_layer_type& lowest_layer = port1.lowest_layer();
+ (void)lowest_layer;
+
+ const serial_port& port8 = port1;
+ const serial_port::lowest_layer_type& lowest_layer2 = port8.lowest_layer();
+ (void)lowest_layer2;
+
+ port1.open("null");
+ port1.open("null", ec);
+
+ serial_port::native_handle_type native_port3 = port1.native_handle();
+ 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;
+
+ port1.close();
+ port1.close(ec);
+
+ serial_port::native_handle_type native_port5 = port1.native_handle();
+ (void)native_port5;
+
+ port1.cancel();
+ port1.cancel(ec);
+
+ port1.set_option(serial_port_option);
+ port1.set_option(serial_port_option, ec);
+
+ port1.get_option(serial_port_option);
+ port1.get_option(serial_port_option, ec);
+
+ port1.send_break();
+ port1.send_break(ec);
+
+ port1.write_some(buffer(mutable_char_buffer));
+ port1.write_some(buffer(const_char_buffer));
+ port1.write_some(buffer(mutable_char_buffer), ec);
+ port1.write_some(buffer(const_char_buffer), ec);
+
+ port1.async_write_some(buffer(mutable_char_buffer), write_some_handler());
+ port1.async_write_some(buffer(const_char_buffer), write_some_handler());
+ int i1 = port1.async_write_some(buffer(mutable_char_buffer), lazy);
+ (void)i1;
+ int i2 = port1.async_write_some(buffer(const_char_buffer), lazy);
+ (void)i2;
+
+ port1.read_some(buffer(mutable_char_buffer));
+ port1.read_some(buffer(mutable_char_buffer), ec);
+
+ port1.async_read_some(buffer(mutable_char_buffer), read_some_handler());
+ int i3 = port1.async_read_some(buffer(mutable_char_buffer), lazy);
+ (void)i3;
+ }
+ catch (std::exception&)
+ {
+ }
+#endif // defined(BOOST_ASIO_HAS_SERIAL_PORT)
+}
+
+} // namespace serial_port_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "serial_port",
+ BOOST_ASIO_TEST_CASE(serial_port_compile::test)
+)
diff --git a/src/boost/libs/asio/test/serial_port_base.cpp b/src/boost/libs/asio/test/serial_port_base.cpp
new file mode 100644
index 000000000..40015f149
--- /dev/null
+++ b/src/boost/libs/asio/test/serial_port_base.cpp
@@ -0,0 +1,99 @@
+//
+// serial_port_base.cpp
+// ~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/serial_port_base.hpp>
+
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/serial_port.hpp>
+#include "unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+// serial_port_base_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// Verify that all options and and their accessors compile. Runtime failures are
+// ignored.
+
+namespace serial_port_base_compile {
+
+void test()
+{
+#if defined(BOOST_ASIO_HAS_SERIAL_PORT)
+ using namespace boost::asio;
+
+ try
+ {
+ io_context ioc;
+ serial_port port(ioc);
+
+ // baud_rate class.
+
+ serial_port_base::baud_rate baud_rate1(9600);
+ port.set_option(baud_rate1);
+ serial_port_base::baud_rate baud_rate2;
+ port.get_option(baud_rate2);
+ (void)static_cast<unsigned int>(baud_rate2.value());
+
+ // flow_control class.
+
+ serial_port_base::flow_control flow_control1(
+ serial_port_base::flow_control::none);
+ port.set_option(flow_control1);
+ serial_port_base::flow_control flow_control2;
+ port.get_option(flow_control2);
+ (void)static_cast<serial_port_base::flow_control::type>(
+ flow_control2.value());
+
+ // parity class.
+
+ serial_port_base::parity parity1(serial_port_base::parity::none);
+ port.set_option(parity1);
+ serial_port_base::parity parity2;
+ port.get_option(parity2);
+ (void)static_cast<serial_port_base::parity::type>(parity2.value());
+
+ // stop_bits class.
+
+ serial_port_base::stop_bits stop_bits1(serial_port_base::stop_bits::one);
+ port.set_option(stop_bits1);
+ serial_port_base::stop_bits stop_bits2;
+ port.get_option(stop_bits2);
+ (void)static_cast<serial_port_base::stop_bits::type>(stop_bits2.value());
+
+ // character_size class.
+
+ serial_port_base::character_size character_size1(8);
+ port.set_option(character_size1);
+ serial_port_base::character_size character_size2;
+ port.get_option(character_size2);
+ (void)static_cast<unsigned int>(character_size2.value());
+ }
+ catch (std::exception&)
+ {
+ }
+#endif // defined(BOOST_ASIO_HAS_SERIAL_PORT)
+}
+
+} // namespace serial_port_base_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "serial_port_base",
+ BOOST_ASIO_TEST_CASE(serial_port_base_compile::test)
+)
diff --git a/src/boost/libs/asio/test/signal_set.cpp b/src/boost/libs/asio/test/signal_set.cpp
new file mode 100644
index 000000000..97f714f4d
--- /dev/null
+++ b/src/boost/libs/asio/test/signal_set.cpp
@@ -0,0 +1,95 @@
+//
+// signal_set.cpp
+// ~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/signal_set.hpp>
+
+#include "archetypes/async_result.hpp"
+#include <boost/asio/io_context.hpp>
+#include "unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+// signal_set_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// signal_set compile and link correctly. Runtime failures are ignored.
+
+namespace signal_set_compile {
+
+void signal_handler(const boost::system::error_code&, int)
+{
+}
+
+void test()
+{
+ using namespace boost::asio;
+
+ try
+ {
+ io_context ioc;
+ const io_context::executor_type ioc_ex = ioc.get_executor();
+ archetypes::lazy_handler lazy;
+ boost::system::error_code ec;
+
+ // basic_signal_set constructors.
+
+ signal_set set1(ioc);
+ signal_set set2(ioc, 1);
+ 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;
+
+ // basic_signal_set functions.
+
+ set1.add(1);
+ set1.add(1, ec);
+
+ set1.remove(1);
+ set1.remove(1, ec);
+
+ set1.clear();
+ set1.clear(ec);
+
+ set1.cancel();
+ set1.cancel(ec);
+
+ set1.async_wait(&signal_handler);
+ int i = set1.async_wait(lazy);
+ (void)i;
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace signal_set_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "signal_set",
+ BOOST_ASIO_TEST_CASE(signal_set_compile::test)
+)
diff --git a/src/boost/libs/asio/test/socket_base.cpp b/src/boost/libs/asio/test/socket_base.cpp
new file mode 100644
index 000000000..9fbf49193
--- /dev/null
+++ b/src/boost/libs/asio/test/socket_base.cpp
@@ -0,0 +1,650 @@
+//
+// socket_base.cpp
+// ~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/socket_base.hpp>
+
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/ip/tcp.hpp>
+#include <boost/asio/ip/udp.hpp>
+#include "unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+// socket_base_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all nested classes, enums and constants in
+// socket_base compile and link correctly. Runtime failures are ignored.
+
+namespace socket_base_compile {
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ try
+ {
+ io_context ioc;
+ ip::tcp::socket sock(ioc);
+ char buf[1024];
+
+ // shutdown_type enumeration.
+
+ sock.shutdown(socket_base::shutdown_receive);
+ sock.shutdown(socket_base::shutdown_send);
+ sock.shutdown(socket_base::shutdown_both);
+
+ // message_flags constants.
+
+ sock.receive(buffer(buf), socket_base::message_peek);
+ sock.receive(buffer(buf), socket_base::message_out_of_band);
+ sock.send(buffer(buf), socket_base::message_do_not_route);
+
+ // broadcast class.
+
+ socket_base::broadcast broadcast1(true);
+ sock.set_option(broadcast1);
+ socket_base::broadcast broadcast2;
+ sock.get_option(broadcast2);
+ broadcast1 = true;
+ (void)static_cast<bool>(broadcast1);
+ (void)static_cast<bool>(!broadcast1);
+ (void)static_cast<bool>(broadcast1.value());
+
+ // debug class.
+
+ socket_base::debug debug1(true);
+ sock.set_option(debug1);
+ socket_base::debug debug2;
+ sock.get_option(debug2);
+ debug1 = true;
+ (void)static_cast<bool>(debug1);
+ (void)static_cast<bool>(!debug1);
+ (void)static_cast<bool>(debug1.value());
+
+ // do_not_route class.
+
+ socket_base::do_not_route do_not_route1(true);
+ sock.set_option(do_not_route1);
+ socket_base::do_not_route do_not_route2;
+ sock.get_option(do_not_route2);
+ do_not_route1 = true;
+ (void)static_cast<bool>(do_not_route1);
+ (void)static_cast<bool>(!do_not_route1);
+ (void)static_cast<bool>(do_not_route1.value());
+
+ // keep_alive class.
+
+ socket_base::keep_alive keep_alive1(true);
+ sock.set_option(keep_alive1);
+ socket_base::keep_alive keep_alive2;
+ sock.get_option(keep_alive2);
+ keep_alive1 = true;
+ (void)static_cast<bool>(keep_alive1);
+ (void)static_cast<bool>(!keep_alive1);
+ (void)static_cast<bool>(keep_alive1.value());
+
+ // send_buffer_size class.
+
+ socket_base::send_buffer_size send_buffer_size1(1024);
+ sock.set_option(send_buffer_size1);
+ socket_base::send_buffer_size send_buffer_size2;
+ sock.get_option(send_buffer_size2);
+ send_buffer_size1 = 1;
+ (void)static_cast<int>(send_buffer_size1.value());
+
+ // send_low_watermark class.
+
+ socket_base::send_low_watermark send_low_watermark1(128);
+ sock.set_option(send_low_watermark1);
+ socket_base::send_low_watermark send_low_watermark2;
+ sock.get_option(send_low_watermark2);
+ send_low_watermark1 = 1;
+ (void)static_cast<int>(send_low_watermark1.value());
+
+ // receive_buffer_size class.
+
+ socket_base::receive_buffer_size receive_buffer_size1(1024);
+ sock.set_option(receive_buffer_size1);
+ socket_base::receive_buffer_size receive_buffer_size2;
+ sock.get_option(receive_buffer_size2);
+ receive_buffer_size1 = 1;
+ (void)static_cast<int>(receive_buffer_size1.value());
+
+ // receive_low_watermark class.
+
+ socket_base::receive_low_watermark receive_low_watermark1(128);
+ sock.set_option(receive_low_watermark1);
+ socket_base::receive_low_watermark receive_low_watermark2;
+ sock.get_option(receive_low_watermark2);
+ receive_low_watermark1 = 1;
+ (void)static_cast<int>(receive_low_watermark1.value());
+
+ // reuse_address class.
+
+ socket_base::reuse_address reuse_address1(true);
+ sock.set_option(reuse_address1);
+ socket_base::reuse_address reuse_address2;
+ sock.get_option(reuse_address2);
+ reuse_address1 = true;
+ (void)static_cast<bool>(reuse_address1);
+ (void)static_cast<bool>(!reuse_address1);
+ (void)static_cast<bool>(reuse_address1.value());
+
+ // linger class.
+
+ socket_base::linger linger1(true, 30);
+ sock.set_option(linger1);
+ socket_base::linger linger2;
+ sock.get_option(linger2);
+ linger1.enabled(true);
+ (void)static_cast<bool>(linger1.enabled());
+ 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);
+ sock.set_option(enable_connection_aborted1);
+ socket_base::enable_connection_aborted enable_connection_aborted2;
+ sock.get_option(enable_connection_aborted2);
+ enable_connection_aborted1 = true;
+ (void)static_cast<bool>(enable_connection_aborted1);
+ (void)static_cast<bool>(!enable_connection_aborted1);
+ (void)static_cast<bool>(enable_connection_aborted1.value());
+
+ // bytes_readable class.
+
+ socket_base::bytes_readable bytes_readable;
+ sock.io_control(bytes_readable);
+ std::size_t bytes = bytes_readable.get();
+ (void)bytes;
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace socket_base_compile
+
+//------------------------------------------------------------------------------
+
+// socket_base_runtime test
+// ~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks the runtime operation of the socket options and I/O
+// control commands defined in socket_base.
+
+namespace socket_base_runtime {
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ io_context ioc;
+ ip::udp::socket udp_sock(ioc, ip::udp::v4());
+ ip::tcp::socket tcp_sock(ioc, ip::tcp::v4());
+ ip::tcp::acceptor tcp_acceptor(ioc, ip::tcp::v4());
+ boost::system::error_code ec;
+
+ // broadcast class.
+
+ socket_base::broadcast broadcast1(true);
+ BOOST_ASIO_CHECK(broadcast1.value());
+ BOOST_ASIO_CHECK(static_cast<bool>(broadcast1));
+ BOOST_ASIO_CHECK(!!broadcast1);
+ udp_sock.set_option(broadcast1, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+
+ socket_base::broadcast broadcast2;
+ udp_sock.get_option(broadcast2, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(broadcast2.value());
+ BOOST_ASIO_CHECK(static_cast<bool>(broadcast2));
+ BOOST_ASIO_CHECK(!!broadcast2);
+
+ socket_base::broadcast broadcast3(false);
+ BOOST_ASIO_CHECK(!broadcast3.value());
+ BOOST_ASIO_CHECK(!static_cast<bool>(broadcast3));
+ BOOST_ASIO_CHECK(!broadcast3);
+ udp_sock.set_option(broadcast3, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+
+ socket_base::broadcast broadcast4;
+ udp_sock.get_option(broadcast4, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(!broadcast4.value());
+ BOOST_ASIO_CHECK(!static_cast<bool>(broadcast4));
+ BOOST_ASIO_CHECK(!broadcast4);
+
+ // debug class.
+
+ socket_base::debug debug1(true);
+ BOOST_ASIO_CHECK(debug1.value());
+ BOOST_ASIO_CHECK(static_cast<bool>(debug1));
+ BOOST_ASIO_CHECK(!!debug1);
+ udp_sock.set_option(debug1, ec);
+#if defined(__linux__)
+ // On Linux, only root can set SO_DEBUG.
+ bool not_root = (ec == boost::asio::error::access_denied);
+ BOOST_ASIO_CHECK(!ec || not_root);
+ BOOST_ASIO_WARN_MESSAGE(!ec, "Must be root to set debug socket option");
+#else // defined(__linux__)
+# if defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ // Option is not supported under Windows CE.
+ BOOST_ASIO_CHECK_MESSAGE(ec == boost::asio::error::no_protocol_option,
+ ec.value() << ", " << ec.message());
+# else // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+# endif // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+#endif // defined(__linux__)
+
+ socket_base::debug debug2;
+ udp_sock.get_option(debug2, ec);
+#if defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ // Option is not supported under Windows CE.
+ BOOST_ASIO_CHECK_MESSAGE(ec == boost::asio::error::no_protocol_option,
+ ec.value() << ", " << ec.message());
+#else // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+# if defined(__linux__)
+ BOOST_ASIO_CHECK(debug2.value() || not_root);
+ BOOST_ASIO_CHECK(static_cast<bool>(debug2) || not_root);
+ BOOST_ASIO_CHECK(!!debug2 || not_root);
+# else // defined(__linux__)
+ BOOST_ASIO_CHECK(debug2.value());
+ BOOST_ASIO_CHECK(static_cast<bool>(debug2));
+ BOOST_ASIO_CHECK(!!debug2);
+# endif // defined(__linux__)
+#endif // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+
+ socket_base::debug debug3(false);
+ BOOST_ASIO_CHECK(!debug3.value());
+ BOOST_ASIO_CHECK(!static_cast<bool>(debug3));
+ BOOST_ASIO_CHECK(!debug3);
+ udp_sock.set_option(debug3, ec);
+#if defined(__linux__)
+ BOOST_ASIO_CHECK(!ec || not_root);
+#else // defined(__linux__)
+# if defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ // Option is not supported under Windows CE.
+ BOOST_ASIO_CHECK_MESSAGE(ec == boost::asio::error::no_protocol_option,
+ ec.value() << ", " << ec.message());
+# else // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+# endif // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+#endif // defined(__linux__)
+
+ socket_base::debug debug4;
+ udp_sock.get_option(debug4, ec);
+#if defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ // Option is not supported under Windows CE.
+ BOOST_ASIO_CHECK_MESSAGE(ec == boost::asio::error::no_protocol_option,
+ ec.value() << ", " << ec.message());
+#else // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+# if defined(__linux__)
+ BOOST_ASIO_CHECK(!debug4.value() || not_root);
+ BOOST_ASIO_CHECK(!static_cast<bool>(debug4) || not_root);
+ BOOST_ASIO_CHECK(!debug4 || not_root);
+# else // defined(__linux__)
+ BOOST_ASIO_CHECK(!debug4.value());
+ BOOST_ASIO_CHECK(!static_cast<bool>(debug4));
+ BOOST_ASIO_CHECK(!debug4);
+# endif // defined(__linux__)
+#endif // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+
+ // do_not_route class.
+
+ socket_base::do_not_route do_not_route1(true);
+ BOOST_ASIO_CHECK(do_not_route1.value());
+ BOOST_ASIO_CHECK(static_cast<bool>(do_not_route1));
+ BOOST_ASIO_CHECK(!!do_not_route1);
+ udp_sock.set_option(do_not_route1, ec);
+#if defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ // Option is not supported under Windows CE.
+ BOOST_ASIO_CHECK_MESSAGE(ec == boost::asio::error::no_protocol_option,
+ ec.value() << ", " << ec.message());
+#else // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+#endif // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+
+ socket_base::do_not_route do_not_route2;
+ udp_sock.get_option(do_not_route2, ec);
+#if defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ // Option is not supported under Windows CE.
+ BOOST_ASIO_CHECK_MESSAGE(ec == boost::asio::error::no_protocol_option,
+ ec.value() << ", " << ec.message());
+#else // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(do_not_route2.value());
+ BOOST_ASIO_CHECK(static_cast<bool>(do_not_route2));
+ BOOST_ASIO_CHECK(!!do_not_route2);
+#endif // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+
+ socket_base::do_not_route do_not_route3(false);
+ BOOST_ASIO_CHECK(!do_not_route3.value());
+ BOOST_ASIO_CHECK(!static_cast<bool>(do_not_route3));
+ BOOST_ASIO_CHECK(!do_not_route3);
+ udp_sock.set_option(do_not_route3, ec);
+#if defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ // Option is not supported under Windows CE.
+ BOOST_ASIO_CHECK_MESSAGE(ec == boost::asio::error::no_protocol_option,
+ ec.value() << ", " << ec.message());
+#else // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+#endif // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+
+ socket_base::do_not_route do_not_route4;
+ udp_sock.get_option(do_not_route4, ec);
+#if defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ // Option is not supported under Windows CE.
+ BOOST_ASIO_CHECK_MESSAGE(ec == boost::asio::error::no_protocol_option,
+ ec.value() << ", " << ec.message());
+#else // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(!do_not_route4.value());
+ BOOST_ASIO_CHECK(!static_cast<bool>(do_not_route4));
+ BOOST_ASIO_CHECK(!do_not_route4);
+#endif // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+
+ // keep_alive class.
+
+ socket_base::keep_alive keep_alive1(true);
+ BOOST_ASIO_CHECK(keep_alive1.value());
+ BOOST_ASIO_CHECK(static_cast<bool>(keep_alive1));
+ BOOST_ASIO_CHECK(!!keep_alive1);
+ tcp_sock.set_option(keep_alive1, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+
+ socket_base::keep_alive keep_alive2;
+ tcp_sock.get_option(keep_alive2, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(keep_alive2.value());
+ BOOST_ASIO_CHECK(static_cast<bool>(keep_alive2));
+ BOOST_ASIO_CHECK(!!keep_alive2);
+
+ socket_base::keep_alive keep_alive3(false);
+ BOOST_ASIO_CHECK(!keep_alive3.value());
+ BOOST_ASIO_CHECK(!static_cast<bool>(keep_alive3));
+ BOOST_ASIO_CHECK(!keep_alive3);
+ tcp_sock.set_option(keep_alive3, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+
+ socket_base::keep_alive keep_alive4;
+ tcp_sock.get_option(keep_alive4, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(!keep_alive4.value());
+ BOOST_ASIO_CHECK(!static_cast<bool>(keep_alive4));
+ BOOST_ASIO_CHECK(!keep_alive4);
+
+ // send_buffer_size class.
+
+ socket_base::send_buffer_size send_buffer_size1(4096);
+ BOOST_ASIO_CHECK(send_buffer_size1.value() == 4096);
+ tcp_sock.set_option(send_buffer_size1, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+
+ socket_base::send_buffer_size send_buffer_size2;
+ tcp_sock.get_option(send_buffer_size2, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(send_buffer_size2.value() == 4096);
+
+ socket_base::send_buffer_size send_buffer_size3(16384);
+ BOOST_ASIO_CHECK(send_buffer_size3.value() == 16384);
+ tcp_sock.set_option(send_buffer_size3, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+
+ socket_base::send_buffer_size send_buffer_size4;
+ tcp_sock.get_option(send_buffer_size4, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(send_buffer_size4.value() == 16384);
+
+ // send_low_watermark class.
+
+ socket_base::send_low_watermark send_low_watermark1(4096);
+ BOOST_ASIO_CHECK(send_low_watermark1.value() == 4096);
+ tcp_sock.set_option(send_low_watermark1, ec);
+#if defined(WIN32) || defined(__linux__) || defined(__sun)
+ BOOST_ASIO_CHECK(!!ec); // Not supported on Windows, Linux or Solaris.
+#else
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+#endif
+
+ socket_base::send_low_watermark send_low_watermark2;
+ tcp_sock.get_option(send_low_watermark2, ec);
+#if defined(WIN32) || defined(__sun)
+ BOOST_ASIO_CHECK(!!ec); // Not supported on Windows or Solaris.
+#elif defined(__linux__)
+ BOOST_ASIO_CHECK(!ec); // Not supported on Linux but can get value.
+#else
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(send_low_watermark2.value() == 4096);
+#endif
+
+ socket_base::send_low_watermark send_low_watermark3(8192);
+ BOOST_ASIO_CHECK(send_low_watermark3.value() == 8192);
+ tcp_sock.set_option(send_low_watermark3, ec);
+#if defined(WIN32) || defined(__linux__) || defined(__sun)
+ BOOST_ASIO_CHECK(!!ec); // Not supported on Windows, Linux or Solaris.
+#else
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+#endif
+
+ socket_base::send_low_watermark send_low_watermark4;
+ tcp_sock.get_option(send_low_watermark4, ec);
+#if defined(WIN32) || defined(__sun)
+ BOOST_ASIO_CHECK(!!ec); // Not supported on Windows or Solaris.
+#elif defined(__linux__)
+ BOOST_ASIO_CHECK(!ec); // Not supported on Linux but can get value.
+#else
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(send_low_watermark4.value() == 8192);
+#endif
+
+ // receive_buffer_size class.
+
+ socket_base::receive_buffer_size receive_buffer_size1(4096);
+ BOOST_ASIO_CHECK(receive_buffer_size1.value() == 4096);
+ tcp_sock.set_option(receive_buffer_size1, ec);
+#if defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ // Option is not supported under Windows CE.
+ BOOST_ASIO_CHECK_MESSAGE(ec == boost::asio::error::no_protocol_option,
+ ec.value() << ", " << ec.message());
+#else // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+#endif // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+
+ socket_base::receive_buffer_size receive_buffer_size2;
+ tcp_sock.get_option(receive_buffer_size2, ec);
+#if defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ BOOST_ASIO_CHECK(!ec); // Not supported under Windows CE but can get value.
+#else // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(receive_buffer_size2.value() == 4096);
+#endif // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+
+ socket_base::receive_buffer_size receive_buffer_size3(16384);
+ BOOST_ASIO_CHECK(receive_buffer_size3.value() == 16384);
+ tcp_sock.set_option(receive_buffer_size3, ec);
+#if defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ // Option is not supported under Windows CE.
+ BOOST_ASIO_CHECK_MESSAGE(ec == boost::asio::error::no_protocol_option,
+ ec.value() << ", " << ec.message());
+#else // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+#endif // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+
+ socket_base::receive_buffer_size receive_buffer_size4;
+ tcp_sock.get_option(receive_buffer_size4, ec);
+#if defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ BOOST_ASIO_CHECK(!ec); // Not supported under Windows CE but can get value.
+#else // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(receive_buffer_size4.value() == 16384);
+#endif // defined(BOOST_ASIO_WINDOWS) && defined(UNDER_CE)
+
+ // receive_low_watermark class.
+
+ socket_base::receive_low_watermark receive_low_watermark1(4096);
+ BOOST_ASIO_CHECK(receive_low_watermark1.value() == 4096);
+ tcp_sock.set_option(receive_low_watermark1, ec);
+#if defined(WIN32) || defined(__sun)
+ BOOST_ASIO_CHECK(!!ec); // Not supported on Windows or Solaris.
+#else
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+#endif
+
+ socket_base::receive_low_watermark receive_low_watermark2;
+ tcp_sock.get_option(receive_low_watermark2, ec);
+#if defined(WIN32) || defined(__sun)
+ BOOST_ASIO_CHECK(!!ec); // Not supported on Windows or Solaris.
+#else
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(receive_low_watermark2.value() == 4096);
+#endif
+
+ socket_base::receive_low_watermark receive_low_watermark3(8192);
+ BOOST_ASIO_CHECK(receive_low_watermark3.value() == 8192);
+ tcp_sock.set_option(receive_low_watermark3, ec);
+#if defined(WIN32) || defined(__sun)
+ BOOST_ASIO_CHECK(!!ec); // Not supported on Windows or Solaris.
+#else
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+#endif
+
+ socket_base::receive_low_watermark receive_low_watermark4;
+ tcp_sock.get_option(receive_low_watermark4, ec);
+#if defined(WIN32) || defined(__sun)
+ BOOST_ASIO_CHECK(!!ec); // Not supported on Windows or Solaris.
+#else
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(receive_low_watermark4.value() == 8192);
+#endif
+
+ // reuse_address class.
+
+ socket_base::reuse_address reuse_address1(true);
+ BOOST_ASIO_CHECK(reuse_address1.value());
+ BOOST_ASIO_CHECK(static_cast<bool>(reuse_address1));
+ BOOST_ASIO_CHECK(!!reuse_address1);
+ udp_sock.set_option(reuse_address1, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+
+ socket_base::reuse_address reuse_address2;
+ udp_sock.get_option(reuse_address2, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(reuse_address2.value());
+ BOOST_ASIO_CHECK(static_cast<bool>(reuse_address2));
+ BOOST_ASIO_CHECK(!!reuse_address2);
+
+ socket_base::reuse_address reuse_address3(false);
+ BOOST_ASIO_CHECK(!reuse_address3.value());
+ BOOST_ASIO_CHECK(!static_cast<bool>(reuse_address3));
+ BOOST_ASIO_CHECK(!reuse_address3);
+ udp_sock.set_option(reuse_address3, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+
+ socket_base::reuse_address reuse_address4;
+ udp_sock.get_option(reuse_address4, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(!reuse_address4.value());
+ BOOST_ASIO_CHECK(!static_cast<bool>(reuse_address4));
+ BOOST_ASIO_CHECK(!reuse_address4);
+
+ // linger class.
+
+ socket_base::linger linger1(true, 60);
+ BOOST_ASIO_CHECK(linger1.enabled());
+ BOOST_ASIO_CHECK(linger1.timeout() == 60);
+ tcp_sock.set_option(linger1, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+
+ socket_base::linger linger2;
+ tcp_sock.get_option(linger2, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(linger2.enabled());
+ BOOST_ASIO_CHECK(linger2.timeout() == 60);
+
+ socket_base::linger linger3(false, 0);
+ BOOST_ASIO_CHECK(!linger3.enabled());
+ BOOST_ASIO_CHECK(linger3.timeout() == 0);
+ tcp_sock.set_option(linger3, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+
+ socket_base::linger linger4;
+ tcp_sock.get_option(linger4, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(!linger4.enabled());
+
+ // enable_connection_aborted class.
+
+ socket_base::enable_connection_aborted enable_connection_aborted1(true);
+ BOOST_ASIO_CHECK(enable_connection_aborted1.value());
+ BOOST_ASIO_CHECK(static_cast<bool>(enable_connection_aborted1));
+ BOOST_ASIO_CHECK(!!enable_connection_aborted1);
+ tcp_acceptor.set_option(enable_connection_aborted1, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+
+ socket_base::enable_connection_aborted enable_connection_aborted2;
+ tcp_acceptor.get_option(enable_connection_aborted2, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(enable_connection_aborted2.value());
+ BOOST_ASIO_CHECK(static_cast<bool>(enable_connection_aborted2));
+ BOOST_ASIO_CHECK(!!enable_connection_aborted2);
+
+ socket_base::enable_connection_aborted enable_connection_aborted3(false);
+ BOOST_ASIO_CHECK(!enable_connection_aborted3.value());
+ BOOST_ASIO_CHECK(!static_cast<bool>(enable_connection_aborted3));
+ BOOST_ASIO_CHECK(!enable_connection_aborted3);
+ tcp_acceptor.set_option(enable_connection_aborted3, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+
+ socket_base::enable_connection_aborted enable_connection_aborted4;
+ tcp_acceptor.get_option(enable_connection_aborted4, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+ BOOST_ASIO_CHECK(!enable_connection_aborted4.value());
+ BOOST_ASIO_CHECK(!static_cast<bool>(enable_connection_aborted4));
+ BOOST_ASIO_CHECK(!enable_connection_aborted4);
+
+ // bytes_readable class.
+
+ socket_base::bytes_readable bytes_readable;
+ udp_sock.io_control(bytes_readable, ec);
+ BOOST_ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
+}
+
+} // namespace socket_base_runtime
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "socket_base",
+ BOOST_ASIO_TEST_CASE(socket_base_compile::test)
+ BOOST_ASIO_TEST_CASE(socket_base_runtime::test)
+)
diff --git a/src/boost/libs/asio/test/ssl/Jamfile.v2 b/src/boost/libs/asio/test/ssl/Jamfile.v2
new file mode 100644
index 000000000..fd6f550ed
--- /dev/null
+++ b/src/boost/libs/asio/test/ssl/Jamfile.v2
@@ -0,0 +1,60 @@
+#
+# Copyright (c) 2003-2020 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)
+#
+
+import os ;
+import feature ;
+
+lib ssl ;
+lib crypto ;
+
+lib socket ; # SOLARIS
+lib nsl ; # SOLARIS
+lib ws2_32 ; # NT
+lib mswsock ; # NT
+lib ipv6 ; # HPUX
+lib network ; # HAIKU
+
+local USE_SELECT =
+ <define>BOOST_ASIO_DISABLE_EPOLL
+ <define>BOOST_ASIO_DISABLE_KQUEUE
+ <define>BOOST_ASIO_DISABLE_IOCP
+ ;
+
+project
+ : requirements
+ <library>/boost/date_time//boost_date_time
+ <library>/boost/system//boost_system
+ <library>/boost/chrono//boost_chrono
+ <define>BOOST_ALL_NO_LIB=1
+ <threading>multi
+ <target-os>solaris:<library>socket
+ <target-os>solaris:<library>nsl
+ <target-os>windows:<define>_WIN32_WINNT=0x0501
+ <target-os>windows,<toolset>gcc:<library>ws2_32
+ <target-os>windows,<toolset>gcc:<library>mswsock
+ <target-os>windows,<toolset>gcc-cygwin:<define>__USE_W32_SOCKETS
+ <target-os>hpux,<toolset>gcc:<define>_XOPEN_SOURCE_EXTENDED
+ <target-os>hpux:<library>ipv6
+ <target-os>haiku:<library>network
+ ;
+
+test-suite "asio-ssl" :
+ [ compile context_base.cpp ]
+ [ compile context_base.cpp : $(USE_SELECT) : context_base_select ]
+ [ compile context.cpp ]
+ [ compile context.cpp : $(USE_SELECT) : context_select ]
+ [ compile error.cpp ]
+ [ compile error.cpp : $(USE_SELECT) : error_select ]
+ [ compile host_name_verification.cpp ]
+ [ compile host_name_verification.cpp : $(USE_SELECT) : host_name_verification_select ]
+ [ compile rfc2818_verification.cpp ]
+ [ compile rfc2818_verification.cpp : $(USE_SELECT) : rfc2818_verification_select ]
+ [ compile stream_base.cpp ]
+ [ compile stream_base.cpp : $(USE_SELECT) : stream_base_select ]
+ [ compile stream.cpp ]
+ [ compile stream.cpp : $(USE_SELECT) : stream_select ]
+ ;
diff --git a/src/boost/libs/asio/test/ssl/context.cpp b/src/boost/libs/asio/test/ssl/context.cpp
new file mode 100644
index 000000000..12b3d838b
--- /dev/null
+++ b/src/boost/libs/asio/test/ssl/context.cpp
@@ -0,0 +1,25 @@
+//
+// context.cpp
+// ~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ssl/context.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ssl/context",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/ssl/context_base.cpp b/src/boost/libs/asio/test/ssl/context_base.cpp
new file mode 100644
index 000000000..a63af9dac
--- /dev/null
+++ b/src/boost/libs/asio/test/ssl/context_base.cpp
@@ -0,0 +1,25 @@
+//
+// context_base.cpp
+// ~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ssl/context_base.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ssl/context_base",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/ssl/error.cpp b/src/boost/libs/asio/test/ssl/error.cpp
new file mode 100644
index 000000000..722abe448
--- /dev/null
+++ b/src/boost/libs/asio/test/ssl/error.cpp
@@ -0,0 +1,25 @@
+//
+// error.cpp
+// ~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ssl/error.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ssl/error",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/ssl/host_name_verification.cpp b/src/boost/libs/asio/test/ssl/host_name_verification.cpp
new file mode 100644
index 000000000..783455a95
--- /dev/null
+++ b/src/boost/libs/asio/test/ssl/host_name_verification.cpp
@@ -0,0 +1,25 @@
+//
+// host_name_verification.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ssl/host_name_verification.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ssl/host_name_verification",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/ssl/rfc2818_verification.cpp b/src/boost/libs/asio/test/ssl/rfc2818_verification.cpp
new file mode 100644
index 000000000..92d002e5b
--- /dev/null
+++ b/src/boost/libs/asio/test/ssl/rfc2818_verification.cpp
@@ -0,0 +1,25 @@
+//
+// rfc2818_verification.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ssl/rfc2818_verification.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ssl/rfc2818_verification",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/ssl/stream.cpp b/src/boost/libs/asio/test/ssl/stream.cpp
new file mode 100644
index 000000000..007dd5f4c
--- /dev/null
+++ b/src/boost/libs/asio/test/ssl/stream.cpp
@@ -0,0 +1,191 @@
+//
+// stream.cpp
+// ~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ssl/stream.hpp>
+
+#include <boost/asio.hpp>
+#include <boost/asio/ssl.hpp>
+#include "../archetypes/async_result.hpp"
+#include "../unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+// ssl_stream_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// ssl::stream::socket compile and link correctly. Runtime failures are ignored.
+
+namespace ssl_stream_compile {
+
+bool verify_callback(bool, boost::asio::ssl::verify_context&)
+{
+ return false;
+}
+
+void handshake_handler(const boost::system::error_code&)
+{
+}
+
+void buffered_handshake_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void shutdown_handler(const boost::system::error_code&)
+{
+}
+
+void write_some_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void read_some_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ try
+ {
+ io_context ioc;
+ char mutable_char_buffer[128] = "";
+ const char const_char_buffer[128] = "";
+ boost::asio::ssl::context context(boost::asio::ssl::context::sslv23);
+ archetypes::lazy_handler lazy;
+ boost::system::error_code ec;
+
+ // ssl::stream constructors.
+
+ ssl::stream<ip::tcp::socket> stream1(ioc, context);
+ ip::tcp::socket socket1(ioc, ip::tcp::v4());
+ ssl::stream<ip::tcp::socket&> stream2(socket1, context);
+
+ // basic_io_object functions.
+
+ ssl::stream<ip::tcp::socket>::executor_type ex = stream1.get_executor();
+ (void)ex;
+
+ // ssl::stream functions.
+
+ SSL* ssl1 = stream1.native_handle();
+ (void)ssl1;
+
+ ssl::stream<ip::tcp::socket>::lowest_layer_type& lowest_layer
+ = stream1.lowest_layer();
+ (void)lowest_layer;
+
+ const ssl::stream<ip::tcp::socket>& stream3 = stream1;
+ const ssl::stream<ip::tcp::socket>::lowest_layer_type& lowest_layer2
+ = stream3.lowest_layer();
+ (void)lowest_layer2;
+
+ stream1.set_verify_mode(ssl::verify_none);
+ stream1.set_verify_mode(ssl::verify_none, ec);
+
+ stream1.set_verify_depth(1);
+ stream1.set_verify_depth(1, ec);
+
+ stream1.set_verify_callback(verify_callback);
+ stream1.set_verify_callback(verify_callback, ec);
+
+ stream1.handshake(ssl::stream_base::client);
+ stream1.handshake(ssl::stream_base::server);
+ stream1.handshake(ssl::stream_base::client, ec);
+ stream1.handshake(ssl::stream_base::server, ec);
+
+ stream1.handshake(ssl::stream_base::client, buffer(mutable_char_buffer));
+ stream1.handshake(ssl::stream_base::server, buffer(mutable_char_buffer));
+ stream1.handshake(ssl::stream_base::client, buffer(const_char_buffer));
+ stream1.handshake(ssl::stream_base::server, buffer(const_char_buffer));
+ stream1.handshake(ssl::stream_base::client,
+ buffer(mutable_char_buffer), ec);
+ stream1.handshake(ssl::stream_base::server,
+ buffer(mutable_char_buffer), ec);
+ stream1.handshake(ssl::stream_base::client,
+ buffer(const_char_buffer), ec);
+ stream1.handshake(ssl::stream_base::server,
+ buffer(const_char_buffer), ec);
+
+ stream1.async_handshake(ssl::stream_base::client, handshake_handler);
+ stream1.async_handshake(ssl::stream_base::server, handshake_handler);
+ int i1 = stream1.async_handshake(ssl::stream_base::client, lazy);
+ (void)i1;
+ int i2 = stream1.async_handshake(ssl::stream_base::server, lazy);
+ (void)i2;
+
+ stream1.async_handshake(ssl::stream_base::client,
+ buffer(mutable_char_buffer), buffered_handshake_handler);
+ stream1.async_handshake(ssl::stream_base::server,
+ buffer(mutable_char_buffer), buffered_handshake_handler);
+ stream1.async_handshake(ssl::stream_base::client,
+ buffer(const_char_buffer), buffered_handshake_handler);
+ stream1.async_handshake(ssl::stream_base::server,
+ buffer(const_char_buffer), buffered_handshake_handler);
+ int i3 = stream1.async_handshake(ssl::stream_base::client,
+ buffer(mutable_char_buffer), lazy);
+ (void)i3;
+ int i4 = stream1.async_handshake(ssl::stream_base::server,
+ buffer(mutable_char_buffer), lazy);
+ (void)i4;
+ int i5 = stream1.async_handshake(ssl::stream_base::client,
+ buffer(const_char_buffer), lazy);
+ (void)i5;
+ int i6 = stream1.async_handshake(ssl::stream_base::server,
+ buffer(const_char_buffer), lazy);
+ (void)i6;
+
+ stream1.shutdown();
+ stream1.shutdown(ec);
+
+ stream1.async_shutdown(shutdown_handler);
+ int i7 = stream1.async_shutdown(lazy);
+ (void)i7;
+
+ stream1.write_some(buffer(mutable_char_buffer));
+ stream1.write_some(buffer(const_char_buffer));
+ stream1.write_some(buffer(mutable_char_buffer), ec);
+ stream1.write_some(buffer(const_char_buffer), ec);
+
+ stream1.async_write_some(buffer(mutable_char_buffer), write_some_handler);
+ stream1.async_write_some(buffer(const_char_buffer), write_some_handler);
+ int i8 = stream1.async_write_some(buffer(mutable_char_buffer), lazy);
+ (void)i8;
+ int i9 = stream1.async_write_some(buffer(const_char_buffer), lazy);
+ (void)i9;
+
+ stream1.read_some(buffer(mutable_char_buffer));
+ stream1.read_some(buffer(mutable_char_buffer), ec);
+
+ stream1.async_read_some(buffer(mutable_char_buffer), read_some_handler);
+ int i10 = stream1.async_read_some(buffer(mutable_char_buffer), lazy);
+ (void)i10;
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace ssl_stream_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ssl/stream",
+ BOOST_ASIO_TEST_CASE(ssl_stream_compile::test)
+)
diff --git a/src/boost/libs/asio/test/ssl/stream_base.cpp b/src/boost/libs/asio/test/ssl/stream_base.cpp
new file mode 100644
index 000000000..5d02e34ad
--- /dev/null
+++ b/src/boost/libs/asio/test/ssl/stream_base.cpp
@@ -0,0 +1,25 @@
+//
+// stream_base.cpp
+// ~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ssl/stream_base.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ssl/stream_base",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/steady_timer.cpp b/src/boost/libs/asio/test/steady_timer.cpp
new file mode 100644
index 000000000..237f71c89
--- /dev/null
+++ b/src/boost/libs/asio/test/steady_timer.cpp
@@ -0,0 +1,30 @@
+//
+// steady_timer.cpp
+// ~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/steady_timer.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "steady_timer",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/strand.cpp b/src/boost/libs/asio/test/strand.cpp
new file mode 100644
index 000000000..66e97b90b
--- /dev/null
+++ b/src/boost/libs/asio/test/strand.cpp
@@ -0,0 +1,263 @@
+//
+// strand.cpp
+// ~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/strand.hpp>
+
+#include <sstream>
+#include <boost/asio/executor.hpp>
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/dispatch.hpp>
+#include <boost/asio/post.hpp>
+#include <boost/asio/detail/thread.hpp>
+#include "unit_test.hpp"
+
+#if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+# include <boost/asio/deadline_timer.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+# include <boost/asio/steady_timer.hpp>
+#endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <boost/bind/bind.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <functional>
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+
+using namespace boost::asio;
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+namespace bindns = std;
+#endif
+
+#if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+typedef deadline_timer timer;
+namespace chronons = boost::posix_time;
+#elif defined(BOOST_ASIO_HAS_CHRONO)
+typedef steady_timer timer;
+namespace chronons = boost::asio::chrono;
+#endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+
+void increment(int* count)
+{
+ ++(*count);
+}
+
+void increment_without_lock(strand<io_context::executor_type>* s, int* count)
+{
+ BOOST_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.
+ BOOST_ASIO_CHECK(*count == original_count + 1);
+}
+
+void increment_with_lock(strand<io_context::executor_type>* s, int* count)
+{
+ BOOST_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.
+ BOOST_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,
+ strand<io_context::executor_type>* 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;
+ strand<io_context::executor_type> s = make_strand(ioc);
+ int count = 0;
+
+ post(ioc, bindns::bind(increment_without_lock, &s, &count));
+
+ // No handlers can be called until run() is called.
+ BOOST_ASIO_CHECK(count == 0);
+
+ ioc.run();
+
+ // The run() call will not return until all work has finished.
+ BOOST_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.
+ BOOST_ASIO_CHECK(count == 0);
+
+ ioc.run();
+
+ // The run() call will not return until all work has finished.
+ BOOST_ASIO_CHECK(count == 1);
+
+ count = 0;
+ ioc.restart();
+ post(ioc, bindns::bind(start_sleep_increments, &ioc, &s, &count));
+ boost::asio::detail::thread thread1(bindns::bind(io_context_run, &ioc));
+ boost::asio::detail::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();
+ BOOST_ASIO_CHECK(count == 0);
+#if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+ timer1.expires_at(timer1.expires_at() + chronons::seconds(2));
+#else // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+ timer1.expires_at(timer1.expiry() + chronons::seconds(2));
+#endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+ timer1.wait();
+ BOOST_ASIO_CHECK(count == 1);
+#if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+ timer1.expires_at(timer1.expires_at() + chronons::seconds(2));
+#else // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+ timer1.expires_at(timer1.expiry() + chronons::seconds(2));
+#endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
+ timer1.wait();
+ BOOST_ASIO_CHECK(count == 2);
+
+ thread1.join();
+ thread2.join();
+
+ // The run() calls will not return until all work has finished.
+ BOOST_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.
+ BOOST_ASIO_CHECK(count == 0);
+ BOOST_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.
+ BOOST_ASIO_CHECK(count == 3);
+ BOOST_ASIO_CHECK(exception_count == 2);
+
+ count = 0;
+ ioc.restart();
+
+ // Check for clean shutdown when handlers posted through an orphaned strand
+ // are abandoned.
+ {
+ 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));
+ }
+
+ // No handlers can be called until run() is called.
+ BOOST_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);
+}
+
+BOOST_ASIO_TEST_SUITE
+(
+ "strand",
+ BOOST_ASIO_TEST_CASE(strand_test)
+ BOOST_ASIO_COMPILE_TEST_CASE(strand_conversion_test)
+)
diff --git a/src/boost/libs/asio/test/streambuf.cpp b/src/boost/libs/asio/test/streambuf.cpp
new file mode 100644
index 000000000..6c17167cb
--- /dev/null
+++ b/src/boost/libs/asio/test/streambuf.cpp
@@ -0,0 +1,62 @@
+//
+// streambuf.cpp
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/streambuf.hpp>
+
+#include <boost/asio/buffer.hpp>
+#include "unit_test.hpp"
+
+void streambuf_test()
+{
+ boost::asio::streambuf sb;
+
+ sb.sputn("abcd", 4);
+
+ BOOST_ASIO_CHECK(sb.size() == 4);
+
+ for (int i = 0; i < 100; ++i)
+ {
+ sb.consume(3);
+
+ BOOST_ASIO_CHECK(sb.size() == 1);
+
+ char buf[1];
+ sb.sgetn(buf, 1);
+
+ BOOST_ASIO_CHECK(sb.size() == 0);
+
+ sb.sputn("ab", 2);
+
+ BOOST_ASIO_CHECK(sb.size() == 2);
+
+ boost::asio::buffer_copy(sb.prepare(10), boost::asio::buffer("cd", 2));
+ sb.commit(2);
+
+ BOOST_ASIO_CHECK(sb.size() == 4);
+ }
+
+ BOOST_ASIO_CHECK(sb.size() == 4);
+
+ sb.consume(4);
+
+ BOOST_ASIO_CHECK(sb.size() == 0);
+}
+
+BOOST_ASIO_TEST_SUITE
+(
+ "streambuf",
+ BOOST_ASIO_TEST_CASE(streambuf_test)
+)
diff --git a/src/boost/libs/asio/test/system_context.cpp b/src/boost/libs/asio/test/system_context.cpp
new file mode 100644
index 000000000..32d08bf61
--- /dev/null
+++ b/src/boost/libs/asio/test/system_context.cpp
@@ -0,0 +1,30 @@
+//
+// system_context.cpp
+// ~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/system_context.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "system_context",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/system_executor.cpp b/src/boost/libs/asio/test/system_executor.cpp
new file mode 100644
index 000000000..2f286f438
--- /dev/null
+++ b/src/boost/libs/asio/test/system_executor.cpp
@@ -0,0 +1,30 @@
+//
+// system_executor.cpp
+// ~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/system_executor.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "system_executor",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/system_timer.cpp b/src/boost/libs/asio/test/system_timer.cpp
new file mode 100644
index 000000000..88755bff8
--- /dev/null
+++ b/src/boost/libs/asio/test/system_timer.cpp
@@ -0,0 +1,399 @@
+//
+// system_timer.cpp
+// ~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/system_timer.hpp>
+
+#include "unit_test.hpp"
+
+#if defined(BOOST_ASIO_HAS_STD_CHRONO)
+
+#include <boost/asio/executor_work_guard.hpp>
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/detail/thread.hpp>
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <boost/bind/bind.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <functional>
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+
+void increment(int* count)
+{
+ ++(*count);
+}
+
+void decrement_to_zero(boost::asio::system_timer* t, int* count)
+{
+ if (*count > 0)
+ {
+ --(*count);
+
+ int before_value = *count;
+
+ t->expires_at(t->expiry() + boost::asio::chrono::seconds(1));
+ t->async_wait(bindns::bind(decrement_to_zero, t, count));
+
+ // Completion cannot nest, so count value should remain unchanged.
+ BOOST_ASIO_CHECK(*count == before_value);
+ }
+}
+
+void increment_if_not_cancelled(int* count,
+ const boost::system::error_code& ec)
+{
+ if (!ec)
+ ++(*count);
+}
+
+void cancel_timer(boost::asio::system_timer* t)
+{
+ std::size_t num_cancelled = t->cancel();
+ BOOST_ASIO_CHECK(num_cancelled == 1);
+}
+
+void cancel_one_timer(boost::asio::system_timer* t)
+{
+ std::size_t num_cancelled = t->cancel_one();
+ BOOST_ASIO_CHECK(num_cancelled == 1);
+}
+
+boost::asio::system_timer::time_point now()
+{
+ return boost::asio::system_timer::clock_type::now();
+}
+
+void system_timer_test()
+{
+ using boost::asio::chrono::seconds;
+ using boost::asio::chrono::microseconds;
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ const boost::asio::io_context::executor_type ioc_ex = ioc.get_executor();
+ int count = 0;
+
+ boost::asio::system_timer::time_point start = now();
+
+ boost::asio::system_timer t1(ioc, seconds(1));
+ t1.wait();
+
+ // The timer must block until after its expiry time.
+ boost::asio::system_timer::time_point end = now();
+ boost::asio::system_timer::time_point expected_end = start + seconds(1);
+ BOOST_ASIO_CHECK(expected_end < end || expected_end == end);
+
+ start = now();
+
+ boost::asio::system_timer t2(ioc_ex, seconds(1) + microseconds(500000));
+ t2.wait();
+
+ // The timer must block until after its expiry time.
+ end = now();
+ expected_end = start + seconds(1) + microseconds(500000);
+ BOOST_ASIO_CHECK(expected_end < end || expected_end == end);
+
+ t2.expires_at(t2.expiry() + seconds(1));
+ t2.wait();
+
+ // The timer must block until after its expiry time.
+ end = now();
+ expected_end += seconds(1);
+ BOOST_ASIO_CHECK(expected_end < end || expected_end == end);
+
+ start = now();
+
+ t2.expires_after(seconds(1) + microseconds(200000));
+ t2.wait();
+
+ // The timer must block until after its expiry time.
+ end = now();
+ expected_end = start + seconds(1) + microseconds(200000);
+ BOOST_ASIO_CHECK(expected_end < end || expected_end == end);
+
+ start = now();
+
+ boost::asio::system_timer t3(ioc, seconds(5));
+ t3.async_wait(bindns::bind(increment, &count));
+
+ // No completions can be delivered until run() is called.
+ BOOST_ASIO_CHECK(count == 0);
+
+ ioc.run();
+
+ // The run() call will not return until all operations have finished, and
+ // this should not be until after the timer's expiry time.
+ BOOST_ASIO_CHECK(count == 1);
+ end = now();
+ expected_end = start + seconds(1);
+ BOOST_ASIO_CHECK(expected_end < end || expected_end == end);
+
+ count = 3;
+ start = now();
+
+ boost::asio::system_timer t4(ioc, seconds(1));
+ t4.async_wait(bindns::bind(decrement_to_zero, &t4, &count));
+
+ // No completions can be delivered until run() is called.
+ BOOST_ASIO_CHECK(count == 3);
+
+ ioc.restart();
+ ioc.run();
+
+ // The run() call will not return until all operations have finished, and
+ // this should not be until after the timer's final expiry time.
+ BOOST_ASIO_CHECK(count == 0);
+ end = now();
+ expected_end = start + seconds(3);
+ BOOST_ASIO_CHECK(expected_end < end || expected_end == end);
+
+ count = 0;
+ start = now();
+
+ boost::asio::system_timer t5(ioc, seconds(10));
+ t5.async_wait(bindns::bind(increment_if_not_cancelled, &count, _1));
+ boost::asio::system_timer t6(ioc, seconds(1));
+ t6.async_wait(bindns::bind(cancel_timer, &t5));
+
+ // No completions can be delivered until run() is called.
+ BOOST_ASIO_CHECK(count == 0);
+
+ ioc.restart();
+ ioc.run();
+
+ // The timer should have been cancelled, so count should not have changed.
+ // The total run time should not have been much more than 1 second (and
+ // certainly far less than 10 seconds).
+ BOOST_ASIO_CHECK(count == 0);
+ end = now();
+ expected_end = start + seconds(2);
+ BOOST_ASIO_CHECK(end < expected_end);
+
+ // Wait on the timer again without cancelling it. This time the asynchronous
+ // wait should run to completion and increment the counter.
+ t5.async_wait(bindns::bind(increment_if_not_cancelled, &count, _1));
+
+ ioc.restart();
+ ioc.run();
+
+ // The timer should not have been cancelled, so count should have changed.
+ // The total time since the timer was created should be more than 10 seconds.
+ BOOST_ASIO_CHECK(count == 1);
+ end = now();
+ expected_end = start + seconds(10);
+ BOOST_ASIO_CHECK(expected_end < end || expected_end == end);
+
+ count = 0;
+ start = now();
+
+ // Start two waits on a timer, one of which will be cancelled. The one
+ // which is not cancelled should still run to completion and increment the
+ // counter.
+ boost::asio::system_timer t7(ioc, seconds(3));
+ t7.async_wait(bindns::bind(increment_if_not_cancelled, &count, _1));
+ t7.async_wait(bindns::bind(increment_if_not_cancelled, &count, _1));
+ boost::asio::system_timer t8(ioc, seconds(1));
+ t8.async_wait(bindns::bind(cancel_one_timer, &t7));
+
+ ioc.restart();
+ ioc.run();
+
+ // One of the waits should not have been cancelled, so count should have
+ // changed. The total time since the timer was created should be more than 3
+ // seconds.
+ BOOST_ASIO_CHECK(count == 1);
+ end = now();
+ expected_end = start + seconds(3);
+ BOOST_ASIO_CHECK(expected_end < end || expected_end == end);
+}
+
+struct timer_handler
+{
+ timer_handler() {}
+ void operator()(const boost::system::error_code&) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ timer_handler(timer_handler&&) {}
+private:
+ timer_handler(const timer_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
+
+void system_timer_cancel_test()
+{
+ static boost::asio::io_context io_context;
+ struct timer
+ {
+ boost::asio::system_timer t;
+ timer() : t(io_context)
+ {
+ t.expires_at((boost::asio::system_timer::time_point::max)());
+ }
+ } timers[50];
+
+ timers[2].t.async_wait(timer_handler());
+ timers[41].t.async_wait(timer_handler());
+ for (int i = 10; i < 20; ++i)
+ timers[i].t.async_wait(timer_handler());
+
+ BOOST_ASIO_CHECK(timers[2].t.cancel() == 1);
+ BOOST_ASIO_CHECK(timers[41].t.cancel() == 1);
+ for (int i = 10; i < 20; ++i)
+ BOOST_ASIO_CHECK(timers[i].t.cancel() == 1);
+}
+
+struct custom_allocation_timer_handler
+{
+ custom_allocation_timer_handler(int* count) : count_(count) {}
+ void operator()(const boost::system::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);
+}
+
+void system_timer_custom_allocation_test()
+{
+ static boost::asio::io_context io_context;
+ struct timer
+ {
+ boost::asio::system_timer t;
+ timer() : t(io_context) {}
+ } timers[100];
+
+ int allocation_count = 0;
+
+ for (int i = 0; i < 50; ++i)
+ {
+ timers[i].t.expires_at((boost::asio::system_timer::time_point::max)());
+ timers[i].t.async_wait(custom_allocation_timer_handler(&allocation_count));
+ }
+
+ for (int i = 50; i < 100; ++i)
+ {
+ timers[i].t.expires_at((boost::asio::system_timer::time_point::min)());
+ timers[i].t.async_wait(custom_allocation_timer_handler(&allocation_count));
+ }
+
+ for (int i = 0; i < 50; ++i)
+ timers[i].t.cancel();
+
+ io_context.run();
+
+ BOOST_ASIO_CHECK(allocation_count == 0);
+}
+
+void io_context_run(boost::asio::io_context* ioc)
+{
+ ioc->run();
+}
+
+void system_timer_thread_test()
+{
+ boost::asio::io_context ioc;
+ boost::asio::executor_work_guard<boost::asio::io_context::executor_type> work
+ = boost::asio::make_work_guard(ioc);
+ boost::asio::system_timer t1(ioc);
+ boost::asio::system_timer t2(ioc);
+ int count = 0;
+
+ boost::asio::detail::thread th(bindns::bind(io_context_run, &ioc));
+
+ t2.expires_after(boost::asio::chrono::seconds(2));
+ t2.wait();
+
+ t1.expires_after(boost::asio::chrono::seconds(2));
+ t1.async_wait(bindns::bind(increment, &count));
+
+ t2.expires_after(boost::asio::chrono::seconds(4));
+ t2.wait();
+
+ ioc.stop();
+ th.join();
+
+ BOOST_ASIO_CHECK(count == 1);
+}
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+boost::asio::system_timer make_timer(boost::asio::io_context& ioc, int* count)
+{
+ boost::asio::system_timer t(ioc);
+ t.expires_after(boost::asio::chrono::seconds(1));
+ t.async_wait(bindns::bind(increment, count));
+ return t;
+}
+#endif
+
+void system_timer_move_test()
+{
+#if defined(BOOST_ASIO_HAS_MOVE)
+ boost::asio::io_context io_context1;
+ boost::asio::io_context io_context2;
+ int count = 0;
+
+ boost::asio::system_timer t1 = make_timer(io_context1, &count);
+ boost::asio::system_timer t2 = make_timer(io_context2, &count);
+ boost::asio::system_timer t3 = std::move(t1);
+
+ t2 = std::move(t1);
+
+ io_context2.run();
+
+ BOOST_ASIO_CHECK(count == 1);
+
+ io_context1.run();
+
+ BOOST_ASIO_CHECK(count == 2);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+}
+
+BOOST_ASIO_TEST_SUITE
+(
+ "system_timer",
+ BOOST_ASIO_TEST_CASE(system_timer_test)
+ BOOST_ASIO_TEST_CASE(system_timer_cancel_test)
+ BOOST_ASIO_TEST_CASE(system_timer_custom_allocation_test)
+ BOOST_ASIO_TEST_CASE(system_timer_thread_test)
+ BOOST_ASIO_TEST_CASE(system_timer_move_test)
+)
+#else // defined(BOOST_ASIO_HAS_STD_CHRONO)
+BOOST_ASIO_TEST_SUITE
+(
+ "system_timer",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
+#endif // defined(BOOST_ASIO_HAS_STD_CHRONO)
diff --git a/src/boost/libs/asio/test/this_coro.cpp b/src/boost/libs/asio/test/this_coro.cpp
new file mode 100644
index 000000000..9a5c4eb77
--- /dev/null
+++ b/src/boost/libs/asio/test/this_coro.cpp
@@ -0,0 +1,25 @@
+//
+// this_coro.cpp
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/this_coro.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "this_coro",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/time_traits.cpp b/src/boost/libs/asio/test/time_traits.cpp
new file mode 100644
index 000000000..181d6fac1
--- /dev/null
+++ b/src/boost/libs/asio/test/time_traits.cpp
@@ -0,0 +1,25 @@
+//
+// time_traits.cpp
+// ~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/time_traits.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "time_traits",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/ts/buffer.cpp b/src/boost/libs/asio/test/ts/buffer.cpp
new file mode 100644
index 000000000..2b2f86a4c
--- /dev/null
+++ b/src/boost/libs/asio/test/ts/buffer.cpp
@@ -0,0 +1,30 @@
+//
+// buffer.cpp
+// ~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ts/buffer.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ts/buffer",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/ts/executor.cpp b/src/boost/libs/asio/test/ts/executor.cpp
new file mode 100644
index 000000000..97faf2b57
--- /dev/null
+++ b/src/boost/libs/asio/test/ts/executor.cpp
@@ -0,0 +1,30 @@
+//
+// executor.cpp
+// ~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ts/executor.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ts/executor",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/ts/internet.cpp b/src/boost/libs/asio/test/ts/internet.cpp
new file mode 100644
index 000000000..d630723bd
--- /dev/null
+++ b/src/boost/libs/asio/test/ts/internet.cpp
@@ -0,0 +1,30 @@
+//
+// internet.cpp
+// ~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ts/internet.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ts/internet",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/ts/io_context.cpp b/src/boost/libs/asio/test/ts/io_context.cpp
new file mode 100644
index 000000000..c5fdbc178
--- /dev/null
+++ b/src/boost/libs/asio/test/ts/io_context.cpp
@@ -0,0 +1,30 @@
+//
+// io_context.cpp
+// ~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ts/io_context.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ts/io_context",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/ts/net.cpp b/src/boost/libs/asio/test/ts/net.cpp
new file mode 100644
index 000000000..12b1d5568
--- /dev/null
+++ b/src/boost/libs/asio/test/ts/net.cpp
@@ -0,0 +1,30 @@
+//
+// net.cpp
+// ~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ts/net.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ts/net",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/ts/netfwd.cpp b/src/boost/libs/asio/test/ts/netfwd.cpp
new file mode 100644
index 000000000..796d918b4
--- /dev/null
+++ b/src/boost/libs/asio/test/ts/netfwd.cpp
@@ -0,0 +1,33 @@
+//
+// netfwd.cpp
+// ~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ts/netfwd.hpp>
+
+// Test that forward declarations don't conflict with full declarations.
+#include <boost/asio/ts/net.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ts/netfwd",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/ts/socket.cpp b/src/boost/libs/asio/test/ts/socket.cpp
new file mode 100644
index 000000000..1722e8e18
--- /dev/null
+++ b/src/boost/libs/asio/test/ts/socket.cpp
@@ -0,0 +1,30 @@
+//
+// socket.cpp
+// ~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ts/socket.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ts/socket",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/ts/timer.cpp b/src/boost/libs/asio/test/ts/timer.cpp
new file mode 100644
index 000000000..5e500f1f0
--- /dev/null
+++ b/src/boost/libs/asio/test/ts/timer.cpp
@@ -0,0 +1,30 @@
+//
+// timer.cpp
+// ~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/ts/timer.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "ts/timer",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/unit_test.hpp b/src/boost/libs/asio/test/unit_test.hpp
new file mode 100644
index 000000000..6d5a78478
--- /dev/null
+++ b/src/boost/libs/asio/test/unit_test.hpp
@@ -0,0 +1,177 @@
+//
+// unit_test.hpp
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 UNIT_TEST_HPP
+#define UNIT_TEST_HPP
+
+#include <boost/asio/detail/config.hpp>
+#include <iostream>
+#include <boost/asio/detail/atomic_count.hpp>
+
+#if defined(__sun)
+# include <stdlib.h> // Needed for lrand48.
+#endif // defined(__sun)
+
+#if defined(__BORLANDC__)
+
+// Prevent use of intrinsic for strcmp.
+# include <cstring>
+# undef strcmp
+
+// Suppress error about condition always being true.
+# pragma option -w-ccc
+
+#endif // defined(__BORLANDC__)
+
+#if defined(BOOST_ASIO_MSVC)
+# pragma warning (disable:4127)
+# pragma warning (push)
+# pragma warning (disable:4244)
+# pragma warning (disable:4702)
+#endif // defined(BOOST_ASIO_MSVC)
+
+#if !defined(BOOST_ASIO_TEST_IOSTREAM)
+# define BOOST_ASIO_TEST_IOSTREAM std::cerr
+#endif // !defined(BOOST_ASIO_TEST_IOSTREAM)
+
+namespace boost {
+namespace asio {
+namespace detail {
+
+inline const char*& test_name()
+{
+ static const char* name = 0;
+ return name;
+}
+
+inline atomic_count& test_errors()
+{
+ static atomic_count errors(0);
+ return errors;
+}
+
+inline void begin_test_suite(const char* name)
+{
+ boost::asio::detail::test_name();
+ boost::asio::detail::test_errors();
+ BOOST_ASIO_TEST_IOSTREAM << name << " test suite begins" << std::endl;
+}
+
+inline int end_test_suite(const char* name)
+{
+ BOOST_ASIO_TEST_IOSTREAM << name << " test suite ends" << std::endl;
+ BOOST_ASIO_TEST_IOSTREAM << "\n*** ";
+ long errors = boost::asio::detail::test_errors();
+ if (errors == 0)
+ BOOST_ASIO_TEST_IOSTREAM << "No errors detected.";
+ else if (errors == 1)
+ BOOST_ASIO_TEST_IOSTREAM << "1 error detected.";
+ else
+ BOOST_ASIO_TEST_IOSTREAM << errors << " errors detected." << std::endl;
+ BOOST_ASIO_TEST_IOSTREAM << std::endl;
+ return errors == 0 ? 0 : 1;
+}
+
+template <void (*Test)()>
+inline void run_test(const char* name)
+{
+ test_name() = name;
+ long errors_before = boost::asio::detail::test_errors();
+ Test();
+ if (test_errors() == errors_before)
+ BOOST_ASIO_TEST_IOSTREAM << name << " passed" << std::endl;
+ else
+ BOOST_ASIO_TEST_IOSTREAM << name << " failed" << std::endl;
+}
+
+template <void (*)()>
+inline void compile_test(const char* name)
+{
+ BOOST_ASIO_TEST_IOSTREAM << name << " passed" << std::endl;
+}
+
+#if defined(BOOST_ASIO_NO_EXCEPTIONS)
+
+template <typename T>
+void throw_exception(const T& t)
+{
+ BOOST_ASIO_TEST_IOSTREAM << "Exception: " << t.what() << std::endl;
+ std::abort();
+}
+
+#endif // defined(BOOST_ASIO_NO_EXCEPTIONS)
+
+} // namespace detail
+} // namespace asio
+} // namespace boost
+
+#define BOOST_ASIO_CHECK(expr) \
+ do { if (!(expr)) { \
+ BOOST_ASIO_TEST_IOSTREAM << __FILE__ << "(" << __LINE__ << "): " \
+ << boost::asio::detail::test_name() << ": " \
+ << "check '" << #expr << "' failed" << std::endl; \
+ ++boost::asio::detail::test_errors(); \
+ } } while (0)
+
+#define BOOST_ASIO_CHECK_MESSAGE(expr, msg) \
+ do { if (!(expr)) { \
+ BOOST_ASIO_TEST_IOSTREAM << __FILE__ << "(" << __LINE__ << "): " \
+ << boost::asio::detail::test_name() << ": " \
+ << msg << std::endl; \
+ ++boost::asio::detail::test_errors(); \
+ } } while (0)
+
+#define BOOST_ASIO_WARN_MESSAGE(expr, msg) \
+ do { if (!(expr)) { \
+ BOOST_ASIO_TEST_IOSTREAM << __FILE__ << "(" << __LINE__ << "): " \
+ << boost::asio::detail::test_name() << ": " \
+ << msg << std::endl; \
+ } } while (0)
+
+#define BOOST_ASIO_ERROR(msg) \
+ do { \
+ BOOST_ASIO_TEST_IOSTREAM << __FILE__ << "(" << __LINE__ << "): " \
+ << boost::asio::detail::test_name() << ": " \
+ << msg << std::endl; \
+ ++boost::asio::detail::test_errors(); \
+ } while (0)
+
+#define BOOST_ASIO_TEST_SUITE(name, tests) \
+ int main() \
+ { \
+ boost::asio::detail::begin_test_suite(name); \
+ tests \
+ return boost::asio::detail::end_test_suite(name); \
+ }
+
+#define BOOST_ASIO_TEST_CASE(test) \
+ boost::asio::detail::run_test<&test>(#test);
+
+#define BOOST_ASIO_COMPILE_TEST_CASE(test) \
+ boost::asio::detail::compile_test<&test>(#test);
+
+inline void null_test()
+{
+}
+
+#if defined(__GNUC__) && defined(_AIX)
+
+// AIX needs this symbol defined in asio, even if it doesn't do anything.
+int test_main(int, char**)
+{
+}
+
+#endif // defined(__GNUC__) && defined(_AIX)
+
+#if defined(BOOST_ASIO_MSVC)
+# pragma warning (pop)
+#endif // defined(BOOST_ASIO_MSVC)
+
+#endif // UNIT_TEST_HPP
diff --git a/src/boost/libs/asio/test/use_awaitable.cpp b/src/boost/libs/asio/test/use_awaitable.cpp
new file mode 100644
index 000000000..338576a73
--- /dev/null
+++ b/src/boost/libs/asio/test/use_awaitable.cpp
@@ -0,0 +1,25 @@
+//
+// use_awaitable.cpp
+// ~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/use_awaitable.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "use_awaitable",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/use_future.cpp b/src/boost/libs/asio/test/use_future.cpp
new file mode 100644
index 000000000..33d3f6187
--- /dev/null
+++ b/src/boost/libs/asio/test/use_future.cpp
@@ -0,0 +1,670 @@
+//
+// use_future.cpp
+// ~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/use_future.hpp>
+
+#include <string>
+#include "unit_test.hpp"
+
+#if defined(BOOST_ASIO_HAS_STD_FUTURE)
+
+#include "archetypes/async_ops.hpp"
+
+void use_future_0_test()
+{
+ using boost::asio::use_future;
+ using namespace archetypes;
+
+ std::future<void> f;
+
+ f = async_op_0(use_future);
+ try
+ {
+ f.get();
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ec_0(true, use_future);
+ try
+ {
+ f.get();
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ec_0(false, use_future);
+ try
+ {
+ f.get();
+ BOOST_ASIO_CHECK(false);
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_ASIO_CHECK(e.code() == boost::asio::error::operation_aborted);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ex_0(true, use_future);
+ try
+ {
+ f.get();
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ex_0(false, use_future);
+ try
+ {
+ f.get();
+ BOOST_ASIO_CHECK(false);
+ }
+ catch (std::exception& e)
+ {
+ BOOST_ASIO_CHECK(e.what() == std::string("blah"));
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+}
+
+void use_future_1_test()
+{
+ using boost::asio::use_future;
+ using namespace archetypes;
+
+ std::future<int> f;
+
+ f = async_op_1(use_future);
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(i == 42);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ec_1(true, use_future);
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(i == 42);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ec_1(false, use_future);
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(false);
+ (void)i;
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_ASIO_CHECK(e.code() == boost::asio::error::operation_aborted);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ex_1(true, use_future);
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(i == 42);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ex_1(false, use_future);
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(false);
+ (void)i;
+ }
+ catch (std::exception& e)
+ {
+ BOOST_ASIO_CHECK(e.what() == std::string("blah"));
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+}
+
+void use_future_2_test()
+{
+ using boost::asio::use_future;
+ using namespace archetypes;
+
+ std::future<std::tuple<int, double>> f;
+
+ f = async_op_2(use_future);
+ try
+ {
+ int i;
+ double d;
+ std::tie(i, d) = f.get();
+ BOOST_ASIO_CHECK(i == 42);
+ BOOST_ASIO_CHECK(d == 2.0);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ec_2(true, use_future);
+ try
+ {
+ int i;
+ double d;
+ std::tie(i, d) = f.get();
+ BOOST_ASIO_CHECK(i == 42);
+ BOOST_ASIO_CHECK(d == 2.0);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ec_2(false, use_future);
+ try
+ {
+ std::tuple<int, double> t = f.get();
+ BOOST_ASIO_CHECK(false);
+ (void)t;
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_ASIO_CHECK(e.code() == boost::asio::error::operation_aborted);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ex_2(true, use_future);
+ try
+ {
+ int i;
+ double d;
+ std::tie(i, d) = f.get();
+ BOOST_ASIO_CHECK(i == 42);
+ BOOST_ASIO_CHECK(d == 2.0);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ex_2(false, use_future);
+ try
+ {
+ std::tuple<int, double> t = f.get();
+ BOOST_ASIO_CHECK(false);
+ (void)t;
+ }
+ catch (std::exception& e)
+ {
+ BOOST_ASIO_CHECK(e.what() == std::string("blah"));
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+}
+
+void use_future_3_test()
+{
+ using boost::asio::use_future;
+ using namespace archetypes;
+
+ std::future<std::tuple<int, double, char>> f;
+
+ f = async_op_3(use_future);
+ try
+ {
+ int i;
+ double d;
+ char c;
+ std::tie(i, d, c) = f.get();
+ BOOST_ASIO_CHECK(i == 42);
+ BOOST_ASIO_CHECK(d == 2.0);
+ BOOST_ASIO_CHECK(c == 'a');
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ec_3(true, use_future);
+ try
+ {
+ int i;
+ double d;
+ char c;
+ std::tie(i, d, c) = f.get();
+ BOOST_ASIO_CHECK(i == 42);
+ BOOST_ASIO_CHECK(d == 2.0);
+ BOOST_ASIO_CHECK(c == 'a');
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ec_3(false, use_future);
+ try
+ {
+ std::tuple<int, double, char> t = f.get();
+ BOOST_ASIO_CHECK(false);
+ (void)t;
+ }
+ catch (boost::system::system_error& e)
+ {
+ BOOST_ASIO_CHECK(e.code() == boost::asio::error::operation_aborted);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ex_3(true, use_future);
+ try
+ {
+ int i;
+ double d;
+ char c;
+ std::tie(i, d, c) = f.get();
+ BOOST_ASIO_CHECK(i == 42);
+ BOOST_ASIO_CHECK(d == 2.0);
+ BOOST_ASIO_CHECK(c == 'a');
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ex_3(false, use_future);
+ try
+ {
+ std::tuple<int, double, char> t = f.get();
+ BOOST_ASIO_CHECK(false);
+ (void)t;
+ }
+ catch (std::exception& e)
+ {
+ BOOST_ASIO_CHECK(e.what() == std::string("blah"));
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+}
+
+int package_0()
+{
+ return 42;
+}
+
+int package_ec_0(boost::system::error_code ec)
+{
+ return ec ? 0 : 42;
+}
+
+int package_ex_0(std::exception_ptr ex)
+{
+ return ex ? 0 : 42;
+}
+
+void use_future_package_0_test()
+{
+ using boost::asio::use_future;
+ using namespace archetypes;
+
+ std::future<int> f;
+
+ f = async_op_0(use_future(package_0));
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(i == 42);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ec_0(true, use_future(&package_ec_0));
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(i == 42);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ec_0(false, use_future(package_ec_0));
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(i == 0);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ex_0(true, use_future(package_ex_0));
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(i == 42);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ex_0(false, use_future(package_ex_0));
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(i == 0);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+}
+
+int package_1(int i)
+{
+ return i;
+}
+
+int package_ec_1(boost::system::error_code ec, int i)
+{
+ return ec ? 0 : i;
+}
+
+int package_ex_1(std::exception_ptr ex, int i)
+{
+ return ex ? 0 : i;
+}
+
+void use_future_package_1_test()
+{
+ using boost::asio::use_future;
+ using namespace archetypes;
+
+ std::future<int> f;
+
+ f = async_op_1(use_future(package_1));
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(i == 42);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ec_1(true, use_future(package_ec_1));
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(i == 42);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ec_1(false, use_future(package_ec_1));
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(i == 0);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ex_1(true, use_future(package_ex_1));
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(i == 42);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ex_1(false, use_future(package_ex_1));
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(i == 0);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+}
+
+int package_2(int i, double)
+{
+ return i;
+}
+
+int package_ec_2(boost::system::error_code ec, int i, double)
+{
+ return ec ? 0 : i;
+}
+
+int package_ex_2(std::exception_ptr ex, int i, double)
+{
+ return ex ? 0 : i;
+}
+
+void use_future_package_2_test()
+{
+ using boost::asio::use_future;
+ using namespace archetypes;
+
+ std::future<int> f;
+
+ f = async_op_2(use_future(package_2));
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(i == 42);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ec_2(true, use_future(package_ec_2));
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(i == 42);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ec_2(false, use_future(package_ec_2));
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(i == 0);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ex_2(true, use_future(package_ex_2));
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(i == 42);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ex_2(false, use_future(package_ex_2));
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(i == 0);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+}
+
+int package_3(int i, double, char)
+{
+ return i;
+}
+
+int package_ec_3(boost::system::error_code ec, int i, double, char)
+{
+ return ec ? 0 : i;
+}
+
+int package_ex_3(std::exception_ptr ex, int i, double, char)
+{
+ return ex ? 0 : i;
+}
+
+void use_future_package_3_test()
+{
+ using boost::asio::use_future;
+ using namespace archetypes;
+
+ std::future<int> f;
+
+ f = async_op_3(use_future(package_3));
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(i == 42);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ec_3(true, use_future(package_ec_3));
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(i == 42);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ec_3(false, use_future(package_ec_3));
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(i == 0);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ex_3(true, use_future(package_ex_3));
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(i == 42);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+
+ f = async_op_ex_3(false, use_future(package_ex_3));
+ try
+ {
+ int i = f.get();
+ BOOST_ASIO_CHECK(i == 0);
+ }
+ catch (...)
+ {
+ BOOST_ASIO_CHECK(false);
+ }
+}
+
+BOOST_ASIO_TEST_SUITE
+(
+ "use_future",
+ BOOST_ASIO_TEST_CASE(use_future_0_test)
+ BOOST_ASIO_TEST_CASE(use_future_1_test)
+ BOOST_ASIO_TEST_CASE(use_future_2_test)
+ BOOST_ASIO_TEST_CASE(use_future_3_test)
+ BOOST_ASIO_TEST_CASE(use_future_package_0_test)
+ BOOST_ASIO_TEST_CASE(use_future_package_1_test)
+ BOOST_ASIO_TEST_CASE(use_future_package_2_test)
+ BOOST_ASIO_TEST_CASE(use_future_package_3_test)
+)
+
+#else // defined(BOOST_ASIO_HAS_STD_FUTURE)
+
+BOOST_ASIO_TEST_SUITE
+(
+ "use_future",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
+
+#endif // defined(BOOST_ASIO_HAS_STD_FUTURE)
diff --git a/src/boost/libs/asio/test/uses_executor.cpp b/src/boost/libs/asio/test/uses_executor.cpp
new file mode 100644
index 000000000..fb4702b87
--- /dev/null
+++ b/src/boost/libs/asio/test/uses_executor.cpp
@@ -0,0 +1,25 @@
+//
+// uses_executor.cpp
+// ~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/uses_executor.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "uses_executor",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/wait_traits.cpp b/src/boost/libs/asio/test/wait_traits.cpp
new file mode 100644
index 000000000..50514710f
--- /dev/null
+++ b/src/boost/libs/asio/test/wait_traits.cpp
@@ -0,0 +1,25 @@
+//
+// wait_traits.cpp
+// ~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/wait_traits.hpp>
+
+#include "unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "wait_traits",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/windows/basic_object_handle.cpp b/src/boost/libs/asio/test/windows/basic_object_handle.cpp
new file mode 100644
index 000000000..d128873e3
--- /dev/null
+++ b/src/boost/libs/asio/test/windows/basic_object_handle.cpp
@@ -0,0 +1,25 @@
+//
+// basic_object_handle.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/windows/basic_object_handle.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "basic_object_handle",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/windows/basic_overlapped_handle.cpp b/src/boost/libs/asio/test/windows/basic_overlapped_handle.cpp
new file mode 100644
index 000000000..bd9623165
--- /dev/null
+++ b/src/boost/libs/asio/test/windows/basic_overlapped_handle.cpp
@@ -0,0 +1,25 @@
+//
+// basic_overlapped_handle.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/windows/basic_overlapped_handle.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "basic_overlapped_handle",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/windows/basic_random_access_handle.cpp b/src/boost/libs/asio/test/windows/basic_random_access_handle.cpp
new file mode 100644
index 000000000..925d068ca
--- /dev/null
+++ b/src/boost/libs/asio/test/windows/basic_random_access_handle.cpp
@@ -0,0 +1,25 @@
+//
+// basic_random_access_handle.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/windows/basic_random_access_handle.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "basic_random_access_handle",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/windows/basic_stream_handle.cpp b/src/boost/libs/asio/test/windows/basic_stream_handle.cpp
new file mode 100644
index 000000000..b15d88d5e
--- /dev/null
+++ b/src/boost/libs/asio/test/windows/basic_stream_handle.cpp
@@ -0,0 +1,25 @@
+//
+// basic_stream_handle.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/windows/basic_stream_handle.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "basic_stream_handle",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/windows/object_handle.cpp b/src/boost/libs/asio/test/windows/object_handle.cpp
new file mode 100644
index 000000000..66c016646
--- /dev/null
+++ b/src/boost/libs/asio/test/windows/object_handle.cpp
@@ -0,0 +1,130 @@
+//
+// object_handle.cpp
+// ~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/windows/object_handle.hpp>
+
+#include <boost/asio/io_context.hpp>
+#include "../archetypes/async_result.hpp"
+#include "../unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+// windows_object_handle_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// windows::object_handle compile and link correctly. Runtime failures are
+// ignored.
+
+namespace windows_object_handle_compile {
+
+void wait_handler(const boost::system::error_code&)
+{
+}
+
+void test()
+{
+#if defined(BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE)
+ using namespace boost::asio;
+ namespace win = boost::asio::windows;
+
+ try
+ {
+ io_context ioc;
+ const io_context::executor_type ioc_ex = ioc.get_executor();
+ archetypes::lazy_handler lazy;
+ boost::system::error_code ec;
+
+ // basic_object_handle constructors.
+
+ win::object_handle handle1(ioc);
+ HANDLE native_handle1 = INVALID_HANDLE_VALUE;
+#if defined(BOOST_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
+
+ win::object_handle handle3(ioc_ex);
+ HANDLE native_handle2 = INVALID_HANDLE_VALUE;
+ win::object_handle handle4(ioc_ex, native_handle2);
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ win::object_handle handle5(std::move(handle4));
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_object_handle operators.
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ handle1 = win::object_handle(ioc);
+ handle1 = std::move(handle3);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_io_object functions.
+
+ win::object_handle::executor_type ex = handle1.get_executor();
+ (void)ex;
+
+ // basic_handle functions.
+
+ win::object_handle::lowest_layer_type& lowest_layer
+ = handle1.lowest_layer();
+ (void)lowest_layer;
+
+ const win::object_handle& handle6 = handle1;
+ const win::object_handle::lowest_layer_type& lowest_layer3
+ = handle6.lowest_layer();
+ (void)lowest_layer3;
+
+ HANDLE native_handle4 = INVALID_HANDLE_VALUE;
+ handle1.assign(native_handle4);
+
+ bool is_open = handle1.is_open();
+ (void)is_open;
+
+ handle1.close();
+ handle1.close(ec);
+
+ win::object_handle::native_handle_type native_handle3
+ = handle1.native_handle();
+ (void)native_handle3;
+
+ handle1.cancel();
+ handle1.cancel(ec);
+
+ // basic_object_handle functions.
+
+ handle1.wait();
+ handle1.wait(ec);
+
+ handle1.async_wait(&wait_handler);
+ int i1 = handle1.async_wait(lazy);
+ (void)i1;
+ }
+ catch (std::exception&)
+ {
+ }
+#endif // defined(BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE)
+}
+
+} // namespace windows_object_handle_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "windows/object_handle",
+ BOOST_ASIO_TEST_CASE(windows_object_handle_compile::test)
+)
diff --git a/src/boost/libs/asio/test/windows/overlapped_handle.cpp b/src/boost/libs/asio/test/windows/overlapped_handle.cpp
new file mode 100644
index 000000000..c06d0a8c0
--- /dev/null
+++ b/src/boost/libs/asio/test/windows/overlapped_handle.cpp
@@ -0,0 +1,26 @@
+//
+// overlapped_handle.cpp
+// ~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/windows/overlapped_handle.hpp>
+
+#include <boost/asio.hpp>
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "windows/overlapped_handle",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
diff --git a/src/boost/libs/asio/test/windows/overlapped_ptr.cpp b/src/boost/libs/asio/test/windows/overlapped_ptr.cpp
new file mode 100644
index 000000000..da20280b9
--- /dev/null
+++ b/src/boost/libs/asio/test/windows/overlapped_ptr.cpp
@@ -0,0 +1,107 @@
+//
+// overlapped_ptr.cpp
+// ~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/windows/overlapped_ptr.hpp>
+
+#include <boost/asio/executor.hpp>
+#include <boost/asio/io_context.hpp>
+#include "../unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+// windows_overlapped_ptr_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// windows::overlapped_ptr compile and link correctly. Runtime failures are
+// ignored.
+
+namespace windows_overlapped_ptr_compile {
+
+void overlapped_handler_1(const boost::system::error_code&, std::size_t)
+{
+}
+
+struct overlapped_handler_2
+{
+ void operator()(const boost::system::error_code&, std::size_t)
+ {
+ }
+};
+
+void test()
+{
+#if defined(BOOST_ASIO_HAS_WINDOWS_OVERLAPPED_PTR)
+ using namespace boost::asio;
+ namespace win = boost::asio::windows;
+
+ try
+ {
+ io_context ioc;
+ boost::asio::executor ex(ioc.get_executor());
+
+ // basic_overlapped_ptr constructors.
+
+ win::overlapped_ptr ptr1;
+
+ 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(ex, &overlapped_handler_1);
+ win::overlapped_ptr ptr7(ex, overlapped_handler_2());
+
+ // overlapped_ptr functions.
+
+ ptr1.reset();
+
+ 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(ex, &overlapped_handler_1);
+ ptr3.reset(ex, overlapped_handler_2());
+
+ OVERLAPPED* ov1 = ptr1.get();
+ (void)ov1;
+
+ const win::overlapped_ptr& ptr8(ptr1);
+ const OVERLAPPED* ov2 = ptr4.get();
+ (void)ov2;
+
+ OVERLAPPED* ov3 = ptr1.release();
+ (void)ov3;
+
+ boost::system::error_code ec;
+ std::size_t bytes_transferred = 0;
+ ptr1.complete(ec, bytes_transferred);
+ }
+ catch (std::exception&)
+ {
+ }
+#endif // defined(BOOST_ASIO_HAS_WINDOWS_OVERLAPPED_PTR)
+}
+
+} // namespace windows_overlapped_ptr_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "windows/overlapped_ptr",
+ BOOST_ASIO_TEST_CASE(windows_overlapped_ptr_compile::test)
+)
diff --git a/src/boost/libs/asio/test/windows/random_access_handle.cpp b/src/boost/libs/asio/test/windows/random_access_handle.cpp
new file mode 100644
index 000000000..d2edcb0c4
--- /dev/null
+++ b/src/boost/libs/asio/test/windows/random_access_handle.cpp
@@ -0,0 +1,155 @@
+//
+// random_access_handle.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/windows/random_access_handle.hpp>
+
+#include <boost/asio/io_context.hpp>
+#include "../archetypes/async_result.hpp"
+#include "../unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+// windows_random_access_handle_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// windows::random_access_handle compile and link correctly. Runtime failures
+// are ignored.
+
+namespace windows_random_access_handle_compile {
+
+void write_some_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void read_some_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void test()
+{
+#if defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE)
+ using namespace boost::asio;
+ namespace win = boost::asio::windows;
+
+ 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] = "";
+ boost::asio::uint64_t offset = 0;
+ archetypes::lazy_handler lazy;
+ boost::system::error_code ec;
+
+ // basic_random_access_handle constructors.
+
+ win::random_access_handle handle1(ioc);
+ HANDLE native_handle1 = INVALID_HANDLE_VALUE;
+#if defined(BOOST_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
+
+ win::random_access_handle handle3(ioc_ex);
+ HANDLE native_handle2 = INVALID_HANDLE_VALUE;
+ win::random_access_handle handle4(ioc_ex, native_handle2);
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ win::random_access_handle handle5(std::move(handle4));
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_random_access_handle operators.
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ handle1 = win::random_access_handle(ioc);
+ handle1 = std::move(handle4);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_io_object functions.
+
+ windows::random_access_handle::executor_type ex = handle1.get_executor();
+ (void)ex;
+
+ // basic_overlapped_handle functions.
+
+ win::random_access_handle::lowest_layer_type& lowest_layer
+ = handle1.lowest_layer();
+ (void)lowest_layer;
+
+ const win::random_access_handle& handle6 = handle1;
+ const win::random_access_handle::lowest_layer_type& lowest_layer2
+ = handle6.lowest_layer();
+ (void)lowest_layer2;
+
+ HANDLE native_handle3 = INVALID_HANDLE_VALUE;
+ handle1.assign(native_handle3);
+
+ bool is_open = handle1.is_open();
+ (void)is_open;
+
+ handle1.close();
+ handle1.close(ec);
+
+ win::random_access_handle::native_handle_type native_handle4
+ = handle1.native_handle();
+ (void)native_handle4;
+
+ handle1.cancel();
+ handle1.cancel(ec);
+
+ // basic_random_access_handle functions.
+
+ handle1.write_some_at(offset, buffer(mutable_char_buffer));
+ handle1.write_some_at(offset, buffer(const_char_buffer));
+ handle1.write_some_at(offset, buffer(mutable_char_buffer), ec);
+ handle1.write_some_at(offset, buffer(const_char_buffer), ec);
+
+ handle1.async_write_some_at(offset,
+ buffer(mutable_char_buffer), &write_some_handler);
+ handle1.async_write_some_at(offset,
+ buffer(const_char_buffer), &write_some_handler);
+ int i1 = handle1.async_write_some_at(offset,
+ buffer(mutable_char_buffer), lazy);
+ (void)i1;
+ int i2 = handle1.async_write_some_at(offset,
+ buffer(const_char_buffer), lazy);
+ (void)i2;
+
+ handle1.read_some_at(offset, buffer(mutable_char_buffer));
+ handle1.read_some_at(offset, buffer(mutable_char_buffer), ec);
+
+ handle1.async_read_some_at(offset,
+ buffer(mutable_char_buffer), &read_some_handler);
+ int i3 = handle1.async_read_some_at(offset,
+ buffer(mutable_char_buffer), lazy);
+ (void)i3;
+ }
+ catch (std::exception&)
+ {
+ }
+#endif // defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE)
+}
+
+} // namespace windows_random_access_handle_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "windows/random_access_handle",
+ BOOST_ASIO_TEST_CASE(windows_random_access_handle_compile::test)
+)
diff --git a/src/boost/libs/asio/test/windows/stream_handle.cpp b/src/boost/libs/asio/test/windows/stream_handle.cpp
new file mode 100644
index 000000000..a782454c9
--- /dev/null
+++ b/src/boost/libs/asio/test/windows/stream_handle.cpp
@@ -0,0 +1,148 @@
+//
+// stream_handle.cpp
+// ~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/windows/stream_handle.hpp>
+
+#include <boost/asio/io_context.hpp>
+#include "../archetypes/async_result.hpp"
+#include "../unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+// windows_stream_handle_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// windows::stream_handle compile and link correctly. Runtime failures are
+// ignored.
+
+namespace windows_stream_handle_compile {
+
+void write_some_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void read_some_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void test()
+{
+#if defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE)
+ using namespace boost::asio;
+ namespace win = boost::asio::windows;
+
+ 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;
+ boost::system::error_code ec;
+
+ // basic_stream_handle constructors.
+
+ win::stream_handle handle1(ioc);
+ HANDLE native_handle1 = INVALID_HANDLE_VALUE;
+#if defined(BOOST_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
+
+ win::stream_handle handle3(ioc_ex);
+ HANDLE native_handle2 = INVALID_HANDLE_VALUE;
+ win::stream_handle handle4(ioc_ex, native_handle2);
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ win::stream_handle handle5(std::move(handle4));
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_stream_handle operators.
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ handle1 = win::stream_handle(ioc);
+ handle1 = std::move(handle4);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_io_object functions.
+
+ windows::stream_handle::executor_type ex = handle1.get_executor();
+ (void)ex;
+
+ // basic_overlapped_handle functions.
+
+ win::stream_handle::lowest_layer_type& lowest_layer
+ = handle1.lowest_layer();
+ (void)lowest_layer;
+
+ const win::stream_handle& handle6 = handle1;
+ const win::stream_handle::lowest_layer_type& lowest_layer2
+ = handle6.lowest_layer();
+ (void)lowest_layer2;
+
+ HANDLE native_handle3 = INVALID_HANDLE_VALUE;
+ handle1.assign(native_handle3);
+
+ bool is_open = handle1.is_open();
+ (void)is_open;
+
+ handle1.close();
+ handle1.close(ec);
+
+ win::stream_handle::native_handle_type native_handle4
+ = handle1.native_handle();
+ (void)native_handle4;
+
+ handle1.cancel();
+ handle1.cancel(ec);
+
+ // basic_stream_handle functions.
+
+ handle1.write_some(buffer(mutable_char_buffer));
+ handle1.write_some(buffer(const_char_buffer));
+ handle1.write_some(buffer(mutable_char_buffer), ec);
+ handle1.write_some(buffer(const_char_buffer), ec);
+
+ handle1.async_write_some(buffer(mutable_char_buffer), &write_some_handler);
+ handle1.async_write_some(buffer(const_char_buffer), &write_some_handler);
+ int i1 = handle1.async_write_some(buffer(mutable_char_buffer), lazy);
+ (void)i1;
+ int i2 = handle1.async_write_some(buffer(const_char_buffer), lazy);
+ (void)i2;
+
+ handle1.read_some(buffer(mutable_char_buffer));
+ handle1.read_some(buffer(mutable_char_buffer), ec);
+
+ handle1.async_read_some(buffer(mutable_char_buffer), &read_some_handler);
+ int i3 = handle1.async_read_some(buffer(mutable_char_buffer), lazy);
+ (void)i3;
+ }
+ catch (std::exception&)
+ {
+ }
+#endif // defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE)
+}
+
+} // namespace windows_stream_handle_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "windows/stream_handle",
+ BOOST_ASIO_TEST_CASE(windows_stream_handle_compile::test)
+)
diff --git a/src/boost/libs/asio/test/write.cpp b/src/boost/libs/asio/test/write.cpp
new file mode 100644
index 000000000..85d2470e2
--- /dev/null
+++ b/src/boost/libs/asio/test/write.cpp
@@ -0,0 +1,4904 @@
+//
+// write.cpp
+// ~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/write.hpp>
+
+#include <cstring>
+#include <vector>
+#include "archetypes/async_result.hpp"
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/post.hpp>
+#include <boost/asio/streambuf.hpp>
+#include "unit_test.hpp"
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <boost/bind/bind.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <functional>
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+#include <boost/array.hpp>
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+
+#if defined(BOOST_ASIO_HAS_STD_ARRAY)
+# include <array>
+#endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
+
+using namespace std; // For memcmp, memcpy and memset.
+
+class test_stream
+{
+public:
+ typedef boost::asio::io_context::executor_type executor_type;
+
+ test_stream(boost::asio::io_context& io_context)
+ : io_context_(io_context),
+ length_(max_length),
+ position_(0),
+ next_write_length_(max_length)
+ {
+ memset(data_, 0, max_length);
+ }
+
+ executor_type get_executor() BOOST_ASIO_NOEXCEPT
+ {
+ return io_context_.get_executor();
+ }
+
+ void reset(size_t length = max_length)
+ {
+ BOOST_ASIO_CHECK(length <= max_length);
+
+ memset(data_, 0, max_length);
+ length_ = length;
+ position_ = 0;
+ next_write_length_ = length;
+ }
+
+ void next_write_length(size_t length)
+ {
+ next_write_length_ = length;
+ }
+
+ template <typename Iterator>
+ bool check_buffers(Iterator begin, Iterator end, size_t length)
+ {
+ if (length != position_)
+ return false;
+
+ Iterator iter = begin;
+ size_t checked_length = 0;
+ for (; iter != end && checked_length < length; ++iter)
+ {
+ size_t buffer_length = boost::asio::buffer_size(*iter);
+ if (buffer_length > length - checked_length)
+ buffer_length = length - checked_length;
+ if (memcmp(data_ + checked_length, iter->data(), buffer_length) != 0)
+ return false;
+ checked_length += buffer_length;
+ }
+
+ return true;
+ }
+
+ template <typename Const_Buffers>
+ bool check_buffers(const Const_Buffers& buffers, size_t length)
+ {
+ return check_buffers(boost::asio::buffer_sequence_begin(buffers),
+ boost::asio::buffer_sequence_end(buffers), length);
+ }
+
+ template <typename Const_Buffers>
+ size_t write_some(const Const_Buffers& buffers)
+ {
+ size_t n = boost::asio::buffer_copy(
+ boost::asio::buffer(data_, length_) + position_,
+ buffers, next_write_length_);
+ position_ += n;
+ return n;
+ }
+
+ template <typename Const_Buffers>
+ size_t write_some(const Const_Buffers& buffers, boost::system::error_code& ec)
+ {
+ ec = boost::system::error_code();
+ return write_some(buffers);
+ }
+
+ template <typename Const_Buffers, typename Handler>
+ void async_write_some(const Const_Buffers& buffers,
+ BOOST_ASIO_MOVE_ARG(Handler) handler)
+ {
+ size_t bytes_transferred = write_some(buffers);
+ boost::asio::post(get_executor(),
+ boost::asio::detail::bind_handler(
+ BOOST_ASIO_MOVE_CAST(Handler)(handler),
+ boost::system::error_code(), bytes_transferred));
+ }
+
+private:
+ boost::asio::io_context& io_context_;
+ enum { max_length = 8192 };
+ char data_[max_length];
+ size_t length_;
+ size_t position_;
+ size_t next_write_length_;
+};
+
+static const char write_data[]
+ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+static char mutable_write_data[]
+ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+void test_2_arg_zero_buffers_write()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::vector<boost::asio::const_buffer> buffers;
+
+ size_t bytes_transferred = boost::asio::write(s, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == 0);
+}
+
+void test_2_arg_const_buffer_write()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::const_buffer buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ size_t bytes_transferred = boost::asio::write(s, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+}
+
+void test_2_arg_mutable_buffer_write()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(mutable_write_data, sizeof(mutable_write_data));
+
+ s.reset();
+ size_t bytes_transferred = boost::asio::write(s, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+}
+
+void test_2_arg_vector_buffers_write()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::vector<boost::asio::const_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(write_data, 32));
+ buffers.push_back(boost::asio::buffer(write_data, 39) + 32);
+ buffers.push_back(boost::asio::buffer(write_data) + 39);
+
+ s.reset();
+ size_t bytes_transferred = boost::asio::write(s, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+}
+
+void test_2_arg_dynamic_string_write()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::string data;
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb
+ = boost::asio::dynamic_buffer(data, sizeof(write_data));
+ boost::asio::const_buffer buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ size_t bytes_transferred = boost::asio::write(s, sb);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_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 = boost::asio::write(s, sb);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_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 = boost::asio::write(s, sb);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+}
+
+void test_3_arg_nothrow_zero_buffers_write()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::vector<boost::asio::const_buffer> buffers;
+
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::write(s, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == 0);
+ BOOST_ASIO_CHECK(!error);
+}
+
+void test_3_arg_nothrow_const_buffer_write()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::const_buffer buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::write(s, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+void test_3_arg_nothrow_mutable_buffer_write()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(mutable_write_data, sizeof(mutable_write_data));
+
+ s.reset();
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::write(s, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+void test_3_arg_nothrow_vector_buffers_write()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::vector<boost::asio::const_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(write_data, 32));
+ buffers.push_back(boost::asio::buffer(write_data, 39) + 32);
+ buffers.push_back(boost::asio::buffer(write_data) + 39);
+
+ s.reset();
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::write(s, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+void test_3_arg_nothrow_dynamic_string_write()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::string data;
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb
+ = boost::asio::dynamic_buffer(data, sizeof(write_data));
+ boost::asio::const_buffer buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::write(s, sb, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, sb, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, sb, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+bool old_style_transfer_all(const boost::system::error_code& ec,
+ size_t /*bytes_transferred*/)
+{
+ return !!ec;
+}
+
+struct short_transfer
+{
+ short_transfer() {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ short_transfer(short_transfer&&) {}
+#else // defined(BOOST_ASIO_HAS_MOVE)
+ short_transfer(const short_transfer&) {}
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+ size_t operator()(const boost::system::error_code& ec,
+ size_t /*bytes_transferred*/)
+ {
+ return !!ec ? 0 : 3;
+ }
+};
+
+void test_3_arg_const_buffer_write()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::const_buffer buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ size_t bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+}
+
+void test_3_arg_mutable_buffer_write()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(mutable_write_data, sizeof(mutable_write_data));
+
+ s.reset();
+ size_t bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+}
+
+void test_3_arg_vector_buffers_write()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::vector<boost::asio::const_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(write_data, 32));
+ buffers.push_back(boost::asio::buffer(write_data, 39) + 32);
+ buffers.push_back(boost::asio::buffer(write_data) + 39);
+
+ s.reset();
+ size_t bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+}
+
+void test_3_arg_dynamic_string_write()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::string data;
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb
+ = boost::asio::dynamic_buffer(data, sizeof(write_data));
+ boost::asio::const_buffer buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ size_t bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_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 = boost::asio::write(s, sb,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_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 = boost::asio::write(s, sb,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_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 = boost::asio::write(s, sb,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_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 = boost::asio::write(s, sb,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_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 = boost::asio::write(s, sb,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ bytes_transferred = boost::asio::write(s, sb, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_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 = boost::asio::write(s, sb, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_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 = boost::asio::write(s, sb, old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ bytes_transferred = boost::asio::write(s, sb, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_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 = boost::asio::write(s, sb, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_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 = boost::asio::write(s, sb, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+}
+
+void test_4_arg_const_buffer_write()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::const_buffer buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+void test_4_arg_mutable_buffer_write()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(mutable_write_data, sizeof(mutable_write_data));
+
+ s.reset();
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+void test_4_arg_vector_buffers_write()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::vector<boost::asio::const_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(write_data, 32));
+ buffers.push_back(boost::asio::buffer(write_data, 39) + 32);
+ buffers.push_back(boost::asio::buffer(write_data) + 39);
+
+ s.reset();
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write(s, buffers, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, buffers, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+void test_4_arg_dynamic_string_write()
+{
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::string data;
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb
+ = boost::asio::dynamic_buffer(data, sizeof(write_data));
+ boost::asio::const_buffer buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ bytes_transferred = boost::asio::write(s, sb,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ bytes_transferred = boost::asio::write(s, sb, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write(s, sb, short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+void async_write_handler(const boost::system::error_code& e,
+ size_t bytes_transferred, size_t expected_bytes_transferred, bool* called)
+{
+ *called = true;
+ BOOST_ASIO_CHECK(!e);
+ BOOST_ASIO_CHECK(bytes_transferred == expected_bytes_transferred);
+}
+
+void test_3_arg_const_buffer_async_write()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::const_buffer buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ bool called = false;
+ boost::asio::async_write(s, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write(s, buffers, archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+}
+
+void test_3_arg_mutable_buffer_async_write()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(mutable_write_data, sizeof(mutable_write_data));
+
+ s.reset();
+ bool called = false;
+ boost::asio::async_write(s, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write(s, buffers, archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+}
+
+void test_3_arg_boost_array_buffers_async_write()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::array<boost::asio::const_buffer, 2> buffers = { {
+ boost::asio::buffer(write_data, 32),
+ boost::asio::buffer(write_data) + 32 } };
+
+ s.reset();
+ bool called = false;
+ boost::asio::async_write(s, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write(s, buffers, archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+}
+
+void test_3_arg_std_array_buffers_async_write()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+#if defined(BOOST_ASIO_HAS_STD_ARRAY)
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::array<boost::asio::const_buffer, 2> buffers = { {
+ boost::asio::buffer(write_data, 32),
+ boost::asio::buffer(write_data) + 32 } };
+
+ s.reset();
+ bool called = false;
+ boost::asio::async_write(s, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write(s, buffers, archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+#endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
+}
+
+void test_3_arg_vector_buffers_async_write()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::vector<boost::asio::const_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(write_data, 32));
+ buffers.push_back(boost::asio::buffer(write_data, 39) + 32);
+ buffers.push_back(boost::asio::buffer(write_data) + 39);
+
+ s.reset();
+ bool called = false;
+ boost::asio::async_write(s, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write(s, buffers, archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+}
+
+void test_3_arg_dynamic_string_async_write()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::string data;
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb
+ = boost::asio::dynamic_buffer(data, sizeof(write_data));
+ boost::asio::const_buffer buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ bool called = false;
+ boost::asio::async_write(s, sb,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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;
+ boost::asio::async_write(s, sb,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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;
+ boost::asio::async_write(s, sb,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ int i = boost::asio::async_write(s, sb, archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+}
+
+void test_3_arg_streambuf_async_write()
+{
+#if !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::streambuf sb;
+ boost::asio::const_buffer buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ bool called = false;
+ boost::asio::async_write(s, sb,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, sb,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ int i = boost::asio::async_write(s, sb, archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+#endif // !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+}
+
+void test_4_arg_const_buffer_async_write()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::const_buffer buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ bool called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write(s, buffers, short_transfer(),
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+}
+
+void test_4_arg_mutable_buffer_async_write()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(mutable_write_data, sizeof(mutable_write_data));
+
+ s.reset();
+ bool called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write(s, buffers, short_transfer(),
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+}
+
+void test_4_arg_boost_array_buffers_async_write()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::array<boost::asio::const_buffer, 2> buffers = { {
+ boost::asio::buffer(write_data, 32),
+ boost::asio::buffer(write_data) + 32 } };
+
+ s.reset();
+ bool called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write(s, buffers, short_transfer(),
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+}
+
+void test_4_arg_std_array_buffers_async_write()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+#if defined(BOOST_ASIO_HAS_STD_ARRAY)
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::array<boost::asio::const_buffer, 2> buffers = { {
+ boost::asio::buffer(write_data, 32),
+ boost::asio::buffer(write_data) + 32 } };
+
+ s.reset();
+ bool called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write(s, buffers, short_transfer(),
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+#endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
+}
+
+void test_4_arg_vector_buffers_async_write()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::vector<boost::asio::const_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(write_data, 32));
+ buffers.push_back(boost::asio::buffer(write_data, 39) + 32);
+ buffers.push_back(boost::asio::buffer(write_data) + 39);
+
+ s.reset();
+ bool called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write(s, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write(s, buffers, short_transfer(),
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+}
+
+void test_4_arg_dynamic_string_async_write()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ std::string data;
+ boost::asio::dynamic_string_buffer<char, std::string::traits_type,
+ std::string::allocator_type> sb
+ = boost::asio::dynamic_buffer(data, sizeof(write_data));
+ boost::asio::const_buffer buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ bool called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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;
+ boost::asio::async_write(s, sb, boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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;
+ boost::asio::async_write(s, sb, boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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;
+ boost::asio::async_write(s, sb, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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;
+ boost::asio::async_write(s, sb, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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;
+ boost::asio::async_write(s, sb, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_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;
+ boost::asio::async_write(s, sb, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ data.assign(write_data, sizeof(write_data));
+ int i = boost::asio::async_write(s, sb, short_transfer(),
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+}
+
+void test_4_arg_streambuf_async_write()
+{
+#if !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_stream s(ioc);
+ boost::asio::streambuf sb;
+ boost::asio::const_buffer buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ bool called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, sb, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, sb, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ int i = boost::asio::async_write(s, sb, short_transfer(),
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+#endif // !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
+}
+
+BOOST_ASIO_TEST_SUITE
+(
+ "write",
+ BOOST_ASIO_TEST_CASE(test_2_arg_zero_buffers_write)
+ BOOST_ASIO_TEST_CASE(test_2_arg_const_buffer_write)
+ BOOST_ASIO_TEST_CASE(test_2_arg_mutable_buffer_write)
+ BOOST_ASIO_TEST_CASE(test_2_arg_vector_buffers_write)
+ BOOST_ASIO_TEST_CASE(test_2_arg_dynamic_string_write)
+ BOOST_ASIO_TEST_CASE(test_3_arg_nothrow_zero_buffers_write)
+ BOOST_ASIO_TEST_CASE(test_3_arg_nothrow_const_buffer_write)
+ BOOST_ASIO_TEST_CASE(test_3_arg_nothrow_mutable_buffer_write)
+ BOOST_ASIO_TEST_CASE(test_3_arg_nothrow_vector_buffers_write)
+ BOOST_ASIO_TEST_CASE(test_3_arg_nothrow_dynamic_string_write)
+ BOOST_ASIO_TEST_CASE(test_3_arg_const_buffer_write)
+ BOOST_ASIO_TEST_CASE(test_3_arg_mutable_buffer_write)
+ BOOST_ASIO_TEST_CASE(test_3_arg_vector_buffers_write)
+ BOOST_ASIO_TEST_CASE(test_3_arg_dynamic_string_write)
+ BOOST_ASIO_TEST_CASE(test_4_arg_const_buffer_write)
+ BOOST_ASIO_TEST_CASE(test_4_arg_mutable_buffer_write)
+ BOOST_ASIO_TEST_CASE(test_4_arg_vector_buffers_write)
+ BOOST_ASIO_TEST_CASE(test_4_arg_dynamic_string_write)
+ BOOST_ASIO_TEST_CASE(test_3_arg_const_buffer_async_write)
+ BOOST_ASIO_TEST_CASE(test_3_arg_mutable_buffer_async_write)
+ BOOST_ASIO_TEST_CASE(test_3_arg_boost_array_buffers_async_write)
+ BOOST_ASIO_TEST_CASE(test_3_arg_std_array_buffers_async_write)
+ BOOST_ASIO_TEST_CASE(test_3_arg_vector_buffers_async_write)
+ BOOST_ASIO_TEST_CASE(test_3_arg_dynamic_string_async_write)
+ BOOST_ASIO_TEST_CASE(test_3_arg_streambuf_async_write)
+ BOOST_ASIO_TEST_CASE(test_4_arg_const_buffer_async_write)
+ BOOST_ASIO_TEST_CASE(test_4_arg_mutable_buffer_async_write)
+ BOOST_ASIO_TEST_CASE(test_4_arg_boost_array_buffers_async_write)
+ BOOST_ASIO_TEST_CASE(test_4_arg_std_array_buffers_async_write)
+ BOOST_ASIO_TEST_CASE(test_4_arg_vector_buffers_async_write)
+ BOOST_ASIO_TEST_CASE(test_4_arg_dynamic_string_async_write)
+ BOOST_ASIO_TEST_CASE(test_4_arg_streambuf_async_write)
+)
diff --git a/src/boost/libs/asio/test/write_at.cpp b/src/boost/libs/asio/test/write_at.cpp
new file mode 100644
index 000000000..8730491f7
--- /dev/null
+++ b/src/boost/libs/asio/test/write_at.cpp
@@ -0,0 +1,7563 @@
+//
+// write_at.cpp
+// ~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2020 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 <boost/asio/write_at.hpp>
+
+#include <cstring>
+#include "archetypes/async_result.hpp"
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/post.hpp>
+#include <boost/asio/streambuf.hpp>
+#include "unit_test.hpp"
+
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <boost/bind/bind.hpp>
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+# include <functional>
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+#include <boost/array.hpp>
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+
+#if defined(BOOST_ASIO_HAS_STD_ARRAY)
+# include <array>
+#endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
+
+using namespace std; // For memcmp, memcpy and memset.
+
+class test_random_access_device
+{
+public:
+ typedef boost::asio::io_context::executor_type executor_type;
+
+ test_random_access_device(boost::asio::io_context& io_context)
+ : io_context_(io_context),
+ length_(max_length),
+ next_write_length_(max_length)
+ {
+ memset(data_, 0, max_length);
+ }
+
+ executor_type get_executor() BOOST_ASIO_NOEXCEPT
+ {
+ return io_context_.get_executor();
+ }
+
+ void reset()
+ {
+ memset(data_, 0, max_length);
+ next_write_length_ = max_length;
+ }
+
+ void next_write_length(size_t length)
+ {
+ next_write_length_ = length;
+ }
+
+ template <typename Iterator>
+ bool check_buffers(boost::asio::uint64_t offset,
+ Iterator begin, Iterator end, size_t length)
+ {
+ if (offset + length > max_length)
+ return false;
+
+ Iterator iter = begin;
+ size_t checked_length = 0;
+ for (; iter != end && checked_length < length; ++iter)
+ {
+ size_t buffer_length = boost::asio::buffer_size(*iter);
+ if (buffer_length > length - checked_length)
+ buffer_length = length - checked_length;
+ if (memcmp(data_ + offset + checked_length,
+ iter->data(), buffer_length) != 0)
+ return false;
+ checked_length += buffer_length;
+ }
+
+ return true;
+ }
+
+ template <typename Const_Buffers>
+ bool check_buffers(boost::asio::uint64_t offset,
+ const Const_Buffers& buffers, size_t length)
+ {
+ return check_buffers(offset, boost::asio::buffer_sequence_begin(buffers),
+ boost::asio::buffer_sequence_end(buffers), length);
+ }
+
+ template <typename Const_Buffers>
+ size_t write_some_at(boost::asio::uint64_t offset,
+ const Const_Buffers& buffers)
+ {
+ return boost::asio::buffer_copy(
+ boost::asio::buffer(data_, length_) + offset,
+ buffers, next_write_length_);
+ }
+
+ template <typename Const_Buffers>
+ size_t write_some_at(boost::asio::uint64_t offset,
+ const Const_Buffers& buffers, boost::system::error_code& ec)
+ {
+ ec = boost::system::error_code();
+ return write_some_at(offset, buffers);
+ }
+
+ template <typename Const_Buffers, typename Handler>
+ void async_write_some_at(boost::asio::uint64_t offset,
+ const Const_Buffers& buffers, BOOST_ASIO_MOVE_ARG(Handler) handler)
+ {
+ size_t bytes_transferred = write_some_at(offset, buffers);
+ boost::asio::post(get_executor(),
+ boost::asio::detail::bind_handler(
+ BOOST_ASIO_MOVE_CAST(Handler)(handler),
+ boost::system::error_code(), bytes_transferred));
+ }
+
+private:
+ boost::asio::io_context& io_context_;
+ enum { max_length = 8192 };
+ char data_[max_length];
+ size_t length_;
+ size_t next_write_length_;
+};
+
+static const char write_data[]
+ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+static char mutable_write_data[]
+ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+void test_3_arg_const_buffer_write_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ boost::asio::const_buffer buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ size_t bytes_transferred = boost::asio::write_at(s, 0, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+}
+
+void test_3_arg_mutable_buffer_write_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(mutable_write_data, sizeof(mutable_write_data));
+
+ s.reset();
+ size_t bytes_transferred = boost::asio::write_at(s, 0, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+}
+
+void test_3_arg_vector_buffers_write_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ std::vector<boost::asio::const_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(write_data, 32));
+ buffers.push_back(boost::asio::buffer(write_data) + 32);
+
+ s.reset();
+ size_t bytes_transferred = boost::asio::write_at(s, 0, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+}
+
+void test_4_arg_nothrow_const_buffer_write_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ boost::asio::const_buffer buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::write_at(s, 0, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+void test_4_arg_nothrow_mutable_buffer_write_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(mutable_write_data, sizeof(mutable_write_data));
+
+ s.reset();
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::write_at(s, 0, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+void test_4_arg_nothrow_vector_buffers_write_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ std::vector<boost::asio::const_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(write_data, 32));
+ buffers.push_back(boost::asio::buffer(write_data) + 32);
+
+ s.reset();
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::write_at(s, 0, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+bool old_style_transfer_all(const boost::system::error_code& ec,
+ size_t /*bytes_transferred*/)
+{
+ return !!ec;
+}
+
+struct short_transfer
+{
+ short_transfer() {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+ short_transfer(short_transfer&&) {}
+#else // defined(BOOST_ASIO_HAS_MOVE)
+ short_transfer(const short_transfer&) {}
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+ size_t operator()(const boost::system::error_code& ec,
+ size_t /*bytes_transferred*/)
+ {
+ return !!ec ? 0 : 3;
+ }
+};
+
+void test_4_arg_const_buffer_write_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ boost::asio::const_buffer buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ size_t bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 50));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 50));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+}
+
+void test_4_arg_mutable_buffer_write_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(mutable_write_data, sizeof(mutable_write_data));
+
+ s.reset();
+ size_t bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 50));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 50));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+}
+
+void test_4_arg_vector_buffers_write_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ std::vector<boost::asio::const_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(write_data, 32));
+ buffers.push_back(boost::asio::buffer(write_data) + 32);
+
+ s.reset();
+ size_t bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_all());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 50));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 50));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1));
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10));
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42));
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ old_style_transfer_all);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 0, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers, short_transfer());
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+}
+
+void test_5_arg_const_buffer_write_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ boost::asio::const_buffer buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 50));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 50));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+void test_5_arg_mutable_buffer_write_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(mutable_write_data, sizeof(mutable_write_data));
+
+ s.reset();
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 50));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 50));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(mutable_write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+void test_5_arg_vector_buffers_write_at()
+{
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ std::vector<boost::asio::const_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(write_data, 32));
+ buffers.push_back(boost::asio::buffer(write_data) + 32);
+
+ s.reset();
+ boost::system::error_code error;
+ size_t bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_all(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 50));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 50);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 50));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 1);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 10);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42), error);
+ BOOST_ASIO_CHECK(bytes_transferred == 42);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ old_style_transfer_all, error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(1);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 0, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+
+ s.reset();
+ s.next_write_length(10);
+ error = boost::system::error_code();
+ bytes_transferred = boost::asio::write_at(s, 1234, buffers,
+ short_transfer(), error);
+ BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+ BOOST_ASIO_CHECK(!error);
+}
+
+void async_write_handler(const boost::system::error_code& e,
+ size_t bytes_transferred, size_t expected_bytes_transferred, bool* called)
+{
+ *called = true;
+ BOOST_ASIO_CHECK(!e);
+ BOOST_ASIO_CHECK(bytes_transferred == expected_bytes_transferred);
+}
+
+void test_4_arg_const_buffer_async_write_at()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ boost::asio::const_buffer buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ bool called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write_at(s, 0, buffers,
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+}
+
+void test_4_arg_mutable_buffer_async_write_at()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(mutable_write_data, sizeof(mutable_write_data));
+
+ s.reset();
+ bool called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write_at(s, 0, buffers,
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+}
+
+void test_4_arg_boost_array_buffers_async_write_at()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ boost::array<boost::asio::const_buffer, 2> buffers = { {
+ boost::asio::buffer(write_data, 32),
+ boost::asio::buffer(write_data) + 32 } };
+
+ s.reset();
+ bool called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write_at(s, 0, buffers,
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+}
+
+void test_4_arg_std_array_buffers_async_write_at()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+#if defined(BOOST_ASIO_HAS_STD_ARRAY)
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ std::array<boost::asio::const_buffer, 2> buffers = { {
+ boost::asio::buffer(write_data, 32),
+ boost::asio::buffer(write_data) + 32 } };
+
+ s.reset();
+ bool called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write_at(s, 0, buffers,
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+#endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
+}
+
+void test_4_arg_vector_buffers_async_write_at()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ std::vector<boost::asio::const_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(write_data, 32));
+ buffers.push_back(boost::asio::buffer(write_data) + 32);
+
+ s.reset();
+ bool called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write_at(s, 0, buffers,
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+}
+
+void test_4_arg_streambuf_async_write_at()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ boost::asio::streambuf sb;
+ boost::asio::const_buffer buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ bool called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ int i = boost::asio::async_write_at(s, 0, sb,
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+}
+
+void test_5_arg_const_buffer_async_write_at()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ boost::asio::const_buffer buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ bool called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 50));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 50));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write_at(s, 0, buffers, short_transfer(),
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+}
+
+void test_5_arg_mutable_buffer_async_write_at()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ boost::asio::mutable_buffer buffers
+ = boost::asio::buffer(mutable_write_data, sizeof(mutable_write_data));
+
+ s.reset();
+ bool called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 50));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 50));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(mutable_write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write_at(s, 0, buffers, short_transfer(),
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+}
+
+void test_5_arg_boost_array_buffers_async_write_at()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ boost::array<boost::asio::const_buffer, 2> buffers = { {
+ boost::asio::buffer(write_data, 32),
+ boost::asio::buffer(write_data) + 32 } };
+
+ s.reset();
+ bool called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 50));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 50));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write_at(s, 0, buffers, short_transfer(),
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
+}
+
+void test_5_arg_std_array_buffers_async_write_at()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+#if defined(BOOST_ASIO_HAS_STD_ARRAY)
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ std::array<boost::asio::const_buffer, 2> buffers = { {
+ boost::asio::buffer(write_data, 32),
+ boost::asio::buffer(write_data) + 32 } };
+
+ s.reset();
+ bool called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 50));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 50));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write_at(s, 0, buffers, short_transfer(),
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+#endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
+}
+
+void test_5_arg_vector_buffers_async_write_at()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ std::vector<boost::asio::const_buffer> buffers;
+ buffers.push_back(boost::asio::buffer(write_data, 32));
+ buffers.push_back(boost::asio::buffer(write_data) + 32);
+
+ s.reset();
+ bool called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 50));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 50));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, buffers, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write_at(s, 0, buffers, short_transfer(),
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+}
+
+void test_5_arg_streambuf_async_write_at()
+{
+#if defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = boost;
+#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ namespace bindns = std;
+#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
+ using bindns::placeholders::_1;
+ using bindns::placeholders::_2;
+
+ boost::asio::io_context ioc;
+ test_random_access_device s(ioc);
+ boost::asio::streambuf sb;
+ boost::asio::const_buffer buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ bool called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_all(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_at_least(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_at_least(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 50));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_at_least(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 50, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 50));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_exactly(1),
+ bindns::bind(async_write_handler,
+ _1, _2, 1, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_exactly(10),
+ bindns::bind(async_write_handler,
+ _1, _2, 10, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_exactly(42),
+ bindns::bind(async_write_handler,
+ _1, _2, 42, &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 0, sb, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb, old_style_transfer_all,
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 0, sb, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb, short_transfer(),
+ bindns::bind(async_write_handler,
+ _1, _2, sizeof(write_data), &called));
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(called);
+ BOOST_ASIO_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ int i = boost::asio::async_write_at(s, 0, sb, short_transfer(),
+ archetypes::lazy_handler());
+ BOOST_ASIO_CHECK(i == 42);
+ ioc.restart();
+ ioc.run();
+ BOOST_ASIO_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+}
+
+BOOST_ASIO_TEST_SUITE
+(
+ "write_at",
+ BOOST_ASIO_TEST_CASE(test_3_arg_const_buffer_write_at)
+ BOOST_ASIO_TEST_CASE(test_3_arg_mutable_buffer_write_at)
+ BOOST_ASIO_TEST_CASE(test_3_arg_vector_buffers_write_at)
+ BOOST_ASIO_TEST_CASE(test_4_arg_nothrow_const_buffer_write_at)
+ BOOST_ASIO_TEST_CASE(test_4_arg_nothrow_mutable_buffer_write_at)
+ BOOST_ASIO_TEST_CASE(test_4_arg_nothrow_vector_buffers_write_at)
+ BOOST_ASIO_TEST_CASE(test_4_arg_const_buffer_write_at)
+ BOOST_ASIO_TEST_CASE(test_4_arg_mutable_buffer_write_at)
+ BOOST_ASIO_TEST_CASE(test_4_arg_vector_buffers_write_at)
+ BOOST_ASIO_TEST_CASE(test_5_arg_const_buffer_write_at)
+ BOOST_ASIO_TEST_CASE(test_5_arg_mutable_buffer_write_at)
+ BOOST_ASIO_TEST_CASE(test_5_arg_vector_buffers_write_at)
+ BOOST_ASIO_TEST_CASE(test_4_arg_const_buffer_async_write_at)
+ BOOST_ASIO_TEST_CASE(test_4_arg_mutable_buffer_async_write_at)
+ BOOST_ASIO_TEST_CASE(test_4_arg_boost_array_buffers_async_write_at)
+ BOOST_ASIO_TEST_CASE(test_4_arg_std_array_buffers_async_write_at)
+ BOOST_ASIO_TEST_CASE(test_4_arg_vector_buffers_async_write_at)
+ BOOST_ASIO_TEST_CASE(test_4_arg_streambuf_async_write_at)
+ BOOST_ASIO_TEST_CASE(test_5_arg_const_buffer_async_write_at)
+ BOOST_ASIO_TEST_CASE(test_5_arg_mutable_buffer_async_write_at)
+ BOOST_ASIO_TEST_CASE(test_5_arg_boost_array_buffers_async_write_at)
+ BOOST_ASIO_TEST_CASE(test_5_arg_std_array_buffers_async_write_at)
+ BOOST_ASIO_TEST_CASE(test_5_arg_vector_buffers_async_write_at)
+ BOOST_ASIO_TEST_CASE(test_5_arg_streambuf_async_write_at)
+)