summaryrefslogtreecommitdiff
path: root/ext/bz2
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2006-06-26 22:17:18 +0000
committerAntony Dovgal <tony2001@php.net>2006-06-26 22:17:18 +0000
commit3d63ca3edcd9f29b8ccfb704ef61f4accecfbfe5 (patch)
treeddab8674fe3f5db22b723ca451d3f5e60eacfc17 /ext/bz2
parent5d2d2fd5a396cdeafd18d2f688888ffe9f75b1c7 (diff)
downloadphp-git-3d63ca3edcd9f29b8ccfb704ef61f4accecfbfe5.tar.gz
add new tests, improve the old ones
Diffstat (limited to 'ext/bz2')
-rw-r--r--ext/bz2/tests/001.phpt2
-rw-r--r--ext/bz2/tests/002.phpt2
-rw-r--r--ext/bz2/tests/003.phpt40
-rw-r--r--ext/bz2/tests/003.txt.bz2bin0 -> 126 bytes
-rw-r--r--ext/bz2/tests/004.phpt111
-rw-r--r--ext/bz2/tests/004_1.txt.bz2bin0 -> 125 bytes
-rw-r--r--ext/bz2/tests/004_2.txt.bz2bin0 -> 123 bytes
-rw-r--r--ext/bz2/tests/005.phpt71
8 files changed, 226 insertions, 0 deletions
diff --git a/ext/bz2/tests/001.phpt b/ext/bz2/tests/001.phpt
index 0e1265f406..a4ef1a2af7 100644
--- a/ext/bz2/tests/001.phpt
+++ b/ext/bz2/tests/001.phpt
@@ -1,5 +1,7 @@
--TEST--
bzopen() and invalid parameters
+--SKIPIF--
+<?php if (!extension_loaded("bz2")) print "skip"; ?>
--FILE--
<?php
diff --git a/ext/bz2/tests/002.phpt b/ext/bz2/tests/002.phpt
index fc538d6024..28c4862ac7 100644
--- a/ext/bz2/tests/002.phpt
+++ b/ext/bz2/tests/002.phpt
@@ -1,5 +1,7 @@
--TEST--
bzopen() using fd opened in wrong mode
+--SKIPIF--
+<?php if (!extension_loaded("bz2")) print "skip"; ?>
--FILE--
<?php
diff --git a/ext/bz2/tests/003.phpt b/ext/bz2/tests/003.phpt
new file mode 100644
index 0000000000..1432600087
--- /dev/null
+++ b/ext/bz2/tests/003.phpt
@@ -0,0 +1,40 @@
+--TEST--
+bzread() tests
+--SKIPIF--
+<?php if (!extension_loaded("bz2")) print "skip"; ?>
+--FILE--
+<?php
+
+$fd = bzopen(dirname(__FILE__)."/003.txt.bz2","r");
+var_dump(bzread());
+var_dump(bzread($fd, 1 ,0));
+var_dump(bzread($fd, 0));
+var_dump(bzread($fd, -10));
+var_dump(bzread($fd, 1));
+var_dump(bzread($fd, 2));
+var_dump(bzread($fd, 100000));
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: bzread() expects at least 1 parameter, 0 given in %s on line %d
+bool(false)
+
+Warning: bzread() expects at most 2 parameters, 3 given in %s on line %d
+bool(false)
+string(0) ""
+
+Warning: bzread(): length may not be negative in %s on line %d
+bool(false)
+string(1) "R"
+string(2) "is"
+string(251) "ing up from the heart of the desert
+Rising up for Jerusalem
+Rising up from the heat of the desert
+Building up Old Jerusalem
+Rising up from the heart of the desert
+Rising up for Jerusalem
+Rising up from the heat of the desert
+Heading out for Jerusalem
+"
+Done
diff --git a/ext/bz2/tests/003.txt.bz2 b/ext/bz2/tests/003.txt.bz2
new file mode 100644
index 0000000000..034cd4d8b7
--- /dev/null
+++ b/ext/bz2/tests/003.txt.bz2
Binary files differ
diff --git a/ext/bz2/tests/004.phpt b/ext/bz2/tests/004.phpt
new file mode 100644
index 0000000000..a638188bcb
--- /dev/null
+++ b/ext/bz2/tests/004.phpt
@@ -0,0 +1,111 @@
+--TEST--
+bzread() tests with invalid files
+--SKIPIF--
+<?php if (!extension_loaded("bz2")) print "skip"; ?>
+--FILE--
+<?php
+
+$fd = bzopen(dirname(__FILE__)."/004_1.txt.bz2","r");
+var_dump(bzerror($fd));
+var_dump(bzerrstr($fd));
+var_dump(bzerrno($fd));
+
+$fd2 = bzopen(dirname(__FILE__)."/004_2.txt.bz2","r");
+var_dump(bzerror($fd2));
+var_dump(bzerrstr($fd2));
+var_dump(bzerrno($fd2));
+
+var_dump(bzread($fd, 10));
+var_dump(bzerror($fd));
+var_dump(bzerrstr($fd));
+var_dump(bzerrno($fd));
+
+var_dump(bzread($fd2, 10));
+var_dump(bzerror($fd2));
+var_dump(bzerrstr($fd2));
+var_dump(bzerrno($fd2));
+
+var_dump(bzread($fd));
+var_dump(bzerror($fd));
+var_dump(bzerrstr($fd));
+var_dump(bzerrno($fd));
+
+var_dump(bzread($fd2));
+var_dump(bzerror($fd2));
+var_dump(bzerrstr($fd2));
+var_dump(bzerrno($fd2));
+
+bzclose($fd2);
+var_dump(bzread($fd2));
+var_dump(bzerror($fd2));
+var_dump(bzerrstr($fd2));
+var_dump(bzerrno($fd2));
+
+echo "Done\n";
+?>
+--EXPECTF--
+array(2) {
+ ["errno"]=>
+ int(0)
+ ["errstr"]=>
+ string(2) "OK"
+}
+string(2) "OK"
+int(0)
+array(2) {
+ ["errno"]=>
+ int(0)
+ ["errstr"]=>
+ string(2) "OK"
+}
+string(2) "OK"
+int(0)
+string(0) ""
+array(2) {
+ ["errno"]=>
+ int(-5)
+ ["errstr"]=>
+ string(16) "DATA_ERROR_MAGIC"
+}
+string(16) "DATA_ERROR_MAGIC"
+int(-5)
+string(0) ""
+array(2) {
+ ["errno"]=>
+ int(-4)
+ ["errstr"]=>
+ string(10) "DATA_ERROR"
+}
+string(10) "DATA_ERROR"
+int(-4)
+string(0) ""
+array(2) {
+ ["errno"]=>
+ int(-5)
+ ["errstr"]=>
+ string(16) "DATA_ERROR_MAGIC"
+}
+string(16) "DATA_ERROR_MAGIC"
+int(-5)
+string(0) ""
+array(2) {
+ ["errno"]=>
+ int(-4)
+ ["errstr"]=>
+ string(10) "DATA_ERROR"
+}
+string(10) "DATA_ERROR"
+int(-4)
+
+Warning: bzread(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: bzerror(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: bzerrstr(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: bzerrno(): %d is not a valid stream resource in %s on line %d
+bool(false)
+Done
diff --git a/ext/bz2/tests/004_1.txt.bz2 b/ext/bz2/tests/004_1.txt.bz2
new file mode 100644
index 0000000000..6a5067b277
--- /dev/null
+++ b/ext/bz2/tests/004_1.txt.bz2
Binary files differ
diff --git a/ext/bz2/tests/004_2.txt.bz2 b/ext/bz2/tests/004_2.txt.bz2
new file mode 100644
index 0000000000..9c19f043a4
--- /dev/null
+++ b/ext/bz2/tests/004_2.txt.bz2
Binary files differ
diff --git a/ext/bz2/tests/005.phpt b/ext/bz2/tests/005.phpt
new file mode 100644
index 0000000000..48323531ea
--- /dev/null
+++ b/ext/bz2/tests/005.phpt
@@ -0,0 +1,71 @@
+--TEST--
+bzcompress()/bzdecompress() tests
+--SKIPIF--
+<?php if (!extension_loaded("bz2")) print "skip"; ?>
+--FILE--
+<?php
+
+$string = "Life it seems, will fade away
+Drifting further everyday
+Getting lost within myself
+Nothing matters no one else";
+
+var_dump(bzcompress());
+var_dump(bzcompress(1,1,1));
+var_dump(bzcompress($string, 100));
+var_dump(bzcompress($string, 100, -1));
+var_dump(bzcompress($string, 100, 1000));
+var_dump(bzcompress($string, -1, 1));
+
+$data = bzcompress($string);
+$data2 = bzcompress($string, 1, 10);
+
+$data3 = $data2;
+$data3{3} = 0;
+
+var_dump(bzdecompress());
+var_dump(bzdecompress(1,1,1));
+var_dump(bzdecompress(1,1));
+var_dump(bzdecompress($data3));
+var_dump(bzdecompress($data3,1));
+
+var_dump(bzdecompress($data, -1));
+var_dump(bzdecompress($data, 0));
+var_dump(bzdecompress($data, 1000));
+var_dump(bzdecompress($data));
+var_dump(bzdecompress($data2));
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: Wrong parameter count for bzcompress() in %s on line %d
+NULL
+string(%d) "BZ%s"
+int(-2)
+int(-2)
+int(-2)
+int(-2)
+
+Warning: bzdecompress() expects at least 1 parameter, 0 given in %s on line %d
+bool(false)
+
+Warning: bzdecompress() expects at most 2 parameters, 3 given in %s on line %d
+bool(false)
+int(-5)
+int(-5)
+int(-5)
+bool(false)
+string(110) "Life it seems, will fade away
+Drifting further everyday
+Getting lost within myself
+Nothing matters no one else"
+bool(false)
+string(110) "Life it seems, will fade away
+Drifting further everyday
+Getting lost within myself
+Nothing matters no one else"
+string(110) "Life it seems, will fade away
+Drifting further everyday
+Getting lost within myself
+Nothing matters no one else"
+Done