Skip to content

Commit

Permalink
Simplifies LtHash tests (#2993)
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo authored Sep 26, 2024
1 parent a15fef1 commit a5b3c2b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lattice-hash/src/lt_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,22 @@ mod tests {
}
}

impl Copy for LtHash {}

// Ensure that if you mix-in then mix-out a hash, you get the original value
#[test]
fn test_inverse() {
let a = LtHash::new_random();
let b = LtHash::new_random();
assert_eq!(a.clone(), a.clone() + b.clone() - b.clone());
assert_eq!(a, a + b - b);
}

// Ensure that mixing is commutative
#[test]
fn test_commutative() {
let a = LtHash::new_random();
let b = LtHash::new_random();
assert_eq!(a.clone() + b.clone(), b.clone() + a.clone());
assert_eq!(a + b, b + a);
}

// Ensure that mixing is associative
Expand All @@ -134,10 +136,7 @@ mod tests {
let a = LtHash::new_random();
let b = LtHash::new_random();
let c = LtHash::new_random();
assert_eq!(
(a.clone() + b.clone()) + c.clone(),
a.clone() + (b.clone() + c.clone()),
);
assert_eq!((a + b) + c, a + (b + c));
}

// Ensure the correct lattice hash and checksum values are produced
Expand Down

0 comments on commit a5b3c2b

Please sign in to comment.