From 0cf2b231e34dcf88b4d7abcdb01785b6aba265ce Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Tue, 14 May 2024 17:48:30 +0200 Subject: Fix test suite --- test/_brk-test.h | 15 +++++++++------ test/run-tests | 4 ++-- test/wbrk-human-test.c | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/test/_brk-test.h b/test/_brk-test.h index e599578..909f33f 100644 --- a/test/_brk-test.h +++ b/test/_brk-test.h @@ -56,8 +56,14 @@ test(struct u8view sv, int id) { size_t total = 0; + arena a = mkarena(0); + struct arena_ctx ctx = {.a = &a}; + typedef dynarr(char8_t) item; - dynarr(item) items = {}; + dynarr(item) items = { + .alloc = alloc_arena, + .ctx = &ctx, + }; rune op; struct u8view sv_cpy = sv; @@ -70,7 +76,7 @@ test(struct u8view sv, int id) total += w; if (op == U'÷') - DAPUSH(&items, (item){}); + DAPUSH(&items, ((item){.alloc = alloc_arena, .ctx = &ctx})); DAEXTEND(&items.buf[items.len - 1], buf, w); } @@ -102,10 +108,7 @@ test(struct u8view sv, int id) } } - da_foreach (items, wd) - free(wd->buf); - free(items.buf); + arena_free(&a); free(p); - return true; } diff --git a/test/run-tests b/test/run-tests index f8554c0..4413fff 100755 --- a/test/run-tests +++ b/test/run-tests @@ -12,7 +12,7 @@ download() readonly FLAGS=' -std=c23 -I../include - -Og -ggdb3 + -O0 -g -ggdb3 -Wall -Wextra -Wpedantic -Wno-pointer-sign -Wno-attributes @@ -34,7 +34,7 @@ sed -En 's/\s+//g; s/÷?#.*//g; /./p' data/WordBreakTest >wbrk.in for src in *.c do - gcc $FLAGS -o "${src%.*}" "$src" ../libmlib.a + cc $FLAGS -o "${src%.*}" "$src" ../libmlib.a done trap "$( diff --git a/test/wbrk-human-test.c b/test/wbrk-human-test.c index 1fa9bd8..6f8bf7a 100644 --- a/test/wbrk-human-test.c +++ b/test/wbrk-human-test.c @@ -50,7 +50,7 @@ test(struct u8view sv, int id) u8cut(&src, &sv, U";", 1); struct u8view w; - dynarr(struct u8view) ws = {}; + dynarr(struct u8view) ws = {.alloc = alloc_heap}; while (u8cut(&w, &sv, U"|", 1) != MBEND) DAPUSH(&ws, w); -- cgit v1.2.3