| 169 | } |
| 170 | |
| 171 | static bool td_presets(cbm_test_declarations_t *declarations, yyjson_val *value) { |
| 172 | static const char *const names[CBM_TEST_PRESET_COUNT] = { |
| 173 | [CBM_TEST_PRESET_C_CBM] = "c-cbm", [CBM_TEST_PRESET_PYTEST] = "pytest", |
| 174 | [CBM_TEST_PRESET_GO] = "go", [CBM_TEST_PRESET_JUNIT] = "junit", |
| 175 | [CBM_TEST_PRESET_GTEST] = "gtest", [CBM_TEST_PRESET_RUST] = "rust", |
| 176 | [CBM_TEST_PRESET_JEST] = "jest"}; |
| 177 | if (!yyjson_is_obj(value)) |
| 178 | return false; |
| 179 | bool seen[CBM_TEST_PRESET_COUNT] = {false}; |
| 180 | size_t index, maximum; |
| 181 | yyjson_val *key, *enabled; |
| 182 | yyjson_obj_foreach(value, index, maximum, key, enabled) { |
| 183 | int preset = -1; |
| 184 | size_t len = yyjson_get_len(key); |
| 185 | const char *text = yyjson_get_str(key); |
| 186 | for (int candidate = 0; candidate < CBM_TEST_PRESET_COUNT; candidate++) { |
| 187 | if (len == strlen(names[candidate]) && memcmp(text, names[candidate], len) == 0) { |
| 188 | preset = candidate; |
| 189 | break; |
| 190 | } |
| 191 | } |
| 192 | /* An unknown switch is an unsupported semantic request, not an |
| 193 | * unrelated future field whose intent can safely remain unconsumed. */ |
| 194 | if (preset < 0 || seen[preset] || !yyjson_is_bool(enabled)) |
| 195 | return false; |
| 196 | seen[preset] = true; |
| 197 | declarations->presets[preset] = yyjson_get_bool(enabled); |
| 198 | } |
| 199 | return true; |
| 200 | } |
| 201 | |
| 202 | static bool td_project(cbm_test_declarations_t *declarations, yyjson_val *root) { |
| 203 | bool valid = true; |