LCOV - code coverage report
Current view: top level - src/test - sha256compress_tests.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 15 15 100.0 %
Date: 2025-02-23 09:33:43 Functions: 2 2 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2020 The PIVX 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 "test/test_pivx.h"
       6             : #include "crypto/sha256.h"
       7             : #include "uint256.h"
       8             : 
       9             : #include <stdexcept>
      10             : 
      11             : #include <boost/test/unit_test.hpp>
      12             : 
      13             : BOOST_FIXTURE_TEST_SUITE(sha256compress_tests, BasicTestingSetup)
      14             : 
      15           2 : BOOST_AUTO_TEST_CASE(compression)
      16             : {
      17           1 :     {
      18           1 :         unsigned char preimage[64] = {};
      19           1 :         CSHA256 hasher;
      20           1 :         hasher.Write(&preimage[0], 64);
      21             : 
      22           1 :         uint256 digest;
      23             : 
      24           1 :         hasher.FinalizeNoPadding(digest.begin());
      25             : 
      26           4 :         BOOST_CHECK_MESSAGE(digest == uint256S("d8a93718eaf9feba4362d2c091d4e58ccabe9f779957336269b4b917be9856da"),
      27             :                             digest.GetHex());
      28             :     }
      29             : 
      30           1 :     {
      31           1 :         unsigned char preimage[63] = {};
      32           1 :         CSHA256 hasher;
      33           1 :         hasher.Write(&preimage[0], 63);
      34           1 :         uint256 digest;
      35           2 :         BOOST_CHECK_THROW(hasher.FinalizeNoPadding(digest.begin()), std::length_error);
      36             :     }
      37           1 : }
      38             : 
      39             : BOOST_AUTO_TEST_SUITE_END()

Generated by: LCOV version 1.14