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