aboutsummaryrefslogtreecommitdiff
path: root/string/test
diff options
context:
space:
mode:
authorWilco Dijkstra <wilco.dijkstra@arm.com>2020-05-22 14:33:50 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2020-05-22 14:39:13 +0100
commitedfa34d216848b4ec84e5f11da4db89229f638ef (patch)
tree4ba5a069752df3cb986441584f96f39f0b82e448 /string/test
parent833a1ea7d90308a769d5d91d5aca6708a67aa7ee (diff)
downloadarm-optimized-routines-edfa34d216848b4ec84e5f11da4db89229f638ef.tar.gz
string: Cleanup strnlen test
Cleanup strnlen test and improve test coverage.
Diffstat (limited to 'string/test')
-rw-r--r--string/test/strnlen.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/string/test/strnlen.c b/string/test/strnlen.c
index e4a9c42..c838092 100644
--- a/string/test/strnlen.c
+++ b/string/test/strnlen.c
@@ -55,23 +55,24 @@ test (const struct fun *fun, int align, size_t maxlen, size_t len)
if (err_count >= ERR_LIMIT)
return;
- if (len > LEN || align > ALIGN)
+ if (len > LEN || align >= ALIGN)
abort ();
for (int i = 0; src + i < s; i++)
src[i] = 0;
for (int i = 1; i <= ALIGN; i++)
- s[len + i] = 0;
+ s[len + i] = (len + align) & 1 ? 1 : 0;
for (int i = 0; i < len; i++)
s[i] = 'a' + (i & 31);
s[len] = 0;
- s[((len ^ align) & 1) ? e + 1 : len + 1] = 0;
+ if ((len + align) & 1)
+ s[e + 1] = 0;
r = fun->fun (s, maxlen);
if (r != e)
{
- ERR ("%s (%p, %zu) len %zu returned %zu, expected %zu\n", fun->name, s,
- maxlen, len, r, e);
+ ERR ("%s (%p, %zu) len %zu returned %zu, expected %zu\n",
+ fun->name, s, maxlen, len, r, e);
quote ("input", s, len);
}
}