projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
doc: update users.txt
[gnulib.git]
/
tests
/
test-mbscasestr2.c
diff --git
a/tests/test-mbscasestr2.c
b/tests/test-mbscasestr2.c
index
712bf3f
..
f9e120c
100644
(file)
--- a/
tests/test-mbscasestr2.c
+++ b/
tests/test-mbscasestr2.c
@@
-1,5
+1,5
@@
/* Test of searching in a string.
/* Test of searching in a string.
- Copyright (C) 2007-20
08
Free Software Foundation, Inc.
+ Copyright (C) 2007-20
11
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-21,20
+21,9
@@
#include <string.h>
#include <locale.h>
#include <string.h>
#include <locale.h>
-#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
int
main ()
int
main ()
@@
-78,22
+67,22
@@
main ()
{
size_t repeat = 10000;
size_t m = 1000000;
{
size_t repeat = 10000;
size_t m = 1000000;
- char *needle =
+ c
onst c
har *needle =
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
char *haystack = (char *) malloc (m + 1);
if (haystack != NULL)
{
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
char *haystack = (char *) malloc (m + 1);
if (haystack != NULL)
{
- memset (haystack, 'a', m);
- haystack[0] = '\303'; haystack[1] = '\204';
- haystack[m] = '\0';
+
memset (haystack, 'a', m);
+
haystack[0] = '\303'; haystack[1] = '\204';
+
haystack[m] = '\0';
- for (; repeat > 0; repeat--)
- {
- ASSERT (mbscasestr (haystack, needle) == haystack + 2);
- }
+
for (; repeat > 0; repeat--)
+
{
+
ASSERT (mbscasestr (haystack, needle) == haystack + 2);
+
}
- free (haystack);
+
free (haystack);
}
}
}
}
@@
-102,7
+91,7
@@
main ()
{
size_t repeat = 10000;
size_t m = 1000000;
{
size_t repeat = 10000;
size_t m = 1000000;
- char *haystack =
+ c
onst c
har *haystack =
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"A\303\207A\303\207A\303\207A\303\207A\303\207A\303\207A\303\207"
"A\303\207A\303\207A\303\207A\303\207A\303\207A\303\207A\303\207"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"A\303\207A\303\207A\303\207A\303\207A\303\207A\303\207A\303\207"
"A\303\207A\303\207A\303\207A\303\207A\303\207A\303\207A\303\207"
@@
-112,15
+101,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 (mbscasestr (haystack, needle) == NULL);
- }
+
for (; repeat > 0; repeat--)
+
{
+
ASSERT (mbscasestr (haystack, needle) == NULL);
+
}
- free (needle);
+
free (needle);
}
}
}
}
@@
-131,18
+120,18
@@
main ()
char *needle = (char *) malloc (m + 3);
if (haystack != NULL && needle != NULL)
{
char *needle = (char *) malloc (m + 3);
if (haystack != NULL && needle != NULL)
{
- const char *result;
+
const char *result;
- memset (haystack, 'A', 2 * m);
- haystack[2 * m] = '\303'; haystack[2 * m + 1] = '\247';
- haystack[2 * m + 2] = '\0';
+
memset (haystack, 'A', 2 * m);
+
haystack[2 * m] = '\303'; haystack[2 * m + 1] = '\247';
+
haystack[2 * m + 2] = '\0';
- memset (needle, 'a', m);
- needle[m] = '\303'; needle[m + 1] = '\207';
- needle[m + 2] = '\0';
+
memset (needle, 'a', m);
+
needle[m] = '\303'; needle[m + 1] = '\207';
+
needle[m + 2] = '\0';
- result = mbscasestr (haystack, needle);
- ASSERT (result == haystack + m);
+
result = mbscasestr (haystack, needle);
+
ASSERT (result == haystack + m);
}
free (needle);
free (haystack);
}
free (needle);
free (haystack);