GCC Code Coverage Report


Directory: libs/url/
File: libs/url/src/rfc/detail/ipv6_addrz_rule.cpp
Date: 2024-08-20 16:05:55
Exec Total Coverage
Lines: 20 20 100.0%
Functions: 1 1 100.0%
Branches: 14 16 87.5%

Line Branch Exec Source
1 //
2 // Copyright (c) 2023 Alan de Freitas (alandefreitas@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
11 #include <boost/url/detail/config.hpp>
12 #include <boost/url/grammar/parse.hpp>
13 #include "ipv6_addrz_rule.hpp"
14 #include <boost/url/rfc/ipv6_address_rule.hpp>
15 #include <boost/url/rfc/unreserved_chars.hpp>
16 #include <boost/url/rfc/pct_encoded_rule.hpp>
17
18 namespace boost {
19 namespace urls {
20 namespace detail {
21
22 auto
23 27 ipv6_addrz_rule_t::
24 parse(
25 char const*& it,
26 char const* const end
27 ) const noexcept ->
28 system::result<value_type>
29 {
30 27 value_type t;
31 27 auto rv1 = grammar::parse(
32 it, end, ipv6_address_rule);
33
2/2
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 10 times.
27 if (! rv1)
34 17 return rv1.error();
35 10 t.ipv6 = *rv1;
36
37 // "%25"
38 10 auto it0 = it;
39
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 if (end - it < 3 ||
40
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3 times.
8 *it != '%' ||
41
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 *(it + 1) != '2' ||
42
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 *(it + 2) != '5')
43 {
44 6 BOOST_URL_RETURN_EC(
45 grammar::error::invalid);
46 }
47 4 it += 3;
48
49 // ZoneID = 1*( unreserved / pct-encoded )
50 // Parse as many (unreserved / pct-encoded)
51 // as available
52 4 auto rv2 = grammar::parse(
53 it, end,
54 4 pct_encoded_rule(unreserved_chars));
55
5/6
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 3 times.
4 if(!rv2 || rv2->empty())
56 {
57 1 it = it0;
58 1 BOOST_URL_RETURN_EC(
59 grammar::error::invalid);
60 }
61 else
62 {
63 3 t.zone_id = *rv2;
64 }
65 3 return t;
66 }
67
68 } // detail
69 } // urls
70 } // boost
71
72