From 4e091d5d6d9fd94881b64214ac5696b22028721d Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 25 Oct 2023 10:41:10 -0700 Subject: [PATCH] Add test of negative NaN and negative infinity --- tests/test.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/test.rs b/tests/test.rs index e548b7dae..a38435069 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -160,17 +160,29 @@ fn test_write_f64() { #[test] fn test_encode_nonfinite_float_yields_null() { - let v = to_value(::std::f64::NAN).unwrap(); + let v = to_value(::std::f64::NAN.copysign(1.0)).unwrap(); + assert!(v.is_null()); + + let v = to_value(::std::f64::NAN.copysign(-1.0)).unwrap(); assert!(v.is_null()); let v = to_value(::std::f64::INFINITY).unwrap(); assert!(v.is_null()); - let v = to_value(::std::f32::NAN).unwrap(); + let v = to_value(-::std::f64::INFINITY).unwrap(); + assert!(v.is_null()); + + let v = to_value(::std::f32::NAN.copysign(1.0)).unwrap(); + assert!(v.is_null()); + + let v = to_value(::std::f32::NAN.copysign(-1.0)).unwrap(); assert!(v.is_null()); let v = to_value(::std::f32::INFINITY).unwrap(); assert!(v.is_null()); + + let v = to_value(-::std::f32::INFINITY).unwrap(); + assert!(v.is_null()); } #[test]