GCC Code Coverage Report


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