File: zero-mojibake.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 (34 lines) | stat: -rw-r--r-- 764 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/perl

use strict;
use Test::More tests => 5;
use Cpanel::JSON::XS;
my $json = Cpanel::JSON::XS->new;

my $input = q[
{
   "dynamic_config" : 0,
   "x_contributors" : [
      "大沢 和宏",
      "Ævar Arnfjörð"
   ]
}
];
eval { $json->decode($input) };
is $@, '', 'decodes default mojibake without error';

$json->utf8;
eval { $json->decode($input) };
is $@, '', 'decodes utf8 mojibake without error';

$json->utf8(0)->ascii;
eval { $json->decode($input) };
is $@, '', 'decodes ascii mojibake without error';

$json->ascii(0)->latin1;
eval { $json->decode($input) };
is $@, '', 'decodes latin1 mojibake without error';

$json->latin1(0)->binary;
eval { $json->decode($input) };
is $@, '', 'decodes binary mojibake without error';