diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index c1c7e3550f..23ed2664e0 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -11,6 +11,15 @@ The crate comes with additional submodules to aid with testing, to ensure you ha git clone --recurse-submodules https://github.com/jorgecarleitao/arrow2 ``` +## Checks + +PRs will run the following checks: + +```bash +cargo fmt --all -- --check +cargo clippy --all --features=full --tests -- -D warnings +``` + ## Testing The simplest way to test the crate is to run diff --git a/src/io/json/write/serialize.rs b/src/io/json/write/serialize.rs index ea868435b9..8247609406 100644 --- a/src/io/json/write/serialize.rs +++ b/src/io/json/write/serialize.rs @@ -56,7 +56,7 @@ where array.iter(), |x, buf| { if let Some(x) = x { - if T::is_nan(*x) { + if T::is_nan(*x) || T::is_infinite(*x) { buf.extend(b"null") } else { lexical_to_bytes_mut(*x, buf) diff --git a/tests/it/io/json/write.rs b/tests/it/io/json/write.rs index 895f0f5973..9c8d1313f2 100644 --- a/tests/it/io/json/write.rs +++ b/tests/it/io/json/write.rs @@ -28,18 +28,34 @@ fn int32() -> Result<()> { #[test] fn f32() -> Result<()> { - let array = Float32Array::from([Some(1.5), Some(2.5), Some(f32::NAN), None, Some(5.5)]); + let array = Float32Array::from([ + Some(1.5), + Some(2.5), + Some(f32::NAN), + Some(f32::INFINITY), + Some(f32::NEG_INFINITY), + None, + Some(5.5), + ]); - let expected = r#"[1.5,2.5,null,null,5.5]"#; + let expected = r#"[1.5,2.5,null,null,null,null,5.5]"#; test!(array, expected) } #[test] fn f64() -> Result<()> { - let array = Float64Array::from([Some(1.5), Some(2.5), Some(f64::NAN), None, Some(5.5)]); + let array = Float64Array::from([ + Some(1.5), + Some(2.5), + Some(f64::NAN), + Some(f64::INFINITY), + Some(f64::NEG_INFINITY), + None, + Some(5.5), + ]); - let expected = r#"[1.5,2.5,null,null,5.5]"#; + let expected = r#"[1.5,2.5,null,null,null,null,5.5]"#; test!(array, expected) }