+32
-32
@@ -12,7 +12,7 @@ WpTestFuncResult test_murmur3(void) {
|
||||
WpI32Array arr = wpArray(i32, 1, 2, 3, 4, 5);
|
||||
u64 num = 287324;
|
||||
|
||||
WpMur3HasherIO io = wpMur3HasherIO(873923);
|
||||
WpMur3HasherData data = wpMur3HasherData(873923);
|
||||
|
||||
WpU8Stream str_bytes = wpStream(u8, str.buf, str.size);
|
||||
WpU8Stream arr_bytes = wpStream(u8, (u8 *)arr, wpArrayCount(arr) * wpArrayItemSize(arr));
|
||||
@@ -21,22 +21,22 @@ WpTestFuncResult test_murmur3(void) {
|
||||
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);
|
||||
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);
|
||||
|
||||
result = result && io.hash[0] == hash[0] && io.hash[1] == hash[1];
|
||||
result = result && mur_hash.hash[0] == hash[0] && mur_hash.hash[1] == 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);
|
||||
mur_hash = wpX64Mur3Hasher128(&arr_bytes, (void *)&data);
|
||||
MurmurHash3_x64_128(arr_bytes.data, arr_bytes.count * arr_bytes.item_size, data.seed, (void *)hash);
|
||||
|
||||
result = result && io.hash[0] == hash[0] && io.hash[1] == hash[1];
|
||||
result = result && mur_hash.hash[0] == hash[0] && mur_hash.hash[1] == 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);
|
||||
mur_hash = wpX64Mur3Hasher128(&num_bytes, (void *)&data);
|
||||
MurmurHash3_x64_128(num_bytes.data, num_bytes.count * num_bytes.item_size, data.seed, (void *)hash);
|
||||
|
||||
result = result && io.hash[0] == hash[0] && io.hash[1] == hash[1];
|
||||
result = result && mur_hash.hash[0] == hash[0] && mur_hash.hash[1] == hash[1];
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
@@ -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 };
|
||||
WpSipHasher128IO io = wpSip24Hasher128IO(key);
|
||||
WpSipHasherKey key = { 238742, 671734 };
|
||||
WpSipHasherData data = wpSip24HasherData(key);
|
||||
|
||||
WpU8Stream str_bytes = wpStream(u8, str.buf, str.size);
|
||||
WpU8Stream arr_bytes = wpStream(u8, (u8 *)arr, wpArrayCount(arr) * wpArrayItemSize(arr));
|
||||
@@ -58,25 +58,25 @@ WpTestFuncResult test_siphash_128(void) {
|
||||
u64 hash[2] = {0};
|
||||
|
||||
// Sring hash
|
||||
wpSipHasher128(&str_bytes, (void *)&io);
|
||||
siphash((void *)str_bytes.data, str_bytes.count * str_bytes.item_size, (void *)&io.params.key,
|
||||
WpU128Hash sip_hash = wpSipHasher128(&str_bytes, (void *)&data);
|
||||
siphash(str_bytes.data, str_bytes.count * str_bytes.item_size, (void *)&data.key,
|
||||
(u8 *)hash, sizeof(u64) * 2);
|
||||
|
||||
result = result && io.hash[0] == hash[0] && io.hash[1] == hash[1];
|
||||
result = result && sip_hash.hash[0] == hash[0] && sip_hash.hash[1] == hash[1];
|
||||
|
||||
// Array hash
|
||||
wpSipHasher128(&arr_bytes, (void *)&io);
|
||||
siphash((void *)arr_bytes.data, arr_bytes.count * arr_bytes.item_size, (void *)&io.params.key,
|
||||
sip_hash = wpSipHasher128(&arr_bytes, (void *)&data);
|
||||
siphash(arr_bytes.data, arr_bytes.count * arr_bytes.item_size, (void *)&data.key,
|
||||
(u8 *)hash, sizeof(u64) * 2);
|
||||
|
||||
result = result && io.hash[0] == hash[0] && io.hash[1] == hash[1];
|
||||
result = result && sip_hash.hash[0] == hash[0] && sip_hash.hash[1] == hash[1];
|
||||
|
||||
// Number hash
|
||||
wpSipHasher128(&num_bytes, (void *)&io);
|
||||
siphash((void *)num_bytes.data, num_bytes.count * num_bytes.item_size, (void *)&io.params.key,
|
||||
sip_hash = wpSipHasher128(&num_bytes, (void *)&data);
|
||||
siphash(num_bytes.data, num_bytes.count * num_bytes.item_size, (void *)&data.key,
|
||||
(u8 *)hash, sizeof(u64) * 2);
|
||||
|
||||
result = result && io.hash[0] == hash[0] && io.hash[1] == hash[1];
|
||||
result = result && sip_hash.hash[0] == hash[0] && sip_hash.hash[1] == hash[1];
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
@@ -88,8 +88,8 @@ WpTestFuncResult test_siphash_64(void) {
|
||||
WpI32Array arr = wpArray(i32, 1, 2, 3, 4, 5);
|
||||
u64 num = 287324;
|
||||
|
||||
WpSipHasherKey key = { 238742, 671734 };
|
||||
WpSipHasher64IO io = wpSip24Hasher64IO(key);
|
||||
WpSipHasherKey key = { 238742, 671734 };
|
||||
WpSipHasherData data = wpSip24HasherData(key);
|
||||
|
||||
WpU8Stream str_bytes = wpStream(u8, str.buf, str.size);
|
||||
WpU8Stream arr_bytes = wpStream(u8, (u8 *)arr, wpArrayCount(arr) * wpArrayItemSize(arr));
|
||||
@@ -98,25 +98,25 @@ WpTestFuncResult test_siphash_64(void) {
|
||||
u64 hash = {0};
|
||||
|
||||
// Sring hash
|
||||
wpSipHasher64(&str_bytes, (void *)&io);
|
||||
siphash((void *)str_bytes.data, str_bytes.count * str_bytes.item_size, (void *)&io.params.key,
|
||||
u64 sip_hash = wpSipHasher64(&str_bytes, (void *)&data);
|
||||
siphash(str_bytes.data, str_bytes.count * str_bytes.item_size, (void *)&data.key,
|
||||
(u8 *)&hash, sizeof(u64));
|
||||
|
||||
result = result && io.hash == hash;
|
||||
result = result && sip_hash == hash;
|
||||
|
||||
// Array hash
|
||||
wpSipHasher64(&arr_bytes, (void *)&io);
|
||||
siphash((void *)arr_bytes.data, arr_bytes.count * arr_bytes.item_size, (void *)&io.params.key,
|
||||
sip_hash = wpSipHasher64(&arr_bytes, (void *)&data);
|
||||
siphash(arr_bytes.data, arr_bytes.count * arr_bytes.item_size, (void *)&data.key,
|
||||
(u8 *)&hash, sizeof(u64));
|
||||
|
||||
result = result && io.hash == hash;
|
||||
result = result && sip_hash == hash;
|
||||
|
||||
// Number hash
|
||||
wpSipHasher64(&num_bytes, (void *)&io);
|
||||
siphash((void *)num_bytes.data, num_bytes.count * num_bytes.item_size, (void *)&io.params.key,
|
||||
sip_hash = wpSipHasher64(&num_bytes, (void *)&data);
|
||||
siphash(num_bytes.data, num_bytes.count * num_bytes.item_size, (void *)&data.key,
|
||||
(u8 *)&hash, sizeof(u64));
|
||||
|
||||
result = result && io.hash == hash;
|
||||
result = result && sip_hash == hash;
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user