GCC Code Coverage Report


Directory: libs/url/
File: src/rfc/detail/h16_rule.cpp
Date: 2025-11-12 22:47:45
Exec Total Coverage
Lines: 32 33 97.0%
Functions: 1 1 100.0%
Branches: 15 16 93.8%

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 #include <boost/url/detail/config.hpp>
11 #include "h16_rule.hpp"
12 #include <boost/url/grammar/charset.hpp>
13 #include <boost/url/grammar/error.hpp>
14 #include <boost/url/grammar/hexdig_chars.hpp>
15 #include <boost/assert.hpp>
16
17 namespace boost {
18 namespace urls {
19 namespace detail {
20
21 auto
22 948 h16_rule_t::
23 parse(
24 char const*& it,
25 char const* end
26 ) const noexcept ->
27 system::result<value_type>
28 {
29 // VFALCO it might be impossible for
30 // this condition to be true (coverage)
31
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 948 times.
948 if(it == end)
32 {
33 // end
34 BOOST_URL_RETURN_EC(
35 grammar::error::invalid);
36 }
37
38 std::uint16_t v;
39 for(;;)
40 {
41 948 auto d = grammar::hexdig_value(*it);
42
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 927 times.
948 if(d < 0)
43 {
44 // expected HEXDIG
45 21 BOOST_URL_RETURN_EC(
46 grammar::error::invalid);
47 }
48 927 v = d;
49 927 ++it;
50
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 850 times.
927 if(it == end)
51 77 break;
52 850 d = grammar::hexdig_value(*it);
53
2/2
✓ Branch 0 taken 564 times.
✓ Branch 1 taken 286 times.
850 if(d < 0)
54 564 break;
55 286 v = (16 * v) + d;
56 286 ++it;
57
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 282 times.
286 if(it == end)
58 4 break;
59 282 d = grammar::hexdig_value(*it);
60
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 278 times.
282 if(d < 0)
61 4 break;
62 278 v = (16 * v) + d;
63 278 ++it;
64
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 274 times.
278 if(it == end)
65 4 break;
66 274 d = grammar::hexdig_value(*it);
67
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 223 times.
274 if(d < 0)
68 51 break;
69 223 v = (16 * v) + d;
70 223 ++it;
71 223 break;
72 }
73 927 return value_type{
74 static_cast<
75 927 unsigned char>(v / 256),
76 static_cast<
77 927 unsigned char>(v % 256)};
78 }
79
80 } // detail
81 } // urls
82 } // boost
83
84