File: 17_relaxed.t

package info (click to toggle)
libcpanel-json-xs-perl 4.09-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,776 kB
  • sloc: perl: 1,052; makefile: 8
file content (21 lines) | stat: -rw-r--r-- 877 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use Test::More $] < 5.008 ? (skip_all => "5.6") : (tests => 12);
use Cpanel::JSON::XS;

my $json = Cpanel::JSON::XS->new->relaxed;

is (encode_json ($json->decode (' [1,2, 3]')), '[1,2,3]');
is (encode_json ($json->decode ('[1,2, 4 , ]')), '[1,2,4]');
ok (!eval { $json->decode ('[1,2, 3,4,,]') });
ok (!eval { $json->decode ('[,1]') });

is (encode_json ($json->decode (' {"1":2}')), '{"1":2}' );
is (encode_json ($json->decode ('{"1":2,}')), '{"1":2}');
is (encode_json ($json->decode (q({'1':2}))), '{"1":2}'); # allow_singlequotes
is (encode_json ($json->decode ('{a:2}')),    '{"a":2}'); # allow_barekey
ok (!eval { $json->decode ('{,}') });

is (encode_json ($json->decode ("[1#,2\n ,2,#  ]  \n\t]")), '[1,2]');

is (encode_json ($json->decode ("[\"Hello\tWorld\"]")), '["Hello\tWorld"]');

is (encode_json ($json->decode ('{"a b":2}')),    '{"a b":2}'); # allow_barekey