3 # This Koha test module is a stub!
4 # Add more tests here!!!
9 use Test
::More tests
=> 10;
12 use_ok
('C4::ClassSortRoutine::LCC');
16 is
(C4
::ClassSortRoutine
::LCC
::get_class_sort_key
(), "", "No arguments returns an empty string");
17 is
(C4
::ClassSortRoutine
::LCC
::get_class_sort_key
('a','b'), "A B", "Arguments 'a','b' return 'A B'");
20 is
(C4
::ClassSortRoutine
::LCC
::get_class_sort_key
(' ','b'), "B", "Arguments ' ','b' return 'B'");
21 is
(C4
::ClassSortRoutine
::LCC
::get_class_sort_key
('a',' '), "A", "Arguments 'a',' ' return 'A'");
22 is
(C4
::ClassSortRoutine
::LCC
::get_class_sort_key
(' ',' '), "", "Arguments ' ',' ' return ''");
24 #'funky cases' based on regex in code
25 is
(C4
::ClassSortRoutine
::LCC
::get_class_sort_key
('.','b'), "", "Arguments '.','b' return ''");
26 is
(C4
::ClassSortRoutine
::LCC
::get_class_sort_key
('....','........'), "", "Arguments '....','........' return ''");
27 is
(C4
::ClassSortRoutine
::LCC
::get_class_sort_key
('.','.'), "", "Arguments '.','.' return ''");
29 # list of example call numbers -- these
30 # are intentionally in the _reverse_ of
31 # the correct sort order
36 'QC145.45 .H4 D65 1998',
37 'QC145 .A57 V.12 1980',
38 'QC100 .U57 NO. 555 1986',
41 my @sorted_call_numbers = map { $_->{call_number
} }
42 sort { $a->{sortkey
} cmp $b->{sortkey
} }
43 map { { call_number
=> $_, sortkey
=> C4
::ClassSortRoutine
::LCC
::get_class_sort_key
($_, '') } }
45 is_deeply
(\
@sorted_call_numbers, [ reverse @call_numbers ], 'LC call numbers sorted in correct order');