2024-05-24 14:36:51 -07:00
|
|
|
import 'package:libac_dart/nbt/Stream.dart';
|
|
|
|
import 'package:libac_dart/utils/uuid/UUID.dart';
|
|
|
|
import 'package:test/expect.dart';
|
|
|
|
import 'package:test/scaffolding.dart';
|
2024-05-06 20:49:48 -07:00
|
|
|
|
|
|
|
void main() {
|
2024-05-08 12:09:33 -07:00
|
|
|
test("Store a 64bit value in int", () {
|
|
|
|
int X = 9223372036854775807;
|
|
|
|
expect(X.toString(), "9223372036854775807");
|
|
|
|
});
|
|
|
|
|
2024-05-06 20:49:48 -07:00
|
|
|
test("Generate a UUID v4", () {
|
|
|
|
var ID = UUID.generate(4);
|
|
|
|
expect(UUID.validate(ID.toString()), true);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("Generate 10 UUIDv4", () {
|
|
|
|
List<UUID> ID = [];
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
ID.add(UUID.generate(4));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (UUID sID in ID) {
|
2024-05-08 14:44:37 -07:00
|
|
|
print("ID : $sID}");
|
2024-05-06 20:49:48 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2024-05-07 12:24:28 -07:00
|
|
|
test("Test stream bitflipping", () {
|
|
|
|
ByteLayer layer = ByteLayer();
|
|
|
|
layer.writeBytes({0, 255, 80});
|
|
|
|
layer.setBit(0, 0x10);
|
|
|
|
layer.unsetSetBit(1, 0x0F, 0x50);
|
|
|
|
|
|
|
|
expect(layer.checkBit(0, 0x10), true);
|
|
|
|
expect(layer.checkBit(1, 0x50), true);
|
|
|
|
expect(layer.getBit(2), 80);
|
|
|
|
});
|
|
|
|
|
2024-05-06 20:49:48 -07:00
|
|
|
test("Test v3 implementation", () {
|
|
|
|
var expected =
|
|
|
|
"3e1b8c8a-efab-381b-ab57-4764c45b0889"; // Minecraft offline UUID : zontreck
|
|
|
|
var ID3 = UUID.generate(3, parameters: ["OfflinePlayer:zontreck", ""]);
|
|
|
|
|
|
|
|
expect(ID3.toString(), expected);
|
|
|
|
});
|
2024-05-08 12:09:33 -07:00
|
|
|
|
|
|
|
test("Parse a v3 and compare", () {
|
|
|
|
var asString = "3e1b8c8a-efab-381b-ab57-4764c45b0889";
|
|
|
|
var ID3 = UUID.parse(asString);
|
|
|
|
var ID3X = UUID.generate(3, parameters: ["OfflinePlayer:zontreck", ""]);
|
|
|
|
|
2024-05-19 18:43:26 -07:00
|
|
|
//expect(ID3.MSB, ID3X.MSB);
|
|
|
|
//expect(ID3.LSB, ID3X.LSB);
|
2024-05-08 12:09:33 -07:00
|
|
|
|
|
|
|
expect(ID3.toString(), asString);
|
|
|
|
});
|
2024-05-16 23:11:30 -07:00
|
|
|
|
|
|
|
test("Null UUID", () {
|
|
|
|
var expected = "00000000-0000-0000-0000-000000000000";
|
|
|
|
var actual = UUID.ZERO.toString();
|
|
|
|
|
|
|
|
expect(actual, expected);
|
|
|
|
});
|
2024-05-06 20:49:48 -07:00
|
|
|
}
|