Skip to content
This repository was archived by the owner on Jul 7, 2020. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/test/java/com/clearspring/analytics/hash/TestMurmurHash.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,22 @@ public void testHash64ByteArrayOverload() {
assertEquals("MurmurHash.hash64(Object) given a byte[] did not match MurmurHash.hash64(String)",
hashOfString, MurmurHash.hash64(bytesAsObject));
}

// test the returned valued of hash functions against the reference implementation: https://github.com/aappleby/smhasher.git

@Test
public void testHash64() throws Exception {
final long actualHash = MurmurHash.hash64("hashthis");
final long expectedHash = -8896273065425798843L;

assertEquals("MurmurHash.hash64(String) returns wrong hash value", expectedHash, actualHash);
}

@Test
public void testHash() throws Exception {
final long actualHash = MurmurHash.hash("hashthis");
final long expectedHash = -1974946086L;

assertEquals("MurmurHash.hash(String) returns wrong hash value", expectedHash, actualHash);
}
}