• 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/beast/websocket/detail/frame.hpp>
11 #include <boost/beast/_experimental/unit_test/suite.hpp>
12 
13 namespace boost {
14 namespace beast {
15 namespace websocket {
16 namespace detail {
17 
18 class frame_test
19     : public beast::unit_test::suite
20 {
21 public:
testCloseCodes()22     void testCloseCodes()
23     {
24         BEAST_EXPECT(! is_valid_close_code(0));
25         BEAST_EXPECT(! is_valid_close_code(1));
26         BEAST_EXPECT(! is_valid_close_code(999));
27         BEAST_EXPECT(! is_valid_close_code(1004));
28         BEAST_EXPECT(! is_valid_close_code(1005));
29         BEAST_EXPECT(! is_valid_close_code(1006));
30         BEAST_EXPECT(! is_valid_close_code(1016));
31         BEAST_EXPECT(! is_valid_close_code(2000));
32         BEAST_EXPECT(! is_valid_close_code(2999));
33         BEAST_EXPECT(is_valid_close_code(1000));
34         BEAST_EXPECT(is_valid_close_code(1002));
35         BEAST_EXPECT(is_valid_close_code(3000));
36         BEAST_EXPECT(is_valid_close_code(4000));
37         BEAST_EXPECT(is_valid_close_code(5000));
38     }
39 
40     struct test_fh : frame_header
41     {
test_fhboost::beast::websocket::detail::frame_test::test_fh42         test_fh()
43         {
44             op = detail::opcode::text;
45             fin =  true;
46             mask = false;
47             rsv1 = false;
48             rsv2 = false;
49             rsv3 = false;
50             len = 0;
51             key = 0;
52         }
53     };
54 
55     void
testWriteFrame()56     testWriteFrame()
57     {
58         test_fh fh;
59         fh.rsv2 = true;
60         fh.rsv3 = true;
61         fh.len = 65536;
62         frame_buffer fb;
63         write(fb, fh);
64     }
65 
run()66     void run() override
67     {
68         testWriteFrame();
69         testCloseCodes();
70     }
71 };
72 
73 BEAST_DEFINE_TESTSUITE(beast,websocket,frame);
74 
75 } // detail
76 } // websocket
77 } // beast
78 } // boost
79