0 | 0 |
#!perl
|
1 | |
|
2 | 1 |
use strict;
|
3 | 2 |
use warnings;
|
4 | 3 |
|
5 | |
use Test::More tests => 32;
|
|
4 |
use Test::More 0.88;
|
6 | 5 |
|
7 | 6 |
BEGIN { use_ok('Data::GUID'); }
|
8 | 7 |
|
|
11 | 10 |
|
12 | 11 |
like(
|
13 | 12 |
$guid->as_string,
|
14 | |
Data::GUID->__type_regex('string'),
|
|
13 |
Data::GUID->string_guid_regex,
|
15 | 14 |
"GUID as_string looks OK",
|
16 | 15 |
);
|
17 | 16 |
|
18 | 17 |
like(
|
19 | 18 |
"$guid",
|
20 | |
Data::GUID->__type_regex('string'),
|
|
19 |
Data::GUID->string_guid_regex,
|
21 | 20 |
"stringified GUID looks OK",
|
22 | 21 |
);
|
23 | 22 |
|
24 | 23 |
like(
|
25 | 24 |
$guid->as_hex,
|
26 | |
Data::GUID->__type_regex('hex'),
|
|
25 |
Data::GUID->hex_guid_regex,
|
27 | 26 |
"GUID as_hex looks OK",
|
28 | 27 |
);
|
29 | 28 |
|
30 | 29 |
like(
|
31 | 30 |
$guid->as_base64,
|
32 | |
Data::GUID->__type_regex('base64'),
|
|
31 |
Data::GUID->base64_guid_regex,
|
33 | 32 |
"GUID as_hex looks OK",
|
34 | 33 |
);
|
35 | 34 |
|
|
37 | 36 |
($guid <=> $guid) == 0,
|
38 | 37 |
"guid is equal to itself",
|
39 | 38 |
);
|
40 | |
|
41 | |
{
|
42 | |
my $other_guid = Data::GUID->new;
|
43 | |
|
44 | |
ok(
|
45 | |
($guid <=> $other_guid) != 0,
|
46 | |
"guid is not equal to a new guid",
|
47 | |
);
|
48 | |
}
|
49 | 39 |
|
50 | 40 |
{
|
51 | 41 |
my $non_guid_value = 10;
|
|
72 | 62 |
}
|
73 | 63 |
}
|
74 | 64 |
|
75 | |
|
76 | 65 |
for my $type (qw(hex string base64)) {
|
77 | 66 |
my $as = "as_$type";
|
78 | 67 |
my $from = "from_$type";
|
|
92 | 81 |
like($@, qr/not a valid $type/, "invalid input to $from croaks");
|
93 | 82 |
}
|
94 | 83 |
|
95 | |
like($guid_str, Data::GUID->__type_regex($type), "guid_$type method ok");
|
|
84 |
my $re_method = "$type\_guid_regex";
|
|
85 |
like($guid_str, Data::GUID->$re_method, "guid_$type method ok");
|
96 | 86 |
}
|
97 | 87 |
|
98 | 88 |
{
|
|
102 | 92 |
my $copy = Data::GUID->from_string($str);
|
103 | 93 |
is($guid->as_string, $copy->as_string, "we can from_string a dash-less str");
|
104 | 94 |
}
|
|
95 |
|
|
96 |
done_testing;
|