]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/beast/test/beast/websocket/stream.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / beast / test / beast / websocket / stream.cpp
1 //
2 // Copyright (w) 2016-2017 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 // Test that header file is self-contained.
11 #include <boost/beast/websocket/stream.hpp>
12
13 #include "test.hpp"
14
15 namespace boost {
16 namespace beast {
17 namespace websocket {
18
19 class stream_test : public websocket_test_suite
20 {
21 public:
22 void
23 testOptions()
24 {
25 stream<test::stream> ws{ioc_};
26 ws.auto_fragment(true);
27 ws.write_buffer_size(2048);
28 ws.binary(false);
29 ws.read_message_max(1 * 1024 * 1024);
30 try
31 {
32 ws.write_buffer_size(7);
33 fail();
34 }
35 catch(std::exception const&)
36 {
37 pass();
38 }
39
40 auto const bad =
41 [&](permessage_deflate const& pmd)
42 {
43 stream<test::stream> ws{ioc_};
44 try
45 {
46 ws.set_option(pmd);
47 fail("", __FILE__, __LINE__);
48 }
49 catch(std::exception const&)
50 {
51 pass();
52 }
53 };
54
55 {
56 permessage_deflate pmd;
57 pmd.server_max_window_bits = 16;
58 bad(pmd);
59 }
60
61 {
62 permessage_deflate pmd;
63 pmd.server_max_window_bits = 8;
64 bad(pmd);
65 }
66
67 {
68 permessage_deflate pmd;
69 pmd.client_max_window_bits = 16;
70 bad(pmd);
71 }
72
73 {
74 permessage_deflate pmd;
75 pmd.client_max_window_bits = 8;
76 bad(pmd);
77 }
78
79 {
80 permessage_deflate pmd;
81 pmd.compLevel = -1;
82 bad(pmd);
83 }
84
85 {
86 permessage_deflate pmd;
87 pmd.compLevel = 10;
88 bad(pmd);
89 }
90
91 {
92 permessage_deflate pmd;
93 pmd.memLevel = 0;
94 bad(pmd);
95 }
96
97 {
98 permessage_deflate pmd;
99 pmd.memLevel = 10;
100 bad(pmd);
101 }
102 }
103
104 void
105 run() override
106 {
107 BOOST_STATIC_ASSERT(std::is_constructible<
108 stream<test::stream>, boost::asio::io_context&>::value);
109
110 BOOST_STATIC_ASSERT(std::is_move_constructible<
111 stream<test::stream>>::value);
112
113 BOOST_STATIC_ASSERT(std::is_move_assignable<
114 stream<test::stream>>::value);
115
116 BOOST_STATIC_ASSERT(std::is_constructible<
117 stream<test::stream&>, test::stream&>::value);
118
119 BOOST_STATIC_ASSERT(std::is_move_constructible<
120 stream<test::stream&>>::value);
121
122 BOOST_STATIC_ASSERT(! std::is_move_assignable<
123 stream<test::stream&>>::value);
124
125 log << "sizeof(websocket::stream) == " <<
126 sizeof(websocket::stream<test::stream&>) << std::endl;
127
128 testOptions();
129 }
130 };
131
132 BEAST_DEFINE_TESTSUITE(beast,websocket,stream);
133
134 } // websocket
135 } // beast
136 } // boost