Fix unit tests

This commit is contained in:
zontreck 2025-03-09 20:09:00 -07:00
parent 4957fe633e
commit aa813f4cdd
4 changed files with 19 additions and 15 deletions

View file

@ -17,7 +17,8 @@ void main() {
test('read non-compressed helloworld NBT', () async {
print("READING : ${Directory.current.path}/test/hello_world.nbt");
CompoundTag tag =
await NbtIo.read("${Directory.current.path}/test/hello_world.nbt");
await NbtIo.read("${Directory.current.path}/test/hello_world.nbt")
as CompoundTag;
expect(tag.getKey(), "hello world");
expect(tag.containsKey("name"), true);
@ -37,7 +38,8 @@ void main() {
test('read non-compressed self-made helloworld NBT', () async {
print("READING : ${Directory.current.path}/build/hello_world.nbt");
CompoundTag tag =
await NbtIo.read("${Directory.current.path}/build/hello_world.nbt");
await NbtIo.read("${Directory.current.path}/build/hello_world.nbt")
as CompoundTag;
expect(tag.getKey(), "hello world");
expect(tag.containsKey("name"), true);
@ -46,7 +48,7 @@ void main() {
test('read compressed bigtest.nbt', () async {
var path = "${Directory.current.path}/test/bigtest.nbt";
CompoundTag tag = await NbtIo.read(path);
CompoundTag tag = await NbtIo.read(path) as CompoundTag;
expect(tag.getKey(), "Level");
expect(tag.get("shortTest")!.asShort(), 32767);
expect(tag.get("doubleTest")!.asDouble(), 0.4931287132182315);
@ -64,7 +66,8 @@ void main() {
test("Read HelloWorld, Output to SNBT", () async {
CompoundTag ct =
await NbtIo.read("${Directory.current.path}/test/hello_world.nbt");
await NbtIo.read("${Directory.current.path}/test/hello_world.nbt")
as CompoundTag;
StringBuilder sb = StringBuilder();
Tag.writeStringifiedNamedTag(ct, sb, 0);
print(sb.toString());
@ -72,7 +75,8 @@ void main() {
test("Read BigTest, Output to SNBT", () async {
CompoundTag ct =
await NbtIo.read("${Directory.current.path}/test/bigtest.nbt");
await NbtIo.read("${Directory.current.path}/test/bigtest.nbt")
as CompoundTag;
StringBuilder sb = StringBuilder();
Tag.writeStringifiedNamedTag(ct, sb, 0);
print(sb.toString());
@ -80,7 +84,8 @@ void main() {
test("Write BigTest to SNBT file", () async {
CompoundTag ct =
await NbtIo.read("${Directory.current.path}/test/bigtest.nbt");
await NbtIo.read("${Directory.current.path}/test/bigtest.nbt")
as CompoundTag;
String output = "${Directory.current.path}/build/bigtest.snbt";
File file = File(output);
SnbtIo.writeToFile(output, ct);
@ -114,7 +119,7 @@ void main() {
String OutputSNBT = "${Directory.current.path}/build/el-test.snbt";
String OutputNBT = "${Directory.current.path}/build/el-test.nbt";
CompoundTag tag = await NbtIo.read(OriginFile);
CompoundTag tag = await NbtIo.read(OriginFile) as CompoundTag;
await SnbtIo.writeToFile(OutputSNBT, tag);
expect(File(OutputSNBT).existsSync(), true);
@ -125,7 +130,8 @@ void main() {
}, timeout: Timeout(Duration(hours: 90)));
test("Read Sophisticated Backpack data", () async {
CompoundTag ct = await NbtIo.read("test/sophisticatedbackpacks.dat");
CompoundTag ct =
await NbtIo.read("test/sophisticatedbackpacks.dat") as CompoundTag;
// Convert to SNBT
String snbtData = SnbtIo.writeToString(ct);
// Convert snbt back to NBT