File: fix-isbn13.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 (36 lines) | stat: -rw-r--r-- 961 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
#!/usr/bin/env perl

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

my $pkg;

BEGIN {
    $pkg = 'Catmandu::Fix::isbn13';
    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 => '978-1-56592-257-0'}, "normalize isbn 13";

is_deeply $pkg->new('isbn_path')->fix({isbn_path => '9780596527242'}),
    {isbn_path => '978-0-596-52724-2'}, "normalize isbn 13 again";

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

is_deeply $pkg->new('isbn_path')->fix({isbn_path => ''}), {isbn_path => ''},
    "empty isbn 13";

is_deeply $pkg->new('isbn_path')->fix({}), {}, "missing isbn 13";

done_testing;