summaryrefslogtreecommitdiff
path: root/src/tree.c
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-06-01 16:58:26 -0300
committerEuAndreh <eu@euandre.org>2024-06-01 16:58:28 -0300
commit22ac686f2a2b9f95bcb6e06272ff7d1417de0de3 (patch)
tree974d3b6685ddda50abd16d512378633bea0feafa /src/tree.c
parenttests/tree.c: Add first test for tree_contains() (diff)
downloadpindaiba-22ac686f2a2b9f95bcb6e06272ff7d1417de0de3.tar.gz
pindaiba-22ac686f2a2b9f95bcb6e06272ff7d1417de0de3.tar.xz
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 :)
Diffstat (limited to '')
-rw-r--r--src/tree.c2
1 files changed, 1 insertions, 1 deletions
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;
}