Fix #6, testsuite implemented.
This commit is contained in:
parent
270302bb4b
commit
b359400c83
16 changed files with 268 additions and 3 deletions
|
@ -3,6 +3,7 @@ import 'dart:io';
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:libac_flutter/nbt/NbtIo.dart';
|
||||
import 'package:libac_flutter/nbt/impl/CompoundTag.dart';
|
||||
import 'package:libac_flutter/nbt/impl/StringTag.dart';
|
||||
|
||||
void main() {
|
||||
test('read non-compressed helloworld NBT', () async {
|
||||
|
@ -14,4 +15,33 @@ void main() {
|
|||
|
||||
expect(tag.get("name")!.asString(), "Bananrama");
|
||||
});
|
||||
|
||||
test("write a hello-world NBT", () async {
|
||||
CompoundTag tag = CompoundTag();
|
||||
tag.setKey("hello world");
|
||||
tag.put("name", StringTag.valueOf("Bananrama"));
|
||||
|
||||
var path = "${Directory.current.path}/build/hello_world.nbt";
|
||||
await NbtIo.write(path, tag);
|
||||
expect(File(path).existsSync(), true);
|
||||
});
|
||||
|
||||
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");
|
||||
expect(tag.getKey(), "hello world");
|
||||
expect(tag.contains("name"), true);
|
||||
|
||||
expect(tag.get("name")!.asString(), "Bananrama");
|
||||
});
|
||||
|
||||
test('read compressed bigtest.nbt', () async {
|
||||
var path = "${Directory.current.path}/test/bigtest.nbt";
|
||||
CompoundTag tag = await NbtIo.read(path);
|
||||
expect(tag.getKey(), "Level");
|
||||
expect(tag.get("shortTest")!.asShort(), 32767);
|
||||
expect(tag.get("doubleTest")!.asDouble(), 0.4931287132182315);
|
||||
expect(tag.get("floatTest")!.asFloat(), 0.49823147);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue