projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
New module attribute 'Applicability'.
[gnulib.git]
/
tests
/
test-strcasestr.c
diff --git
a/tests/test-strcasestr.c
b/tests/test-strcasestr.c
index
a674719
..
8ecd3a9
100644
(file)
--- a/
tests/test-strcasestr.c
+++ b/
tests/test-strcasestr.c
@@
-20,19
+20,21
@@
#include <string.h>
#include <string.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define ASSERT(expr) \
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
+ do
\
+ {
\
+ if (!(expr))
\
+ {
\
fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- abort (); \
- } \
- } \
+ fflush (stderr); \
+ abort (); \
+ } \
+ } \
while (0)
int
while (0)
int
@@
-41,8
+43,9
@@
main ()
#if HAVE_DECL_ALARM
/* Declare failure if test takes too long, by using default abort
caused by SIGALRM. All known platforms that lack alarm also lack
#if HAVE_DECL_ALARM
/* Declare failure if test takes too long, by using default abort
caused by SIGALRM. All known platforms that lack alarm also lack
-
memmem, and the replacement memmem
is known to not take too
+
strcasestr, and the replacement strcasestr
is known to not take too
long. */
long. */
+ signal (SIGALRM, SIG_DFL);
alarm (50);
#endif
alarm (50);
#endif
@@
-88,16
+91,16
@@
main ()
char *haystack = (char *) malloc (m + 1);
if (haystack != NULL)
{
char *haystack = (char *) malloc (m + 1);
if (haystack != NULL)
{
- memset (haystack, 'A', m);
- haystack[0] = 'B';
- haystack[m] = '\0';
+
memset (haystack, 'A', m);
+
haystack[0] = 'B';
+
haystack[m] = '\0';
- for (; repeat > 0; repeat--)
- {
- ASSERT (strcasestr (haystack, needle) == haystack + 1);
- }
+
for (; repeat > 0; repeat--)
+
{
+
ASSERT (strcasestr (haystack, needle) == haystack + 1);
+
}
- free (haystack);
+
free (haystack);
}
}
}
}
@@
-112,15
+115,15
@@
main ()
char *needle = (char *) malloc (m + 1);
if (needle != NULL)
{
char *needle = (char *) malloc (m + 1);
if (needle != NULL)
{
- memset (needle, 'A', m);
- needle[m] = '\0';
+
memset (needle, 'A', m);
+
needle[m] = '\0';
- for (; repeat > 0; repeat--)
- {
- ASSERT (strcasestr (haystack, needle) == NULL);
- }
+
for (; repeat > 0; repeat--)
+
{
+
ASSERT (strcasestr (haystack, needle) == NULL);
+
}
- free (needle);
+
free (needle);
}
}
}
}
@@
-131,18
+134,18
@@
main ()
char *needle = (char *) malloc (m + 2);
if (haystack != NULL && needle != NULL)
{
char *needle = (char *) malloc (m + 2);
if (haystack != NULL && needle != NULL)
{
- const char *result;
+
const char *result;
- memset (haystack, 'A', 2 * m);
- haystack[2 * m] = 'B';
- haystack[2 * m + 1] = '\0';
+
memset (haystack, 'A', 2 * m);
+
haystack[2 * m] = 'B';
+
haystack[2 * m + 1] = '\0';
- memset (needle, 'a', m);
- needle[m] = 'B';
- needle[m + 1] = '\0';
+
memset (needle, 'a', m);
+
needle[m] = 'B';
+
needle[m + 1] = '\0';
- result = strcasestr (haystack, needle);
- ASSERT (result == haystack + m);
+
result = strcasestr (haystack, needle);
+
ASSERT (result == haystack + m);
}
free (needle);
free (haystack);
}
free (needle);
free (haystack);