MCPcopy Create free account
hub / github.com/davisking/dlib / murmur_hash_test

Function murmur_hash_test

dlib/test/hash.cpp:51–78  ·  view source on GitHub ↗

Run the official test for MurmurHash3

Source from the content-addressed store, hash-verified

49
50 // Run the official test for MurmurHash3
51 void murmur_hash_test()
52 {
53 uint8 key[256];
54 uint32 hashes[256];
55 uint32 final = 0;
56
57 memset(key,0,sizeof(key));
58 memset(hashes,0,sizeof(hashes));
59
60 // Hash keys of the form {0}, {0,1}, {0,1,2}... up to N=255,using 256-N as
61 // the seed.
62 for(int i = 0; i < 256; i++)
63 {
64 key[i] = (uint8)i;
65
66 hashes[i] = murmur_hash3(key,i,256-i);
67 }
68
69 byte_orderer bo;
70 bo.host_to_little(hashes);
71 final = murmur_hash3(hashes,sizeof(hashes),0);
72
73 // using ostringstream to avoid compiler error in visual studio 2005
74 ostringstream sout;
75 sout << hex << final;
76 dlog << LINFO << "final: "<< sout.str();
77 DLIB_TEST(final == 0xB0F57EE3);
78 }
79
80 void murmur_hash_128_test()
81 {

Callers 1

perform_testMethod · 0.85

Calls 3

murmur_hash3Function · 0.85
host_to_littleMethod · 0.80
strMethod · 0.45

Tested by

no test coverage detected