From a3ae0a562894a83da93f7f5abf3ad28cfb397d06 Mon Sep 17 00:00:00 2001 From: Joe Atzberger Date: Fri, 6 Mar 2009 18:27:50 -0600 Subject: [PATCH] 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 --- t/Labels_split_lccn.t | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 t/Labels_split_lccn.t diff --git a/t/Labels_split_lccn.t b/t/Labels_split_lccn.t new file mode 100755 index 0000000000..1893e9ddab --- /dev/null +++ b/t/Labels_split_lccn.t @@ -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++; + } +} + -- 2.39.5