aboutsummaryrefslogtreecommitdiff
path: root/src/unit/hash.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/unit/hash.cpp')
-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[] )