]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // |
b32b8144 | 2 | // Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) |
7c673cae FG |
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 | // | |
b32b8144 FG |
7 | // Official repository: https://github.com/boostorg/beast |
8 | // | |
7c673cae FG |
9 | |
10 | // Test that header file is self-contained. | |
b32b8144 | 11 | #include <boost/beast/websocket/error.hpp> |
7c673cae | 12 | |
b32b8144 | 13 | #include <boost/beast/unit_test/suite.hpp> |
7c673cae FG |
14 | #include <memory> |
15 | ||
b32b8144 | 16 | namespace boost { |
7c673cae FG |
17 | namespace beast { |
18 | namespace websocket { | |
19 | ||
20 | class error_test : public unit_test::suite | |
21 | { | |
22 | public: | |
11fdf7f2 | 23 | void check(error e) |
7c673cae | 24 | { |
11fdf7f2 TL |
25 | auto const ec = make_error_code(e); |
26 | ec.category().name(); | |
7c673cae | 27 | BEAST_EXPECT(! ec.message().empty()); |
11fdf7f2 TL |
28 | BEAST_EXPECT(ec != condition::handshake_failed); |
29 | BEAST_EXPECT(ec != condition::protocol_violation); | |
30 | } | |
31 | ||
32 | void check(condition c, error e) | |
33 | { | |
34 | auto const ec = make_error_code(e); | |
35 | BEAST_EXPECT(ec.category().name() != nullptr); | |
36 | BEAST_EXPECT(! ec.message().empty()); | |
37 | BEAST_EXPECT(ec == c); | |
7c673cae FG |
38 | } |
39 | ||
40 | void run() override | |
41 | { | |
11fdf7f2 TL |
42 | check(error::closed); |
43 | check(error::buffer_overflow); | |
44 | check(error::partial_deflate_block); | |
45 | check(error::message_too_big); | |
46 | ||
47 | check(condition::protocol_violation, error::bad_opcode); | |
48 | check(condition::protocol_violation, error::bad_data_frame); | |
49 | check(condition::protocol_violation, error::bad_continuation); | |
50 | check(condition::protocol_violation, error::bad_reserved_bits); | |
51 | check(condition::protocol_violation, error::bad_control_fragment); | |
52 | check(condition::protocol_violation, error::bad_control_size); | |
53 | check(condition::protocol_violation, error::bad_unmasked_frame); | |
54 | check(condition::protocol_violation, error::bad_masked_frame); | |
55 | check(condition::protocol_violation, error::bad_size); | |
56 | check(condition::protocol_violation, error::bad_frame_payload); | |
57 | check(condition::protocol_violation, error::bad_close_code); | |
58 | check(condition::protocol_violation, error::bad_close_size); | |
59 | check(condition::protocol_violation, error::bad_close_payload); | |
60 | ||
61 | check(condition::handshake_failed, error::bad_http_version); | |
62 | check(condition::handshake_failed, error::bad_method); | |
63 | check(condition::handshake_failed, error::no_host); | |
64 | check(condition::handshake_failed, error::no_connection); | |
65 | check(condition::handshake_failed, error::no_connection_upgrade); | |
66 | check(condition::handshake_failed, error::no_upgrade); | |
67 | check(condition::handshake_failed, error::no_upgrade_websocket); | |
68 | check(condition::handshake_failed, error::no_sec_key); | |
69 | check(condition::handshake_failed, error::bad_sec_key); | |
70 | check(condition::handshake_failed, error::no_sec_version); | |
71 | check(condition::handshake_failed, error::bad_sec_version); | |
72 | check(condition::handshake_failed, error::no_sec_accept); | |
73 | check(condition::handshake_failed, error::bad_sec_accept); | |
74 | check(condition::handshake_failed, error::upgrade_declined); | |
7c673cae FG |
75 | } |
76 | }; | |
77 | ||
b32b8144 | 78 | BEAST_DEFINE_TESTSUITE(beast,websocket,error); |
7c673cae FG |
79 | |
80 | } // websocket | |
81 | } // beast | |
b32b8144 | 82 | } // boost |