chiark / gitweb /
test-sizeof: print the size of an enum
[elogind.git] / src / test / test-prioq.c
index 73c640840aa3a6ffb4b4cadf8e94e551e145f99a..d81880a6556efbf513ce68b1dc4957cd1731b018 100644 (file)
@@ -1,5 +1,3 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
 /***
   This file is part of systemd.
 
 
 #include <stdlib.h>
 
-#include "util.h"
-#include "set.h"
+#include "alloc-util.h"
 #include "prioq.h"
+#include "set.h"
+#include "siphash24.h"
+#include "util.h"
 
 #define SET_SIZE 1024*4
 
@@ -88,12 +88,17 @@ static int test_compare(const void *a, const void *b) {
         return 0;
 }
 
-static unsigned test_hash(const void *a) {
+static void test_hash(const void *a, struct siphash *state) {
         const struct test *x = a;
 
-        return x->value;
+        siphash24_compress(&x->value, sizeof(x->value), state);
 }
 
+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 +110,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++) {
@@ -119,7 +124,7 @@ static void test_struct(void) {
                 assert_se(r >= 0);
 
                 if (i % 4 == 0) {
-                        r = set_put(s, t);
+                        r = set_consume(s, t);
                         assert_se(r >= 0);
                 }
         }