]> granicus.if.org Git - php/commitdiff
improve code coverage
authorAntony Dovgal <tony2001@php.net>
Sun, 13 Jul 2008 19:47:27 +0000 (19:47 +0000)
committerAntony Dovgal <tony2001@php.net>
Sun, 13 Jul 2008 19:47:27 +0000 (19:47 +0000)
ext/spl/tests/fixedarray_010.phpt
ext/spl/tests/fixedarray_021.phpt [new file with mode: 0644]

index 9d53475f7d3890af9b6dc0aa738352f2ad04164f..472e8b07a232d393c389e204e910f69a4cd2eff5 100644 (file)
@@ -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 (file)
index 0000000..4aa5feb
--- /dev/null
@@ -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==