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

Side by Side Diff: third_party/JSON/JSON-2.59/t/07_pc_esc.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/JSON/JSON-2.59/t/06_pc_pretty.t ('k') | third_party/JSON/JSON-2.59/t/08_pc_base.t » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #
2 # このファイルのエンコーディングはUTF-8
3 #
4
5 # copied over from JSON::PC and modified to use JSON
6 # copied over from JSON::XS and modified to use JSON
7
8 use Test::More;
9 use strict;
10
11 BEGIN { plan tests => 17 };
12
13 BEGIN { $ENV{PERL_JSON_BACKEND} = "JSON::backportPP"; }
14
15 BEGIN {
16 use lib qw(t);
17 use _unicode_handling;
18 }
19
20
21 use utf8;
22 use JSON;
23
24 #########################
25 my ($js,$obj,$str);
26
27 my $pc = new JSON;
28
29 $obj = {test => qq|abc"def|};
30 $str = $pc->encode($obj);
31 is($str,q|{"test":"abc\"def"}|);
32
33 $obj = {qq|te"st| => qq|abc"def|};
34 $str = $pc->encode($obj);
35 is($str,q|{"te\"st":"abc\"def"}|);
36
37 $obj = {test => qq|abc/def|}; # / => \/
38 $str = $pc->encode($obj); # but since version 0.99
39 is($str,q|{"test":"abc/def"}|); # this handling is deleted.
40 $obj = $pc->decode($str);
41 is($obj->{test},q|abc/def|);
42
43 $obj = {test => q|abc\def|};
44 $str = $pc->encode($obj);
45 is($str,q|{"test":"abc\\\\def"}|);
46
47 $obj = {test => "abc\bdef"};
48 $str = $pc->encode($obj);
49 is($str,q|{"test":"abc\bdef"}|);
50
51 $obj = {test => "abc\fdef"};
52 $str = $pc->encode($obj);
53 is($str,q|{"test":"abc\fdef"}|);
54
55 $obj = {test => "abc\ndef"};
56 $str = $pc->encode($obj);
57 is($str,q|{"test":"abc\ndef"}|);
58
59 $obj = {test => "abc\rdef"};
60 $str = $pc->encode($obj);
61 is($str,q|{"test":"abc\rdef"}|);
62
63 $obj = {test => "abc-def"};
64 $str = $pc->encode($obj);
65 is($str,q|{"test":"abc-def"}|);
66
67 $obj = {test => "abc(def"};
68 $str = $pc->encode($obj);
69 is($str,q|{"test":"abc(def"}|);
70
71 $obj = {test => "abc\\def"};
72 $str = $pc->encode($obj);
73 is($str,q|{"test":"abc\\\\def"}|);
74
75
76 $obj = {test => "あいうえお"};
77 $str = $pc->encode($obj);
78 is($str,q|{"test":"あいうえお"}|);
79
80 $obj = {"あいうえお" => "かきくけこ"};
81 $str = $pc->encode($obj);
82 is($str,q|{"あいうえお":"かきくけこ"}|);
83
84
85 $obj = $pc->decode(q|{"id":"abc\ndef"}|);
86 is($obj->{id},"abc\ndef",q|{"id":"abc\ndef"}|);
87
88 $obj = $pc->decode(q|{"id":"abc\\\ndef"}|);
89 is($obj->{id},"abc\\ndef",q|{"id":"abc\\\ndef"}|);
90
91 $obj = $pc->decode(q|{"id":"abc\\\\\ndef"}|);
92 is($obj->{id},"abc\\\ndef",q|{"id":"abc\\\\\ndef"}|);
93
OLDNEW
« no previous file with comments | « third_party/JSON/JSON-2.59/t/06_pc_pretty.t ('k') | third_party/JSON/JSON-2.59/t/08_pc_base.t » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698