import zend zlib tests

Esse commit está contido em:
Paul Tarjan
2013-04-23 16:40:53 -07:00
commit de Sara Golemon
commit 2980d466f2
284 arquivos alterados com 5564 adições e 1 exclusões
+30
Ver Arquivo
@@ -0,0 +1,30 @@
<?php
var_dump(gzcompress());
var_dump(gzcompress("", 1000));
var_dump(gzcompress("", -1));
var_dump(gzcompress(""));
var_dump(gzcompress("", 9));
$string = "Answer me, it can't be so hard
Cry to relieve what's in your heart
Desolation, grief and agony";
var_dump($data1 = gzcompress($string));
var_dump($data2 = gzcompress($string, 9));
var_dump(gzuncompress());
var_dump(gzuncompress("", 1000));
var_dump(gzuncompress("", -1));
var_dump(gzuncompress(""));
var_dump(gzuncompress("", 9));
var_dump(gzuncompress($data1));
var_dump(gzuncompress($data2));
$data2{4} = 0;
var_dump(gzuncompress($data2));
echo "Done\n";
?>
+28
Ver Arquivo
@@ -0,0 +1,28 @@
HipHop Warning: %a
NULL
HipHop Warning: %a
bool(false)
string(%d) "%a"
string(%d) "%a"
string(%d) "%a"
string(%d) "%a"
string(%d) "%a"
HipHop Warning: %a
NULL
HipHop Warning: %a
bool(false)
HipHop Warning: %a
bool(false)
HipHop Warning: %a
bool(false)
HipHop Warning: %a
bool(false)
string(94) "Answer me, it can't be so hard
Cry to relieve what's in your heart
Desolation, grief and agony"
string(94) "Answer me, it can't be so hard
Cry to relieve what's in your heart
Desolation, grief and agony"
HipHop Warning: %a
bool(false)
Done
+31
Ver Arquivo
@@ -0,0 +1,31 @@
<?php
var_dump(gzdeflate());
var_dump(gzdeflate("", 1000));
var_dump(gzdeflate("", -1));
var_dump(gzdeflate(""));
var_dump(gzdeflate("", 9));
$string = "Answer me, it can't be so hard
Cry to relieve what's in your heart
Desolation, grief and agony";
var_dump($data1 = gzdeflate($string));
var_dump($data2 = gzdeflate($string, 9));
var_dump(gzinflate());
var_dump(gzinflate(""));
var_dump(gzinflate("asfwe", 1000));
var_dump(gzinflate("asdf", -1));
var_dump(gzinflate("asdf"));
var_dump(gzinflate("asdf", 9));
var_dump(gzinflate($data1));
var_dump(gzinflate($data2));
$data2{4} = 0;
var_dump(gzinflate($data2));
echo "Done\n";
?>
+30
Ver Arquivo
@@ -0,0 +1,30 @@
HipHop Warning: %a
NULL
HipHop Warning: %a
bool(false)
string(%d) "%a"
string(%d) "%a"
string(%d) "%a"
string(%d) "%a"
string(%d) "%a"
HipHop Warning: %a
NULL
HipHop Warning: %a
bool(false)
HipHop Warning: %a
bool(false)
HipHop Warning: %a
bool(false)
HipHop Warning: %a
bool(false)
HipHop Warning: %a
bool(false)
string(94) "Answer me, it can't be so hard
Cry to relieve what's in your heart
Desolation, grief and agony"
string(94) "Answer me, it can't be so hard
Cry to relieve what's in your heart
Desolation, grief and agony"
HipHop Warning: %a
bool(false)
Done
+23
Ver Arquivo
@@ -0,0 +1,23 @@
<?php
var_dump(gzencode());
var_dump(gzencode(1,1,1,1));
var_dump(gzencode("", -10));
var_dump(gzencode("", 100));
var_dump(gzencode("", 1, 100));
var_dump(gzencode("", -1, ZLIB_ENCODING_GZIP));
var_dump(gzencode("", 9, ZLIB_ENCODING_DEFLATE));
$string = "Light of my sun
Light in this temple
Light in my truth
Lies in the darkness";
var_dump(gzencode($string, 9, 3));
var_dump(gzencode($string, -1, ZLIB_ENCODING_GZIP));
var_dump(gzencode($string, 9, ZLIB_ENCODING_DEFLATE));
echo "Done\n";
?>
+17
Ver Arquivo
@@ -0,0 +1,17 @@
HipHop Warning: %a
NULL
HipHop Warning: %a
NULL
HipHop Warning: %a
bool(false)
HipHop Warning: %a
bool(false)
HipHop Warning: %a
bool(false)
string(%d) "%s"
string(%d) "%s"
HipHop Warning: %a
bool(false)
string(%d) "%s"
string(%d) "%s"
Done
+12
Ver Arquivo
@@ -0,0 +1,12 @@
<?php
ob_start('ob_gzhandler');
echo "Hi there.\n";
ob_flush();
flush();
echo "This is confusing...\n";
ob_flush();
flush();
?>
DONE
@@ -0,0 +1,3 @@
Hi there.
This is confusing...
DONE
@@ -0,0 +1,15 @@
<?php
chdir(dirname(__FILE__). "/../../..");
$pfx = str_repeat('../', substr_count($_SERVER['PHP_SELF'], '../'));
// Relative path
$fp = fopen("compress.zlib://{$pfx}ext/xsl/tests/xslt.xsl.gz", "rb");
fclose($fp);
// Absolute path
$fp = fopen("compress.zlib://". dirname(__FILE__). "/../../../ext/xsl/tests/xslt.xsl.gz", "rb");
fclose($fp);
echo "ok\n";
?>
@@ -0,0 +1 @@
ok
@@ -0,0 +1,16 @@
<?php
$f = dirname(__FILE__)."/004.txt.gz";
$h = gzopen($f, 'r');
$extra_arg = 'nothing';
var_dump(gzclose( $h, $extra_arg ) );
var_dump(gzclose());
gzclose($h);
?>
===DONE===
@@ -0,0 +1,5 @@
HipHop Warning: %a
bool(false)
HipHop Warning: %a
bool(false)
===DONE===
@@ -0,0 +1,44 @@
<?php
/* Prototype : string gzcompress(string data [, int level, [int encoding]])
* Description: Gzip-compress a string
* Source code: ext/zlib/zlib.c
* Alias to functions:
*/
/*
* add a comment here to say what the test is supposed to do
*/
include(dirname(__FILE__) . '/data.inc');
echo "*** Testing gzcompress() : basic functionality ***\n";
// Initialise all required variables
$smallstring = "A small string to compress\n";
// Calling gzcompress() with all possible arguments
// Compressing a big string
for($i = -1; $i < 10; $i++) {
echo "-- Compression level $i --\n";
$output = gzcompress($data, $i);
var_dump(md5($output));
var_dump(strcmp(gzuncompress($output), $data));
}
// Compressing a smaller string
for($i = -1; $i < 10; $i++) {
echo "-- Compression level $i --\n";
$output = gzcompress($smallstring, $i);
var_dump(bin2hex($output));
var_dump(strcmp(gzuncompress($output), $smallstring));
}
// Calling gzcompress() with mandatory arguments
echo "\n-- Testing with no specified compression level --\n";
var_dump( bin2hex(gzcompress($smallstring) ));
?>
===Done===
@@ -0,0 +1,71 @@
*** Testing gzcompress() : basic functionality ***
-- Compression level -1 --
string(32) "764809aef15bb34cb73ad49ecb600d99"
int(0)
-- Compression level 0 --
string(32) "d0136b3fb5424142c0eb26dfec8f56fe"
int(0)
-- Compression level 1 --
string(32) "c2e070f4320d1f674965eaab95b53d9c"
int(0)
-- Compression level 2 --
string(32) "36922f486410d08209d0d0d21b26030e"
int(0)
-- Compression level 3 --
string(32) "a441a2f5169bb303cd45b860a5a9dbf9"
int(0)
-- Compression level 4 --
string(32) "d5b7451e9de2864beccc9de1fc55eb87"
int(0)
-- Compression level 5 --
string(32) "32ba4a01120449ec25508cabfad41f56"
int(0)
-- Compression level 6 --
string(32) "764809aef15bb34cb73ad49ecb600d99"
int(0)
-- Compression level 7 --
string(32) "e083e7e8d05471fed3c2182b9cd0d9eb"
int(0)
-- Compression level 8 --
string(32) "e083e7e8d05471fed3c2182b9cd0d9eb"
int(0)
-- Compression level 9 --
string(32) "e083e7e8d05471fed3c2182b9cd0d9eb"
int(0)
-- Compression level -1 --
string(70) "789c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
int(0)
-- Compression level 0 --
string(76) "7801011b00e4ff4120736d616c6c20737472696e6720746f20636f6d70726573730a87a509cb"
int(0)
-- Compression level 1 --
string(70) "7801735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
int(0)
-- Compression level 2 --
string(70) "785e735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
int(0)
-- Compression level 3 --
string(70) "785e735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
int(0)
-- Compression level 4 --
string(70) "785e735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
int(0)
-- Compression level 5 --
string(70) "785e735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
int(0)
-- Compression level 6 --
string(70) "789c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
int(0)
-- Compression level 7 --
string(70) "78da735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
int(0)
-- Compression level 8 --
string(70) "78da735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
int(0)
-- Compression level 9 --
string(70) "78da735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
int(0)
-- Testing with no specified compression level --
string(70) "789c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
===Done===
@@ -0,0 +1,47 @@
<?php
/* Prototype : string gzcompress(string data [, int level, [int encoding]])
* Description: Gzip-compress a string
* Source code: ext/zlib/zlib.c
* Alias to functions:
*/
/*
* add a comment here to say what the test is supposed to do
*/
echo "*** Testing gzcompress() : error conditions ***\n";
// Zero arguments
echo "\n-- Testing gzcompress() function with Zero arguments --\n";
var_dump( gzcompress() );
//Test gzcompress with one more than the expected number of arguments
echo "\n-- Testing gzcompress() function with more than expected no. of arguments --\n";
$data = 'string_val';
$level = 2;
$encoding = ZLIB_ENCODING_RAW;
$extra_arg = 10;
var_dump( gzcompress($data, $level, $encoding, $extra_arg) );
echo "\n-- Testing with incorrect compression level --\n";
$bad_level = 99;
var_dump(gzcompress($data, $bad_level));
echo "\n-- Testing with invalid encoding --\n";
$data = 'string_val';
$encoding = 99;
var_dump(gzcompress($data, $level, $encoding));
echo "\n-- Testing with incorrect parameters --\n";
class Tester {
function Hello() {
echo "Hello\n";
}
}
$testclass = new Tester();
var_dump(gzcompress($testclass));
?>
===Done===
@@ -0,0 +1,22 @@
*** Testing gzcompress() : error conditions ***
-- Testing gzcompress() function with Zero arguments --
HipHop Warning: %a
NULL
-- Testing gzcompress() function with more than expected no. of arguments --
HipHop Warning: %a
NULL
-- Testing with incorrect compression level --
HipHop Warning: %a
bool(false)
-- Testing with invalid encoding --
HipHop Warning: %a
bool(false)
-- Testing with incorrect parameters --
HipHop Warning: %a
NULL
===Done===
@@ -0,0 +1,18 @@
<?php
/* Prototype : string gzcompress(string data [, int level, [int encoding]])
* Description: Gzip-compress a string
* Source code: ext/zlib/zlib.c
* Alias to functions:
*/
include(dirname(__FILE__) . '/data.inc');
echo "*** Testing gzcompress() : variation ***\n";
echo "\n-- Testing multiple compression --\n";
$output = gzcompress($data);
var_dump( md5($output));
var_dump(md5(gzcompress($output)));
?>
===Done===
@@ -0,0 +1,6 @@
*** Testing gzcompress() : variation ***
-- Testing multiple compression --
string(32) "764809aef15bb34cb73ad49ecb600d99"
string(32) "eba942bc2061f23ea8688cc5101872a4"
===Done===
@@ -0,0 +1,44 @@
<?php
/* Prototype : string gzdeflate(string data [, int level, [int encoding]])
* Description: Gzip-compress a string
* Source code: ext/zlib/zlib.c
* Alias to functions:
*/
/*
* add a comment here to say what the test is supposed to do
*/
include(dirname(__FILE__) . '/data.inc');
echo "*** Testing gzdeflate() : basic functionality ***\n";
// Initialise all required variables
$smallstring = "A small string to compress\n";
// Calling gzdeflate() with all possible arguments
// Compressing a big string
for($i = -1; $i < 10; $i++) {
echo "-- Compression level $i --\n";
$output = gzdeflate($data, $i);
var_dump(md5($output));
var_dump(strcmp(gzinflate($output), $data));
}
// Compressing a smaller string
for($i = -1; $i < 10; $i++) {
echo "-- Compression level $i --\n";
$output = gzdeflate($smallstring, $i);
var_dump(bin2hex($output));
var_dump(strcmp(gzinflate($output), $smallstring));
}
// Calling gzdeflate() with just mandatory arguments
echo "\n-- Testing with no specified compression level --\n";
var_dump( bin2hex(gzdeflate($smallstring) ));
?>
===Done===
@@ -0,0 +1,71 @@
*** Testing gzdeflate() : basic functionality ***
-- Compression level -1 --
string(32) "078554fe65e06f6ff01eab51cfc7ae9b"
int(0)
-- Compression level 0 --
string(32) "a71e54d2499aff9e48643cb1c260b60c"
int(0)
-- Compression level 1 --
string(32) "05e80f4dc0d422e1f333cbed555d381f"
int(0)
-- Compression level 2 --
string(32) "0fb33656e4ed0750f977df83246fce7a"
int(0)
-- Compression level 3 --
string(32) "bc6e9c1dccc3e951e006315ee669ee08"
int(0)
-- Compression level 4 --
string(32) "a61727d7a28c634470eb6e97a4a81b24"
int(0)
-- Compression level 5 --
string(32) "a2a1a14b7542c82e8943200d093d5f27"
int(0)
-- Compression level 6 --
string(32) "078554fe65e06f6ff01eab51cfc7ae9b"
int(0)
-- Compression level 7 --
string(32) "078554fe65e06f6ff01eab51cfc7ae9b"
int(0)
-- Compression level 8 --
string(32) "078554fe65e06f6ff01eab51cfc7ae9b"
int(0)
-- Compression level 9 --
string(32) "078554fe65e06f6ff01eab51cfc7ae9b"
int(0)
-- Compression level -1 --
string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200"
int(0)
-- Compression level 0 --
string(64) "011b00e4ff4120736d616c6c20737472696e6720746f20636f6d70726573730a"
int(0)
-- Compression level 1 --
string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200"
int(0)
-- Compression level 2 --
string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200"
int(0)
-- Compression level 3 --
string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200"
int(0)
-- Compression level 4 --
string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200"
int(0)
-- Compression level 5 --
string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200"
int(0)
-- Compression level 6 --
string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200"
int(0)
-- Compression level 7 --
string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200"
int(0)
-- Compression level 8 --
string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200"
int(0)
-- Compression level 9 --
string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200"
int(0)
-- Testing with no specified compression level --
string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200"
===Done===
@@ -0,0 +1,46 @@
<?php
/* Prototype : string gzdeflate(string data [, int level, [int encoding]])
* Description: Gzip-compress a string
* Source code: ext/zlib/zlib.c
* Alias to functions:
*/
/*
* add a comment here to say what the test is supposed to do
*/
echo "*** Testing gzdeflate() : error conditions ***\n";
// Zero arguments
echo "\n-- Testing gzdeflate() function with Zero arguments --\n";
var_dump( gzdeflate() );
//Test gzdeflate with one more than the expected number of arguments
echo "\n-- Testing gzdeflate() function with more than expected no. of arguments --\n";
$data = 'string_val';
$level = 2;
$encoding = ZLIB_ENCODING_RAW;
$extra_arg = 10;
var_dump( gzdeflate($data, $level, $encoding, $extra_arg) );
echo "\n-- Testing with incorrect compression level --\n";
$bad_level = 99;
var_dump(gzdeflate($data, $bad_level));
echo "\n-- Testing with incorrect encoding --\n";
$bad_encoding = 99;
var_dump(gzdeflate($data, $level, $bad_encoding));
class Tester {
function Hello() {
echo "Hello\n";
}
}
echo "\n-- Testing with incorrect parameters --\n";
$testclass = new Tester();
var_dump(gzdeflate($testclass));
var_dump(gzdeflate($data, $testclass));
?>
===Done===
@@ -0,0 +1,24 @@
*** Testing gzdeflate() : error conditions ***
-- Testing gzdeflate() function with Zero arguments --
HipHop Warning: %a
NULL
-- Testing gzdeflate() function with more than expected no. of arguments --
HipHop Warning: %a
NULL
-- Testing with incorrect compression level --
HipHop Warning: %a
bool(false)
-- Testing with incorrect encoding --
HipHop Warning: %a
bool(false)
-- Testing with incorrect parameters --
HipHop Warning: %a
NULL
HipHop Warning: %a
NULL
===Done===
@@ -0,0 +1,20 @@
<?php
/* Prototype : string gzdeflate(string data [, int level])
* Description: Gzip-compress a string
* Source code: ext/zlib/zlib.c
* Alias to functions:
*/
include(dirname(__FILE__) . '/data.inc');
echo "*** Testing gzdeflate() : variation ***\n";
echo "\n-- Testing multiple compression --\n";
$output = gzdeflate($data);
var_dump( md5($output));
var_dump(md5(gzdeflate($output)));
?>
===Done===
@@ -0,0 +1,6 @@
*** Testing gzdeflate() : variation ***
-- Testing multiple compression --
string(32) "078554fe65e06f6ff01eab51cfc7ae9b"
string(32) "86b9f895ef1377da5269ec3cb2729f71"
===Done===
@@ -0,0 +1,53 @@
<?php
/* Prototype : string gzencode ( string $data [, int $level [, int $encoding_mode ]] )
* Description: Gzip-compress a string
* Source code: ext/zlib/zlib.c
* Alias to functions:
*/
/*
* Test basic function of gzencode
*/
include(dirname(__FILE__) . '/data.inc');
echo "*** Testing gzencode() : basic functionality ***\n";
// Initialise all required variables
$smallstring = "A small string to compress\n";
// Calling gzencode() with various compression levels
// Compressing a big string
for($i = -1; $i < 10; $i++) {
echo "-- Compression level $i --\n";
$output = gzencode($data, $i);
// Clear OS byte before encode
$output[9] = "\x00";
var_dump(md5($output));
}
// Compressing a smaller string
for($i = -1; $i < 10; $i++) {
echo "-- Compression level $i --\n";
$output = gzencode($smallstring, $i);
// Clear OS byte before encode
$output[9] = "\x00";
var_dump(md5($output));
}
// Calling gzencode() with mandatory arguments
echo "\n-- Testing with no specified compression level --\n";
var_dump(bin2hex(gzencode($smallstring)));
echo "\n-- Testing gzencode with mode specified --\n";
var_dump(bin2hex(gzencode($smallstring, -1, FORCE_GZIP)));
?>
===Done===
@@ -0,0 +1,52 @@
*** Testing gzencode() : basic functionality ***
-- Compression level -1 --
string(32) "d9ede02415ce91d21e5a94274e2b9c42"
-- Compression level 0 --
string(32) "bbf32d5508e5f1f4e6d42790489dae15"
-- Compression level 1 --
string(32) "0bfaaa7a5a57f8fb533074fca6c85eeb"
-- Compression level 2 --
string(32) "7ddbfed63a76c42808722b66f1c133fc"
-- Compression level 3 --
string(32) "ca2b85d194dfa2a4e8a162b646c99265"
-- Compression level 4 --
string(32) "cfe28033eaf260bc33ddc04b53d3ba39"
-- Compression level 5 --
string(32) "ae357fada2b515422f8bea0aa3bcc48f"
-- Compression level 6 --
string(32) "d9ede02415ce91d21e5a94274e2b9c42"
-- Compression level 7 --
string(32) "d9ede02415ce91d21e5a94274e2b9c42"
-- Compression level 8 --
string(32) "d9ede02415ce91d21e5a94274e2b9c42"
-- Compression level 9 --
string(32) "0f220a09e9895bcb3a1308d2bc99cfdf"
-- Compression level -1 --
string(32) "f77bd31e1e4dd11d12828fb661a08010"
-- Compression level 0 --
string(32) "9c5005db88490d6fe102ea2c233b2872"
-- Compression level 1 --
string(32) "d24ff7c4c20cef69b9c3abd603368db9"
-- Compression level 2 --
string(32) "f77bd31e1e4dd11d12828fb661a08010"
-- Compression level 3 --
string(32) "f77bd31e1e4dd11d12828fb661a08010"
-- Compression level 4 --
string(32) "f77bd31e1e4dd11d12828fb661a08010"
-- Compression level 5 --
string(32) "f77bd31e1e4dd11d12828fb661a08010"
-- Compression level 6 --
string(32) "f77bd31e1e4dd11d12828fb661a08010"
-- Compression level 7 --
string(32) "f77bd31e1e4dd11d12828fb661a08010"
-- Compression level 8 --
string(32) "f77bd31e1e4dd11d12828fb661a08010"
-- Compression level 9 --
string(32) "8849e9a1543c04b3f882b5ce20839ed2"
-- Testing with no specified compression level --
string(94) "1f8b08000000000000%c%c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200edc4e40b1b000000"
-- Testing gzencode with mode specified --
string(94) "1f8b08000000000000%c%c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200edc4e40b1b000000"
===Done===
@@ -0,0 +1,49 @@
<?php
/* Prototype : string gzencode ( string $data [, int $level [, int $encoding_mode ]] )
* Description: Gzip-compress a string
* Source code: ext/zlib/zlib.c
* Alias to functions:
*/
/*
* Test error cases for gzencode
*/
echo "*** Testing gzencode() : error conditions ***\n";
// Zero arguments
echo "\n-- Testing gzencode() function with Zero arguments --\n";
var_dump( gzencode() );
//Test gzencode with one more than the expected number of arguments
echo "\n-- Testing gzencode() function with more than expected no. of arguments --\n";
$data = 'string_val';
$level = 2;
$encoding_mode = FORCE_DEFLATE;
$extra_arg = 10;
var_dump( gzencode($data, $level, $encoding_mode, $extra_arg) );
echo "\n-- Testing with incorrect compression level --\n";
$bad_level = 99;
var_dump(gzencode($data, $bad_level));
echo "\n-- Testing with incorrect encoding_mode --\n";
$bad_mode = 99;
var_dump(gzencode($data, $level, $bad_mode));
class Tester {
function Hello() {
echo "Hello\n";
}
}
echo "\n-- Testing with incorrect parameters --\n";
$testclass = new Tester();
var_dump(gzencode($testclass));
var_dump(gzencode($data, $testclass));
var_dump(gzencode($data, -1, 99.99));
var_dump(gzencode($data, -1, $testclass));
var_dump(gzencode($data, "a very none numeric string\n"));
?>
===Done===
@@ -0,0 +1,30 @@
*** Testing gzencode() : error conditions ***
-- Testing gzencode() function with Zero arguments --
HipHop Warning: %a
NULL
-- Testing gzencode() function with more than expected no. of arguments --
HipHop Warning: %a
NULL
-- Testing with incorrect compression level --
HipHop Warning: %a
bool(false)
-- Testing with incorrect encoding_mode --
HipHop Warning: %a
bool(false)
-- Testing with incorrect parameters --
HipHop Warning: %a
NULL
HipHop Warning: %a
NULL
HipHop Warning: %a
bool(false)
HipHop Warning: %a
NULL
HipHop Warning: %a
NULL
===Done===
@@ -0,0 +1,26 @@
<?php
/* Prototype : string gzencode ( string $data [, int $level [, int $encoding_mode ]] )
* Description: Gzip-compress a string
* Source code: ext/zlib/zlib.c
* Alias to functions:
*/
if(!function_exists("gzdecode")) {
function gzdecode($data)
{
return gzinflate(substr($data,10,-8));
}
}
include(dirname(__FILE__) . '/data.inc');
echo "*** Testing gzencode() : variation ***\n";
echo "\n-- Testing multiple compression --\n";
$output = gzencode(gzencode($data));
$back = gzdecode(gzdecode($output));
var_dump($data === $back);
?>
===Done===
@@ -0,0 +1,5 @@
*** Testing gzencode() : variation ***
-- Testing multiple compression --
bool(true)
===Done===
@@ -0,0 +1,17 @@
<?php
/* Prototype : string gzencode ( string $data [, int $level [, int $encoding_mode ]] )
* Description: Gzip-compress a string
* Source code: ext/zlib/zlib.c
* Alias to functions:
*/
include(dirname(__FILE__) . '/data.inc');
echo "*** Testing gzencode() : variation ***\n";
echo "\n-- Testing multiple compression --\n";
$output = gzencode($data);
var_dump(bin2hex(gzencode($output)));
?>
===Done===
@@ -0,0 +1,5 @@
*** Testing gzencode() : variation ***
-- Testing multiple compression --
string(3658) "1f8b0800000000000003010e07f1f81f8b08000000000000036d574d6fe4c80dbdeb57d4ad2f3dfe01eb83e1ec22980e309b4562c067b64449159754dafab0b6e7d7e73d96da1e4c72184c4b2ab2c8f7c847fa25baabba98dc1a8b2b7c38bb324b713ee37f757f56cdc5c7f5b17b9d152f923b157c5ae335e0b75fedd0e2d781c6b98ea3a6ee05affe1dfc3a6527f8f09c52dcb38ba38bb5249934d6ecfe1e53a9ab76ff4c342cf2a64ed2028349fc9a8b139755685352acb82b9fbb67f8bade5cdcb698e1fcec94b7ceba3cb897e806cfc8114350dd1ebbdfa35b62d2478b0056d23ed809b9b95d696d91ce2aa97c911e3fa539c43f84c887554a4d125c9e63ff96711cc08c0866263cb37a0bbe2122ae8f6baecb2284abfb4ddf916db8354cddeef37c1afe5fa02fc7afb3db34f5b3acbdf2eb905490d8f38d7468d253a323d5ebb903760d7944d3b2024e834a99ddce77669bdd823cfbb8e899d4ad4c799677452e6029e80023a03b2374005590641f7d3877df2ad09f3c0e82a54d6a5644fd63049a37ed4bc362016fd9f51264f1e5c630727421ae930b7ed416e93e47b7c71a400390361ffbecb7561bb98f69b5da289e91becc27f08b3b724cb8704f9144d366431d0cb870c56b205deaa2e17636063761a911039fb7e4bf9f06c4f0aecd2ec80e8b41831ca7515e31286166458ea3ef71f2ce7cde2ae269c96d60525724a9c9170b713ed5750758f3cd2a361fc8b288fc92358ce884692e8ea0fe59bd969a0da2eed5831b715749eaae7178f3ebd30fb88c92105f367cce2c882955dc6bf8eca0d5d57540b3092894743ba0fd5b2dad021836191f1afc0bba14dde1642cb0b1aa6879c38907dcefa0720082b801bec61417469219175267dfa047df35b0bd1332001c28cdfafd3bcabe91e74368cdd8d8478e494c190e7ee90c67f2bde288e68ab6b15e883c995be4f8feb6c6dda4278e4f38578ddbdc7be36788daf0c3cb1d1819c73822f7000a0d1813fa94153b572315e51343b536bc64977dff163cebfd8418773261f524017e251fccc60ae29a5770ae097594d52e9c1229d87ce967a36401c46b69945afb249d101c9d420ffa9a123e232c20e76467d5d169202a2dd4c582949e013e745df7958d4b0cc4fd4377a737cd4feea7974070000f314d423e0634cb9a618fdf5dc64fd422181fd59c9230c9f6f9d18dc8fc23e9cccbc7188733b04aa57de83ebea0be3633cff5fa1ff83269be7f44f5a8d84550cc703255fd345dd402034d0b3e11a73ec6e3d4a77f4f685b614329f1b3132ae7af33d02e1e55e291fa6574b758d1f0200e7423dbc852211818043a7c9ce80aa9d59fce0401959f5ea2cf71fde90824f8c9192dbe9d329db143794675ddcf257dd7755273b67340414e3ccad12e3f661f8aad9cf9957dc1275d10a51d3934fa81e68dc6768fb8ee23e373936c8e13feab8b0f50d227f7af76f561fb0950f3d099bbc316c3892a42fb36806d8660e800fa4f43fd4b962d2097d71933a54b77ff948677848eb17bb3a88b621682cfb3bbb49cf42fed6b3944124ad8358ca688aa44dd5f2144c7c9ab16f25b9aca9654ef357ec9ad55c40d324d6cc3d9e3920b863c231d31a95d937fb5520f9c816c79b7dcecc593fb9593cc05a51ebb1eeddd5b49eb437769738d0f64adc579d372b8b7f7c0208487ee3915ebf5766e148ebd77cf4e01f3ec285047011e55838968b6494d517fe29224777b24dd3ddf933101695b102e87db805eef291b74dcfd91628fb2a53f93dbd2968ef2e598746c9204f89fba1f0246fc671610a0591806e46a1346f77c40d910a47c5e20ffb23f003c04b648327a4ed98032c1965bd35bb0044f5344248f56fdb99aa61d6451d68e33489a83bffbe6573541b2da5f64681ea12090f778b2075374778810f73965fa3626a9d41f4df2f83f7c34658cec921b5a9bde49dd5007ec882b02adc514f81aa85898b5cc98e1b137733c0a8789b7f5648d2d231b80bf74978f25d61ce08a8abd11801fd8f995e066676307192ff7641f1cc6e0dee68565b8b22ac3889cd067bf732754a6b270af1044c6a8776811a4f6d8bd0477a9f516064201b920b92d7cd4dc7eee13e6b3eb3528a82f9abb3f388ebe6a8f871393461b73816ec54c99d604174bc5a6801de13908f86aea6a7d0fea107d682bcf1ec348b83872e6b8a316ecd02eb8f8dc86a609bf59a2dd03f1dfa4079436d55e24617be1a2854d008b2b2b1705e2078a7f3946318df1c24f6bf70d4b456eca286ec2b585b28262cc048a098c3e2d5f325a92bb36f691afdc14c822da1b116c9c1c07bb362eb0a04b78834c812134230ebf2044ac2e3c0e3ad00f848dc5010f3bf917ec2fc700b7bf26dacea8440620e04f90f4d97d6dd77cfde8a05c7d3930f1e5811fb8ec5c70964dcc8187ec90e32fdd6b64eec7586413b7d55bed65c4cce39a9b6c15e70e9da94e53fc904e6286f01f5b5562c94211befbc23507e01b2a3865e2f45b5d7b591f290087a5605b82495b4e393f31aa5b37211ec40241a746d903c5eebf117a4d3ddb0d00007b64cbc70e070000"
===Done===
@@ -0,0 +1,18 @@
<?php
/* Prototype : string gzencode ( string $data [, int $level [, int $encoding_mode ]] )
* Description: Gzip-compress a string
* Source code: ext/zlib/zlib.c
* Alias to functions:
*/
echo "*** Testing gzencode() : variation ***\n";
$data = "A small string to encode\n";
echo "\n-- Testing with each encoding_mode --\n";
var_dump(bin2hex(gzencode($data, -1)));
var_dump(bin2hex(gzencode($data, -1, FORCE_GZIP)));
var_dump(bin2hex(gzencode($data, -1, FORCE_DEFLATE)));
?>
===DONE===
@@ -0,0 +1,7 @@
*** Testing gzencode() : variation ***
-- Testing with each encoding_mode --
string(90) "1f8b080000000000000b735428ce4dccc951282e29cacc4b5728c95748cd4bce4f49e50200d7739de519000000"
string(90) "1f8b080000000000000b735428ce4dccc951282e29cacc4b5728c95748cd4bce4f49e50200d7739de519000000"
string(66) "789c735428ce4dccc951282e29cacc4b5728c95748cd4bce4f49e50200735808cd"
===DONE===
@@ -0,0 +1,18 @@
<?php
/* Prototype : string gzencode ( string $data [, int $level [, int $encoding_mode ]] )
* Description: Gzip-compress a string
* Source code: ext/zlib/zlib.c
* Alias to functions:
*/
echo "*** Testing gzencode() : variation ***\n";
$data = "A small string to encode\n";
echo "\n-- Testing with each encoding_mode --\n";
var_dump(bin2hex(gzencode($data, -1)));
var_dump(bin2hex(gzencode($data, -1, FORCE_GZIP)));
var_dump(bin2hex(gzencode($data, -1, FORCE_DEFLATE)));
?>
===DONE===
@@ -0,0 +1,7 @@
*** Testing gzencode() : variation ***
-- Testing with each encoding_mode --
string(90) "1f8b0800000000000003735428ce4dccc951282e29cacc4b5728c95748cd4bce4f49e50200d7739de519000000"
string(90) "1f8b0800000000000003735428ce4dccc951282e29cacc4b5728c95748cd4bce4f49e50200d7739de519000000"
string(66) "789c735428ce4dccc951282e29cacc4b5728c95748cd4bce4f49e50200735808cd"
===DONE===
+30
Ver Arquivo
@@ -0,0 +1,30 @@
<?php
// note that gzeof is an alias to gzeof. parameter checking tests will be
// the same as gzeof
$f = dirname(__FILE__)."/004.txt.gz";
echo "-- test 1 --\n";
$h = gzopen($f, 'r');
var_dump(gzeof($h));
gzpassthru($h);
var_dump(gzeof($h));
gzclose($h);
echo "\n-- test 2 --\n";
$h = gzopen($f, 'r');
echo "reading 50 characters. eof should be false\n";
gzread($h, 50)."\n";
var_dump(gzeof($h));
echo "reading 250 characters. eof should be true\n";
gzread($h, 250)."\n";
var_dump(gzeof($h));
echo "reading 20 characters. eof should be true still\n";
gzread($h, 20)."\n";
var_dump(gzeof($h));
gzclose($h);
?>
===DONE===
@@ -0,0 +1,18 @@
-- test 1 --
bool(false)
When you're taught through feelings
Destiny flying high above
all I know is that you can realize it
Destiny who cares
as it turns around
and I know that it descends down on me
bool(true)
-- test 2 --
reading 50 characters. eof should be false
bool(false)
reading 250 characters. eof should be true
bool(true)
reading 20 characters. eof should be true still
bool(true)
===DONE===
+11
Ver Arquivo
@@ -0,0 +1,11 @@
<?php
$f = dirname(__FILE__)."/004.txt.gz";
$h = gzopen($f, 'r');
$extra_arg = 'nothing';
var_dump(gzeof( $h, $extra_arg ) );
var_dump(gzeof() );
gzclose($h)
?>
===DONE===
@@ -0,0 +1,5 @@
HipHop Warning: %a
bool(false)
HipHop Warning: %a
bool(false)
===DONE===
@@ -0,0 +1,22 @@
<?php
$use_include_path = false;
$index_array = array(1, 2, 3);
$assoc_array = array(1 => 'one', 2 => 'two');
$variation = array(
'empty array' => array(),
'int indexed array' => $index_array,
'associative array' => $assoc_array,
'nested arrays' => array('foo', $index_array, $assoc_array),
);
foreach ( $variation as $var ) {
var_dump(gzfile( $var , $use_include_path ) );
}
?>
===DONE===
@@ -0,0 +1,9 @@
HipHop Warning: %a
NULL
HipHop Warning: %a
NULL
HipHop Warning: %a
NULL
HipHop Warning: %a
NULL
===DONE===
@@ -0,0 +1,24 @@
<?php
$filename = dirname(__FILE__)."/004.txt.gz";
$unset_var = 10;
unset($unset_var);
$variation = array(
'unset var' => @$unset_var,
'undefined var' => @$undefined_var,
'empty string DQ' => "",
'empty string SQ' => '',
'uppercase NULL' => NULL,
'lowercase null' => null,
);
foreach ( $variation as $var ) {
var_dump(gzfile( $filename, $var ) );
}
?>
===DONE===
@@ -0,0 +1,85 @@
array(6) {
[0]=>
string(36) "When you're taught through feelings
"
[1]=>
string(26) "Destiny flying high above
"
[2]=>
string(38) "all I know is that you can realize it
"
[3]=>
string(18) "Destiny who cares
"
[4]=>
string(19) "as it turns around
"
[5]=>
string(39) "and I know that it descends down on me
"
}
array(6) {
[0]=>
string(36) "When you're taught through feelings
"
[1]=>
string(26) "Destiny flying high above
"
[2]=>
string(38) "all I know is that you can realize it
"
[3]=>
string(18) "Destiny who cares
"
[4]=>
string(19) "as it turns around
"
[5]=>
string(39) "and I know that it descends down on me
"
}
HipHop Warning: %a
NULL
HipHop Warning: %a
NULL
array(6) {
[0]=>
string(36) "When you're taught through feelings
"
[1]=>
string(26) "Destiny flying high above
"
[2]=>
string(38) "all I know is that you can realize it
"
[3]=>
string(18) "Destiny who cares
"
[4]=>
string(19) "as it turns around
"
[5]=>
string(39) "and I know that it descends down on me
"
}
array(6) {
[0]=>
string(36) "When you're taught through feelings
"
[1]=>
string(26) "Destiny flying high above
"
[2]=>
string(38) "all I know is that you can realize it
"
[3]=>
string(18) "Destiny who cares
"
[4]=>
string(19) "as it turns around
"
[5]=>
string(39) "and I know that it descends down on me
"
}
===DONE===
@@ -0,0 +1,38 @@
<?php
$filename = $filename = dirname(__FILE__)."/004.txt.gz";
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
if (error_reporting() != 0) {
// report non-silenced errors
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
}
}
set_error_handler('test_error_handler');
class classWithToString
{
public function __toString() {
return "Class A object";
}
}
class classWithoutToString
{
}
$variation = array(
'instance of classWithToString' => new classWithToString(),
'instance of classWithoutToString' => new classWithoutToString(),
);
foreach ( $variation as $var ) {
var_dump(gzfile( $filename, $var ) );
}
?>
===DONE===
@@ -0,0 +1,5 @@
Error: 2 - gzfile() expects parameter 2 to be long, object given, %s(%d)
NULL
Error: 2 - gzfile() expects parameter 2 to be long, object given, %s(%d)
NULL
===DONE===
@@ -0,0 +1,23 @@
<?php
$filename = $filename = dirname(__FILE__)."/004.txt.gz";
$heredoc = <<<EOT
hello world
EOT;
$variation_array = array(
'string DQ' => "string",
'string SQ' => 'string',
'mixed case string' => "sTrInG",
'heredoc' => $heredoc
);
foreach ( $variation_array as $var ) {
var_dump(gzfile( $filename, $var ) );
}
?>
===DONE===
@@ -0,0 +1,9 @@
HipHop Warning: %a
NULL
HipHop Warning: %a
NULL
HipHop Warning: %a
NULL
HipHop Warning: %a
NULL
===DONE===
@@ -0,0 +1,72 @@
<?php
require_once('reading_include_path.inc');
//define the files to go into these directories, create one in dir2
set_include_path($newIncludePath);
test_gzfile();
restore_include_path();
// remove the directory structure
chdir($baseDir);
rmdir($workingDir);
foreach($newdirs as $newdir) {
rmdir($newdir);
}
chdir("..");
rmdir($thisTestDir);
function test_gzfile() {
global $scriptFile, $secondFile, $firstFile, $filename;
// create a file in the middle directory
$h = gzopen($secondFile, "w");
gzwrite($h, "This is a file in dir2");
gzclose($h);
// should read dir2 file
var_dump(gzfile($filename, true));
echo "\n";
//create a file in dir1
$h = gzopen($firstFile, "w");
gzwrite($h, "This is a file in dir1");
gzclose($h);
//should now read dir1 file
var_dump(gzfile($filename, true));
echo "\n";
// create a file in working directory
$h = gzopen($filename, "w");
gzwrite($h, "This is a file in working dir");
gzclose($h);
//should still read dir1 file
var_dump(gzfile($filename, true));
echo "\n";
unlink($firstFile);
unlink($secondFile);
//should read the file in working directory
var_dump(gzfile($filename, true));
echo "\n";
// create a file in the script directory
$h = gzopen($scriptFile, "w");
gzwrite($h, "This is a file in script dir");
gzclose($h);
//should read the file in script dir
var_dump(gzfile($filename, true));
echo "\n";
//cleanup
unlink($filename);
unlink($scriptFile);
}
?>
===DONE===
@@ -0,0 +1,26 @@
array(1) {
[0]=>
string(22) "This is a file in dir2"
}
array(1) {
[0]=>
string(22) "This is a file in dir1"
}
array(1) {
[0]=>
string(22) "This is a file in dir1"
}
array(1) {
[0]=>
string(29) "This is a file in working dir"
}
array(1) {
[0]=>
string(28) "This is a file in script dir"
}
===DONE===
@@ -0,0 +1,19 @@
<?php
$use_include_path =
$variation = array(
'lowercase true' => true,
'lowercase false' =>false,
'uppercase TRUE' =>TRUE,
'uppercase FALSE' =>FALSE,
);
foreach ( $variation as $var ) {
var_dump(gzfile( $var , $use_include_path ) );
}
?>
===DONE===
@@ -0,0 +1,9 @@
HipHop Warning: %a
NULL
HipHop Warning: %a
NULL
HipHop Warning: %a
NULL
HipHop Warning: %a
NULL
===DONE===
@@ -0,0 +1,24 @@
<?php
$use_include_path = false;
$unset_var = 10;
unset($unset_var);
$variation = array(
'unset var' => @$unset_var,
'undefined var' => @$undefined_var,
'empty string DQ' => "",
'empty string SQ' => '',
'uppercase NULL' => NULL,
'lowercase null' => null,
);
foreach ( $variation as $var ) {
var_dump(gzfile( $var , $use_include_path ) );
}
?>
===DONE===
@@ -0,0 +1,13 @@
HipHop Warning: %a
bool(false)
HipHop Warning: %a
bool(false)
HipHop Warning: %a
bool(false)
HipHop Warning: %a
bool(false)
HipHop Warning: %a
bool(false)
HipHop Warning: %a
bool(false)
===DONE===
@@ -0,0 +1,37 @@
<?php
$use_include_path = false;
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
if (error_reporting() != 0) {
// report non-silenced errors
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
}
}
set_error_handler('test_error_handler');
class classWithToString
{
public function __toString() {
return "Class A object";
}
}
class classWithoutToString
{
}
$variation = array(
'instance of classWithToString' => new classWithToString(),
'instance of classWithoutToString' => new classWithoutToString(),
);
foreach ( $variation as $var ) {
var_dump(gzfile( $var , $use_include_path ) );
}
?>
@@ -0,0 +1,4 @@
Error: 2 - gzfile(Class A object): failed to open stream: No such file or directory, %s(%d)
bool(false)
Error: 2 - gzfile() expects parameter 1 to be a valid path, object given, %s(%d)
NULL
@@ -0,0 +1,22 @@
<?php
$filename = dirname(__FILE__)."/004.txt.gz";
$index_array = array(1, 2, 3);
$assoc_array = array(1 => 'one', 2 => 'two');
$variation = array(
'empty array' => array(),
'int indexed array' => $index_array,
'associative array' => $assoc_array,
'nested arrays' => array('foo', $index_array, $assoc_array),
);
foreach ( $variation as $var ) {
var_dump(gzfile( $filename, $var ) );
}
?>
===DONE===
@@ -0,0 +1,9 @@
HipHop Warning: %a
NULL
HipHop Warning: %a
NULL
HipHop Warning: %a
NULL
HipHop Warning: %a
NULL
===DONE===
+12
Ver Arquivo
@@ -0,0 +1,12 @@
<?php
$f = dirname(__FILE__)."/004.txt.gz";
$h = gzopen($f, 'r');
$extra_arg = 'nothing';
var_dump(gzgetc( $h, $extra_arg ) );
var_dump(gzgetc() );
gzclose($h);
?>
===DONE===
@@ -0,0 +1,5 @@
HipHop Warning: %a
bool(false)
HipHop Warning: %a
bool(false)
===DONE===
+13
Ver Arquivo
@@ -0,0 +1,13 @@
<?php
$f = dirname(__FILE__)."/004.txt.gz";
$h = gzopen($f, 'r');
$length = 10;
$extra_arg = 'nothing';
var_dump(gzgets( $h, $length, $extra_arg ) );
var_dump(gzgets());
?>
===DONE===
@@ -0,0 +1,5 @@
HipHop Warning: %a
bool(false)
HipHop Warning: %a
bool(false)
===DONE===
@@ -0,0 +1,14 @@
<?php
// build a predictable string
$string = '';
for($i=0; $i<30000; ++$i) $string .= $i . ' ';
var_dump(strlen($string));
// deflate string
$deflated = gzdeflate($string,9);
var_dump(strlen($deflated));
// truncate $deflated string
$truncated = substr($deflated, 0, 65535);
var_dump(strlen($truncated));
// inflate $truncated string (check if it will not eat all memory)
var_dump(gzinflate($truncated));
?>
@@ -0,0 +1,5 @@
int(168890)
int(66743)
int(65535)
HipHop Warning: %a
bool(false)
@@ -0,0 +1,40 @@
<?php
/* Prototype : string gzinflate(string data [, int length])
* Description: Unzip a gzip-compressed string
* Source code: ext/zlib/zlib.c
* Alias to functions:
*/
include(dirname(__FILE__) . '/data.inc');
echo "*** Testing gzinflate() : error conditions ***\n";
echo "\n-- Testing gzcompress() function with Zero arguments --\n";
var_dump( gzinflate() );
echo "\n-- Testing gzcompress() function with more than expected no. of arguments --\n";
$data = 'string_val';
$length = 10;
$extra_arg = 10;
var_dump( gzinflate($data, $length, $extra_arg) );
echo "\n-- Testing with a buffer that is too small --\n";
$short_len = strlen($data) - 1;
$compressed = gzcompress($data);
var_dump(gzinflate($compressed, $short_len));
echo "\n-- Testing with incorrect parameters --\n";
class Tester {
function Hello() {
echo "Hello\n";
}
}
$testclass = new Tester();
var_dump(gzinflate($testclass));
var_dump(gzinflate($data, $testclass));
?>
===DONE===
@@ -0,0 +1,20 @@
*** Testing gzinflate() : error conditions ***
-- Testing gzcompress() function with Zero arguments --
HipHop Warning: %a
NULL
-- Testing gzcompress() function with more than expected no. of arguments --
HipHop Warning: %a
NULL
-- Testing with a buffer that is too small --
HipHop Warning: %a
bool(false)
-- Testing with incorrect parameters --
HipHop Warning: %a
NULL
HipHop Warning: %a
NULL
===DONE===
@@ -0,0 +1,13 @@
<?php
$original = 'aaaaaaaaaaaaaaa';
$packed=gzdeflate($original);
echo strlen($packed)." ".strlen($original)."\n";
$unpacked=gzinflate($packed, strlen($original));
if (strcmp($original,$unpacked)==0) echo "Strings are equal\n";
$unpacked=gzinflate($packed, strlen($original)*10);
if (strcmp($original,$unpacked)==0) echo "Strings are equal\n";
$unpacked=gzinflate($packed, 1);
if ($unpacked === false) echo "Failed (as expected)\n";
?>
@@ -0,0 +1,5 @@
5 15
Strings are equal
Strings are equal
HipHop Warning: %a
Failed (as expected)
@@ -0,0 +1,34 @@
<?php
/* Prototype : resource gzopen(string filename, string mode [, int use_include_path])
* Description: Open a .gz-file and return a .gz-file pointer
* Source code: ext/zlib/zlib.c
* Alias to functions:
*/
echo "*** Testing gzopen() : basic functionality ***\n";
// Initialise all required variables
$filename = "temp.txt.gz";
$modes = array('w', 'w+');
$data = "This was the information that was written";
foreach($modes as $mode) {
echo "testing mode -- $mode --\n";
$h = gzopen($filename, $mode);
if ($h !== false) {
gzwrite($h, $data);
gzclose($h);
$h = gzopen($filename, 'r');
gzpassthru($h);
gzclose($h);
echo "\n";
unlink($filename);
}
else {
var_dump($h);
}
}
?>
===DONE===
@@ -0,0 +1,7 @@
*** Testing gzopen() : basic functionality ***
testing mode -- w --
This was the information that was written
testing mode -- w+ --
HipHop Warning: %a
bool(false)
===DONE===
@@ -0,0 +1,111 @@
<?php
/* Prototype : resource gzopen(string filename, string mode [, int use_include_path])
* Description: Open a .gz-file and return a .gz-file pointer
* Source code: ext/zlib/zlib.c
* Alias to functions:
*/
echo "*** Testing gzopen() : usage variation ***\n";
// Define error handler
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
if (error_reporting() != 0) {
// report non-silenced errors
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
}
}
set_error_handler('test_error_handler');
// Initialise function arguments not being substituted (if any)
$mode = 'r';
$use_include_path = false;
//get an unset variable
$unset_var = 10;
unset ($unset_var);
// define some classes
class classWithToString
{
public function __toString() {
return "Class A object";
}
}
class classWithoutToString
{
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// get a resource variable
$fp = fopen(__FILE__, "r");
// add arrays
$index_array = array (1, 2, 3);
$assoc_array = array ('one' => 1, 'two' => 2);
//array of values to iterate over
$inputs = array(
// int data
'int 0' => 0,
'int 1' => 1,
'int 12345' => 12345,
'int -12345' => -2345,
// float data
'float 10.5' => 10.5,
'float -10.5' => -10.5,
'float 12.3456789000e10' => 12.3456789000e10,
'float -12.3456789000e10' => -12.3456789000e10,
'float .5' => .5,
// array data
'empty array' => array(),
'int indexed array' => $index_array,
'associative array' => $assoc_array,
'nested arrays' => array('foo', $index_array, $assoc_array),
// null data
'uppercase NULL' => NULL,
'lowercase null' => null,
// boolean data
'lowercase true' => true,
'lowercase false' =>false,
'uppercase TRUE' =>TRUE,
'uppercase FALSE' =>FALSE,
// empty data
'empty string DQ' => "",
'empty string SQ' => '',
// object data
'instance of classWithToString' => new classWithToString(),
'instance of classWithoutToString' => new classWithoutToString(),
// undefined data
'undefined var' => @$undefined_var,
// unset data
'unset var' => @$unset_var,
// resource variable
'resource' => $fp
);
// loop through each element of the array for filename
foreach($inputs as $key =>$value) {
echo "\n--$key--\n";
var_dump( gzopen($value, $mode, $use_include_path) );
};
fclose($fp);
?>
===DONE===
@@ -0,0 +1,106 @@
*** Testing gzopen() : usage variation ***
--int 0--
Error: 2 - gzopen(0): failed to open stream: No such file or directory, %s(%d)
bool(false)
--int 1--
Error: 2 - gzopen(1): failed to open stream: No such file or directory, %s(%d)
bool(false)
--int 12345--
Error: 2 - gzopen(12345): failed to open stream: No such file or directory, %s(%d)
bool(false)
--int -12345--
Error: 2 - gzopen(-2345): failed to open stream: No such file or directory, %s(%d)
bool(false)
--float 10.5--
Error: 2 - gzopen(10.5): failed to open stream: No such file or directory, %s(%d)
bool(false)
--float -10.5--
Error: 2 - gzopen(-10.5): failed to open stream: No such file or directory, %s(%d)
bool(false)
--float 12.3456789000e10--
Error: 2 - gzopen(123456789000): failed to open stream: No such file or directory, %s(%d)
bool(false)
--float -12.3456789000e10--
Error: 2 - gzopen(-123456789000): failed to open stream: No such file or directory, %s(%d)
bool(false)
--float .5--
Error: 2 - gzopen(0.5): failed to open stream: No such file or directory, %s(%d)
bool(false)
--empty array--
Error: 2 - gzopen() expects parameter 1 to be string, array given, %s(%d)
NULL
--int indexed array--
Error: 2 - gzopen() expects parameter 1 to be string, array given, %s(%d)
NULL
--associative array--
Error: 2 - gzopen() expects parameter 1 to be string, array given, %s(%d)
NULL
--nested arrays--
Error: 2 - gzopen() expects parameter 1 to be string, array given, %s(%d)
NULL
--uppercase NULL--
Error: 2 - gzopen(): Filename cannot be empty, %s(%d)
bool(false)
--lowercase null--
Error: 2 - gzopen(): Filename cannot be empty, %s(%d)
bool(false)
--lowercase true--
Error: 2 - gzopen(1): failed to open stream: No such file or directory, %s(%d)
bool(false)
--lowercase false--
Error: 2 - gzopen(): Filename cannot be empty, %s(%d)
bool(false)
--uppercase TRUE--
Error: 2 - gzopen(1): failed to open stream: No such file or directory, %s(%d)
bool(false)
--uppercase FALSE--
Error: 2 - gzopen(): Filename cannot be empty, %s(%d)
bool(false)
--empty string DQ--
Error: 2 - gzopen(): Filename cannot be empty, %s(%d)
bool(false)
--empty string SQ--
Error: 2 - gzopen(): Filename cannot be empty, %s(%d)
bool(false)
--instance of classWithToString--
Error: 2 - gzopen(Class A object): failed to open stream: No such file or directory, %s(%d)
bool(false)
--instance of classWithoutToString--
Error: 2 - gzopen() expects parameter 1 to be string, object given, %s(%d)
NULL
--undefined var--
Error: 2 - gzopen(): Filename cannot be empty, %s(%d)
bool(false)
--unset var--
Error: 2 - gzopen(): Filename cannot be empty, %s(%d)
bool(false)
--resource--
Error: 2 - gzopen() expects parameter 1 to be string, resource given, %s(%d)
NULL
===DONE===
@@ -0,0 +1,111 @@
<?php
/* Prototype : resource gzopen(string filename, string mode [, int use_include_path])
* Description: Open a .gz-file and return a .gz-file pointer
* Source code: ext/zlib/zlib.c
* Alias to functions:
*/
echo "*** Testing gzopen() : usage variation ***\n";
// Define error handler
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
if (error_reporting() != 0) {
// report non-silenced errors
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
}
}
set_error_handler('test_error_handler');
// Initialise function arguments not being substituted (if any)
$filename = dirname(__FILE__)."/004.txt.gz";
$use_include_path = false;
//get an unset variable
$unset_var = 10;
unset ($unset_var);
// define some classes
class classWithToString
{
public function __toString() {
return "Class A object";
}
}
class classWithoutToString
{
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// get a resource variable
$fp = fopen(__FILE__, "r");
// add arrays
$index_array = array (1, 2, 3);
$assoc_array = array ('one' => 1, 'two' => 2);
//array of values to iterate over
$inputs = array(
// int data
'int 0' => 0,
'int 1' => 1,
'int 12345' => 12345,
'int -12345' => -2345,
// float data
'float 10.5' => 10.5,
'float -10.5' => -10.5,
'float 12.3456789000e10' => 12.3456789000e10,
'float -12.3456789000e10' => -12.3456789000e10,
'float .5' => .5,
// array data
'empty array' => array(),
'int indexed array' => $index_array,
'associative array' => $assoc_array,
'nested arrays' => array('foo', $index_array, $assoc_array),
// null data
'uppercase NULL' => NULL,
'lowercase null' => null,
// boolean data
'lowercase true' => true,
'lowercase false' =>false,
'uppercase TRUE' =>TRUE,
'uppercase FALSE' =>FALSE,
// empty data
'empty string DQ' => "",
'empty string SQ' => '',
// object data
'instance of classWithToString' => new classWithToString(),
'instance of classWithoutToString' => new classWithoutToString(),
// undefined data
'undefined var' => @$undefined_var,
// unset data
'unset var' => @$unset_var,
// resource variable
'resource' => $fp
);
// loop through each element of the array for mode
foreach($inputs as $key =>$value) {
echo "\n--$key--\n";
var_dump( gzopen($filename, $value, $use_include_path) );
};
fclose($fp);
?>
===DONE===
@@ -0,0 +1,106 @@
*** Testing gzopen() : usage variation ***
--int 0--
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
bool(false)
--int 1--
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
bool(false)
--int 12345--
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
bool(false)
--int -12345--
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
bool(false)
--float 10.5--
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
bool(false)
--float -10.5--
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
bool(false)
--float 12.3456789000e10--
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
bool(false)
--float -12.3456789000e10--
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
bool(false)
--float .5--
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
bool(false)
--empty array--
Error: 2 - gzopen() expects parameter 2 to be string, array given, %s(%d)
NULL
--int indexed array--
Error: 2 - gzopen() expects parameter 2 to be string, array given, %s(%d)
NULL
--associative array--
Error: 2 - gzopen() expects parameter 2 to be string, array given, %s(%d)
NULL
--nested arrays--
Error: 2 - gzopen() expects parameter 2 to be string, array given, %s(%d)
NULL
--uppercase NULL--
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
bool(false)
--lowercase null--
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
bool(false)
--lowercase true--
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
bool(false)
--lowercase false--
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
bool(false)
--uppercase TRUE--
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
bool(false)
--uppercase FALSE--
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
bool(false)
--empty string DQ--
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
bool(false)
--empty string SQ--
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
bool(false)
--instance of classWithToString--
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
bool(false)
--instance of classWithoutToString--
Error: 2 - gzopen() expects parameter 2 to be string, object given, %s(%d)
NULL
--undefined var--
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
bool(false)
--unset var--
Error: 2 - gzopen(%s/004.txt.gz): failed to open stream: %s, %s(%d)
bool(false)
--resource--
Error: 2 - gzopen() expects parameter 2 to be string, resource given, %s(%d)
NULL
===DONE===
@@ -0,0 +1,115 @@
<?php
/* Prototype : resource gzopen(string filename, string mode [, int use_include_path])
* Description: Open a .gz-file and return a .gz-file pointer
* Source code: ext/zlib/zlib.c
* Alias to functions:
*/
echo "*** Testing gzopen() : usage variation ***\n";
// Define error handler
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
if (error_reporting() != 0) {
// report non-silenced errors
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
}
}
set_error_handler('test_error_handler');
// Initialise function arguments not being substituted (if any)
$filename = dirname(__FILE__)."/004.txt.gz";
$mode = 'r';
//get an unset variable
$unset_var = 10;
unset ($unset_var);
// define some classes
class classWithToString
{
public function __toString() {
return "Class A object";
}
}
class classWithoutToString
{
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// get a resource variable
$fp = fopen(__FILE__, "r");
// add arrays
$index_array = array (1, 2, 3);
$assoc_array = array ('one' => 1, 'two' => 2);
//array of values to iterate over
$inputs = array(
// float data
'float 10.5' => 10.5,
'float -10.5' => -10.5,
'float 12.3456789000e10' => 12.3456789000e10,
'float -12.3456789000e10' => -12.3456789000e10,
'float .5' => .5,
// array data
'empty array' => array(),
'int indexed array' => $index_array,
'associative array' => $assoc_array,
'nested arrays' => array('foo', $index_array, $assoc_array),
// null data
'uppercase NULL' => NULL,
'lowercase null' => null,
// boolean data
'lowercase true' => true,
'lowercase false' =>false,
'uppercase TRUE' =>TRUE,
'uppercase FALSE' =>FALSE,
// empty data
'empty string DQ' => "",
'empty string SQ' => '',
// string data
'string DQ' => "string",
'string SQ' => 'string',
'mixed case string' => "sTrInG",
'heredoc' => $heredoc,
// object data
'instance of classWithToString' => new classWithToString(),
'instance of classWithoutToString' => new classWithoutToString(),
// undefined data
'undefined var' => @$undefined_var,
// unset data
'unset var' => @$unset_var,
// resource variable
'resource' => $fp
);
// loop through each element of the array for use_include_path
foreach($inputs as $key =>$value) {
echo "\n--$key--\n";
$res = gzopen($filename, $mode, $value);
var_dump($res);
if ($res === true) {
gzclose($res);
}
};
fclose($fp);
?>
===DONE===
@@ -0,0 +1,93 @@
*** Testing gzopen() : usage variation ***
--float 10.5--
resource(%d) of type (stream)
--float -10.5--
resource(%d) of type (stream)
--float 12.3456789000e10--
resource(%d) of type (stream)
--float -12.3456789000e10--
resource(%d) of type (stream)
--float .5--
resource(%d) of type (stream)
--empty array--
Error: 2 - gzopen() expects parameter 3 to be long, array given, %s(%d)
NULL
--int indexed array--
Error: 2 - gzopen() expects parameter 3 to be long, array given, %s(%d)
NULL
--associative array--
Error: 2 - gzopen() expects parameter 3 to be long, array given, %s(%d)
NULL
--nested arrays--
Error: 2 - gzopen() expects parameter 3 to be long, array given, %s(%d)
NULL
--uppercase NULL--
resource(%d) of type (stream)
--lowercase null--
resource(%d) of type (stream)
--lowercase true--
resource(%d) of type (stream)
--lowercase false--
resource(%d) of type (stream)
--uppercase TRUE--
resource(%d) of type (stream)
--uppercase FALSE--
resource(%d) of type (stream)
--empty string DQ--
Error: 2 - gzopen() expects parameter 3 to be long, string given, %s(%d)
NULL
--empty string SQ--
Error: 2 - gzopen() expects parameter 3 to be long, string given, %s(%d)
NULL
--string DQ--
Error: 2 - gzopen() expects parameter 3 to be long, string given, %s(%d)
NULL
--string SQ--
Error: 2 - gzopen() expects parameter 3 to be long, string given, %s(%d)
NULL
--mixed case string--
Error: 2 - gzopen() expects parameter 3 to be long, string given, %s(%d)
NULL
--heredoc--
Error: 2 - gzopen() expects parameter 3 to be long, string given, %s(%d)
NULL
--instance of classWithToString--
Error: 2 - gzopen() expects parameter 3 to be long, object given, %s(%d)
NULL
--instance of classWithoutToString--
Error: 2 - gzopen() expects parameter 3 to be long, object given, %s(%d)
NULL
--undefined var--
resource(%d) of type (stream)
--unset var--
resource(%d) of type (stream)
--resource--
Error: 2 - gzopen() expects parameter 3 to be long, resource given, %s(%d)
NULL
===DONE===
@@ -0,0 +1,95 @@
<?php
/* Prototype : resource gzopen(string filename, string mode [, int use_include_path])
* Description: Open a .gz-file and return a .gz-file pointer
* Source code: ext/zlib/zlib.c
* Alias to functions:
*/
echo "*** Testing gzopen() : usage variation ***\n";
require_once('reading_include_path.inc');
//define the files to go into these directories, create one in dir2
echo "\n--- testing include path ---\n";
set_include_path($newIncludePath);
$modes = array("r", "r+", "rt");
foreach($modes as $mode) {
test_gzopen($mode);
}
restore_include_path();
// remove the directory structure
chdir($baseDir);
rmdir($workingDir);
foreach($newdirs as $newdir) {
rmdir($newdir);
}
chdir("..");
rmdir($thisTestDir);
function test_gzopen($mode) {
global $scriptFile, $secondFile, $firstFile, $filename;
// create a file in the middle directory
$h = gzopen($secondFile, "w");
gzwrite($h, "This is a file in dir2");
gzclose($h);
echo "\n** testing with mode=$mode **\n";
// should read dir2 file
$h = gzopen($filename, $mode, true);
gzpassthru($h);
gzclose($h);
echo "\n";
//create a file in dir1
$h = gzopen($firstFile, "w");
gzwrite($h, "This is a file in dir1");
gzclose($h);
//should now read dir1 file
$h = gzopen($filename, $mode, true);
gzpassthru($h);
gzclose($h);
echo "\n";
// create a file in working directory
$h = gzopen($filename, "w");
gzwrite($h, "This is a file in working dir");
gzclose($h);
//should still read dir1 file
$h = gzopen($filename, $mode, true);
gzpassthru($h);
gzclose($h);
echo "\n";
unlink($firstFile);
unlink($secondFile);
//should read the file in working dir
$h = gzopen($filename, $mode, true);
gzpassthru($h);
gzclose($h);
echo "\n";
// create a file in the script directory
$h = gzopen($scriptFile, "w");
gzwrite($h, "This is a file in script dir");
gzclose($h);
//should read the file in script dir
$h = gzopen($filename, $mode, true);
gzpassthru($h);
gzclose($h);
echo "\n";
//cleanup
unlink($filename);
unlink($scriptFile);
}
?>
===DONE===
@@ -0,0 +1,40 @@
*** Testing gzopen() : usage variation ***
--- testing include path ---
** testing with mode=r **
This is a file in dir2
This is a file in dir1
This is a file in dir1
This is a file in working dir
This is a file in script dir
** testing with mode=r+ **
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
** testing with mode=rt **
This is a file in dir2
This is a file in dir1
This is a file in dir1
This is a file in working dir
This is a file in script dir
===DONE===
@@ -0,0 +1,55 @@
<?php
/* Prototype : resource gzopen(string filename, string mode [, int use_include_path])
* Description: Open a .gz-file and return a .gz-file pointer
* Source code: ext/zlib/zlib.c
* Alias to functions:
*/
require_once('gzopen_include_path.inc');
echo "*** Testing gzopen() : variation ***\n";
$thisTestDir = "gzopenVariation5.dir";
mkdir($thisTestDir);
chdir($thisTestDir);
$newpath = relative_include_path();
set_include_path($newpath);
runtest();
$newpath = generate_next_rel_path();
set_include_path($newpath);
runtest();
teardown_relative_path();
restore_include_path();
chdir("..");
rmdir($thisTestDir);
function runtest() {
$tmpfile = 'gzopen_variation5.tmp';
$h = gzopen($tmpfile, "w", true);
fwrite($h, "This is the test file");
fclose($h);
$h = @gzopen($tmpfile, "r");
if ($h === false) {
echo "Not created in working dir\n";
}
else {
echo "created in working dir\n";
gzclose($h);
unlink($tmpfile);
}
$h = @gzopen('dir1/'.$tmpfile, "r");
if ($h === false) {
echo "Not created in dir1\n";
}
else {
echo "created in dir1\n";
gzclose($h);
unlink('dir1/'.$tmpfile);
}
}
?>
===DONE===
@@ -0,0 +1,6 @@
*** Testing gzopen() : variation ***
created in working dir
Not created in dir1
created in working dir
Not created in dir1
===DONE===
@@ -0,0 +1,25 @@
<?php
/* Prototype : resource gzopen(string filename, string mode [, int use_include_path])
* Description: Open a .gz-file and return a .gz-file pointer
* Source code: ext/zlib/zlib.c
* Alias to functions:
*/
echo "*** Testing gzopen() : variation ***\n";
$modes = array('r+', 'rf', 'w+' , 'e');
$file = dirname(__FILE__)."/004.txt.gz";
foreach ($modes as $mode) {
echo "mode=$mode\n";
$h = gzopen($file, $mode);
echo "gzopen=";
var_dump($h);
if ($h !== false) {
gzclose($h);
}
echo "\n";
}
?>
===DONE===
@@ -0,0 +1,17 @@
*** Testing gzopen() : variation ***
mode=r+
HipHop Warning: %a
gzopen=bool(false)
mode=rf
gzopen=resource(%d) of type (stream)
mode=w+
HipHop Warning: %a
gzopen=bool(false)
mode=e
HipHop Warning: %a
gzopen=bool(false)
===DONE===
@@ -0,0 +1,12 @@
<?php
$f = dirname(__FILE__)."/004.txt.gz";
$h = gzopen($f, 'r');
$extra_arg = 'nothing';
var_dump(gzpassthru( $h, $extra_arg ) );
var_dump(gzpassthru() );
gzclose($h);
?>
===DONE===
@@ -0,0 +1,5 @@
HipHop Warning: %a
bool(false)
HipHop Warning: %a
bool(false)
===DONE===
+15
Ver Arquivo
@@ -0,0 +1,15 @@
<?php
$f = dirname(__FILE__)."/004.txt.gz";
$h = gzopen($f, 'r');
$length = 10;
$extra_arg = 'nothing';
var_dump(gzread( $h, $length, $extra_arg ) );
var_dump(gzread());
gzclose($h);
?>
===DONE===
@@ -0,0 +1,5 @@
HipHop Warning: %a
bool(false)
HipHop Warning: %a
bool(false)
===DONE===
@@ -0,0 +1,12 @@
<?php
$f = dirname(__FILE__)."/004.txt.gz";
$h = gzopen($f, 'r');
var_dump(gzread($h, 10));
var_dump(gzread($h, 0));
var_dump(gzread($h, 5));
var_dump(gzread($h, -1));
var_dump(gzread($h, 8));
gzclose($h);
?>
===DONE===
@@ -0,0 +1,8 @@
string(10) "When you'r"
HipHop Warning: %a
bool(false)
string(5) "e tau"
HipHop Warning: %a
bool(false)
string(8) "ght thro"
===DONE===
@@ -0,0 +1,42 @@
<?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);
?>
@@ -0,0 +1,5 @@
int(36864)
int(36864)
Strings are equal
int(18432)
Strings are equal
@@ -0,0 +1,16 @@
<?php
$f = dirname(__FILE__)."/004.txt.gz";
$h = gzopen($f, 'r');
echo "test rewind before doing anything\n";
var_dump(gzrewind($h));
var_dump(gztell($h));
echo "\nfirst 30 characters=".gzread($h, 30)."\n";
var_dump(gztell($h));
gzrewind($h);
var_dump(gztell($h));
echo "first 10 characters=".gzread($h, 10)."\n";
gzrewind($h);
echo "first 20 characters=".gzread($h, 20)."\n";
gzclose($h);
?>
===DONE===
@@ -0,0 +1,10 @@
test rewind before doing anything
bool(true)
int(0)
first 30 characters=When you're taught through fee
int(30)
int(0)
first 10 characters=When you'r
first 20 characters=When you're taught t
===DONE===
@@ -0,0 +1,11 @@
<?php
$f = dirname(__FILE__)."/004.txt.gz";
$h = gzopen($f, 'r');
$extra_arg = 'nothing';
var_dump(gzrewind( $h, $extra_arg ) );
var_dump(gzrewind());
gzclose($h);
?>
===DONE===
@@ -0,0 +1,5 @@
HipHop Warning: %a
bool(false)
HipHop Warning: %a
bool(false)
===DONE===
@@ -0,0 +1,15 @@
<?php
$f = "temp2.txt.gz";
$h = gzopen($f, 'w');
gzwrite($h, b'The first string.');
var_dump(gzrewind($h));
gzwrite($h, b'The second string.');
gzclose($h);
$h = gzopen($f, 'r');
gzpassthru($h);
gzclose($h);
unlink($f);
echo "\n";
?>
===DONE===
@@ -0,0 +1,3 @@
bool(false)
The first string.The second string.
===DONE===
+24
Ver Arquivo
@@ -0,0 +1,24 @@
<?php
$f = dirname(__FILE__)."/004.txt.gz";
$h = gzopen($f, 'r');
echo "move to the 50th byte\n";
var_dump(gzseek( $h, 50 ) );
echo "tell=".gztell($h)."\n";
//read the next 10
var_dump(gzread($h, 10));
echo "\nmove forward to the 100th byte\n";
var_dump(gzseek( $h, 100 ) );
echo "tell=".gztell($h)."\n";
//read the next 10
var_dump(gzread($h, 10));
echo "\nmove backward to the 20th byte\n";
var_dump(gzseek( $h, 20 ) );
echo "tell=".gztell($h)."\n";
//read the next 10
var_dump(gzread($h, 10));
gzclose($h);
?>
===DONE===
@@ -0,0 +1,15 @@
move to the 50th byte
int(0)
tell=50
string(10) " high abov"
move forward to the 100th byte
int(0)
tell=100
string(10) "Destiny wh"
move backward to the 20th byte
int(0)
tell=20
string(10) "hrough fee"
===DONE===
+13
Ver Arquivo
@@ -0,0 +1,13 @@
<?php
$f = dirname(__FILE__)."/004.txt.gz";
$h = gzopen($f, 'r');
$offset = 1;
$whence = SEEK_SET;
$extra_arg = 'nothing';
var_dump(gzseek( $h, $offset, $whence, $extra_arg ) );
var_dump(gzseek($h));
var_dump(gzseek());
?>
===DONE===
@@ -0,0 +1,7 @@
HipHop Warning: %a
bool(false)
HipHop Warning: %a
bool(false)
HipHop Warning: %a
bool(false)
===DONE===

Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais