diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2022-01-08 11:53:52 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2022-01-08 11:53:52 +0100 |
commit | fa838e76139763f902c7d27cb9e1d393ed6a15e4 (patch) | |
tree | 7d0ae09775ea950056193eaa2ca93844299d46f1 /tests/test-strstr.c | |
parent | c78359d9542c86b972aac373efcf7bc7a8a560e5 (diff) | |
parent | 2959e59fab3bab834368adefd90bd4b1b094366b (diff) |
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'tests/test-strstr.c')
-rw-r--r-- | tests/test-strstr.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/tests/test-strstr.c b/tests/test-strstr.c index 5ba6cb8..046439b 100644 --- a/tests/test-strstr.c +++ b/tests/test-strstr.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007-2018 Free Software Foundation, Inc. + * Copyright (C) 2004, 2007-2022 Free Software Foundation, Inc. * Written by Bruno Haible and Eric Blake * * This program is free software: you can redistribute it and/or modify @@ -60,7 +60,7 @@ main (int argc, char *argv[]) read access for strstr(). See <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737>. This is a bug in memchr(), see the Austin Group's clarification - <http://www.opengroup.org/austin/docs/austin_454.txt>. */ + <https://www.opengroup.org/austin/docs/austin_454.txt>. */ const char *fix = "aBaaaaaaaaaaax"; char *page_boundary = (char *) zerosize_ptr (); size_t len = strlen (fix) + 1; @@ -275,5 +275,27 @@ main (int argc, char *argv[]) free (haystack); } + /* Test long needles. */ + { + size_t m = 1024; + char *haystack = (char *) malloc (2 * m + 1); + char *needle = (char *) malloc (m + 1); + if (haystack != NULL && needle != NULL) + { + const char *p; + haystack[0] = 'x'; + memset (haystack + 1, ' ', m - 1); + memset (haystack + m, 'x', m); + haystack[2 * m] = '\0'; + memset (needle, 'x', m); + needle[m] = '\0'; + p = strstr (haystack, needle); + ASSERT (p); + ASSERT (p - haystack == m); + } + free (needle); + free (haystack); + } + return 0; } |