File: test880and6.t

package info (click to toggle)
libmarc-lint-perl 1.53-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 544 kB
  • sloc: perl: 4,179; makefile: 2
file content (86 lines) | stat: -rwxr-xr-x 2,063 bytes parent folder | download | duplicates (2)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!perl

#Tests for field 880 and for subfield 6

use strict;
use warnings;
use File::Spec;
use Test::More tests=>9;

BEGIN { use_ok( 'MARC::File::USMARC' ); }
BEGIN { use_ok( 'MARC::Lint' ); }

FROM_TEXT: {
    my $marc = MARC::Record->new();
    isa_ok( $marc, 'MARC::Record', 'MARC record' );

    $marc->leader("00000nam  22002538a 4500"); 

    my $nfields = $marc->add_fields(
        ['001', 'ttt07000001 '],
        ['003', 'TEST '],
        ['008', '070520s2007    ilu           000 0 eng d',
        ],
        ['040', "", "",
            a => 'TEST',
            c => 'TEST',
         ],
        ['050', "", "4",
            a => 'RZ999',
            b => '.J66 2007',
         ],
        ['082', "0", "4",
            a => '615.8/9',
            2 => '22'
         ],
        [100, "1","", 
            a => "Jones, John.",
        ],
        [245, "1","0",
            6 => "880-02",
            a => "Test 880.",
        ],
        [260, "", "",
            a => "Mount Morris, Ill. :",
            b => "B. Baldus,",
            c => "2007.",
            ],
        [300, "", "",
            a => "1 v. ;",
            c => "23 cm.",
        ],
        [880, "1", "0",
            6 => '245-02/$1',
            a => "<Title in CJK script>.",
        ],
        [880, "1", " ",
            a => "<Jones, John in CJK script>.",
        ],
        [880, "1", " ",
            6 => '500-00/$1',
            c => "<Note in CJK script>.",
        ],
    );
    is( $nfields, 13, "All the fields added OK" );

    my @expected = (
    q{880: No subfield 6.},
    q{500: Indicator 1 must be blank but it's "1"},
    q{500: Subfield _c is not allowed.},
        #q{},
    );

    my $lint = new MARC::Lint;
    isa_ok( $lint, 'MARC::Lint' );

    $lint->check_record( $marc );
    my @warnings = $lint->warnings;
    while ( @warnings ) {
        my $expected = shift @expected;
        my $actual = shift @warnings;

        is( $actual, $expected, "Checking expected messages" );
    }
    is( scalar @expected, 0, "All expected messages exhausted." );
}