From 53865aad225ffbe5cf3c42736e5a2095092f9fff Mon Sep 17 00:00:00 2001 From: JSDurand Date: Fri, 21 Jan 2022 21:53:50 +0800 Subject: temporary save point Just to save some work. --- src/test/check_ht.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/test/check_ht.c') 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; } -- cgit v1.2.3-18-g5258