From 7edb08f083dbe1408285a083e4132673b6e1d7be Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 21 Mar 2007 18:20:24 +0000 Subject: Fixed another random bug in the string compare for raw strings. --- src/tests/hashtest2.cpp | 70 +++++-------------------------------------------- 1 file changed, 6 insertions(+), 64 deletions(-) (limited to 'src/tests/hashtest2.cpp') diff --git a/src/tests/hashtest2.cpp b/src/tests/hashtest2.cpp index 9ac75d5..74700fd 100644 --- a/src/tests/hashtest2.cpp +++ b/src/tests/hashtest2.cpp @@ -1,72 +1,14 @@ #include "hash.h" #include -typedef struct CC -{ - const char *sKey; - const char *sData; -} CC; - -char *c(const char *s) -{ - int l = strlen(s); - char *o = new char[l+1]; - o[l] = '\0'; - memcpy(o, s, l); - - return o; -} - -CC *mkCC(const char *k, const char *d) -{ - CC *o = new CC; - o->sKey = c(k); - o->sData = c(d); - return o; -} - -void klCC(CC *c) -{ - delete[] c->sKey; - delete[] c->sData; - delete c; -} - -typedef Hash CCHash; - int main() { - char buf1[200]; - char buf2[200]; - CCHash h; - CC *tmp; - - for(int i=0;i<10;i++) - { - sprintf(buf1, "key_%d", i); - sprintf(buf2, "data_%d", i); - tmp = mkCC(buf1, buf2); - h[tmp->sKey] = tmp; - } - - for(int i=0;i<12;i++) - { - sprintf(buf1, "key_%d", i); - if(h.has(buf1)) - { - tmp = h[buf1]; - printf("GOT %s = %s\n", tmp->sKey, tmp->sData); - } - else - printf("%s is not in the table.\n", buf1); - } - - CCHash::iterator it = h.begin(); - for(;it!=h.end();it++) - { - tmp = (*it).second; - klCC(tmp); - } + char *a, *b; + a = new char[10]; + b = new char[10]; + strcpy( a, "Hey there"); + strcpy( b, "Hey there"); + printf("Same: %s\n", __cmpHashKeys( a, b )?"yes":"no"); return 0; } -- cgit v1.2.3