]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/beast/test/beast/websocket/error.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / beast / test / beast / websocket / error.cpp
1 //
2 // Copyright (c) 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/error.hpp>
12
13 #include <boost/beast/unit_test/suite.hpp>
14 #include <memory>
15
16 namespace boost {
17 namespace beast {
18 namespace websocket {
19
20 class error_test : public unit_test::suite
21 {
22 public:
23 void check(char const* name, error ev)
24 {
25 auto const ec = make_error_code(ev);
26 BEAST_EXPECT(std::string{ec.category().name()} == name);
27 BEAST_EXPECT(! ec.message().empty());
28 BEAST_EXPECT(std::addressof(ec.category()) ==
29 std::addressof(detail::get_error_category()));
30 BEAST_EXPECT(detail::get_error_category().equivalent(
31 static_cast<std::underlying_type<error>::type>(ev),
32 ec.category().default_error_condition(
33 static_cast<std::underlying_type<error>::type>(ev))));
34 BEAST_EXPECT(detail::get_error_category().equivalent(
35 ec, static_cast<std::underlying_type<error>::type>(ev)));
36 }
37
38 void run() override
39 {
40 check("boost.beast.websocket", error::closed);
41 check("boost.beast.websocket", error::failed);
42 check("boost.beast.websocket", error::handshake_failed);
43 check("boost.beast.websocket", error::buffer_overflow);
44 check("boost.beast.websocket", error::partial_deflate_block);
45 }
46 };
47
48 BEAST_DEFINE_TESTSUITE(beast,websocket,error);
49
50 } // websocket
51 } // beast
52 } // boost