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

Unified Diff: third_party/JSON/JSON-2.59/t/99_binary.t

Issue 15736030: Add JSON.pm to third_party (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix permissions and shebangs 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/JSON/JSON-2.59/t/22_comment_at_eof.t ('k') | third_party/JSON/JSON-2.59/t/_unicode_handling.pm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/JSON/JSON-2.59/t/99_binary.t
diff --git a/third_party/JSON/JSON-2.59/t/99_binary.t b/third_party/JSON/JSON-2.59/t/99_binary.t
new file mode 100644
index 0000000000000000000000000000000000000000..254b08ea7facd0d1c25bce2193d2523aafa24169
--- /dev/null
+++ b/third_party/JSON/JSON-2.59/t/99_binary.t
@@ -0,0 +1,53 @@
+# copied over from JSON::XS and modified to use JSON
+
+use Test::More;
+use strict;
+BEGIN { plan tests => 2432 };
+
+BEGIN { $ENV{PERL_JSON_BACKEND} = "JSON::backportPP"; }
+
+BEGIN {
+ use lib qw(t);
+ use _unicode_handling;
+}
+
+use JSON;
+
+SKIP: {
+ skip "UNICODE handling is disabale.", 2432 unless $JSON::can_handle_UTF16_and_utf8;
+
+sub test($) {
+ my $js;
+
+ $js = JSON->new->allow_nonref(0)->utf8->ascii->shrink->encode ([$_[0]]);
+ ok ($_[0] eq ((decode_json $js)->[0]));
+ $js = JSON->new->allow_nonref(0)->utf8->ascii->encode ([$_[0]]);
+ ok ($_[0] eq (JSON->new->utf8->shrink->decode($js))->[0]);
+
+ $js = JSON->new->allow_nonref(0)->utf8->shrink->encode ([$_[0]]);
+ ok ($_[0] eq ((decode_json $js)->[0]));
+ $js = JSON->new->allow_nonref(1)->utf8->encode ([$_[0]]);
+ ok ($_[0] eq (JSON->new->utf8->shrink->decode($js))->[0]);
+
+ $js = JSON->new->allow_nonref(1)->ascii->encode ([$_[0]]);
+ ok ($_[0] eq JSON->new->decode ($js)->[0]);
+ $js = JSON->new->allow_nonref(0)->ascii->encode ([$_[0]]);
+ ok ($_[0] eq JSON->new->shrink->decode ($js)->[0]);
+
+ $js = JSON->new->allow_nonref(1)->shrink->encode ([$_[0]]);
+ ok ($_[0] eq JSON->new->decode ($js)->[0]);
+ $js = JSON->new->allow_nonref(0)->encode ([$_[0]]);
+ ok ($_[0] eq JSON->new->shrink->decode ($js)->[0]);
+}
+
+srand 0; # doesn't help too much, but its at least more deterministic
+
+#for (1..768) {
+for (1..64, 125..129, 255..257, 512, 704, 736, 768) {
+ test join "", map chr ($_ & 255), 0..$_;
+ test join "", map chr rand 255, 0..$_;
+ test join "", map chr ($_ * 97 & ~0x4000), 0..$_;
+ test join "", map chr (rand (2**20) & ~0x800), 0..$_;
+}
+
+}
« no previous file with comments | « third_party/JSON/JSON-2.59/t/22_comment_at_eof.t ('k') | third_party/JSON/JSON-2.59/t/_unicode_handling.pm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698