pub mod commands; pub mod packet; pub mod prelude; #[cfg(test)] mod tests { use crate::packet; use crate::packet::data_types::DataType; use crate::packet::identifier::Identifier; use crate::packet::packet_data::PacketData; #[test] pub fn data_types() { // test Vec -> Vec assert_eq!( DataType::get_data(vec![0x00, 0x10, 0x00]), vec![ DataType::Nothing, DataType::Switch(false), ]); // test DataType -> Vec assert_eq!( Into::>::into(DataType::Switch(true)), vec![0x10, 0x01] ) } #[test] pub fn packets() { assert_eq!(packet::Packet { src: Identifier::from(0xAABBCCDD), dest: Identifier::from(0xAABBCCDD), packet_id: Identifier::from(0x00000001), reply_to: Identifier::from(0x00000000), command: 0x00, data: PacketData::default(), }.build_base_packet(), vec![ 0x01, // version 0xAA, 0xBB, 0xCC, 0xDD, // dest 0xAA, 0xBB, 0xCC, 0xDD, // src 0x00, 0x00, 0x00, 0x01, // packet_id 0x00, 0x00, 0x00, 0x00, // reply_to 0x00, // command 0x00, 0x00, // data length // no packet data ] ); } }