]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - t/cmp_path.t
update info on my split-view setup, and ask for plugin advice
[git.ikiwiki.info.git] / t / cmp_path.t
1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4 use Test::More tests => 25;
6 BEGIN { use_ok("IkiWiki"); }
8 %config=IkiWiki::defaultconfig();
9 $config{srcdir}=$config{destdir}="/dev/null";
10 IkiWiki::checkconfig();
12 sub test {
13         my ($before, $after) = @_;
15         $IkiWiki::SortSpec::a = $before;
16         $IkiWiki::SortSpec::b = $after;
17         my $r = IkiWiki::SortSpec::cmp_path();
19         if ($before eq $after) {
20                 is($r, 0);
21         }
22         else {
23                 is($r, -1);
24         }
26         $IkiWiki::SortSpec::a = $after;
27         $IkiWiki::SortSpec::b = $before;
28         $r = IkiWiki::SortSpec::cmp_path();
30         if ($before eq $after) {
31                 is($r, 0);
32         }
33         else {
34                 is($r, 1);
35         }
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 }
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");