From 5cb339f6d3759e566da5ee7eef5d7609570ee8f6 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 22 Nov 2006 06:31:53 +0000 Subject: Fixed a silly mistake that made the whole thing useless when using strings. --- src/hash.cpp | 2 +- src/tests/hash.cpp | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/hash.cpp b/src/hash.cpp index a32fa2a..d477aff 100644 --- a/src/hash.cpp +++ b/src/hash.cpp @@ -44,7 +44,7 @@ template<> bool __cmpHashKeys( const char *a, const char *b ) if( a == b ) return true; - for(; *a != *b; a++, b++ ) + for(; *a == *b; a++, b++ ) if( *a == '\0' && *b == '\0' ) return true; 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() NULL }; - Hash sTest; + Hash sTest; printf("Inserting\n-------------------\n\n"); for( int j = 0; j < 33; j++ ) { sTest[names[j]] = j; } + + printf("Test1: %d, Test2: %d\n", sTest.has("Lemon of Troy"), sTest.has(std::string("Lemon of Troy").c_str() ) ); + + sTest.has(std::string("Lemon of Troy").c_str() ); printf("Getting\n-------------------\n\n"); sTest.erase("Homer the Great"); sTest["Bart's Comet"].erase(); - for( Hash::iterator i = sTest.begin(); + for( Hash::iterator i = sTest.begin(); i != sTest.end(); i++ ) { - Hash::iterator j = i; - printf("%d: %s\n", (*j).second, (*j).first.c_str() ); + Hash::iterator j = i; + printf("%d: %s\n", (*j).second, (*j).first ); } printf("Testing\n-------------------\n\n"); @@ -101,11 +105,12 @@ int main() sTest.clear(); - for( Hash::iterator i = sTest.begin(); + for( Hash::iterator i = sTest.begin(); i != sTest.end(); i++ ) { - Hash::iterator j = i; - printf("%d: %s\n", (*j).second, (*j).first.c_str() ); + Hash::iterator j = i; + printf("%d: %s\n", (*j).second, (*j).first ); } + } -- cgit v1.2.3