diff options
Diffstat (limited to 'tests/test_as_tokenizer.c')
| -rw-r--r-- | tests/test_as_tokenizer.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/tests/test_as_tokenizer.c b/tests/test_as_tokenizer.c index 4f5aac6..f791324 100644 --- a/tests/test_as_tokenizer.c +++ b/tests/test_as_tokenizer.c @@ -6,14 +6,14 @@ #include "as_tokenizer.h" #include "utils.h" -char *inputBuffer = +char *input_buffer = "start:\n" " add 1\n" " sub start\n" " div\n" " eq\n"; -char *expectedOutput = +char *expected_output = "LABEL: start, line: 1, col: 1\n" "COLON\n" "NEWLINE\n" @@ -31,26 +31,26 @@ char *expectedOutput = int main(int argc, char** argv) { printf("[TEST] assembler tokenizer\n"); // make a memory buffer to FILE* - FILE *fp = fmemopen(inputBuffer, strlen(inputBuffer), "r"); - Allocator alct = newAllocator(); - TokenStream ts = makeTokenStream(alct, fp); + FILE *fp = fmemopen(input_buffer, strlen(input_buffer), "r"); + allocator_t alct = new_allocator(); + token_stream_t ts = new_token_stream(alct, fp); - char *outputBuffer = malloc(10240); + char *output_buffer = malloc(10240); // redirect stdout to a file - FILE *out = fmemopen(outputBuffer, 10240, "w"); + FILE *out = fmemopen(output_buffer, 10240, "w"); FILE *origin_stdout = stdout; stdout = out; - while (peekToken(alct, ts)->type != ENDOFFILE) { - printToken(peekToken(alct, ts)); - nextToken(alct, ts); + while (peek_token(alct, ts)->type != TK_ENDOFFILE) { + print_token(peek_token(alct, ts)); + next_token(alct, ts); } fclose(out); stdout = origin_stdout; - // compare outputBuffer with expectedOutput - assert(strcmp(outputBuffer, expectedOutput) == 0); + + assert(strcmp(output_buffer, expected_output) == 0); printf("[PASS] assembler tokenizer\n"); - free(outputBuffer); - deleteAllocator(alct); + free(output_buffer); + delete_allocator(alct); return 0; } |
