diff --git a/tests/test.rs b/tests/test.rs index 51227c5..c4a1728 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -906,34 +906,32 @@ fn test_parse_f64() { ]); } -// test roundtrip with some values that failed with the old version of the f64 deserializer +// Test roundtrip with some values that were not perfectly roundtripped by the +// old f64 deserializer. #[test] fn test_roundtrip_f64() { - let roundtrip = |input: &f64| { - let json = serde_json::to_string(input).unwrap(); - let output: f64 = serde_json::from_str(&json).unwrap(); - assert_eq!(input, &output); - }; - - [ - // samples from quickcheck-ing `roundtrip` with `input: f64` - // comments on the right showed the value returned by the old deserializer + for &float in &[ + // Samples from quickcheck-ing roundtrip with `input: f64`. Comments + // indicate the value returned by the old deserializer. 51.24817837550540_4, // 51.2481783755054_1 -93.3113703768803_3, // -93.3113703768803_2 -36.5739948427534_36, // -36.5739948427534_4 52.31400820410624_4, // 52.31400820410624_ 97.45365320034685, // 97.4536532003468_4 - // samples from `rng.next_u64` + `f64::from_bits` + `is_finite` filter + // Samples from `rng.next_u64` + `f64::from_bits` + `is_finite` filter. 2.0030397744267762e-253, 7.101215824554616e260, 1.769268377902049e74, -1.6727517818542075e58, 3.9287532173373315e299, - // edge case from https://github.com/serde-rs/json/issues/536#issuecomment-583714900 + // Edge case from: + // https://github.com/serde-rs/json/issues/536#issuecomment-583714900 2.638344616030823e-256, - ] - .iter() - .for_each(roundtrip); + ] { + let json = serde_json::to_string(&float).unwrap(); + let output: f64 = serde_json::from_str(&json).unwrap(); + assert_eq!(float, output); + } } #[test]