diff options
Diffstat (limited to 'test/it.t')
-rwxr-xr-x | test/it.t | 54 |
1 files changed, 36 insertions, 18 deletions
@@ -221,15 +221,15 @@ _match( ); _match( - utf8_decode('ö'), utf8_decode('Ö'), - utf8_decode('Ö'), + it::utf8_decode('ö'), it::utf8_decode('Ö'), + it::utf8_decode('Ö'), 'match umlaute in de_CH.latin1 case insensitive', ['utf8' => false] ); _match( - utf8_decode('aöBÜ'), utf8_decode('AÖbü'), - utf8_decode('AÖbü'), + it::utf8_decode('aöBÜ'), it::utf8_decode('AÖbü'), + it::utf8_decode('AÖbü'), "match umlaute with non-utf-8 override in p", ['utf8' => false] ); @@ -270,6 +270,12 @@ _match( ['all' => 1, 'pattern_order' => 1] ); +_match( + preg_quote('a/b!c(d\\e{f$g^h|i??**++'), 'faa/b!c(d\\e{f$g^h|i??**++ar', + 'a/b!c(d\\e{f$g^h|i??**++', + 'match with preg_quote of special characters in pattern' +); + ini_set('default_charset', 'iso-8859-1'); _match( 'aöBÜ', "AÖbü", @@ -388,7 +394,19 @@ _time("152715", it::date('', '15:27:15')); _time("yesterday", it::date('', 'yesterday')); is(it::date('date', '2011-10-25'), '25.10.2011', 'parse date string with strtotime'); -is(it::date('date', '2011-10-25 + 3 days'), '28.10.2011', 'some date arithmetic'); +is(it::date('date', '2011-10-25 + 3 days'), '28.10.2011', 'date arithmetic (add)'); +is(it::date('date', '2011-10-25 - 3 days'), '22.10.2011', 'date arithmetic (subtract)'); +is(it::date('date', '2011-10-25 +-3 days'), '22.10.2011', 'date arithmetic (negative value)'); +is(it::date('date', '2011-10-25 --3 days'), '28.10.2011', 'date arithmetic (double negative)'); +is(it::date('date', '2011-10-25 ++ 3 days'), '28.10.2011', 'date arithmetic (double positive with space)'); +is(it::date('date', '2011-10-25 -+ 3 days'), '22.10.2011', 'date arithmetic (negative positive with space)'); +is(it::date('datetime', '2011-10-25 +12 hours +30 minutes'), '25.10.2011 12:30', 'datetime arithmetic (hours minutes)'); +is(it::date('datetime', '2011-10-25 +24 hours +30 minutes'), '26.10.2011 00:30', 'datetime arithmetic (hours minutes over midnight)'); +is(it::date('datetime', '2011-10-25 8:00 +10 minutes'), '25.10.2011 08:10', 'time arithmetic (add)'); +is(it::date('datetime', '2011-10-25 8:00 -10 minutes'), '25.10.2011 07:50', 'time arithmetic (subtract)'); +is(it::date('datetime', '2011-10-25 8:00 +-10 minutes'), '25.10.2011 07:50', 'time arithmetic (negative value)'); +is(it::date('datetime', '2011-10-25 8:00 --10 minutes'), '25.10.2011 08:10', 'time arithmetic (double negative)'); +is(it::date('datetime', '2011-10-25 --1 month --3 days 8:00 +- 4 hours +-10 minutes'), '28.11.2011 03:50', 'date and time arithmetic (multiple signs)'); is(it::date('datetime', it::time()), it::date('datetime'), 'recognize int as timestamp'); is(it::date('datetime', it::time()*1.0), it::date('datetime'), 'recognize float as timestamp'); is(it::date('datetime', it::time() . ''), it::date('datetime'), 'recognize digit string as timestamp'); @@ -419,32 +437,32 @@ is(grapheme_strlen("\xc1"), null, "need grapheme_strlen side effect for any2utf8 is(it::any2utf8('Meier'), 'Meier', "it::any2utf8 ascii input"); is(it::any2utf8('Müller'), 'Müller', "it::any2utf8 utf8 input"); is(it::any2utf8('Aslı'), 'Aslı', "it::any2utf8 utf8 non-latin1 input"); -is(it::any2utf8(utf8_decode('Müller')), 'Müller', "it::any2utf8 latin1 input"); +is(it::any2utf8(it::utf8_decode('Müller')), 'Müller', "it::any2utf8 latin1 input"); is(it::any2utf8( ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'), # omit soft hyphen cause we filter it ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ', "it::any2utf8 utf8 input (exhaustive alphabet)"); is(it::any2utf8( - utf8_decode(' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ')), + it::utf8_decode(' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ')), ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ', "it::any2utf8 latin1 input (exhaustive alphabet)"); -is(it::any2utf8(utf8_encode("ü")), "ü", "it::any2utf8 double encoding"); +is(it::any2utf8(it::utf8_encode("ü")), "ü", "it::any2utf8 double encoding"); is(it::any2utf8("Meier"), "Meier", "it::any2utf8 ascii"); is(it::any2utf8("Müller"), "Müller", "it::any2utf8 utf-8 latin1"); is(it::any2utf8("Aslı"), "Aslı", "it::any2utf8 utf-8 non-latin1"); is(it::any2utf8("é»"), "é»", "it::any2utf8 utf-8 latin1 special combination"); -is(it::any2utf8(utf8_encode("Müller")), "Müller", "it::any2utf8 doubly encoded utf8"); -is(it::any2utf8(utf8_encode(utf8_encode("Müller"))), "Müller", "it::any2utf8 triply encoded utf8"); -is(it::any2utf8(utf8_decode("Müller")), "Müller", "it::any2utf8 incorrectly encoded latin1"); +is(it::any2utf8(it::utf8_encode("Müller")), "Müller", "it::any2utf8 doubly encoded utf8"); +is(it::any2utf8(it::utf8_encode(it::utf8_encode("Müller"))), "Müller", "it::any2utf8 triply encoded utf8"); +is(it::any2utf8(it::utf8_decode("Müller")), "Müller", "it::any2utf8 incorrectly encoded latin1"); is(it::any2utf8("a💚b"), "a💚b", "it::any2utf8 correctly handles 4-byte utf-8 character GREEN HEART"); -is(it::any2utf8(["foo", utf8_decode("bär")]), ["foo", "bär"], "any2utf8 on arrays"); -is(it::any2utf8(["foo", [utf8_decode("bär")]]), ["foo", ["bär"]], "any2utf8 on recursive arrays"); +is(it::any2utf8(["foo", it::utf8_decode("bär")]), ["foo", "bär"], "any2utf8 on arrays"); +is(it::any2utf8(["foo", [it::utf8_decode("bär")]]), ["foo", ["bär"]], "any2utf8 on recursive arrays"); is(it::any2utf8([1, true, false, null]), [1, true, false, null], "any2utf8 should leave types alone"); -is(it::any2utf8([utf8_decode('Müller') => utf8_decode('Müller')]), ['Müller' => 'Müller'], "it::any2utf8 latin1 keys"); +is(it::any2utf8([it::utf8_decode('Müller') => it::utf8_decode('Müller')]), ['Müller' => 'Müller'], "it::any2utf8 latin1 keys"); is(it::any2utf8("\xc2\xad"), "", "it::any2utf8 remove soft hyphens"); @@ -532,10 +550,10 @@ it::file_put($tmpfile, "bb"); is(it::file_get($tmpfile), "bb"); unlink($tmpfile); -requesturi(utf8_decode("lüönd"), "lüönd"); -requesturi(utf8_decode("ü").utf8_encode("ü"), "üü"); -requesturi(utf8_encode("müller"), "müller"); -requesturi(utf8_encode(utf8_encode("müller")), "müller"); +requesturi(it::utf8_decode("lüönd"), "lüönd"); +requesturi(it::utf8_decode("ü").it::utf8_encode("ü"), "üü"); +requesturi(it::utf8_encode("müller"), "müller"); +requesturi(it::utf8_encode(it::utf8_encode("müller")), "müller"); requesturi("I 💚 Nü York", "I 💚 Nü York"); function requesturi($teststring, $expect) |