Annotation of embedaddon/php/ext/zlib/tests/gzreadgzwriteplain.phpt, revision 1.1
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
! 8: $original = str_repeat("hallo php",4096);
! 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");
! 18: $data = gzread($fp, strlen($original));
! 19: if ($data == $original) {
! 20: echo "Strings are equal\n";
! 21: } else {
! 22: echo "Strings are not equal\n";
! 23: var_dump($data);
! 24: }
! 25:
! 26: gzseek($fp, strlen($original) / 2);
! 27: $data = gzread($fp, strlen($original));
! 28:
! 29: var_dump(strlen($data));
! 30: if ($data == substr($original, strlen($original) / 2)) {
! 31: echo "Strings are equal\n";
! 32: } else {
! 33: echo "Strings are not equal\n";
! 34: var_dump($data);
! 35: }
! 36:
! 37: gzclose($fp);
! 38: unlink($filename);
! 39: ?>
! 40: --EXPECT--
! 41: int(36864)
! 42: int(36864)
! 43: Strings are equal
! 44: int(18432)
! 45: Strings are equal
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>