File: fix-isbn_versions.t

package info (click to toggle)
libcatmandu-identifier-perl 0.15-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 292 kB
  • sloc: perl: 978; makefile: 2
file content (44 lines) | stat: -rw-r--r-- 1,001 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env perl

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

my $pkg;

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

dies_ok {$pkg->new()} "required argument";
lives_ok {$pkg->new('isbn')} "path required";

is_deeply $pkg->new('isbn_path')->fix({isbn_path => '1565922573'}),
    {isbn_path =>
        ['1-56592-257-3', '1565922573', '978-1-56592-257-0', '9781565922570']
    }, "isbn 10 versions";

is_deeply $pkg->new('identifier.*.isbn')
    ->fix(
    {identifier => [{isbn => '9781565922570'}, {isbn => '0596527241'}]}),
    {
    identifier => [
        {
            isbn => [
                '1-56592-257-3',     '1565922573',
                '978-1-56592-257-0', '9781565922570'
            ]
        },
        {
            isbn => [
                '0-596-52724-1',     '0596527241',
                '978-0-596-52724-2', '9780596527242'
            ]
        }
    ]
    },
    "isbn 13 and 10 versions with complex path";

done_testing;