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

Function check_example_5

ccan/ccan/graphql/test/run.c:207–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205}
206
207void check_example_5(char *source) {
208 struct list_head *tokens;
209 struct graphql_token *tok;
210
211 if (!mute) printf("// Example No. 5\n");
212
213 sprintf(source, "\
214mutation {\n\
215 likeStory(storyID: 12345) {\n\
216 story {\n\
217 likeCount\n\
218 }\n\
219 }\n\
220}\n\
221 ");
222
223 // Test the lexer.
224 TEST_CONT(graphql_lex(NULL, source, &tokens) == NULL);
225 TEST_ABRT(listlen(tokens) == 15);
226 tok = list_pop(tokens, struct graphql_token, node);
227 TEST_CONT(tok->token_type == 'a');
228 TEST_STRG(tok->token_string, "mutation");
229 TEST_CONT(tok->source_line == 1);
230 TEST_CONT(tok->source_column == 1);
231 TEST_CONT(tok->source_len == 8);
232 tok = list_pop(tokens, struct graphql_token, node);
233 TEST_CONT(tok->token_type == '{');
234 tok = list_pop(tokens, struct graphql_token, node);
235 TEST_CONT(tok->token_type == 'a');
236 TEST_STRG(tok->token_string, "likeStory");
237 TEST_CONT(tok->source_line == 2);
238 TEST_CONT(tok->source_column == 3);
239 TEST_CONT(tok->source_len == 9);
240 tok = list_pop(tokens, struct graphql_token, node);
241 TEST_CONT(tok->token_type == '(');
242 tok = list_pop(tokens, struct graphql_token, node);
243 TEST_CONT(tok->token_type == 'a');
244 TEST_STRG(tok->token_string, "storyID");
245 TEST_CONT(tok->source_line == 2);
246 tok = list_pop(tokens, struct graphql_token, node);
247 TEST_CONT(tok->token_type == ':');
248 tok = list_pop(tokens, struct graphql_token, node);
249 TEST_CONT(tok->token_type == 'i');
250 TEST_STRG(tok->token_string, "12345");
251 TEST_CONT(tok->source_line == 2);
252 TEST_CONT(tok->source_column == 22);
253 TEST_CONT(tok->source_len == 5);
254 tok = list_pop(tokens, struct graphql_token, node);
255 TEST_CONT(tok->token_type == ')');
256 tok = list_pop(tokens, struct graphql_token, node);
257 TEST_CONT(tok->token_type == '{');
258 tok = list_pop(tokens, struct graphql_token, node);
259 TEST_CONT(tok->token_type == 'a');
260 TEST_STRG(tok->token_string, "story");
261 TEST_CONT(tok->source_line == 3);
262 tok = list_pop(tokens, struct graphql_token, node);
263 TEST_CONT(tok->token_type == '{');
264 tok = list_pop(tokens, struct graphql_token, node);

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