ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/JSON-XS/t/13_limit.t
(Generate patch)

Comparing JSON-XS/t/13_limit.t (file contents):
Revision 1.2 by root, Thu Mar 29 02:45:50 2007 UTC vs.
Revision 1.4 by root, Wed Apr 4 00:01:44 2007 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines