ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CBOR-XS/t/58_hv.t
(Generate patch)

Comparing CBOR-XS/t/58_hv.t (file contents):
Revision 1.2 by root, Sun Apr 24 19:31:56 2016 UTC vs.
Revision 1.3 by root, Sun Apr 24 20:08:41 2016 UTC

1BEGIN { $| = 1; print "1..18\n"; } 1BEGIN { $| = 1; print "1..21\n"; }
2 2
3# none of the other tests serialise hv's, gross 3# none of the other tests serialise hv's, gross
4# also checks utf8_strings 4# also checks text_keys/text_strings
5 5
6use CBOR::XS; 6use CBOR::XS;
7 7
8print "ok 1\n"; 8print "ok 1\n";
9 9
39print +(keys %$dec)[0] ne "\x{100}" ? "not " : "", "ok 12\n"; 39print +(keys %$dec)[0] ne "\x{100}" ? "not " : "", "ok 12\n";
40 40
41$enc = encode_cbor { "\x{8f}" => undef }; 41$enc = encode_cbor { "\x{8f}" => undef };
42print $enc ne (pack "H*", "a1418ff6") ? "not " : "", "ok 13\n"; 42print $enc ne (pack "H*", "a1418ff6") ? "not " : "", "ok 13\n";
43 43
44$utf8_strings = CBOR::XS->new->utf8_strings; 44$text_strings = CBOR::XS->new->text_strings;
45 45
46$enc = $utf8_strings->encode ({ "\x{7f}" => undef }); 46$enc = $text_strings->encode ({ "\x{7f}" => "\x{3f}" });
47print $enc ne (pack "H*", "a1617ff6") ? "not " : "", "ok 14\n"; 47print $enc ne (pack "H*", "a1617f613f") ? "not " : "", "ok 14\n";
48 48
49$enc = $utf8_strings->encode ({ "\x{8f}" => undef }); 49$enc = $text_strings->encode ({ "\x{8f}" => "\x{c7}" });
50print $enc ne (pack "H*", "a162c28ff6") ? "not " : "", "ok 15\n"; 50print $enc ne (pack "H*", "a162c28f62c387") ? "not " : "", "ok 15\n";
51 51
52$enc = $utf8_strings->encode ({ "\x{8f}gix\x{ff}x" => undef }); 52$enc = $text_strings->encode ({ "\x{8f}gix\x{ff}x" => "a\x{80}b\x{fe}y" });
53print $enc ne (pack "H*", "a168c28f676978c3bf78f6") ? "not " : "", "ok 16\n"; 53print $enc ne (pack "H*", "a168c28f676978c3bf786761c28062c3be79") ? "not " : "", "ok 16\n";
54 54
55$dec = decode_cbor pack "H*", "a168c28f676978c3bf78f6"; 55$dec = decode_cbor pack "H*", "a168c28f676978c3bf78f6";
56print +(keys %$dec)[0] ne "\x{8f}gix\x{ff}x" ? "not " : "", "ok 17\n"; 56print +(keys %$dec)[0] ne "\x{8f}gix\x{ff}x" ? "not " : "", "ok 17\n";
57 57
58print "ok 18\n"; 58$text_keys = CBOR::XS->new->text_keys;
59 59
60$enc = $text_keys->encode ({ "\x{7f}" => "\x{3f}" });
61print $enc ne (pack "H*", "a1617f413f") ? "not " : "", "ok 18\n";
62
63$enc = $text_keys->encode ({ "\x{8f}" => "\x{c7}" });
64print $enc ne (pack "H*", "a162c28f41c7") ? "not " : "", "ok 19\n";
65
66$enc = $text_keys->encode ({ "\x{8f}gix\x{ff}x" => "a\x{80}b\x{fe}y" });
67print $enc ne (pack "H*", "a168c28f676978c3bf7845618062fe79") ? "not " : "", "ok 20\n";
68
69print "ok 21\n";
70

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines