Add tests for hash inversion
All checks were successful
lint/clippy Checking for common mistakes and opportunities for code improvement
build/linux Build for the target platform: linux
build/msvc Build for the target platform: msvc

Just a quick round trip test, and an additional assert to demonstrate
that byte order does matter.
This commit is contained in:
Lucas Schwiderski 2024-08-14 09:22:24 +02:00
parent 4b39d290b6
commit 2a1d8d815f
Signed by: lucas
GPG key ID: AA12679AAA6DF4D8

View file

@ -119,4 +119,9 @@ fn test_hash() {
} }
#[test] #[test]
fn test_inverse() {} fn test_inverse() {
let h = hash("lua".as_bytes(), crate::murmur::SEED as u64);
let inv = hash_inverse(h, crate::murmur::SEED as u64);
assert_eq!(h, hash(&inv.to_le_bytes(), crate::murmur::SEED as u64));
assert_ne!(h, hash(&inv.to_be_bytes(), crate::murmur::SEED as u64));
}