gzinflate_error1.phpt 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. --TEST--
  2. Test gzinflate() function : error conditions
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded("zlib")) {
  6. print "skip - ZLIB extension not loaded";
  7. }
  8. ?>
  9. --FILE--
  10. <?php
  11. /* Prototype : string gzinflate(string data [, int length])
  12. * Description: Unzip a gzip-compressed string
  13. * Source code: ext/zlib/zlib.c
  14. * Alias to functions:
  15. */
  16. include(dirname(__FILE__) . '/data.inc');
  17. echo "*** Testing gzinflate() : error conditions ***\n";
  18. echo "\n-- Testing gzcompress() function with Zero arguments --\n";
  19. var_dump( gzinflate() );
  20. echo "\n-- Testing gzcompress() function with more than expected no. of arguments --\n";
  21. $data = 'string_val';
  22. $length = 10;
  23. $extra_arg = 10;
  24. var_dump( gzinflate($data, $length, $extra_arg) );
  25. echo "\n-- Testing with a buffer that is too small --\n";
  26. $short_len = strlen($data) - 1;
  27. $compressed = gzcompress($data);
  28. var_dump(gzinflate($compressed, $short_len));
  29. echo "\n-- Testing with incorrect parameters --\n";
  30. class Tester {
  31. function Hello() {
  32. echo "Hello\n";
  33. }
  34. }
  35. $testclass = new Tester();
  36. var_dump(gzinflate($testclass));
  37. var_dump(gzinflate($data, $testclass));
  38. ?>
  39. ===DONE===
  40. --EXPECTF--
  41. *** Testing gzinflate() : error conditions ***
  42. -- Testing gzcompress() function with Zero arguments --
  43. Warning: gzinflate() expects at least 1 parameter, 0 given in %s on line %d
  44. NULL
  45. -- Testing gzcompress() function with more than expected no. of arguments --
  46. Warning: gzinflate() expects at most 2 parameters, 3 given in %s on line %d
  47. NULL
  48. -- Testing with a buffer that is too small --
  49. Warning: gzinflate(): data error in %s on line %d
  50. bool(false)
  51. -- Testing with incorrect parameters --
  52. Warning: gzinflate() expects parameter 1 to be string, object given in %s on line %d
  53. NULL
  54. Warning: gzinflate() expects parameter 2 to be long, object given in %s on line %d
  55. NULL
  56. ===DONE===