+ myStringHashMap sh(0); // as small as possible
+ wxString buf;
+ size_t i;
+ const size_t count = 10000;
+
+ // init with some data
+ for( i = 0; i < count; ++i )
+ {
+ buf.Printf(wxT("%d"), i );
+ sh[buf] = wxT("A") + buf + wxT("C");
+ }
+
+ // test that insertion worked
+ CPPUNIT_ASSERT( sh.size() == count );
+
+ for( i = 0; i < count; ++i )
+ {
+ buf.Printf(wxT("%d"), i );
+ CPPUNIT_ASSERT( sh[buf] == wxT("A") + buf + wxT("C") );
+ }
+
+ // check that iterators work
+ Itor it;
+ for( i = 0, it = sh.begin(); it != sh.end(); ++it, ++i )
+ {
+ CPPUNIT_ASSERT( i != count );
+ CPPUNIT_ASSERT( it->second == sh[it->first] );
+ }
+
+ CPPUNIT_ASSERT( sh.size() == i );
+
+ // test copy ctor, assignment operator
+ myStringHashMap h1( sh ), h2( 0 );
+ h2 = sh;
+
+ for( i = 0, it = sh.begin(); it != sh.end(); ++it, ++i )
+ {
+ CPPUNIT_ASSERT( h1[it->first] == it->second );
+ CPPUNIT_ASSERT( h2[it->first] == it->second );
+ }
+
+ // other tests
+ for( i = 0; i < count; ++i )
+ {
+ buf.Printf(wxT("%d"), i );
+ size_t sz = sh.size();
+
+ // test find() and erase(it)
+ if( i < 100 )
+ {
+ it = sh.find( buf );
+ CPPUNIT_ASSERT( it != sh.end() );
+
+ sh.erase( it );
+
+ CPPUNIT_ASSERT( sh.find( buf ) == sh.end() );
+ }
+ else
+ // test erase(key)
+ {
+ size_t c = sh.erase( buf );
+ CPPUNIT_ASSERT( c == 1 );
+ CPPUNIT_ASSERT( sh.find( buf ) == sh.end() );
+ }
+
+ // count should decrease
+ CPPUNIT_ASSERT( sh.size() == sz - 1 );
+ }