aboutsummaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2006-11-21 16:01:57 +0000
committerMike Buland <eichlan@xagasoft.com>2006-11-21 16:01:57 +0000
commit6f6bb9f9309a6d5e471579ec565d56e4d083dafb (patch)
tree5ab79eded3cdf59053e90cf24d977dca31fed495 /src/tests
parent525b50abe6b5a6e06c2b4ba327c9490de5277a5b (diff)
downloadlibbu++-6f6bb9f9309a6d5e471579ec565d56e4d083dafb.tar.gz
libbu++-6f6bb9f9309a6d5e471579ec565d56e4d083dafb.tar.bz2
libbu++-6f6bb9f9309a6d5e471579ec565d56e4d083dafb.tar.xz
libbu++-6f6bb9f9309a6d5e471579ec565d56e4d083dafb.zip
Added erase functionality, and specializations for using ints as hash keys, so
really it does everything the old one did, does it better, easier, and possibly faster.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/hash.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/tests/hash.cpp b/src/tests/hash.cpp
index 8406439..f9a8f12 100644
--- a/src/tests/hash.cpp
+++ b/src/tests/hash.cpp
@@ -67,11 +67,9 @@ int main()
67 } 67 }
68 68
69 printf("Getting\n-------------------\n\n"); 69 printf("Getting\n-------------------\n\n");
70 printf("%d\n", sTest.get( names[10] ) ); 70
71 printf("%d\n", (int)sTest[names[10]] ); 71 sTest.erase("Homer the Great");
72 sTest[names[10]] = 22; 72 sTest["Bart's Comet"].erase();
73 sTest["That one guy"] = 135;
74 printf("%d\n", (int)sTest[names[10]] );
75 73
76 for( Hash<std::string, int>::iterator i = sTest.begin(); 74 for( Hash<std::string, int>::iterator i = sTest.begin();
77 i != sTest.end(); i++ ) 75 i != sTest.end(); i++ )
@@ -79,5 +77,23 @@ int main()
79 Hash<std::string, int>::iterator j = i; 77 Hash<std::string, int>::iterator j = i;
80 printf("%d: %s\n", (*j).second, (*j).first.c_str() ); 78 printf("%d: %s\n", (*j).second, (*j).first.c_str() );
81 } 79 }
80
81 for( int j = 0; j < 33; j++ )
82 {
83 if( sTest[names[j]].isFilled() )
84 {
85 if( sTest[names[j]] != j )
86 {
87 printf("'%s' should be %d, is %d\n",
88 names[j], j,
89 sTest[names[j]].value()
90 );
91 }
92 }
93 else
94 {
95 printf("Missing element %d, '%s'\n", j, names[j] );
96 }
97 }
82} 98}
83 99