From 8eb8ef3b5410cd8c7b930c0589a4af744f64b6e9 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sat, 4 May 2024 00:22:03 +0200 Subject: Make test more stringent --- test/upper-test.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/test/upper-test.c b/test/upper-test.c index 6881e0c..c1a8ead 100644 --- a/test/upper-test.c +++ b/test/upper-test.c @@ -64,18 +64,25 @@ test(const char8_t *line, int id) cf |= CF_LANG_LT; char8_t *buf = bufalloc(nullptr, 1, after.len); - size_t ret = u8upper(buf, after.len, U8_ARGS(before), cf); + size_t bufsz = u8upper(nullptr, 0, U8_ARGS(before), cf); + if (bufsz != after.len) { + warn("case %d: expected uppercased buffer size of %zu but got %zu " + "(flags=‘%.*s’)", + id, after.len, bufsz, U8_PRI_ARGS(flags)); + return false; + } - if (ret != after.len) { + bufsz = u8upper(buf, bufsz, U8_ARGS(before), cf); + if (bufsz != after.len) { warn("case %d: expected uppercased length of %zu but got %zu " "(flags=‘%.*s’)", - id, after.len, ret, U8_PRI_ARGS(flags)); + id, after.len, bufsz, U8_PRI_ARGS(flags)); return false; } - if (!memeq(buf, after.p, after.len)) { + if (!memeq(buf, after.p, bufsz)) { warn("case %d: expected ‘%.*s’ but got ‘%.*s’ (flags=‘%.*s’)", id, - U8_PRI_ARGS(after), (int)after.len, buf, U8_PRI_ARGS(flags)); + U8_PRI_ARGS(after), (int)bufsz, buf, U8_PRI_ARGS(flags)); return false; } -- cgit v1.2.3