GCC Code Coverage Report


Directory: libs/url/
File: src/parse_path.cpp
Date: 2025-11-12 22:47:45
Exec Total Coverage
Lines: 23 23 100.0%
Functions: 1 1 100.0%
Branches: 12 12 100.0%

Line Branch Exec Source
1 //
2 // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
3 // Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
4 //
5 // Distributed under the Boost Software License, Version 1.0. (See accompanying
6 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 //
8 // Official repository: https://github.com/boostorg/url
9 //
10
11
12 #include <boost/url/detail/config.hpp>
13 #include <boost/url/parse_path.hpp>
14 #include <boost/url/error.hpp>
15 #include "detail/path.hpp"
16 #include <boost/url/grammar/parse.hpp>
17 #include "boost/url/rfc/detail/path_rules.hpp"
18
19 namespace boost {
20 namespace urls {
21
22 system::result<segments_encoded_view>
23 170 parse_path(core::string_view s) noexcept
24 {
25 170 auto it = s.data();
26 170 auto const end = it + s.size();
27 170 std::size_t dn = 0;
28 170 std::size_t nseg = 0;
29
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 3 times.
170 if( it != end &&
30
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 42 times.
167 *it != '/')
31 125 ++nseg;
32
2/2
✓ Branch 0 taken 838 times.
✓ Branch 1 taken 158 times.
996 while(it != end)
33 {
34
2/2
✓ Branch 0 taken 371 times.
✓ Branch 1 taken 467 times.
838 if(*it == '/')
35 {
36 371 ++it;
37 371 ++dn;
38 371 ++nseg;
39 371 continue;
40 }
41 467 auto rv = grammar::parse(
42 it, end, detail::segment_rule);
43
2/2
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 457 times.
467 if(! rv)
44 10 return rv.error();
45
2/2
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 455 times.
457 if(rv->empty())
46 {
47 2 BOOST_URL_RETURN_EC(
48 grammar::error::mismatch);
49 }
50 455 dn += rv->decoded_size();
51 }
52 // adjust nseg
53 158 nseg = detail::path_segments(s, nseg);
54 158 return segments_encoded_view(
55 316 detail::path_ref(s, dn, nseg));
56 }
57
58 } // urls
59 } // boost
60
61