File: 120_type_all_string.t

package info (click to toggle)
libcpanel-json-xs-perl 4.35-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 2,864 kB
  • sloc: perl: 1,092; makefile: 8
file content (14 lines) | stat: -rw-r--r-- 416 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use strict;
use warnings;

use Cpanel::JSON::XS;

use Test::More tests => 5;

my $sjson = Cpanel::JSON::XS->new->canonical->require_types->type_all_string->allow_nonref;

is($sjson->encode(0), '"0"');
is($sjson->encode("0"), '"0"');
is($sjson->encode(0.5), '"0.5"');
is($sjson->encode("0.5"), '"0.5"');
is($sjson->encode([ 1, "2", { key1 => 3.5 }, [ "string", -10 ] ]), '["1","2",{"key1":"3.5"},["string","-10"]]');