diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-26 16:59:39 +0100 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-26 16:59:39 +0100 |
| commit | 6871825565d0ba24436dbd5b92cc09e02f93af6a (patch) | |
| tree | 0fbd4f05de5997d74bbc4f65d55a611e650ee83f /tests/t_vector.c | |
| parent | 5e86efde052760a53ca92ddd411db095fcf4a970 (diff) | |
First run of making variable names more readable
Diffstat (limited to 'tests/t_vector.c')
| -rw-r--r-- | tests/t_vector.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/tests/t_vector.c b/tests/t_vector.c index a8186b2..541a6da 100644 --- a/tests/t_vector.c +++ b/tests/t_vector.c | |||
| @@ -13,7 +13,7 @@ | |||
| 13 | #include "trackerlogic.h" | 13 | #include "trackerlogic.h" |
| 14 | #include "test.h" | 14 | #include "test.h" |
| 15 | 15 | ||
| 16 | /* binary_search returns the matching member when there is one, and otherwise | 16 | /* vector_binary_search returns the matching member when there is one, and otherwise |
| 17 | the position at which the key would have to be inserted to keep the vector | 17 | the position at which the key would have to be inserted to keep the vector |
| 18 | sorted. exactmatch distinguishes the two. */ | 18 | sorted. exactmatch distinguishes the two. */ |
| 19 | 19 | ||
| @@ -25,7 +25,7 @@ static void case_search_finds_member(void) { | |||
| 25 | void *found; | 25 | void *found; |
| 26 | 26 | ||
| 27 | test_case("an existing key is found"); | 27 | test_case("an existing key is found"); |
| 28 | found = binary_search(key, sorted, 5, 4, 4, &exactmatch); | 28 | found = vector_binary_search(key, sorted, 5, 4, 4, &exactmatch); |
| 29 | CHECK(exactmatch != 0); | 29 | CHECK(exactmatch != 0); |
| 30 | CHECK_PTR(found, sorted[2]); | 30 | CHECK_PTR(found, sorted[2]); |
| 31 | } | 31 | } |
| @@ -36,9 +36,9 @@ static void case_search_finds_first_and_last(void) { | |||
| 36 | int exactmatch; | 36 | int exactmatch; |
| 37 | 37 | ||
| 38 | test_case("the first and last members are found"); | 38 | test_case("the first and last members are found"); |
| 39 | CHECK_PTR(binary_search(first, sorted, 5, 4, 4, &exactmatch), sorted[0]); | 39 | CHECK_PTR(vector_binary_search(first, sorted, 5, 4, 4, &exactmatch), sorted[0]); |
| 40 | CHECK(exactmatch != 0); | 40 | CHECK(exactmatch != 0); |
| 41 | CHECK_PTR(binary_search(last, sorted, 5, 4, 4, &exactmatch), sorted[4]); | 41 | CHECK_PTR(vector_binary_search(last, sorted, 5, 4, 4, &exactmatch), sorted[4]); |
| 42 | CHECK(exactmatch != 0); | 42 | CHECK(exactmatch != 0); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| @@ -49,11 +49,11 @@ static void case_search_insert_position(void) { | |||
| 49 | void *slot; | 49 | void *slot; |
| 50 | 50 | ||
| 51 | test_case("a missing key yields its insert position"); | 51 | test_case("a missing key yields its insert position"); |
| 52 | slot = binary_search(middle, sorted, 5, 4, 4, &exactmatch); | 52 | slot = vector_binary_search(middle, sorted, 5, 4, 4, &exactmatch); |
| 53 | CHECK_INT(exactmatch, 0); | 53 | CHECK_INT(exactmatch, 0); |
| 54 | CHECK_PTR(slot, sorted[2]); | 54 | CHECK_PTR(slot, sorted[2]); |
| 55 | 55 | ||
| 56 | slot = binary_search(before, sorted, 5, 4, 4, &exactmatch); | 56 | slot = vector_binary_search(before, sorted, 5, 4, 4, &exactmatch); |
| 57 | CHECK_INT(exactmatch, 0); | 57 | CHECK_INT(exactmatch, 0); |
| 58 | CHECK_PTR(slot, sorted[0]); | 58 | CHECK_PTR(slot, sorted[0]); |
| 59 | } | 59 | } |
| @@ -64,7 +64,7 @@ static void case_search_past_the_end(void) { | |||
| 64 | void *slot; | 64 | void *slot; |
| 65 | 65 | ||
| 66 | test_case("a key above every member yields the position past the end"); | 66 | test_case("a key above every member yields the position past the end"); |
| 67 | slot = binary_search(beyond, sorted, 5, 4, 4, &exactmatch); | 67 | slot = vector_binary_search(beyond, sorted, 5, 4, 4, &exactmatch); |
| 68 | CHECK_INT(exactmatch, 0); | 68 | CHECK_INT(exactmatch, 0); |
| 69 | CHECK_PTR(slot, sorted[5]); | 69 | CHECK_PTR(slot, sorted[5]); |
| 70 | } | 70 | } |
| @@ -74,7 +74,7 @@ static void case_search_empty(void) { | |||
| 74 | void *base = (void *)sorted; | 74 | void *base = (void *)sorted; |
| 75 | 75 | ||
| 76 | test_case("searching an empty vector reports no match at the base"); | 76 | test_case("searching an empty vector reports no match at the base"); |
| 77 | CHECK_PTR(binary_search(sorted[0], base, 0, 4, 4, &exactmatch), base); | 77 | CHECK_PTR(vector_binary_search(sorted[0], base, 0, 4, 4, &exactmatch), base); |
| 78 | CHECK_INT(exactmatch, 0); | 78 | CHECK_INT(exactmatch, 0); |
| 79 | } | 79 | } |
| 80 | 80 | ||
