X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/55cc22939f4ac497cc08f25c51a510a5cddef168..313e85700bb89857b89ff2538fb448185eeabcaf:/t/bestlink.t?ds=inline diff --git a/t/bestlink.t b/t/bestlink.t index ed748b0f2..9358bf376 100755 --- a/t/bestlink.t +++ b/t/bestlink.t @@ -1,24 +1,30 @@ #!/usr/bin/perl use warnings; use strict; -use Test::More tests => 5; +use Test::More tests => 9; + +BEGIN { use_ok("IkiWiki"); } sub test ($$$) { my $page=shift; my $link=shift; my @existing_pages=@{shift()}; - %IkiWiki::links=(); + %IkiWiki::pagecase=(); + %links=(); foreach my $page (@existing_pages) { - $IkiWiki::links{$page}=[]; + $IkiWiki::pagecase{lc $page}=$page; + $links{$page}=[]; } - return IkiWiki::bestlink($page, $link); + return bestlink($page, $link); } -BEGIN { use_ok("IkiWiki"); } - is(test("bar", "foo", ["bar"]), "", "broken link"); is(test("bar", "foo", ["bar", "foo"]), "foo", "simple link"); +is(test("bar", "FoO", ["bar", "foo"]), "foo", "simple link with different input case"); +is(test("bar", "foo", ["bar", "fOo"]), "fOo", "simple link with different page case"); +is(test("bar", "FoO", ["bar", "fOo"]), "fOo", "simple link with different page and input case"); +is(test("bar", "Foo", ["bar", "fOo", "foo", "fOO", "Foo", "fOo"]), "Foo", "in case of ambiguity, like case wins"); is(test("bar", "foo", ["bar", "foo", "bar/foo"]), "bar/foo", "simple subpage link"); is(test("bar", "foo/subpage", ["bar", "foo", "bar/subpage", "foo/subpage"]), "foo/subpage", "cross subpage link");