Run the official test for MurmurHash3
| 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 | { |
no test coverage detected