Debian Codegraph @

t/3unique/v5.t

raw
1 #
2 # v5 should be all dupes.
3 #
4 use strict;
5 use warnings;
6 use MyTest;
7 use MyTmpTimer;
8 use UUID;
9
10 my $N = 4_000;
11 my %seen = ();
12 my $count = 0;
13
14 my $fh = tmptimer( $N, sub {
15 my ($N, $fh) = @_;
16 my ($bin, $str);
17 for (1 .. $N) {
18 UUID::generate_v5($bin, dns => 'www.example.com');
19 UUID::unparse($bin, $str);
20 print $fh $str. "\n";
21 }
22 });
23
24 while (my $str = <$fh>) {
25 chomp $str;
26 note $str if $count++ < 3;
27 ++$seen{$str};
28 }
29
30 # avoid cleanup race
31 $fh->close;
32
33 {
34 my $expected = $N;
35 my $got = scalar keys %seen;
36 is $count, $expected, 'count ok';
37 is $got, 1, 'unique ok';
38 }
39
40 done_testing;