diff --git a/src/lib.rs b/src/lib.rs index ab4d5d3..b0388d2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -346,6 +346,36 @@ mod test { }); } + #[test] + fn test_derive_pso_data_packet_array() { + #[derive(PSOPacketData, Debug, PartialEq)] + struct Test { + a: u8, + b: u32, + c: u16, + d: [u8; 5], + } + + let test = Test { + a: 12, + b: 34567, + c: 890, + d: [1,2,3,4,5], + }; + + let mut bytes = test.as_bytes(); + assert!(bytes == vec![12, 7, 135, 0, 0, 122, 3, 1, 2, 3, 4, 5]); + bytes[10] = 17; + let mut cur = std::io::Cursor::new(bytes.clone()); + let test2 = Test::from_bytes(&mut cur).unwrap(); + assert!(test2 == Test { + a: 12, + b: 34567, + c: 890, + d: [1,2,3,17,5] + }); + } + #[test] fn test_derive_pso_data_packet_not_enough_data() { #[derive(PSOPacketData, Debug, PartialEq)]