Koha/t/Labels_split_lccn.t
Joe Atzberger a3ae0a5628 Test for LCCN splitting.
This test establishes what LCCN splitting is required to do
to be considered successful.  See Bug 2691.

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
2009-03-11 08:37:27 -05:00

35 lines
1.1 KiB
Perl
Executable file

#!/usr/bin/perl
#
# for context, see http://bugs.koha.org/cgi-bin/bugzilla/show_bug.cgi?id=2691
use strict;
use warnings;
use Test::More tests => 44;
BEGIN {
use_ok('C4::Labels');
}
ok(defined C4::Labels::split_lccn, 'C4::Labels::split_lccn defined');
my $lccns = {
'HE8700.7 .P6T44 1983' => [qw(HE 8700.7 .P6 T44 1983)],
'BS2545.E8 H39 1996' => [qw(BS 2545 .E8 H39 1996)],
'NX512.S85 A4 2006' => [qw(NX 512 .S85 A4 2006)],
};
foreach my $lccn (sort keys %$lccns) {
my (@parts, @expected);
ok($lccn, "lccn: $lccn");
ok(@expected = @{$lccns->{$lccn}}, "split expected to produce " . scalar(@expected) . " pieces");
ok(@parts = C4::Labels::split_lccn($lccn), "C4::Labels::split_lccn($lccn)");
ok(scalar(@expected) == scalar(@parts), sprintf("%d of %d pieces produced", scalar(@parts), scalar(@expected)));
my $i = 0;
foreach my $unit (@expected) {
my $part;
ok($part = $parts[$i], "($lccn)[$i] populated: " . (defined($part) ? $part : 'UNDEF'));
ok((defined($part) and $part eq $unit), "($lccn)[$i] matches: $unit");
$i++;
}
}