GCC Code Coverage Report


Directory: ./
File: libs/buffers/src/buffer_pair.cpp
Date: 2025-12-08 17:18:03
Exec Total Coverage
Lines: 44 44 100.0%
Functions: 2 2 100.0%
Branches: 12 14 85.7%

Line Branch Exec Source
1 //
2 // Copyright (c) 2023 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/buffers
8 //
9
10 #include <boost/buffers/buffer_pair.hpp>
11 #include <boost/buffers/slice.hpp>
12
13 namespace boost {
14 namespace buffers {
15
16 void
17 6529856 tag_invoke(
18 slice_tag const&,
19 const_buffer_pair& bs,
20 slice_how how,
21 std::size_t n) noexcept
22 {
23
2/3
✓ Branch 0 taken 2993536 times.
✓ Branch 1 taken 3536320 times.
✗ Branch 2 not taken.
6529856 switch(how)
24 {
25 2993536 case slice_how::remove_prefix:
26 {
27 2993536 auto p = &bs[0];
28
2/2
✓ Branch 1 taken 1834873 times.
✓ Branch 2 taken 1158663 times.
2993536 if(n < p->size())
29 {
30 1834873 remove_prefix(*p, n);
31 1834873 return;
32 }
33 1158663 n -= p->size();
34 1158663 *p = bs[1];
35 1158663 bs[1] = {};
36 1158663 remove_prefix(*p, n);
37 1158663 return;
38 }
39
40 3536320 case slice_how::keep_prefix:
41 {
42 3536320 auto p = &bs[0];
43
2/2
✓ Branch 1 taken 2718075 times.
✓ Branch 2 taken 818245 times.
3536320 if(n <= p->size())
44 {
45 2718075 keep_prefix(*p, n);
46 2718075 bs[1] = {};
47 2718075 return;
48 }
49 818245 n -= p->size();
50 818245 ++p;
51 818245 keep_prefix(*p, n);
52 818245 return;
53 }
54 }
55 }
56
57 void
58 25408 tag_invoke(
59 slice_tag const&,
60 mutable_buffer_pair& bs,
61 slice_how how,
62 std::size_t n) noexcept
63 {
64
2/3
✓ Branch 0 taken 11648 times.
✓ Branch 1 taken 13760 times.
✗ Branch 2 not taken.
25408 switch(how)
65 {
66 11648 case slice_how::remove_prefix:
67 {
68 11648 auto p = &bs[0];
69
2/2
✓ Branch 1 taken 6425 times.
✓ Branch 2 taken 5223 times.
11648 if(n < p->size())
70 {
71 6425 remove_prefix(*p, n);
72 6425 return;
73 }
74 5223 n -= p->size();
75 5223 *p = bs[1];
76 5223 bs[1] = {};
77 5223 remove_prefix(*p, n);
78 5223 return;
79 }
80
81 13760 case slice_how::keep_prefix:
82 {
83 13760 auto p = &bs[0];
84
2/2
✓ Branch 1 taken 9883 times.
✓ Branch 2 taken 3877 times.
13760 if(n <= p->size())
85 {
86 9883 keep_prefix(*p, n);
87 9883 bs[1] = {};
88 9883 return;
89 }
90 3877 n -= p->size();
91 3877 ++p;
92 3877 keep_prefix(*p, n);
93 3877 return;
94 }
95 }
96 }
97
98 } // buffers
99 } // boost
100