• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <boost/config.hpp>
11 
12 #ifdef BOOST_MSVC
13 #pragma warning(push)
14 #pragma warning(disable: 4459) // declaration hides global declaration
15 #endif
16 
17 #include <boost/beast/_experimental/unit_test/suite.hpp>
18 
19 #include <boost/beast.hpp>
20 #include <boost/beast/ssl.hpp>
21 #include <boost/asio.hpp>
22 #include <boost/asio/ssl.hpp>
23 
24 namespace {
25 
26 #include "websocket_common.ipp"
27 
28 //[code_websocket_7_1
29 
30 struct custom_stream;
31 
32 void
33 teardown(
34     role_type role,
35     custom_stream& stream,
36     error_code& ec);
37 
38 template<class TeardownHandler>
39 void
40 async_teardown(
41     role_type role,
42     custom_stream& stream,
43     TeardownHandler&& handler);
44 
45 //]
46 
47 void
teardown(role_type,custom_stream &,error_code &)48 teardown(
49     role_type,
50     custom_stream&,
51     error_code&)
52 {
53 }
54 
55 //[code_websocket_7_2
56 
57 template <class NextLayer>
58 struct custom_wrapper
59 {
60     NextLayer next_layer;
61 
62     template<class... Args>
63     explicit
custom_wrapper__anon7fe790b40111::custom_wrapper64     custom_wrapper(Args&&... args)
65         : next_layer(std::forward<Args>(args)...)
66     {
67     }
68 
69     friend
70     void
teardown(role_type role,custom_wrapper & stream,error_code & ec)71     teardown(
72         role_type role,
73         custom_wrapper& stream,
74         error_code& ec)
75     {
76         using boost::beast::websocket::teardown;
77         teardown(role, stream.next_layer, ec);
78     }
79 
80     template<class TeardownHandler>
81     friend
82     void
async_teardown(role_type role,custom_wrapper & stream,TeardownHandler && handler)83     async_teardown(
84         role_type role,
85         custom_wrapper& stream,
86         TeardownHandler&& handler)
87     {
88         using boost::beast::websocket::async_teardown;
89         async_teardown(role, stream.next_layer, std::forward<TeardownHandler>(handler));
90     }
91 };
92 
93 //]
94 
95 void
snippets()96 snippets()
97 {
98     //stream<tcp_stream> ws(ioc);
99 
100     {
101     //[code_websocket_7_3
102 
103     //]
104     }
105 }
106 
107 struct websocket_7_test
108     : public boost::beast::unit_test::suite
109 {
110     void
run__anon7fe790b40111::websocket_7_test111     run() override
112     {
113         BEAST_EXPECT(&snippets);
114         BEAST_EXPECT(static_cast<void(*)(
115             role_type, custom_stream&, error_code&)>(
116                 &teardown));
117     }
118 };
119 
120 BEAST_DEFINE_TESTSUITE(beast,doc,websocket_7);
121 
122 } // (anon)
123 
124 #ifdef BOOST_MSVC
125 #pragma warning(pop)
126 #endif
127