]> sipb.mit.edu Git - ikiwiki.git/blob - t/cmp_path.t
Extract check_cgi_mode_bits(). No change intended.
[ikiwiki.git] / t / cmp_path.t
1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4 use Test::More tests => 25;
5
6 BEGIN { use_ok("IkiWiki"); }
7
8 %config=IkiWiki::defaultconfig();
9 $config{srcdir}=$config{destdir}="/dev/null";
10 IkiWiki::checkconfig();
11
12 sub test {
13         my ($before, $after) = @_;
14
15         $IkiWiki::SortSpec::a = $before;
16         $IkiWiki::SortSpec::b = $after;
17         my $r = IkiWiki::SortSpec::cmp_path();
18
19         if ($before eq $after) {
20                 is($r, 0);
21         }
22         else {
23                 is($r, -1);
24         }
25
26         $IkiWiki::SortSpec::a = $after;
27         $IkiWiki::SortSpec::b = $before;
28         $r = IkiWiki::SortSpec::cmp_path();
29
30         if ($before eq $after) {
31                 is($r, 0);
32         }
33         else {
34                 is($r, 1);
35         }
36
37         is_deeply([IkiWiki::SortSpec::sort_pages(\&IkiWiki::SortSpec::cmp_path, $before, $after)],
38                 [$before, $after]);
39         is_deeply([IkiWiki::SortSpec::sort_pages(\&IkiWiki::SortSpec::cmp_path, $after, $before)],
40                 [$before, $after]);
41 }
42
43 test("a/b/c", "a/b/c");
44 test("a/b", "a/c");
45 test("a/z", "z/a");
46 test("a", "a/b");
47 test("a", "a/b");
48 test("a/z", "ab");