2006-05-04 20:51:26 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
2019-02-03 12:48:43 +01:00
|
|
|
use Test::More;
|
2006-05-04 20:51:26 +02:00
|
|
|
|
|
|
|
BEGIN { use_ok("IkiWiki"); }
|
|
|
|
|
2019-02-03 12:48:43 +01:00
|
|
|
# pagetitle(x) => XML-escaped form of page title
|
2008-09-27 20:14:36 +02:00
|
|
|
is(pagetitle("foo_bar"), "foo bar");
|
|
|
|
is(pagetitle("foo_bar_baz"), "foo bar baz");
|
|
|
|
is(pagetitle("foo_bar__33__baz"), "foo bar!baz");
|
2019-02-03 12:48:43 +01:00
|
|
|
# Ӓ is U+04D2 CYRILLIC CAPITAL LETTER A WITH DIAERESIS
|
|
|
|
is(pagetitle("foo_bar__1234__baz"), "foo barӒbaz", 'Unicode in BMP');
|
|
|
|
# ≠ is U+2260 NOT EQUAL TO
|
|
|
|
is(pagetitle("foo_bar__8800__baz"), "foo bar≠baz", 'Unicode in BMP');
|
|
|
|
is(pagetitle("foo_bar___33___baz"), "foo bar ! baz", 'Exclamation mark');
|
|
|
|
is(pagetitle("foo_bar___95___baz"), "foo bar _ baz", 'Underscore');
|
2019-02-03 14:07:01 +01:00
|
|
|
is(pagetitle("中文"), "中文", 'Chinese');
|
|
|
|
is(pagetitle("Кириллица"), "Кириллица", 'Cyrillic');
|
2019-02-03 12:48:43 +01:00
|
|
|
# Outside basic multilingual plane: 💩 is U+1F4A9 PILE OF POO
|
|
|
|
is(pagetitle("foo_bar__128169__baz"), "foo bar💩baz", 'Unicode outside BMP');
|
|
|
|
|
|
|
|
# pagetitle(x, false) => same
|
|
|
|
is(pagetitle("foo_bar__33__baz", 0), "foo bar!baz");
|
|
|
|
is(pagetitle("foo_bar__1234__baz", undef), "foo barӒbaz", 'Unicode in BMP');
|
|
|
|
is(pagetitle("foo_bar__8800__baz", undef), "foo bar≠baz", 'Unicode in BMP');
|
|
|
|
is(pagetitle("foo_bar___33___baz", ""), "foo bar ! baz", 'Exclamation mark');
|
|
|
|
is(pagetitle("foo_bar___95___baz", 0), "foo bar _ baz", 'Underscore');
|
2019-02-03 14:07:01 +01:00
|
|
|
is(pagetitle("中文", 0), "中文", 'Chinese');
|
|
|
|
is(pagetitle("Кириллица", 0), "Кириллица", 'Cyrillic');
|
2019-02-03 12:48:43 +01:00
|
|
|
is(pagetitle("foo_bar__128169__baz", 0), "foo bar💩baz", 'Unicode outside BMP');
|
|
|
|
|
|
|
|
# pagetitle(x, true) => unescaped form of page title
|
|
|
|
is(pagetitle("foo_bar", 1), "foo bar");
|
|
|
|
is(pagetitle("foo_bar_baz", 'unescaped'), "foo bar baz");
|
|
|
|
is(pagetitle("foo_bar__33__baz", 42), "foo bar!baz");
|
|
|
|
is(chr(1234), "\x{04D2}");
|
|
|
|
is(pagetitle("foo_bar__1234__baz", 1), "foo bar\x{04D2}baz", 'Unicode in BMP');
|
|
|
|
is(chr(8800), "\x{2260}");
|
|
|
|
is(pagetitle("foo_bar__8800__baz", 1), "foo bar\x{2260}baz", 'Unicode in BMP');
|
|
|
|
is(pagetitle("foo_bar___33___baz", 1), "foo bar ! baz");
|
|
|
|
is(pagetitle("foo_bar___95___baz", 1), "foo bar _ baz");
|
2019-02-03 14:07:01 +01:00
|
|
|
is(pagetitle("中文", 1), "中文", 'Chinese');
|
|
|
|
is(pagetitle("Кириллица", 1), "Кириллица", 'Cyrillic');
|
2019-02-03 12:48:43 +01:00
|
|
|
is(chr(128169), "\x{0001F4A9}");
|
|
|
|
is(pagetitle("foo_bar__128169__baz", 1), "foo bar\x{0001F4A9}baz", 'Unicode outside BMP');
|
|
|
|
|
|
|
|
done_testing;
|