From 438d0ec6ec4ae97d13d950ea317ce324dd205e10 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 26 Sep 2024 18:08:33 -0700 Subject: [PATCH] test zeroes --- fixed_wide/src/tests.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/fixed_wide/src/tests.rs b/fixed_wide/src/tests.rs index 8e4dd4e..22002a2 100644 --- a/fixed_wide/src/tests.rs +++ b/fixed_wide/src/tests.rs @@ -139,3 +139,27 @@ fn test_sqrt_max(){ let a=I32F32::MAX; test_exact(a); } +#[test] +#[cfg(all(feature="zeroes",not(feature="deferred-division")))] +fn test_zeroes_normal(){ + // (x-1)*(x+1) + // x^2-1 + let zeroes=I32F32::zeroes2(I32F32::NEG_ONE,I32F32::ZERO,I32F32::ONE); + assert_eq!(zeroes,arrayvec::ArrayVec::from_iter([I32F32::NEG_ONE,I32F32::ONE])); + let zeroes=I32F32::zeroes2(I32F32::NEG_ONE*3,I32F32::ONE*2,I32F32::ONE); + assert_eq!(zeroes,arrayvec::ArrayVec::from_iter([I32F32::NEG_ONE*3,I32F32::ONE])); +} +#[test] +#[cfg(all(feature="zeroes",feature="deferred-division"))] +fn test_zeroes_deferred_division(){ + // (x-1)*(x+1) + // x^2-1 + let zeroes=I32F32::zeroes2(I32F32::NEG_ONE,I32F32::ZERO,I32F32::ONE); + assert_eq!( + zeroes, + arrayvec::ArrayVec::from_iter([ + ratio_ops::ratio::Ratio::new(I32F32::ONE*2,I32F32::NEG_ONE*2), + ratio_ops::ratio::Ratio::new(I32F32::ONE*2,I32F32::ONE*2), + ]) + ); +}