Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(432)

Side by Side Diff: trunk/src/third_party/JSON/JSON-2.59/t/99_binary.t

Issue 16539003: Revert 205057 "Add JSON.pm to third_party" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # copied over from JSON::XS and modified to use JSON
2
3 use Test::More;
4 use strict;
5 BEGIN { plan tests => 2432 };
6
7 BEGIN { $ENV{PERL_JSON_BACKEND} = "JSON::backportPP"; }
8
9 BEGIN {
10 use lib qw(t);
11 use _unicode_handling;
12 }
13
14 use JSON;
15
16 SKIP: {
17 skip "UNICODE handling is disabale.", 2432 unless $JSON::can_handle_UTF16_an d_utf8;
18
19 sub test($) {
20 my $js;
21
22 $js = JSON->new->allow_nonref(0)->utf8->ascii->shrink->encode ([$_[0]]);
23 ok ($_[0] eq ((decode_json $js)->[0]));
24 $js = JSON->new->allow_nonref(0)->utf8->ascii->encode ([$_[0]]);
25 ok ($_[0] eq (JSON->new->utf8->shrink->decode($js))->[0]);
26
27 $js = JSON->new->allow_nonref(0)->utf8->shrink->encode ([$_[0]]);
28 ok ($_[0] eq ((decode_json $js)->[0]));
29 $js = JSON->new->allow_nonref(1)->utf8->encode ([$_[0]]);
30 ok ($_[0] eq (JSON->new->utf8->shrink->decode($js))->[0]);
31
32 $js = JSON->new->allow_nonref(1)->ascii->encode ([$_[0]]);
33 ok ($_[0] eq JSON->new->decode ($js)->[0]);
34 $js = JSON->new->allow_nonref(0)->ascii->encode ([$_[0]]);
35 ok ($_[0] eq JSON->new->shrink->decode ($js)->[0]);
36
37 $js = JSON->new->allow_nonref(1)->shrink->encode ([$_[0]]);
38 ok ($_[0] eq JSON->new->decode ($js)->[0]);
39 $js = JSON->new->allow_nonref(0)->encode ([$_[0]]);
40 ok ($_[0] eq JSON->new->shrink->decode ($js)->[0]);
41 }
42
43 srand 0; # doesn't help too much, but its at least more deterministic
44
45 #for (1..768) {
46 for (1..64, 125..129, 255..257, 512, 704, 736, 768) {
47 test join "", map chr ($_ & 255), 0..$_;
48 test join "", map chr rand 255, 0..$_;
49 test join "", map chr ($_ * 97 & ~0x4000), 0..$_;
50 test join "", map chr (rand (2**20) & ~0x800), 0..$_;
51 }
52
53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698