2020-01-28 23:43:09 +01:00
|
|
|
import hash.fnv1a
|
|
|
|
|
2021-12-29 10:27:26 +01:00
|
|
|
fn test_fnv1a_sum32() {
|
2020-02-05 10:00:11 +01:00
|
|
|
$if windows {
|
|
|
|
return
|
|
|
|
}
|
2021-12-29 10:27:26 +01:00
|
|
|
ahash := '10bc2abf'
|
2020-01-28 23:43:09 +01:00
|
|
|
a := 'apple'
|
2021-12-29 10:27:26 +01:00
|
|
|
b := fnv1a.sum32_string(a)
|
|
|
|
c := fnv1a.sum32(a.bytes())
|
|
|
|
d := unsafe { fnv1a.sum32_bytes(a.str, a.len) }
|
|
|
|
assert b.hex() == ahash
|
|
|
|
assert c.hex() == ahash
|
|
|
|
assert d.hex() == ahash
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test_fnv1a_sum64() {
|
|
|
|
$if windows {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
a := 'apple'
|
|
|
|
ahash := 'f74a62a458befdbf'
|
2020-01-28 23:43:09 +01:00
|
|
|
b := fnv1a.sum64_string(a)
|
|
|
|
c := fnv1a.sum64(a.bytes())
|
2021-12-29 10:27:26 +01:00
|
|
|
d := unsafe { fnv1a.sum64_bytes(a.str, a.len) }
|
|
|
|
assert b.hex() == ahash
|
|
|
|
assert c.hex() == ahash
|
|
|
|
assert d.hex() == ahash
|
2020-01-28 23:43:09 +01:00
|
|
|
}
|