aboutsummaryrefslogtreecommitdiff
path: root/t/bestlink.t
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-05-02 21:14:50 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-05-02 21:14:50 +0000
commit55cc22939f4ac497cc08f25c51a510a5cddef168 (patch)
tree60c839f57a8ffa46de1a2667cc984b9c598a99ea /t/bestlink.t
parenta2e98e7ffc50626e6259713094b3b388e8460cd1 (diff)
downloadikiwiki-55cc22939f4ac497cc08f25c51a510a5cddef168.tar
ikiwiki-55cc22939f4ac497cc08f25c51a510a5cddef168.tar.gz
* Add unit tests for several core functions, including globlist_match,
dirname, basename, and bestlink. as plugins and work. (Well, in theory.)
Diffstat (limited to 't/bestlink.t')
-rwxr-xr-xt/bestlink.t24
1 files changed, 24 insertions, 0 deletions
diff --git a/t/bestlink.t b/t/bestlink.t
new file mode 100755
index 000000000..ed748b0f2
--- /dev/null
+++ b/t/bestlink.t
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use Test::More tests => 5;
+
+sub test ($$$) {
+ my $page=shift;
+ my $link=shift;
+ my @existing_pages=@{shift()};
+
+ %IkiWiki::links=();
+ foreach my $page (@existing_pages) {
+ $IkiWiki::links{$page}=[];
+ }
+
+ return IkiWiki::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", "bar/foo"]), "bar/foo", "simple subpage link");
+is(test("bar", "foo/subpage", ["bar", "foo", "bar/subpage", "foo/subpage"]), "foo/subpage", "cross subpage link");