Browse Source

- MFH

- Bug #46615
- Return the count - 1 when invoking SplHeap->key()
- Adjusted the tests
PECL
David Coallier 18 years ago
parent
commit
16de7fbd16
  1. 4
      ext/spl/spl_heap.c
  2. 9
      ext/spl/tests/heap_007.phpt
  3. 8
      ext/spl/tests/pqueue_003.phpt

4
ext/spl/spl_heap.c

@ -970,8 +970,8 @@ static void spl_heap_it_move_forward(zend_object_iterator *iter TSRMLS_DC) /* {{
SPL_METHOD(SplHeap, key) SPL_METHOD(SplHeap, key)
{ {
spl_heap_object *intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC); spl_heap_object *intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
RETURN_LONG(intern->heap->count);
RETURN_LONG(intern->heap->count - 1);
} }
/* }}} */ /* }}} */

9
ext/spl/tests/heap_007.phpt

@ -12,6 +12,7 @@ $h->insert(4);
$h->rewind(); $h->rewind();
echo "count(\$h) = ".count($h)."\n"; echo "count(\$h) = ".count($h)."\n";
echo "\$h->count() = ".$h->count()."\n"; echo "\$h->count() = ".$h->count()."\n";
while ($h->valid()) { while ($h->valid()) {
$k = $h->key(); $k = $h->key();
$v = $h->current(); $v = $h->current();
@ -24,8 +25,8 @@ while ($h->valid()) {
--EXPECTF-- --EXPECTF--
count($h) = 4 count($h) = 4
$h->count() = 4 $h->count() = 4
4=>5
3=>4
2=>1
1=>0
3=>5
2=>4
1=>1
0=>0
===DONE=== ===DONE===

8
ext/spl/tests/pqueue_003.phpt

@ -24,8 +24,8 @@ while ($h->valid()) {
--EXPECTF-- --EXPECTF--
count($h) = 4 count($h) = 4
$h->count() = 4 $h->count() = 4
4=>5
3=>4
2=>1
1=>0
3=>5
2=>4
1=>1
0=>0
===DONE=== ===DONE===
Loading…
Cancel
Save