File: 120_type_all_string.t

package info (click to toggle)
libcpanel-json-xs-perl 4.39-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,872 kB
  • sloc: perl: 1,165; makefile: 8
file content (17 lines) | stat: -rw-r--r-- 594 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use strict;
use warnings;

use Cpanel::JSON::XS;

use Test::More tests => 8;

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"]]');
is($sjson->encode([ Cpanel::JSON::XS::false, Cpanel::JSON::XS::true ]), '["false","true"]');
is($sjson->encode([ 1 < 0, 1 > 0 ]), '["","1"]');
is($sjson->encode(undef), 'null');