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

Function check_example_9

ccan/ccan/graphql/test/run.c:665–800  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

663}
664
665void check_example_9(char *source) {
666 struct list_head *tokens;
667 struct graphql_token *tok;
668
669 if (!mute) printf("// Example No. 9\n");
670
671 sprintf(source, "\
672# `me` could represent the currently logged in viewer.\n\
673{\n\
674 me {\n\
675 name\n\
676 }\n\
677}\n\
678\n\
679# `user` represents one of many users in a graph of data, referred to by a\n\
680# unique identifier.\n\
681{\n\
682 user(id: 4) {\n\
683 name\n\
684 }\n\
685}\n\
686 ");
687
688 // Test the lexer.
689 TEST_CONT(graphql_lex(NULL, source, &tokens) == NULL);
690 TEST_ABRT(listlen(tokens) == 17);
691 // NOTE: Comments are ignored.
692 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '{');
693 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a');
694 TEST_STRG(tok->token_string, "me");
695 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '{');
696 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a');
697 TEST_STRG(tok->token_string, "name");
698 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '}');
699 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '}');
700 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '{');
701 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a');
702 TEST_STRG(tok->token_string, "user");
703 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '(');
704 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a');
705 TEST_STRG(tok->token_string, "id");
706 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == ':');
707 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'i');
708 TEST_STRG(tok->token_string, "4");
709 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == ')');
710 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '{');
711 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a');
712 TEST_STRG(tok->token_string, "name");
713 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '}');
714 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '}');
715 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok == NULL);
716 tokens = tal_free(tokens);
717
718 // Test the parser.
719 struct graphql_executable_document *doc;
720 TEST_CONT(graphql_lex(NULL, source, &tokens) == NULL);
721 TEST_ABRT(graphql_parse(tokens, &doc) == NULL);
722 TEST_ABRT(doc != 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