reftable/basics: improve `binsearch()` test
commite8b808258e70d85918aaee0c84817b74a747c9d5
authorPatrick Steinhardt <ps@pks.im>
Wed, 3 Apr 2024 06:04:00 +0000 (3 08:04 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 3 Apr 2024 16:16:49 +0000 (3 09:16 -0700)
tree75f27d609ba6e2324029ff588c0276681339ae58
parent3e7b36d129a5972e20cab4e55c43a8628b4d2c9c
reftable/basics: improve `binsearch()` test

The `binsearch()` test is somewhat weird in that it doesn't explicitly
spell out its expectations. Instead it does so in a rather ad-hoc way
with some hard-to-understand computations.

Refactor the test to spell out the needle as well as expected index for
all testcases. This refactoring highlights that the `binsearch_func()`
is written somewhat weirdly to find the first integer smaller than the
needle, not smaller or equal to it. Adjust the function accordingly.

While at it, rename the callback function to better convey its meaning.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reftable/basics_test.c