diff options
-rw-r--r-- | src/sorted_array.c | 2 | ||||
-rw-r--r-- | test/sorted_array_test.c | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/sorted_array.c b/src/sorted_array.c index 72a024c..eb48fe1 100644 --- a/src/sorted_array.c +++ b/src/sorted_array.c @@ -183,7 +183,7 @@ zix_sorted_array_end(ZixSortedArray* a) bool zix_sorted_array_iter_is_end(ZixSortedArray* a, ZixSortedArrayIter i) { - return i != zix_sorted_array_end(a); + return i >= zix_sorted_array_end(a); } ZixSortedArrayIter diff --git a/test/sorted_array_test.c b/test/sorted_array_test.c index e62a635..fc92933 100644 --- a/test/sorted_array_test.c +++ b/test/sorted_array_test.c @@ -121,6 +121,14 @@ stress(unsigned test_num, unsigned n_elems) last = iter_data; } + if (i != zix_sorted_array_size(t)) { + fprintf(stderr, + "Iterated over only %u/%" PRIuPTR " elements\n", + i, + zix_sorted_array_size(t)); + return test_fail(); + } + srand(seed); // Delete all elements |