Decrement _nele when erasing an element from hashmap, and add a test-case for this bug.

svn-id: r32343
This commit is contained in:
Willem Jan Palenstijn 2008-05-28 18:32:05 +00:00
parent 16b0905bb0
commit 90bf3de2d6
2 changed files with 4 additions and 0 deletions

View File

@ -535,6 +535,7 @@ void HashMap<Key, Val, HashFunc, EqualFunc>::erase(const Key &key) {
}
}
_arr[i] = NULL;
_nele--;
return;
}

View File

@ -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 )