Runs `query` and checks that its first column holds exactly the names in * `expected`, given in strcmp order; the rows are sorted the same way so the * engine's row order does not matter. */
| 5353 | * `expected`, given in strcmp order; the rows are sorted the same way so the |
| 5354 | * engine's row order does not matter. */ |
| 5355 | static int assert_name_set(cbm_store_t *s, const char *query, const char *const *expected, int n) { |
| 5356 | enum { NAME_SET_MAX = 8 }; |
| 5357 | ASSERT_TRUE(n <= NAME_SET_MAX); |
| 5358 | cbm_cypher_result_t r = {0}; |
| 5359 | int rc = cbm_cypher_execute(s, query, "test", 0, &r); |
| 5360 | if (rc != 0) { |
| 5361 | printf(" query error: %s\n", r.error ? r.error : "(none)"); |
| 5362 | } |
| 5363 | ASSERT_EQ(rc, 0); |
| 5364 | ASSERT_EQ(r.row_count, n); |
| 5365 | const char *names[NAME_SET_MAX]; |
| 5366 | for (int i = 0; i < n; i++) { |
| 5367 | names[i] = r.rows[i][0]; |
| 5368 | } |
| 5369 | qsort(names, (size_t)n, sizeof(names[0]), cmp_cstr); |
| 5370 | for (int i = 0; i < n; i++) { |
| 5371 | ASSERT_STR_EQ(names[i], expected[i]); |
| 5372 | } |
| 5373 | cbm_cypher_result_free(&r); |
| 5374 | return 0; |
| 5375 | } |
| 5376 | |
| 5377 | /* Every spelling in `forms` is one WHERE expression; all must yield `expected`. */ |
| 5378 | static int where_forms_agree(cbm_store_t *s, const char *const *forms, int form_count, |
no test coverage detected