std:#️⃣ Add testcase for colliding hashes of tuples

Add a testcase that verifies that (s, t) and (u, v) don't collide even if
s + t == u + v (concatenation).
This commit is contained in:
blake2-ppc 2013-08-18 15:23:42 +02:00
parent 73fdacbac9
commit bfa1331cd7

View File

@ -595,4 +595,18 @@ mod tests {
fn test_float_hashes_of_zero() {
assert_eq!(0.0.hash(), (-0.0).hash());
}
#[test]
fn test_hash_no_concat_alias() {
let s = ("aa", "bb");
let t = ("aabb", "");
let u = ("a", "abb");
let v = (&[1u8], &[0u8, 0], &[0u8]);
let w = (&[1u8, 0, 0, 0], &[], &[]);
assert!(v != w);
assert!(s.hash() != t.hash() && s.hash() != u.hash());
assert!(v.hash() != w.hash());
}
}