summaryrefslogtreecommitdiff
path: root/src/unit/hash.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2008-12-20 02:01:44 +0000
committerMike Buland <eichlan@xagasoft.com>2008-12-20 02:01:44 +0000
commitb7a687b08e32adafbb609bec7aa79b54f161ee4c (patch)
tree9c0214eb7fa5c69619bb4226cb292d19445b92df /src/unit/hash.cpp
parent5db154c3fb36a677c551e39c3c6661207eb51778 (diff)
downloadlibbu++-b7a687b08e32adafbb609bec7aa79b54f161ee4c.tar.gz
libbu++-b7a687b08e32adafbb609bec7aa79b54f161ee4c.tar.bz2
libbu++-b7a687b08e32adafbb609bec7aa79b54f161ee4c.tar.xz
libbu++-b7a687b08e32adafbb609bec7aa79b54f161ee4c.zip
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.
Diffstat (limited to '')
-rw-r--r--src/unit/hash.cpp21
1 files changed, 21 insertions, 0 deletions
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:
24 addTest( Unit::insert1 ); 24 addTest( Unit::insert1 );
25 addTest( Unit::insert2 ); 25 addTest( Unit::insert2 );
26 addTest( Unit::probe1 ); 26 addTest( Unit::probe1 );
27 addTest( Unit::erase1 );
27 } 28 }
28 29
29 virtual ~Unit() 30 virtual ~Unit()
@@ -66,6 +67,26 @@ public:
66 unitTest( h3["Hi"].getValue() = "Yo" ); 67 unitTest( h3["Hi"].getValue() = "Yo" );
67 unitTest( h3["Bye"].getValue() = "Later" ); 68 unitTest( h3["Bye"].getValue() = "Later" );
68 } 69 }
70
71 void erase1()
72 {
73 StrIntHash h;
74 h.insert("Number 1", 1 );
75 h.insert("Number 2", 2 );
76 h.insert("Number 3", 3 );
77 h.erase("Number 2");
78 h.get("Number 3");
79 try {
80 h.get("Number 2");
81 unitFailed("h.get(\"Number 2\") should have thrown an exception.");
82 } catch( Bu::HashException &e ) { }
83
84 printf("\n");
85 for( StrIntHash::iterator i = h.begin(); i != h.end(); i++ )
86 {
87 printf(" - \"%s\" = %d\n", i.getKey().getStr(), i.getValue() );
88 }
89 }
69}; 90};
70 91
71int main( int argc, char *argv[] ) 92int main( int argc, char *argv[] )