2016-11-20 07:32:41 -05:00
|
|
|
//
|
2019-02-21 07:00:31 -08:00
|
|
|
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
2016-11-20 07:32:41 -05: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)
|
|
|
|
|
//
|
2017-07-20 13:40:34 -07:00
|
|
|
// Official repository: https://github.com/boostorg/beast
|
|
|
|
|
//
|
2016-11-20 07:32:41 -05:00
|
|
|
|
|
|
|
|
// Test that header file is self-contained.
|
2017-07-20 13:40:34 -07:00
|
|
|
#include <boost/beast/http/error.hpp>
|
2016-11-20 07:32:41 -05:00
|
|
|
|
2018-11-11 14:07:55 -08:00
|
|
|
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
2016-11-20 07:32:41 -05:00
|
|
|
#include <memory>
|
|
|
|
|
|
2017-07-20 13:40:34 -07:00
|
|
|
namespace boost {
|
2016-11-20 07:32:41 -05:00
|
|
|
namespace beast {
|
|
|
|
|
namespace http {
|
|
|
|
|
|
|
|
|
|
class error_test : public unit_test::suite
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
void
|
|
|
|
|
check(char const* name, error ev)
|
|
|
|
|
{
|
|
|
|
|
auto const ec = make_error_code(ev);
|
2019-02-22 13:06:43 -08:00
|
|
|
auto const& cat = make_error_code(
|
|
|
|
|
static_cast<http::error>(0)).category();
|
2017-07-25 12:35:54 -07:00
|
|
|
BEAST_EXPECT(std::string(ec.category().name()) == name);
|
|
|
|
|
BEAST_EXPECT(! ec.message().empty());
|
2019-02-22 13:06:43 -08:00
|
|
|
BEAST_EXPECT(
|
|
|
|
|
std::addressof(ec.category()) == std::addressof(cat));
|
2018-09-25 06:13:12 -07:00
|
|
|
BEAST_EXPECT(cat.equivalent(
|
2016-11-20 07:32:41 -05:00
|
|
|
static_cast<std::underlying_type<error>::type>(ev),
|
|
|
|
|
ec.category().default_error_condition(
|
|
|
|
|
static_cast<std::underlying_type<error>::type>(ev))));
|
2018-09-25 06:13:12 -07:00
|
|
|
BEAST_EXPECT(cat.equivalent(ec,
|
|
|
|
|
static_cast<std::underlying_type<error>::type>(ev)));
|
2016-11-20 07:32:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
run() override
|
|
|
|
|
{
|
2017-06-17 18:00:01 -07:00
|
|
|
check("beast.http", error::end_of_stream);
|
|
|
|
|
check("beast.http", error::partial_message);
|
|
|
|
|
check("beast.http", error::need_more);
|
|
|
|
|
check("beast.http", error::unexpected_body);
|
|
|
|
|
check("beast.http", error::need_buffer);
|
2017-07-12 18:06:36 -07:00
|
|
|
check("beast.http", error::end_of_chunk);
|
2017-06-17 18:00:01 -07:00
|
|
|
check("beast.http", error::buffer_overflow);
|
2017-10-10 08:17:16 -07:00
|
|
|
check("beast.http", error::header_limit);
|
2017-06-27 21:00:53 -07:00
|
|
|
check("beast.http", error::body_limit);
|
2017-06-23 02:22:15 -07:00
|
|
|
check("beast.http", error::bad_alloc);
|
2017-06-17 18:00:01 -07:00
|
|
|
|
|
|
|
|
check("beast.http", error::bad_line_ending);
|
|
|
|
|
check("beast.http", error::bad_method);
|
2017-06-25 17:18:02 -07:00
|
|
|
check("beast.http", error::bad_target);
|
2017-06-17 18:00:01 -07:00
|
|
|
check("beast.http", error::bad_version);
|
|
|
|
|
check("beast.http", error::bad_status);
|
|
|
|
|
check("beast.http", error::bad_reason);
|
|
|
|
|
check("beast.http", error::bad_field);
|
|
|
|
|
check("beast.http", error::bad_value);
|
|
|
|
|
check("beast.http", error::bad_content_length);
|
|
|
|
|
check("beast.http", error::bad_transfer_encoding);
|
|
|
|
|
check("beast.http", error::bad_chunk);
|
2017-07-12 18:06:36 -07:00
|
|
|
check("beast.http", error::bad_chunk_extension);
|
2017-06-17 18:00:01 -07:00
|
|
|
check("beast.http", error::bad_obs_fold);
|
2019-02-28 10:27:43 -08:00
|
|
|
|
|
|
|
|
check("beast.http", error::stale_parser);
|
2020-01-24 11:28:24 +01:00
|
|
|
check("beast.http", error::short_read);
|
2016-11-20 07:32:41 -05:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2017-08-01 17:01:57 -07:00
|
|
|
BEAST_DEFINE_TESTSUITE(beast,http,error);
|
2016-11-20 07:32:41 -05:00
|
|
|
|
|
|
|
|
} // http
|
|
|
|
|
} // beast
|
2017-07-20 13:40:34 -07:00
|
|
|
} // boost
|