| 494 | } |
| 495 | |
| 496 | void check_example_8(char *source) { |
| 497 | struct list_head *tokens; |
| 498 | struct graphql_token *tok; |
| 499 | |
| 500 | if (!mute) printf("// Example No. 8\n"); |
| 501 | |
| 502 | sprintf(source, "\ |
| 503 | {\n\ |
| 504 | me {\n\ |
| 505 | id\n\ |
| 506 | firstName\n\ |
| 507 | lastName\n\ |
| 508 | birthday {\n\ |
| 509 | month\n\ |
| 510 | day\n\ |
| 511 | }\n\ |
| 512 | friends {\n\ |
| 513 | name\n\ |
| 514 | }\n\ |
| 515 | }\n\ |
| 516 | }\n\ |
| 517 | "); |
| 518 | |
| 519 | // Test the lexer. |
| 520 | TEST_CONT(graphql_lex(NULL, source, &tokens) == NULL); |
| 521 | TEST_ABRT(listlen(tokens) == 17); |
| 522 | tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '{'); |
| 523 | tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a'); |
| 524 | TEST_STRG(tok->token_string, "me"); |
| 525 | tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '{'); |
| 526 | tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a'); |
| 527 | TEST_STRG(tok->token_string, "id"); |
| 528 | tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a'); |
| 529 | TEST_STRG(tok->token_string, "firstName"); |
| 530 | tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a'); |
| 531 | TEST_STRG(tok->token_string, "lastName"); |
| 532 | tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a'); |
| 533 | TEST_STRG(tok->token_string, "birthday"); |
| 534 | tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '{'); |
| 535 | tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a'); |
| 536 | TEST_STRG(tok->token_string, "month"); |
| 537 | tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a'); |
| 538 | TEST_STRG(tok->token_string, "day"); |
| 539 | tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '}'); |
| 540 | tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a'); |
| 541 | TEST_STRG(tok->token_string, "friends"); |
| 542 | tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '{'); |
| 543 | tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == 'a'); |
| 544 | TEST_STRG(tok->token_string, "name"); |
| 545 | tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '}'); |
| 546 | tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '}'); |
| 547 | tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok->token_type == '}'); |
| 548 | tok = list_pop(tokens, struct graphql_token, node); TEST_CONT(tok == NULL); |
| 549 | tokens = tal_free(tokens); |
| 550 | |
| 551 | // Test the parser. |
| 552 | struct graphql_executable_document *doc; |
| 553 | TEST_CONT(graphql_lex(NULL, source, &tokens) == NULL); |
nothing calls this directly
no test coverage detected