Skip to content

Commit fb2957e

Browse files
authored
Add tests for Hash impl (#214)
1 parent b3b36c6 commit fb2957e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,24 @@ fn from_fn() {
258258
assert_eq!(array.as_slice(), EXAMPLE_SLICE);
259259
}
260260

261+
#[test]
262+
#[allow(clippy::std_instead_of_core)]
263+
fn hash() {
264+
use std::hash::{DefaultHasher, Hash, Hasher};
265+
266+
type A = Array<u8, U2>;
267+
let array1: A = Array([1, 2]);
268+
let array2: A = Array([1, 3]);
269+
270+
let mut hasher1 = DefaultHasher::new();
271+
array1.hash(&mut hasher1);
272+
273+
let mut hasher2 = DefaultHasher::new();
274+
array2.hash(&mut hasher2);
275+
276+
assert_ne!(hasher1.finish(), hasher2.finish());
277+
}
278+
261279
#[test]
262280
fn tryfrom_slice_for_clonable_array() {
263281
assert!(Array::<u8, U0>::try_from(EXAMPLE_SLICE).is_err());

0 commit comments

Comments
 (0)