Skip to content

Commit 6642f4e

Browse files
committed
tests/search_test: Better documentation.
Explain which cases are covered by the test cases. This aligns it better with the documentation of Bsearch, and the claim about the various ways in which it can be used.
1 parent 2d1fc00 commit 6642f4e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

test/search_test.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ int main(int argc, char** argv)
5959
#define red(x) reduce_to_bits(b, (x))
6060
uint32_t d = red(rnext(&rstate));
6161

62-
/* Variant 1: smallest i s.t. a[i] >= key */
62+
/* Variants
63+
* 1a) smallest i s.t. a[i] >= key
64+
* 1b) largest i s.t. a[i] < key (satisfied by i - 1)
65+
*/
6366
Bsearch(int, u, red(a[u]) < d, N, idx);
6467
printf(" d = %"PRIu32" -> V1_idx = %d ", d, idx);
6568
if (idx < 0 || idx > N) {
@@ -78,7 +81,10 @@ int main(int argc, char** argv)
7881
return 1;
7982
}
8083

81-
/* Variant 2: lowest i s.t. a[i] > key */
84+
/* Variants
85+
* 2a) smallest i s.t. a[i] > key
86+
* 2b) largest i s.t. a[i] <= key (satisfied by i - 1)
87+
*/
8288
Bsearch(int, u, red(a[u]) <= d, N, idx);
8389
printf("V2_idx = %d ", idx);
8490
if (idx < 0 || idx > N) {

0 commit comments

Comments
 (0)