Bug 23679: fix software error when trying to transfer an unknown barcode
[koha.git] / t / Labels_split_Regex.t
blobe94eaec170e35c948ba74ad2ce677d4afd3e5013
1 #!/usr/bin/perl
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
18 use Modern::Perl;
20 use Test::More tests => 5;
21 use C4::ClassSplitRoutine::RegEx;
23 my $callnumbers = {
24 '830 Han' => [qw{830 Han}],
25 '159.9 (091) Gesh' => [qw{159.9 (091) Gesh}],
26 'J 3 Kin =774' => ['J 3', 'Kin', '=774'],
27 '830 Hil =774 4' => [qw{830 Hil =774 4}],
28 '830 Las=20 4' => [qw{830 Las =20 4}],
31 # Split on spaces and before =
32 # If starts with J or K then do not split the first 2 groups
33 my @regexs = ('s/\s/\n/g', 's/(\s?=)/\n=/g', 's/^(J|K)\n/$1 /');
34 foreach my $cn (sort keys %$callnumbers) {
35 my @parts = C4::ClassSplitRoutine::RegEx::split_callnumber($cn, \@regexs);
36 my @expected = @{$callnumbers->{$cn}};
37 is_deeply(\@parts, \@expected);