Debian Codegraph @

t/7compare/junk.t

raw
1 #
2 # compare junk to junk.
3 #
4 use strict;
5 use warnings;
6 use MyTest;
7 use UUID ':all';
8
9 ok 1, 'loaded';
10
11 {# junk 16
12 #
13 # this really isnt a "test", per se, but rather a
14 # demonstration of what UUID will do. it sees these
15 # two strings as packed binary uuids, so just compares
16 # them as if they were.
17 #
18 # this will undoubtedly break if we ever get the bright
19 # idea to validate first somehow.
20 #
21 my $u0 = '1234567890123456';
22 my $u1 = 'abcdefghijklmnop';
23 is compare($u0, $u1), -1, 'compare junk 16 equal 0';
24 is compare($u1, $u0), 1, 'compare junk 16 equal 1';
25 }
26
27 {# junk 17
28 #
29 # what if one of the binary "uuid"s isnt? it reverts
30 # to simple string compare.
31 #
32 my $u0 = '12345678901234567';
33 my $u1 = '';
34 is compare($u0, $u1), 1, 'compare junk 17 equal 0';
35 is compare($u1, $u0), -1, 'compare junk 17 equal 1';
36 }
37
38 {# undef
39 #
40 # what if one or both of the binaries are undefined?
41 # sorta string compare -- defined wins.
42 #
43 my $u0 = '1234567890123456';
44 my $u1 = undef;
45 is compare($u0, $u1), 1, 'binary undef 0';
46 is compare($u1, $u0), -1, 'binary undef 1';
47 is compare($u1, $u1), 0, 'binary undef 2';
48 }
49
50 done_testing;