MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / check_sources_exact

Function check_sources_exact

tests/repro/repro_issue842.c:278–302  ·  view source on GitHub ↗

Check that paths[] contains exactly the expected file suffixes, once each. * Returns 1 if all expected suffixes appear exactly once, 0 otherwise. * Prints a diagnostic on mismatch. */

Source from the content-addressed store, hash-verified

276 * Returns 1 if all expected suffixes appear exactly once, 0 otherwise.
277 * Prints a diagnostic on mismatch. */
278static int check_sources_exact(char **paths, int count, const char **expected, int nexpected) {
279 if (count != nexpected) {
280 printf(" source count %d != expected %d\n", count, nexpected);
281 for (int i = 0; i < count; i++) {
282 printf(" got: %s\n", paths[i] ? paths[i] : "(null)");
283 }
284 return 0;
285 }
286 for (int e = 0; e < nexpected; e++) {
287 int seen = 0;
288 for (int i = 0; i < count; i++) {
289 if (paths[i] && strstr(paths[i], expected[e])) {
290 seen++;
291 }
292 }
293 if (seen != 1) {
294 printf(" expected suffix '%s' appears %d time(s) (want 1)\n", expected[e], seen);
295 for (int i = 0; i < count; i++) {
296 printf(" got: %s\n", paths[i] ? paths[i] : "(null)");
297 }
298 return 0;
299 }
300 }
301 return 1;
302}
303
304/* ── Tests ──────────────────────────────────────────────────────────────── */
305

Callers 1

repro_issue842.cFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected