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

Function check_example_11

ccan/ccan/graphql/test/run.c:933–1076  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

931}
932
933void check_example_11(char *source) {
934 struct list_head *tokens;
935 struct graphql_token *tok;
936
937 if (!mute) printf("// Example No. 11\n");
938
939 sprintf(source, "\
940{\n\
941 user(id: 4) {\n\
942 id\n\
943 name\n\
944 profilePic(width: 100, height: 50)\n\
945 }\n\
946}\n\
947 ");
948
949 // Test the lexer.
950 TEST_CONT(graphql_lex(NULL, source, &tokens) == NULL);
951 TEST_ABRT(listlen(tokens) == 21);
952 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '{');
953 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a');
954 TEST_STRG(tok->token_string, "user");
955 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '(');
956 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a');
957 TEST_STRG(tok->token_string, "id");
958 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == ':');
959 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'i');
960 TEST_STRG(tok->token_string, "4");
961 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == ')');
962 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '{');
963 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a');
964 TEST_STRG(tok->token_string, "id");
965 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a');
966 TEST_STRG(tok->token_string, "name");
967 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a');
968 TEST_STRG(tok->token_string, "profilePic");
969 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '(');
970 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a');
971 TEST_STRG(tok->token_string, "width");
972 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == ':');
973 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'i');
974 TEST_STRG(tok->token_string, "100");
975 // NOTE: Comma is ignored.
976 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a');
977 TEST_STRG(tok->token_string, "height");
978 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == ':');
979 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'i');
980 TEST_STRG(tok->token_string, "50");
981 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == ')');
982 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '}');
983 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '}');
984 tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok == NULL);
985 tokens = tal_free(tokens);
986
987 // Test the parser.
988 struct graphql_executable_document *doc;
989 TEST_CONT(graphql_lex(NULL, source, &tokens) == NULL);
990 TEST_ABRT(graphql_parse(tokens, &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