MCPcopy Create free account
hub / github.com/ElementsProject/lightning / check_example_16

Function check_example_16

ccan/ccan/graphql/test/run.c:1336–1440  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1334}
1335
1336void check_example_16(char *source) {
1337 struct list_head *tokens;
1338 struct graphql_token *tok;
1339
1340 if (!mute) printf("// Example No. 16\n");
1341
1342 sprintf(source, "\
1343{\n\
1344 zuck: user(id: 4) {\n\
1345 id\n\
1346 name\n\
1347 }\n\
1348}\n\
1349 ");
1350
1351 // Test the lexer.
1352 TEST_CONT(graphql_lex(NULL, source, &tokens) == NULL);
1353 TEST_ABRT(listlen(tokens) == 14);
1354 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '{');
1355 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a');
1356 TEST_STRG(tok->token_string, "zuck");
1357 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == ':');
1358 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a');
1359 TEST_STRG(tok->token_string, "user");
1360 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '(');
1361 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a');
1362 TEST_STRG(tok->token_string, "id");
1363 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == ':');
1364 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'i');
1365 TEST_STRG(tok->token_string, "4");
1366 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == ')');
1367 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '{');
1368 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a');
1369 TEST_STRG(tok->token_string, "id");
1370 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a');
1371 TEST_STRG(tok->token_string, "name");
1372 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '}');
1373 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '}');
1374 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok == NULL);
1375 tokens = tal_free(tokens);
1376
1377 // Test the parser.
1378 struct graphql_executable_document *doc;
1379 TEST_CONT(graphql_lex(NULL, source, &tokens) == NULL);
1380 TEST_ABRT(graphql_parse(tokens, &doc) == NULL);
1381 TEST_ABRT(doc != NULL);
1382 TEST_ABRT(doc->first_def != NULL);
1383 TEST_CONT(doc->first_def->next_def == NULL);
1384 TEST_CONT(doc->first_def->frag_def == NULL);
1385 TEST_ABRT(doc->first_def->op_def != NULL);
1386 TEST_CONT(doc->first_def->op_def->op_type == NULL);
1387 TEST_CONT(doc->first_def->op_def->op_name == NULL);
1388 TEST_CONT(doc->first_def->op_def->vars == NULL);
1389 TEST_CONT(doc->first_def->op_def->directives == NULL);
1390 TEST_ABRT(doc->first_def->op_def->sel_set != NULL);
1391 TEST_ABRT(doc->first_def->op_def->sel_set->first != NULL);
1392 TEST_CONT(doc->first_def->op_def->sel_set->first->next == NULL);
1393 TEST_CONT(doc->first_def->op_def->sel_set->first->frag_spread == NULL);

Callers

nothing calls this directly

Calls 4

graphql_lexFunction · 0.85
listlenFunction · 0.85
tal_freeFunction · 0.85
graphql_parseFunction · 0.85

Tested by

no test coverage detected