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

Comparing CBOR-XS/t/50_rfc.t (file contents):
Revision 1.1 by root, Sat Oct 26 10:41:12 2013 UTC vs.
Revision 1.4 by root, Sun Oct 27 15:04:54 2013 UTC

1BEGIN { $| = 1; print "1..77\n"; } 1BEGIN { $| = 1; print "1..72\n"; }
2 2
3# examples from rfc7049 3# examples from rfc7049
4 4
5use Data::Dumper; 5use Data::Dumper;
6use CBOR::XS; 6use CBOR::XS;
7 7
8binmode DATA; 8binmode DATA;
9binmode STDOUT, ":utf8"; 9binmode STDOUT, ":utf8";
10 10
11my $test;
12
11sub ok($;$) { 13sub ok($;$) {
12 print $_[0] ? "" : "not ", "ok ", ++$test, " - $_[1]\n"; 14 print $_[0] ? "" : "not ", "ok ", ++$test, " - $_[1]\n";
13} 15}
14 16
15$Data::Dumper::Terse = 1; 17$Data::Dumper::Terse = 1;
16$Data::Dumper::Sortkeys = 1; 18$Data::Dumper::Sortkeys = 1;
17$Data::Dumper::Pair = ','; 19$Data::Dumper::Pair = ',';
18$Data::Dumper::Useqq = 1; 20$Data::Dumper::Useqq = 1;
19$Data::Dumper::Indent = 0; 21$Data::Dumper::Indent = 0;
22$Data::Dumper::Quotekeys = 1;
20 23
21while (<DATA>) { 24while (<DATA>) {
22 next unless /^([<>\+*])\s*(.*?)\s*0x([0-9a-f]+)$/; 25 next unless /^([<>\+*])\s*(.*?)\s*0x([0-9a-f]+)$/;
23 my ($dir, $val, $hex) = ($1, $2, $3); 26 my ($dir, $val, $hex) = ($1, $2, $3);
24 27
67+ 24 0x1818 70+ 24 0x1818
68+ 25 0x1819 71+ 25 0x1819
69+ 100 0x1864 72+ 100 0x1864
70+ 1000 0x1903e8 73+ 1000 0x1903e8
71+ 1000000 0x1a000f4240 74+ 1000000 0x1a000f4240
72+ 1000000000000 0x1b000000e8d4a51000 75 1000000000000 0x1b000000e8d4a51000
73 18446744073709551615 0x1bffffffffffffffff 76 18446744073709551615 0x1bffffffffffffffff
74 18446744073709551616 0xc249010000000000000000 77 18446744073709551616 0xc249010000000000000000
75 -18446744073709551616 0x3bffffffffffffffff 78 -18446744073709551616 0x3bffffffffffffffff
76 -18446744073709551617 0xc349010000000000000000 79 -18446744073709551617 0xc349010000000000000000
77+ -1 0x20 80+ -1 0x20
79+ -100 0x3863 82+ -100 0x3863
80+ -1000 0x3903e7 83+ -1000 0x3903e7
81< 0 0xf90000 84< 0 0xf90000
82 -0 0xf98000 85 -0 0xf98000
83< 1 0xf93c00 86< 1 0xf93c00
84+ 1.1 0xfb3ff199999999999a 87* 1.1 0xfb3ff199999999999a
85< 1.5 0xf93e00 88< 1.5 0xf93e00
86< 65504 0xf97bff 89< 65504 0xf97bff
87< 100000 0xfa47c35000 90< 100000 0xfa47c35000
88* 3.4028234663852886e+38 0xfa7f7fffff 91* 3.4028234663852886e+38 0xfa7f7fffff
89+ 1e+300 0xfb7e37e43c8800759c 92+ 1e+300 0xfb7e37e43c8800759c
90 5.960464477539063e-8 0xf90001 93 5.960464477539063e-8 0xf90001
91 0.00006103515625 0xf90400 94 0.00006103515625 0xf90400
92< -4 0xf9c400 95< -4 0xf9c400
93+ -4.1 0xfbc010666666666666 96* -4.1 0xfbc010666666666666
94 Infinity 0xf97c00 97 Infinity 0xf97c00
95 NaN 0xf97e00 98 NaN 0xf97e00
96 -Infinity 0xf9fc00 99 -Infinity 0xf9fc00
97* Infinity 0xfa7f800000 100* Infinity 0xfa7f800000
98 NaN 0xfa7fc00000 101 NaN 0xfa7fc00000
125* [] 0x80 128* [] 0x80
126* [1,2,3] 0x83010203 129* [1,2,3] 0x83010203
127* [1,[2,3],[4,5]] 0x8301820203820405 130* [1,[2,3],[4,5]] 0x8301820203820405
128* [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]0x98190102030405060708090a0b0c0d0e0f101112131415161718181819 131* [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]0x98190102030405060708090a0b0c0d0e0f101112131415161718181819
129* {} 0xa0 132* {} 0xa0
130< {1,2,3,4} 0xa201020304 133 {1,2,3,4} 0xa201020304
131< {"a",1,"b",[2,3]} 0xa26161016162820203 134< {"a",1,"b",[2,3]} 0xa26161016162820203
132< ["a",{"b","c"}] 0x826161a161626163 135< ["a",{"b","c"}] 0x826161a161626163
133< {"a","A","b","B","c","C","d","D","e","E"}0xa56161614161626142616361436164614461656145 136< {"a","A","b","B","c","C","d","D","e","E"}0xa56161614161626142616361436164614461656145
134 (_h'0102',h'030405') 0x5f42010243030405ff 137 (_h'0102',h'030405') 0x5f42010243030405ff
135< streaming 0x7f657374726561646d696e67ff 138< streaming 0x7f657374726561646d696e67ff

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines