2017-07-20 08:01:46 -07:00
|
|
|
//
|
|
|
|
|
// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com)
|
|
|
|
|
//
|
|
|
|
|
// 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(static_cast<int>(ev),
|
2016-05-06 21:51:43 -04:00
|
|
|
ec.category().default_error_condition(static_cast<int>(ev))));
|
2016-08-03 15:34:23 -04:00
|
|
|
BEAST_EXPECT(detail::get_error_category().equivalent(
|
2016-05-06 21:51:43 -04:00
|
|
|
ec, static_cast<int>(ev)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
} // http
|
|
|
|
|
} // beast
|