preg_split_error.phpt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. --TEST--
  2. Test preg_split() function : error conditions - incorrect number of parameters
  3. --FILE--
  4. <?php
  5. /*
  6. * proto array preg_split(string pattern, string subject [, int limit [, int flags]])
  7. * Function is implemented in ext/pcre/php_pcre.c
  8. */
  9. echo "*** Testing preg_split() : error conditions ***\n";
  10. // Zero arguments
  11. echo "\n-- Testing preg_split() function with Zero arguments --\n";
  12. var_dump(preg_split());
  13. //Test preg_split with one more than the expected number of arguments
  14. echo "\n-- Testing preg_split() function with more than expected no. of arguments --\n";
  15. $pattern = '/_/';
  16. $subject = 'string_val';
  17. $limit = 10;
  18. $flags = PREG_SPLIT_NO_EMPTY;
  19. $extra_arg = 10;
  20. var_dump(preg_split($pattern, $subject, $limit, $flags, $extra_arg));
  21. // Testing preg_split withone less than the expected number of arguments
  22. echo "\n-- Testing preg_split() function with less than expected no. of arguments --\n";
  23. $pattern = '/\./';
  24. var_dump(preg_split($pattern));
  25. echo "Done"
  26. ?>
  27. --EXPECTF--
  28. *** Testing preg_split() : error conditions ***
  29. -- Testing preg_split() function with Zero arguments --
  30. Warning: preg_split() expects at least 2 parameters, 0 given in %spreg_split_error.php on line %d
  31. bool(false)
  32. -- Testing preg_split() function with more than expected no. of arguments --
  33. Warning: preg_split() expects at most 4 parameters, 5 given in %spreg_split_error.php on line %d
  34. bool(false)
  35. -- Testing preg_split() function with less than expected no. of arguments --
  36. Warning: preg_split() expects at least 2 parameters, 1 given in %spreg_split_error.php on line %d
  37. bool(false)
  38. Done