2006-05-02 23:14:50 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
2007-01-06 05:22:46 +01:00
|
|
|
use Test::More tests => 11;
|
2006-05-02 23:14:50 +02:00
|
|
|
|
2006-09-10 00:50:27 +02:00
|
|
|
BEGIN { use_ok("IkiWiki"); }
|
|
|
|
|
2006-05-02 23:14:50 +02:00
|
|
|
sub test ($$$) {
|
|
|
|
my $page=shift;
|
|
|
|
my $link=shift;
|
|
|
|
my @existing_pages=@{shift()};
|
|
|
|
|
2006-08-13 04:03:43 +02:00
|
|
|
%IkiWiki::pagecase=();
|
2006-09-10 00:50:27 +02:00
|
|
|
%links=();
|
2007-01-06 05:22:46 +01:00
|
|
|
$IkiWiki::config{userdir}="foouserdir";
|
2006-05-02 23:14:50 +02:00
|
|
|
foreach my $page (@existing_pages) {
|
2006-08-13 04:03:43 +02:00
|
|
|
$IkiWiki::pagecase{lc $page}=$page;
|
2006-09-10 00:50:27 +02:00
|
|
|
$links{$page}=[];
|
2006-05-02 23:14:50 +02:00
|
|
|
}
|
|
|
|
|
2006-09-10 00:50:27 +02:00
|
|
|
return bestlink($page, $link);
|
2006-05-02 23:14:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
is(test("bar", "foo", ["bar"]), "", "broken link");
|
|
|
|
is(test("bar", "foo", ["bar", "foo"]), "foo", "simple link");
|
2006-08-13 04:03:43 +02:00
|
|
|
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");
|
2006-08-13 04:08:42 +02:00
|
|
|
is(test("bar", "Foo", ["bar", "fOo", "foo", "fOO", "Foo", "fOo"]), "Foo", "in case of ambiguity, like case wins");
|
2006-05-02 23:14:50 +02:00
|
|
|
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");
|
2007-01-06 05:22:46 +01:00
|
|
|
is(test("bar", "bob", ["bar", "foo", "foouserdir/bob"]), "foouserdir/bob", "user link");
|
|
|
|
is(test("bar", "bob", ["bar", "foo", "bob", "foouserdir/bob"]), "bob", "non-user link");
|