Debian Codegraph @

.cargo/vendor/serde_json/tests/regression/issue1004.rs

raw
1 #![cfg(feature = "arbitrary_precision")]
2
3 #[test]
4 fn test() {
5 let float = 5.55f32;
6 let value = serde_json::to_value(float).unwrap();
7 let json = serde_json::to_string(&value).unwrap();
8
9 // If the f32 were cast to f64 by Value before serialization, then this
10 // would incorrectly serialize as 5.550000190734863.
11 assert_eq!(json, "5.55");
12 }