GCC Code Coverage Report


Directory: libs/http_proto/include/boost/http_proto/
File: boost/http_proto/impl/error.ipp
Date: 2023-01-09 16:11:13
Exec Total Coverage
Lines: 38 40 95.0%
Functions: 5 5 100.0%
Branches: 53 82 64.6%

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 108 get_error_cat() noexcept
25 {
26 struct codes : error_category
27 {
28 4 codes() noexcept
29 4 : error_category(
30 4 0x3663257e7585fbfd)
31 {
32 4 }
33
34 const char*
35 25 name() const noexcept override
36 {
37 25 return "boost.http.proto";
38 }
39
40 std::string
41 25 message(int ev) const override
42 {
43
25/26
✓ 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 not taken.
25 switch(static_cast<error>(ev))
44 {
45
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::end_of_message: return "end of message";
46
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::end_of_stream: return "end of stream";
47
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_connection: return "bad Connection";
48
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_content_length: return "bad Content-Length";
49
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_expect: return "bad Expect";
50
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_field_name: return "bad field name";
51
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_field_value: return "bad field value";
52
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_line_ending: return "bad line ending";
53
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_list: return "bad list";
54
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_method: return "bad method";
55
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_number: return "bad number";
56
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_version: return "bad version";
57
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_reason: return "bad reason-phrase";
58
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_request_target: return "bad request-target";
59
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_status_code: return "bad status-code";
60
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_status_line: return "bad status-line";
61
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_transfer_encoding: return "bad Transfer-Encoding";
62
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::bad_upgrade: return "bad Upgrade";
63
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::syntax: return "syntax error";
64
65
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::body_too_large: return "body too large";
66
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::field_too_large: return "field too large";
67
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::header_too_large: return "header too large";
68
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::too_many_fields: return "too many fields";
69
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::numeric_overflow: return "numeric overflow";
70
71
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 case error::multiple_content_length: return "multiple Content-Length";
72 default:
73 return "unknown";
74 }
75 }
76 };
77
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
108 static codes const t{};
78 108 return t;
79 }
80
81 } // detail
82
83 error_code
84 108 make_error_code(
85 error ev) noexcept
86 {
87 return error_code{static_cast<
88 std::underlying_type<
89 error>::type>(ev),
90 108 detail::get_error_cat()};
91 }
92
93 } // http_proto
94 } // boost
95
96 #endif
97