X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Ftest%2Ftest-prioq.c;h=dfedc9b8dce32000886baec72ddd75a85edcb249;hb=c2fa048c4a70c8386c6d8fe939e5ea9edecf1e98;hp=aeac73973b3eee699eb221cf4dddc633bae6fbf0;hpb=ef42202ac8ed27e7ff1fc90ef8bc2590046dff25;p=elogind.git diff --git a/src/test/test-prioq.c b/src/test/test-prioq.c index aeac73973..dfedc9b8d 100644 --- a/src/test/test-prioq.c +++ b/src/test/test-prioq.c @@ -24,6 +24,7 @@ #include "util.h" #include "set.h" #include "prioq.h" +#include "siphash24.h" #define SET_SIZE 1024*4 @@ -88,12 +89,20 @@ static int test_compare(const void *a, const void *b) { return 0; } -static unsigned test_hash(const void *a) { +static unsigned long test_hash(const void *a, const uint8_t hash_key[HASH_KEY_SIZE]) { const struct test *x = a; + uint64_t u; - return x->value; + siphash24((uint8_t*) &u, &x->value, sizeof(x->value), hash_key); + + return (unsigned long) u; } +static const struct hash_ops test_hash_ops = { + .hash = test_hash, + .compare = test_compare +}; + static void test_struct(void) { Prioq *q; Set *s; @@ -105,7 +114,7 @@ static void test_struct(void) { q = prioq_new(test_compare); assert_se(q); - s = set_new(test_hash, test_compare); + s = set_new(&test_hash_ops); assert_se(s); for (i = 0; i < SET_SIZE; i++) {