-/* $OpenBSD: rde_sets_test.c,v 1.2 2018/09/07 09:31:14 claudio Exp $ */
+/* $OpenBSD: rde_sets_test.c,v 1.3 2018/09/14 10:23:42 claudio Exp $ */
/*
* Copyright (c) 2018 Claudio Jeker <claudio@openbsd.org>
{
struct as_set *a;
- a = as_set_new(name, initial);
+ a = as_set_new(name, initial, sizeof(*mem));
if (a == NULL)
err(1, "as_set_new %s", name);
if (as_set_add(a, mem, nmemb) != 0)
int
main(int argc, char **argv)
{
- struct as_set *a, *aa, *b, *c;
+ struct as_set *a, *aa, *b, *c, *empty;
size_t i;
a = build_set("a", va, sizeof(va) / sizeof(va[0]),
sizeof(va) / sizeof(va[0]));
-
aa = build_set("aa", vaa, sizeof(vaa) / sizeof(vaa[0]), 0);
-
b = build_set("b", vb, sizeof(vb) / sizeof(vb[0]), 1);
-
c = build_set("c", vc, sizeof(vc) / sizeof(vc[0]), 1);
+ empty = build_set("empty", NULL, 0, 0);
+ if (!as_set_equal(a, a))
+ errx(1, "as_set_equal(a, a) non equal");
if (!as_set_equal(a, aa))
errx(1, "as_set_equal(a, aa) non equal");
if (as_set_equal(a, b))
if (as_set_match(c, 7))
errx(1, "as_set_match(c, %u) matched but should not", 7);
+ if (!as_set_equal(empty, empty))
+ errx(1, "as_set_equal(empty, empty) non equal");
+ if (as_set_match(empty, 42))
+ errx(1, "as_set_match(empty, %u) matched but should not", 42);
+
+ as_set_free(a);
+ as_set_free(aa);
+ as_set_free(b);
+ as_set_free(c);
+ as_set_free(empty);
+
printf("OK\n");
return 0;
}