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>
This commit is contained in:
Joe Atzberger 2009-03-06 18:27:50 -06:00 committed by Henri-Damien LAURENT
parent f37dc3592a
commit 656a55d6b3
1 changed files with 35 additions and 0 deletions

35
t/Labels_split_lccn.t Executable file
View File

@ -0,0 +1,35 @@
#!/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++;
}
}