GCC Code Coverage Report


Directory: libs/http_proto/include/boost/http_proto/
File: boost/http_proto/rfc/impl/combine_field_values.ipp
Date: 2023-02-25 19:48:06
Exec Total Coverage
Lines: 25 27 92.6%
Functions: 1 1 100.0%
Branches: 15 26 57.7%

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 #ifndef BOOST_HTTP_PROTO_RFC_COMBINE_FIELD_VALUES_IPP
11 #define BOOST_HTTP_PROTO_RFC_COMBINE_FIELD_VALUES_IPP
12
13 #include <boost/http_proto/rfc/combine_field_values.hpp>
14
15 namespace boost {
16 namespace http_proto {
17
18 string_view
19 8 combine_field_values(
20 fields_view_base::subrange const& vr,
21 grammar::recycled_ptr<std::string>& temp)
22 {
23 8 string_view result;
24 8 bool acquired = false;
25
2/2
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 8 times.
19 for(auto s : vr)
26 {
27
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
11 if(s.empty())
28 continue;
29
2/2
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 4 times.
11 if(result.empty())
30 {
31 7 result = s;
32 }
33
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 else if(! acquired)
34 {
35 3 acquired = true;
36
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
3 if(temp.empty())
37 temp.acquire();
38 3 temp->clear();
39 3 temp->reserve(
40 3 result.size() +
41
1/2
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 1 + s.size());
42
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 *temp = result;
43
1/2
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 temp->push_back(',');
44 temp->append(
45
1/2
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 s.data(), s.size());
46 3 result = *temp;
47 }
48 else
49 {
50 1 temp->reserve(
51 1 temp->size() +
52
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 1 + s.size());
53
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 temp->push_back(',');
54 temp->append(
55
1/2
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 s.data(), s.size());
56 1 result = *temp;
57 }
58 }
59 8 return result;
60 }
61
62 } // http_proto
63 } // boost
64
65 #endif
66