From 3a28451e796a5a84cef005c82e53c654f3fcd490 Mon Sep 17 00:00:00 2001 From: Tom Kaitchuck Date: Thu, 29 Feb 2024 19:41:40 -0800 Subject: [PATCH] Add test from #213 Signed-off-by: Tom Kaitchuck --- src/lib.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index c757a70..53527a2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -337,4 +337,31 @@ mod test { fn test_ahasher_construction() { let _ = AHasher::new_with_keys(1234, 5678); } + + #[test] + fn test_specialize_reference_hash() { + let hasher_build = RandomState::default(); + let h1 = hasher_build.hash_one(1u64); + let h2 = hasher_build.hash_one(&1u64); + let h3 = hasher_build.hash_one(&&1u64); + + assert_eq!(h1, h2); + assert_eq!(h1, h3); + + let h1 = u64::get_hash(&1_u64, &hasher_build); + let h2 = u64::get_hash(&&1_u64, &hasher_build); + let h3 = u64::get_hash(&&&1_u64, &hasher_build); + + assert_eq!(h1, h2); + assert_eq!(h1, h3); + + let hasher_build = RandomState::::default(); + + let h1 = hasher_build.hash_one(1u128); + let h2 = hasher_build.hash_one(&1u128); + let h3 = hasher_build.hash_one(&&1u128); + + assert_eq!(h1, h2); + assert_eq!(h1, h3); + } }