ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/JSON-XS/t/13_limit.t
Revision: 1.4
Committed: Wed Apr 4 00:01:44 2007 UTC (17 years, 3 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-1_11, rel-1_1, rel-1_3, rel-1_2, rel-1_24, rel-1_21, rel-1_22, rel-1_23
Changes since 1.3: +8 -3 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 BEGIN { $| = 1; print "1..9\n"; }
2
3 use JSON::XS;
4
5 our $test;
6 sub ok($;$) {
7 print $_[0] ? "" : "not ", "ok ", ++$test, "\n";
8 }
9
10 my $def = 512;
11
12 my $js = JSON::XS->new;
13
14 ok (!eval { $js->decode (("[" x ($def + 1)) . ("]" x ($def + 1))) });
15 ok (ref $js->decode (("[" x $def) . ("]" x $def)));
16 ok (ref $js->decode (("{\"\":" x ($def - 1)) . "[]" . ("}" x ($def - 1))));
17 ok (!eval { $js->decode (("{\"\":" x $def) . "[]" . ("}" x $def)) });
18
19 ok (ref $js->max_depth (32)->decode (("[" x 32) . ("]" x 32)));
20
21 ok ($js->max_depth(1)->encode ([]));
22 ok (!eval { $js->encode ([[]]), 1 });
23
24 ok ($js->max_depth(2)->encode ([{}]));
25 ok (!eval { $js->encode ([[{}]]), 1 });
26