/* Test and measure strcmp and wcscmp functions.
- Copyright (C) 1999-2012 Free Software Foundation, Inc.
+ Copyright (C) 1999-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Jakub Jelinek <jakub@redhat.com>, 1999.
Added wcscmp support by Liubov Dmitrieva <liubov.dmitrieva@gmail.com>, 2011.
<http://www.gnu.org/licenses/>. */
#define TEST_MAIN
+#ifdef WIDE
+# define TEST_NAME "wcscmp"
+#else
+# define TEST_NAME "strcmp"
+#endif
#include "test-string.h"
#ifdef WIDE
{
if (check_result (impl, s1, s2, exp_result) < 0)
return;
-
- if (HP_TIMING_AVAIL)
- {
- hp_timing_t start __attribute ((unused));
- hp_timing_t stop __attribute ((unused));
- hp_timing_t best_time = ~ (hp_timing_t) 0;
- size_t i;
-
- for (i = 0; i < 32; ++i)
- {
- HP_TIMING_NOW (start);
- CALL (impl, s1, s2);
- HP_TIMING_NOW (stop);
- HP_TIMING_BEST (best_time, start, stop);
- }
-
- printf ("\t%zd", (size_t) best_time);
- }
}
static void
s2[len + 1] = 24 + exp_result;
s2[len - 1] -= exp_result;
- if (HP_TIMING_AVAIL)
- printf ("Length %4zd, alignment %2zd/%2zd:", len, align1, align2);
-
FOR_EACH_IMPL (impl, 0)
do_one_test (impl, s1, s2, exp_result);
-
- if (HP_TIMING_AVAIL)
- putchar ('\n');
}
static void
FOR_EACH_IMPL (impl, 0)
check_result (impl, s1 + i1, s2 + i2, exp_result);
}
+
+ /* Test cases where there are multiple zero bytes after the first. */
+
+ for (size_t i = 0; i < 16 + 1; i++)
+ {
+ s1[i] = 0x00;
+ s2[i] = 0x00;
+ }
+
+ for (size_t i = 0; i < 16; i++)
+ {
+ int exp_result;
+
+ for (int val = 0x01; val < 0x100; val++)
+ {
+ for (size_t j = 0; j < i; j++)
+ {
+ s1[j] = val;
+ s2[j] = val;
+ }
+
+ s2[i] = val;
+
+ exp_result = SIMPLE_STRCMP (s1, s2);
+ FOR_EACH_IMPL (impl, 0)
+ check_result (impl, s1, s2, exp_result);
+ }
+ }
}