LCOV - code coverage report
Current view: top level - src/util - hash_type.h (source / functions) Coverage Total Hit
Test: fuzz_coverage.info Lines: 100.0 % 16 16
Test Date: 2026-08-15 06:42:17 Functions: 100.0 % 2 2
Branches: 50.0 % 66 33

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2020-present 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                 :             : #ifndef BITCOIN_UTIL_HASH_TYPE_H
       6                 :             : #define BITCOIN_UTIL_HASH_TYPE_H
       7                 :             : 
       8                 :             : template <typename HashType>
       9                 :             : class BaseHash
      10                 :             : {
      11                 :             : protected:
      12                 :             :     HashType m_hash;
      13                 :             : 
      14                 :             : public:
      15   [ +  +  +  + ]:     5685653 :     BaseHash() : m_hash() {}
      16 [ #  # ][ +  - ]:     1990105 :     explicit BaseHash(const HashType& in) : m_hash(in) {}
           [ #  #  #  # ]
           [ +  -  +  -  
           +  - ][ +  -  
          +  -  +  -  +  
           - ][ +  -  +  
          -  +  -  +  -  
                   +  - ]
      17                 :             : 
      18                 :      391508 :     unsigned char* begin()
      19                 :             :     {
      20                 :      391508 :         return m_hash.begin();
      21                 :             :     }
      22                 :             : 
      23                 :     2018838 :     const unsigned char* begin() const
      24                 :             :     {
      25 [ #  # ][ +  -  :     2018838 :         return m_hash.begin();
          +  -  +  -  +  
                      - ]
      26                 :             :     }
      27                 :             : 
      28                 :             :     unsigned char* end()
      29                 :             :     {
      30                 :             :         return m_hash.end();
      31                 :             :     }
      32                 :             : 
      33                 :     2018838 :     const unsigned char* end() const
      34                 :             :     {
      35   [ +  -  +  -  :     2018838 :         return m_hash.end();
             +  -  +  - ]
      36                 :             :     }
      37                 :             : 
      38                 :             :     operator std::vector<unsigned char>() const
      39                 :             :     {
      40                 :             :         return std::vector<unsigned char>{m_hash.begin(), m_hash.end()};
      41                 :             :     }
      42                 :             : 
      43                 :        1584 :     std::string ToString() const
      44                 :             :     {
      45         [ +  - ]:        1584 :         return m_hash.ToString();
      46                 :             :     }
      47                 :             : 
      48                 :      264716 :     bool operator==(const BaseHash<HashType>& other) const noexcept
      49                 :             :     {
      50         [ -  + ]:      264716 :         return m_hash == other.m_hash;
           [ +  +  +  + ]
      51                 :             :     }
      52                 :             : 
      53                 :     2813295 :     bool operator<(const BaseHash<HashType>& other) const noexcept
      54                 :             :     {
      55                 :     2813295 :         return m_hash < other.m_hash;
      56                 :             :     }
      57                 :             : 
      58                 :             :     size_t size() const
      59                 :             :     {
      60                 :             :         return m_hash.size();
      61                 :             :     }
      62                 :             : 
      63                 :        2981 :     unsigned char* data() { return m_hash.data(); }
      64   [ +  -  +  - ]:       20440 :     const unsigned char* data() const { return m_hash.data(); }
      65                 :             : };
      66                 :             : 
      67                 :             : #endif // BITCOIN_UTIL_HASH_TYPE_H
        

Generated by: LCOV version 2.5.0-full