summaryrefslogtreecommitdiff
path: root/src/test/check_ht.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/check_ht.c')
-rw-r--r--src/test/check_ht.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/test/check_ht.c b/src/test/check_ht.c
index 2419ce5..00cd2f1 100644
--- a/src/test/check_ht.c
+++ b/src/test/check_ht.c
@@ -11,7 +11,7 @@ int main(int UNUSED argc, char ** UNUSED argv)
if (ht_insert(htp, key, temp)) {
fleprintf0("Fail to insert\n");
free(temp);
- destroy_ht(htp, 1);
+ destroy_ht(htp, DESTROY_EVERY_SELF);
return 1;
}
@@ -21,9 +21,17 @@ int main(int UNUSED argc, char ** UNUSED argv)
} else
fleprintf("We found no value for key %ld\n", key);
+ NUM size = ht_size(htp);
+
+ fleprintf("The size of the hash table is %ld\n", size);
+
+ for (NUM i = 0; i < size; i++)
+ fleprintf("The %ld-th element has key %ld and value %ld\n",
+ i, *(ht_keys(htp)+i), *((NUM *)*(ht_values(htp)+i)));
+
if (ht_delete(htp, key, 1)) {
fleprintf("Fail to delete key %ld\n", key);
- destroy_ht(htp, 1);
+ destroy_ht(htp, DESTROY_EVERY_SELF);
return 1;
}
@@ -32,12 +40,12 @@ int main(int UNUSED argc, char ** UNUSED argv)
if ((temp = ht_find(htp, key))) {
eprintf("We found value %ld for key %ld\n",
*temp, key);
- destroy_ht(htp, 1);
+ destroy_ht(htp, DESTROY_EVERY_SELF);
return 1;
} else {
eprintf("We found no value for key %ld\n", key);
}
- destroy_ht(htp, 1);
+ destroy_ht(htp, DESTROY_EVERY_SELF);
return 0;
}