#include #include #include #include #include #include #include "io_backend/io_backend.h" #include "lexer/lexer.h" TestSuite(peek_token); Test(peek_token, basic_empty) { // simulates input char command[] = ""; struct iob_context context = { IOB_MODE_CMD, command }; iob_init(&context); struct lexer_context ctx = { .end_previous_token = NULL, .remaining_chars = 0, .only_digits = false, .previous_token = NULL, .current_token = NULL }; // test struct token *tok = peek_token(&ctx); // expected enum token_type type_expected = TOKEN_EOF; char *string_expected = NULL; cr_assert(tok->data == string_expected); cr_assert(type_expected == tok->type); free_token(&tok); } Test(peek_token, basic_word) { // simulates input char command[] = "hello"; struct iob_context context = { IOB_MODE_CMD, command }; iob_init(&context); struct lexer_context ctx = { .end_previous_token = NULL, .remaining_chars = 0, .only_digits = false, .previous_token = NULL, .current_token = NULL }; // test struct token *tok = peek_token(&ctx); // expected enum token_type type_expected = TOKEN_WORD; char string_expected[] = "hello"; cr_assert(eq(str, string_expected, tok->data)); cr_assert(type_expected == tok->type); free_token(&tok); }