aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-05-09 03:09:53 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-05-09 03:09:53 +0200
commit99b1b6e74b9ded856466eccb998c762a3a7f1f45 (patch)
tree50ac470fd46416b99c8d5788f4b02bb0a12daa58 /test
parent085b77730a553ce9769fcc76b68772dbde564004 (diff)
Make the rest of the casemapping functions take custom allocators
Diffstat (limited to 'test')
-rw-r--r--test/_case-test.h26
-rwxr-xr-xtest/run-tests1
2 files changed, 11 insertions, 16 deletions
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;
}
diff --git a/test/run-tests b/test/run-tests
index 2562a32..f8554c0 100755
--- a/test/run-tests
+++ b/test/run-tests
@@ -16,6 +16,7 @@ readonly FLAGS='
-Wall -Wextra -Wpedantic
-Wno-pointer-sign
-Wno-attributes
+ -fsanitize=address,undefined
'
(cd ..; ./make)