GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 92.9% 26 / 0 / 28
Functions: 100.0% 1 / 0 / 1
Branches: 83.3% 10 / 0 / 12

libs/url/src/rfc/authority_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/authority_rule.hpp>
13 #include <boost/url/grammar/delim_rule.hpp>
14 #include <boost/url/grammar/optional_rule.hpp>
15 #include <boost/url/grammar/parse.hpp>
16 #include <boost/url/grammar/tuple_rule.hpp>
17 #include "detail/host_rule.hpp"
18 #include "detail/port_rule.hpp"
19 #include "detail/userinfo_rule.hpp"
20
21 namespace boost {
22 namespace urls {
23
24 auto
25 2044 implementation_defined::authority_rule_t::
26 parse(
27 char const*& it,
28 char const* const end
29 ) const noexcept ->
30 system::result<value_type>
31 {
32 2044 detail::url_impl u(detail::url_impl::from::authority);
33 2044 u.cs_ = it;
34
35 // [ userinfo "@" ]
36 {
37 auto rv = grammar::parse(
38 it, end,
39 2044 grammar::optional_rule(
40 2044 grammar::tuple_rule(
41 detail::userinfo_rule,
42 2044 grammar::squelch(
43 4088 grammar::delim_rule('@')))));
44
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2044 times.
2044 if(! rv)
45 return rv.error();
46
2/2
✓ Branch 2 taken 405 times.
✓ Branch 3 taken 1639 times.
2044 if(rv->has_value())
47 {
48 135 u.apply_userinfo(
49 405 (*rv)->user,
50
2/2
✓ Branch 2 taken 270 times.
✓ Branch 3 taken 135 times.
405 (*rv)->has_password
51 270 ? &(*rv)->password
52 : nullptr);
53 }
54 2044 }
55
56 // host
57 {
58 2044 auto rv = grammar::parse(
59 it, end, detail::host_rule);
60
2/2
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 2013 times.
2044 if(! rv)
61 31 return rv.error();
62 2013 u.apply_host(rv->host_type,
63 2013 rv->match, rv->addr);
64 }
65
66 // [ ":" port ]
67 {
68 2013 auto rv = grammar::parse(
69 it, end, detail::port_part_rule);
70
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2013 times.
2013 if(! rv)
71 return rv.error();
72
2/2
✓ Branch 1 taken 282 times.
✓ Branch 2 taken 1731 times.
2013 if(rv->has_port)
73 282 u.apply_port(
74 282 rv->port,
75 282 rv->port_number);
76 }
77
78 2013 return u.construct_authority();
79 }
80
81 } // urls
82 } // boost
83
84