File: t_Labels_split_lccn.t

package info (click to toggle)
liblibrary-callnumber-lc-perl 0.23-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 96 kB
  • sloc: perl: 338; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 883 bytes parent folder | download | duplicates (3)
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
#!/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 => 26;

use Library::CallNumber::LC;

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)],
    'J 295.435 K56'        => [qw(J 295.435 K56)],
};

foreach my $lccn (sort keys %$lccns) {
    my @expected = @{$lccns->{$lccn}};
    my @parts = Library::CallNumber::LC->new($lccn)->components;
    ok($lccn, "lccn: $lccn (" . join(" | ", @parts) . ')');
    is(scalar(@parts), scalar(@expected), "$lccn: Correctly produced " . scalar(@expected) . " parts");
    my $i = 0;
    foreach my $unit (@expected) {
      is($parts[$i], $unit, "$lccn: Correctly matched $unit at position $i");
      $i++;
    }
}