LCOV - code coverage report
Current view: top level - src/util - hash_type.h (source / functions) Coverage Total Hit
Test: test_bitcoin_coverage.info Lines: 100.0 % 21 21
Test Date: 2024-08-28 04:44:32 Functions: - 0 0
Branches: 31.9 % 254 81

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2020-2021 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   [ +  -  +  -  :       33929 :     BaseHash() : m_hash() {}
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
           [ +  +  +  + ]
      16 [ +  - ][ -  -  :      178918 :     explicit BaseHash(const HashType& in) : m_hash(in) {}
          +  -  +  -  #  
                      # ]
           [ +  -  +  - ]
           [ +  -  +  -  
             +  -  +  - ]
      17                 :             : 
      18                 :        7573 :     unsigned char* begin()
      19                 :             :     {
      20         [ +  - ]:        7573 :         return m_hash.begin();
      21                 :             :     }
      22                 :             : 
      23                 :      341619 :     const unsigned char* begin() const
      24                 :             :     {
      25 [ #  # ][ +  -  :      341619 :         return m_hash.begin();
          +  -  +  -  +  
                      - ]
      26                 :             :     }
      27                 :             : 
      28                 :             :     unsigned char* end()
      29                 :             :     {
      30                 :             :         return m_hash.end();
      31                 :             :     }
      32                 :             : 
      33                 :      341551 :     const unsigned char* end() const
      34                 :             :     {
      35   [ +  -  +  -  :      341619 :         return m_hash.end();
             +  -  +  - ]
      36                 :             :     }
      37                 :             : 
      38                 :         600 :     operator std::vector<unsigned char>() const
      39                 :             :     {
      40         [ +  - ]:         600 :         return std::vector<unsigned char>{m_hash.begin(), m_hash.end()};
      41                 :             :     }
      42                 :             : 
      43                 :          10 :     std::string ToString() const
      44                 :             :     {
      45 [ +  - ][ +  -  :          10 :         return m_hash.ToString();
             +  -  +  - ]
           [ +  -  +  - ]
      46                 :             :     }
      47                 :             : 
      48                 :         550 :     bool operator==(const BaseHash<HashType>& other) const noexcept
      49                 :             :     {
      50   [ +  -  +  -  :         550 :         return m_hash == other.m_hash;
             +  -  +  - ]
           [ +  +  #  #  
             #  #  #  # ]
           [ +  +  +  + ]
      51                 :             :     }
      52                 :             : 
      53                 :          13 :     bool operator!=(const BaseHash<HashType>& other) const noexcept
      54                 :             :     {
      55   [ +  +  +  + ]:          13 :         return !(m_hash == other.m_hash);
      56                 :             :     }
      57                 :             : 
      58                 :      289321 :     bool operator<(const BaseHash<HashType>& other) const noexcept
      59                 :             :     {
      60   [ -  -  -  -  :      289321 :         return m_hash < other.m_hash;
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  +  
           -  -  - ][ #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
           #  # ][ -  +  
          +  -  +  -  +  
          -  -  -  -  -  
          +  +  -  +  +  
           -  +  + ][ -  
          +  -  -  -  -  
          +  +  +  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  +  
           -  - ][ -  -  
          -  -  -  -  -  
          -  +  +  -  -  
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  -  +  
             +  -  -  +  
                      + ]
      61                 :             :     }
      62                 :             : 
      63   [ #  #  #  # ]:           2 :     size_t size() const
                 [ +  - ]
      64                 :             :     {
      65                 :             :         return m_hash.size();
      66                 :             :     }
      67                 :             : 
      68         [ +  - ]:           1 :     unsigned char* data() { return m_hash.data(); }
      69   [ #  #  #  # ]:           1 :     const unsigned char* data() const { return m_hash.data(); }
      70                 :             : };
      71                 :             : 
      72                 :             : #endif // BITCOIN_UTIL_HASH_TYPE_H
        

Generated by: LCOV version 2.0-1