Browse Source

test for pso_packet manual_flag

pull/3/head
jake 5 years ago
parent
commit
1c5db7d050
  1. 27
      src/lib.rs

27
src/lib.rs

@ -435,4 +435,31 @@ mod test {
let test5 = Test::from_bytes(&mut cur); let test5 = Test::from_bytes(&mut cur);
assert!(test5 == Err(PacketParseError::NotEnoughBytes)); 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,
});
}
} }
Loading…
Cancel
Save