From cf10ce9b930a4e2db013e3fa4dcaf249e4346069 Mon Sep 17 00:00:00 2001 From: Attractive Chaos Date: Thu, 19 Dec 2019 13:52:42 -0500 Subject: [PATCH] more tests --- krmq.h | 2 +- test/krmq_test.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/krmq.h b/krmq.h index b2ba944..4f4ea75 100644 --- a/krmq.h +++ b/krmq.h @@ -127,7 +127,7 @@ int main(void) { else if (cmp > 0) p = p->__head.p[1]; \ else break; \ } \ - for (i = 0; i < plen[0] && i < plen[1]; ++i) \ + for (i = 0; i < plen[0] && i < plen[1]; ++i) /* find the LCA */ \ if (path[0][i] == path[1][i] && pcmp[0][i] <= 0 && pcmp[1][i] >= 0) \ break; \ if (i == plen[0] || i == plen[1]) return 0; /* no elements in the closed interval */ \ diff --git a/test/krmq_test.c b/test/krmq_test.c index 8af20ca..69aff4c 100644 --- a/test/krmq_test.c +++ b/test/krmq_test.c @@ -133,6 +133,12 @@ int main(void) check_rmq(root, 'A', 'Z'); check_rmq(root, 'F', 'G'); check_rmq(root, 'a', 'z'); + for (i = 0; i < n; ++i) { + int lo, hi; + lo = (int)(drand48() * n); + hi = (int)(drand48() * n); + check_rmq(root, lo, hi); + } krmq_itr_first(my, root, &itr); do { -- 2.47.3