aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/read.rs
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-09-09 23:46:46 -0500
committermat <github@matdoes.dev>2022-09-09 23:46:46 -0500
commitdee991a7fc54b3e7e75f051b83901c282f18ae37 (patch)
tree4cba3c7708f5b3b122776b19687d148974aa0157 /azalea-protocol/src/read.rs
parent3389f19e601cf52d7920796effaca55f2f0fcf4a (diff)
downloadazalea-drasl-dee991a7fc54b3e7e75f051b83901c282f18ae37.tar.xz
fix errors in enums inconsistent w/ vanilla
Diffstat (limited to 'azalea-protocol/src/read.rs')
-rwxr-xr-xazalea-protocol/src/read.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/azalea-protocol/src/read.rs b/azalea-protocol/src/read.rs
index 2c749a61..3ff24f72 100755
--- a/azalea-protocol/src/read.rs
+++ b/azalea-protocol/src/read.rs
@@ -217,3 +217,39 @@ where
Ok(packet)
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::packets::game::{clientbound_player_chat_packet::ChatType, ClientboundGamePacket};
+ use std::io::Cursor;
+
+ #[tokio::test]
+ async fn test_read_packet() {
+ let mut buf = Cursor::new(vec![
+ 51, 0, 12, 177, 250, 155, 132, 106, 60, 218, 161, 217, 90, 157, 105, 57, 206, 20, 0, 5,
+ 104, 101, 108, 108, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 116,
+ 123, 34, 101, 120, 116, 114, 97, 34, 58, 91, 123, 34, 99, 111, 108, 111, 114, 34, 58,
+ 34, 103, 114, 97, 121, 34, 44, 34, 116, 101, 120, 116, 34, 58, 34, 91, 77, 69, 77, 66,
+ 69, 82, 93, 32, 112, 108, 97, 121, 101, 114, 49, 34, 125, 44, 123, 34, 116, 101, 120,
+ 116, 34, 58, 34, 32, 34, 125, 44, 123, 34, 99, 111, 108, 111, 114, 34, 58, 34, 103,
+ 114, 97, 121, 34, 44, 34, 116, 101, 120, 116, 34, 58, 34, 92, 117, 48, 48, 51, 101, 32,
+ 104, 101, 108, 108, 111, 34, 125, 93, 44, 34, 116, 101, 120, 116, 34, 58, 34, 34, 125,
+ 0, 7, 64, 123, 34, 101, 120, 116, 114, 97, 34, 58, 91, 123, 34, 99, 111, 108, 111, 114,
+ 34, 58, 34, 103, 114, 97, 121, 34, 44, 34, 116, 101, 120, 116, 34, 58, 34, 91, 77, 69,
+ 77, 66, 69, 82, 93, 32, 112, 108, 97, 121, 101, 114, 49, 34, 125, 93, 44, 34, 116, 101,
+ 120, 116, 34, 58, 34, 34, 125, 0,
+ ]);
+ let packet = packet_decoder::<ClientboundGamePacket>(&mut buf).unwrap();
+ match &packet {
+ ClientboundGamePacket::PlayerChat(m) => {
+ assert_eq!(
+ m.chat_type.chat_type,
+ ChatType::Chat,
+ "Enums should default if they're invalid"
+ );
+ }
+ _ => panic!("Wrong packet type"),
+ }
+ }
+}