From 56e630204ad0409de539a2a9bf5e3907c914a7a8 Mon Sep 17 00:00:00 2001 From: Rico Riedel Date: Sun, 31 Jul 2022 16:49:29 +0200 Subject: [PATCH] Simplify tests --- src/convert/color.rs | 10 +++++----- src/convert/level.rs | 24 ++++++------------------ 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/convert/color.rs b/src/convert/color.rs index 94c5cbf..09a1d66 100644 --- a/src/convert/color.rs +++ b/src/convert/color.rs @@ -33,34 +33,34 @@ mod test { fn convert_negative_index() { let converter = ColorConverterImpl::new(vec![Red, Green, Blue]); - assert!(matches!(converter.convert(-0.2), Blue)); + assert_eq!(Blue, converter.convert(-0.2)); } #[test] fn convert_index_zero() { let converter = ColorConverterImpl::new(vec![Red, Green, Blue]); - assert!(matches!(converter.convert(0.0), Red)); + assert_eq!(Red, converter.convert(0.0)); } #[test] fn convert() { let converter = ColorConverterImpl::new(vec![Red, Green, Blue]); - assert!(matches!(converter.convert(0.5), Green)); + assert_eq!(Green, converter.convert(0.5)); } #[test] fn convert_index_one() { let converter = ColorConverterImpl::new(vec![Red, Green, Blue]); - assert!(matches!(converter.convert(1.0), Red)); + assert_eq!(Red, converter.convert(1.0)); } #[test] fn convert_index_above_one() { let converter = ColorConverterImpl::new(vec![Red, Green, Blue]); - assert!(matches!(converter.convert(1.5), Green)); + assert_eq!(Green, converter.convert(1.5)); } } diff --git a/src/convert/level.rs b/src/convert/level.rs index 72f5bca..b968468 100644 --- a/src/convert/level.rs +++ b/src/convert/level.rs @@ -33,35 +33,23 @@ mod test { fn convert_keep() { let converter = LevelConverterImpl::default(); - assert!(matches!(converter.convert(-0.1), Level::Keep)); + assert_eq!(Level::Keep, converter.convert(-0.1)); } #[test] fn convert_draw() { let converter = LevelConverterImpl::default(); - if let Level::Draw(level) = converter.convert(0.0) { - assert_eq!(0.0, level); - } else { - panic!(); - } - if let Level::Draw(level) = converter.convert(0.5) { - assert_eq!(0.5, level); - } else { - panic!(); - } - if let Level::Draw(level) = converter.convert(0.9) { - assert_eq!(0.9, level); - } else { - panic!(); - } + assert_eq!(Level::Draw(0.0), converter.convert(0.0)); + assert_eq!(Level::Draw(0.5), converter.convert(0.5)); + assert_eq!(Level::Draw(0.9), converter.convert(0.9)); } #[test] fn convert_clear() { let converter = LevelConverterImpl::default(); - assert!(matches!(converter.convert(1.0), Level::Clear)); - assert!(matches!(converter.convert(1.5), Level::Clear)); + assert_eq!(Level::Clear, converter.convert(1.0)); + assert_eq!(Level::Clear, converter.convert(1.5)); } }