]>
Commit | Line | Data |
---|---|---|
92f5a8d4 TL |
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> | |
92f5a8d4 TL |
17 | #include <boost/asio/use_future.hpp> |
18 | ||
19 | namespace boost { | |
20 | namespace beast { | |
21 | ||
22 | template<class SyncReadStream> | |
23 | void | |
24 | test_sync_read_stream() | |
25 | { | |
26 | BOOST_ASSERT(is_sync_read_stream<SyncReadStream>::value); | |
27 | BEAST_EXPECT(static_cast< | |
28 | std::size_t(SyncReadStream::*)(net::mutable_buffer const&)>( | |
29 | &SyncReadStream::template read_some<net::mutable_buffer>)); | |
30 | BEAST_EXPECT(static_cast< | |
31 | std::size_t(SyncReadStream::*)(net::mutable_buffer const&, error_code&)>( | |
32 | &SyncReadStream::template read_some<net::mutable_buffer>)); | |
33 | } | |
34 | ||
35 | template<class SyncWriteStream> | |
36 | void | |
37 | test_sync_write_stream() | |
38 | { | |
39 | BOOST_ASSERT(is_sync_write_stream<SyncWriteStream>::value); | |
40 | BEAST_EXPECT(static_cast< | |
41 | std::size_t(SyncWriteStream::*)(net::const_buffer const&)>( | |
42 | &SyncWriteStream::template write_some<net::const_buffer>)); | |
43 | BEAST_EXPECT(static_cast< | |
44 | std::size_t(SyncWriteStream::*)(net::const_buffer const&, error_code&)>( | |
45 | &SyncWriteStream::template write_some<net::const_buffer>)); | |
46 | } | |
47 | ||
48 | template<class SyncReadStream> | |
49 | void | |
50 | test_sync_stream() | |
51 | { | |
52 | test_sync_read_stream<SyncReadStream>(); | |
53 | test_sync_write_stream<SyncReadStream>(); | |
54 | } | |
55 | ||
56 | template<class AsyncReadStream> | |
57 | void | |
58 | test_async_read_stream() | |
59 | { | |
60 | struct handler | |
61 | { | |
62 | void operator()(error_code, std::size_t) | |
63 | { | |
64 | } | |
65 | }; | |
66 | ||
67 | BOOST_ASSERT(is_async_read_stream<AsyncReadStream>::value); | |
68 | BEAST_EXPECT(&AsyncReadStream::get_executor); | |
69 | ||
70 | // VFALCO These stopped working because of enable_if as the last parameter | |
71 | //BEAST_EXPECT((&AsyncReadStream::template async_read_some<net::mutable_buffer, handler>)); | |
72 | //BEAST_EXPECT((&AsyncReadStream::template async_read_some<net::mutable_buffer, net::use_future_t<>>)); | |
73 | //BEAST_EXPECT((&AsyncReadStream::template async_read_some<net::mutable_buffer, net::yield_context>)); | |
74 | } | |
75 | ||
76 | template<class AsyncWriteStream> | |
77 | void | |
78 | test_async_write_stream() | |
79 | { | |
80 | struct handler | |
81 | { | |
82 | void operator()(error_code, std::size_t) | |
83 | { | |
84 | } | |
85 | }; | |
86 | ||
87 | BOOST_ASSERT(is_async_write_stream<AsyncWriteStream>::value); | |
88 | BEAST_EXPECT(&AsyncWriteStream::get_executor); | |
89 | // VFALCO These stopped working because of enable_if as the last parameter | |
90 | //BEAST_EXPECT((&AsyncWriteStream::template async_write_some<net::const_buffer, handler>)); | |
91 | //BEAST_EXPECT((&AsyncWriteStream::template async_write_some<net::const_buffer, net::use_future_t<>>)); | |
92 | //BEAST_EXPECT((&AsyncWriteStream::template async_write_some<net::const_buffer, net::yield_context>)); | |
93 | } | |
94 | ||
95 | template<class AsyncStream> | |
96 | void | |
97 | test_async_stream() | |
98 | { | |
99 | test_async_read_stream<AsyncStream>(); | |
100 | test_async_write_stream<AsyncStream>(); | |
101 | } | |
102 | ||
103 | } // beast | |
104 | } // boost | |
105 | ||
106 | #endif |