summaryrefslogtreecommitdiff
path: root/tests/test-strstr.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-strstr.c')
-rw-r--r--tests/test-strstr.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/test-strstr.c b/tests/test-strstr.c
index 1482e7de82..1ddd015276 100644
--- a/tests/test-strstr.c
+++ b/tests/test-strstr.c
@@ -91,6 +91,25 @@ main (int argc, char *argv[])
ASSERT (result == input + 11);
}
+ /* Check that a long periodic needle does not cause false positives. */
+ {
+ const char input[] = ("F_BD_CE_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD"
+ "_C3_88_20_EF_BF_BD_EF_BF_BD_EF_BF_BD"
+ "_C3_A7_20_EF_BF_BD");
+ const char need[] = "_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD";
+ const char *result = strstr (input, need);
+ ASSERT (result == NULL);
+ }
+ {
+ const char input[] = ("F_BD_CE_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD"
+ "_C3_88_20_EF_BF_BD_EF_BF_BD_EF_BF_BD"
+ "_C3_A7_20_EF_BF_BD_DA_B5_C2_A6_20"
+ "_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD");
+ const char need[] = "_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD";
+ const char *result = strstr (input, need);
+ ASSERT (result == input + 115);
+ }
+
/* Check that a very long haystack is handled quickly if the needle is
short and occurs near the beginning. */
{