diff options
| author | Antony Dovgal <tony2001@php.net> | 2008-07-13 19:47:52 +0000 |
|---|---|---|
| committer | Antony Dovgal <tony2001@php.net> | 2008-07-13 19:47:52 +0000 |
| commit | 4f040525efed4c332d14841c28be22147294a88f (patch) | |
| tree | 9d0a851534e63e9c47205eb2240732b643c32994 /ext/spl/tests/fixedarray_021.phpt | |
| parent | f60da35554fd2d6c2990d2682add3d32e2d1ccf0 (diff) | |
| download | php-git-4f040525efed4c332d14841c28be22147294a88f.tar.gz | |
improve code coverage
Diffstat (limited to 'ext/spl/tests/fixedarray_021.phpt')
| -rw-r--r-- | ext/spl/tests/fixedarray_021.phpt | 66 |
1 files changed, 66 insertions, 0 deletions
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-- +<?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) +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== |
