diff --git a/src/tests/system.rs b/src/tests/system.rs index f5c99d99..2533265d 100644 --- a/src/tests/system.rs +++ b/src/tests/system.rs @@ -373,10 +373,16 @@ mod float { } #[allow(trivial_casts)] - fn clamp(x: A, min: A, max: A) -> bool { - Test::eq( - &Length::new::(x.clamp(*min, *max)), - &Length::new::(*x).clamp(Length::new::(*min), Length::new::(*max))) + fn clamp(x: A, min: A, max: A) -> TestResult { + if *min > *max || min.is_nan() || max.is_nan() { + return TestResult::discard(); + } + TestResult::from_bool( + Test::eq( + &Length::new::(x.clamp(*min, *max)), + &Length::new::(*x).clamp(Length::new::(*min), Length::new::(*max)) + ) + ) } } } @@ -580,13 +586,19 @@ mod fixed { } #[allow(trivial_casts)] - fn clamp(x: A, min: A, max: A) -> bool { - Test::eq(&Length::new::((*x).clone().clamp((*min).clone(), (*max).clone())), - &Ord::clamp( - Length::new::((*x).clone()), - Length::new::((*min).clone()), - Length::new::((*max).clone()), - )) + fn clamp(x: A, min: A, max: A) -> TestResult { + if *min > *max { + return TestResult::discard() + } + TestResult::from_bool( + Test::eq(&Length::new::((*x).clone().clamp((*min).clone(), (*max).clone())), + &Ord::clamp( + Length::new::((*x).clone()), + Length::new::((*min).clone()), + Length::new::((*max).clone()), + ) + ) + ) } } }