GCC Code Coverage Report


Directory: libs/buffers/
File: libs/buffers/src/const_buffer_pair.cpp
Date: 2024-07-24 21:34:17
Exec Total Coverage
Lines: 24 24 100.0%
Functions: 2 2 100.0%
Branches: 8 8 100.0%

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/const_buffer_pair.hpp>
11
12 namespace boost {
13 namespace buffers {
14
15 const_buffer_pair
16 139808 const_buffer_pair::
17 prefix_impl(
18 std::size_t n) const noexcept
19 {
20 139808 auto const it0 = begin();
21
2/2
✓ Branch 1 taken 84304 times.
✓ Branch 2 taken 55504 times.
139808 if(n <= it0->size())
22 return { {
23 it0->data(), n },
24 84304 const_buffer{} };
25 55504 n -= it0->size();
26 55504 auto it1 = it0;
27 55504 ++it1;
28
2/2
✓ Branch 1 taken 40978 times.
✓ Branch 2 taken 14526 times.
55504 if(n < it1->size())
29 return { *it0, {
30 40978 it1->data(), n } };
31 14526 return *this;
32 }
33
34 const_buffer_pair
35 139808 const_buffer_pair::
36 suffix_impl(
37 std::size_t n) const noexcept
38 {
39 139808 auto it0 = end();
40 139808 --it0;
41
2/2
✓ Branch 1 taken 55504 times.
✓ Branch 2 taken 84304 times.
139808 if(n <= it0->size())
42 55504 return { *it0 + (
43 55504 it0->size() - n),
44 55504 const_buffer{} };
45 84304 n -= it0->size();
46 84304 auto it1 = it0;
47 84304 --it1;
48
2/2
✓ Branch 1 taken 67858 times.
✓ Branch 2 taken 16446 times.
84304 if(n < it1->size())
49 67858 return { *it1 + (
50 67858 it1->size() - n), *it0 };
51 16446 return *this;
52 }
53
54 } // buffers
55 } // boost
56