refac: переосмысление

This commit is contained in:
2024-02-07 03:21:23 +03:00
commit 25302bd1e6
44 changed files with 2275 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
package mc.nbt.io;
import mc.nbt.CompoundTag;
import mc.nbt.StringTag;
import mc.nbt.TagType;
import mc.nbt.TagValue;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.Objects;
import static org.junit.jupiter.api.Assertions.*;
class NbtInputStreamTest {
@Test
void testSimple() throws IOException {
try (var stream = Objects.requireNonNull(NbtInputStreamTest.class.getResourceAsStream("/hello_world.nbt"));
NbtInputStream nbtInputStream = new NbtInputStream(stream)) {
TagValue tag = nbtInputStream.readTag();
assertNotNull(tag);
assertEquals(TagType.COMPOUND, tag.getType());
CompoundTag compoundTag = tag.asCompound();
assertEquals("hello world", compoundTag.getName());
assertEquals(1, compoundTag.size());
assertTrue(compoundTag.containsKey("name"));
tag = compoundTag.get("name");
assertEquals(TagType.STRING, tag.getType());
StringTag stringTag = tag.asString();
assertEquals("name", stringTag.getName());
assertEquals("Bananrama", stringTag.getValue());
}
}
}