diff options
| author | Mistivia <i@mistivia.com> | 2025-03-16 20:03:30 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-03-16 20:03:30 +0800 |
| commit | c684a4a302e95d860210a9ddaa891adf9775eadc (patch) | |
| tree | 1803180b7b508121f414204de98c7f0a0bc47b58 /tests/test_as_tokenizer.c | |
| parent | b83187f66175d93a0dba45f6d110ed94badac7c5 (diff) | |
fix unit test
Diffstat (limited to 'tests/test_as_tokenizer.c')
| -rw-r--r-- | tests/test_as_tokenizer.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/test_as_tokenizer.c b/tests/test_as_tokenizer.c index c32eddb..4f5aac6 100644 --- a/tests/test_as_tokenizer.c +++ b/tests/test_as_tokenizer.c @@ -4,6 +4,7 @@ #include <assert.h> #include "as_tokenizer.h" +#include "utils.h" char *inputBuffer = "start:\n" @@ -31,22 +32,25 @@ int main(int argc, char** argv) { printf("[TEST] assembler tokenizer\n"); // make a memory buffer to FILE* FILE *fp = fmemopen(inputBuffer, strlen(inputBuffer), "r"); - TokenStream* ts = makeTokenStream(fp); + Allocator alct = newAllocator(); + TokenStream ts = makeTokenStream(alct, fp); char *outputBuffer = malloc(10240); // redirect stdout to a file FILE *out = fmemopen(outputBuffer, 10240, "w"); FILE *origin_stdout = stdout; stdout = out; - while (peekToken(ts)->type != ENDOFFILE) { - printToken(peekToken(ts)); - nextToken(ts); + while (peekToken(alct, ts)->type != ENDOFFILE) { + printToken(peekToken(alct, ts)); + nextToken(alct, ts); } fclose(out); stdout = origin_stdout; // compare outputBuffer with expectedOutput assert(strcmp(outputBuffer, expectedOutput) == 0); printf("[PASS] assembler tokenizer\n"); + free(outputBuffer); + deleteAllocator(alct); return 0; } |
