]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // |
2 | // Copyright (c) 2013-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 | ||
8 | // Test that header file is self-contained. | |
9 | #include <beast/websocket/error.hpp> | |
10 | ||
11 | #include <beast/unit_test/suite.hpp> | |
12 | #include <memory> | |
13 | ||
14 | namespace beast { | |
15 | namespace websocket { | |
16 | ||
17 | class error_test : public unit_test::suite | |
18 | { | |
19 | public: | |
20 | void check(char const* name, error ev) | |
21 | { | |
22 | auto const ec = make_error_code(ev); | |
23 | BEAST_EXPECT(std::string{ec.category().name()} == name); | |
24 | BEAST_EXPECT(! ec.message().empty()); | |
25 | BEAST_EXPECT(std::addressof(ec.category()) == | |
26 | std::addressof(detail::get_error_category())); | |
27 | BEAST_EXPECT(detail::get_error_category().equivalent( | |
28 | static_cast<std::underlying_type<error>::type>(ev), | |
29 | ec.category().default_error_condition( | |
30 | static_cast<std::underlying_type<error>::type>(ev)))); | |
31 | BEAST_EXPECT(detail::get_error_category().equivalent( | |
32 | ec, static_cast<std::underlying_type<error>::type>(ev))); | |
33 | } | |
34 | ||
35 | void run() override | |
36 | { | |
37 | check("websocket", error::closed); | |
38 | check("websocket", error::failed); | |
39 | check("websocket", error::handshake_failed); | |
40 | check("websocket", error::keep_alive); | |
41 | check("websocket", error::response_malformed); | |
42 | check("websocket", error::response_failed); | |
43 | check("websocket", error::response_denied); | |
44 | check("websocket", error::request_malformed); | |
45 | check("websocket", error::request_invalid); | |
46 | check("websocket", error::request_denied); | |
47 | check("websocket", error::general); | |
48 | } | |
49 | }; | |
50 | ||
51 | BEAST_DEFINE_TESTSUITE(error,websocket,beast); | |
52 | ||
53 | } // websocket | |
54 | } // beast |