diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-05-04 00:22:03 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-05-04 00:22:03 +0200 |
commit | 8eb8ef3b5410cd8c7b930c0589a4af744f64b6e9 (patch) | |
tree | c614f22bbc533b9e8b65706f5483a780d78154a6 /test | |
parent | 4dba29f6a5f1450fec25a506e21e2ccf53be3568 (diff) |
Make test more stringent
Diffstat (limited to 'test')
-rw-r--r-- | test/upper-test.c | 17 |
1 files 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; } |