#include "util.h"
#include "set.h"
#include "prioq.h"
+#include "siphash24.h"
#define SET_SIZE 1024*4
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;
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++) {
assert_se(r >= 0);
if (i % 4 == 0) {
- r = set_put(s, t);
+ r = set_consume(s, t);
assert_se(r >= 0);
}
}