From 16de7fbd16d7a9cbed6e71db7b87bb3da0d2c6f4 Mon Sep 17 00:00:00 2001 From: David Coallier Date: Sat, 22 Nov 2008 14:19:47 +0000 Subject: [PATCH] - MFH - Bug #46615 - Return the count - 1 when invoking SplHeap->key() - Adjusted the tests --- ext/spl/spl_heap.c | 4 ++-- ext/spl/tests/heap_007.phpt | 9 +++++---- ext/spl/tests/pqueue_003.phpt | 8 ++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c index fe82d81644..f073597af1 100644 --- a/ext/spl/spl_heap.c +++ b/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_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); } /* }}} */ diff --git a/ext/spl/tests/heap_007.phpt b/ext/spl/tests/heap_007.phpt index 784ac6e8b0..e8d5c9997c 100644 --- a/ext/spl/tests/heap_007.phpt +++ b/ext/spl/tests/heap_007.phpt @@ -12,6 +12,7 @@ $h->insert(4); $h->rewind(); echo "count(\$h) = ".count($h)."\n"; echo "\$h->count() = ".$h->count()."\n"; + while ($h->valid()) { $k = $h->key(); $v = $h->current(); @@ -24,8 +25,8 @@ while ($h->valid()) { --EXPECTF-- count($h) = 4 $h->count() = 4 -4=>5 -3=>4 -2=>1 -1=>0 +3=>5 +2=>4 +1=>1 +0=>0 ===DONE=== diff --git a/ext/spl/tests/pqueue_003.phpt b/ext/spl/tests/pqueue_003.phpt index 8abc72c4c7..9c0b5a5147 100644 --- a/ext/spl/tests/pqueue_003.phpt +++ b/ext/spl/tests/pqueue_003.phpt @@ -24,8 +24,8 @@ while ($h->valid()) { --EXPECTF-- count($h) = 4 $h->count() = 4 -4=>5 -3=>4 -2=>1 -1=>0 +3=>5 +2=>4 +1=>1 +0=>0 ===DONE=== -- 2.50.1