diff options
-rw-r--r-- | source/kit/lower_bound.h | 26 | ||||
-rw-r--r-- | source/kit_test/test.h | 7 | ||||
-rw-r--r-- | source/test/unittests/lower_bound.test.c | 8 |
3 files changed, 21 insertions, 20 deletions
diff --git a/source/kit/lower_bound.h b/source/kit/lower_bound.h index fee1648..3fd1b08 100644 --- a/source/kit/lower_bound.h +++ b/source/kit/lower_bound.h @@ -20,19 +20,19 @@ extern "C" { (return_val) = position_; \ } -#define KIT_LOWER_BOUND_REF(return_val, array, value, op) \ - { \ - ptrdiff_t position_ = 0; \ - ptrdiff_t count_ = (array).size; \ - while (count_ > 0) { \ - ptrdiff_t delta_ = count_ / 2; \ - if ((op) ((array).values + position_ + delta_, &(value))) { \ - position_ += delta_ + 1; \ - count_ -= delta_ + 1; \ - } else \ - count_ = delta_; \ - } \ - (return_val) = position_; \ +#define KIT_LOWER_BOUND_REF(return_val, array, value, op) \ + { \ + ptrdiff_t position_ = 0; \ + ptrdiff_t count_ = (array).size; \ + while (count_ > 0) { \ + ptrdiff_t delta_ = count_ / 2; \ + if ((op) ((array).values + position_ + delta_, (value))) { \ + position_ += delta_ + 1; \ + count_ -= delta_ + 1; \ + } else \ + count_ = delta_; \ + } \ + (return_val) = position_; \ } #ifdef __cplusplus diff --git a/source/kit_test/test.h b/source/kit_test/test.h index 4dc7aac..9c2fea9 100644 --- a/source/kit_test/test.h +++ b/source/kit_test/test.h @@ -24,9 +24,10 @@ extern "C" { # define KIT_TEST_STRING_SIZE 0x100 #endif -typedef void (*kit_test_report_fn)(int, char const *file, int line, - int ok); -typedef void (*kit_test_run_fn)(int, kit_test_report_fn); +typedef void (*kit_test_report_fn)(int test_index, char const *file, + int line, int ok); +typedef void (*kit_test_run_fn)( + int kit_test_index_, kit_test_report_fn kit_test_report_fn_); typedef struct { char test_name[KIT_TEST_STRING_SIZE]; diff --git a/source/test/unittests/lower_bound.test.c b/source/test/unittests/lower_bound.test.c index 225c6ba..44145f8 100644 --- a/source/test/unittests/lower_bound.test.c +++ b/source/test/unittests/lower_bound.test.c @@ -143,7 +143,7 @@ TEST("lower bound ref first of four") { AR(ref, int) = { .size = 4, .values = v }; ptrdiff_t index; - KIT_LOWER_BOUND_REF(index, ref, value, kit_less_int_ref); + KIT_LOWER_BOUND_REF(index, ref, &value, kit_less_int_ref); REQUIRE(index == 0); } @@ -153,7 +153,7 @@ TEST("lower bound ref second of four") { AR(ref, int) = { .size = 4, .values = v }; ptrdiff_t index; - KIT_LOWER_BOUND_REF(index, ref, value, kit_less_int_ref); + KIT_LOWER_BOUND_REF(index, ref, &value, kit_less_int_ref); REQUIRE(index == 1); } @@ -163,7 +163,7 @@ TEST("lower bound ref fifth of five") { AR(ref, int) = { .size = 5, .values = v }; ptrdiff_t index; - KIT_LOWER_BOUND_REF(index, ref, value, kit_less_int_ref); + KIT_LOWER_BOUND_REF(index, ref, &value, kit_less_int_ref); REQUIRE(index == 4); } @@ -173,6 +173,6 @@ TEST("lower bound ref sixth of five") { AR(ref, int) = { .size = 5, .values = v }; ptrdiff_t index; - KIT_LOWER_BOUND_REF(index, ref, value, kit_less_int_ref); + KIT_LOWER_BOUND_REF(index, ref, &value, kit_less_int_ref); REQUIRE(index == 5); } |