mb_split_error.phpt 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. --TEST--
  2. Test mb_split() function : error conditions
  3. --SKIPIF--
  4. <?php
  5. extension_loaded('mbstring') or die('skip');
  6. function_exists('mb_split') or die("skip mb_split() is not available in this build");
  7. ?>
  8. --FILE--
  9. <?php
  10. /* Prototype : proto array mb_split(string pattern, string string [, int limit])
  11. * Description: split multibyte string into array by regular expression
  12. * Source code: ext/mbstring/php_mbregex.c
  13. * Alias to functions:
  14. */
  15. /*
  16. * test too few and too many parameters
  17. */
  18. echo "*** Testing mb_split() : error conditions ***\n";
  19. //Test mb_split with one more than the expected number of arguments
  20. echo "\n-- Testing mb_split() function with more than expected no. of arguments --\n";
  21. $pattern = ' ';
  22. $string = 'a b c d e f g';
  23. $limit = 0;
  24. $extra_arg = 10;
  25. var_dump( mb_split($pattern, $string, $limit, $extra_arg) );
  26. // Testing mb_split with one less than the expected number of arguments
  27. echo "\n-- Testing mb_split() function with less than expected no. of arguments --\n";
  28. $pattern = 'string_val';
  29. var_dump( mb_split($pattern) );
  30. echo "Done";
  31. ?>
  32. --EXPECTF--
  33. *** Testing mb_split() : error conditions ***
  34. -- Testing mb_split() function with more than expected no. of arguments --
  35. Warning: mb_split() expects at most 3 parameters, 4 given in %s on line %d
  36. bool(false)
  37. -- Testing mb_split() function with less than expected no. of arguments --
  38. Warning: mb_split() expects at least 2 parameters, 1 given in %s on line %d
  39. bool(false)
  40. Done