gzuncompress_error1.phpt 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. --TEST--
  2. Test gzuncompress() 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 gzuncompress(string data [, int length])
  12. * Description: Unzip a gzip-compressed string
  13. * Source code: ext/zlib/zlib.c
  14. * Alias to functions:
  15. */
  16. echo "*** Testing gzuncompress() : error conditions ***\n";
  17. // Zero arguments
  18. echo "\n-- Testing gzuncompress() function with Zero arguments --\n";
  19. var_dump( gzuncompress() );
  20. //Test gzuncompress with one more than the expected number of arguments
  21. echo "\n-- Testing gzuncompress() function with more than expected no. of arguments --\n";
  22. $data = 'string_val';
  23. $length = 10;
  24. $extra_arg = 10;
  25. var_dump( gzuncompress($data, $length, $extra_arg) );
  26. echo "\n-- Testing with a buffer that is too small --\n";
  27. $short_len = strlen($data) - 1;
  28. $compressed = gzcompress($data);
  29. var_dump(gzuncompress($compressed, $short_len));
  30. echo "\n-- Testing with incorrect arguments --\n";
  31. var_dump(gzuncompress(123));
  32. class Tester {
  33. function Hello() {
  34. echo "Hello\n";
  35. }
  36. }
  37. $testclass = new Tester();
  38. var_dump(gzuncompress($testclass));
  39. var_dump(gzuncompress($compressed, "this is not a number\n"));
  40. ?>
  41. ===DONE===
  42. --EXPECTF--
  43. *** Testing gzuncompress() : error conditions ***
  44. -- Testing gzuncompress() function with Zero arguments --
  45. Warning: gzuncompress() expects at least 1 parameter, 0 given in %s on line %d
  46. NULL
  47. -- Testing gzuncompress() function with more than expected no. of arguments --
  48. Warning: gzuncompress() expects at most 2 parameters, 3 given in %s on line %d
  49. NULL
  50. -- Testing with a buffer that is too small --
  51. Warning: gzuncompress(): insufficient memory in %s on line %d
  52. bool(false)
  53. -- Testing with incorrect arguments --
  54. Warning: gzuncompress(): data error in %s on line %d
  55. bool(false)
  56. Warning: gzuncompress() expects parameter 1 to be string, object given in %s on line %d
  57. NULL
  58. Warning: gzuncompress() expects parameter 2 to be int, string given in %s on line %d
  59. NULL
  60. ===DONE===