File: fix-isbn10.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 (38 lines) | stat: -rw-r--r-- 1,056 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
#!/usr/bin/env perl

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

my $pkg;

BEGIN {
    $pkg = 'Catmandu::Fix::isbn10';
    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'}, "normalize isbn 10";

is_deeply $pkg->new('isbn_path')->fix({isbn_path => '1565922573'}),
    {isbn_path => '1-56592-257-3'}, "normalize isbn 10";

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

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

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

is_deeply $pkg->new('isbn_path')->fix({isbn_path => '979-10-90636-07-1'}),
    {isbn_path => ''}, "non-convertible isbn 13";

done_testing;