2 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // Official repository: https://github.com/boostorg/beast
10 #ifndef BOOST_BEAST_STREAM_TESTS_HPP
11 #define BOOST_BEAST_STREAM_TESTS_HPP
13 #include <boost/beast/_experimental/unit_test/suite.hpp>
14 #include <boost/beast/core/error.hpp>
15 #include <boost/beast/core/stream_traits.hpp>
16 #include <boost/asio/buffer.hpp>
17 #include <boost/asio/spawn.hpp>
18 #include <boost/asio/use_future.hpp>
23 template<class SyncReadStream>
25 test_sync_read_stream()
27 BOOST_ASSERT(is_sync_read_stream<SyncReadStream>::value);
28 BEAST_EXPECT(static_cast<
29 std::size_t(SyncReadStream::*)(net::mutable_buffer const&)>(
30 &SyncReadStream::template read_some<net::mutable_buffer>));
31 BEAST_EXPECT(static_cast<
32 std::size_t(SyncReadStream::*)(net::mutable_buffer const&, error_code&)>(
33 &SyncReadStream::template read_some<net::mutable_buffer>));
36 template<class SyncWriteStream>
38 test_sync_write_stream()
40 BOOST_ASSERT(is_sync_write_stream<SyncWriteStream>::value);
41 BEAST_EXPECT(static_cast<
42 std::size_t(SyncWriteStream::*)(net::const_buffer const&)>(
43 &SyncWriteStream::template write_some<net::const_buffer>));
44 BEAST_EXPECT(static_cast<
45 std::size_t(SyncWriteStream::*)(net::const_buffer const&, error_code&)>(
46 &SyncWriteStream::template write_some<net::const_buffer>));
49 template<class SyncReadStream>
53 test_sync_read_stream<SyncReadStream>();
54 test_sync_write_stream<SyncReadStream>();
57 template<class AsyncReadStream>
59 test_async_read_stream()
63 void operator()(error_code, std::size_t)
68 BOOST_ASSERT(is_async_read_stream<AsyncReadStream>::value);
69 BEAST_EXPECT(&AsyncReadStream::get_executor);
71 // VFALCO These stopped working because of enable_if as the last parameter
72 //BEAST_EXPECT((&AsyncReadStream::template async_read_some<net::mutable_buffer, handler>));
73 //BEAST_EXPECT((&AsyncReadStream::template async_read_some<net::mutable_buffer, net::use_future_t<>>));
74 //BEAST_EXPECT((&AsyncReadStream::template async_read_some<net::mutable_buffer, net::yield_context>));
77 template<class AsyncWriteStream>
79 test_async_write_stream()
83 void operator()(error_code, std::size_t)
88 BOOST_ASSERT(is_async_write_stream<AsyncWriteStream>::value);
89 BEAST_EXPECT(&AsyncWriteStream::get_executor);
90 // VFALCO These stopped working because of enable_if as the last parameter
91 //BEAST_EXPECT((&AsyncWriteStream::template async_write_some<net::const_buffer, handler>));
92 //BEAST_EXPECT((&AsyncWriteStream::template async_write_some<net::const_buffer, net::use_future_t<>>));
93 //BEAST_EXPECT((&AsyncWriteStream::template async_write_some<net::const_buffer, net::yield_context>));
96 template<class AsyncStream>
100 test_async_read_stream<AsyncStream>();
101 test_async_write_stream<AsyncStream>();