diff options
| author | mat <github@matdoes.dev> | 2022-09-01 20:37:38 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-09-01 20:37:38 -0500 |
| commit | 32458d743f757da3193717fe5554f490703640c0 (patch) | |
| tree | d0e655ac09195c41f6f7d44462d28aab4d1183db /azalea-buf/src | |
| parent | 4d072d8057518fe233b8e7390f6c1f4c54b1cfc0 (diff) | |
| download | azalea-drasl-32458d743f757da3193717fe5554f490703640c0.tar.xz | |
fix bad u32::write_into and add tests
Diffstat (limited to 'azalea-buf/src')
| -rw-r--r-- | azalea-buf/src/serializable_uuid.rs | 11 | ||||
| -rw-r--r-- | azalea-buf/src/write.rs | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/azalea-buf/src/serializable_uuid.rs b/azalea-buf/src/serializable_uuid.rs index fad5edfc..be93c5fd 100644 --- a/azalea-buf/src/serializable_uuid.rs +++ b/azalea-buf/src/serializable_uuid.rs @@ -73,4 +73,15 @@ mod tests { let u = Uuid::from_int_array([0x6536bfed, 0x869548fd, 0x83a1ecd2, 0x4cf2a0fd]); assert_eq!(u.to_string(), "6536bfed-8695-48fd-83a1-ecd24cf2a0fd"); } + + #[test] + fn read_write() { + let u = Uuid::parse_str("6536bfed-8695-48fd-83a1-ecd24cf2a0fd").unwrap(); + let mut buf = Vec::new(); + u.write_into(&mut buf).unwrap(); + println!("{:?}", buf); + assert_eq!(buf.len(), 16); + let u2 = Uuid::read_from(&mut buf.as_slice()).unwrap(); + assert_eq!(u, u2); + } } diff --git a/azalea-buf/src/write.rs b/azalea-buf/src/write.rs index 8def52b3..15fa9680 100644 --- a/azalea-buf/src/write.rs +++ b/azalea-buf/src/write.rs @@ -181,7 +181,7 @@ impl McBufWritable for String { impl McBufWritable for u32 { fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { - i16::write_into(&(*self as i16), buf) + i32::write_into(&(*self as i32), buf) } } |
