summaryrefslogtreecommitdiff
path: root/src/lib/tests/hashtable_test.c
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@ugent.be>2017-09-21 14:26:51 +0200
committerSander Vrijders <sander.vrijders@ugent.be>2017-09-21 16:55:31 +0200
commitf6071ecf0cd3768eaed9a847f676433c120ea89e (patch)
tree21f2738c9f0130653ae4253b374f34061d119399 /src/lib/tests/hashtable_test.c
parent6b6f82c8a58b2edbd029909be2ba1057c00cd6ed (diff)
downloadouroboros-f6071ecf0cd3768eaed9a847f676433c120ea89e.tar.gz
ouroboros-f6071ecf0cd3768eaed9a847f676433c120ea89e.zip
ipcpd: normal: Add alternate hop PFF
This adds a PFF that returns an alternate hop as next hop in case the hop that would have been returned is down.
Diffstat (limited to 'src/lib/tests/hashtable_test.c')
-rw-r--r--src/lib/tests/hashtable_test.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/lib/tests/hashtable_test.c b/src/lib/tests/hashtable_test.c
index 9d5917f4..36f68ebf 100644
--- a/src/lib/tests/hashtable_test.c
+++ b/src/lib/tests/hashtable_test.c
@@ -30,8 +30,10 @@
int hashtable_test(int argc, char ** argv)
{
struct htable * table;
- int i;
- int * j;
+ int i;
+ int * j;
+ void * el;
+ size_t len;
(void) argc;
(void) argv;
@@ -59,20 +61,20 @@ int hashtable_test(int argc, char ** argv)
}
*j = i;
- if (htable_insert(table, i, (void *) j)) {
+ if (htable_insert(table, i, (void *) j, 1)) {
printf("Failed to insert.\n");
htable_destroy(table);
return -1;
}
}
- j = (int *) htable_lookup(table, INT_TEST);
- if (j == NULL) {
+ if (htable_lookup(table, INT_TEST, &el, &len)) {
printf("Failed to lookup.\n");
htable_destroy(table);
return -1;
}
+ j = (int *) el;
if (*j != INT_TEST) {
printf("Lookup returned wrong value (%d != %d).\n",
INT_TEST, *j);
@@ -80,13 +82,13 @@ int hashtable_test(int argc, char ** argv)
return -1;
}
- j = (int *) htable_lookup(table, HASHTABLE_SIZE + INT_TEST);
- if (j == NULL) {
+ if (htable_lookup(table, HASHTABLE_SIZE + INT_TEST, &el, &len)) {
printf("Failed to lookup.\n");
htable_destroy(table);
return -1;
}
+ j = (int *) el;
if (*j != HASHTABLE_SIZE + INT_TEST) {
printf("Lookup returned wrong value (%d != %d).\n",
INT_TEST, *j);
@@ -100,20 +102,19 @@ int hashtable_test(int argc, char ** argv)
return -1;
}
- j = (int *) htable_lookup(table, INT_TEST);
- if (j != NULL) {
+ if (htable_lookup(table, INT_TEST, &el, &len) == 0) {
printf("Failed to delete properly.\n");
htable_destroy(table);
return -1;
}
- j = (int *) htable_lookup(table, HASHTABLE_SIZE + INT_TEST);
- if (j == NULL) {
+ if (htable_lookup(table, HASHTABLE_SIZE + INT_TEST, &el, &len)) {
printf("Failed to lookup after deletion.\n");
htable_destroy(table);
return -1;
}
+ j = (int *) el;
if (*j != HASHTABLE_SIZE + INT_TEST) {
printf("Lookup returned wrong value (%d != %d).\n",
INT_TEST, *j);