summaryrefslogtreecommitdiffstats
path: root/test/btree_test.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-09-10 20:11:35 -0400
committerDavid Robillard <d@drobilla.net>2021-09-10 20:11:35 -0400
commit4b86bcd2713a0ccb6b171371a5d0eb70be4f1f1b (patch)
treec8d1320d6fd38b8e3c19d06602b59fe4eae66415 /test/btree_test.c
parentbb9d3ce25dd09b96cdf232477c90414270c503e8 (diff)
downloadzix-4b86bcd2713a0ccb6b171371a5d0eb70be4f1f1b.tar.gz
zix-4b86bcd2713a0ccb6b171371a5d0eb70be4f1f1b.tar.bz2
zix-4b86bcd2713a0ccb6b171371a5d0eb70be4f1f1b.zip
Avoid inserting wildcards as values in BTree test
Diffstat (limited to 'test/btree_test.c')
-rw-r--r--test/btree_test.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/test/btree_test.c b/test/btree_test.c
index c5b575d..9c4eab8 100644
--- a/test/btree_test.c
+++ b/test/btree_test.c
@@ -33,12 +33,16 @@
static bool expect_failure = false;
+ZIX_PURE_FUNC
static int
int_cmp(const void* a, const void* b, const void* ZIX_UNUSED(user_data))
{
const uintptr_t ia = (uintptr_t)a;
const uintptr_t ib = (uintptr_t)b;
+ assert(ia != 0u); // No wildcards
+ assert(ib != 0u); // No wildcards
+
return ia < ib ? -1 : ia > ib ? 1 : 0;
}
@@ -51,7 +55,7 @@ ith_elem(const unsigned test_num, const size_t n_elems, const size_t i)
case 1:
return n_elems - i; // Decreasing
default:
- return unique_rand(i); // Pseudo-random
+ return 1u + unique_rand(i); // Pseudo-random
}
}
@@ -455,13 +459,9 @@ stress(const unsigned test_num, const size_t n_elems)
// Insert n_elems elements
for (i = 0; i < n_elems; ++i) {
r = ith_elem(test_num, n_elems, i);
- if (r != 0) { // Can't insert wildcards
- if ((st = zix_btree_insert(t, (void*)r))) {
- return test_fail(t,
- "Insert %" PRIuPTR " failed (%s)\n",
- (uintptr_t)r,
- zix_strerror(st));
- }
+ if ((st = zix_btree_insert(t, (void*)r))) {
+ return test_fail(
+ t, "Insert %" PRIuPTR " failed (%s)\n", (uintptr_t)r, zix_strerror(st));
}
}