diff --git a/tests/value.rs b/tests/value.rs index 6714069a..404a7ea7 100644 --- a/tests/value.rs +++ b/tests/value.rs @@ -80,4 +80,21 @@ mod std_tests { assert_eq!(value, data_de_value); } + + #[derive(Debug, Deserialize, Serialize)] + struct SmallStruct { + spam: u32, + eggs: u32, + } + + #[test] + fn small_struct() { + // Test whether the packed format works. + // Field names should not be serialized, + // instead field indizes are serialized. + let value = SmallStruct { spam: 17, eggs: 42 }; + let data = serde_cbor::ser::to_vec_packed(&value).unwrap(); + let reference = b"\xa2\x00\x11\x01\x18\x2a"; + assert_eq!(data, reference); + } }