From 4d491c401f1a42e127cad688ef67ae1a195b934d Mon Sep 17 00:00:00 2001 From: chris_kohlhoff Date: Tue, 1 Apr 2008 23:49:04 +0000 Subject: [PATCH] Add compile-time tests for the null_buffers support. --- asio/src/tests/unit/ip/tcp.cpp | 15 ++++++++++++++ asio/src/tests/unit/ip/udp.cpp | 37 ++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/asio/src/tests/unit/ip/tcp.cpp b/asio/src/tests/unit/ip/tcp.cpp index 91496817..c7db8728 100644 --- a/asio/src/tests/unit/ip/tcp.cpp +++ b/asio/src/tests/unit/ip/tcp.cpp @@ -239,36 +239,51 @@ void test() socket1.send(buffer(mutable_char_buffer)); socket1.send(buffer(const_char_buffer)); + socket1.send(null_buffers()); socket1.send(buffer(mutable_char_buffer), in_flags); socket1.send(buffer(const_char_buffer), in_flags); + socket1.send(null_buffers(), in_flags); socket1.send(buffer(mutable_char_buffer), in_flags, ec); socket1.send(buffer(const_char_buffer), in_flags, ec); + socket1.send(null_buffers(), in_flags, ec); socket1.async_send(buffer(mutable_char_buffer), send_handler); socket1.async_send(buffer(const_char_buffer), send_handler); + socket1.async_send(null_buffers(), send_handler); socket1.async_send(buffer(mutable_char_buffer), in_flags, send_handler); socket1.async_send(buffer(const_char_buffer), in_flags, send_handler); + socket1.async_send(null_buffers(), in_flags, send_handler); socket1.receive(buffer(mutable_char_buffer)); + socket1.receive(null_buffers()); socket1.receive(buffer(mutable_char_buffer), in_flags); + socket1.receive(null_buffers(), in_flags); socket1.receive(buffer(mutable_char_buffer), in_flags, ec); + socket1.receive(null_buffers(), in_flags, ec); socket1.async_receive(buffer(mutable_char_buffer), receive_handler); + socket1.async_receive(null_buffers(), receive_handler); socket1.async_receive(buffer(mutable_char_buffer), in_flags, receive_handler); + socket1.async_receive(null_buffers(), in_flags, receive_handler); socket1.write_some(buffer(mutable_char_buffer)); socket1.write_some(buffer(const_char_buffer)); + socket1.write_some(null_buffers()); socket1.write_some(buffer(mutable_char_buffer), ec); socket1.write_some(buffer(const_char_buffer), ec); + socket1.write_some(null_buffers(), ec); socket1.async_write_some(buffer(mutable_char_buffer), write_some_handler); socket1.async_write_some(buffer(const_char_buffer), write_some_handler); + socket1.async_write_some(null_buffers(), write_some_handler); socket1.read_some(buffer(mutable_char_buffer)); socket1.read_some(buffer(mutable_char_buffer), ec); + socket1.read_some(null_buffers(), ec); socket1.async_read_some(buffer(mutable_char_buffer), read_some_handler); + socket1.async_read_some(null_buffers(), read_some_handler); } catch (std::exception&) { diff --git a/asio/src/tests/unit/ip/udp.cpp b/asio/src/tests/unit/ip/udp.cpp index 36fe383d..8c59df13 100644 --- a/asio/src/tests/unit/ip/udp.cpp +++ b/asio/src/tests/unit/ip/udp.cpp @@ -144,15 +144,20 @@ void test() socket1.send(buffer(mutable_char_buffer)); socket1.send(buffer(const_char_buffer)); + socket1.send(null_buffers()); socket1.send(buffer(mutable_char_buffer), in_flags); socket1.send(buffer(const_char_buffer), in_flags); + socket1.send(null_buffers(), in_flags); socket1.send(buffer(mutable_char_buffer), in_flags, ec); socket1.send(buffer(const_char_buffer), in_flags, ec); + socket1.send(null_buffers(), in_flags, ec); socket1.async_send(buffer(mutable_char_buffer), send_handler); socket1.async_send(buffer(const_char_buffer), send_handler); + socket1.async_send(null_buffers(), send_handler); socket1.async_send(buffer(mutable_char_buffer), in_flags, send_handler); socket1.async_send(buffer(const_char_buffer), in_flags, send_handler); + socket1.async_send(null_buffers(), in_flags, send_handler); socket1.send_to(buffer(mutable_char_buffer), ip::udp::endpoint(ip::udp::v4(), 0)); @@ -162,6 +167,10 @@ void test() ip::udp::endpoint(ip::udp::v4(), 0)); socket1.send_to(buffer(const_char_buffer), ip::udp::endpoint(ip::udp::v6(), 0)); + socket1.send_to(null_buffers(), + ip::udp::endpoint(ip::udp::v4(), 0)); + socket1.send_to(null_buffers(), + ip::udp::endpoint(ip::udp::v6(), 0)); socket1.send_to(buffer(mutable_char_buffer), ip::udp::endpoint(ip::udp::v4(), 0), in_flags); socket1.send_to(buffer(mutable_char_buffer), @@ -170,6 +179,10 @@ void test() ip::udp::endpoint(ip::udp::v4(), 0), in_flags); socket1.send_to(buffer(const_char_buffer), ip::udp::endpoint(ip::udp::v6(), 0), in_flags); + socket1.send_to(null_buffers(), + ip::udp::endpoint(ip::udp::v4(), 0), in_flags); + socket1.send_to(null_buffers(), + ip::udp::endpoint(ip::udp::v6(), 0), in_flags); socket1.send_to(buffer(mutable_char_buffer), ip::udp::endpoint(ip::udp::v4(), 0), in_flags, ec); socket1.send_to(buffer(mutable_char_buffer), @@ -178,6 +191,10 @@ void test() ip::udp::endpoint(ip::udp::v4(), 0), in_flags, ec); socket1.send_to(buffer(const_char_buffer), ip::udp::endpoint(ip::udp::v6(), 0), in_flags, ec); + socket1.send_to(null_buffers(), + ip::udp::endpoint(ip::udp::v4(), 0), in_flags, ec); + socket1.send_to(null_buffers(), + ip::udp::endpoint(ip::udp::v6(), 0), in_flags, ec); socket1.async_send_to(buffer(mutable_char_buffer), ip::udp::endpoint(ip::udp::v4(), 0), send_handler); @@ -187,6 +204,10 @@ void test() ip::udp::endpoint(ip::udp::v4(), 0), send_handler); socket1.async_send_to(buffer(const_char_buffer), ip::udp::endpoint(ip::udp::v6(), 0), send_handler); + socket1.async_send_to(null_buffers(), + ip::udp::endpoint(ip::udp::v4(), 0), send_handler); + socket1.async_send_to(null_buffers(), + ip::udp::endpoint(ip::udp::v6(), 0), send_handler); socket1.async_send_to(buffer(mutable_char_buffer), ip::udp::endpoint(ip::udp::v4(), 0), in_flags, send_handler); socket1.async_send_to(buffer(mutable_char_buffer), @@ -195,24 +216,40 @@ void test() ip::udp::endpoint(ip::udp::v4(), 0), in_flags, send_handler); socket1.async_send_to(buffer(const_char_buffer), ip::udp::endpoint(ip::udp::v6(), 0), in_flags, send_handler); + socket1.async_send_to(null_buffers(), + ip::udp::endpoint(ip::udp::v4(), 0), in_flags, send_handler); + socket1.async_send_to(null_buffers(), + ip::udp::endpoint(ip::udp::v6(), 0), in_flags, send_handler); socket1.receive(buffer(mutable_char_buffer)); + socket1.receive(null_buffers()); socket1.receive(buffer(mutable_char_buffer), in_flags); + socket1.receive(null_buffers(), in_flags); socket1.receive(buffer(mutable_char_buffer), in_flags, ec); + socket1.receive(null_buffers(), in_flags, ec); socket1.async_receive(buffer(mutable_char_buffer), receive_handler); + socket1.async_receive(null_buffers(), receive_handler); socket1.async_receive(buffer(mutable_char_buffer), in_flags, receive_handler); + socket1.async_receive(null_buffers(), in_flags, receive_handler); ip::udp::endpoint endpoint; socket1.receive_from(buffer(mutable_char_buffer), endpoint); + socket1.receive_from(null_buffers(), endpoint); socket1.receive_from(buffer(mutable_char_buffer), endpoint, in_flags); + socket1.receive_from(null_buffers(), endpoint, in_flags); socket1.receive_from(buffer(mutable_char_buffer), endpoint, in_flags, ec); + socket1.receive_from(null_buffers(), endpoint, in_flags, ec); socket1.async_receive_from(buffer(mutable_char_buffer), endpoint, receive_handler); + socket1.async_receive_from(null_buffers(), + endpoint, receive_handler); socket1.async_receive_from(buffer(mutable_char_buffer), endpoint, in_flags, receive_handler); + socket1.async_receive_from(null_buffers(), + endpoint, in_flags, receive_handler); } catch (std::exception&) {