From: mquinson Date: Wed, 23 Feb 2005 08:17:24 +0000 (+0000) Subject: Try harder to break that pile of crap when storing NULL X-Git-Tag: v3.3~4307 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/aa324d2e65e7b57cae9108a6664be800e2582837 Try harder to break that pile of crap when storing NULL git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1045 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/testsuite/xbt/dict_usage.c b/testsuite/xbt/dict_usage.c index e521ca804c..6f2a23e215 100644 --- a/testsuite/xbt/dict_usage.c +++ b/testsuite/xbt/dict_usage.c @@ -59,7 +59,7 @@ static xbt_error_t search(xbt_dict_t head,const char*key) { errcode=xbt_dict_get(head,key,&data); - printf(" - Search %s. Found %s\n",key,data?(char*)data:"(null)");fflush(stdout); + printf(" - Search %s. Found %s\n",key,data?(char*)data:"NULL");fflush(stdout); if (!data) return errcode; if (strcmp((char*)data,key)) @@ -85,7 +85,7 @@ static xbt_error_t traverse(xbt_dict_t head) { xbt_dict_foreach(head,cursor,key,data) { printf(" - Seen: %s->%s\n",key,data); - xbt_assert2(!strcmp(key,data), + xbt_assert2(!data || !strcmp(key,data), "Key(%s) != value(%s). Abording\n",key,data); } return no_error; @@ -110,10 +110,25 @@ int main(int argc,char **argv) { fill(&head); + /* xbt_dict_dump(head,(void (*)(void*))&printf);*/ printf(" - Test that it works with NULL data\n"); - printf(" - Store NULL under 'null'\n"); + printf(" - Store NULL under 'null'\n");fflush(stdout); xbt_dict_set(head,"null",NULL,NULL); TRYFAIL(search(head,"null")); + /* xbt_dict_dump(head,(void (*)(void*))&printf); */ + printf(" Check whether I see it while traversing\n");fflush(stdout); + { + xbt_dict_cursor_t cursor=NULL; + char *key; + int found=0; + + xbt_dict_foreach(head,cursor,key,data) { + printf(" - Seen: %s->%s\n",key,data);fflush(stdout); + if (!strcmp(key,"null")) + found = 1; + } + xbt_assert0(found,"the key 'null', associated to NULL is not found"); + } printf(" - Change some values\n"); printf(" - Change 123 to 'Changed 123'\n");