Annotation of embedaddon/php/ext/zlib/tests/gzuncompress_error1.phpt, revision 1.1.1.2

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>