LCOV - code coverage report
Current view: top level - src/test - hash_tests.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 18 18 100.0 %
Date: 2015-10-12 22:39:14 Functions: 4 6 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Copyright (c) 2013 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 "hash.h"
       6             : #include "utilstrencodings.h"
       7             : #include "test/test_bitcoin.h"
       8             : 
       9             : #include <vector>
      10             : 
      11             : #include <boost/test/unit_test.hpp>
      12             : 
      13             : using namespace std;
      14             : 
      15           1 : BOOST_FIXTURE_TEST_SUITE(hash_tests, BasicTestingSetup)
      16             : 
      17           6 : BOOST_AUTO_TEST_CASE(murmurhash3)
      18             : {
      19             : 
      20             : #define T(expected, seed, data) BOOST_CHECK_EQUAL(MurmurHash3(seed, ParseHex(data)), expected)
      21             : 
      22             :     // Test MurmurHash3 with various inputs. Of course this is retested in the
      23             :     // bloom filter tests - they would fail if MurmurHash3() had any problems -
      24             :     // but is useful for those trying to implement Bitcoin libraries as a
      25             :     // source of test data for their MurmurHash3() primitive during
      26             :     // development.
      27             :     //
      28             :     // The magic number 0xFBA4C795 comes from CBloomFilter::Hash()
      29             : 
      30           6 :     T(0x00000000, 0x00000000, "");
      31           6 :     T(0x6a396f08, 0xFBA4C795, "");
      32           6 :     T(0x81f16f39, 0xffffffff, "");
      33             : 
      34           6 :     T(0x514e28b7, 0x00000000, "00");
      35           6 :     T(0xea3f0b17, 0xFBA4C795, "00");
      36           6 :     T(0xfd6cf10d, 0x00000000, "ff");
      37             : 
      38           6 :     T(0x16c6b7ab, 0x00000000, "0011");
      39           6 :     T(0x8eb51c3d, 0x00000000, "001122");
      40           6 :     T(0xb4471bf8, 0x00000000, "00112233");
      41           6 :     T(0xe2301fa8, 0x00000000, "0011223344");
      42           6 :     T(0xfc2e4a15, 0x00000000, "001122334455");
      43           6 :     T(0xb074502c, 0x00000000, "00112233445566");
      44           6 :     T(0x8034d2a0, 0x00000000, "0011223344556677");
      45           6 :     T(0xb4698def, 0x00000000, "001122334455667788");
      46             : 
      47             : #undef T
      48           1 : }
      49             : 
      50           3 : BOOST_AUTO_TEST_SUITE_END()

Generated by: LCOV version 1.11