aboutsummaryrefslogtreecommitdiff
path: root/azalea-nbt/src/lib.rs
blob: e20049e011c35b6988f15bb2e63730589b20bc79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
mod decode;
mod encode;
mod error;
mod tag;

pub use error::Error;
pub use tag::Tag;

#[cfg(test)]
mod tests {
    use std::io::Cursor;

    use super::*;
    use ahash::AHashMap;
    use azalea_buf::{McBufReadable, McBufWritable};

    #[test]
    fn mcbuf_nbt() {
        let mut buf = Vec::new();
        let tag = Tag::Compound(AHashMap::from_iter(vec![(
            "hello world".to_string(),
            Tag::Compound(AHashMap::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_from(&mut buf).unwrap();
        assert_eq!(
            result,
            Tag::Compound(AHashMap::from_iter(vec![(
                "hello world".to_string(),
                Tag::Compound(AHashMap::from_iter(vec![(
                    "name".to_string(),
                    Tag::String("Bananrama".to_string()),
                )])),
            )]))
        );
    }
}