LCOV - code coverage report
Current view: top level - src/test/fuzz - span.cpp (source / functions) Coverage Total Hit
Test: fuzz_coverage.info Lines: 100.0 % 16 16
Test Date: 2024-09-01 05:20:30 Functions: 100.0 % 2 2
Branches: 60.0 % 10 6

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2020 The Bitcoin Core developers
       2                 :             : // Distributed under the MIT software license, see the accompanying
       3                 :             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4                 :             : 
       5                 :             : #include <span.h>
       6                 :             : #include <test/fuzz/FuzzedDataProvider.h>
       7                 :             : #include <test/fuzz/fuzz.h>
       8                 :             : #include <test/fuzz/util.h>
       9                 :             : 
      10                 :             : #include <cassert>
      11                 :             : #include <cstddef>
      12                 :             : #include <cstdint>
      13                 :             : #include <string>
      14                 :             : #include <vector>
      15                 :             : 
      16   [ +  -  +  - ]:          28 : FUZZ_TARGET(span)
      17                 :             : {
      18                 :          25 :     FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
      19                 :             : 
      20                 :          25 :     std::string str = fuzzed_data_provider.ConsumeBytesAsString(32);
      21         [ +  - ]:          25 :     const Span<const char> span{str};
      22                 :          25 :     (void)span.data();
      23                 :          25 :     (void)span.begin();
      24                 :          25 :     (void)span.end();
      25         [ +  + ]:          25 :     if (span.size() > 0) {
      26         [ +  - ]:          24 :         const std::ptrdiff_t idx = fuzzed_data_provider.ConsumeIntegralInRange<std::ptrdiff_t>(0U, span.size() - 1U);
      27                 :          24 :         (void)span.first(idx);
      28                 :          24 :         (void)span.last(idx);
      29                 :          24 :         (void)span.subspan(idx);
      30                 :          24 :         (void)span.subspan(idx, span.size() - idx);
      31                 :          24 :         (void)span[idx];
      32                 :          24 :     }
      33                 :          25 : }
        

Generated by: LCOV version 2.0-1