Convert to use the Boost testing framework and start adding a unit test for
each public header file.
This commit is contained in:
parent
1960f94b01
commit
1134f50ea4
@ -21,6 +21,7 @@
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
||||
#include "asio/service_factory.hpp"
|
||||
#include "asio/wrapped_handler.hpp"
|
||||
|
||||
namespace asio {
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
#include "asio/detail/socket_types.hpp" // Must come before posix_time include.
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
#include <memory>
|
||||
#include <boost/date_time/posix_time/posix_time_types.hpp>
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
|
||||
#include "asio/detail/socket_types.hpp" // Must come before posix_time include.
|
||||
|
||||
#include "asio/detail/push_options.hpp"
|
||||
#include <boost/date_time/posix_time/posix_time_types.hpp>
|
||||
#include "asio/detail/pop_options.hpp"
|
||||
|
@ -6,12 +6,25 @@ CXXFLAGS = -q -O2 -v -vi -y -a8 -b -Ve- -Vx- -tWM -tWR -tWC -w-inl -w-par -I../i
|
||||
DEFINES = -D_WIN32_WINNT=0x0500 -DBOOST_DATE_TIME_NO_LIB
|
||||
LDFLAGS = -q -O2 -v -vi -y -a8 -b -Ve- -Vx- -tWM -tWR -tWC
|
||||
|
||||
all: \
|
||||
PERFORMANCE_TEST_EXES = \
|
||||
tests\performance\client.exe \
|
||||
tests\performance\server.exe \
|
||||
tests\performance\server.exe
|
||||
|
||||
UNIT_TEST_EXES = \
|
||||
tests\unit\basic_datagram_socket_test.exe \
|
||||
tests\unit\basic_deadline_timer_test.exe \
|
||||
tests\unit\basic_demuxer_test.exe \
|
||||
tests\unit\basic_locking_dispatcher_test.exe \
|
||||
tests\unit\basic_socket_acceptor_test.exe \
|
||||
tests\unit\basic_stream_socket_test.exe \
|
||||
tests\unit\buffer_test.exe \
|
||||
tests\unit\buffered_read_stream.exe \
|
||||
tests\unit\buffered_stream.exe \
|
||||
tests\unit\buffered_write_stream.exe \
|
||||
tests\unit\buffers_test.exe \
|
||||
tests\unit\datagram_socket_test.exe \
|
||||
tests\unit\deadline_timer_test.exe \
|
||||
tests\unit\demuxer_test.exe \
|
||||
tests\unit\datagram_socket_test.exe \
|
||||
tests\unit\error_handler_test.exe \
|
||||
tests\unit\fixed_buffer_test.exe \
|
||||
tests\unit\ipv4_host_resolver_test.exe \
|
||||
@ -21,6 +34,8 @@ all: \
|
||||
tests\unit\read_test.exe \
|
||||
tests\unit\write_test.exe \
|
||||
tests\unit\socket_acceptor_test.exe \
|
||||
|
||||
EXAMPLE_EXES = \
|
||||
examples\chat\chat_client.exe \
|
||||
examples\chat\chat_server.exe \
|
||||
examples\echo\async_tcp_echo_server.exe \
|
||||
@ -48,19 +63,13 @@ all: \
|
||||
examples\tutorial\daytime6\server.exe \
|
||||
examples\tutorial\daytime7\server.exe
|
||||
|
||||
check: all
|
||||
@tests\unit\deadline_timer_test.exe
|
||||
@tests\unit\demuxer_test.exe
|
||||
@tests\unit\datagram_socket_test.exe
|
||||
@tests\unit\error_handler_test.exe
|
||||
@tests\unit\fixed_buffer_test.exe
|
||||
@tests\unit\ipv4_host_resolver_test.exe
|
||||
@tests\unit\is_read_buffered_test.exe
|
||||
@tests\unit\is_write_buffered_test.exe
|
||||
@tests\unit\locking_dispatcher_test.exe
|
||||
@tests\unit\read_test.exe
|
||||
@tests\unit\write_test.exe
|
||||
@tests\unit\socket_acceptor_test.exe
|
||||
all: \
|
||||
$(PERFORMANCE_TEST_EXES) \
|
||||
$(UNIT_TEST_EXES) \
|
||||
$(EXAMPLE_EXES)
|
||||
|
||||
check: $(UNIT_TEST_EXES)
|
||||
!$**
|
||||
|
||||
clean:
|
||||
-del /q /s tests\*.exe
|
||||
|
@ -2,17 +2,30 @@ ifndef BOOSTDIR
|
||||
BOOSTDIR = ../../boost_1_33_0
|
||||
endif
|
||||
|
||||
CXXFLAGS = -g -O3 -Wall -mthreads -I../include -I$(BOOSTDIR)
|
||||
LDFLAGS = -g -O3 -mthreads
|
||||
CXXFLAGS = -g -O2 -Wall -mthreads -I../include -I$(BOOSTDIR)
|
||||
LDFLAGS = -g -O2 -mthreads
|
||||
LIBS = -lws2_32
|
||||
DEFINES = -D_WIN32_WINNT=0x0500
|
||||
|
||||
TEST_EXES = \
|
||||
PERFORMANCE_TEST_EXES = \
|
||||
tests/performance/client.exe \
|
||||
tests/performance/server.exe \
|
||||
tests/performance/server.exe
|
||||
|
||||
UNIT_TEST_EXES = \
|
||||
tests/unit/basic_datagram_socket_test.exe \
|
||||
tests/unit/basic_deadline_timer_test.exe \
|
||||
tests/unit/basic_demuxer_test.exe \
|
||||
tests/unit/basic_locking_dispatcher_test.exe \
|
||||
tests/unit/basic_socket_acceptor_test.exe \
|
||||
tests/unit/basic_stream_socket_test.exe \
|
||||
tests/unit/buffer_test.exe \
|
||||
tests/unit/buffered_read_stream.exe \
|
||||
tests/unit/buffered_stream.exe \
|
||||
tests/unit/buffered_write_stream.exe \
|
||||
tests/unit/buffers_test.exe \
|
||||
tests/unit/datagram_socket_test.exe \
|
||||
tests/unit/deadline_timer_test.exe \
|
||||
tests/unit/demuxer_test.exe \
|
||||
tests/unit/datagram_socket_test.exe \
|
||||
tests/unit/error_handler_test.exe \
|
||||
tests/unit/fixed_buffer_test.exe \
|
||||
tests/unit/ipv4_host_resolver_test.exe \
|
||||
@ -51,29 +64,27 @@ EXAMPLE_EXES = \
|
||||
examples/tutorial/daytime6/server.exe \
|
||||
examples/tutorial/daytime7/server.exe
|
||||
|
||||
all: $(TEST_EXES) $(EXAMPLE_EXES)
|
||||
all: \
|
||||
$(PERFORMANCE_TEST_EXES) \
|
||||
$(UNIT_TEST_EXES) \
|
||||
$(EXAMPLE_EXES)
|
||||
|
||||
check: all
|
||||
@tests/unit/deadline_timer_test.exe
|
||||
@tests/unit/demuxer_test.exe
|
||||
@tests/unit/datagram_socket_test.exe
|
||||
@tests/unit/error_handler_test.exe
|
||||
@tests/unit/fixed_buffer_test.exe
|
||||
@tests/unit/ipv4_host_resolver_test.exe
|
||||
@tests/unit/is_read_buffered_test.exe
|
||||
@tests/unit/is_write_buffered_test.exe
|
||||
@tests/unit/locking_dispatcher_test.exe
|
||||
@tests/unit/read_test.exe
|
||||
@tests/unit/write_test.exe
|
||||
@tests/unit/socket_acceptor_test.exe
|
||||
check: $(UNIT_TEST_EXES) $(addprefix run.,$(UNIT_TEST_EXES))
|
||||
|
||||
$(addprefix run.,$(UNIT_TEST_EXES))::
|
||||
@echo === Running $(@:run.%=%) ===
|
||||
@$(@:run.%=%)
|
||||
@echo.
|
||||
|
||||
clean:
|
||||
-rm -f $(TEST_EXES)
|
||||
-rm -f $(TEST_EXES:.exe=.o)
|
||||
-rm -f $(PERFORMANCE_TEST_EXES)
|
||||
-rm -f $(PERFORMANCE_TEST_EXES:.exe=.o)
|
||||
-rm -f $(UNIT_TEST_EXES)
|
||||
-rm -f $(UNIT_TEST_EXES:.exe=.o)
|
||||
-rm -f $(EXAMPLE_EXES)
|
||||
-rm -f $(EXAMPLE_EXES:.exe=.o)
|
||||
|
||||
$(TEST_EXES) $(EXAMPLE_EXES): %.exe: %.o
|
||||
$(PERFORMANCE_TEST_EXES) $(UNIT_TEST_EXES) $(EXAMPLE_EXES): %.exe: %.o
|
||||
g++ -o$@ $(LDFLAGS) $< $(LIBS)
|
||||
|
||||
.cpp.o:
|
||||
|
@ -2,8 +2,8 @@
|
||||
BOOSTDIR = ../../boost_1_33_0
|
||||
!endif
|
||||
|
||||
COMMON_CXXFLAGS = -nologo -GX -GR -MT -I. -I../include -I$(BOOSTDIR)
|
||||
COMMON_LDFLAGS = -nologo -GX -GR -MT
|
||||
COMMON_CXXFLAGS = -nologo -EHac -GR -MT -I. -I../include -I$(BOOSTDIR)
|
||||
COMMON_LDFLAGS = -nologo -EHac -GR -MT
|
||||
|
||||
!ifdef WARNINGS
|
||||
WARNINGS_CXXFLAGS = -W3
|
||||
@ -26,12 +26,25 @@ DEFINES = -D_WIN32_WINNT=0x0500 -DBOOST_DATE_TIME_NO_LIB
|
||||
CXXFLAGS = $(COMMON_CXXFLAGS) $(WARNINGS_CXXFLAGS) $(DEBUG_CXXFLAGS)
|
||||
LDFLAGS = $(COMMON_LDFLAGS) $(DEBUG_LDFLAGS)
|
||||
|
||||
all: \
|
||||
PERFORMANCE_TEST_EXES = \
|
||||
tests\performance\client.exe \
|
||||
tests\performance\server.exe \
|
||||
tests\performance\server.exe
|
||||
|
||||
UNIT_TEST_EXES = \
|
||||
tests\unit\basic_datagram_socket_test.exe \
|
||||
tests\unit\basic_deadline_timer_test.exe \
|
||||
tests\unit\basic_demuxer_test.exe \
|
||||
tests\unit\basic_locking_dispatcher_test.exe \
|
||||
tests\unit\basic_socket_acceptor_test.exe \
|
||||
tests\unit\basic_stream_socket_test.exe \
|
||||
tests\unit\buffer_test.exe \
|
||||
tests\unit\buffered_read_stream.exe \
|
||||
tests\unit\buffered_stream.exe \
|
||||
tests\unit\buffered_write_stream.exe \
|
||||
tests\unit\buffers_test.exe \
|
||||
tests\unit\datagram_socket_test.exe \
|
||||
tests\unit\deadline_timer_test.exe \
|
||||
tests\unit\demuxer_test.exe \
|
||||
tests\unit\datagram_socket_test.exe \
|
||||
tests\unit\error_handler_test.exe \
|
||||
tests\unit\fixed_buffer_test.exe \
|
||||
tests\unit\ipv4_host_resolver_test.exe \
|
||||
@ -41,6 +54,8 @@ all: \
|
||||
tests\unit\read_test.exe \
|
||||
tests\unit\write_test.exe \
|
||||
tests\unit\socket_acceptor_test.exe \
|
||||
|
||||
EXAMPLE_EXES = \
|
||||
examples\chat\chat_client.exe \
|
||||
examples\chat\chat_server.exe \
|
||||
examples\echo\async_tcp_echo_server.exe \
|
||||
@ -68,60 +83,67 @@ all: \
|
||||
examples\tutorial\daytime6\server.exe \
|
||||
examples\tutorial\daytime7\server.exe
|
||||
|
||||
tests\performance\client.exe: tests\performance\client.obj
|
||||
tests\performance\server.exe: tests\performance\server.obj
|
||||
tests\unit\deadline_timer_test.exe: tests\unit\deadline_timer_test.obj
|
||||
tests\unit\demuxer_test.exe: tests\unit\demuxer_test.obj
|
||||
tests\unit\datagram_socket_test.exe: tests\unit\datagram_socket_test.obj
|
||||
tests\unit\error_handler_test.exe: tests\unit\error_handler_test.obj
|
||||
tests\unit\fixed_buffer_test.exe: tests\unit\fixed_buffer_test.obj
|
||||
tests\unit\ipv4_host_resolver_test.exe: tests\unit\ipv4_host_resolver_test.obj
|
||||
tests\unit\is_read_buffered_test.exe: tests\unit\is_read_buffered_test.obj
|
||||
tests\unit\is_write_buffered_test.exe: tests\unit\is_write_buffered_test.obj
|
||||
tests\unit\locking_dispatcher_test.exe: tests\unit\locking_dispatcher_test.obj
|
||||
tests\unit\read_test.exe: tests\unit\read_test.obj
|
||||
tests\unit\write_test.exe: tests\unit\write_test.obj
|
||||
tests\unit\socket_acceptor_test.exe: tests\unit\socket_acceptor_test.obj
|
||||
examples\chat\chat_client.exe: examples\chat\chat_client.obj
|
||||
examples\chat\chat_server.exe: examples\chat\chat_server.obj
|
||||
examples\echo\async_tcp_echo_server.exe: examples\echo\async_tcp_echo_server.obj
|
||||
examples\echo\async_udp_echo_server.exe: examples\echo\async_udp_echo_server.obj
|
||||
examples\echo\blocking_tcp_echo_client.exe: examples\echo\blocking_tcp_echo_client.obj
|
||||
examples\echo\blocking_tcp_echo_server.exe: examples\echo\blocking_tcp_echo_server.obj
|
||||
examples\echo\blocking_udp_echo_client.exe: examples\echo\blocking_udp_echo_client.obj
|
||||
examples\echo\blocking_udp_echo_server.exe: examples\echo\blocking_udp_echo_server.obj
|
||||
examples\multicast\receiver.exe: examples\multicast\receiver.obj
|
||||
examples\multicast\sender.exe: examples\multicast\sender.obj
|
||||
examples\timeouts\accept_timeout.exe: examples\timeouts\accept_timeout.obj
|
||||
examples\timeouts\connect_timeout.exe: examples\timeouts\connect_timeout.obj
|
||||
examples\timeouts\datagram_receive_timeout.exe: examples\timeouts\datagram_receive_timeout.obj
|
||||
examples\timeouts\stream_receive_timeout.exe: examples\timeouts\stream_receive_timeout.obj
|
||||
examples\tutorial\timer1\timer.exe: examples\tutorial\timer1\timer.obj
|
||||
examples\tutorial\timer2\timer.exe: examples\tutorial\timer2\timer.obj
|
||||
examples\tutorial\timer3\timer.exe: examples\tutorial\timer3\timer.obj
|
||||
examples\tutorial\timer4\timer.exe: examples\tutorial\timer4\timer.obj
|
||||
examples\tutorial\timer5\timer.exe: examples\tutorial\timer5\timer.obj
|
||||
examples\tutorial\daytime1\client.exe: examples\tutorial\daytime1\client.obj
|
||||
examples\tutorial\daytime2\server.exe: examples\tutorial\daytime2\server.obj
|
||||
examples\tutorial\daytime3\server.exe: examples\tutorial\daytime3\server.obj
|
||||
examples\tutorial\daytime4\client.exe: examples\tutorial\daytime4\client.obj
|
||||
examples\tutorial\daytime5\server.exe: examples\tutorial\daytime5\server.obj
|
||||
examples\tutorial\daytime6\server.exe: examples\tutorial\daytime6\server.obj
|
||||
examples\tutorial\daytime7\server.exe: examples\tutorial\daytime7\server.obj
|
||||
all: \
|
||||
$(PERFORMANCE_TEST_EXES) \
|
||||
$(UNIT_TEST_EXES) \
|
||||
$(EXAMPLE_EXES)
|
||||
|
||||
check: all
|
||||
@tests\unit\deadline_timer_test.exe && \
|
||||
tests\unit\demuxer_test.exe && \
|
||||
tests\unit\datagram_socket_test.exe && \
|
||||
tests\unit\error_handler_test.exe && \
|
||||
tests\unit\fixed_buffer_test.exe && \
|
||||
tests\unit\ipv4_host_resolver_test.exe && \
|
||||
tests\unit\is_read_buffered_test.exe && \
|
||||
tests\unit\is_write_buffered_test.exe && \
|
||||
tests\unit\locking_dispatcher_test.exe && \
|
||||
tests\unit\read_test.exe && \
|
||||
tests\unit\write_test.exe && \
|
||||
tests\unit\socket_acceptor_test.exe
|
||||
check: $(UNIT_TEST_EXES)
|
||||
!@echo === Running $** === && $** && echo.
|
||||
|
||||
{tests\performance}.cpp{tests\performance}.exe:
|
||||
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< -link -opt:ref
|
||||
|
||||
{tests\unit}.cpp{tests\unit}.exe:
|
||||
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< -link -opt:ref
|
||||
|
||||
{examples\chat}.cpp{examples\chat}.exe:
|
||||
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< -link -opt:ref
|
||||
|
||||
{examples\echo}.cpp{examples\echo}.exe:
|
||||
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< -link -opt:ref
|
||||
|
||||
{examples\multicast}.cpp{examples\multicast}.exe:
|
||||
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< -link -opt:ref
|
||||
|
||||
{examples\timeouts}.cpp{examples\timeouts}.exe:
|
||||
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< -link -opt:ref
|
||||
|
||||
{examples\tutorial\timer1}.cpp{examples\tutorial\timer1}.exe:
|
||||
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< -link -opt:ref
|
||||
|
||||
{examples\tutorial\timer2}.cpp{examples\tutorial\timer2}.exe:
|
||||
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< -link -opt:ref
|
||||
|
||||
{examples\tutorial\timer3}.cpp{examples\tutorial\timer3}.exe:
|
||||
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< -link -opt:ref
|
||||
|
||||
{examples\tutorial\timer4}.cpp{examples\tutorial\timer4}.exe:
|
||||
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< -link -opt:ref
|
||||
|
||||
{examples\tutorial\timer5}.cpp{examples\tutorial\timer5}.exe:
|
||||
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< -link -opt:ref
|
||||
|
||||
{examples\tutorial\daytime1}.cpp{examples\tutorial\daytime1}.exe:
|
||||
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< -link -opt:ref
|
||||
|
||||
{examples\tutorial\daytime2}.cpp{examples\tutorial\daytime2}.exe:
|
||||
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< -link -opt:ref
|
||||
|
||||
{examples\tutorial\daytime3}.cpp{examples\tutorial\daytime3}.exe:
|
||||
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< -link -opt:ref
|
||||
|
||||
{examples\tutorial\daytime4}.cpp{examples\tutorial\daytime4}.exe:
|
||||
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< -link -opt:ref
|
||||
|
||||
{examples\tutorial\daytime5}.cpp{examples\tutorial\daytime5}.exe:
|
||||
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< -link -opt:ref
|
||||
|
||||
{examples\tutorial\daytime6}.cpp{examples\tutorial\daytime6}.exe:
|
||||
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< -link -opt:ref
|
||||
|
||||
{examples\tutorial\daytime7}.cpp{examples\tutorial\daytime7}.exe:
|
||||
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< -link -opt:ref
|
||||
|
||||
clean:
|
||||
-del /q /s tests\*.exe
|
||||
|
20
asio/src/tests/unit/basic_datagram_socket_test.cpp
Normal file
20
asio/src/tests/unit/basic_datagram_socket_test.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
//
|
||||
// basic_datagram_socket_test.cpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2005 Christopher M. Kohlhoff (chris@kohlhoff.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/basic_datagram_socket.hpp"
|
||||
|
||||
#include "unit_test.hpp"
|
||||
|
||||
test_suite* init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE("basic_datagram_socket");
|
||||
return test;
|
||||
}
|
20
asio/src/tests/unit/basic_deadline_timer_test.cpp
Normal file
20
asio/src/tests/unit/basic_deadline_timer_test.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
//
|
||||
// basic_deadline_timer_test.cpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2005 Christopher M. Kohlhoff (chris@kohlhoff.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/basic_deadline_timer.hpp"
|
||||
|
||||
#include "unit_test.hpp"
|
||||
|
||||
test_suite* init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE("basic_deadline_timer");
|
||||
return test;
|
||||
}
|
20
asio/src/tests/unit/basic_demuxer_test.cpp
Normal file
20
asio/src/tests/unit/basic_demuxer_test.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
//
|
||||
// basic_demuxer_test.cpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2005 Christopher M. Kohlhoff (chris@kohlhoff.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/basic_demuxer.hpp"
|
||||
|
||||
#include "unit_test.hpp"
|
||||
|
||||
test_suite* init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE("basic_demuxer");
|
||||
return test;
|
||||
}
|
20
asio/src/tests/unit/basic_locking_dispatcher_test.cpp
Normal file
20
asio/src/tests/unit/basic_locking_dispatcher_test.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
//
|
||||
// basic_locking_dispatcher_test.cpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2005 Christopher M. Kohlhoff (chris@kohlhoff.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/basic_locking_dispatcher.hpp"
|
||||
|
||||
#include "unit_test.hpp"
|
||||
|
||||
test_suite* init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE("basic_locking_dispatcher");
|
||||
return test;
|
||||
}
|
20
asio/src/tests/unit/basic_socket_acceptor_test.cpp
Normal file
20
asio/src/tests/unit/basic_socket_acceptor_test.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
//
|
||||
// basic_socket_acceptor_test.cpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2005 Christopher M. Kohlhoff (chris@kohlhoff.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/basic_socket_acceptor.hpp"
|
||||
|
||||
#include "unit_test.hpp"
|
||||
|
||||
test_suite* init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE("basic_socket_acceptor");
|
||||
return test;
|
||||
}
|
20
asio/src/tests/unit/basic_stream_socket_test.cpp
Normal file
20
asio/src/tests/unit/basic_stream_socket_test.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
//
|
||||
// basic_stream_socket_test.cpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2005 Christopher M. Kohlhoff (chris@kohlhoff.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/basic_stream_socket.hpp"
|
||||
|
||||
#include "unit_test.hpp"
|
||||
|
||||
test_suite* init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE("basic_stream_socket");
|
||||
return test;
|
||||
}
|
20
asio/src/tests/unit/buffer_test.cpp
Normal file
20
asio/src/tests/unit/buffer_test.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
//
|
||||
// buffer_test.cpp
|
||||
// ~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2005 Christopher M. Kohlhoff (chris@kohlhoff.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/buffer.hpp"
|
||||
|
||||
#include "unit_test.hpp"
|
||||
|
||||
test_suite* init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE("buffer");
|
||||
return test;
|
||||
}
|
20
asio/src/tests/unit/buffered_read_stream_test.cpp
Normal file
20
asio/src/tests/unit/buffered_read_stream_test.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
//
|
||||
// buffered_read_stream_test.cpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2005 Christopher M. Kohlhoff (chris@kohlhoff.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/buffered_read_stream.hpp"
|
||||
|
||||
#include "unit_test.hpp"
|
||||
|
||||
test_suite* init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE("buffered_read_stream");
|
||||
return test;
|
||||
}
|
20
asio/src/tests/unit/buffered_stream_test.cpp
Normal file
20
asio/src/tests/unit/buffered_stream_test.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
//
|
||||
// buffered_stream_test.cpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2005 Christopher M. Kohlhoff (chris@kohlhoff.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/buffered_stream.hpp"
|
||||
|
||||
#include "unit_test.hpp"
|
||||
|
||||
test_suite* init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE("buffered_stream");
|
||||
return test;
|
||||
}
|
20
asio/src/tests/unit/buffered_write_stream_test.cpp
Normal file
20
asio/src/tests/unit/buffered_write_stream_test.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
//
|
||||
// buffered_write_stream_test.cpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2005 Christopher M. Kohlhoff (chris@kohlhoff.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/buffered_write_stream.hpp"
|
||||
|
||||
#include "unit_test.hpp"
|
||||
|
||||
test_suite* init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE("buffered_write_stream");
|
||||
return test;
|
||||
}
|
20
asio/src/tests/unit/buffers_test.cpp
Normal file
20
asio/src/tests/unit/buffers_test.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
//
|
||||
// buffers_test.cpp
|
||||
// ~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2005 Christopher M. Kohlhoff (chris@kohlhoff.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/buffers.hpp"
|
||||
|
||||
#include "unit_test.hpp"
|
||||
|
||||
test_suite* init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE("buffers");
|
||||
return test;
|
||||
}
|
@ -8,6 +8,9 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/datagram_socket.hpp"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <cstring>
|
||||
#include "asio.hpp"
|
||||
@ -18,15 +21,15 @@ using namespace asio;
|
||||
void handle_send(size_t expected_bytes_sent, const error& err,
|
||||
size_t bytes_sent)
|
||||
{
|
||||
UNIT_TEST_CHECK(!err);
|
||||
UNIT_TEST_CHECK(expected_bytes_sent == bytes_sent);
|
||||
BOOST_CHECK(!err);
|
||||
BOOST_CHECK(expected_bytes_sent == bytes_sent);
|
||||
}
|
||||
|
||||
void handle_recv(size_t expected_bytes_recvd, const error& err,
|
||||
size_t bytes_recvd)
|
||||
{
|
||||
UNIT_TEST_CHECK(!err);
|
||||
UNIT_TEST_CHECK(expected_bytes_recvd == bytes_recvd);
|
||||
BOOST_CHECK(!err);
|
||||
BOOST_CHECK(expected_bytes_recvd == bytes_recvd);
|
||||
}
|
||||
|
||||
void datagram_socket_test()
|
||||
@ -51,8 +54,8 @@ void datagram_socket_test()
|
||||
size_t bytes_recvd = s1.receive_from(buffers(recv_msg, sizeof(recv_msg)), 0,
|
||||
sender_endpoint);
|
||||
|
||||
UNIT_TEST_CHECK(bytes_recvd == sizeof(send_msg));
|
||||
UNIT_TEST_CHECK(memcmp(send_msg, recv_msg, sizeof(send_msg)) == 0);
|
||||
BOOST_CHECK(bytes_recvd == sizeof(send_msg));
|
||||
BOOST_CHECK(memcmp(send_msg, recv_msg, sizeof(send_msg)) == 0);
|
||||
|
||||
memset(recv_msg, 0, sizeof(recv_msg));
|
||||
|
||||
@ -66,7 +69,12 @@ void datagram_socket_test()
|
||||
|
||||
d.run();
|
||||
|
||||
UNIT_TEST_CHECK(memcmp(send_msg, recv_msg, sizeof(send_msg)) == 0);
|
||||
BOOST_CHECK(memcmp(send_msg, recv_msg, sizeof(send_msg)) == 0);
|
||||
}
|
||||
|
||||
UNIT_TEST(datagram_socket_test)
|
||||
test_suite* init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE("datagram_socket");
|
||||
test->add(BOOST_TEST_CASE(&datagram_socket_test));
|
||||
return test;
|
||||
}
|
||||
|
@ -8,6 +8,9 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/deadline_timer.hpp"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include "asio.hpp"
|
||||
#include "unit_test.hpp"
|
||||
@ -31,7 +34,7 @@ void decrement_to_zero(asio::deadline_timer* t, int* count)
|
||||
t->async_wait(boost::bind(decrement_to_zero, t, count));
|
||||
|
||||
// Completion cannot nest, so count value should remain unchanged.
|
||||
UNIT_TEST_CHECK(*count == before_value);
|
||||
BOOST_CHECK(*count == before_value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,7 +47,7 @@ void increment_if_not_cancelled(int* count, const asio::error& e)
|
||||
void cancel_timer(asio::deadline_timer* t)
|
||||
{
|
||||
int num_cancelled = t->cancel();
|
||||
UNIT_TEST_CHECK(num_cancelled == 1);
|
||||
BOOST_CHECK(num_cancelled == 1);
|
||||
}
|
||||
|
||||
ptime now()
|
||||
@ -65,7 +68,7 @@ void deadline_timer_test()
|
||||
// The timer must block until after its expiry time.
|
||||
ptime end = now();
|
||||
ptime expected_end = start + seconds(1);
|
||||
UNIT_TEST_CHECK(expected_end < end || expected_end == end);
|
||||
BOOST_CHECK(expected_end < end || expected_end == end);
|
||||
|
||||
start = now();
|
||||
|
||||
@ -75,7 +78,7 @@ void deadline_timer_test()
|
||||
// The timer must block until after its expiry time.
|
||||
end = now();
|
||||
expected_end = start + seconds(1) + microseconds(500000);
|
||||
UNIT_TEST_CHECK(expected_end < end || expected_end == end);
|
||||
BOOST_CHECK(expected_end < end || expected_end == end);
|
||||
|
||||
t2.expires_at(t2.expires_at() + seconds(1));
|
||||
t2.wait();
|
||||
@ -83,7 +86,7 @@ void deadline_timer_test()
|
||||
// The timer must block until after its expiry time.
|
||||
end = now();
|
||||
expected_end += seconds(1);
|
||||
UNIT_TEST_CHECK(expected_end < end || expected_end == end);
|
||||
BOOST_CHECK(expected_end < end || expected_end == end);
|
||||
|
||||
start = now();
|
||||
|
||||
@ -93,7 +96,7 @@ void deadline_timer_test()
|
||||
// The timer must block until after its expiry time.
|
||||
end = now();
|
||||
expected_end = start + seconds(1) + microseconds(200000);
|
||||
UNIT_TEST_CHECK(expected_end < end || expected_end == end);
|
||||
BOOST_CHECK(expected_end < end || expected_end == end);
|
||||
|
||||
start = now();
|
||||
|
||||
@ -101,16 +104,16 @@ void deadline_timer_test()
|
||||
t3.async_wait(boost::bind(increment, &count));
|
||||
|
||||
// No completions can be delivered until run() is called.
|
||||
UNIT_TEST_CHECK(count == 0);
|
||||
BOOST_CHECK(count == 0);
|
||||
|
||||
d.run();
|
||||
|
||||
// The run() call will not return until all operations have finished, and
|
||||
// this should not be until after the timer's expiry time.
|
||||
UNIT_TEST_CHECK(count == 1);
|
||||
BOOST_CHECK(count == 1);
|
||||
end = now();
|
||||
expected_end = start + seconds(1);
|
||||
UNIT_TEST_CHECK(expected_end < end || expected_end == end);
|
||||
BOOST_CHECK(expected_end < end || expected_end == end);
|
||||
|
||||
count = 3;
|
||||
start = now();
|
||||
@ -119,17 +122,17 @@ void deadline_timer_test()
|
||||
t4.async_wait(boost::bind(decrement_to_zero, &t4, &count));
|
||||
|
||||
// No completions can be delivered until run() is called.
|
||||
UNIT_TEST_CHECK(count == 3);
|
||||
BOOST_CHECK(count == 3);
|
||||
|
||||
d.reset();
|
||||
d.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.
|
||||
UNIT_TEST_CHECK(count == 0);
|
||||
BOOST_CHECK(count == 0);
|
||||
end = now();
|
||||
expected_end = start + seconds(3);
|
||||
UNIT_TEST_CHECK(expected_end < end || expected_end == end);
|
||||
BOOST_CHECK(expected_end < end || expected_end == end);
|
||||
|
||||
count = 0;
|
||||
start = now();
|
||||
@ -141,7 +144,7 @@ void deadline_timer_test()
|
||||
t6.async_wait(boost::bind(cancel_timer, &t5));
|
||||
|
||||
// No completions can be delivered until run() is called.
|
||||
UNIT_TEST_CHECK(count == 0);
|
||||
BOOST_CHECK(count == 0);
|
||||
|
||||
d.reset();
|
||||
d.run();
|
||||
@ -149,10 +152,10 @@ void deadline_timer_test()
|
||||
// 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).
|
||||
UNIT_TEST_CHECK(count == 0);
|
||||
BOOST_CHECK(count == 0);
|
||||
end = now();
|
||||
expected_end = start + seconds(2);
|
||||
UNIT_TEST_CHECK(end < expected_end);
|
||||
BOOST_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.
|
||||
@ -164,10 +167,15 @@ void deadline_timer_test()
|
||||
|
||||
// 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.
|
||||
UNIT_TEST_CHECK(count == 1);
|
||||
BOOST_CHECK(count == 1);
|
||||
end = now();
|
||||
expected_end = start + seconds(10);
|
||||
UNIT_TEST_CHECK(expected_end < end);
|
||||
BOOST_CHECK(expected_end < end);
|
||||
}
|
||||
|
||||
UNIT_TEST(deadline_timer_test)
|
||||
test_suite* init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE("deadline_timer");
|
||||
test->add(BOOST_TEST_CASE(&deadline_timer_test));
|
||||
return test;
|
||||
}
|
||||
|
@ -8,6 +8,9 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/demuxer.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <boost/bind.hpp>
|
||||
#include "asio.hpp"
|
||||
@ -30,7 +33,7 @@ void decrement_to_zero(demuxer* d, int* count)
|
||||
d->post(boost::bind(decrement_to_zero, d, count));
|
||||
|
||||
// Handler execution cannot nest, so count value should remain unchanged.
|
||||
UNIT_TEST_CHECK(*count == before_value);
|
||||
BOOST_CHECK(*count == before_value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,7 +46,7 @@ void nested_decrement_to_zero(demuxer* d, int* count)
|
||||
d->dispatch(boost::bind(nested_decrement_to_zero, d, count));
|
||||
|
||||
// Handler execution is nested, so count value should now be zero.
|
||||
UNIT_TEST_CHECK(*count == 0);
|
||||
BOOST_CHECK(*count == 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,12 +82,12 @@ void demuxer_test()
|
||||
d.post(boost::bind(increment, &count));
|
||||
|
||||
// No handlers can be called until run() is called.
|
||||
UNIT_TEST_CHECK(count == 0);
|
||||
BOOST_CHECK(count == 0);
|
||||
|
||||
d.run();
|
||||
|
||||
// The run() call will not return until all work has finished.
|
||||
UNIT_TEST_CHECK(count == 1);
|
||||
BOOST_CHECK(count == 1);
|
||||
|
||||
count = 0;
|
||||
d.reset();
|
||||
@ -95,12 +98,12 @@ void demuxer_test()
|
||||
d.post(boost::bind(increment, &count));
|
||||
|
||||
// No handlers can be called until run() is called.
|
||||
UNIT_TEST_CHECK(count == 0);
|
||||
BOOST_CHECK(count == 0);
|
||||
|
||||
d.run();
|
||||
|
||||
// The run() call will not return until all work has finished.
|
||||
UNIT_TEST_CHECK(count == 5);
|
||||
BOOST_CHECK(count == 5);
|
||||
|
||||
count = 0;
|
||||
d.reset();
|
||||
@ -109,43 +112,43 @@ void demuxer_test()
|
||||
d.run();
|
||||
|
||||
// The only operation executed should have been to interrupt run().
|
||||
UNIT_TEST_CHECK(count == 0);
|
||||
BOOST_CHECK(count == 0);
|
||||
|
||||
d.reset();
|
||||
d.post(boost::bind(increment, &count));
|
||||
delete w;
|
||||
|
||||
// No handlers can be called until run() is called.
|
||||
UNIT_TEST_CHECK(count == 0);
|
||||
BOOST_CHECK(count == 0);
|
||||
|
||||
d.run();
|
||||
|
||||
// The run() call will not return until all work has finished.
|
||||
UNIT_TEST_CHECK(count == 1);
|
||||
BOOST_CHECK(count == 1);
|
||||
|
||||
count = 10;
|
||||
d.reset();
|
||||
d.post(boost::bind(decrement_to_zero, &d, &count));
|
||||
|
||||
// No handlers can be called until run() is called.
|
||||
UNIT_TEST_CHECK(count == 10);
|
||||
BOOST_CHECK(count == 10);
|
||||
|
||||
d.run();
|
||||
|
||||
// The run() call will not return until all work has finished.
|
||||
UNIT_TEST_CHECK(count == 0);
|
||||
BOOST_CHECK(count == 0);
|
||||
|
||||
count = 10;
|
||||
d.reset();
|
||||
d.post(boost::bind(nested_decrement_to_zero, &d, &count));
|
||||
|
||||
// No handlers can be called until run() is called.
|
||||
UNIT_TEST_CHECK(count == 10);
|
||||
BOOST_CHECK(count == 10);
|
||||
|
||||
d.run();
|
||||
|
||||
// The run() call will not return until all work has finished.
|
||||
UNIT_TEST_CHECK(count == 0);
|
||||
BOOST_CHECK(count == 0);
|
||||
|
||||
count = 10;
|
||||
d.reset();
|
||||
@ -153,12 +156,12 @@ void demuxer_test()
|
||||
|
||||
// No handlers can be called until run() is called, even though nested
|
||||
// delivery was specifically allowed in the previous call.
|
||||
UNIT_TEST_CHECK(count == 10);
|
||||
BOOST_CHECK(count == 10);
|
||||
|
||||
d.run();
|
||||
|
||||
// The run() call will not return until all work has finished.
|
||||
UNIT_TEST_CHECK(count == 0);
|
||||
BOOST_CHECK(count == 0);
|
||||
|
||||
count = 0;
|
||||
int count2 = 0;
|
||||
@ -171,8 +174,8 @@ void demuxer_test()
|
||||
thread2.join();
|
||||
|
||||
// The run() calls will not return until all work has finished.
|
||||
UNIT_TEST_CHECK(count == 3);
|
||||
UNIT_TEST_CHECK(count2 == 3);
|
||||
BOOST_CHECK(count == 3);
|
||||
BOOST_CHECK(count2 == 3);
|
||||
|
||||
count = 10;
|
||||
demuxer d2;
|
||||
@ -182,12 +185,12 @@ void demuxer_test()
|
||||
|
||||
// No decrement_to_zero handlers can be called until run() is called on the
|
||||
// second demuxer object.
|
||||
UNIT_TEST_CHECK(count == 10);
|
||||
BOOST_CHECK(count == 10);
|
||||
|
||||
d2.run();
|
||||
|
||||
// The run() call will not return until all work has finished.
|
||||
UNIT_TEST_CHECK(count == 0);
|
||||
BOOST_CHECK(count == 0);
|
||||
|
||||
count = 0;
|
||||
int exception_count = 0;
|
||||
@ -199,8 +202,8 @@ void demuxer_test()
|
||||
d.post(boost::bind(increment, &count));
|
||||
|
||||
// No handlers can be called until run() is called.
|
||||
UNIT_TEST_CHECK(count == 0);
|
||||
UNIT_TEST_CHECK(exception_count == 0);
|
||||
BOOST_CHECK(count == 0);
|
||||
BOOST_CHECK(exception_count == 0);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
@ -216,8 +219,8 @@ void demuxer_test()
|
||||
}
|
||||
|
||||
// The run() calls will not return until all work has finished.
|
||||
UNIT_TEST_CHECK(count == 3);
|
||||
UNIT_TEST_CHECK(exception_count == 2);
|
||||
BOOST_CHECK(count == 3);
|
||||
BOOST_CHECK(exception_count == 2);
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
// Use a non-default allocator type.
|
||||
@ -231,4 +234,9 @@ void demuxer_test()
|
||||
#endif // !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
}
|
||||
|
||||
UNIT_TEST(demuxer_test)
|
||||
test_suite* init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE("demuxer");
|
||||
test->add(BOOST_TEST_CASE(&demuxer_test));
|
||||
return test;
|
||||
}
|
||||
|
@ -8,6 +8,9 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/error_handler.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include "asio.hpp"
|
||||
#include "unit_test.hpp"
|
||||
@ -26,36 +29,36 @@ void error_handler_test()
|
||||
|
||||
std::ostringstream os;
|
||||
s.connect(endpoint, log_error(os));
|
||||
UNIT_TEST_CHECK(!os.str().empty());
|
||||
BOOST_CHECK(!os.str().empty());
|
||||
|
||||
os.str("");
|
||||
s.connect(endpoint, the_error == expected_err || log_error(os));
|
||||
UNIT_TEST_CHECK(os.str().empty());
|
||||
BOOST_CHECK(os.str().empty());
|
||||
|
||||
os.str("");
|
||||
s.connect(endpoint, the_error == expected_err && log_error(os));
|
||||
UNIT_TEST_CHECK(!os.str().empty());
|
||||
BOOST_CHECK(!os.str().empty());
|
||||
|
||||
os.str("");
|
||||
s.connect(endpoint, the_error != expected_err || log_error(os));
|
||||
UNIT_TEST_CHECK(!os.str().empty());
|
||||
BOOST_CHECK(!os.str().empty());
|
||||
|
||||
os.str("");
|
||||
s.connect(endpoint, the_error != expected_err && log_error(os));
|
||||
UNIT_TEST_CHECK(os.str().empty());
|
||||
BOOST_CHECK(os.str().empty());
|
||||
|
||||
os.str("");
|
||||
s.connect(endpoint, log_error_if(os, the_error == expected_err));
|
||||
UNIT_TEST_CHECK(!os.str().empty());
|
||||
BOOST_CHECK(!os.str().empty());
|
||||
|
||||
os.str("");
|
||||
s.connect(endpoint, log_error_if(os, the_error != expected_err));
|
||||
UNIT_TEST_CHECK(os.str().empty());
|
||||
BOOST_CHECK(os.str().empty());
|
||||
|
||||
try
|
||||
{
|
||||
s.connect(endpoint, throw_error());
|
||||
UNIT_TEST_CHECK(0);
|
||||
BOOST_CHECK(0);
|
||||
}
|
||||
catch (error&)
|
||||
{
|
||||
@ -67,13 +70,13 @@ void error_handler_test()
|
||||
}
|
||||
catch (error&)
|
||||
{
|
||||
UNIT_TEST_CHECK(0);
|
||||
BOOST_CHECK(0);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
s.connect(endpoint, the_error == expected_err && throw_error());
|
||||
UNIT_TEST_CHECK(0);
|
||||
BOOST_CHECK(0);
|
||||
}
|
||||
catch (error&)
|
||||
{
|
||||
@ -82,7 +85,7 @@ void error_handler_test()
|
||||
try
|
||||
{
|
||||
s.connect(endpoint, the_error != expected_err || throw_error());
|
||||
UNIT_TEST_CHECK(0);
|
||||
BOOST_CHECK(0);
|
||||
}
|
||||
catch (error&)
|
||||
{
|
||||
@ -94,13 +97,13 @@ void error_handler_test()
|
||||
}
|
||||
catch (error&)
|
||||
{
|
||||
UNIT_TEST_CHECK(0);
|
||||
BOOST_CHECK(0);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
s.connect(endpoint, throw_error_if(the_error == expected_err));
|
||||
UNIT_TEST_CHECK(0);
|
||||
BOOST_CHECK(0);
|
||||
}
|
||||
catch (error&)
|
||||
{
|
||||
@ -112,30 +115,30 @@ void error_handler_test()
|
||||
}
|
||||
catch (error&)
|
||||
{
|
||||
UNIT_TEST_CHECK(0);
|
||||
BOOST_CHECK(0);
|
||||
}
|
||||
|
||||
error err;
|
||||
s.connect(endpoint, set_error(err));
|
||||
UNIT_TEST_CHECK(err == expected_err);
|
||||
BOOST_CHECK(err == expected_err);
|
||||
|
||||
s.connect(endpoint, the_error == expected_err || set_error(err));
|
||||
UNIT_TEST_CHECK(err != expected_err);
|
||||
BOOST_CHECK(err != expected_err);
|
||||
|
||||
s.connect(endpoint, the_error == expected_err && set_error(err));
|
||||
UNIT_TEST_CHECK(err == expected_err);
|
||||
BOOST_CHECK(err == expected_err);
|
||||
|
||||
s.connect(endpoint, the_error != expected_err || set_error(err));
|
||||
UNIT_TEST_CHECK(err == expected_err);
|
||||
BOOST_CHECK(err == expected_err);
|
||||
|
||||
s.connect(endpoint, the_error != expected_err && set_error(err));
|
||||
UNIT_TEST_CHECK(err != expected_err);
|
||||
BOOST_CHECK(err != expected_err);
|
||||
|
||||
s.connect(endpoint, set_error_if(err, the_error == expected_err));
|
||||
UNIT_TEST_CHECK(err == expected_err);
|
||||
BOOST_CHECK(err == expected_err);
|
||||
|
||||
s.connect(endpoint, set_error_if(err, the_error != expected_err));
|
||||
UNIT_TEST_CHECK(err != expected_err);
|
||||
BOOST_CHECK(err != expected_err);
|
||||
|
||||
try
|
||||
{
|
||||
@ -143,7 +146,7 @@ void error_handler_test()
|
||||
}
|
||||
catch (error&)
|
||||
{
|
||||
UNIT_TEST_CHECK(0);
|
||||
BOOST_CHECK(0);
|
||||
}
|
||||
|
||||
try
|
||||
@ -152,7 +155,7 @@ void error_handler_test()
|
||||
}
|
||||
catch (error&)
|
||||
{
|
||||
UNIT_TEST_CHECK(0);
|
||||
BOOST_CHECK(0);
|
||||
}
|
||||
|
||||
try
|
||||
@ -161,7 +164,7 @@ void error_handler_test()
|
||||
}
|
||||
catch (error&)
|
||||
{
|
||||
UNIT_TEST_CHECK(0);
|
||||
BOOST_CHECK(0);
|
||||
}
|
||||
|
||||
try
|
||||
@ -170,7 +173,7 @@ void error_handler_test()
|
||||
}
|
||||
catch (error&)
|
||||
{
|
||||
UNIT_TEST_CHECK(0);
|
||||
BOOST_CHECK(0);
|
||||
}
|
||||
|
||||
try
|
||||
@ -179,7 +182,7 @@ void error_handler_test()
|
||||
}
|
||||
catch (error&)
|
||||
{
|
||||
UNIT_TEST_CHECK(0);
|
||||
BOOST_CHECK(0);
|
||||
}
|
||||
|
||||
try
|
||||
@ -189,18 +192,23 @@ void error_handler_test()
|
||||
}
|
||||
catch (error&)
|
||||
{
|
||||
UNIT_TEST_CHECK(0);
|
||||
BOOST_CHECK(0);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
s.connect(endpoint,
|
||||
ignore_error_if(the_error != expected_err) || throw_error());
|
||||
UNIT_TEST_CHECK(0);
|
||||
BOOST_CHECK(0);
|
||||
}
|
||||
catch (error&)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
UNIT_TEST(error_handler_test)
|
||||
test_suite* init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE("error_handler");
|
||||
test->add(BOOST_TEST_CASE(&error_handler_test));
|
||||
return test;
|
||||
}
|
||||
|
@ -8,6 +8,9 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/fixed_buffer.hpp"
|
||||
|
||||
#include "asio.hpp"
|
||||
#include "unit_test.hpp"
|
||||
|
||||
@ -18,114 +21,119 @@ void fixed_buffer_test()
|
||||
fixed_buffer<32> fb;
|
||||
const fixed_buffer<32>& const_fb = fb;
|
||||
|
||||
UNIT_TEST_CHECK(fb.capacity() == 32);
|
||||
UNIT_TEST_CHECK(fb.empty());
|
||||
UNIT_TEST_CHECK(fb.size() == 0);
|
||||
UNIT_TEST_CHECK(fb.begin() == fb.end());
|
||||
UNIT_TEST_CHECK(const_fb.begin() == const_fb.end());
|
||||
BOOST_CHECK(fb.capacity() == 32);
|
||||
BOOST_CHECK(fb.empty());
|
||||
BOOST_CHECK(fb.size() == 0);
|
||||
BOOST_CHECK(fb.begin() == fb.end());
|
||||
BOOST_CHECK(const_fb.begin() == const_fb.end());
|
||||
|
||||
fb.push('A');
|
||||
|
||||
UNIT_TEST_CHECK(!fb.empty());
|
||||
UNIT_TEST_CHECK(fb.size() == 1);
|
||||
UNIT_TEST_CHECK(fb.begin() != fb.end());
|
||||
UNIT_TEST_CHECK(const_fb.begin() != const_fb.end());
|
||||
UNIT_TEST_CHECK(fb.front() == 'A');
|
||||
UNIT_TEST_CHECK(const_fb.front() == 'A');
|
||||
UNIT_TEST_CHECK(fb.back() == 'A');
|
||||
UNIT_TEST_CHECK(const_fb.back() == 'A');
|
||||
BOOST_CHECK(!fb.empty());
|
||||
BOOST_CHECK(fb.size() == 1);
|
||||
BOOST_CHECK(fb.begin() != fb.end());
|
||||
BOOST_CHECK(const_fb.begin() != const_fb.end());
|
||||
BOOST_CHECK(fb.front() == 'A');
|
||||
BOOST_CHECK(const_fb.front() == 'A');
|
||||
BOOST_CHECK(fb.back() == 'A');
|
||||
BOOST_CHECK(const_fb.back() == 'A');
|
||||
|
||||
fb.front() = 'B';
|
||||
|
||||
UNIT_TEST_CHECK(!fb.empty());
|
||||
UNIT_TEST_CHECK(fb.size() == 1);
|
||||
UNIT_TEST_CHECK(fb.begin() != fb.end());
|
||||
UNIT_TEST_CHECK(const_fb.begin() != const_fb.end());
|
||||
UNIT_TEST_CHECK(fb.front() == 'B');
|
||||
UNIT_TEST_CHECK(const_fb.front() == 'B');
|
||||
UNIT_TEST_CHECK(fb.back() == 'B');
|
||||
UNIT_TEST_CHECK(const_fb.back() == 'B');
|
||||
BOOST_CHECK(!fb.empty());
|
||||
BOOST_CHECK(fb.size() == 1);
|
||||
BOOST_CHECK(fb.begin() != fb.end());
|
||||
BOOST_CHECK(const_fb.begin() != const_fb.end());
|
||||
BOOST_CHECK(fb.front() == 'B');
|
||||
BOOST_CHECK(const_fb.front() == 'B');
|
||||
BOOST_CHECK(fb.back() == 'B');
|
||||
BOOST_CHECK(const_fb.back() == 'B');
|
||||
|
||||
fb.back() = 'C';
|
||||
|
||||
UNIT_TEST_CHECK(!fb.empty());
|
||||
UNIT_TEST_CHECK(fb.size() == 1);
|
||||
UNIT_TEST_CHECK(fb.begin() != fb.end());
|
||||
UNIT_TEST_CHECK(const_fb.begin() != const_fb.end());
|
||||
UNIT_TEST_CHECK(fb.front() == 'C');
|
||||
UNIT_TEST_CHECK(const_fb.front() == 'C');
|
||||
UNIT_TEST_CHECK(fb.back() == 'C');
|
||||
UNIT_TEST_CHECK(const_fb.back() == 'C');
|
||||
BOOST_CHECK(!fb.empty());
|
||||
BOOST_CHECK(fb.size() == 1);
|
||||
BOOST_CHECK(fb.begin() != fb.end());
|
||||
BOOST_CHECK(const_fb.begin() != const_fb.end());
|
||||
BOOST_CHECK(fb.front() == 'C');
|
||||
BOOST_CHECK(const_fb.front() == 'C');
|
||||
BOOST_CHECK(fb.back() == 'C');
|
||||
BOOST_CHECK(const_fb.back() == 'C');
|
||||
|
||||
fb.pop();
|
||||
|
||||
UNIT_TEST_CHECK(fb.empty());
|
||||
UNIT_TEST_CHECK(fb.size() == 0);
|
||||
UNIT_TEST_CHECK(fb.begin() == fb.end());
|
||||
UNIT_TEST_CHECK(const_fb.begin() == const_fb.end());
|
||||
BOOST_CHECK(fb.empty());
|
||||
BOOST_CHECK(fb.size() == 0);
|
||||
BOOST_CHECK(fb.begin() == fb.end());
|
||||
BOOST_CHECK(const_fb.begin() == const_fb.end());
|
||||
|
||||
fb.push('D', 32);
|
||||
|
||||
UNIT_TEST_CHECK(!fb.empty());
|
||||
UNIT_TEST_CHECK(fb.size() == 32);
|
||||
UNIT_TEST_CHECK(fb.begin() != fb.end());
|
||||
UNIT_TEST_CHECK(const_fb.begin() != const_fb.end());
|
||||
UNIT_TEST_CHECK(fb.front() == 'D');
|
||||
UNIT_TEST_CHECK(const_fb.front() == 'D');
|
||||
UNIT_TEST_CHECK(fb.back() == 'D');
|
||||
UNIT_TEST_CHECK(const_fb.back() == 'D');
|
||||
BOOST_CHECK(!fb.empty());
|
||||
BOOST_CHECK(fb.size() == 32);
|
||||
BOOST_CHECK(fb.begin() != fb.end());
|
||||
BOOST_CHECK(const_fb.begin() != const_fb.end());
|
||||
BOOST_CHECK(fb.front() == 'D');
|
||||
BOOST_CHECK(const_fb.front() == 'D');
|
||||
BOOST_CHECK(fb.back() == 'D');
|
||||
BOOST_CHECK(const_fb.back() == 'D');
|
||||
for (size_t i = 0; i < fb.size(); ++i)
|
||||
{
|
||||
UNIT_TEST_CHECK(fb[i] == 'D');
|
||||
UNIT_TEST_CHECK(const_fb[i] == 'D');
|
||||
BOOST_CHECK(fb[i] == 'D');
|
||||
BOOST_CHECK(const_fb[i] == 'D');
|
||||
}
|
||||
|
||||
fb.front() = 'E';
|
||||
|
||||
UNIT_TEST_CHECK(!fb.empty());
|
||||
UNIT_TEST_CHECK(fb.size() == 32);
|
||||
UNIT_TEST_CHECK(fb.begin() != fb.end());
|
||||
UNIT_TEST_CHECK(const_fb.begin() != const_fb.end());
|
||||
UNIT_TEST_CHECK(fb.front() == 'E');
|
||||
UNIT_TEST_CHECK(const_fb.front() == 'E');
|
||||
UNIT_TEST_CHECK(fb.back() == 'D');
|
||||
UNIT_TEST_CHECK(const_fb.back() == 'D');
|
||||
BOOST_CHECK(!fb.empty());
|
||||
BOOST_CHECK(fb.size() == 32);
|
||||
BOOST_CHECK(fb.begin() != fb.end());
|
||||
BOOST_CHECK(const_fb.begin() != const_fb.end());
|
||||
BOOST_CHECK(fb.front() == 'E');
|
||||
BOOST_CHECK(const_fb.front() == 'E');
|
||||
BOOST_CHECK(fb.back() == 'D');
|
||||
BOOST_CHECK(const_fb.back() == 'D');
|
||||
|
||||
fb.pop();
|
||||
|
||||
UNIT_TEST_CHECK(!fb.empty());
|
||||
UNIT_TEST_CHECK(fb.size() == 31);
|
||||
UNIT_TEST_CHECK(fb.begin() != fb.end());
|
||||
UNIT_TEST_CHECK(const_fb.begin() != const_fb.end());
|
||||
UNIT_TEST_CHECK(fb.front() == 'D');
|
||||
UNIT_TEST_CHECK(const_fb.front() == 'D');
|
||||
UNIT_TEST_CHECK(fb.back() == 'D');
|
||||
UNIT_TEST_CHECK(const_fb.back() == 'D');
|
||||
BOOST_CHECK(!fb.empty());
|
||||
BOOST_CHECK(fb.size() == 31);
|
||||
BOOST_CHECK(fb.begin() != fb.end());
|
||||
BOOST_CHECK(const_fb.begin() != const_fb.end());
|
||||
BOOST_CHECK(fb.front() == 'D');
|
||||
BOOST_CHECK(const_fb.front() == 'D');
|
||||
BOOST_CHECK(fb.back() == 'D');
|
||||
BOOST_CHECK(const_fb.back() == 'D');
|
||||
for (char* p = fb.begin(); p != fb.end(); ++p)
|
||||
UNIT_TEST_CHECK(*p == 'D');
|
||||
BOOST_CHECK(*p == 'D');
|
||||
for (const char* cp = const_fb.begin(); cp != const_fb.end(); ++cp)
|
||||
UNIT_TEST_CHECK(*cp == 'D');
|
||||
BOOST_CHECK(*cp == 'D');
|
||||
|
||||
fb.pop(31);
|
||||
|
||||
UNIT_TEST_CHECK(fb.empty());
|
||||
UNIT_TEST_CHECK(fb.size() == 0);
|
||||
UNIT_TEST_CHECK(fb.begin() == fb.end());
|
||||
UNIT_TEST_CHECK(const_fb.begin() == const_fb.end());
|
||||
BOOST_CHECK(fb.empty());
|
||||
BOOST_CHECK(fb.size() == 0);
|
||||
BOOST_CHECK(fb.begin() == fb.end());
|
||||
BOOST_CHECK(const_fb.begin() == const_fb.end());
|
||||
|
||||
fb.resize(16);
|
||||
|
||||
UNIT_TEST_CHECK(!fb.empty());
|
||||
UNIT_TEST_CHECK(fb.size() == 16);
|
||||
UNIT_TEST_CHECK(fb.begin() != fb.end());
|
||||
UNIT_TEST_CHECK(const_fb.begin() != const_fb.end());
|
||||
BOOST_CHECK(!fb.empty());
|
||||
BOOST_CHECK(fb.size() == 16);
|
||||
BOOST_CHECK(fb.begin() != fb.end());
|
||||
BOOST_CHECK(const_fb.begin() != const_fb.end());
|
||||
|
||||
fb.clear();
|
||||
|
||||
UNIT_TEST_CHECK(fb.empty());
|
||||
UNIT_TEST_CHECK(fb.size() == 0);
|
||||
UNIT_TEST_CHECK(fb.begin() == fb.end());
|
||||
UNIT_TEST_CHECK(const_fb.begin() == const_fb.end());
|
||||
BOOST_CHECK(fb.empty());
|
||||
BOOST_CHECK(fb.size() == 0);
|
||||
BOOST_CHECK(fb.begin() == fb.end());
|
||||
BOOST_CHECK(const_fb.begin() == const_fb.end());
|
||||
}
|
||||
|
||||
UNIT_TEST(fixed_buffer_test)
|
||||
test_suite* init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE("fixed_buffer");
|
||||
test->add(BOOST_TEST_CASE(&fixed_buffer_test));
|
||||
return test;
|
||||
}
|
||||
|
@ -8,6 +8,9 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/ipv4/host_resolver.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
@ -20,22 +23,22 @@ using namespace asio;
|
||||
|
||||
void handle_accept(const error& err)
|
||||
{
|
||||
UNIT_TEST_CHECK(!err);
|
||||
BOOST_CHECK(!err);
|
||||
}
|
||||
|
||||
void handle_connect(const error& err)
|
||||
{
|
||||
UNIT_TEST_CHECK(!err);
|
||||
BOOST_CHECK(!err);
|
||||
}
|
||||
|
||||
void handle_get_host_by_address(const error& err)
|
||||
{
|
||||
UNIT_TEST_CHECK(!err);
|
||||
BOOST_CHECK(!err);
|
||||
}
|
||||
|
||||
void handle_get_host_by_name(const error& err)
|
||||
{
|
||||
UNIT_TEST_CHECK(!err);
|
||||
BOOST_CHECK(!err);
|
||||
}
|
||||
|
||||
bool test_if_hosts_equal(const ipv4::host& h1, const ipv4::host& h2)
|
||||
@ -95,7 +98,7 @@ void ipv4_host_resolver_test()
|
||||
ipv4::host h2;
|
||||
resolver.get_local_host(h2, throw_error_if(the_error != error::success));
|
||||
|
||||
UNIT_TEST_CHECK(test_if_hosts_equal(h1, h2));
|
||||
BOOST_CHECK(test_if_hosts_equal(h1, h2));
|
||||
|
||||
ipv4::host h3;
|
||||
resolver.get_host_by_address(h3, h1.address(0));
|
||||
@ -104,8 +107,8 @@ void ipv4_host_resolver_test()
|
||||
resolver.get_host_by_address(h4, h1.address(0),
|
||||
throw_error_if(the_error != error::success));
|
||||
|
||||
UNIT_TEST_CHECK(test_if_hosts_equal(h3, h4));
|
||||
UNIT_TEST_CHECK(test_if_addresses_intersect(h1, h3));
|
||||
BOOST_CHECK(test_if_hosts_equal(h3, h4));
|
||||
BOOST_CHECK(test_if_addresses_intersect(h1, h3));
|
||||
|
||||
ipv4::host h5;
|
||||
resolver.get_host_by_name(h5, h1.name());
|
||||
@ -114,8 +117,8 @@ void ipv4_host_resolver_test()
|
||||
resolver.get_host_by_name(h6, h1.name(),
|
||||
throw_error_if(the_error != error::success));
|
||||
|
||||
UNIT_TEST_CHECK(test_if_hosts_equal(h5, h6));
|
||||
UNIT_TEST_CHECK(test_if_addresses_intersect(h1, h5));
|
||||
BOOST_CHECK(test_if_hosts_equal(h5, h6));
|
||||
BOOST_CHECK(test_if_addresses_intersect(h1, h5));
|
||||
|
||||
ipv4::host h7;
|
||||
resolver.async_get_host_by_address(h7, h1.address(0),
|
||||
@ -123,16 +126,21 @@ void ipv4_host_resolver_test()
|
||||
d.reset();
|
||||
d.run();
|
||||
|
||||
UNIT_TEST_CHECK(test_if_hosts_equal(h3, h7));
|
||||
UNIT_TEST_CHECK(test_if_addresses_intersect(h1, h7));
|
||||
BOOST_CHECK(test_if_hosts_equal(h3, h7));
|
||||
BOOST_CHECK(test_if_addresses_intersect(h1, h7));
|
||||
|
||||
ipv4::host h8;
|
||||
resolver.async_get_host_by_name(h8, h1.name(), handle_get_host_by_name);
|
||||
d.reset();
|
||||
d.run();
|
||||
|
||||
UNIT_TEST_CHECK(test_if_hosts_equal(h5, h8));
|
||||
UNIT_TEST_CHECK(test_if_addresses_intersect(h1, h8));
|
||||
BOOST_CHECK(test_if_hosts_equal(h5, h8));
|
||||
BOOST_CHECK(test_if_addresses_intersect(h1, h8));
|
||||
}
|
||||
|
||||
UNIT_TEST(ipv4_host_resolver_test)
|
||||
test_suite* init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE("ipv4/host_resolver");
|
||||
test->add(BOOST_TEST_CASE(&ipv4_host_resolver_test));
|
||||
return test;
|
||||
}
|
||||
|
@ -8,6 +8,9 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/is_read_buffered.hpp"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include "asio.hpp"
|
||||
@ -80,27 +83,32 @@ private:
|
||||
|
||||
void is_read_buffered_test()
|
||||
{
|
||||
UNIT_TEST_CHECK(!asio::is_read_buffered<asio::stream_socket>::value);
|
||||
BOOST_CHECK(!asio::is_read_buffered<asio::stream_socket>::value);
|
||||
|
||||
UNIT_TEST_CHECK(asio::is_read_buffered<
|
||||
BOOST_CHECK(asio::is_read_buffered<
|
||||
asio::buffered_read_stream<asio::stream_socket> >::value);
|
||||
|
||||
UNIT_TEST_CHECK(!asio::is_read_buffered<
|
||||
BOOST_CHECK(!asio::is_read_buffered<
|
||||
asio::buffered_write_stream<asio::stream_socket> >::value);
|
||||
|
||||
UNIT_TEST_CHECK(asio::is_read_buffered<
|
||||
BOOST_CHECK(asio::is_read_buffered<
|
||||
asio::buffered_stream<asio::stream_socket> >::value);
|
||||
|
||||
UNIT_TEST_CHECK(!asio::is_read_buffered<test_stream>::value);
|
||||
BOOST_CHECK(!asio::is_read_buffered<test_stream>::value);
|
||||
|
||||
UNIT_TEST_CHECK(asio::is_read_buffered<
|
||||
BOOST_CHECK(asio::is_read_buffered<
|
||||
asio::buffered_read_stream<test_stream> >::value);
|
||||
|
||||
UNIT_TEST_CHECK(!asio::is_read_buffered<
|
||||
BOOST_CHECK(!asio::is_read_buffered<
|
||||
asio::buffered_write_stream<test_stream> >::value);
|
||||
|
||||
UNIT_TEST_CHECK(asio::is_read_buffered<
|
||||
BOOST_CHECK(asio::is_read_buffered<
|
||||
asio::buffered_stream<test_stream> >::value);
|
||||
}
|
||||
|
||||
UNIT_TEST(is_read_buffered_test)
|
||||
test_suite* init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE("is_read_buffered");
|
||||
test->add(BOOST_TEST_CASE(&is_read_buffered_test));
|
||||
return test;
|
||||
}
|
||||
|
@ -8,6 +8,9 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/is_write_buffered.hpp"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include "asio.hpp"
|
||||
@ -80,27 +83,32 @@ private:
|
||||
|
||||
void is_write_buffered_test()
|
||||
{
|
||||
UNIT_TEST_CHECK(!asio::is_write_buffered<asio::stream_socket>::value);
|
||||
BOOST_CHECK(!asio::is_write_buffered<asio::stream_socket>::value);
|
||||
|
||||
UNIT_TEST_CHECK(!asio::is_write_buffered<
|
||||
BOOST_CHECK(!asio::is_write_buffered<
|
||||
asio::buffered_read_stream<asio::stream_socket> >::value);
|
||||
|
||||
UNIT_TEST_CHECK(asio::is_write_buffered<
|
||||
BOOST_CHECK(asio::is_write_buffered<
|
||||
asio::buffered_write_stream<asio::stream_socket> >::value);
|
||||
|
||||
UNIT_TEST_CHECK(asio::is_write_buffered<
|
||||
BOOST_CHECK(asio::is_write_buffered<
|
||||
asio::buffered_stream<asio::stream_socket> >::value);
|
||||
|
||||
UNIT_TEST_CHECK(!asio::is_write_buffered<test_stream>::value);
|
||||
BOOST_CHECK(!asio::is_write_buffered<test_stream>::value);
|
||||
|
||||
UNIT_TEST_CHECK(!asio::is_write_buffered<
|
||||
BOOST_CHECK(!asio::is_write_buffered<
|
||||
asio::buffered_read_stream<test_stream> >::value);
|
||||
|
||||
UNIT_TEST_CHECK(asio::is_write_buffered<
|
||||
BOOST_CHECK(asio::is_write_buffered<
|
||||
asio::buffered_write_stream<test_stream> >::value);
|
||||
|
||||
UNIT_TEST_CHECK(asio::is_write_buffered<
|
||||
BOOST_CHECK(asio::is_write_buffered<
|
||||
asio::buffered_stream<test_stream> >::value);
|
||||
}
|
||||
|
||||
UNIT_TEST(is_write_buffered_test)
|
||||
test_suite* init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE("is_write_buffered");
|
||||
test->add(BOOST_TEST_CASE(&is_write_buffered_test));
|
||||
return test;
|
||||
}
|
||||
|
@ -8,6 +8,9 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/locking_dispatcher.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <boost/bind.hpp>
|
||||
#include "asio.hpp"
|
||||
@ -28,7 +31,7 @@ void increment_without_lock(locking_dispatcher* l, int* count)
|
||||
|
||||
// No other functions are currently executing through the locking dispatcher,
|
||||
// so the previous call to dispatch should have successfully nested.
|
||||
UNIT_TEST_CHECK(*count == original_count + 1);
|
||||
BOOST_CHECK(*count == original_count + 1);
|
||||
}
|
||||
|
||||
void increment_with_lock(locking_dispatcher* l, int* count)
|
||||
@ -39,7 +42,7 @@ void increment_with_lock(locking_dispatcher* l, int* count)
|
||||
|
||||
// The current function already holds the locking_dispatcher's lock, so the
|
||||
// previous call to dispatch should not have nested.
|
||||
UNIT_TEST_CHECK(*count == original_count);
|
||||
BOOST_CHECK(*count == original_count);
|
||||
}
|
||||
|
||||
void sleep_increment(demuxer* d, int* count)
|
||||
@ -76,24 +79,24 @@ void locking_dispatcher_test()
|
||||
d.post(boost::bind(increment_without_lock, &l, &count));
|
||||
|
||||
// No handlers can be called until run() is called.
|
||||
UNIT_TEST_CHECK(count == 0);
|
||||
BOOST_CHECK(count == 0);
|
||||
|
||||
d.run();
|
||||
|
||||
// The run() call will not return until all work has finished.
|
||||
UNIT_TEST_CHECK(count == 1);
|
||||
BOOST_CHECK(count == 1);
|
||||
|
||||
count = 0;
|
||||
d.reset();
|
||||
l.post(boost::bind(increment_with_lock, &l, &count));
|
||||
|
||||
// No handlers can be called until run() is called.
|
||||
UNIT_TEST_CHECK(count == 0);
|
||||
BOOST_CHECK(count == 0);
|
||||
|
||||
d.run();
|
||||
|
||||
// The run() call will not return until all work has finished.
|
||||
UNIT_TEST_CHECK(count == 1);
|
||||
BOOST_CHECK(count == 1);
|
||||
|
||||
count = 0;
|
||||
d.reset();
|
||||
@ -104,19 +107,19 @@ void locking_dispatcher_test()
|
||||
// Check all events run one after another even though there are two threads.
|
||||
deadline_timer timer1(d, boost::posix_time::seconds(3));
|
||||
timer1.wait();
|
||||
UNIT_TEST_CHECK(count == 0);
|
||||
BOOST_CHECK(count == 0);
|
||||
timer1.expires_at(timer1.expires_at() + boost::posix_time::seconds(2));
|
||||
timer1.wait();
|
||||
UNIT_TEST_CHECK(count == 1);
|
||||
BOOST_CHECK(count == 1);
|
||||
timer1.expires_at(timer1.expires_at() + boost::posix_time::seconds(2));
|
||||
timer1.wait();
|
||||
UNIT_TEST_CHECK(count == 2);
|
||||
BOOST_CHECK(count == 2);
|
||||
|
||||
thread1.join();
|
||||
thread2.join();
|
||||
|
||||
// The run() calls will not return until all work has finished.
|
||||
UNIT_TEST_CHECK(count == 3);
|
||||
BOOST_CHECK(count == 3);
|
||||
|
||||
count = 0;
|
||||
int exception_count = 0;
|
||||
@ -128,8 +131,8 @@ void locking_dispatcher_test()
|
||||
l.post(boost::bind(increment, &count));
|
||||
|
||||
// No handlers can be called until run() is called.
|
||||
UNIT_TEST_CHECK(count == 0);
|
||||
UNIT_TEST_CHECK(exception_count == 0);
|
||||
BOOST_CHECK(count == 0);
|
||||
BOOST_CHECK(exception_count == 0);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
@ -145,8 +148,13 @@ void locking_dispatcher_test()
|
||||
}
|
||||
|
||||
// The run() calls will not return until all work has finished.
|
||||
UNIT_TEST_CHECK(count == 3);
|
||||
UNIT_TEST_CHECK(exception_count == 2);
|
||||
BOOST_CHECK(count == 3);
|
||||
BOOST_CHECK(exception_count == 2);
|
||||
}
|
||||
|
||||
UNIT_TEST(locking_dispatcher_test)
|
||||
test_suite* init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE("locking_dispatcher");
|
||||
test->add(BOOST_TEST_CASE(&locking_dispatcher_test));
|
||||
return test;
|
||||
}
|
||||
|
@ -8,6 +8,9 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/read.hpp"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <cstring>
|
||||
@ -37,7 +40,7 @@ public:
|
||||
|
||||
void reset(const void* data, size_t length)
|
||||
{
|
||||
UNIT_TEST_CHECK(length <= max_length);
|
||||
BOOST_CHECK(length <= max_length);
|
||||
|
||||
memcpy(data_, data, length);
|
||||
length_ = length;
|
||||
@ -133,22 +136,22 @@ void test_read()
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
size_t last_bytes_transferred = asio::read(s, buffers);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(1);
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read(s, buffers);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 1));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, 1));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(10);
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read(s, buffers);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
}
|
||||
|
||||
void test_read_with_error_handler()
|
||||
@ -161,29 +164,29 @@ void test_read_with_error_handler()
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
size_t last_bytes_transferred = asio::read(s, buffers, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(1);
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read(s, buffers, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 1));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, 1));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(10);
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read(s, buffers, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
}
|
||||
|
||||
void async_read_handler(const asio::error& e, size_t bytes_transferred,
|
||||
size_t expected_bytes_transferred, bool* called)
|
||||
{
|
||||
*called = true;
|
||||
UNIT_TEST_CHECK(bytes_transferred == expected_bytes_transferred);
|
||||
BOOST_CHECK(bytes_transferred == expected_bytes_transferred);
|
||||
}
|
||||
|
||||
void test_async_read()
|
||||
@ -201,8 +204,8 @@ void test_async_read()
|
||||
asio::placeholders::bytes_transferred, sizeof(read_data), &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(1);
|
||||
@ -213,8 +216,8 @@ void test_async_read()
|
||||
asio::placeholders::bytes_transferred, 1, &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 1));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, 1));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(10);
|
||||
@ -225,8 +228,8 @@ void test_async_read()
|
||||
asio::placeholders::bytes_transferred, 10, &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
}
|
||||
|
||||
void test_read_n()
|
||||
@ -239,48 +242,48 @@ void test_read_n()
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
size_t last_bytes_transferred = asio::read_n(s, buffers);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
size_t total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_n(s, buffers, &total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(1);
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read_n(s, buffers);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(1);
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_n(s, buffers, &total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(10);
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read_n(s, buffers);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data) % 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data) % 10);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(10);
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_n(s, buffers, &total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data) % 10);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data) % 10);
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
}
|
||||
|
||||
void test_read_n_with_error_handler()
|
||||
@ -294,24 +297,24 @@ void test_read_n_with_error_handler()
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
size_t last_bytes_transferred = asio::read_n(s, buffers, 0,
|
||||
asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
size_t total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_n(s, buffers, &total_bytes_transferred,
|
||||
asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(1);
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read_n(s, buffers, 0, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(1);
|
||||
@ -319,16 +322,16 @@ void test_read_n_with_error_handler()
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_n(s, buffers, &total_bytes_transferred,
|
||||
asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(10);
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read_n(s, buffers, 0, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data) % 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data) % 10);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(10);
|
||||
@ -336,9 +339,9 @@ void test_read_n_with_error_handler()
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_n(s, buffers, &total_bytes_transferred,
|
||||
asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data) % 10);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data) % 10);
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
}
|
||||
|
||||
void async_read_n_handler(const asio::error& e, size_t last_bytes_transferred,
|
||||
@ -346,8 +349,8 @@ void async_read_n_handler(const asio::error& e, size_t last_bytes_transferred,
|
||||
size_t expected_total_bytes_transferred, bool* called)
|
||||
{
|
||||
*called = true;
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == expected_last_bytes_transferred);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == expected_total_bytes_transferred);
|
||||
BOOST_CHECK(last_bytes_transferred == expected_last_bytes_transferred);
|
||||
BOOST_CHECK(total_bytes_transferred == expected_total_bytes_transferred);
|
||||
}
|
||||
|
||||
void test_async_read_n()
|
||||
@ -367,8 +370,8 @@ void test_async_read_n()
|
||||
sizeof(read_data), sizeof(read_data), &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(1);
|
||||
@ -381,8 +384,8 @@ void test_async_read_n()
|
||||
sizeof(read_data), &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(10);
|
||||
@ -395,8 +398,8 @@ void test_async_read_n()
|
||||
sizeof(read_data) % 10, sizeof(read_data), &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
}
|
||||
|
||||
void test_read_at_least_n()
|
||||
@ -409,54 +412,54 @@ void test_read_at_least_n()
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
size_t last_bytes_transferred = asio::read_at_least_n(s, buffers, 1);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
size_t total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, 1,
|
||||
&total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, 10);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, 10,
|
||||
&total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, sizeof(read_data));
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, sizeof(read_data),
|
||||
&total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(1);
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, 1);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 1));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, 1));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(1);
|
||||
@ -464,16 +467,16 @@ void test_read_at_least_n()
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, 1,
|
||||
&total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 1));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(total_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, 1));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(1);
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, 10);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(1);
|
||||
@ -481,16 +484,16 @@ void test_read_at_least_n()
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, 10,
|
||||
&total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(total_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(1);
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, sizeof(read_data));
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(1);
|
||||
@ -498,16 +501,16 @@ void test_read_at_least_n()
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, sizeof(read_data),
|
||||
&total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(10);
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, 1);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(10);
|
||||
@ -515,16 +518,16 @@ void test_read_at_least_n()
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, 1,
|
||||
&total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 10);
|
||||
BOOST_CHECK(total_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(10);
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, 10);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(10);
|
||||
@ -532,16 +535,16 @@ void test_read_at_least_n()
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, 10,
|
||||
&total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 10);
|
||||
BOOST_CHECK(total_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(10);
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, sizeof(read_data));
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data) % 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data) % 10);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(10);
|
||||
@ -549,9 +552,9 @@ void test_read_at_least_n()
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, sizeof(read_data),
|
||||
&total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data) % 10);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data) % 10);
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
}
|
||||
|
||||
void test_read_at_least_n_with_error_handler()
|
||||
@ -565,57 +568,57 @@ void test_read_at_least_n_with_error_handler()
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
size_t last_bytes_transferred = asio::read_at_least_n(s, buffers, 1,
|
||||
0, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
size_t total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, 1,
|
||||
&total_bytes_transferred, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, 10,
|
||||
0, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, 10,
|
||||
&total_bytes_transferred, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, sizeof(read_data),
|
||||
0, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, sizeof(read_data),
|
||||
&total_bytes_transferred, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(1);
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, 1,
|
||||
0, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 1));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, 1));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(1);
|
||||
@ -623,17 +626,17 @@ void test_read_at_least_n_with_error_handler()
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, 1,
|
||||
&total_bytes_transferred, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 1));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(total_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, 1));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(1);
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, 10,
|
||||
0, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(1);
|
||||
@ -641,17 +644,17 @@ void test_read_at_least_n_with_error_handler()
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, 10,
|
||||
&total_bytes_transferred, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(total_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(1);
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, sizeof(read_data),
|
||||
0, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(1);
|
||||
@ -659,17 +662,17 @@ void test_read_at_least_n_with_error_handler()
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, sizeof(read_data),
|
||||
&total_bytes_transferred, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(10);
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, 1,
|
||||
0, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(10);
|
||||
@ -677,17 +680,17 @@ void test_read_at_least_n_with_error_handler()
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, 1,
|
||||
&total_bytes_transferred, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 10);
|
||||
BOOST_CHECK(total_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(10);
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, 10,
|
||||
0, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(10);
|
||||
@ -695,17 +698,17 @@ void test_read_at_least_n_with_error_handler()
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, 10,
|
||||
&total_bytes_transferred, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 10);
|
||||
BOOST_CHECK(total_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(10);
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, sizeof(read_data),
|
||||
0, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data) % 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data) % 10);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(10);
|
||||
@ -713,9 +716,9 @@ void test_read_at_least_n_with_error_handler()
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::read_at_least_n(s, buffers, sizeof(read_data),
|
||||
&total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(read_data) % 10);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(read_data) % 10);
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(read_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
}
|
||||
|
||||
void async_read_at_least_n_handler(const asio::error& e,
|
||||
@ -724,8 +727,8 @@ void async_read_at_least_n_handler(const asio::error& e,
|
||||
size_t expected_total_bytes_transferred, bool* called)
|
||||
{
|
||||
*called = true;
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == expected_last_bytes_transferred);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == expected_total_bytes_transferred);
|
||||
BOOST_CHECK(last_bytes_transferred == expected_last_bytes_transferred);
|
||||
BOOST_CHECK(total_bytes_transferred == expected_total_bytes_transferred);
|
||||
}
|
||||
|
||||
void test_async_read_at_least_n()
|
||||
@ -745,8 +748,8 @@ void test_async_read_at_least_n()
|
||||
sizeof(read_data), sizeof(read_data), &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
@ -758,8 +761,8 @@ void test_async_read_at_least_n()
|
||||
sizeof(read_data), sizeof(read_data), &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
memset(read_buf, 0, sizeof(read_buf));
|
||||
@ -771,8 +774,8 @@ void test_async_read_at_least_n()
|
||||
sizeof(read_data), sizeof(read_data), &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(1);
|
||||
@ -784,8 +787,8 @@ void test_async_read_at_least_n()
|
||||
asio::placeholders::total_bytes_transferred, 1, 1, &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 1));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, 1));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(1);
|
||||
@ -797,8 +800,8 @@ void test_async_read_at_least_n()
|
||||
asio::placeholders::total_bytes_transferred, 1, 10, &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(1);
|
||||
@ -811,8 +814,8 @@ void test_async_read_at_least_n()
|
||||
1, sizeof(read_data), &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(10);
|
||||
@ -824,8 +827,8 @@ void test_async_read_at_least_n()
|
||||
asio::placeholders::total_bytes_transferred, 10, 10, &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(10);
|
||||
@ -837,8 +840,8 @@ void test_async_read_at_least_n()
|
||||
asio::placeholders::total_bytes_transferred, 10, 10, &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset(read_data, sizeof(read_data));
|
||||
s.next_read_length(10);
|
||||
@ -851,23 +854,21 @@ void test_async_read_at_least_n()
|
||||
sizeof(read_data) % 10, sizeof(read_data), &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(read_data)));
|
||||
}
|
||||
|
||||
void read_test()
|
||||
test_suite* init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
test_read();
|
||||
test_read_with_error_handler();
|
||||
test_async_read();
|
||||
|
||||
test_read_n();
|
||||
test_read_n_with_error_handler();
|
||||
test_async_read_n();
|
||||
|
||||
test_read_at_least_n();
|
||||
test_read_at_least_n_with_error_handler();
|
||||
test_async_read_at_least_n();
|
||||
test_suite* test = BOOST_TEST_SUITE("read");
|
||||
test->add(BOOST_TEST_CASE(&test_read));
|
||||
test->add(BOOST_TEST_CASE(&test_read_with_error_handler));
|
||||
test->add(BOOST_TEST_CASE(&test_async_read));
|
||||
test->add(BOOST_TEST_CASE(&test_read_n));
|
||||
test->add(BOOST_TEST_CASE(&test_read_n_with_error_handler));
|
||||
test->add(BOOST_TEST_CASE(&test_async_read_n));
|
||||
test->add(BOOST_TEST_CASE(&test_read_at_least_n));
|
||||
test->add(BOOST_TEST_CASE(&test_read_at_least_n_with_error_handler));
|
||||
test->add(BOOST_TEST_CASE(&test_async_read_at_least_n));
|
||||
return test;
|
||||
}
|
||||
|
||||
UNIT_TEST(read_test)
|
||||
|
@ -8,6 +8,9 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/socket_acceptor.hpp"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <cstring>
|
||||
#include "asio.hpp"
|
||||
@ -17,12 +20,12 @@ using namespace asio;
|
||||
|
||||
void handle_accept(const error& err)
|
||||
{
|
||||
UNIT_TEST_CHECK(!err);
|
||||
BOOST_CHECK(!err);
|
||||
}
|
||||
|
||||
void handle_connect(const error& err)
|
||||
{
|
||||
UNIT_TEST_CHECK(!err);
|
||||
BOOST_CHECK(!err);
|
||||
}
|
||||
|
||||
void socket_acceptor_test()
|
||||
@ -49,11 +52,11 @@ void socket_acceptor_test()
|
||||
|
||||
ipv4::tcp::endpoint client_side_local_endpoint;
|
||||
client_side_socket.get_local_endpoint(client_side_local_endpoint);
|
||||
UNIT_TEST_CHECK(client_side_local_endpoint.port() == client_endpoint.port());
|
||||
BOOST_CHECK(client_side_local_endpoint.port() == client_endpoint.port());
|
||||
|
||||
ipv4::tcp::endpoint server_side_remote_endpoint;
|
||||
server_side_socket.get_remote_endpoint(server_side_remote_endpoint);
|
||||
UNIT_TEST_CHECK(server_side_remote_endpoint.port() == client_endpoint.port());
|
||||
BOOST_CHECK(server_side_remote_endpoint.port() == client_endpoint.port());
|
||||
|
||||
client_side_socket.close();
|
||||
server_side_socket.close();
|
||||
@ -74,10 +77,15 @@ void socket_acceptor_test()
|
||||
d.run();
|
||||
|
||||
client_side_socket.get_local_endpoint(client_side_local_endpoint);
|
||||
UNIT_TEST_CHECK(client_side_local_endpoint.port() == client_endpoint.port());
|
||||
BOOST_CHECK(client_side_local_endpoint.port() == client_endpoint.port());
|
||||
|
||||
server_side_socket.get_remote_endpoint(server_side_remote_endpoint);
|
||||
UNIT_TEST_CHECK(server_side_remote_endpoint.port() == client_endpoint.port());
|
||||
BOOST_CHECK(server_side_remote_endpoint.port() == client_endpoint.port());
|
||||
}
|
||||
|
||||
UNIT_TEST(socket_acceptor_test)
|
||||
test_suite* init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE("socket_acceptor");
|
||||
test->add(BOOST_TEST_CASE(&socket_acceptor_test));
|
||||
return test;
|
||||
}
|
||||
|
@ -11,49 +11,19 @@
|
||||
#ifndef UNIT_TEST_HPP
|
||||
#define UNIT_TEST_HPP
|
||||
|
||||
#include <iostream>
|
||||
#if defined(__BORLANDC__)
|
||||
|
||||
static int unit_test_exit_code = 0;
|
||||
// Prevent use of intrinsic for strcmp.
|
||||
#include <cstring>
|
||||
#undef strcmp
|
||||
|
||||
inline int unit_test(const char* name, void (*func)(void))
|
||||
{
|
||||
std::cout << "INFO: " << name << " started\n";
|
||||
// Suppress error about condition always being true.
|
||||
#pragma option -w-ccc
|
||||
|
||||
try
|
||||
{
|
||||
func();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cout << "FAIL: unhandled exception\n";
|
||||
unit_test_exit_code = 1;
|
||||
}
|
||||
#endif // defined(__BORLANDC__)
|
||||
|
||||
std::cout << "INFO: " << name << " ended with exit code ";
|
||||
std::cout << unit_test_exit_code << "\n";
|
||||
|
||||
return unit_test_exit_code;
|
||||
}
|
||||
|
||||
#define UNIT_TEST(name) int main() { return unit_test(#name, name); }
|
||||
|
||||
inline void unit_test_info(const char* file, int line, const char* msg)
|
||||
{
|
||||
std::cout << "INFO: " << file << "(" << line << "):" << msg << "\n";
|
||||
}
|
||||
|
||||
#define UNIT_TEST_INFO(s) unit_test_info(__FILE__, __LINE__, s)
|
||||
|
||||
inline void unit_test_check(bool condition, const char* file, int line,
|
||||
const char* msg)
|
||||
{
|
||||
if (!condition)
|
||||
{
|
||||
std::cout << "FAIL: " << file << "(" << line << "):" << msg << "\n";
|
||||
unit_test_exit_code = 1;
|
||||
}
|
||||
}
|
||||
|
||||
#define UNIT_TEST_CHECK(c) unit_test_check((c), __FILE__, __LINE__, #c)
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/included/unit_test_framework.hpp>
|
||||
using boost::unit_test::test_suite;
|
||||
|
||||
#endif // UNIT_TEST_HPP
|
||||
|
@ -8,6 +8,9 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "asio/write.hpp"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <cstring>
|
||||
@ -38,7 +41,7 @@ public:
|
||||
|
||||
void reset(size_t length = max_length)
|
||||
{
|
||||
UNIT_TEST_CHECK(length <= max_length);
|
||||
BOOST_CHECK(length <= max_length);
|
||||
|
||||
memset(data_, 0, max_length);
|
||||
length_ = length;
|
||||
@ -133,20 +136,20 @@ void test_write()
|
||||
|
||||
s.reset();
|
||||
size_t last_bytes_transferred = asio::write(s, buffers);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(1);
|
||||
last_bytes_transferred = asio::write(s, buffers);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 1));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, 1));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(10);
|
||||
last_bytes_transferred = asio::write(s, buffers);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
}
|
||||
|
||||
void test_write_with_error_handler()
|
||||
@ -158,27 +161,27 @@ void test_write_with_error_handler()
|
||||
|
||||
s.reset();
|
||||
size_t last_bytes_transferred = asio::write(s, buffers, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(1);
|
||||
last_bytes_transferred = asio::write(s, buffers, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 1));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, 1));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(10);
|
||||
last_bytes_transferred = asio::write(s, buffers, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
}
|
||||
|
||||
void async_write_handler(const asio::error& e, size_t bytes_transferred,
|
||||
size_t expected_bytes_transferred, bool* called)
|
||||
{
|
||||
*called = true;
|
||||
UNIT_TEST_CHECK(bytes_transferred == expected_bytes_transferred);
|
||||
BOOST_CHECK(bytes_transferred == expected_bytes_transferred);
|
||||
}
|
||||
|
||||
void test_async_write()
|
||||
@ -195,8 +198,8 @@ void test_async_write()
|
||||
asio::placeholders::bytes_transferred, sizeof(write_data), &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(1);
|
||||
@ -206,8 +209,8 @@ void test_async_write()
|
||||
asio::placeholders::bytes_transferred, 1, &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 1));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, 1));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(10);
|
||||
@ -217,8 +220,8 @@ void test_async_write()
|
||||
asio::placeholders::bytes_transferred, 10, &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
}
|
||||
|
||||
void test_write_n()
|
||||
@ -230,43 +233,43 @@ void test_write_n()
|
||||
|
||||
s.reset();
|
||||
size_t last_bytes_transferred = asio::write_n(s, buffers);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
size_t total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_n(s, buffers, &total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(1);
|
||||
last_bytes_transferred = asio::write_n(s, buffers);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(1);
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_n(s, buffers, &total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(10);
|
||||
last_bytes_transferred = asio::write_n(s, buffers);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data) % 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data) % 10);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(10);
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_n(s, buffers, &total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data) % 10);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data) % 10);
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
}
|
||||
|
||||
void test_write_n_with_error_handler()
|
||||
@ -279,46 +282,46 @@ void test_write_n_with_error_handler()
|
||||
s.reset();
|
||||
size_t last_bytes_transferred = asio::write_n(s, buffers, 0,
|
||||
asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
size_t total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_n(s, buffers, &total_bytes_transferred,
|
||||
asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(1);
|
||||
last_bytes_transferred = asio::write_n(s, buffers, 0, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(1);
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_n(s, buffers, &total_bytes_transferred,
|
||||
asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(10);
|
||||
last_bytes_transferred = asio::write_n(s, buffers, 0, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data) % 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data) % 10);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(10);
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_n(s, buffers, &total_bytes_transferred,
|
||||
asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data) % 10);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data) % 10);
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
}
|
||||
|
||||
void async_write_n_handler(const asio::error& e, size_t last_bytes_transferred,
|
||||
@ -326,8 +329,8 @@ void async_write_n_handler(const asio::error& e, size_t last_bytes_transferred,
|
||||
size_t expected_total_bytes_transferred, bool* called)
|
||||
{
|
||||
*called = true;
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == expected_last_bytes_transferred);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == expected_total_bytes_transferred);
|
||||
BOOST_CHECK(last_bytes_transferred == expected_last_bytes_transferred);
|
||||
BOOST_CHECK(total_bytes_transferred == expected_total_bytes_transferred);
|
||||
}
|
||||
|
||||
void test_async_write_n()
|
||||
@ -346,8 +349,8 @@ void test_async_write_n()
|
||||
sizeof(write_data), sizeof(write_data), &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(1);
|
||||
@ -359,8 +362,8 @@ void test_async_write_n()
|
||||
1, sizeof(write_data), &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(10);
|
||||
@ -372,8 +375,8 @@ void test_async_write_n()
|
||||
sizeof(write_data) % 10, sizeof(write_data), &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
}
|
||||
|
||||
void test_write_at_least_n()
|
||||
@ -385,135 +388,135 @@ void test_write_at_least_n()
|
||||
|
||||
s.reset();
|
||||
size_t last_bytes_transferred = asio::write_at_least_n(s, buffers, 1);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
size_t total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers, 1,
|
||||
&total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers, 10);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers, 10,
|
||||
&total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers,
|
||||
sizeof(write_data));
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers,
|
||||
sizeof(write_data), &total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(1);
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers, 1);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 1));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, 1));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(1);
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers, 1,
|
||||
&total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 1));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(total_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, 1));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(1);
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers, 10);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(1);
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers, 10,
|
||||
&total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(total_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(1);
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers,
|
||||
sizeof(write_data));
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(1);
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers,
|
||||
sizeof(write_data), &total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(10);
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers, 1);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(10);
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers, 1,
|
||||
&total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 10);
|
||||
BOOST_CHECK(total_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(10);
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers, 10);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(10);
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers, 10,
|
||||
&total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 10);
|
||||
BOOST_CHECK(total_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(10);
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers,
|
||||
sizeof(write_data));
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data) % 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data) % 10);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(10);
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers,
|
||||
sizeof(write_data), &total_bytes_transferred);
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data) % 10);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data) % 10);
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
}
|
||||
|
||||
void test_write_at_least_n_with_error_handler()
|
||||
@ -526,140 +529,140 @@ void test_write_at_least_n_with_error_handler()
|
||||
s.reset();
|
||||
size_t last_bytes_transferred = asio::write_at_least_n(s, buffers, 1, 0,
|
||||
asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
size_t total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers, 1,
|
||||
&total_bytes_transferred, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers, 10, 0,
|
||||
asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers, 10,
|
||||
&total_bytes_transferred, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers,
|
||||
sizeof(write_data), 0, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers,
|
||||
sizeof(write_data), &total_bytes_transferred, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(1);
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers, 1, 0,
|
||||
asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 1));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, 1));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(1);
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers, 1,
|
||||
&total_bytes_transferred, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 1));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(total_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, 1));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(1);
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers, 10, 0,
|
||||
asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(1);
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers, 10,
|
||||
&total_bytes_transferred, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(total_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(1);
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers,
|
||||
sizeof(write_data), 0, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(1);
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers,
|
||||
sizeof(write_data), &total_bytes_transferred, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 1);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == 1);
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(10);
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers, 1, 0,
|
||||
asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(10);
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers, 1,
|
||||
&total_bytes_transferred, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 10);
|
||||
BOOST_CHECK(total_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(10);
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers, 10, 0,
|
||||
asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(10);
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers, 10,
|
||||
&total_bytes_transferred, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(last_bytes_transferred == 10);
|
||||
BOOST_CHECK(total_bytes_transferred == 10);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(10);
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers,
|
||||
sizeof(write_data), 0, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data) % 10);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data) % 10);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(10);
|
||||
total_bytes_transferred = 0;
|
||||
last_bytes_transferred = asio::write_at_least_n(s, buffers,
|
||||
sizeof(write_data), &total_bytes_transferred, asio::ignore_error());
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == sizeof(write_data) % 10);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(last_bytes_transferred == sizeof(write_data) % 10);
|
||||
BOOST_CHECK(total_bytes_transferred == sizeof(write_data));
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
}
|
||||
|
||||
void async_write_at_least_n_handler(const asio::error& e,
|
||||
@ -668,8 +671,8 @@ void async_write_at_least_n_handler(const asio::error& e,
|
||||
size_t expected_total_bytes_transferred, bool* called)
|
||||
{
|
||||
*called = true;
|
||||
UNIT_TEST_CHECK(last_bytes_transferred == expected_last_bytes_transferred);
|
||||
UNIT_TEST_CHECK(total_bytes_transferred == expected_total_bytes_transferred);
|
||||
BOOST_CHECK(last_bytes_transferred == expected_last_bytes_transferred);
|
||||
BOOST_CHECK(total_bytes_transferred == expected_total_bytes_transferred);
|
||||
}
|
||||
|
||||
void test_async_write_at_least_n()
|
||||
@ -688,8 +691,8 @@ void test_async_write_at_least_n()
|
||||
sizeof(write_data), sizeof(write_data), &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
called = false;
|
||||
@ -700,8 +703,8 @@ void test_async_write_at_least_n()
|
||||
sizeof(write_data), sizeof(write_data), &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
called = false;
|
||||
@ -712,8 +715,8 @@ void test_async_write_at_least_n()
|
||||
sizeof(write_data), sizeof(write_data), &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(1);
|
||||
@ -724,8 +727,8 @@ void test_async_write_at_least_n()
|
||||
asio::placeholders::total_bytes_transferred, 1, 1, &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 1));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, 1));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(1);
|
||||
@ -736,8 +739,8 @@ void test_async_write_at_least_n()
|
||||
asio::placeholders::total_bytes_transferred, 1, 10, &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(1);
|
||||
@ -749,8 +752,8 @@ void test_async_write_at_least_n()
|
||||
1, sizeof(write_data), &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(10);
|
||||
@ -761,8 +764,8 @@ void test_async_write_at_least_n()
|
||||
asio::placeholders::total_bytes_transferred, 10, 10, &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(10);
|
||||
@ -773,8 +776,8 @@ void test_async_write_at_least_n()
|
||||
asio::placeholders::total_bytes_transferred, 10, 10, &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, 10));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, 10));
|
||||
|
||||
s.reset();
|
||||
s.next_write_length(10);
|
||||
@ -786,23 +789,21 @@ void test_async_write_at_least_n()
|
||||
sizeof(write_data) % 10, sizeof(write_data), &called));
|
||||
d.reset();
|
||||
d.run();
|
||||
UNIT_TEST_CHECK(called);
|
||||
UNIT_TEST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
BOOST_CHECK(called);
|
||||
BOOST_CHECK(s.check(buffers, sizeof(write_data)));
|
||||
}
|
||||
|
||||
void write_test()
|
||||
test_suite* init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
test_write();
|
||||
test_write_with_error_handler();
|
||||
test_async_write();
|
||||
|
||||
test_write_n();
|
||||
test_write_n_with_error_handler();
|
||||
test_async_write_n();
|
||||
|
||||
test_write_at_least_n();
|
||||
test_write_at_least_n_with_error_handler();
|
||||
test_async_write_at_least_n();
|
||||
test_suite* test = BOOST_TEST_SUITE("write");
|
||||
test->add(BOOST_TEST_CASE(&test_write));
|
||||
test->add(BOOST_TEST_CASE(&test_write_with_error_handler));
|
||||
test->add(BOOST_TEST_CASE(&test_async_write));
|
||||
test->add(BOOST_TEST_CASE(&test_write_n));
|
||||
test->add(BOOST_TEST_CASE(&test_write_n_with_error_handler));
|
||||
test->add(BOOST_TEST_CASE(&test_async_write_n));
|
||||
test->add(BOOST_TEST_CASE(&test_write_at_least_n));
|
||||
test->add(BOOST_TEST_CASE(&test_write_at_least_n_with_error_handler));
|
||||
test->add(BOOST_TEST_CASE(&test_async_write_at_least_n));
|
||||
return test;
|
||||
}
|
||||
|
||||
UNIT_TEST(write_test)
|
||||
|
Loading…
Reference in New Issue
Block a user