Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dipu-bd committed Sep 18, 2024
1 parent 91a945a commit 962a1f2
Showing 1 changed file with 41 additions and 32 deletions.
73 changes: 41 additions & 32 deletions test/random/uuid_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@ import 'package:hashlib/codecs.dart';
import 'package:hashlib/src/uuid.dart';
import 'package:test/test.dart';

@pragma('vm:entry-point')
String runIsolate(version) {
switch (version) {
case 'v1':
return uuid.v1();
case 'v3':
return uuid.v3();
case 'v4':
return uuid.v4();
case 'v5':
return uuid.v5();
case 'v6':
return uuid.v6();
case 'v7':
return uuid.v7();
case 'v8':
return uuid.v8();
}
throw ArgumentError('Undefined version: $version');
}

void main() {
group('UUID v1', () {
test("known value", () {
Expand All @@ -30,12 +51,10 @@ void main() {
final seeds = await Future.wait(List.generate(
1000,
(_) => Isolate.spawn(
(e) => {},
null,
runIsolate,
'v1',
errorsAreFatal: true,
).then((value) {
return uuid.v1();
}),
),
));
expect(seeds.toSet().length, 1000);
}, tags: ['vm-only']);
Expand All @@ -61,12 +80,10 @@ void main() {
final seeds = await Future.wait(List.generate(
1000,
(_) => Isolate.spawn(
(e) => {},
null,
runIsolate,
'v3',
errorsAreFatal: true,
).then((value) {
return uuid.v3();
}),
),
));
expect(seeds.toSet().length, 1000);
}, tags: ['vm-only']);
Expand All @@ -92,12 +109,10 @@ void main() {
final seeds = await Future.wait(List.generate(
1000,
(_) => Isolate.spawn(
(e) => {},
null,
runIsolate,
'v4',
errorsAreFatal: true,
).then((value) {
return uuid.v4();
}),
),
));
expect(seeds.toSet().length, 1000);
}, tags: ['vm-only']);
Expand All @@ -123,12 +138,10 @@ void main() {
final seeds = await Future.wait(List.generate(
1000,
(_) => Isolate.spawn(
(e) => {},
null,
runIsolate,
'v5',
errorsAreFatal: true,
).then((value) {
return uuid.v5();
}),
),
));
expect(seeds.toSet().length, 1000);
}, tags: ['vm-only']);
Expand All @@ -155,12 +168,10 @@ void main() {
final seeds = await Future.wait(List.generate(
1000,
(_) => Isolate.spawn(
(e) => {},
null,
runIsolate,
'v6',
errorsAreFatal: true,
).then((value) {
return uuid.v6();
}),
),
));
expect(seeds.toSet().length, 1000);
}, tags: ['vm-only']);
Expand All @@ -187,12 +198,10 @@ void main() {
final seeds = await Future.wait(List.generate(
1000,
(_) => Isolate.spawn(
(e) => {},
null,
runIsolate,
'v7',
errorsAreFatal: true,
).then((value) {
return uuid.v7();
}),
),
));
expect(seeds.toSet().length, 1000);
}, tags: ['vm-only']);
Expand Down Expand Up @@ -237,8 +246,8 @@ void main() {
final seeds = await Future.wait(List.generate(
1000,
(_) => Isolate.spawn(
(e) => {},
null,
runIsolate,
'v8',
errorsAreFatal: true,
).then((value) {
return uuid.v8();
Expand Down

0 comments on commit 962a1f2

Please sign in to comment.