Browse Source

psopacket enum derive test

cleanuppery
jake 1 year ago
parent
commit
d975874a64
  1. 29
      src/lib.rs

29
src/lib.rs

@ -624,4 +624,33 @@ mod test {
d: vec![9,9,9,8],
});
}
#[test]
fn test_derive_pso_packet_data_on_simple_enum() {
#[repr(u8)]
#[derive(PSOPacketData, Eq, PartialEq)]
enum Q {
A,
B,
C,
}
let q = Q::A.as_bytes();
assert!(q == vec![0]);
let q = Q::B.as_bytes();
assert!(q == vec![1]);
let q = Q::C.as_bytes();
assert!(q == vec![2]);
let q = Q::from_bytes(&mut std::io::Cursor::new(vec![0])).unwrap();
assert!(q == Q::A);
let q = Q::from_bytes(&mut std::io::Cursor::new(vec![1])).unwrap();
assert!(q == Q::B);
let q = Q::from_bytes(&mut std::io::Cursor::new(vec![2])).unwrap();
assert!(q == Q::C);
}
}
Loading…
Cancel
Save