]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // |
92f5a8d4 | 2 | // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) |
7c673cae FG |
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 | // | |
b32b8144 FG |
7 | // Official repository: https://github.com/boostorg/beast |
8 | // | |
7c673cae FG |
9 | |
10 | // Test that header file is self-contained. | |
b32b8144 | 11 | #include <boost/beast/zlib/error.hpp> |
7c673cae | 12 | |
92f5a8d4 | 13 | #include <boost/beast/_experimental/unit_test/suite.hpp> |
7c673cae FG |
14 | #include <memory> |
15 | ||
b32b8144 | 16 | namespace boost { |
7c673cae FG |
17 | namespace beast { |
18 | namespace zlib { | |
19 | ||
20 | class error_test : public unit_test::suite | |
21 | { | |
22 | public: | |
23 | void check(char const* name, error ev) | |
24 | { | |
25 | auto const ec = make_error_code(ev); | |
92f5a8d4 TL |
26 | auto const& cat = make_error_code( |
27 | static_cast<zlib::error>(0)).category(); | |
7c673cae FG |
28 | BEAST_EXPECT(std::string{ec.category().name()} == name); |
29 | BEAST_EXPECT(! ec.message().empty()); | |
92f5a8d4 TL |
30 | BEAST_EXPECT( |
31 | std::addressof(ec.category()) == std::addressof(cat)); | |
32 | BEAST_EXPECT(cat.equivalent( | |
7c673cae FG |
33 | static_cast<std::underlying_type<error>::type>(ev), |
34 | ec.category().default_error_condition( | |
35 | static_cast<std::underlying_type<error>::type>(ev)))); | |
92f5a8d4 TL |
36 | BEAST_EXPECT(cat.equivalent(ec, |
37 | static_cast<std::underlying_type<error>::type>(ev))); | |
7c673cae FG |
38 | } |
39 | ||
40 | void run() override | |
41 | { | |
92f5a8d4 TL |
42 | check("boost.beast.zlib", error::need_buffers); |
43 | check("boost.beast.zlib", error::end_of_stream); | |
44 | check("boost.beast.zlib", error::need_dict); | |
45 | check("boost.beast.zlib", error::stream_error); | |
b32b8144 | 46 | |
92f5a8d4 TL |
47 | check("boost.beast.zlib", error::invalid_block_type); |
48 | check("boost.beast.zlib", error::invalid_stored_length); | |
49 | check("boost.beast.zlib", error::too_many_symbols); | |
50 | check("boost.beast.zlib", error::invalid_code_lengths); | |
51 | check("boost.beast.zlib", error::invalid_bit_length_repeat); | |
52 | check("boost.beast.zlib", error::missing_eob); | |
53 | check("boost.beast.zlib", error::invalid_literal_length); | |
54 | check("boost.beast.zlib", error::invalid_distance_code); | |
55 | check("boost.beast.zlib", error::invalid_distance); | |
b32b8144 | 56 | |
92f5a8d4 TL |
57 | check("boost.beast.zlib", error::over_subscribed_length); |
58 | check("boost.beast.zlib", error::incomplete_length_set); | |
b32b8144 | 59 | |
92f5a8d4 | 60 | check("boost.beast.zlib", error::general); |
7c673cae FG |
61 | } |
62 | }; | |
63 | ||
b32b8144 | 64 | BEAST_DEFINE_TESTSUITE(beast,zlib,error); |
7c673cae FG |
65 | |
66 | } // zlib | |
67 | } // beast | |
b32b8144 | 68 | } // boost |