Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
# This file is part of Koha. |
4 |
# |
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. |
9 |
# |
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. |
14 |
# |
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>. |
17 |
|
18 |
use Modern::Perl; |
19 |
|
20 |
use Test::More tests => 5; |
21 |
|
22 |
BEGIN { |
23 |
use_ok('Koha::Util::Normalize'); |
24 |
} |
25 |
|
26 |
subtest 'legacy_default() normalizer' => sub { |
27 |
|
28 |
plan tests => 1; |
29 |
|
30 |
my $string = ' .; kY[]:, (l)/E\'"'; |
31 |
|
32 |
is( Koha::Util::Normalize::legacy_default( $string ), 'KY LE', |
33 |
'The \'legacy_default\' normalizer removes: .;:,][)(/\'" and shifts characters upper-case. |
34 |
Also removes spaces from the beginning and ending, and replaces multiple spaces with a single one.' ); |
35 |
}; |
36 |
|
37 |
subtest 'remove_spaces() normalizer' => sub { |
38 |
|
39 |
plan tests => 1; |
40 |
|
41 |
my $string = ' .; kY[]:, (l)/E\'"'; |
42 |
|
43 |
is( Koha::Util::Normalize::remove_spaces( $string ), '.;kY[]:,(l)/E\'"', |
44 |
'The \'remove_spaces\' normalizer removes all spaces' ); |
45 |
}; |
46 |
|
47 |
subtest 'upper_case() normalizer' => sub { |
48 |
|
49 |
plan tests => 1; |
50 |
|
51 |
my $string = ' .; kY[]:, (l)/E\'"'; |
52 |
|
53 |
is( Koha::Util::Normalize::upper_case( $string ), ' .; KY[]:, (L)/E\'"', |
54 |
'The \'upper_case\' normalizer only makes characters upper-case' ); |
55 |
}; |
56 |
|
57 |
subtest 'lower_case() normalizer' => sub { |
58 |
|
59 |
plan tests => 1; |
60 |
|
61 |
my $string = ' .; kY[]:, (l)/E\'"'; |
62 |
|
63 |
is( Koha::Util::Normalize::lower_case( $string ), ' .; ky[]:, (l)/e\'"', |
64 |
'The \'lower_case\' normalizer only makes characters lower-case' ); |
65 |
}; |
66 |
|
67 |
1; |