GCC Code Coverage Report


Directory: libs/url/
File: libs/url/src/grammar/error.cpp
Date: 2024-02-29 20:02:56
Exec Total Coverage
Lines: 25 25 100.0%
Functions: 7 7 100.0%
Branches: 10 12 83.3%

Line Branch Exec Source
1 //
2 // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.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/boostorg/url
8 //
9
10 #ifndef BOOST_URL_GRAMMAR_IMPL_ERROR_IPP
11 #define BOOST_URL_GRAMMAR_IMPL_ERROR_IPP
12
13 #include <boost/url/detail/config.hpp>
14 #include <boost/url/grammar/error.hpp>
15
16 namespace boost {
17 namespace urls {
18 namespace grammar {
19
20 namespace detail {
21
22 const char*
23 72 error_cat_type::
24 name() const noexcept
25 {
26 72 return "boost.url.grammar";
27 }
28
29 std::string
30 72 error_cat_type::
31 message(int code) const
32 {
33
1/2
✓ Branch 3 taken 72 times.
✗ Branch 4 not taken.
72 return message(code, nullptr, 0);
34 }
35
36 char const*
37 72 error_cat_type::
38 message(
39 int code,
40 char*,
41 std::size_t) const noexcept
42 {
43
6/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 42 times.
✓ Branch 5 taken 1 times.
72 switch(static_cast<error>(code))
44 {
45 1 default:
46 1 case error::need_more: return "need more";
47 14 case error::mismatch: return "mismatch";
48 13 case error::invalid: return "invalid";
49 1 case error::end_of_range: return "end of range";
50 42 case error::leftover: return "leftover";
51 1 case error::out_of_range: return "out of range";
52 }
53 }
54
55 system::error_condition
56 6 error_cat_type::
57 default_error_condition(
58 int ev) const noexcept
59 {
60
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 switch(static_cast<error>(ev))
61 {
62 2 case error::invalid:
63 case error::out_of_range:
64 2 return condition::fatal;
65 4 default:
66 4 return {ev, *this};
67 }
68 }
69
70 //------------------------------------------------
71
72 const char*
73 5 condition_cat_type::
74 name() const noexcept
75 {
76 5 return "boost.url.grammar";
77 }
78
79 std::string
80 5 condition_cat_type::
81 message(int code) const
82 {
83
1/2
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
5 return message(code, nullptr, 0);
84 }
85
86 char const*
87 5 condition_cat_type::
88 message(
89 int code, char*, std::size_t) const noexcept
90 {
91 switch(static_cast<condition>(code))
92 {
93 default:
94 case condition::fatal:
95 5 return "fatal condition";
96 }
97 }
98
99 //-----------------------------------------------
100
101 // msvc 14.0 has a bug that warns about inability
102 // to use constexpr construction here, even though
103 // there's no constexpr construction
104 #if defined(_MSC_VER) && _MSC_VER <= 1900
105 # pragma warning( push )
106 # pragma warning( disable : 4592 )
107 #endif
108
109 error_cat_type error_cat;
110 condition_cat_type condition_cat;
111
112 #if defined(_MSC_VER) && _MSC_VER <= 1900
113 # pragma warning( pop )
114 #endif
115
116 } // detail
117
118 } // grammar
119 } // urls
120 } // boost
121
122 #endif
123