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.6 by root, Sun Jan 5 14:24:54 2014 UTC

1BEGIN { $| = 1; print "1..77\n"; } 1BEGIN { $| = 1; print "1..79\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
101* NaN 0xfb7ff8000000000000 104* NaN 0xfb7ff8000000000000
102 -Infinity 0xfbfff0000000000000 105 -Infinity 0xfbfff0000000000000
103* false 0xf4 106* false 0xf4
104* true 0xf5 107* true 0xf5
105* null 0xf6 108* null 0xf6
106 undefined 0xf7 109* undefined 0xf7
107 simple(16) 0xf0 110 simple(16) 0xf0
108 simple(24) 0xf818 111 simple(24) 0xf818
109 simple(255) 0xf8ff 112 simple(255) 0xf8ff
110 0("2013-03-21T20:04:00Z") 0xc074323031332d30332d32315432303a30343a30305a 113 0("2013-03-21T20:04:00Z") 0xc074323031332d30332d32315432303a30343a30305a
111 1(1363896240) 0xc11a514b67b0 114* 1(1363896240) 0xc11a514b67b0
112 1(1363896240.5) 0xc1fb41d452d9ec200000 115* 1(1363896240.5) 0xc1fb41d452d9ec200000
113 23(h'01020304') 0xd74401020304 116 23(h'01020304') 0xd74401020304
114 24(h'6449455446') 0xd818456449455446 117* 24(h'6449455446') 0xd818456449455446
115 32("http://www.example.com") 0xd82076687474703a2f2f7777772e6578616d706c652e636f6d 118 32("http://www.example.com") 0xd82076687474703a2f2f7777772e6578616d706c652e636f6d
116 h'' 0x40 119* h'' 0x40
117 h'01020304' 0x4401020304 120* h'01020304' 0x4401020304
118 "" 0x60 121* "" 0x60
119+ a 0x6161 122+ a 0x6161
120+ IETF 0x6449455446 123+ IETF 0x6449455446
121+ "\ 0x62225c 124+ "\ 0x62225c
122+ ü 0x62c3bc 125+ ü 0x62c3bc
123+ 水 0x63e6b0b4 126+ 水 0x63e6b0b4

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines