LCOV - code coverage report
Current view: top level - shared_model/cryptography/model_impl - hash.cpp (source / functions) Hit Total Coverage
Test: cleared_cor.info Lines: 8 10 80.0 %
Date: 2019-03-07 14:46:43 Functions: 9 9 100.0 %

          Line data    Source code
       1             : /**
       2             :  * Copyright Soramitsu Co., Ltd. All Rights Reserved.
       3             :  * SPDX-License-Identifier: Apache-2.0
       4             :  */
       5             : 
       6             : #include "cryptography/hash.hpp"
       7             : 
       8             : #include <boost/functional/hash.hpp>
       9             : 
      10             : #include "common/byteutils.hpp"
      11             : namespace shared_model {
      12             :   namespace crypto {
      13             : 
      14             :     Hash::Hash() : Blob() {}
      15             : 
      16             :     Hash::Hash(const std::string &hash) : Blob(hash) {}
      17             : 
      18             :     Hash::Hash(const Blob &blob) : Blob(blob) {}
      19             : 
      20             :     Hash Hash::fromHexString(const std::string &hex) {
      21       65922 :       return Hash(Blob::fromHexString(hex));
      22           0 :     }
      23             : 
      24             :     std::string Hash::toString() const {
      25        3329 :       return detail::PrettyStringBuilder()
      26        3328 :           .init("Hash")
      27        3329 :           .append(Blob::hex())
      28        3329 :           .finalize();
      29           0 :     }
      30             : 
      31             :     std::size_t Hash::Hasher::operator()(const Hash &h) const {
      32             :       using boost::hash_combine;
      33             :       using boost::hash_value;
      34             : 
      35       21818 :       std::size_t seed = 0;
      36       21818 :       hash_combine(seed, hash_value(h.blob()));
      37             : 
      38       21818 :       return seed;
      39             :     }
      40             :   }  // namespace crypto
      41             : }  // namespace shared_model

Generated by: LCOV version 1.13