From 7c13c8838a96c25ae6c8263b795909c951ae0384 Mon Sep 17 00:00:00 2001 From: Rico Riedel Date: Fri, 5 Aug 2022 19:20:50 +0200 Subject: [PATCH] Switch to approx --- src/transform/invert.rs | 3 ++- src/transform/shift.rs | 3 ++- src/transform/slice.rs | 5 +++-- src/transform/swap.rs | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/transform/invert.rs b/src/transform/invert.rs index 7744d4e..01cd310 100644 --- a/src/transform/invert.rs +++ b/src/transform/invert.rs @@ -30,6 +30,7 @@ impl Pattern for Invert { mod test { use super::*; use crate::MockPatternFactory; + use approx::*; use mockall::predicate::eq; #[test] @@ -62,7 +63,7 @@ mod test { let sampler = InvertFactory::new(Box::new(child)).create(&Config::default()); - assert_eq!(0.3, sampler.sample(Vector::default())); + assert_abs_diff_eq!(0.3, sampler.sample(Vector::default())); } #[test] diff --git a/src/transform/shift.rs b/src/transform/shift.rs index 2840473..39f090d 100644 --- a/src/transform/shift.rs +++ b/src/transform/shift.rs @@ -28,6 +28,7 @@ impl Pattern for Shift { mod test { use super::*; use crate::MockPatternFactory; + use approx::*; use mockall::predicate::eq; #[test] @@ -61,7 +62,7 @@ mod test { let sampler = ShiftFactory::new(Box::new(child)).create(&config); - assert_eq!(0.8, sampler.sample(Vector::default())); + assert_abs_diff_eq!(0.8, sampler.sample(Vector::default())); } #[test] diff --git a/src/transform/slice.rs b/src/transform/slice.rs index 50e75fe..1aaef8a 100644 --- a/src/transform/slice.rs +++ b/src/transform/slice.rs @@ -38,6 +38,7 @@ impl Pattern for Slice { mod test { use super::*; use crate::MockPatternFactory; + use approx::*; use mockall::predicate::eq; #[test] @@ -67,7 +68,7 @@ mod test { let sampler = SliceFactory::new(Box::new(child), 4).create(&Config::default()); - assert_eq!(1.0, sampler.sample(Vector::default())); + assert_abs_diff_eq!(1.0, sampler.sample(Vector::default())); } #[test] @@ -81,7 +82,7 @@ mod test { let sampler = SliceFactory::new(Box::new(child), 4).create(&Config::default()); - assert_eq!(0.0, sampler.sample(Vector::default())); + assert_abs_diff_eq!(0.0, sampler.sample(Vector::default())); } #[test] diff --git a/src/transform/swap.rs b/src/transform/swap.rs index f0ee618..04b49f4 100644 --- a/src/transform/swap.rs +++ b/src/transform/swap.rs @@ -30,6 +30,7 @@ impl Pattern for Swap { mod test { use super::*; use crate::MockPatternFactory; + use approx::*; use mockall::predicate::eq; #[test] @@ -62,7 +63,7 @@ mod test { let sampler = SwapFactory::new(Box::new(child)).create(&Config::default()); - assert_eq!(0.4, sampler.sample(Vector::default())); + assert_abs_diff_eq!(0.4, sampler.sample(Vector::default())); } #[test]