aboutsummaryrefslogtreecommitdiff
path: root/azalea-nbt/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-nbt/src/lib.rs')
-rwxr-xr-xazalea-nbt/src/lib.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/azalea-nbt/src/lib.rs b/azalea-nbt/src/lib.rs
index d14fd929..cb2eb28e 100755
--- a/azalea-nbt/src/lib.rs
+++ b/azalea-nbt/src/lib.rs
@@ -5,3 +5,37 @@ mod tag;
pub use error::Error;
pub use tag::Tag;
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use azalea_buf::{McBufReadable, McBufWritable};
+ use std::{collections::HashMap, io::Cursor};
+
+ #[test]
+ fn mcbuf_nbt() {
+ let mut buf = Vec::new();
+ let tag = Tag::Compound(HashMap::from_iter(vec![(
+ "hello world".to_string(),
+ Tag::Compound(HashMap::from_iter(vec![(
+ "name".to_string(),
+ Tag::String("Bananrama".to_string()),
+ )])),
+ )]));
+ tag.write_into(&mut buf).unwrap();
+
+ let mut buf = Cursor::new(buf);
+
+ let result = Tag::read_into(&mut buf).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()),
+ )])),
+ )]))
+ );
+ }
+}