xref: /PHP-5.4/ext/mbstring/tests/mb_split.phpt (revision 4a78652f)
1--TEST--
2mb_split()
3--SKIPIF--
4<?php
5extension_loaded('mbstring') or die('skip mbstring not available');
6function_exists('mb_split') or die("skip mb_split() is not available in this build");
7?>
8--INI--
9mbstring.func_overload=0
10--FILE--
11<?php
12	mb_regex_set_options( '' );
13	mb_regex_encoding( 'EUC-JP' );
14
15	function verify_split( $spliton, $str, $count = 0 )
16	{
17		$result1 = mb_split( $spliton, $str, $count );
18		$result2 = split( $spliton, $str, $count );
19		if ( $result1 == $result2 ) {
20			print "ok\n";
21		} else {
22			print count($result1).'-'.count($result2)."\n";
23		}
24	}
25
26	var_dump( mb_split( b" ", b"a b c d e f g" )
27	          == mb_split( b"[[:space:]]", b"a\nb\tc\nd e f g" ) );
28
29	for ( $i = 0; $i < 5; ++$i ) {
30		verify_split( b" ", b"a\tb\tc\td   e\tf g", $i );
31	}
32
33	for ( $i = 1; $i < 5; ++$i ) {
34		verify_split( b"\xa1\xa1+", b"\xa1\xa1\xa1\xa2\xa2\xa1\xa1\xa1\xa1\xa1\xa1\xa2\xa2\xa1\xa1\xa1", $i );
35	}
36?>
37
38--EXPECTF--
39bool(true)
40
41Deprecated: Function split() is deprecated in %s on line %d
42ok
43
44Deprecated: Function split() is deprecated in %s on line %d
45ok
46
47Deprecated: Function split() is deprecated in %s on line %d
48ok
49
50Deprecated: Function split() is deprecated in %s on line %d
51ok
52
53Deprecated: Function split() is deprecated in %s on line %d
54ok
55
56Deprecated: Function split() is deprecated in %s on line %d
57ok
58
59Deprecated: Function split() is deprecated in %s on line %d
602-2
61
62Deprecated: Function split() is deprecated in %s on line %d
633-3
64
65Deprecated: Function split() is deprecated in %s on line %d
664-4
67
68