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), + ]) + ); +}