Annotation of embedaddon/php/ext/zlib/tests/gzinflate_error1.phpt, revision 1.1.1.1

1.1       misho       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: 
                     17: include(dirname(__FILE__) . '/data.inc');
                     18: 
                     19: echo "*** Testing gzinflate() : error conditions ***\n";
                     20: 
                     21: echo "\n-- Testing gzcompress() function with Zero arguments --\n";
                     22: var_dump( gzinflate() );
                     23: 
                     24: echo "\n-- Testing gzcompress() function with more than expected no. of arguments --\n";
                     25: $data = 'string_val';
                     26: $length = 10;
                     27: $extra_arg = 10;
                     28: var_dump( gzinflate($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(gzinflate($compressed, $short_len));
                     35: 
                     36: echo "\n-- Testing with incorrect parameters --\n";
                     37: 
                     38: class Tester {
                     39:     function Hello() {
                     40:         echo "Hello\n"; 
                     41:     }
                     42: }
                     43: 
                     44: $testclass = new Tester();
                     45: var_dump(gzinflate($testclass));
                     46: var_dump(gzinflate($data, $testclass));
                     47: 
                     48: ?>
                     49: ===DONE===
                     50: --EXPECTF--
                     51: *** Testing gzinflate() : error conditions ***
                     52: 
                     53: -- Testing gzcompress() function with Zero arguments --
                     54: 
                     55: Warning: gzinflate() expects at least 1 parameter, 0 given in %s on line %d
                     56: NULL
                     57: 
                     58: -- Testing gzcompress() function with more than expected no. of arguments --
                     59: 
                     60: Warning: gzinflate() expects at most 2 parameters, 3 given in %s on line %d
                     61: NULL
                     62: 
                     63: -- Testing with a buffer that is too small --
                     64: 
                     65: Warning: gzinflate(): data error in %s on line %d
                     66: bool(false)
                     67: 
                     68: -- Testing with incorrect parameters --
                     69: 
                     70: Warning: gzinflate() expects parameter 1 to be string, object given in %s on line %d
                     71: NULL
                     72: 
                     73: Warning: gzinflate() expects parameter 2 to be long, object given in %s on line %d
                     74: NULL
                     75: ===DONE===

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