GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 97.0% 32 / 0 / 33
Functions: 100.0% 1 / 0 / 1
Branches: 92.9% 13 / 0 / 14

libs/url/src/rfc/uri_rule.cpp
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
11 #include <boost/url/detail/config.hpp>
12 #include <boost/url/rfc/uri_rule.hpp>
13 #include <boost/url/rfc/query_rule.hpp>
14 #include "detail/fragment_part_rule.hpp"
15 #include "detail/hier_part_rule.hpp"
16 #include "detail/query_part_rule.hpp"
17 #include "detail/scheme_rule.hpp"
18 #include <boost/url/grammar/delim_rule.hpp>
19 #include <boost/url/grammar/tuple_rule.hpp>
20 #include <boost/url/grammar/optional_rule.hpp>
21 #include <boost/url/grammar/parse.hpp>
22
23 namespace boost {
24 namespace urls {
25
26 auto
27 3446 implementation_defined::uri_rule_t::
28 parse(
29 char const*& it,
30 char const* const end
31 ) const noexcept ->
32 system::result<value_type>
33 {
34 3446 detail::url_impl u(detail::url_impl::from::string);
35 3446 u.cs_ = it;
36
37 // scheme
38 {
39 3446 auto rv = grammar::parse(
40 it, end,
41 3446 grammar::tuple_rule(
42 3446 detail::scheme_rule(),
43 3446 grammar::squelch(
44 3446 grammar::delim_rule(':'))));
45
2/2
✓ Branch 1 taken 1167 times.
✓ Branch 2 taken 2279 times.
3446 if(! rv)
46 1167 return rv.error();
47 2279 u.apply_scheme(rv->scheme);
48 }
49
50 // hier_part
51 {
52 auto rv = grammar::parse(
53 it, end,
54 2279 detail::hier_part_rule);
55
2/2
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 2244 times.
2279 if(! rv)
56 35 return rv.error();
57
2/2
✓ Branch 1 taken 1475 times.
✓ Branch 2 taken 769 times.
2244 if(rv->has_authority)
58 1475 u.apply_authority(rv->authority);
59 2244 u.apply_path(
60 2244 rv->path,
61 2244 rv->segment_count);
62 2279 }
63
64 // [ "?" query ]
65 {
66 2244 auto rv = grammar::parse(
67 it, end, detail::query_part_rule);
68
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2244 times.
2244 if(! rv)
69 return rv.error();
70
2/2
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 2040 times.
2244 if(rv->has_query)
71 {
72 // map "?" to { {} }
73 204 u.apply_query(
74 204 rv->query,
75 204 rv->count);
76 }
77 }
78
79 // [ "#" fragment ]
80 {
81 2244 auto rv = grammar::parse(
82 it, end, detail::fragment_part_rule);
83
2/2
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 2243 times.
2244 if(! rv)
84 1 return rv.error();
85
2/2
✓ Branch 1 taken 155 times.
✓ Branch 2 taken 2088 times.
2243 if(rv->has_fragment)
86 155 u.apply_frag(rv->fragment);
87 }
88
89 2243 return u.construct();
90 }
91
92 } // urls
93 } // boost
94
95