--- CBOR-XS/t/58_hv.t 2016/04/24 13:15:19 1.1 +++ CBOR-XS/t/58_hv.t 2016/04/24 20:08:41 1.3 @@ -1,7 +1,7 @@ -BEGIN { $| = 1; print "1..16\n"; } +BEGIN { $| = 1; print "1..21\n"; } # none of the other tests serialise hv's, gross -# also checks utf8_strings +# also checks text_keys/text_strings use CBOR::XS; @@ -41,12 +41,30 @@ $enc = encode_cbor { "\x{8f}" => undef }; print $enc ne (pack "H*", "a1418ff6") ? "not " : "", "ok 13\n"; -$utf8_strings = CBOR::XS->new->utf8_strings; +$text_strings = CBOR::XS->new->text_strings; -$enc = $utf8_strings->encode ({ "\x{7f}" => undef }); -print $enc ne (pack "H*", "a1617ff6") ? "not " : "", "ok 14\n"; +$enc = $text_strings->encode ({ "\x{7f}" => "\x{3f}" }); +print $enc ne (pack "H*", "a1617f613f") ? "not " : "", "ok 14\n"; -$enc = $utf8_strings->encode ({ "\x{8f}" => undef }); -print $enc ne (pack "H*", "a162c28ff6") ? "not " : "", "ok 15\n"; +$enc = $text_strings->encode ({ "\x{8f}" => "\x{c7}" }); +print $enc ne (pack "H*", "a162c28f62c387") ? "not " : "", "ok 15\n"; + +$enc = $text_strings->encode ({ "\x{8f}gix\x{ff}x" => "a\x{80}b\x{fe}y" }); +print $enc ne (pack "H*", "a168c28f676978c3bf786761c28062c3be79") ? "not " : "", "ok 16\n"; + +$dec = decode_cbor pack "H*", "a168c28f676978c3bf78f6"; +print +(keys %$dec)[0] ne "\x{8f}gix\x{ff}x" ? "not " : "", "ok 17\n"; + +$text_keys = CBOR::XS->new->text_keys; + +$enc = $text_keys->encode ({ "\x{7f}" => "\x{3f}" }); +print $enc ne (pack "H*", "a1617f413f") ? "not " : "", "ok 18\n"; + +$enc = $text_keys->encode ({ "\x{8f}" => "\x{c7}" }); +print $enc ne (pack "H*", "a162c28f41c7") ? "not " : "", "ok 19\n"; + +$enc = $text_keys->encode ({ "\x{8f}gix\x{ff}x" => "a\x{80}b\x{fe}y" }); +print $enc ne (pack "H*", "a168c28f676978c3bf7845618062fe79") ? "not " : "", "ok 20\n"; + +print "ok 21\n"; -print "ok 16\n";