summaryrefslogtreecommitdiff
path: root/ccan/htable/test/run-zero-hash-first-entry.c
diff options
context:
space:
mode:
authorWilliam Casarin <jb55@jb55.com>2018-07-09 22:28:25 -0700
committerWilliam Casarin <jb55@jb55.com>2018-07-09 22:31:48 -0700
commit9593fc545950782ed75f12f53238b07885559b2b (patch)
tree9c7c2f7cbb427c54e9184cb61eedce737a6cbc6f /ccan/htable/test/run-zero-hash-first-entry.c
parentbd8c223756d2f912526ecef53bae0cc8e0c63442 (diff)
remove ccan for now
Diffstat (limited to 'ccan/htable/test/run-zero-hash-first-entry.c')
-rw-r--r--ccan/htable/test/run-zero-hash-first-entry.c61
1 files changed, 0 insertions, 61 deletions
diff --git a/ccan/htable/test/run-zero-hash-first-entry.c b/ccan/htable/test/run-zero-hash-first-entry.c
deleted file mode 100644
index 3a1a939..0000000
--- a/ccan/htable/test/run-zero-hash-first-entry.c
+++ /dev/null
@@ -1,61 +0,0 @@
-#include <ccan/htable/htable.h>
-#include <ccan/htable/htable.c>
-#include <ccan/tap/tap.h>
-#include <stdbool.h>
-
-struct data {
- size_t key;
-};
-
-/* Hash is simply key itself. */
-static size_t hash(const void *e, void *unused UNNEEDED)
-{
- struct data *d = (struct data *)e;
-
- return d->key;
-}
-
-static bool eq(const void *e, void *k)
-{
- struct data *d = (struct data *)e;
- size_t *key = (size_t *)k;
-
- return (d->key == *key);
-}
-
-int main(void)
-{
- struct htable table;
- struct data *d0, *d1;
-
- plan_tests(6);
-
- d1 = malloc(sizeof(struct data));
- d1->key = 1;
- d0 = malloc(sizeof(struct data));
- d0->key = 0;
-
- htable_init(&table, hash, NULL);
-
- htable_add(&table, d0->key, d0);
- htable_add(&table, d1->key, d1);
-
- ok1(table.elems == 2);
- ok1(htable_get(&table, 1, eq, &d1->key) == d1);
- ok1(htable_get(&table, 0, eq, &d0->key) == d0);
- htable_clear(&table);
-
- /* Now add in reverse order, should still be OK. */
- htable_add(&table, d1->key, d1);
- htable_add(&table, d0->key, d0);
-
- ok1(table.elems == 2);
- ok1(htable_get(&table, 1, eq, &d1->key) == d1);
- ok1(htable_get(&table, 0, eq, &d0->key) == d0);
- htable_clear(&table);
-
- free(d0);
- free(d1);
- return exit_status();
-}
-