Skip to content

Commit

Permalink
Add test from #213
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Kaitchuck <Tom.Kaitchuck@gmail.com>
  • Loading branch information
tkaitchuck committed Mar 1, 2024
1 parent fa016f4 commit 3a28451
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<u128>::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);
}
}

0 comments on commit 3a28451

Please sign in to comment.