Annotation of embedaddon/php/ext/iconv/tests/iconv_strpos.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: iconv_strpos()
                      3: --SKIPIF--
                      4: <?php extension_loaded('iconv') or die('skip iconv extension is not available'); ?>
                      5: --INI--
                      6: iconv.internal_charset=ISO-8859-1
                      7: --FILE--
                      8: <?php
                      9: function my_error_handler($errno, $errmsg, $filename, $linenum, $vars)
                     10: {
                     11:        echo "$errno: $errmsg\n";
                     12: }
                     13: set_error_handler('my_error_handler');
                     14: function foo($haystk, $needle, $offset, $to_charset = false, $from_charset = false)
                     15: {
                     16:        if ($from_charset !== false) {
                     17:                $haystk = iconv($from_charset, $to_charset, $haystk);
                     18:        }
                     19:        var_dump(strpos($haystk, $needle, $offset));
                     20:        if ($to_charset !== false) {
                     21:                var_dump(iconv_strpos($haystk, $needle, $offset, $to_charset));
                     22:        } else {
                     23:                var_dump(iconv_strpos($haystk, $needle, $offset));
                     24:        }
                     25: }
                     26: foo("abecdbcdabef", "bcd", -1);
                     27: foo("abecdbcdabef", "bcd", 100000);
                     28: foo("abcabcabcdabcababcdabc", "bcd", 0);
                     29: foo("abcabcabcdabcababcdabc", "bcd", 10);
                     30: foo(str_repeat("abcab", 60)."abcdb".str_repeat("adabc", 60), "abcd", 0);
                     31: foo(str_repeat("あいうえお", 30)."いうおえあ".str_repeat("あいえおう", 30), "うお", 0, "EUC-JP");
                     32: $str = str_repeat("あいうえお", 60).'$'.str_repeat("あいえおう", 60);
                     33: foo($str, '$', 0, "ISO-2022-JP", "EUC-JP");
                     34: 
                     35: var_dump(iconv_strpos("string", ""));
                     36: var_dump(iconv_strpos("", "string"));
                     37: 
                     38: ?>
                     39: --EXPECTF--
                     40: 2: %s
                     41: bool(false)
                     42: 2: %s
                     43: bool(false)
                     44: 2: %s
                     45: bool(false)
                     46: bool(false)
                     47: int(7)
                     48: int(7)
                     49: int(16)
                     50: int(16)
                     51: int(300)
                     52: int(300)
                     53: int(302)
                     54: int(151)
                     55: int(1)
                     56: int(300)
                     57: bool(false)
                     58: bool(false)

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>