GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 87.0% 94 / 0 / 108
Functions: 80.0% 4 / 0 / 5
Branches: 83.3% 40 / 0 / 48

libs/url/include/boost/url/rfc/impl/pct_encoded_rule.hpp
Line Branch Exec Source
1 //
2 // Copyright (c) 2016-2019 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/boostorg/url
8 //
9
10 #ifndef BOOST_URL_RFC_IMPL_PCT_ENCODED_RULE_HPP
11 #define BOOST_URL_RFC_IMPL_PCT_ENCODED_RULE_HPP
12
13 #include <boost/url/grammar/charset.hpp>
14 #include <boost/url/grammar/error.hpp>
15 #include <boost/url/grammar/hexdig_chars.hpp>
16
17 namespace boost {
18 namespace urls {
19
20 namespace detail {
21
22 template<class CharSet>
23 auto
24 9333 parse_encoded(
25 char const*& it,
26 char const* end,
27 CharSet const& cs) noexcept ->
28 system::result<pct_string_view>
29 {
30 9333 auto const start = it;
31 9333 std::size_t n = 0;
32 char const* it0;
33 9654 skip:
34 9654 it0 = it;
35 9654 it = grammar::find_if_not(
36 it0, end, cs);
37 9654 n += it - it0;
38
6/6
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::implementation_defined::charset_ref<boost::urls::grammar::lut_chars> >(char const*&, char const*, boost::urls::grammar::implementation_defined::charset_ref<boost::urls::grammar::lut_chars> const&):
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 2071 times.
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::implementation_defined::digit_chars_t>(char const*&, char const*, boost::urls::grammar::implementation_defined::digit_chars_t const&):
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::lut_chars>(char const*&, char const*, boost::urls::grammar::lut_chars const&):
✓ Branch 0 taken 2474 times.
✓ Branch 1 taken 4754 times.
9654 if(it == end)
39 2825 goto finish;
40
6/6
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::implementation_defined::charset_ref<boost::urls::grammar::lut_chars> >(char const*&, char const*, boost::urls::grammar::implementation_defined::charset_ref<boost::urls::grammar::lut_chars> const&):
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 1933 times.
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::implementation_defined::digit_chars_t>(char const*&, char const*, boost::urls::grammar::implementation_defined::digit_chars_t const&):
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 time.
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::lut_chars>(char const*&, char const*, boost::urls::grammar::lut_chars const&):
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 4475 times.
6829 if(*it != '%')
41 6409 goto finish;
42 212 for(;;)
43 {
44 632 ++it;
45
6/6
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::implementation_defined::charset_ref<boost::urls::grammar::lut_chars> >(char const*&, char const*, boost::urls::grammar::implementation_defined::charset_ref<boost::urls::grammar::lut_chars> const&):
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 224 times.
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::implementation_defined::digit_chars_t>(char const*&, char const*, boost::urls::grammar::implementation_defined::digit_chars_t const&):
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::lut_chars>(char const*&, char const*, boost::urls::grammar::lut_chars const&):
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 392 times.
632 if(it == end)
46 {
47 // expected HEXDIG
48 14 BOOST_URL_RETURN_EC(
49 grammar::error::invalid);
50 }
51 618 auto r = grammar::hexdig_value(*it);
52
6/6
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::implementation_defined::charset_ref<boost::urls::grammar::lut_chars> >(char const*&, char const*, boost::urls::grammar::implementation_defined::charset_ref<boost::urls::grammar::lut_chars> const&):
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 221 times.
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::implementation_defined::digit_chars_t>(char const*&, char const*, boost::urls::grammar::implementation_defined::digit_chars_t const&):
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::lut_chars>(char const*&, char const*, boost::urls::grammar::lut_chars const&):
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 384 times.
618 if(r < 0)
53 {
54 // expected HEXDIG
55 12 BOOST_URL_RETURN_EC(
56 grammar::error::invalid);
57 }
58 606 ++it;
59
4/6
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::implementation_defined::charset_ref<boost::urls::grammar::lut_chars> >(char const*&, char const*, boost::urls::grammar::implementation_defined::charset_ref<boost::urls::grammar::lut_chars> const&):
✗ Branch 0 not taken.
✓ Branch 1 taken 221 times.
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::implementation_defined::digit_chars_t>(char const*&, char const*, boost::urls::grammar::implementation_defined::digit_chars_t const&):
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::lut_chars>(char const*&, char const*, boost::urls::grammar::lut_chars const&):
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 380 times.
606 if(it == end)
60 {
61 // expected HEXDIG
62 5 BOOST_URL_RETURN_EC(
63 grammar::error::invalid);
64 }
65 601 r = grammar::hexdig_value(*it);
66
4/6
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::implementation_defined::charset_ref<boost::urls::grammar::lut_chars> >(char const*&, char const*, boost::urls::grammar::implementation_defined::charset_ref<boost::urls::grammar::lut_chars> const&):
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 219 times.
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::implementation_defined::digit_chars_t>(char const*&, char const*, boost::urls::grammar::implementation_defined::digit_chars_t const&):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::lut_chars>(char const*&, char const*, boost::urls::grammar::lut_chars const&):
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 374 times.
601 if(r < 0)
67 {
68 // expected HEXDIG
69 8 BOOST_URL_RETURN_EC(
70 grammar::error::invalid);
71 }
72 593 ++n;
73 593 ++it;
74
4/6
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::implementation_defined::charset_ref<boost::urls::grammar::lut_chars> >(char const*&, char const*, boost::urls::grammar::implementation_defined::charset_ref<boost::urls::grammar::lut_chars> const&):
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 209 times.
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::implementation_defined::digit_chars_t>(char const*&, char const*, boost::urls::grammar::implementation_defined::digit_chars_t const&):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::lut_chars>(char const*&, char const*, boost::urls::grammar::lut_chars const&):
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 324 times.
593 if(it == end)
75 60 break;
76
4/6
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::implementation_defined::charset_ref<boost::urls::grammar::lut_chars> >(char const*&, char const*, boost::urls::grammar::implementation_defined::charset_ref<boost::urls::grammar::lut_chars> const&):
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 89 times.
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::implementation_defined::digit_chars_t>(char const*&, char const*, boost::urls::grammar::implementation_defined::digit_chars_t const&):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
boost::system::result<boost::urls::pct_string_view, boost::system::error_code> boost::urls::detail::parse_encoded<boost::urls::grammar::lut_chars>(char const*&, char const*, boost::urls::grammar::lut_chars const&):
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 123 times.
533 if(*it != '%')
77 321 goto skip;
78 }
79 9294 finish:
80 9294 return make_pct_string_view_unsafe(
81 9294 start, it - start, n);
82 }
83
84 } // detail
85
86 //------------------------------------------------
87
88 template<class CharSet>
89 auto
90 9333 implementation_defined::pct_encoded_rule_t<CharSet>::
91 parse(
92 char const*& it,
93 char const* end) const noexcept ->
94 system::result<value_type>
95 {
96 9333 return detail::parse_encoded(
97 9333 it, end, cs_);
98 }
99
100 } // urls
101 } // boost
102
103 #endif
104