We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 96851de commit 05a48ffCopy full SHA for 05a48ff
src/lib.rs
@@ -465,4 +465,14 @@ mod tests {
465
fn test_to_string() {
466
assert_to_string("609.0 PB", ByteSize::pb(609), true);
467
}
468
+
469
+ #[test]
470
+ #[cfg(feature = "serde")]
471
+ fn test_serde_json() {
472
+ let json = serde_json::to_string(&ByteSize::mib(1)).unwrap();
473
+ assert_eq!(json, "\"1.0 MiB\"");
474
475
+ let deserialized: ByteSize = serde_json::from_str(&json).unwrap();
476
+ assert_eq!(deserialized.0, 1048576);
477
+ }
478
0 commit comments