summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2008-07-13 19:47:27 +0000
committerAntony Dovgal <tony2001@php.net>2008-07-13 19:47:27 +0000
commit05028ba6d38e84632a5c9099df0b71a6ef921a26 (patch)
tree68e7cd399949f8ece02c6985036c461e6bfabc08
parentb111b673e695c06f13e1e7df6bbfaf5de0362dc9 (diff)
downloadphp-git-05028ba6d38e84632a5c9099df0b71a6ef921a26.tar.gz
improve code coverage
-rw-r--r--ext/spl/tests/fixedarray_010.phpt31
-rw-r--r--ext/spl/tests/fixedarray_021.phpt66
2 files changed, 97 insertions, 0 deletions
diff --git a/ext/spl/tests/fixedarray_010.phpt b/ext/spl/tests/fixedarray_010.phpt
index 9d53475f7d..472e8b07a2 100644
--- a/ext/spl/tests/fixedarray_010.phpt
+++ b/ext/spl/tests/fixedarray_010.phpt
@@ -12,8 +12,39 @@ $a->setSize(2);
$a->setSize(3);
$a->setSize(0);
+$a = new SplFixedArray(0);
+$a->setSize(0);
+var_dump($a->getSize());
+
+$a = new SplFixedArray(10);
+$a->setSize(10);
+var_dump($a->getSize());
+
+$a = new SplFixedArray(1);
+$a->setSize(5);
+var_dump($a->getSize());
+
+$a = new SplFixedArray(20);
+$a->setSize(3);
+var_dump($a->getSize());
+
+$a = new SplFixedArray(3);
+
+$a[0] = "test";
+$a[1] = array(1,2,"blah");
+$a[2] = 1;
+$a[0] = "test";
+
+$a->setSize(0);
+var_dump($a->getSize());
+
print "ok\n";
?>
--EXPECT--
+int(0)
+int(10)
+int(5)
+int(3)
+int(0)
ok
diff --git a/ext/spl/tests/fixedarray_021.phpt b/ext/spl/tests/fixedarray_021.phpt
new file mode 100644
index 0000000000..4aa5feb502
--- /dev/null
+++ b/ext/spl/tests/fixedarray_021.phpt
@@ -0,0 +1,66 @@
+--TEST--
+SPL: FixedArray: misc small tests
+--FILE--
+<?php
+
+/* empty count */
+$a = new SplFixedArray();
+
+var_dump(count($a));
+var_dump($a->count());
+
+/* negative init value */
+try {
+ $b = new SplFixedArray(-10);
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+/* resize and negative value */
+$b = new SplFixedArray();
+try {
+ $b->setSize(-5);
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+/* calling __construct() twice */
+$c = new SplFixedArray(0);
+var_dump($c->__construct());
+
+/* fromArray() from empty array */
+$d = new SplFixedArray();
+$d->fromArray(array());
+
+var_dump(count($a));
+var_dump($a->count());
+var_dump($a);
+
+/* foreach by ref */
+$e = new SplFixedArray(10);
+$e[0] = 1;
+$e[1] = 5;
+$e[2] = 10;
+
+try {
+ foreach ($e as $k=>&$v) {
+ var_dump($v);
+ }
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+?>
+==DONE==
+--EXPECTF--
+int(0)
+int(0)
+unicode(35) "array size cannot be less than zero"
+unicode(35) "array size cannot be less than zero"
+NULL
+int(0)
+int(0)
+object(SplFixedArray)#$d (0) {
+}
+unicode(52) "An iterator cannot be used with foreach by reference"
+==DONE==