]> git.proxmox.com Git - ceph.git/blob - ceph/src/Beast/test/http/error.cpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / Beast / test / http / error.cpp
1 //
2 // Copyright (c) 2013-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
8 // Test that header file is self-contained.
9 #include <beast/http/error.hpp>
10
11 #include <beast/unit_test/suite.hpp>
12 #include <memory>
13
14 namespace beast {
15 namespace http {
16
17 class error_test : public unit_test::suite
18 {
19 public:
20 void
21 check(char const* name, error ev)
22 {
23 auto const ec = make_error_code(ev);
24 BEAST_EXPECT(std::string(ec.category().name()) == name);
25 BEAST_EXPECT(! ec.message().empty());
26 BEAST_EXPECT(std::addressof(ec.category()) ==
27 std::addressof(detail::get_http_error_category()));
28 BEAST_EXPECT(detail::get_http_error_category().equivalent(
29 static_cast<std::underlying_type<error>::type>(ev),
30 ec.category().default_error_condition(
31 static_cast<std::underlying_type<error>::type>(ev))));
32 BEAST_EXPECT(detail::get_http_error_category().equivalent(
33 ec, static_cast<std::underlying_type<error>::type>(ev)));
34 }
35
36 void
37 run() override
38 {
39 check("http", error::end_of_stream);
40 check("http", error::partial_message);
41 check("http", error::buffer_overflow);
42 check("http", error::bad_line_ending);
43 check("http", error::bad_method);
44 check("http", error::bad_path);
45 check("http", error::bad_version);
46 check("http", error::bad_status);
47 check("http", error::bad_reason);
48 check("http", error::bad_field);
49 check("http", error::bad_value);
50 check("http", error::bad_content_length);
51 check("http", error::bad_transfer_encoding);
52 check("http", error::bad_chunk);
53 }
54 };
55
56 BEAST_DEFINE_TESTSUITE(error,http,beast);
57
58 } // http
59 } // beast