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

Function run_inherit_case

tests/test_extraction_inheritance.c:154–214  ·  view source on GitHub ↗

* Generic runner for one inherit_case_t row. * Returns 0 on pass, 1 on failure (sets FAIL path via printf + return). * Cannot use ASSERT macros directly here because they do `return 1` — which * is fine since this helper also returns int. We use manual checks so we * can include the case description in the failure message. */

Source from the content-addressed store, hash-verified

152 * can include the case description in the failure message.
153 */
154static int run_inherit_case(const inherit_case_t *tc) {
155 CBMFileResult *r =
156 cbm_extract_file(tc->src, (int)strlen(tc->src), tc->lang, "t", tc->path, 0, NULL, NULL);
157 if (!r) {
158 printf(" FAIL [%s] cbm_extract_file returned NULL\n", tc->class_name);
159 return 1;
160 }
161
162 CBMDefinition *cls = find_def_flex(r, tc->class_name);
163 if (!cls) {
164 printf(" FAIL [%s] definition not found in extraction result\n", tc->class_name);
165 cbm_free_result(r);
166 return 1;
167 }
168
169 /* When no bases are expected and no min count is set, this is a
170 * no-crash / sanity row — skip the rest of the checks. */
171 if (!tc->expected_bases[0] && tc->min_base_count == 0) {
172 cbm_free_result(r);
173 return 0;
174 }
175
176 /* Assert base_classes is non-NULL (at least one base expected). */
177 if (!cls->base_classes) {
178 printf(" FAIL [%s] base_classes is NULL (expected non-empty)\n", tc->class_name);
179 cbm_free_result(r);
180 return 1;
181 }
182
183 /* Assert each expected base name is present. */
184 int ok = 1;
185 for (int i = 0; tc->expected_bases[i]; i++) {
186 if (!bases_contain(cls, tc->expected_bases[i])) {
187 printf(" FAIL [%s] expected base \"%s\" not found in base_classes\n", tc->class_name,
188 tc->expected_bases[i]);
189 ok = 0;
190 }
191 }
192
193 /* Assert no bad keyword strings appear inside any base name. */
194 for (int i = 0; tc->bad_strings[i]; i++) {
195 if (bases_contain_substr(cls, tc->bad_strings[i])) {
196 printf(" FAIL [%s] bad string \"%s\" found inside a base_classes entry\n",
197 tc->class_name, tc->bad_strings[i]);
198 ok = 0;
199 }
200 }
201
202 /* Assert minimum count. */
203 if (tc->min_base_count > 0) {
204 int cnt = bases_count(cls);
205 if (cnt < tc->min_base_count) {
206 printf(" FAIL [%s] base_classes has %d entries, expected >= %d\n", tc->class_name,
207 cnt, tc->min_base_count);
208 ok = 0;
209 }
210 }
211

Callers

nothing calls this directly

Calls 6

cbm_extract_fileFunction · 0.85
find_def_flexFunction · 0.85
cbm_free_resultFunction · 0.85
bases_containFunction · 0.85
bases_contain_substrFunction · 0.85
bases_countFunction · 0.85

Tested by

no test coverage detected