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

1.1       misho       1: --TEST--
                      2: gzopen(), gzread(), gzwrite() for non-compressed data
                      3: --SKIPIF--
                      4: <?php # vim600:syn=php:
                      5: if (!extension_loaded("zlib")) print "skip"; ?>
                      6: --FILE--
                      7: <?php
1.1.1.2 ! misho       8: $original = str_repeat(b"hallo php",4096);
1.1       misho       9: $filename = tempnam("/tmp", "phpt");
                     10: 
                     11: $fp = fopen($filename, "wb");
                     12: fwrite($fp, $original);
                     13: var_dump(strlen($original));
                     14: var_dump(ftell($fp));
                     15: fclose($fp);
                     16: 
                     17: $fp = gzopen($filename, "rb");
1.1.1.2 ! misho      18: 
        !            19: $data = '';
        !            20: while ($buf = gzread($fp, 8192)) {
        !            21:        $data .= $buf;
        !            22: }
        !            23: 
1.1       misho      24: if ($data == $original) {
                     25:        echo "Strings are equal\n";
                     26: } else {
                     27:        echo "Strings are not equal\n";
                     28:        var_dump($data);
                     29: }
                     30: 
                     31: gzseek($fp, strlen($original) / 2);
1.1.1.2 ! misho      32: 
        !            33: $data = '';
        !            34: while ($buf = gzread($fp, 8192)) {
        !            35:        $data .= $buf;
        !            36: }
1.1       misho      37: 
                     38: var_dump(strlen($data));
                     39: if ($data == substr($original, strlen($original) / 2)) {
                     40:        echo "Strings are equal\n";
                     41: } else {
                     42:        echo "Strings are not equal\n";
                     43:        var_dump($data);
                     44: }
                     45: 
                     46: gzclose($fp);
                     47: unlink($filename);
                     48: ?>
                     49: --EXPECT--
                     50: int(36864)
                     51: int(36864)
                     52: Strings are equal
                     53: int(18432)
                     54: Strings are equal

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