]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/beast/test/beast/core/stream_tests.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / beast / test / beast / core / stream_tests.hpp
1 //
2 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
3 //
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)
6 //
7 // Official repository: https://github.com/boostorg/beast
8 //
9
10 #ifndef BOOST_BEAST_STREAM_TESTS_HPP
11 #define BOOST_BEAST_STREAM_TESTS_HPP
12
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>
19
20 namespace boost {
21 namespace beast {
22
23 template<class SyncReadStream>
24 void
25 test_sync_read_stream()
26 {
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>));
34 }
35
36 template<class SyncWriteStream>
37 void
38 test_sync_write_stream()
39 {
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>));
47 }
48
49 template<class SyncReadStream>
50 void
51 test_sync_stream()
52 {
53 test_sync_read_stream<SyncReadStream>();
54 test_sync_write_stream<SyncReadStream>();
55 }
56
57 template<class AsyncReadStream>
58 void
59 test_async_read_stream()
60 {
61 struct handler
62 {
63 void operator()(error_code, std::size_t)
64 {
65 }
66 };
67
68 BOOST_ASSERT(is_async_read_stream<AsyncReadStream>::value);
69 BEAST_EXPECT(&AsyncReadStream::get_executor);
70
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>));
75 }
76
77 template<class AsyncWriteStream>
78 void
79 test_async_write_stream()
80 {
81 struct handler
82 {
83 void operator()(error_code, std::size_t)
84 {
85 }
86 };
87
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>));
94 }
95
96 template<class AsyncStream>
97 void
98 test_async_stream()
99 {
100 test_async_read_stream<AsyncStream>();
101 test_async_write_stream<AsyncStream>();
102 }
103
104 } // beast
105 } // boost
106
107 #endif