@@ -101,7 +101,7 @@ inhibit_loop_to_libcall
SIMPLE_MEMSET (CHAR *s, int c, size_t n)
{
CHAR *r = s, *end = s + n;
- while (r < end)
+ while (r != end)
*r++ = c;
return s;
}
@@ -237,7 +237,7 @@ do_random_tests (void)
int
test_main (void)
{
- size_t i;
+ size_t i, j;
int c = 0;
test_init ();
@@ -252,15 +252,29 @@ test_main (void)
#endif
{
for (i = 0; i < 18; ++i)
- do_test (0, c, 1 << i);
- for (i = 1; i < 64; ++i)
+ {
+ do_test (0, c, 1 << i);
+ do_test (i, c, 1 << i);
+ do_test (0, c, (1 << i) + 1);
+ do_test (i, c, (1 << i) + 1);
+ do_test (0, c, (1 << i) - 1);
+ do_test (i, c, (1 << i) - 1);
+ }
+ for (i = 1; i < 128; ++i)
{
- do_test (i, c, i);
- do_test (4096 - i, c, i);
- do_test (4095, c, i);
+ for (j = i; j <= 2500; j += 15)
+ {
+ do_test (i, c, j);
+ do_test (4096 - i, c, j);
+ do_test (4095, c, j);
+ }
if (i & (i - 1))
do_test (0, c, i);
}
+ do_test (0, c, 257);
+ do_test (0, c, 383);
+ do_test (0, c, 384);
+ do_test (0, c, 385);
do_test (1, c, 14);
do_test (3, c, 1024);
do_test (4, c, 64);
This commit adds some additional tests cases that seemed lacking. Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com> --- string/test-memset.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-)