This commit is contained in:
+15
-15
@@ -12,7 +12,7 @@ WpTestFuncResult test_murmur3(void) {
|
||||
WpI32Array arr = wpArray(i32, 1, 2, 3, 4, 5);
|
||||
u64 num = 287324;
|
||||
|
||||
WpMur3HasherData data = wpMur3HasherData(873923);
|
||||
WpMur3HasherCtx ctx = wpMur3HasherCtx(873923);
|
||||
|
||||
WpU8Stream str_bytes = wpStream(u8, str.buf, str.size);
|
||||
WpU8Stream arr_bytes = wpStream(u8, (u8 *)arr, wpArrayCount(arr) * wpArrayItemSize(arr));
|
||||
@@ -21,20 +21,20 @@ WpTestFuncResult test_murmur3(void) {
|
||||
u64 hash[2] = {0};
|
||||
|
||||
// Sring hash
|
||||
WpU128Hash mur_hash = wpX64Mur3Hasher128(&str_bytes, (void *)&data);
|
||||
MurmurHash3_x64_128(str_bytes.data, str_bytes.count * str_bytes.item_size, data.seed, (void *)hash);
|
||||
WpU128Hash mur_hash = wpX64Mur3Hasher128(&str_bytes, (void *)&ctx);
|
||||
MurmurHash3_x64_128(str_bytes.data, str_bytes.count * str_bytes.item_size, ctx.seed, (void *)hash);
|
||||
|
||||
result = result && mur_hash.hash[0] == hash[0] && mur_hash.hash[1] == hash[1];
|
||||
|
||||
// Array hash
|
||||
mur_hash = wpX64Mur3Hasher128(&arr_bytes, (void *)&data);
|
||||
MurmurHash3_x64_128(arr_bytes.data, arr_bytes.count * arr_bytes.item_size, data.seed, (void *)hash);
|
||||
mur_hash = wpX64Mur3Hasher128(&arr_bytes, (void *)&ctx);
|
||||
MurmurHash3_x64_128(arr_bytes.data, arr_bytes.count * arr_bytes.item_size, ctx.seed, (void *)hash);
|
||||
|
||||
result = result && mur_hash.hash[0] == hash[0] && mur_hash.hash[1] == hash[1];
|
||||
|
||||
// Number hash
|
||||
mur_hash = wpX64Mur3Hasher128(&num_bytes, (void *)&data);
|
||||
MurmurHash3_x64_128(num_bytes.data, num_bytes.count * num_bytes.item_size, data.seed, (void *)hash);
|
||||
mur_hash = wpX64Mur3Hasher128(&num_bytes, (void *)&ctx);
|
||||
MurmurHash3_x64_128(num_bytes.data, num_bytes.count * num_bytes.item_size, ctx.seed, (void *)hash);
|
||||
|
||||
result = result && mur_hash.hash[0] == hash[0] && mur_hash.hash[1] == hash[1];
|
||||
|
||||
@@ -48,8 +48,8 @@ WpTestFuncResult test_siphash_128(void) {
|
||||
WpI32Array arr = wpArray(i32, 1, 2, 3, 4, 5);
|
||||
u64 num = 287324;
|
||||
|
||||
WpSipHasherKey key = { 238742, 671734 };
|
||||
WpSipHasherData data = wpSip24HasherData(key);
|
||||
WpSipHasherKey key = { 238742, 671734 };
|
||||
WpSipHasherCtx ctx = wpSip24HasherCtx(key);
|
||||
|
||||
WpU8Stream str_bytes = wpStream(u8, str.buf, str.size);
|
||||
WpU8Stream arr_bytes = wpStream(u8, (u8 *)arr, wpArrayCount(arr) * wpArrayItemSize(arr));
|
||||
@@ -58,22 +58,22 @@ WpTestFuncResult test_siphash_128(void) {
|
||||
u64 hash[2] = {0};
|
||||
|
||||
// Sring hash
|
||||
WpU128Hash sip_hash = wpSipHasher128(&str_bytes, (void *)&data);
|
||||
siphash(str_bytes.data, str_bytes.count * str_bytes.item_size, (void *)&data.key,
|
||||
WpU128Hash sip_hash = wpSipHasher128(&str_bytes, (void *)&ctx);
|
||||
siphash(str_bytes.data, str_bytes.count * str_bytes.item_size, (void *)&ctx.key,
|
||||
(u8 *)hash, sizeof(u64) * 2);
|
||||
|
||||
result = result && sip_hash.hash[0] == hash[0] && sip_hash.hash[1] == hash[1];
|
||||
|
||||
// Array hash
|
||||
sip_hash = wpSipHasher128(&arr_bytes, (void *)&data);
|
||||
siphash(arr_bytes.data, arr_bytes.count * arr_bytes.item_size, (void *)&data.key,
|
||||
sip_hash = wpSipHasher128(&arr_bytes, (void *)&ctx);
|
||||
siphash(arr_bytes.data, arr_bytes.count * arr_bytes.item_size, (void *)&ctx.key,
|
||||
(u8 *)hash, sizeof(u64) * 2);
|
||||
|
||||
result = result && sip_hash.hash[0] == hash[0] && sip_hash.hash[1] == hash[1];
|
||||
|
||||
// Number hash
|
||||
sip_hash = wpSipHasher128(&num_bytes, (void *)&data);
|
||||
siphash(num_bytes.data, num_bytes.count * num_bytes.item_size, (void *)&data.key,
|
||||
sip_hash = wpSipHasher128(&num_bytes, (void *)&ctx);
|
||||
siphash(num_bytes.data, num_bytes.count * num_bytes.item_size, (void *)&ctx.key,
|
||||
(u8 *)hash, sizeof(u64) * 2);
|
||||
|
||||
result = result && sip_hash.hash[0] == hash[0] && sip_hash.hash[1] == hash[1];
|
||||
|
||||
Reference in New Issue
Block a user