int i;
xbt_dictelm_t current, previous = NULL;
+
+ if (dict->count == 0)
+ return;
+
for (i = 0; i < dict->table_size; i++) {
current = dict->table[i];
while (current != NULL) {
XBT_TEST_UNIT("basic",test_dict_basic,"Basic usage: change, retrieve, traverse"){
- xbt_test_add0("Traversal the empty dictionnary");
+ xbt_test_add0("Traversal the null dictionnary");
+ traverse(head);
+
+ xbt_test_add0("Traversal and search the empty dictionnary");
+ head = xbt_dict_new();
traverse(head);
+ TRY {
+ debuged_remove(head,"12346");
+ } CATCH(e) {
+ if (e.category != not_found_error)
+ xbt_test_exception(e);
+ xbt_ex_free(e);
+ }
+ xbt_dict_free(&head);
xbt_test_add0("Traverse the full dictionnary");
fill(&head);
for (i=0;i<10;i++) {
head=xbt_dict_new();
- // if (i%10) printf("."); else printf("%d",i/10); fflush(stdout);
+ /* if (i%10) printf("."); else printf("%d",i/10); fflush(stdout); */
nb=0;
for (j=0;j<1000;j++) {
key=xbt_malloc(SIZEOFKEY);
head=xbt_dict_new();
xbt_test_add1("Fill %d elements, with keys being the number of element",NB_ELM);
for (j=0;j<NB_ELM;j++) {
- // if (!(j%1000)) { printf("."); fflush(stdout); }
+ /* if (!(j%1000)) { printf("."); fflush(stdout); } */
key = xbt_malloc(10);
xbt_test_add1("Search my %d elements 20 times",NB_ELM);
key=xbt_malloc(10);
for (i=0;i<20;i++) {
- // if (i%10) printf("."); else printf("%d",i/10); fflush(stdout);
+ /* if (i%10) printf("."); else printf("%d",i/10); fflush(stdout); */
for (j=0;j<NB_ELM;j++) {
sprintf(key,"%d",j);
xbt_test_add1("Remove my %d elements",NB_ELM);
key=xbt_malloc(10);
for (j=0;j<NB_ELM;j++) {
- //if (!(j%10000)) printf("."); fflush(stdout);
+ /* if (!(j%10000)) printf("."); fflush(stdout); */
sprintf(key,"%d",j);
xbt_dict_remove(head,key);