Files
beast/test/websocket/error.cpp
T

55 lines
1.8 KiB
C++
Raw Normal View History

2016-04-22 14:59:53 -04:00
//
2017-02-06 20:07:03 -05:00
// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
2016-04-22 14:59:53 -04:00
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Test that header file is self-contained.
#include <beast/websocket/error.hpp>
2016-05-06 21:51:43 -04:00
#include <beast/unit_test/suite.hpp>
#include <memory>
namespace beast {
namespace websocket {
class error_test : public unit_test::suite
{
public:
void check(char const* name, error ev)
{
auto const ec = make_error_code(ev);
2016-08-03 15:34:23 -04:00
BEAST_EXPECT(std::string{ec.category().name()} == name);
BEAST_EXPECT(! ec.message().empty());
BEAST_EXPECT(std::addressof(ec.category()) ==
2016-05-06 21:51:43 -04:00
std::addressof(detail::get_error_category()));
2016-08-03 15:34:23 -04:00
BEAST_EXPECT(detail::get_error_category().equivalent(
2016-10-04 18:00:11 -04:00
static_cast<std::underlying_type<error>::type>(ev),
ec.category().default_error_condition(
static_cast<std::underlying_type<error>::type>(ev))));
BEAST_EXPECT(detail::get_error_category().equivalent(
ec, static_cast<std::underlying_type<error>::type>(ev)));
2016-05-06 21:51:43 -04:00
}
void run() override
{
check("websocket", error::closed);
check("websocket", error::failed);
check("websocket", error::handshake_failed);
check("websocket", error::keep_alive);
check("websocket", error::response_malformed);
check("websocket", error::response_failed);
check("websocket", error::response_denied);
check("websocket", error::request_malformed);
check("websocket", error::request_invalid);
check("websocket", error::request_denied);
2016-05-07 17:06:46 -04:00
check("websocket", error::general);
2016-05-06 21:51:43 -04:00
}
};
BEAST_DEFINE_TESTSUITE(error,websocket,beast);
2016-10-18 19:43:36 -04:00
} // websocket
2016-05-06 21:51:43 -04:00
} // beast