diff options
Diffstat (limited to 'azalea-protocol/src/packets/game/c_container_set_content.rs')
| -rwxr-xr-x | azalea-protocol/src/packets/game/c_container_set_content.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/azalea-protocol/src/packets/game/c_container_set_content.rs b/azalea-protocol/src/packets/game/c_container_set_content.rs index 852ce60f..d4bd9184 100755 --- a/azalea-protocol/src/packets/game/c_container_set_content.rs +++ b/azalea-protocol/src/packets/game/c_container_set_content.rs @@ -10,3 +10,29 @@ pub struct ClientboundContainerSetContent { pub items: Vec<ItemStack>, pub carried_item: ItemStack, } + +#[cfg(test)] +mod tests { + use std::io::Cursor; + + use super::ClientboundContainerSetContent; + use crate::packets::ProtocolPacket; + + #[test] + fn test_read_write_container_set_content() { + let contents = [ + 1, 2, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 196, 6, 0, 0, 0, + ]; + let mut buf = Cursor::new(contents.as_slice()); + let packet = ClientboundContainerSetContent::read(&mut buf).unwrap(); + println!("{:?}", packet); + + assert_eq!(buf.position(), contents.len() as u64); + + let mut buf = Vec::new(); + packet.write(&mut buf).unwrap(); + assert_eq!(buf, contents); + } +} |
