Annotation of embedaddon/php/ext/mbstring/tests/mb_ereg_search_xxx.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: mb_ereg_search() stuff
! 3: --SKIPIF--
! 4: <?php
! 5: extension_loaded('mbstring') or die('skip mbstring not available');
! 6: function_exists('mb_ereg_search') or die("skip\n");
! 7: ?>
! 8: --INI--
! 9: output_handler=
! 10: --FILE--
! 11: <?php
! 12: mb_regex_set_options( '' );
! 13:
! 14: $encs = array( 'EUC-JP', 'Shift_JIS', 'SJIS', 'UTF-8' );
! 15:
! 16: function test_search( $test_enc, $str, $look_for, $opt, $in_enc = 'EUC-JP' ) {
! 17: mb_regex_encoding( $test_enc );
! 18: $str = mb_convert_encoding( $str, $test_enc, $in_enc );
! 19: $look_for = mb_convert_encoding( $look_for, $test_enc, $in_enc );
! 20: mb_ereg_search_init( $str, $look_for, $opt );
! 21: while ( mb_ereg_search_pos() ) {
! 22: $regs = mb_ereg_search_getregs();
! 23: array_shift( $regs );
! 24: printf( "(%s) (%d) %s\n", $test_enc, mb_ereg_search_getpos(), mb_convert_encoding( ( is_array( $regs ) ? implode( '-', $regs ): '' ), $in_enc, $test_enc ) );
! 25: }
! 26: }
! 27: function do_tests( $enc, $opt ) {
! 28: test_search( $enc, "¢Ï¡¦ ¡¦¢Ï\n", ' (¡¦?¢Ï¡¦?)[[:space:]]', $opt );
! 29: test_search( $enc, 'abcde abdeabcf anvfabc odu abcd ', '(ab[a-z]+)', $opt );
! 30: }
! 31:
! 32: foreach( $encs as $enc ) {
! 33: do_tests( $enc, '' );
! 34: do_tests( $enc, 'x' );
! 35: }
! 36: ?>
! 37:
! 38: --EXPECT--
! 39: (EUC-JP) (10) ¡¦¢Ï
! 40: (EUC-JP) (5) abcde
! 41: (EUC-JP) (14) abdeabcf
! 42: (EUC-JP) (22) abc
! 43: (EUC-JP) (31) abcd
! 44: (EUC-JP) (5) ¢Ï¡¦
! 45: (EUC-JP) (10) ¡¦¢Ï
! 46: (EUC-JP) (5) abcde
! 47: (EUC-JP) (14) abdeabcf
! 48: (EUC-JP) (22) abc
! 49: (EUC-JP) (31) abcd
! 50: (Shift_JIS) (10) ¡¦¢Ï
! 51: (Shift_JIS) (5) abcde
! 52: (Shift_JIS) (14) abdeabcf
! 53: (Shift_JIS) (22) abc
! 54: (Shift_JIS) (31) abcd
! 55: (Shift_JIS) (5) ¢Ï¡¦
! 56: (Shift_JIS) (10) ¡¦¢Ï
! 57: (Shift_JIS) (5) abcde
! 58: (Shift_JIS) (14) abdeabcf
! 59: (Shift_JIS) (22) abc
! 60: (Shift_JIS) (31) abcd
! 61: (SJIS) (10) ¡¦¢Ï
! 62: (SJIS) (5) abcde
! 63: (SJIS) (14) abdeabcf
! 64: (SJIS) (22) abc
! 65: (SJIS) (31) abcd
! 66: (SJIS) (5) ¢Ï¡¦
! 67: (SJIS) (10) ¡¦¢Ï
! 68: (SJIS) (5) abcde
! 69: (SJIS) (14) abdeabcf
! 70: (SJIS) (22) abc
! 71: (SJIS) (31) abcd
! 72: (UTF-8) (14) ¡¦¢Ï
! 73: (UTF-8) (5) abcde
! 74: (UTF-8) (14) abdeabcf
! 75: (UTF-8) (22) abc
! 76: (UTF-8) (31) abcd
! 77: (UTF-8) (7) ¢Ï¡¦
! 78: (UTF-8) (14) ¡¦¢Ï
! 79: (UTF-8) (5) abcde
! 80: (UTF-8) (14) abdeabcf
! 81: (UTF-8) (22) abc
! 82: (UTF-8) (31) abcd
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>