refac: переосмысление
This commit is contained in:
38
src/test/java/mc/nbt/io/NbtInputStreamTest.java
Normal file
38
src/test/java/mc/nbt/io/NbtInputStreamTest.java
Normal 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user