File: Catmandu-Fix-string.t

package info (click to toggle)
libcatmandu-perl 1.2024-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,552 kB
  • sloc: perl: 17,037; makefile: 24; sh: 1
file content (24 lines) | stat: -rw-r--r-- 695 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
22
23
24
#!/usr/bin/env perl

use strict;
use warnings;
use Test::More;
use Test::Exception;

my $pkg;

BEGIN {
    $pkg = 'Catmandu::Fix::string';
    use_ok $pkg;
}

is_deeply $pkg->new('str')->fix({}),                        {};
is_deeply $pkg->new('str')->fix({str => 0}),                {str => "0"};
is_deeply $pkg->new('str')->fix({str => 123}),              {str => "123"};
is_deeply $pkg->new('str')->fix({str => [1, 2]}),           {str => "12"};
is_deeply $pkg->new('str')->fix({str => [1, {2 => 3}]}),    {str => ""};
is_deeply $pkg->new('str')->fix({str => {3 => 4, 1 => 2}}), {str => "24"};
is_deeply $pkg->new('str')->fix({str => {3 => {4 => 5}, 1 => 2}}),
    {str => ""};

done_testing;