From: Antony Dovgal Date: Sun, 13 Jul 2008 19:47:52 +0000 (+0000) Subject: improve code coverage X-Git-Tag: php-5.3.0alpha1~374 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4f040525efed4c332d14841c28be22147294a88f;p=php improve code coverage --- 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..ecefe56e0e --- /dev/null +++ b/ext/spl/tests/fixedarray_021.phpt @@ -0,0 +1,66 @@ +--TEST-- +SPL: FixedArray: misc small tests +--FILE-- +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) +string(35) "array size cannot be less than zero" +string(35) "array size cannot be less than zero" +NULL +int(0) +int(0) +object(SplFixedArray)#%d (0) { +} +string(52) "An iterator cannot be used with foreach by reference" +==DONE==