Push more utilities and UUID stuff
This commit is contained in:
parent
dd6ee1bf60
commit
9b7b84153f
7 changed files with 325 additions and 0 deletions
51
test/uuid_test.dart
Normal file
51
test/uuid_test.dart
Normal file
|
@ -0,0 +1,51 @@
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:libac_flutter/nbt/Stream.dart';
|
||||
import 'package:libac_flutter/utils/uuid/UUID.dart';
|
||||
|
||||
void main() {
|
||||
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) {
|
||||
print("ID : ${sID}}");
|
||||
}
|
||||
});
|
||||
|
||||
test("Check UUIDv4 for validity", () {
|
||||
var ID = UUID.generate(4);
|
||||
ByteLayer layer = ByteLayer();
|
||||
layer.writeLong(ID.getMostSignificantBits());
|
||||
layer.writeLong(ID.getLeastSignificantBits());
|
||||
|
||||
print(
|
||||
"Checking version bit: ${layer.checkBit(6, 0x40)} - ${layer.getBit(6)}");
|
||||
expect(layer.checkBit(6, 0x40), true);
|
||||
});
|
||||
|
||||
test("Generate and check a UUIDv3", () {
|
||||
var ID3 = UUID.generate(3, parameters: ["Test", "Test2"]);
|
||||
ByteLayer layer = ByteLayer();
|
||||
layer.writeLong(ID3.getMostSignificantBits());
|
||||
layer.writeLong(ID3.getLeastSignificantBits());
|
||||
|
||||
print(
|
||||
"Checking version bit: ${layer.checkBit(6, 0x30)} - ${layer.getBit(6)}");
|
||||
expect(layer.checkBit(6, 0x30), true);
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue