From 22ac686f2a2b9f95bcb6e06272ff7d1417de0de3 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sat, 1 Jun 2024 16:58:26 -0300 Subject: tests/tree.c: Add test for tree_contains() After writing the test, a failing case made me notice that the comparison was reversed, and I then fixed the implementation :) --- src/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/tree.c') diff --git a/src/tree.c b/src/tree.c index fccf209..f19eae2 100644 --- a/src/tree.c +++ b/src/tree.c @@ -191,7 +191,7 @@ tree_contains(const struct Tree *const t, const void *const value) { const int cmp = memcmp(value, t->value, t->value_size); if (cmp == 0) { return true; - } else if (cmp > 0) { + } else if (cmp < 0) { if (t->left == NULL) { return false; } -- cgit v1.2.3