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

Function th_index_status_check

tests/test_httpd.c:3904–3931  ·  view source on GitHub ↗

Parse an index-status body and compare each entry's "path" with the root * expected for its slot. Results go to out-params so the caller can tear * down before asserting. */

Source from the content-addressed store, hash-verified

3902 * expected for its slot. Results go to out-params so the caller can tear
3903 * down before asserting. */
3904static void th_index_status_check(const char *body, int expected_count, char expected[][4096],
3905 bool *parsed, int *count, bool *paths_whole) {
3906 *parsed = false;
3907 *count = 0;
3908 *paths_whole = false;
3909 yyjson_doc *doc = yyjson_read(body, strlen(body), 0);
3910 if (!doc) {
3911 return;
3912 }
3913 yyjson_val *arr = yyjson_doc_get_root(doc);
3914 if (yyjson_is_arr(arr)) {
3915 *parsed = true;
3916 *count = (int)yyjson_arr_size(arr);
3917 bool whole = *count == expected_count;
3918 size_t idx;
3919 size_t max_entries;
3920 yyjson_val *entry;
3921 yyjson_arr_foreach(arr, idx, max_entries, entry) {
3922 yyjson_val *slot = yyjson_obj_get(entry, "slot");
3923 yyjson_val *path = yyjson_obj_get(entry, "path");
3924 int s = yyjson_is_int(slot) ? yyjson_get_int(slot) : -1;
3925 whole = whole && s >= 0 && s < expected_count && yyjson_is_str(path) &&
3926 strcmp(yyjson_get_str(path), expected[s]) == 0;
3927 }
3928 *paths_whole = whole;
3929 }
3930 yyjson_doc_free(doc);
3931}
3932
3933/* The listing is sized for what the job table holds. Every slot takes a root
3934 * as long as the platform resolves; the body has to parse as JSON and carry

Callers 1

test_httpd.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected