GCC Code Coverage Report


Directory: libs/url/
File: libs/url/src/error.cpp
Date: 2023-12-15 15:31:49
Exec Total Coverage
Lines: 22 22 100.0%
Functions: 4 4 100.0%
Branches: 13 14 92.9%

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_IMPL_ERROR_IPP
11 #define BOOST_URL_IMPL_ERROR_IPP
12
13 #include <boost/url/detail/config.hpp>
14 #include <boost/url/error.hpp>
15 #include <boost/url/grammar/error.hpp>
16
17 namespace boost {
18 namespace urls {
19
20 namespace detail {
21
22 const char*
23 97 error_cat_type::
24 name() const noexcept
25 {
26 97 return "boost.url";
27 }
28
29 std::string
30 98 error_cat_type::
31 message(int code) const
32 {
33
1/2
✓ Branch 3 taken 98 times.
✗ Branch 4 not taken.
98 return message(code, nullptr, 0);
34 }
35
36 char const*
37 98 error_cat_type::
38 message(
39 int code,
40 char*,
41 std::size_t) const noexcept
42 {
43
10/10
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 19 times.
✓ Branch 5 taken 63 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 1 times.
98 switch(static_cast<error>(code))
44 {
45 1 case error::success: return "success";
46 1 case error::illegal_null: return "illegal null";
47 1 case error::illegal_reserved_char: return "illegal reserved char";
48 1 case error::non_canonical: return "non canonical";
49
50 19 case error::bad_pct_hexdig: return "bad hexdig in pct-encoding";
51 63 case error::incomplete_encoding: return "incomplete pct-encoding";
52 9 case error::missing_pct_hexdig: return "missing hexdig in pct-encoding";
53 1 case error::no_space: return "no space";
54 1 case error::not_a_base: return "not a base";
55 }
56 1 return "";
57 }
58
59 system::error_condition
60 9 error_cat_type::
61 default_error_condition(
62 int ev) const noexcept
63 {
64
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3 times.
9 switch(static_cast<error>(ev))
65 {
66 6 default:
67 6 return {ev, *this};
68
69 3 case error::bad_pct_hexdig:
70 case error::incomplete_encoding:
71 case error::missing_pct_hexdig:
72 3 return grammar::condition::fatal;
73 }
74 }
75
76 //-----------------------------------------------
77
78 // msvc 14.0 has a bug that warns about inability
79 // to use constexpr construction here, even though
80 // there's no constexpr construction
81 #if defined(_MSC_VER) && _MSC_VER <= 1900
82 # pragma warning( push )
83 # pragma warning( disable : 4592 )
84 #endif
85
86 error_cat_type error_cat;
87
88 #if defined(_MSC_VER) && _MSC_VER <= 1900
89 # pragma warning( pop )
90 #endif
91
92 } // detail
93
94 } // urls
95 } // boost
96
97 #endif
98