LCOV - code coverage report
Current view: top level - /jenkins/workspace/boost-root/libs/capy/src/buffers - buffer_pair.cpp (source / functions) Coverage Total Hit
Test: coverage_remapped.info Lines: 100.0 % 44 44
Test Date: 2026-02-17 18:14:47 Functions: 100.0 % 2 2

           TLA  Line data    Source code
       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/capy
       8                 : //
       9                 : 
      10                 : #include <boost/capy/buffers/buffer_pair.hpp>
      11                 : #include <boost/capy/buffers/slice.hpp>
      12                 : 
      13                 : namespace boost {
      14                 : namespace capy {
      15                 : 
      16                 : void
      17 HIT        1040 : tag_invoke(
      18                 :     slice_tag const&,
      19                 :     const_buffer_pair& bs,
      20                 :     slice_how how,
      21                 :     std::size_t n) noexcept
      22                 : {
      23            1040 :     switch(how)
      24                 :     {
      25             512 :     case slice_how::remove_prefix:
      26                 :     {
      27             512 :         auto p = &bs[0];
      28             512 :         if(n < p->size())
      29                 :         {
      30             225 :             remove_prefix(*p, n);
      31             225 :             return;
      32                 :         }
      33             287 :         n -= p->size();
      34             287 :         *p = bs[1];
      35             287 :         bs[1] = {};
      36             287 :         remove_prefix(*p, n);
      37             287 :         return;
      38                 :     }
      39                 : 
      40             528 :     case slice_how::keep_prefix:
      41                 :     {
      42             528 :         auto p = &bs[0];
      43             528 :         if(n <= p->size())
      44                 :         {
      45             287 :             keep_prefix(*p, n);
      46             287 :             bs[1] = {};
      47             287 :             return;
      48                 :         }
      49             241 :         n -= p->size();
      50             241 :         ++p;
      51             241 :         keep_prefix(*p, n);
      52             241 :         return;
      53                 :     }
      54                 :     }
      55                 : }
      56                 : 
      57                 : void
      58            1040 : tag_invoke(
      59                 :     slice_tag const&,
      60                 :     mutable_buffer_pair& bs,
      61                 :     slice_how how,
      62                 :     std::size_t n) noexcept
      63                 : {
      64            1040 :     switch(how)
      65                 :     {
      66             512 :     case slice_how::remove_prefix:
      67                 :     {
      68             512 :         auto p = &bs[0];
      69             512 :         if(n < p->size())
      70                 :         {
      71             225 :             remove_prefix(*p, n);
      72             225 :             return;
      73                 :         }
      74             287 :         n -= p->size();
      75             287 :         *p = bs[1];
      76             287 :         bs[1] = {};
      77             287 :         remove_prefix(*p, n);
      78             287 :         return;
      79                 :     }
      80                 : 
      81             528 :     case slice_how::keep_prefix:
      82                 :     {
      83             528 :         auto p = &bs[0];
      84             528 :         if(n <= p->size())
      85                 :         {
      86             287 :             keep_prefix(*p, n);
      87             287 :             bs[1] = {};
      88             287 :             return;
      89                 :         }
      90             241 :         n -= p->size();
      91             241 :         ++p;
      92             241 :         keep_prefix(*p, n);
      93             241 :         return;
      94                 :     }
      95                 :     }
      96                 : }
      97                 : 
      98                 : } // capy
      99                 : } // boost
        

Generated by: LCOV version 2.3