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

Function check_example_6

ccan/ccan/graphql/test/run.c:344–400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

342}
343
344void check_example_6(char *source) {
345 struct list_head *tokens;
346 struct graphql_token *tok;
347
348 if (!mute) printf("// Example No. 6\n");
349
350 sprintf(source, "\
351{\n\
352 field\n\
353}\n\
354 ");
355
356 // Test the lexer.
357 TEST_CONT(graphql_lex(NULL, source, &tokens) == NULL);
358 TEST_ABRT(listlen(tokens) == 3);
359 tok = list_pop(tokens, struct graphql_token, node);
360 TEST_CONT(tok->token_type == '{');
361 tok = list_pop(tokens, struct graphql_token, node);
362 TEST_CONT(tok->token_type == 'a');
363 TEST_STRG(tok->token_string, "field");
364 TEST_CONT(tok->source_line == 2);
365 TEST_CONT(tok->source_column == 3);
366 TEST_CONT(tok->source_len == 5);
367 tok = list_pop(tokens, struct graphql_token, node);
368 TEST_CONT(tok->token_type == '}');
369 tok = list_pop(tokens, struct graphql_token, node);
370 TEST_CONT(tok == NULL);
371 tokens = tal_free(tokens);
372
373 // Test the parser.
374 struct graphql_executable_document *doc;
375 TEST_CONT(graphql_lex(NULL, source, &tokens) == NULL);
376 TEST_ABRT(graphql_parse(tokens, &doc) == NULL);
377 TEST_ABRT(doc != NULL);
378 TEST_ABRT(doc->first_def != NULL);
379 TEST_CONT(doc->first_def->next_def == NULL);
380 TEST_CONT(doc->first_def->frag_def == NULL);
381 TEST_ABRT(doc->first_def->op_def != NULL);
382 TEST_CONT(doc->first_def->op_def->op_type == NULL);
383 TEST_ABRT(doc->first_def->op_def->op_name == NULL);
384 TEST_CONT(doc->first_def->op_def->vars == NULL);
385 TEST_CONT(doc->first_def->op_def->directives == NULL);
386 TEST_ABRT(doc->first_def->op_def->sel_set != NULL);
387 TEST_ABRT(doc->first_def->op_def->sel_set->first != NULL);
388 TEST_CONT(doc->first_def->op_def->sel_set->first->next == NULL);
389 TEST_CONT(doc->first_def->op_def->sel_set->first->frag_spread == NULL);
390 TEST_CONT(doc->first_def->op_def->sel_set->first->inline_frag == NULL);
391 TEST_ABRT(doc->first_def->op_def->sel_set->first->field != NULL);
392 TEST_CONT(doc->first_def->op_def->sel_set->first->field->alias == NULL);
393 TEST_ABRT(doc->first_def->op_def->sel_set->first->field->name != NULL);
394 TEST_CONT(doc->first_def->op_def->sel_set->first->field->name->token_type == 'a');
395 TEST_STRG(doc->first_def->op_def->sel_set->first->field->name->token_string, "field");
396 TEST_CONT(doc->first_def->op_def->sel_set->first->field->args == NULL);
397 TEST_CONT(doc->first_def->op_def->sel_set->first->field->directives == NULL);
398 TEST_CONT(doc->first_def->op_def->sel_set->first->field->sel_set == NULL);
399 tokens = tal_free(tokens);
400}
401

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