GCC Code Coverage Report


Directory: libs/http_proto/include/boost/http_proto/
File: boost/http_proto/impl/error.ipp
Date: 2023-02-02 18:17:22
Exec Total Coverage
Lines: 41 43 95.3%
Functions: 5 5 100.0%
Branches: 59 91 64.8%

Line Branch Exec Source
1 //
2 // Copyright (c) 2021 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 // Official repository: https://github.com/CPPAlliance/http_proto
8 //
9
10 #ifndef BOOST_HTTP_PROTO_IMPL_ERROR_IPP
11 #define BOOST_HTTP_PROTO_IMPL_ERROR_IPP
12
13 #include <boost/http_proto/error.hpp>
14 #include <boost/assert.hpp>
15 #include <type_traits>
16
17 namespace boost {
18 namespace http_proto {
19
20 namespace detail {
21
22 static
23 error_category const&
24 118 get_error_cat() noexcept
25 {
26 struct codes : error_category
27 {
28 5 codes() noexcept
29 5 : error_category(
30 5 0x3663257e7585fbfd)
31 {
32 5 }
33
34 const char*
35 28 name() const noexcept override
36 {
37 28 return "boost.http.proto";
38 }
39
40 std::string
41 28 message(int ev) const override
42 {
43
28/29
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 15 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 19 taken 1 times.
✓ Branch 20 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 23 taken 1 times.
✓ Branch 24 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 26 taken 1 times.
✓ Branch 27 taken 1 times.
✗ Branch 28 not taken.
28 switch(static_cast<error>(ev))
44 {
45
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::expect_100_continue: return "expect continue";
46
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::end_of_message: return "end of message";
47
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::end_of_stream: return "end of stream";
48
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::need_data: return "need data";
49
50
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_connection: return "bad Connection";
51
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_content_length: return "bad Content-Length";
52
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_expect: return "bad Expect";
53
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_field_name: return "bad field name";
54
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_field_value: return "bad field value";
55
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_line_ending: return "bad line ending";
56
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_list: return "bad list";
57
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_method: return "bad method";
58
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_number: return "bad number";
59
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_version: return "bad version";
60
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_reason: return "bad reason-phrase";
61
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_request_target: return "bad request-target";
62
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_status_code: return "bad status-code";
63
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_status_line: return "bad status-line";
64
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_transfer_encoding: return "bad Transfer-Encoding";
65
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_upgrade: return "bad Upgrade";
66
67
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::body_too_large: return "body too large";
68
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::headers_limit: return "headers limit";
69
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::start_line_limit: return "start line limit";
70
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::field_size_limit: return "field size limit";
71
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::fields_limit: return "fields limit";
72
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::incomplete: return "incomplete";
73
74
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::numeric_overflow: return "numeric overflow";
75
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::multiple_content_length: return "multiple Content-Length";
76 default:
77 return "unknown";
78 }
79 }
80 };
81
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 113 times.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
118 static codes const t{};
82 118 return t;
83 }
84
85 } // detail
86
87 error_code
88 118 make_error_code(
89 error ev) noexcept
90 {
91 return error_code{static_cast<
92 std::underlying_type<
93 error>::type>(ev),
94 118 detail::get_error_cat()};
95 }
96
97 } // http_proto
98 } // boost
99
100 #endif
101