diff --git a/src/tests/system.rs b/src/tests/system.rs index 18f0ee9e..c56e27bc 100644 --- a/src/tests/system.rs +++ b/src/tests/system.rs @@ -587,33 +587,44 @@ mod complex { #[test] fn fp_categories() { - assert!(!Length::new::( - V::new(VV::infinity(), VV::infinity()) - ).is_finite()); - assert!(!Length::new::( - V::new(VV::neg_infinity(), VV::neg_infinity()) - ).is_finite()); - assert!(Length::new::( - V::new(VV::infinity(), VV::infinity()) - ).is_infinite()); - assert!(Length::new::( - V::new(VV::neg_infinity(), VV::neg_infinity()) - ).is_infinite()); - assert!(Length::new::( - V::new(VV::min_positive_value(), VV::min_positive_value()) - ).is_normal()); - assert!(Length::new::( - V::new(VV::max_value(), VV::max_value()) - ).is_normal()); - assert!(!Length::new::( - V::new(VV::zero(), VV::zero()) - ).is_normal()); - assert!(!Length::new::( - V::new(VV::nan(), VV::nan()) - ).is_normal()); - assert!(!Length::new::( - V::new(VV::infinity(), VV::infinity()) - ).is_normal()); + let float_categories = vec![ + VV::neg_infinity(), + VV::min_value(), + VV::zero(), + VV::max_value(), + VV::infinity(), + VV::nan(), + ]; + for re in float_categories.clone() { + for im in float_categories { + let complex = V::new(re, im); + + // Infinities + if re.is_infinite() || im.is_infinite() { + assert!(!Length::new::(complex).is_finite()); + assert!(Length::new::(complex).is_infinite()); + assert!(!Length::new::(complex).is_normal()); + assert!(!Length::new::(complex).is_nan()); + } + + // NaNs + if re.is_nan() || im.is_nan() { + assert!(!Length::new::(complex).is_finite()); + assert!(!Length::new::(complex).is_infinite()); + assert!(!Length::new::(complex).is_normal()); + assert!(Length::new::(complex).is_nan()); + } + + // Finite and normal numbers + if (!re.is_infinite() && !re.is_nan()) + && (!im.is_infinite() && !im.is_nan()) { + assert!(Length::new::(complex).is_finite()); + assert!(!Length::new::(complex).is_infinite()); + assert!(Length::new::(complex).is_normal()); + assert!(!Length::new::(complex).is_nan()); + } + } + } } quickcheck! {