Annotation of embedaddon/php/ext/zlib/tests/gzuncompress_error1.phpt, revision 1.1
1.1 ! misho 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:
! 17:
! 18:
! 19: echo "*** Testing gzuncompress() : error conditions ***\n";
! 20:
! 21: // Zero arguments
! 22: echo "\n-- Testing gzuncompress() function with Zero arguments --\n";
! 23: var_dump( gzuncompress() );
! 24:
! 25: //Test gzuncompress with one more than the expected number of arguments
! 26: echo "\n-- Testing gzuncompress() function with more than expected no. of arguments --\n";
! 27: $data = 'string_val';
! 28: $length = 10;
! 29: $extra_arg = 10;
! 30: var_dump( gzuncompress($data, $length, $extra_arg) );
! 31:
! 32:
! 33: echo "\n-- Testing with a buffer that is too small --\n";
! 34: $short_len = strlen($data) - 1;
! 35: $compressed = gzcompress($data);
! 36:
! 37: var_dump(gzuncompress($compressed, $short_len));
! 38:
! 39:
! 40: echo "\n-- Testing with incorrect arguments --\n";
! 41: var_dump(gzuncompress(123));
! 42:
! 43: class Tester {
! 44: function Hello() {
! 45: echo "Hello\n";
! 46: }
! 47: }
! 48:
! 49: $testclass = new Tester();
! 50: var_dump(gzuncompress($testclass));
! 51:
! 52: var_dump(gzuncompress($compressed, "this is not a number\n"));
! 53:
! 54: ?>
! 55: ===DONE===
! 56: --EXPECTF--
! 57: *** Testing gzuncompress() : error conditions ***
! 58:
! 59: -- Testing gzuncompress() function with Zero arguments --
! 60:
! 61: Warning: gzuncompress() expects at least 1 parameter, 0 given in %s on line %d
! 62: NULL
! 63:
! 64: -- Testing gzuncompress() function with more than expected no. of arguments --
! 65:
! 66: Warning: gzuncompress() expects at most 2 parameters, 3 given in %s on line %d
! 67: NULL
! 68:
! 69: -- Testing with a buffer that is too small --
! 70:
! 71: Warning: gzuncompress(): buffer error in %s on line %d
! 72: bool(false)
! 73:
! 74: -- Testing with incorrect arguments --
! 75:
! 76: Warning: gzuncompress(): data error in %s on line %d
! 77: bool(false)
! 78:
! 79: Warning: gzuncompress() expects parameter 1 to be string, object given in %s on line %d
! 80: NULL
! 81:
! 82: Warning: gzuncompress() expects parameter 2 to be long, string given in %s on line %d
! 83: NULL
! 84: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>