diff options
-rw-r--r-- | regress/usr.sbin/bgpd/unittests/rde_sets_test.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/regress/usr.sbin/bgpd/unittests/rde_sets_test.c b/regress/usr.sbin/bgpd/unittests/rde_sets_test.c index 57e0abfa935..0535723d25f 100644 --- a/regress/usr.sbin/bgpd/unittests/rde_sets_test.c +++ b/regress/usr.sbin/bgpd/unittests/rde_sets_test.c @@ -1,4 +1,4 @@ -/* $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> @@ -33,7 +33,7 @@ build_set(const char *name, u_int32_t *mem, size_t nmemb, size_t initial) { 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) @@ -46,18 +46,18 @@ build_set(const char *name, u_int32_t *mem, size_t nmemb, size_t initial) 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)) @@ -75,6 +75,17 @@ main(int argc, char **argv) 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; } |