mb_split.phpt 983 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --TEST--
  2. mb_split()
  3. --EXTENSIONS--
  4. mbstring
  5. --SKIPIF--
  6. <?php
  7. function_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. function verify_split( $spliton, $str, $count = 0 )
  14. {
  15. $result1 = mb_split( $spliton, $str, $count );
  16. $result2 = preg_split( "/$spliton/", $str, $count );
  17. if ( $result1 == $result2 ) {
  18. print "ok\n";
  19. } else {
  20. print count($result1).'-'.count($result2)."\n";
  21. }
  22. }
  23. var_dump( mb_split( " ", "a b c d e f g" )
  24. == mb_split( "[[:space:]]", "a\nb\tc\nd e f g" ) );
  25. for ( $i = 1; $i < 5; ++$i ) {
  26. verify_split( " ", "a\tb\tc\td e\tf g", $i );
  27. }
  28. for ( $i = 1; $i < 5; ++$i ) {
  29. verify_split( "\xa1\xa1+", "\xa1\xa1\xa1\xa2\xa2\xa1\xa1\xa1\xa1\xa1\xa1\xa2\xa2\xa1\xa1\xa1", $i );
  30. }
  31. ?>
  32. --EXPECT--
  33. bool(true)
  34. ok
  35. ok
  36. ok
  37. ok
  38. ok
  39. 2-2
  40. 3-3
  41. 4-4