Debian Codegraph @

t/1uuid/v1.t

raw
1 use strict;
2 use warnings;
3 use MyTest;
4
5 use vars '@OPTS';
6
7 BEGIN {
8 @OPTS = qw(:mac=random uuid1 parse unparse type variant);
9 }
10
11 use UUID @OPTS;
12
13 my $bin;
14 my $str = uuid1();
15 note '';
16 note $str;
17
18 ok defined($str), 'defined';
19 ok length($str) == 36, 'length';
20 ok !parse($str, $bin), 'parsable';
21
22 # must be v1
23 my $type = type($bin);
24 is $type, 1, 'correct type';
25
26 # all are variant 1
27 is variant($bin), 1, 'correct variant';
28
29 my $foo;
30 unparse($bin, $foo);
31 is $foo, $str, 'unparse';
32 note $foo;
33
34 # check for null node. makes sure randoms are
35 # initialized since :mac=random here.
36 unlike $foo, qr/-010000000000/, 'not null node';
37
38 done_testing;