From 90bf3de2d66a6605fad7f6a050fae6d277d15f56 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 28 May 2008 18:32:05 +0000 Subject: [PATCH] Decrement _nele when erasing an element from hashmap, and add a test-case for this bug. svn-id: r32343 --- common/hashmap.h | 1 + test/common/hashmap.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/common/hashmap.h b/common/hashmap.h index 81a4b0d17e5..1bae44e98eb 100644 --- a/common/hashmap.h +++ b/common/hashmap.h @@ -535,6 +535,7 @@ void HashMap::erase(const Key &key) { } } _arr[i] = NULL; + _nele--; return; } diff --git a/test/common/hashmap.h b/test/common/hashmap.h index 883e965065c..5aa609bc00f 100644 --- a/test/common/hashmap.h +++ b/test/common/hashmap.h @@ -37,6 +37,9 @@ class HashMapTestSuite : public CxxTest::TestSuite TS_ASSERT( !container.contains(1) ); container[1] = 42; TS_ASSERT( container.contains(1) ); + container.erase(0); + container.erase(1); + TS_ASSERT( container.empty() ); } void test_lookup( void )