GCC Code Coverage Report


Directory: libs/http_proto/
File: src/detail/impl/filter.hpp
Date: 2024-12-31 05:34:49
Exec Total Coverage
Lines: 27 28 96.4%
Functions: 1 1 100.0%
Branches: 19 24 79.2%

Line Branch Exec Source
1 //
2 // Copyright (c) 2023 Vinnie Falco (vinnie.falco@gmail.com)
3 // Copyright (c) 2024 Mohammad Nejati
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/cppalliance/http_proto
9 //
10
11 #ifndef BOOST_HTTP_PROTO_DETAIL_IMPL_FILTER_HPP
12 #define BOOST_HTTP_PROTO_DETAIL_IMPL_FILTER_HPP
13
14 #include <boost/buffers/algorithm.hpp>
15
16 namespace boost {
17 namespace http_proto {
18 namespace detail {
19
20 template<
21 class MutableBufferSequence,
22 class ConstBufferSequence>
23 auto
24 19673 filter::
25 process_impl(
26 MutableBufferSequence const& out,
27 ConstBufferSequence const& in,
28 bool more) ->
29 results
30 {
31 19673 results rv;
32 19673 auto it_o = buffers::begin(out);
33 19673 auto it_i = buffers::begin(in);
34
35
3/6
✓ Branch 1 taken 19673 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 19673 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 19673 times.
39346 if( it_o == buffers::end(out) ||
36 19673 it_i == buffers::end(in) )
37 return rv;
38
39 19673 auto ob = *it_o++;
40 19673 auto ib = *it_i++;
41 19804 for(;;)
42 {
43 // empty buffers may be passed, and this is
44 // intentional and valid.
45
1/2
✓ Branch 1 taken 39477 times.
✗ Branch 2 not taken.
39477 results rs = process_impl(ob, ib, more);
46
47 39477 rv.out_bytes += rs.out_bytes;
48 39477 rv.in_bytes += rs.in_bytes;
49 39477 rv.ec = rs.ec;
50 39477 rv.finished = rs.finished;
51
52
6/6
✓ Branch 0 taken 39453 times.
✓ Branch 1 taken 24 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 39452 times.
✓ Branch 5 taken 25 times.
✓ Branch 6 taken 39452 times.
39477 if( rv.finished || rv.ec )
53 19673 return rv;
54
55 39452 ob = buffers::sans_prefix(ob, rs.out_bytes);
56 39452 ib = buffers::sans_prefix(ib, rs.in_bytes);
57
58
2/2
✓ Branch 1 taken 2160 times.
✓ Branch 2 taken 37292 times.
39452 if( ob.size() == 0 )
59 {
60
2/2
✓ Branch 1 taken 1080 times.
✓ Branch 2 taken 1080 times.
2160 if( it_o == buffers::end(out) )
61 1080 return rv;
62 1080 ob = *it_o++;
63 }
64
65
2/2
✓ Branch 1 taken 37302 times.
✓ Branch 2 taken 1070 times.
38372 if( ib.size() == 0 )
66 {
67
2/2
✓ Branch 1 taken 18568 times.
✓ Branch 2 taken 18734 times.
37302 if( it_i == buffers::end(in) )
68 {
69 // if `more == false` we return only
70 // when `out` buffers are full.
71
1/2
✓ Branch 0 taken 18568 times.
✗ Branch 1 not taken.
18568 if( more )
72 18568 return rv;
73 }
74 else
75 {
76 18734 ib = *it_i++;
77 }
78 }
79 }
80 }
81
82 } // detail
83 } // http_proto
84 } // boost
85
86 #endif
87