Skip to content

Commit

Permalink
Test matching blank indicator (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
nichtich committed Sep 28, 2021
1 parent de846d6 commit 15c4389
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions t/match-blank-indicator.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!perl

use strict;
use warnings;
use Test::More;
use Catmandu qw(importer);

my $mrc = <<'MRC';
<?xml version="1.0" encoding="UTF-8"?>
<marc:collection xmlns:marc="http://www.loc.gov/MARC21/slim">
<marc:record>
<marc:datafield ind1=" " ind2=" " tag="300">
<marc:subfield code="a">__</marc:subfield>
</marc:datafield>
<marc:datafield ind1="1" ind2=" " tag="300">
<marc:subfield code="a">1_</marc:subfield>
</marc:datafield>
<marc:datafield ind1=" " ind2="1" tag="300">
<marc:subfield code="a">_1</marc:subfield>
</marc:datafield>
</marc:record>
</marc:collection>
MRC

my $fix = <<'FIX';
marc_map("003[,]",test.0)
marc_map("003[ ,]",test.1)
marc_map("003[, ]",test.2)
marc_map("003[ , ]",test.3)
retain_field(test)
FIX

my $importer = importer( 'MARC', file => \$mrc, type => 'XML', fix => $fix );
my $record = $importer->first;
note explain $record;

is_deeply $record->{test},
[ [ "__", "1_", "_1" ], [ "__", "_1" ], [ "__", "1_" ], ["__"] ],
"match blank indicators";

done_testing;

0 comments on commit 15c4389

Please sign in to comment.