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

@ -9,14 +9,14 @@ environment:
# Add regular dependencies here.
dependencies:
crypto: ^3.0.3
dio: ^5.5.0+1
dio: ^5.8.0+1
encrypt: ^5.0.3
intl: ^0.20.1
intl: ^0.20.2
# path: ^1.8.0
dev_dependencies:
lints: ^3.0.0
test: ^1.24.0
lints: ^5.1.1
test: ^1.25.15
# following page: https://dart.dev/tools/pub/pubspec

View file

@ -2,8 +2,6 @@ import 'dart:convert';
import 'dart:io';
import 'package:libac_dart/encryption/aes.dart';
import 'package:libac_dart/encryption/xtea.dart';
import 'package:libac_dart/utils/Hashing.dart';
import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';

View file

@ -11,7 +11,7 @@ Future<void> main() async {
});
test("Test directory size checking", () async {
expect(await getDirectorySize("test"), 121634);
expect(await getDirectorySize("test"), 121680);
});
test("Test file info methods", () async {

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