Fixes for wxHashTable when wxUSE_STL=1:

wxHashTable must work like an hash_multimap, not an hash_map.
wxHashTable::Delete is supposed to actually delete entries
more tests in console sample.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23034 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Mattia Barbon
2003-08-19 21:17:04 +00:00
parent 8b7ac60523
commit 760d3c7cd3
3 changed files with 76 additions and 22 deletions

View File

@@ -1152,10 +1152,11 @@ static void TestHash()
{
wxHashTable hash(wxKEY_INTEGER), hash2(wxKEY_STRING);
wxObject o;
int i;
for ( i = 0; i < 100; ++i )
hash.Put(i, (wxObject*)&i + i);
hash.Put(i, &o + i);
hash.BeginFind();
wxHashTable::compatibility_iterator it = hash.Next();
@@ -1171,18 +1172,50 @@ static void TestHash()
wxPuts(_T("Error in wxHashTable::compatibility_iterator\n"));
for ( i = 99; i >= 0; --i )
if( hash.Get(i) != (wxObject*)&i + i )
if( hash.Get(i) != &o + i )
wxPuts(_T("Error in wxHashTable::Get/Put\n"));
hash2.Put("foo", (wxObject*)&i + 1);
hash2.Put("bar", (wxObject*)&i + 2);
hash2.Put("baz", (wxObject*)&i + 3);
for ( i = 0; i < 100; ++i )
hash.Put(i, &o + i + 20);
if (hash2.Get("moo") != NULL)
for ( i = 99; i >= 0; --i )
if( hash.Get(i) != &o + i)
wxPuts(_T("Error (2) in wxHashTable::Get/Put\n"));
for ( i = 0; i < 50; ++i )
if( hash.Delete(i) != &o + i)
wxPuts(_T("Error in wxHashTable::Delete\n"));
for ( i = 50; i < 100; ++i )
if( hash.Get(i) != &o + i)
wxPuts(_T("Error (3) in wxHashTable::Get/Put\n"));
for ( i = 0; i < 50; ++i )
if( hash.Get(i) != &o + i + 20)
wxPuts(_T("Error (4) in wxHashTable::Put/Delete\n"));
for ( i = 0; i < 50; ++i )
if( hash.Delete(i) != &o + i + 20)
wxPuts(_T("Error (2) in wxHashTable::Delete\n"));
for ( i = 0; i < 50; ++i )
if( hash.Get(i) != NULL)
wxPuts(_T("Error (5) in wxHashTable::Put/Delete\n"));
hash2.Put(_T("foo"), &o + 1);
hash2.Put(_T("bar"), &o + 2);
hash2.Put(_T("baz"), &o + 3);
if (hash2.Get(_T("moo")) != NULL)
wxPuts(_T("Error in wxHashTable::Get\n"));
if (hash2.Get("bar") != (wxObject*)&i + 2)
if (hash2.Get(_T("bar")) != &o + 2)
wxPuts(_T("Error in wxHashTable::Get/Put\n"));
hash2.Put(_T("bar"), &o + 0);
if (hash2.Get(_T("bar")) != &o + 2)
wxPuts(_T("Error (2) in wxHashTable::Get/Put\n"));
}
#if !wxUSE_STL
{