From 99b1b6e74b9ded856466eccb998c762a3a7f1f45 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Thu, 9 May 2024 03:09:53 +0200 Subject: Make the rest of the casemapping functions take custom allocators --- test/_case-test.h | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'test/_case-test.h') diff --git a/test/_case-test.h b/test/_case-test.h index 8f18b69..684c6ec 100644 --- a/test/_case-test.h +++ b/test/_case-test.h @@ -52,7 +52,7 @@ main(int, char **argv) bool test(const char8_t *line, int id) { - struct u8view sv = {line, strlen(line)}; + struct u8view mapped, sv = {line, strlen(line)}; struct u8view before, after, flags; u8cut(&before, &sv, U";", 1); u8cut(&after, &sv, U";", 1); @@ -63,27 +63,21 @@ test(const char8_t *line, int id) : u8eq(flags, U8("LT")) ? CF_LANG_LT : u8eq(flags, U8("NL")) ? CF_LANG_NL : 0; - char8_t *buf = bufalloc(nullptr, 1, after.len); - size_t bufsz = FUNC(nullptr, 0, before, cf); - if (bufsz != after.len) { - warn("case %d: expected %s buffer size of %zu but got %zu", - id, STR(CASETYPE_VERB), after.len, bufsz); - return false; - } - bufsz = FUNC(buf, bufsz, before, cf); - if (bufsz != after.len) { - warn("case %d: expected %s length of %zu but got %zu", - id, STR(CASETYPE_VERB), after.len, bufsz); + arena a = mkarena(0); + mapped.p = FUNC(&mapped.len, before, cf, alloc_arena, &a); + + if (mapped.p == nullptr) { + warn("case %d: got null %s buffer", id, STR(CASETYPE_VERB)); return false; } - if (!memeq(buf, after.p, bufsz)) { - warn("case %d: expected ‘%.*s’ but got ‘%.*s’", - id, SV_PRI_ARGS(after), (int)bufsz, buf); + if (!u8eq(mapped, after)) { + warn("case %d: expected ‘%.*s’ but got ‘%.*s’", id, SV_PRI_ARGS(after), + SV_PRI_ARGS(mapped)); return false; } - free(buf); + arena_free(&a); return true; } -- cgit v1.2.3