2020-01-29 01:43:09 +03:00
|
|
|
import hash.fnv1a
|
|
|
|
|
2021-12-29 12:27:26 +03:00
|
|
|
fn test_fnv1a_sum32() {
|
2020-02-05 12:00:11 +03:00
|
|
|
$if windows {
|
|
|
|
return
|
|
|
|
}
|
2021-12-29 12:27:26 +03:00
|
|
|
ahash := '10bc2abf'
|
2020-01-29 01:43:09 +03:00
|
|
|
a := 'apple'
|
2021-12-29 12:27:26 +03: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-29 01:43:09 +03:00
|
|
|
b := fnv1a.sum64_string(a)
|
|
|
|
c := fnv1a.sum64(a.bytes())
|
2021-12-29 12:27:26 +03:00
|
|
|
d := unsafe { fnv1a.sum64_bytes(a.str, a.len) }
|
|
|
|
assert b.hex() == ahash
|
|
|
|
assert c.hex() == ahash
|
|
|
|
assert d.hex() == ahash
|
2020-01-29 01:43:09 +03:00
|
|
|
}
|