From e6f97e0c24040814ca3eec82822251d049e85d1c Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 25 Oct 2023 10:27:59 -0700 Subject: [PATCH] Add test of negative NaN --- tests/d2s_test.rs | 3 ++- tests/f2s_test.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/d2s_test.rs b/tests/d2s_test.rs index 368cab6..7e8eba6 100644 --- a/tests/d2s_test.rs +++ b/tests/d2s_test.rs @@ -82,7 +82,8 @@ fn test_basic() { check!(-0.0); check!(1.0); check!(-1.0); - assert_eq!(pretty(f64::NAN), "NaN"); + assert_eq!(pretty(f64::NAN.copysign(1.0)), "NaN"); + assert_eq!(pretty(f64::NAN.copysign(-1.0)), "NaN"); assert_eq!(pretty(f64::INFINITY), "inf"); assert_eq!(pretty(f64::NEG_INFINITY), "-inf"); } diff --git a/tests/f2s_test.rs b/tests/f2s_test.rs index 927fa7e..d6249a3 100644 --- a/tests/f2s_test.rs +++ b/tests/f2s_test.rs @@ -75,7 +75,8 @@ fn test_basic() { check!(-0.0); check!(1.0); check!(-1.0); - assert_eq!(pretty(f32::NAN), "NaN"); + assert_eq!(pretty(f32::NAN.copysign(1.0)), "NaN"); + assert_eq!(pretty(f32::NAN.copysign(-1.0)), "NaN"); assert_eq!(pretty(f32::INFINITY), "inf"); assert_eq!(pretty(f32::NEG_INFINITY), "-inf"); }