Add implementation for the murmur3 x64_128 hash
Release / release (push) Successful in 3s

This commit is contained in:
2026-08-30 22:03:28 +01:00
parent d5578f009a
commit 55ff77c4ea
15 changed files with 980 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
// vim:fileencoding=utf-8:foldmethod=marker
#include "test_hasher.h"
#include "MurmurHash3.h"
#include "wapp.h"
WpTestFuncResult test_murmur3(void) {
b8 result = true;
WpStr8 str = wpStr8Lit("Hello world");
WpI32Array arr = wpArray(i32, 1, 2, 3, 4, 5);
u64 num = 287324;
WpMur3HasherIO io = wpMur3HasherIO(873923);
WpU8Stream str_bytes = wpStream(u8, str.buf, str.size);
WpU8Stream arr_bytes = wpStream(u8, (u8 *)arr, wpArrayCount(arr) * wpArrayItemSize(arr));
WpU8Stream num_bytes = wpStream(u8, (u8 *)&num, sizeof(u64));
u64 hash[2] = {0};
// Sring hash
wpX64Mur3Hasher128(&str_bytes, (void *)&io);
MurmurHash3_x64_128(str_bytes.data, str_bytes.count * str_bytes.item_size, io.seed, (void *)hash);
result = result && io.out_hash1 == hash[0] && io.out_hash2 == hash[1];
// Array hash
wpX64Mur3Hasher128(&arr_bytes, (void *)&io);
MurmurHash3_x64_128(arr_bytes.data, arr_bytes.count * arr_bytes.item_size, io.seed, (void *)hash);
result = result && io.out_hash1 == hash[0] && io.out_hash2 == hash[1];
// Number hash
wpX64Mur3Hasher128(&num_bytes, (void *)&io);
MurmurHash3_x64_128(num_bytes.data, num_bytes.count * num_bytes.item_size, io.seed, (void *)hash);
result = result && io.out_hash1 == hash[0] && io.out_hash2 == hash[1];
return wpTesterResult(result);
}