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

Function check_example_10

ccan/ccan/graphql/test/run.c:802–931  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

800}
801
802void check_example_10(char *source) {
803 struct list_head *tokens;
804 struct graphql_token *tok;
805
806 if (!mute) printf("// Example No. 10\n");
807
808 sprintf(source, "\
809{\n\
810 user(id: 4) {\n\
811 id\n\
812 name\n\
813 profilePic(size: 100)\n\
814 }\n\
815}\n\
816 ");
817
818 // Test the lexer.
819 TEST_CONT(graphql_lex(NULL, source, &tokens) == NULL);
820 TEST_ABRT(listlen(tokens) == 18);
821 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '{');
822 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a');
823 TEST_STRG(tok->token_string, "user");
824 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '(');
825 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a');
826 TEST_STRG(tok->token_string, "id");
827 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == ':');
828 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'i');
829 TEST_STRG(tok->token_string, "4");
830 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == ')');
831 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '{');
832 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a');
833 TEST_STRG(tok->token_string, "id");
834 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a');
835 TEST_STRG(tok->token_string, "name");
836 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a');
837 TEST_STRG(tok->token_string, "profilePic");
838 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '(');
839 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a');
840 TEST_STRG(tok->token_string, "size");
841 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == ':');
842 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'i');
843 TEST_STRG(tok->token_string, "100");
844 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == ')');
845 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '}');
846 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '}');
847 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok == NULL);
848 tokens = tal_free(tokens);
849
850 // Test the parser.
851 struct graphql_executable_document *doc;
852 TEST_CONT(graphql_lex(NULL, source, &tokens) == NULL);
853 TEST_ABRT(graphql_parse(tokens, &doc) == NULL);
854 TEST_ABRT(doc != NULL);
855 TEST_ABRT(doc->first_def != NULL);
856 TEST_CONT(doc->first_def->next_def == NULL);
857 TEST_CONT(doc->first_def->frag_def == NULL);
858 TEST_ABRT(doc->first_def->op_def != NULL);
859 TEST_CONT(doc->first_def->op_def->op_type == 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