This commit is contained in:
@@ -80,43 +80,3 @@ WpTestFuncResult test_siphash_128(void) {
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_siphash_64(void) {
|
||||
b8 result = true;
|
||||
|
||||
WpStr8 str = wpStr8Lit("Hello world");
|
||||
WpI32Array arr = wpArray(i32, 1, 2, 3, 4, 5);
|
||||
u64 num = 287324;
|
||||
|
||||
WpSipHasherKey key = { .lo = 238742, .hi = 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));
|
||||
WpU8Stream num_bytes = wpStream(u8, (u8 *)&num, sizeof(u64));
|
||||
|
||||
u64 hash = {0};
|
||||
|
||||
// Sring hash
|
||||
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 && sip_hash == hash;
|
||||
|
||||
// Array hash
|
||||
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 && sip_hash == hash;
|
||||
|
||||
// Number hash
|
||||
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 && sip_hash == hash;
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
@@ -80,43 +80,3 @@ WpTestFuncResult test_siphash_128(void) {
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_siphash_64(void) {
|
||||
b8 result = true;
|
||||
|
||||
WpStr8 str = wpStr8Lit("Hello world");
|
||||
WpI32Array arr = wpArray(i32, 1, 2, 3, 4, 5);
|
||||
u64 num = 287324;
|
||||
|
||||
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));
|
||||
WpU8Stream num_bytes = wpStream(u8, (u8 *)&num, sizeof(u64));
|
||||
|
||||
u64 hash = {0};
|
||||
|
||||
// Sring hash
|
||||
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 && sip_hash == hash;
|
||||
|
||||
// Array hash
|
||||
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 && sip_hash == hash;
|
||||
|
||||
// Number hash
|
||||
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 && sip_hash == hash;
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,5 @@ WpTestFuncResult test_murmur3(void);
|
||||
|
||||
// Test Sip hash implementation against the reference implementation
|
||||
WpTestFuncResult test_siphash_128(void);
|
||||
WpTestFuncResult test_siphash_64(void);
|
||||
|
||||
#endif // !TEST_HASHER_H
|
||||
|
||||
Reference in New Issue
Block a user