aboutsummaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2006-11-22 06:31:53 +0000
committerMike Buland <eichlan@xagasoft.com>2006-11-22 06:31:53 +0000
commit5cb339f6d3759e566da5ee7eef5d7609570ee8f6 (patch)
tree124908ad391aebc38f8ea5d3143aa42c3f4ce175 /src/tests
parenta6e4c198a23217f126a5abf759b91382dd829e90 (diff)
downloadlibbu++-5cb339f6d3759e566da5ee7eef5d7609570ee8f6.tar.gz
libbu++-5cb339f6d3759e566da5ee7eef5d7609570ee8f6.tar.bz2
libbu++-5cb339f6d3759e566da5ee7eef5d7609570ee8f6.tar.xz
libbu++-5cb339f6d3759e566da5ee7eef5d7609570ee8f6.zip
Fixed a silly mistake that made the whole thing useless when using strings.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/hash.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/tests/hash.cpp b/src/tests/hash.cpp
index 58e0112..2fc6968 100644
--- a/src/tests/hash.cpp
+++ b/src/tests/hash.cpp
@@ -58,24 +58,28 @@ int main()
58 NULL 58 NULL
59 }; 59 };
60 60
61 Hash<std::string, int> sTest; 61 Hash<const char *, int> sTest;
62 62
63 printf("Inserting\n-------------------\n\n"); 63 printf("Inserting\n-------------------\n\n");
64 for( int j = 0; j < 33; j++ ) 64 for( int j = 0; j < 33; j++ )
65 { 65 {
66 sTest[names[j]] = j; 66 sTest[names[j]] = j;
67 } 67 }
68
69 printf("Test1: %d, Test2: %d\n", sTest.has("Lemon of Troy"), sTest.has(std::string("Lemon of Troy").c_str() ) );
70
71 sTest.has(std::string("Lemon of Troy").c_str() );
68 72
69 printf("Getting\n-------------------\n\n"); 73 printf("Getting\n-------------------\n\n");
70 74
71 sTest.erase("Homer the Great"); 75 sTest.erase("Homer the Great");
72 sTest["Bart's Comet"].erase(); 76 sTest["Bart's Comet"].erase();
73 77
74 for( Hash<std::string, int>::iterator i = sTest.begin(); 78 for( Hash<const char *, int>::iterator i = sTest.begin();
75 i != sTest.end(); i++ ) 79 i != sTest.end(); i++ )
76 { 80 {
77 Hash<std::string, int>::iterator j = i; 81 Hash<const char *, int>::iterator j = i;
78 printf("%d: %s\n", (*j).second, (*j).first.c_str() ); 82 printf("%d: %s\n", (*j).second, (*j).first );
79 } 83 }
80 84
81 printf("Testing\n-------------------\n\n"); 85 printf("Testing\n-------------------\n\n");
@@ -101,11 +105,12 @@ int main()
101 105
102 sTest.clear(); 106 sTest.clear();
103 107
104 for( Hash<std::string, int>::iterator i = sTest.begin(); 108 for( Hash<const char *, int>::iterator i = sTest.begin();
105 i != sTest.end(); i++ ) 109 i != sTest.end(); i++ )
106 { 110 {
107 Hash<std::string, int>::iterator j = i; 111 Hash<const char *, int>::iterator j = i;
108 printf("%d: %s\n", (*j).second, (*j).first.c_str() ); 112 printf("%d: %s\n", (*j).second, (*j).first );
109 } 113 }
114
110} 115}
111 116