From 1c5db7d05028ebf37ba5bbaf588f43b419a3afdb Mon Sep 17 00:00:00 2001 From: jake Date: Sat, 9 Nov 2019 22:56:39 -0800 Subject: [PATCH] test for pso_packet manual_flag --- src/lib.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 91a8d68..280e601 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -435,4 +435,31 @@ mod test { let test5 = Test::from_bytes(&mut cur); assert!(test5 == Err(PacketParseError::NotEnoughBytes)); } + + #[test] + fn test_pso_packet_manual_flag() { + #[pso_packet(0x23, manual_flag)] + struct Test { + flag: u32, + a: u32, + b: u32, + } + + let test = Test { + flag: 99, + a: 123, + b: 456, + }; + + let mut bytes = test.as_bytes(); + assert!(bytes == vec![16, 0, 35, 0, 99, 0, 0, 0, 123, 0, 0, 0, 200, 1, 0, 0]); + + bytes[6] = 2; + let test2 = Test::from_bytes(&bytes).unwrap(); + assert!(test2 == Test { + flag: 131171, + a: 123, + b: 456, + }); + } }