From 9a66cb97a659ed1f0e52ba3d9438de1d9b78d64a Mon Sep 17 00:00:00 2001 From: EightFactorial Date: Wed, 25 Jan 2023 09:51:27 -0800 Subject: Fix test and packets (#60) * Fix test and packets * Fix bug, fix a couple more packets * add tests and fix stuff * fix warnings Co-authored-by: Ubuntu --- azalea-buf/src/lib.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'azalea-buf/src/lib.rs') diff --git a/azalea-buf/src/lib.rs b/azalea-buf/src/lib.rs index 568b542e..73d76949 100755 --- a/azalea-buf/src/lib.rs +++ b/azalea-buf/src/lib.rs @@ -142,6 +142,21 @@ mod tests { assert_eq!(i32::var_read_from(&mut Cursor::new(&buf)).unwrap(), 7178); } + #[test] + fn test_write_varlong() { + let mut buf = Vec::new(); + 0u64.var_write_into(&mut buf).unwrap(); + assert_eq!(buf, vec![0]); + + let mut buf = Vec::new(); + 1u64.var_write_into(&mut buf).unwrap(); + assert_eq!(buf, vec![1]); + + let mut buf = Vec::new(); + 9223372036854775807u64.var_write_into(&mut buf).unwrap(); + assert_eq!(buf, vec![255, 255, 255, 255, 255, 255, 255, 255, 127]); + } + #[test] fn test_list() { let original_vec = vec!["a".to_string(), "bc".to_string(), "def".to_string()]; -- cgit v1.2.3