Skip to content

Commit 21cec06

Browse files
tests: salvage missing coverage from orphan, delete the stale file
You called my bluff -- the orphan Tests/Std/BitVec.Pattern.c wasn't purely dead. Diff between it and the registered Simple/Deadend pair showed test_bitvec_find_all_pattern_vec was real coverage that neither registered file had: it tests BitVecFindAllPattern in its 3-arg Vec form (BitVecFindAllPattern(&source, &pattern, &matches)), whereas Simple only tested the 4-arg raw form with a fixed-size results buffer. Salvaged the test verbatim into BitVec.Pattern.Simple.c (with .data/.length swapped for VecLen/VecAt per the test-side accessor convention) and registered it in the test list. Then deleted the orphan -- it was 1376 lines, of which 88 tests duplicated the registered files and most of the rest referenced stale API (BitVecContains, the 3-arg BitVecPrefixMatch/SuffixMatch shapes that don't exist anymore). Drops .audit-questions.md item 2; only Allocator/Debug.c warnings remain.
1 parent 91a02e5 commit 21cec06

3 files changed

Lines changed: 61 additions & 1377 deletions

File tree

.audit-questions.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Open questions from audit loop
2+
3+
The audit loop converged across 9 rounds. Items 1–4 from earlier rounds
4+
have all been resolved (overload naming kept short under `_Generic`,
5+
missing accessors added, Str now wraps every Vec op, Graph test helpers
6+
moved to `const Str *`). Two items remain parked for your decision.
7+
8+
## 1. `Allocator/Debug.c` cascading pre-existing warnings
9+
10+
When the `BudgetAllocator` `buf` / `slots` fields went from `char *` to
11+
`u8 *` (commit `3c589aa`), `Debug.c` continued to surface a set of
12+
pre-existing "Cannot take the address of an rvalue of type 'void'"
13+
warnings cascading from how `MapInsertR(&dbg->live, user_p, rec)`
14+
interacts with the typing. These warnings predate the audit loop and
15+
the build still succeeds — clangd is the only thing that flags them.
16+
17+
**Question:** refactor Debug.c's live-map shape to silence them, or
18+
leave the diagnostics noise alone.
19+

Tests/Std/BitVec.Pattern.Simple.c

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,46 @@ bool test_bitvec_find_all_pattern(void) {
250250
return result;
251251
}
252252

253+
// Test BitVecFindAllPattern in its 3-arg Vec form. Same source/pattern as the
254+
// raw-buffer test above (5 hits in 10101010101), but we feed the matches into
255+
// a BitVecMatchIndices and check the full match list. The Vec form never
256+
// truncates -- proves we get all 5 hits without pre-sizing.
257+
bool test_bitvec_find_all_pattern_vec(void) {
258+
DefaultAllocator alloc = DefaultAllocatorInit();
259+
Allocator *base = ALLOCATOR_OF(&alloc);
260+
261+
WriteFmt("Testing BitVecFindAllPattern Vec form\n");
262+
263+
BitVec source = BitVecInit(base);
264+
BitVec pattern = BitVecInit(base);
265+
bool result = true;
266+
267+
// Source: 10101010101 (11 bits)
268+
for (int i = 0; i < 11; i++)
269+
BitVecPush(&source, i % 2 == 0);
270+
// Pattern: 101
271+
BitVecPush(&pattern, true);
272+
BitVecPush(&pattern, false);
273+
BitVecPush(&pattern, true);
274+
275+
BitVecMatchIndices matches = VecInitT(matches, base);
276+
result = result && BitVecFindAllPattern(&source, &pattern, &matches);
277+
result = result && VecLen(&matches) == 5;
278+
if (result) {
279+
result = result && VecAt(&matches, 0) == 0;
280+
result = result && VecAt(&matches, 1) == 2;
281+
result = result && VecAt(&matches, 2) == 4;
282+
result = result && VecAt(&matches, 3) == 6;
283+
result = result && VecAt(&matches, 4) == 8;
284+
}
285+
286+
VecDeinit(&matches);
287+
BitVecDeinit(&source);
288+
BitVecDeinit(&pattern);
289+
DefaultAllocatorDeinit(&alloc);
290+
return result;
291+
}
292+
253293
// Test edge cases for pattern functions
254294
bool test_bitvec_pattern_edge_cases(void) {
255295
DefaultAllocator alloc = DefaultAllocatorInit();
@@ -982,7 +1022,8 @@ int main(void) {
9821022
// Array of test functions
9831023
TestFunction tests[] = {
9841024
test_bitvec_basic_pattern_functions, test_bitvec_find_pattern, test_bitvec_find_last_pattern,
985-
test_bitvec_find_all_pattern, test_bitvec_pattern_edge_cases, test_bitvec_pattern_stress_tests,
1025+
test_bitvec_find_all_pattern, test_bitvec_find_all_pattern_vec, test_bitvec_pattern_edge_cases,
1026+
test_bitvec_pattern_stress_tests,
9861027
test_bitvec_starts_with_basic, test_bitvec_starts_with_edge_cases, test_bitvec_ends_with_basic,
9871028
test_bitvec_ends_with_edge_cases, test_bitvec_contains_basic, test_bitvec_contains_at_basic,
9881029
test_bitvec_contains_at_edge_cases, test_bitvec_count_pattern_basic, test_bitvec_rfind_pattern_basic,

0 commit comments

Comments
 (0)