xref: /php-src/ext/mbstring/tests/mb_split.phpt (revision 39131219)
1--TEST--
2mb_split()
3--EXTENSIONS--
4mbstring
5--SKIPIF--
6<?php
7function_exists('mb_split') or die("skip mb_split() is not available in this build");
8?>
9--FILE--
10<?php
11    mb_regex_set_options( '' );
12    mb_regex_encoding( 'EUC-JP' );
13
14    function verify_split( $spliton, $str, $count = 0 )
15    {
16        $result1 = mb_split( $spliton, $str, $count );
17        $result2 = preg_split( "/$spliton/", $str, $count );
18        if ( $result1 == $result2 ) {
19            print "ok\n";
20        } else {
21            print count($result1).'-'.count($result2)."\n";
22        }
23    }
24
25    var_dump( mb_split( " ", "a b c d e f g" )
26              == mb_split( "[[:space:]]", "a\nb\tc\nd e f g" ) );
27
28    for ( $i = 1; $i < 5; ++$i ) {
29        verify_split( " ", "a\tb\tc\td   e\tf g", $i );
30    }
31
32    for ( $i = 1; $i < 5; ++$i ) {
33        verify_split( "\xa1\xa1+", "\xa1\xa1\xa1\xa2\xa2\xa1\xa1\xa1\xa1\xa1\xa1\xa2\xa2\xa1\xa1\xa1", $i );
34    }
35?>
36--EXPECT--
37bool(true)
38ok
39ok
40ok
41ok
42ok
432-2
443-3
454-4
46