aboutsummaryrefslogtreecommitdiff
path: root/azalea-nbt/src/lib.rs
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2022-06-25 05:09:26 +0000
committerGitHub <noreply@github.com>2022-06-25 05:09:26 +0000
commit7d3e57763e32ac9cf94180b1c714704cfbc3034d (patch)
tree2dcfe72bf09a42f6614f9dc988dc0254162ea0bf /azalea-nbt/src/lib.rs
parent69c47eda4c496b13dadd80976bffd2fab7ea5894 (diff)
parentca7067e173129f3044ebc8c77634f06da29a086e (diff)
downloadazalea-drasl-7d3e57763e32ac9cf94180b1c714704cfbc3034d.tar.xz
Merge pull request #10 from mat-1/azalea-entity
azalea-entity
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()),
+ )])),
+ )]))
+ );
+ }
+}