Fix unit tests
This commit is contained in:
parent
4957fe633e
commit
aa813f4cdd
4 changed files with 19 additions and 15 deletions
|
@ -9,14 +9,14 @@ environment:
|
||||||
# Add regular dependencies here.
|
# Add regular dependencies here.
|
||||||
dependencies:
|
dependencies:
|
||||||
crypto: ^3.0.3
|
crypto: ^3.0.3
|
||||||
dio: ^5.5.0+1
|
dio: ^5.8.0+1
|
||||||
encrypt: ^5.0.3
|
encrypt: ^5.0.3
|
||||||
intl: ^0.20.1
|
intl: ^0.20.2
|
||||||
# path: ^1.8.0
|
# path: ^1.8.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
lints: ^3.0.0
|
lints: ^5.1.1
|
||||||
test: ^1.24.0
|
test: ^1.25.15
|
||||||
|
|
||||||
# following page: https://dart.dev/tools/pub/pubspec
|
# following page: https://dart.dev/tools/pub/pubspec
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,6 @@ import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libac_dart/encryption/aes.dart';
|
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/expect.dart';
|
||||||
import 'package:test/scaffolding.dart';
|
import 'package:test/scaffolding.dart';
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ Future<void> main() async {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Test directory size checking", () async {
|
test("Test directory size checking", () async {
|
||||||
expect(await getDirectorySize("test"), 121634);
|
expect(await getDirectorySize("test"), 121680);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Test file info methods", () async {
|
test("Test file info methods", () async {
|
||||||
|
|
|
@ -17,7 +17,8 @@ void main() {
|
||||||
test('read non-compressed helloworld NBT', () async {
|
test('read non-compressed helloworld NBT', () async {
|
||||||
print("READING : ${Directory.current.path}/test/hello_world.nbt");
|
print("READING : ${Directory.current.path}/test/hello_world.nbt");
|
||||||
CompoundTag tag =
|
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.getKey(), "hello world");
|
||||||
expect(tag.containsKey("name"), true);
|
expect(tag.containsKey("name"), true);
|
||||||
|
|
||||||
|
@ -37,7 +38,8 @@ void main() {
|
||||||
test('read non-compressed self-made helloworld NBT', () async {
|
test('read non-compressed self-made helloworld NBT', () async {
|
||||||
print("READING : ${Directory.current.path}/build/hello_world.nbt");
|
print("READING : ${Directory.current.path}/build/hello_world.nbt");
|
||||||
CompoundTag tag =
|
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.getKey(), "hello world");
|
||||||
expect(tag.containsKey("name"), true);
|
expect(tag.containsKey("name"), true);
|
||||||
|
|
||||||
|
@ -46,7 +48,7 @@ void main() {
|
||||||
|
|
||||||
test('read compressed bigtest.nbt', () async {
|
test('read compressed bigtest.nbt', () async {
|
||||||
var path = "${Directory.current.path}/test/bigtest.nbt";
|
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.getKey(), "Level");
|
||||||
expect(tag.get("shortTest")!.asShort(), 32767);
|
expect(tag.get("shortTest")!.asShort(), 32767);
|
||||||
expect(tag.get("doubleTest")!.asDouble(), 0.4931287132182315);
|
expect(tag.get("doubleTest")!.asDouble(), 0.4931287132182315);
|
||||||
|
@ -64,7 +66,8 @@ void main() {
|
||||||
|
|
||||||
test("Read HelloWorld, Output to SNBT", () async {
|
test("Read HelloWorld, Output to SNBT", () async {
|
||||||
CompoundTag ct =
|
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();
|
StringBuilder sb = StringBuilder();
|
||||||
Tag.writeStringifiedNamedTag(ct, sb, 0);
|
Tag.writeStringifiedNamedTag(ct, sb, 0);
|
||||||
print(sb.toString());
|
print(sb.toString());
|
||||||
|
@ -72,7 +75,8 @@ void main() {
|
||||||
|
|
||||||
test("Read BigTest, Output to SNBT", () async {
|
test("Read BigTest, Output to SNBT", () async {
|
||||||
CompoundTag ct =
|
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();
|
StringBuilder sb = StringBuilder();
|
||||||
Tag.writeStringifiedNamedTag(ct, sb, 0);
|
Tag.writeStringifiedNamedTag(ct, sb, 0);
|
||||||
print(sb.toString());
|
print(sb.toString());
|
||||||
|
@ -80,7 +84,8 @@ void main() {
|
||||||
|
|
||||||
test("Write BigTest to SNBT file", () async {
|
test("Write BigTest to SNBT file", () async {
|
||||||
CompoundTag ct =
|
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";
|
String output = "${Directory.current.path}/build/bigtest.snbt";
|
||||||
File file = File(output);
|
File file = File(output);
|
||||||
SnbtIo.writeToFile(output, ct);
|
SnbtIo.writeToFile(output, ct);
|
||||||
|
@ -114,7 +119,7 @@ void main() {
|
||||||
String OutputSNBT = "${Directory.current.path}/build/el-test.snbt";
|
String OutputSNBT = "${Directory.current.path}/build/el-test.snbt";
|
||||||
String OutputNBT = "${Directory.current.path}/build/el-test.nbt";
|
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);
|
await SnbtIo.writeToFile(OutputSNBT, tag);
|
||||||
|
|
||||||
expect(File(OutputSNBT).existsSync(), true);
|
expect(File(OutputSNBT).existsSync(), true);
|
||||||
|
@ -125,7 +130,8 @@ void main() {
|
||||||
}, timeout: Timeout(Duration(hours: 90)));
|
}, timeout: Timeout(Duration(hours: 90)));
|
||||||
|
|
||||||
test("Read Sophisticated Backpack data", () async {
|
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
|
// Convert to SNBT
|
||||||
String snbtData = SnbtIo.writeToString(ct);
|
String snbtData = SnbtIo.writeToString(ct);
|
||||||
// Convert snbt back to NBT
|
// Convert snbt back to NBT
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue