GCC Code Coverage Report


Directory: ./
File: libs/http_proto/src/rfc/parameter.cpp
Date: 2025-12-23 17:59:41
Exec Total Coverage
Lines: 16 17 94.1%
Functions: 2 2 100.0%
Branches: 7 8 87.5%

Line Branch Exec Source
1 //
2 // Copyright (c) 2021 Vinnie Falco (vinnie.falco@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/cppalliance/http_proto
8 //
9
10 #include <boost/http_proto/rfc/parameter.hpp>
11 #include <boost/http_proto/rfc/token_rule.hpp>
12 #include <boost/http_proto/rfc/quoted_token_rule.hpp>
13 #include <boost/http_proto/rfc/detail/ws.hpp>
14
15 #include <boost/url/grammar/parse.hpp>
16 #include <boost/url/grammar/optional_rule.hpp>
17 #include <boost/url/grammar/tuple_rule.hpp>
18 #include <boost/url/grammar/literal_rule.hpp>
19
20 namespace boost {
21 namespace http_proto {
22 namespace implementation_defined {
23 auto
24 32 parameter_rule_t::
25 parse(
26 char const*& it,
27 char const* end) const noexcept ->
28 system::result<value_type>
29 {
30 32 auto name = grammar::parse(it, end, token_rule);
31
2/2
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 27 times.
32 if(!name)
32 5 return name.error();
33
34
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 26 times.
27 if(it == end)
35 1 BOOST_HTTP_PROTO_RETURN_EC(
36 grammar::error::need_more);
37
38
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 if(*it++ != '=')
39 BOOST_HTTP_PROTO_RETURN_EC(
40 grammar::error::mismatch);
41
42 26 auto value = grammar::parse(
43 it, end, quoted_token_rule);
44
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 25 times.
26 if(!value)
45 1 return value.error();
46
47 25 return value_type{ *name, *value };
48 }
49
50 auto
51 18 parameters_rule_t::
52 parse(
53 char const*& it,
54 char const* end) const noexcept ->
55 system::result<value_type>
56 {
57 constexpr auto ows = grammar::squelch(
58 grammar::optional_rule(
59 grammar::token_rule(detail::ws)));
60
61 return grammar::parse(
62 18 it, end, grammar::range_rule(
63 18 grammar::tuple_rule(
64 ows,
65 36 grammar::squelch(grammar::literal_rule(";")),
66 ows,
67 18 parameter_rule)));
68 }
69 } // implementation_defined
70 } // http_proto
71 } // boost
72