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