| 1 |
use strict; |
| 2 |
use warnings; |
| 3 |
use MyTest; |
| 4 |
use UUID (); |
| 5 |
|
| 6 |
|
| 7 |
UUID::generate_time(my $bin); |
| 8 |
ok 1, 'generate'; |
| 9 |
|
| 10 |
UUID::unparse($bin,my $str); |
| 11 |
ok 1, 'unparse ok'; |
| 12 |
note "unparse: $str\n"; |
| 13 |
|
| 14 |
is length($str), 36, 'length'; |
| 15 |
|
| 16 |
like $str, qr{^[-0-9a-f]+$}i, 'match'; |
| 17 |
|
| 18 |
UUID::clear($bin); |
| 19 |
ok 1, 'clear'; |
| 20 |
|
| 21 |
UUID::unparse($bin,$str); |
| 22 |
ok 1, 'unparse null'; |
| 23 |
note "unparse: $str\n"; |
| 24 |
is length($str), 36, 'length null'; |
| 25 |
is $str, '00000000-0000-0000-0000-000000000000', 'value null'; |
| 26 |
|
| 27 |
$bin = 'foo'; |
| 28 |
$str = 'bar'; |
| 29 |
UUID::unparse($bin,$str); |
| 30 |
ok 1, 'unparse garbage'; |
| 31 |
note "unparse: $str\n"; |
| 32 |
is $bin, 'foo', 'not mangled'; |
| 33 |
|
| 34 |
is $str, '666f6f00-0000-0000-0000-000000000000', 'questionable'; |
| 35 |
|
| 36 |
done_testing; |