From b7a687b08e32adafbb609bec7aa79b54f161ee4c Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sat, 20 Dec 2008 02:01:44 +0000 Subject: All of the basic, core workings of the Cache are complete, and tested. Even added some more tests and whatnot. A lot happened, but I can't remember everything. Also, Bu::File reports errors in more error cases. --- src/unit/hash.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/unit') diff --git a/src/unit/hash.cpp b/src/unit/hash.cpp index de4edd1..77160e3 100644 --- a/src/unit/hash.cpp +++ b/src/unit/hash.cpp @@ -24,6 +24,7 @@ public: addTest( Unit::insert1 ); addTest( Unit::insert2 ); addTest( Unit::probe1 ); + addTest( Unit::erase1 ); } virtual ~Unit() @@ -66,6 +67,26 @@ public: unitTest( h3["Hi"].getValue() = "Yo" ); unitTest( h3["Bye"].getValue() = "Later" ); } + + void erase1() + { + StrIntHash h; + h.insert("Number 1", 1 ); + h.insert("Number 2", 2 ); + h.insert("Number 3", 3 ); + h.erase("Number 2"); + h.get("Number 3"); + try { + h.get("Number 2"); + unitFailed("h.get(\"Number 2\") should have thrown an exception."); + } catch( Bu::HashException &e ) { } + + printf("\n"); + for( StrIntHash::iterator i = h.begin(); i != h.end(); i++ ) + { + printf(" - \"%s\" = %d\n", i.getKey().getStr(), i.getValue() ); + } + } }; int main( int argc, char *argv[] ) -- cgit v1.2.3