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.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/test/check_ht.c b/src/test/check_ht.c
index 00cd2f1..0298087 100644
--- a/src/test/check_ht.c
+++ b/src/test/check_ht.c
@@ -3,19 +3,20 @@
int main(int UNUSED argc, char ** UNUSED argv)
{
- ht *htp = new_ht(HT_INIT_CAP);
+
+ ht *htp = new_ht(HT_INIT_CAP, 0);
NUM *temp = MYALLOC(NUM, 1), key = 1023;
*temp = 12345;
- if (ht_insert(htp, key, temp)) {
+ if (ht_insert(htp, &key, temp)) {
fleprintf0("Fail to insert\n");
free(temp);
destroy_ht(htp, DESTROY_EVERY_SELF);
return 1;
}
- if ((temp = ht_find(htp, key))) {
+ if ((temp = ht_find(htp, &key))) {
fleprintf("We found value %ld for key %ld\n",
*temp, key);
} else
@@ -27,25 +28,27 @@ int main(int UNUSED argc, char ** UNUSED argv)
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)));
+ i,
+ *((NUM *)*(ht_keys(htp)+i)),
+ *((NUM *)*(ht_values(htp)+i)));
- if (ht_delete(htp, key, 1)) {
+ if (ht_delete(htp, &key, DELETE_VALUE)) {
fleprintf("Fail to delete key %ld\n", key);
- destroy_ht(htp, DESTROY_EVERY_SELF);
+ destroy_ht(htp, DESTROY_VALUE_SELF);
return 1;
}
fleprintf0("After the deletion, ");
- if ((temp = ht_find(htp, key))) {
+ if ((temp = ht_find(htp, &key))) {
eprintf("We found value %ld for key %ld\n",
*temp, key);
- destroy_ht(htp, DESTROY_EVERY_SELF);
+ destroy_ht(htp, DESTROY_VALUE_SELF);
return 1;
} else {
eprintf("We found no value for key %ld\n", key);
}
- destroy_ht(htp, DESTROY_EVERY_SELF);
+ destroy_ht(htp, DESTROY_VALUE_SELF);
return 0;
}