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