From b0d6076a67ecfaf3f7df480f62f432df1e88f8e8 Mon Sep 17 00:00:00 2001 From: Anders Olsson Date: Wed, 24 Oct 2018 17:29:40 +0200 Subject: [PATCH] Added a custom epsilon for tests. --- src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1d8252c..5207ac2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -301,6 +301,8 @@ mod tests { use super::*; + const EPSILON: f64 = 2e-14; + impl AbsDiffEq for Rating { type Epsilon = f64; @@ -336,7 +338,7 @@ mod tests { let alice = Rating::new(MU, SIGMA); let bob = Rating::new(MU, SIGMA); - assert_relative_eq!(quality(&[&[alice], &[bob]]), 0.4472135954999579); + assert_relative_eq!(quality(&[&[alice], &[bob]]), 0.4472135954999579, epsilon = EPSILON); } #[test] @@ -356,7 +358,7 @@ mod tests { let ratings = rate(&[&[alice], &[bob], &[chris], &[darren]]); for (rating, expected) in ratings.iter().zip(expected_ratings.iter()) { - assert_relative_eq!(rating, expected); + assert_relative_eq!(rating, expected, epsilon = EPSILON); } } }