File: dosEOF.t

package info (click to toggle)
libmarc-record-perl 2.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 516 kB
  • ctags: 120
  • sloc: perl: 2,573; makefile: 2
file content (92 lines) | stat: -rwxr-xr-x 3,009 bytes parent folder | download | duplicates (6)
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
87
88
89
90
91
92
#!perl -Tw

=head2 NAME

DOS EOF test -- tests modification to MARC::File::USMARC to remove/ignore \x1a
from MARC files.

=head2 DESCRIPTION

Checks t/sample1eof.usmarc and cameleof.usmarc, which are just sample1.usmarc
with \x1a added as a final character, and cameleof.usmarc with \x1a added
between some records.


Prior to the change, MARC::File::USMARC should report
1..12
ok 1 - use MARC::File::USMARC;
ok 2 - Test record 1 in file sample1eof.usmarc
not ok 3 - Test record 2 in file sample1eof.usmarc
#     Failed test ([path_to_test_file] at line 58)
#          got: 'Record length "\x1a" is not numeric in record 2'
#     expected: undef
ok 4 - Test record 1 in file cameleof.usmarc
not ok 5 - Test record 2 in file cameleof.usmarc
#     Failed test ([path_to_test_file] at line 58)
#          got: 'Record length "\x1a0064" is not numeric in record 2'
#     expected: undef
ok 6 - Test record 3 in file cameleof.usmarc
ok 7 - Test record 4 in file cameleof.usmarc
not ok 8 - Test record 5 in file cameleof.usmarc
#     Failed test ([path_to_test_file] at line 58)
#          got: 'Record length "\x1a0080" is not numeric in record 5'
#     expected: undef
ok 9 - Test record 6 in file cameleof.usmarc
ok 10 - Test record 7 in file cameleof.usmarc
not ok 11 - Test record 8 in file cameleof.usmarc
#     Failed test ([path_to_test_file] at line 58)
#          got: 'Record length "\x1a0066" is not numeric in record 8'
#     expected: undef
ok 12 - Test record 9 in file cameleof.usmarc
ok 13 - Test record 10 in file cameleof.usmarc
# Looks like you planned 12 tests but ran 1 extra.

In the output above, I changed the EOF character to \x1a to prevent possible
problems a real EOF may have caused. [path_to_test_file] will be dosEOF.t plus
the path to the test file.

The revised version should report:
1..12
ok 1 - use MARC::File::USMARC;
ok 2 - Test record 1 in file sample1eof.usmarc
ok 3 - Test record 1 in file cameleof.usmarc
ok 4 - Test record 2 in file cameleof.usmarc
ok 5 - Test record 3 in file cameleof.usmarc
ok 6 - Test record 4 in file cameleof.usmarc
ok 7 - Test record 5 in file cameleof.usmarc
ok 8 - Test record 6 in file cameleof.usmarc
ok 9 - Test record 7 in file cameleof.usmarc
ok 10 - Test record 8 in file cameleof.usmarc
ok 11 - Test record 9 in file cameleof.usmarc
ok 12 - Test record 10 in file cameleof.usmarc

=cut

use strict;

use File::Spec;

use Test::More tests=>12;

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

my @expected = (undef)x11;

foreach my $file ( 'sample1eof.usmarc', 'cameleof.usmarc' ) {

    my $filename = File::Spec->catfile( 't', $file );

    my $marcfile = MARC::File::USMARC->in( $filename ) or die "Can not open file $filename, $!";

    my $reccount = 0;

    while ( my $marc = $marcfile->next() ) {
        $reccount++;
        my @warnings = $marc->warnings();
        my $expected = shift @expected;
        my $warns = shift @warnings;
        is($warns, $expected, "Test record $reccount in file $file");

    } #while

} #foreach file