]>
git.proxmox.com Git - ceph.git/blob - ceph/src/Beast/test/websocket/error.cpp
2 // Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
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)
8 // Test that header file is self-contained.
9 #include <beast/websocket/error.hpp>
11 #include <beast/unit_test/suite.hpp>
17 class error_test
: public unit_test::suite
20 void check(char const* name
, error ev
)
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
)));
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
);
51 BEAST_DEFINE_TESTSUITE(error
,websocket
,beast
);