File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / zlib / tests / gzreadgzwriteplain.phpt
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:34:37 2012 UTC (12 years, 5 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, HEAD
php 5.4.3+patches

--TEST--
gzopen(), gzread(), gzwrite() for non-compressed data
--SKIPIF--
<?php # vim600:syn=php:
if (!extension_loaded("zlib")) print "skip"; ?>
--FILE--
<?php
$original = str_repeat(b"hallo php",4096);
$filename = tempnam("/tmp", "phpt");

$fp = fopen($filename, "wb");
fwrite($fp, $original);
var_dump(strlen($original));
var_dump(ftell($fp));
fclose($fp);

$fp = gzopen($filename, "rb");

$data = '';
while ($buf = gzread($fp, 8192)) {
	$data .= $buf;
}

if ($data == $original) {
	echo "Strings are equal\n";
} else {
	echo "Strings are not equal\n";
	var_dump($data);
}

gzseek($fp, strlen($original) / 2);

$data = '';
while ($buf = gzread($fp, 8192)) {
	$data .= $buf;
}

var_dump(strlen($data));
if ($data == substr($original, strlen($original) / 2)) {
	echo "Strings are equal\n";
} else {
	echo "Strings are not equal\n";
	var_dump($data);
}

gzclose($fp);
unlink($filename);
?>
--EXPECT--
int(36864)
int(36864)
Strings are equal
int(18432)
Strings are equal

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