1
0
Fork 0
firefox/third_party/rust/serde_json/tests/regression/issue1004.rs
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

12 lines
362 B
Rust

#![cfg(feature = "arbitrary_precision")]
#[test]
fn test() {
let float = 5.55f32;
let value = serde_json::to_value(float).unwrap();
let json = serde_json::to_string(&value).unwrap();
// If the f32 were cast to f64 by Value before serialization, then this
// would incorrectly serialize as 5.550000190734863.
assert_eq!(json, "5.55");
}