diff options
| author | mat <github@matdoes.dev> | 2022-06-23 15:12:17 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-06-23 15:12:17 -0500 |
| commit | 5ca49e680ed8519456dc9a9af84321d4b69dcbb3 (patch) | |
| tree | 0f727c3e862f60eb227db69c87946a0f629a397d /azalea-nbt/src/lib.rs | |
| parent | c7b0c51274b5d8548c8a2f829b75dfbec4038be2 (diff) | |
| download | azalea-drasl-5ca49e680ed8519456dc9a9af84321d4b69dcbb3.tar.xz | |
azalea-buf
Diffstat (limited to 'azalea-nbt/src/lib.rs')
| -rwxr-xr-x | azalea-nbt/src/lib.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/azalea-nbt/src/lib.rs b/azalea-nbt/src/lib.rs index d14fd929..8cca1f2b 100755 --- a/azalea-nbt/src/lib.rs +++ b/azalea-nbt/src/lib.rs @@ -5,3 +5,36 @@ mod tag; pub use error::Error; pub use tag::Tag; + +#[cfg(test)] +mod tests { + use super::*; + use std::{collections::HashMap, io::Cursor}; + + #[test] + fn mcbuf_nbt() { + let mut buf = Vec::new(); + buf.write_nbt(&Tag::Compound(HashMap::from_iter(vec![( + "hello world".to_string(), + Tag::Compound(HashMap::from_iter(vec![( + "name".to_string(), + Tag::String("Bananrama".to_string()), + )])), + )]))) + .unwrap(); + + let mut buf = Cursor::new(buf); + + let result = buf.read_nbt().unwrap(); + assert_eq!( + result, + Tag::Compound(HashMap::from_iter(vec![( + "hello world".to_string(), + Tag::Compound(HashMap::from_iter(vec![( + "name".to_string(), + Tag::String("Bananrama".to_string()), + )])), + )])) + ); + } +} |
