aboutsummaryrefslogtreecommitdiff
path: root/string/test-strcasestr.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2012-10-05 13:32:07 -0700
committerH.J. Lu <hjl.tools@gmail.com>2012-10-05 13:32:07 -0700
commit03759f47db62930f2dddf1c9733ef89b9d99e2da (patch)
treeff23ba8b81b00366f0cbc0c890e9e7487b4497ae /string/test-strcasestr.c
parentfb228a2d94a130eda38c8794b0f264aa9f0e4714 (diff)
downloadglibc-03759f47db62930f2dddf1c9733ef89b9d99e2da.zip
glibc-03759f47db62930f2dddf1c9733ef89b9d99e2da.tar.gz
glibc-03759f47db62930f2dddf1c9733ef89b9d99e2da.tar.bz2
Test strcasestr/strchr/strstr under all implementations
Diffstat (limited to 'string/test-strcasestr.c')
-rw-r--r--string/test-strcasestr.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/string/test-strcasestr.c b/string/test-strcasestr.c
index 6c1a878..fc01858 100644
--- a/string/test-strcasestr.c
+++ b/string/test-strcasestr.c
@@ -57,8 +57,9 @@ IMPL (simple_strcasestr, 0)
IMPL (strcasestr, 1)
-static void
-do_one_test (impl_t *impl, const char *s1, const char *s2, char *exp_result)
+static int
+check_result (impl_t *impl, const char *s1, const char *s2,
+ char *exp_result)
{
char *result = CALL (impl, s1, s2);
if (result != exp_result)
@@ -66,8 +67,16 @@ do_one_test (impl_t *impl, const char *s1, const char *s2, char *exp_result)
error (0, 0, "Wrong result in function %s %s %s", impl->name,
result, exp_result);
ret = 1;
- return;
+ return -1;
}
+ return 0;
+}
+
+static void
+do_one_test (impl_t *impl, const char *s1, const char *s2, char *exp_result)
+{
+ if (check_result (impl, s1, s2, exp_result) < 0)
+ return;
if (HP_TIMING_AVAIL)
{
@@ -136,12 +145,25 @@ do_test (size_t align1, size_t align2, size_t len1, size_t len2,
putchar ('\n');
}
+static void
+check1 (void)
+{
+ const char s1[] = "AOKB";
+ const char s2[] = "OK";
+ char *exp_result;
+
+ exp_result = stupid_strcasestr (s1, s2);
+ FOR_EACH_IMPL (impl, 0)
+ check_result (impl, s1, s2, exp_result);
+}
static int
test_main (void)
{
test_init ();
+ check1 ();
+
printf ("%23s", "");
FOR_EACH_IMPL (impl, 0)
printf ("\t%s", impl->name);