mirror of
https://github.com/php/php-src.git
synced 2024-11-28 20:34:29 +08:00
MFB: zlib stream tests
This commit is contained in:
parent
5029c73096
commit
ca6b002e4c
33
ext/zlib/tests/gzreadgzwrite.phpt
Normal file
33
ext/zlib/tests/gzreadgzwrite.phpt
Normal file
@ -0,0 +1,33 @@
|
||||
--TEST--
|
||||
gzopen(), gzread(), gzwrite()
|
||||
--SKIPIF--
|
||||
<?php # vim600:syn=php:
|
||||
if (!extension_loaded("zlib")) print "skip"; ?>
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php
|
||||
$original = str_repeat("hallo php",4096);
|
||||
$filename = tempnam("/tmp", "phpt");
|
||||
|
||||
$fp = gzopen($filename, "wb");
|
||||
gzwrite($fp, $original);
|
||||
var_dump(strlen($original));
|
||||
var_dump(gztell($fp));
|
||||
fclose($fp);
|
||||
|
||||
$fp = gzopen($filename, "rb");
|
||||
$data = gzread($fp, strlen($original));
|
||||
if ($data == $original) {
|
||||
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
|
47
ext/zlib/tests/gzreadgzwriteplain.phpt
Normal file
47
ext/zlib/tests/gzreadgzwriteplain.phpt
Normal file
@ -0,0 +1,47 @@
|
||||
--TEST--
|
||||
gzopen(), gzread(), gzwrite() for non-compressed data
|
||||
--SKIPIF--
|
||||
<?php # vim600:syn=php:
|
||||
if (!extension_loaded("zlib")) print "skip"; ?>
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php
|
||||
$original = str_repeat("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 = gzread($fp, strlen($original));
|
||||
if ($data == $original) {
|
||||
echo "Strings are equal\n";
|
||||
} else {
|
||||
echo "Strings are not equal\n";
|
||||
var_dump($data);
|
||||
}
|
||||
|
||||
gzseek($fp, strlen($original) / 2);
|
||||
$data = gzread($fp, strlen($original));
|
||||
|
||||
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
|
Loading…
Reference in New Issue
Block a user