diff options
author | Noah Goldstein <goldstein.w.n@gmail.com> | 2022-10-29 15:19:57 -0500 |
---|---|---|
committer | Noah Goldstein <goldstein.w.n@gmail.com> | 2022-11-08 19:19:35 -0800 |
commit | ca7d181b62f703ae56b7be1e27428184560f68b4 (patch) | |
tree | 7ba13edf767a4cb6e452cd093b51e99170cfa7cb /string/test-memcmp.c | |
parent | 2e274cd8c1ebd0bd0c43a7f2e5433685740938ca (diff) | |
download | glibc-ca7d181b62f703ae56b7be1e27428184560f68b4.tar glibc-ca7d181b62f703ae56b7be1e27428184560f68b4.tar.gz glibc-ca7d181b62f703ae56b7be1e27428184560f68b4.tar.bz2 glibc-ca7d181b62f703ae56b7be1e27428184560f68b4.zip |
string: Add len=0 to {w}memcmp{eq} tests and benchtests
len=0 is valid and fairly common so should be tested.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Diffstat (limited to 'string/test-memcmp.c')
-rw-r--r-- | string/test-memcmp.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/string/test-memcmp.c b/string/test-memcmp.c index 181b689f68..18d8b0d9f1 100644 --- a/string/test-memcmp.c +++ b/string/test-memcmp.c @@ -117,9 +117,6 @@ do_test (size_t align1, size_t align2, size_t len, int exp_result) size_t i; CHAR *s1, *s2; - if (len == 0) - return; - align1 &= (4096 - CHARBYTES); if (align1 + (len + 1) * CHARBYTES >= page_size) return; @@ -134,9 +131,16 @@ do_test (size_t align1, size_t align2, size_t len, int exp_result) for (i = 0; i < len; i++) s1[i] = s2[i] = 1 + (23 << ((CHARBYTES - 1) * 8)) * i % CHAR__MAX; - s1[len] = align1; - s2[len] = align2; - s2[len - 1] -= exp_result; + if (len) + { + s1[len] = align1; + s2[len] = align2; + s2[len - 1] -= exp_result; + } + else + { + exp_result = 0; + } FOR_EACH_IMPL (impl, 0) do_one_test (impl, s1, s2, len, exp_result); |