mirror of
https://https.git.savannah.gnu.org/git/gnulib.git
synced 2026-04-28 06:33:36 +00:00
tests: Use streq, part 2.
Done through sed -e 's/strcmp \([(][^()]*[)]\) != 0/!streq \1/' * tests/**/*.[hc]: Use !streq instead of strcmp ... != 0. * modules/*-tests (Dependencies): Add streq.
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
2026-03-01 Bruno Haible <bruno@clisp.org>
|
||||
|
||||
tests: Use streq, part 2.
|
||||
Done through sed -e 's/strcmp \([(][^()]*[)]\) != 0/!streq \1/'
|
||||
* tests/**/*.[hc]: Use !streq instead of strcmp ... != 0.
|
||||
* modules/*-tests (Dependencies): Add streq.
|
||||
|
||||
tests: Use streq, part 1.
|
||||
Done through sed -e 's/strcmp \([(][^()]*[)]\) == 0/streq \1/'
|
||||
* tests/**/*.[hc]: Use streq instead of strcmp ... == 0.
|
||||
|
||||
@@ -16,6 +16,7 @@ read-file
|
||||
unistd-h
|
||||
xalloc
|
||||
test-framework-sh
|
||||
streq
|
||||
|
||||
configure.ac:
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ c99
|
||||
intprops
|
||||
setlocale
|
||||
strerror
|
||||
streq
|
||||
|
||||
configure.ac:
|
||||
gt_LOCALE_FR
|
||||
|
||||
@@ -4,6 +4,7 @@ tests/test-filenamecat.c
|
||||
Depends-on:
|
||||
idx
|
||||
bool
|
||||
streq
|
||||
|
||||
configure.ac:
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ Files:
|
||||
tests/test-gettext-h.c
|
||||
|
||||
Depends-on:
|
||||
streq
|
||||
|
||||
configure.ac:
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ m4/musl.m4
|
||||
|
||||
Depends-on:
|
||||
setlocale
|
||||
streq
|
||||
|
||||
configure.ac:
|
||||
gl_MUSL_LIBC
|
||||
|
||||
@@ -5,6 +5,7 @@ tests/test-libgmp-mpz.c
|
||||
Depends-on:
|
||||
assert-h
|
||||
c99
|
||||
streq
|
||||
|
||||
configure.ac:
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ Depends-on:
|
||||
setlocale
|
||||
thread
|
||||
nanosleep
|
||||
streq
|
||||
|
||||
configure.ac:
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ tests/signature.h
|
||||
|
||||
Depends-on:
|
||||
net_if-h-c++-tests
|
||||
streq
|
||||
|
||||
configure.ac:
|
||||
NET_IF_LIB=
|
||||
|
||||
@@ -2,6 +2,7 @@ Files:
|
||||
tests/test-qsort_r.c
|
||||
|
||||
Depends-on:
|
||||
streq
|
||||
|
||||
configure.ac:
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ setenv
|
||||
unsetenv
|
||||
setlocale
|
||||
localcharset
|
||||
streq
|
||||
|
||||
configure.ac:
|
||||
gt_LOCALE_FR
|
||||
|
||||
@@ -6,6 +6,7 @@ Depends-on:
|
||||
gettext-h
|
||||
localcharset
|
||||
wctype-h
|
||||
streq
|
||||
|
||||
configure.ac:
|
||||
AC_CHECK_DECLS_ONCE([alarm])
|
||||
|
||||
@@ -7,6 +7,7 @@ tests/macros.h
|
||||
Depends-on:
|
||||
gethostname
|
||||
root-uid
|
||||
streq
|
||||
|
||||
configure.ac:
|
||||
AC_CHECK_FUNCS_ONCE([geteuid])
|
||||
|
||||
@@ -6,6 +6,7 @@ tests/test-setlocale_null-mt-all.c
|
||||
Depends-on:
|
||||
thread
|
||||
nanosleep
|
||||
streq
|
||||
|
||||
configure.ac:
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ unportable-test
|
||||
|
||||
Depends-on:
|
||||
unlink
|
||||
streq
|
||||
|
||||
configure.ac:
|
||||
|
||||
|
||||
@@ -57,12 +57,12 @@ main (_GL_UNUSED int argc, char *argv[])
|
||||
idx_t prefixlen = base_in_result - res;
|
||||
size_t t0len = strlen (t[0]);
|
||||
size_t reslen = strlen (res);
|
||||
if (strcmp (res, t[2]) != 0)
|
||||
if (!streq (res, t[2]))
|
||||
{
|
||||
fprintf (stderr, "test #%u: got %s, expected %s\n", i, res, t[2]);
|
||||
fail = true;
|
||||
}
|
||||
if (strcmp (t[1], base_in_result) != 0)
|
||||
if (!streq (t[1], base_in_result))
|
||||
{
|
||||
fprintf (stderr, "test #%u: base %s != base_in_result %s\n",
|
||||
i, t[1], base_in_result);
|
||||
|
||||
@@ -30,11 +30,11 @@ main (void)
|
||||
textdomain ("tzlof");
|
||||
|
||||
s = gettext ("some text");
|
||||
if (strcmp (s, "some text") != 0)
|
||||
if (!streq (s, "some text"))
|
||||
return 1;
|
||||
|
||||
s = pgettext ("menu", "some other text");
|
||||
if (strcmp (s, "some other text") != 0)
|
||||
if (!streq (s, "some other text"))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -65,7 +65,7 @@ test_one (const char *name, int failure_bitmask)
|
||||
#if defined __NetBSD__
|
||||
expected = false;
|
||||
#elif defined MUSL_LIBC
|
||||
expected = strcmp (name, "C.UTF-8") != 0;
|
||||
expected = !streq (name, "C.UTF-8");
|
||||
#elif (defined __OpenBSD__ && HAVE_DUPLOCALE) || defined __HAIKU__ || defined __ANDROID__ /* OpenBSD >= 6.2, Haiku, Android */
|
||||
expected = true;
|
||||
#else
|
||||
|
||||
@@ -40,13 +40,13 @@ main ()
|
||||
char gmp_header_version[32];
|
||||
sprintf (gmp_header_version, "%d.%d.%d", __GNU_MP_VERSION,
|
||||
__GNU_MP_VERSION_MINOR, __GNU_MP_VERSION_PATCHLEVEL);
|
||||
if (strcmp (gmp_version, gmp_header_version) != 0)
|
||||
if (!streq (gmp_version, gmp_header_version))
|
||||
{
|
||||
char gmp_header_version2[32];
|
||||
if (__GNU_MP_VERSION_PATCHLEVEL > 0
|
||||
|| (sprintf (gmp_header_version2, "%d.%d", __GNU_MP_VERSION,
|
||||
__GNU_MP_VERSION_MINOR),
|
||||
strcmp (gmp_version, gmp_header_version2) != 0))
|
||||
!streq (gmp_version, gmp_header_version2)))
|
||||
{
|
||||
fprintf (stderr,
|
||||
"gmp header version (%s) does not match gmp library version (%s).\n",
|
||||
|
||||
@@ -67,7 +67,7 @@ thread1_func (void *arg)
|
||||
for (;;)
|
||||
{
|
||||
const char *value = localeconv () -> decimal_point;
|
||||
if (strcmp (expected1, value) != 0)
|
||||
if (!streq (expected1, value))
|
||||
{
|
||||
fprintf (stderr, "thread1 disturbed by threadN!\n"); fflush (stderr);
|
||||
abort ();
|
||||
@@ -85,7 +85,7 @@ thread2_func (void *arg)
|
||||
for (;;)
|
||||
{
|
||||
const char *value = localeconv () -> thousands_sep;
|
||||
if (strcmp (expected2, value) != 0)
|
||||
if (!streq (expected2, value))
|
||||
{
|
||||
fprintf (stderr, "thread2 disturbed by threadN!\n"); fflush (stderr);
|
||||
abort ();
|
||||
@@ -103,7 +103,7 @@ thread3_func (void *arg)
|
||||
for (;;)
|
||||
{
|
||||
const char *value = localeconv () -> mon_decimal_point;
|
||||
if (strcmp (expected3, value) != 0)
|
||||
if (!streq (expected3, value))
|
||||
{
|
||||
fprintf (stderr, "thread3 disturbed by threadN!\n"); fflush (stderr);
|
||||
abort ();
|
||||
@@ -121,7 +121,7 @@ thread4_func (void *arg)
|
||||
for (;;)
|
||||
{
|
||||
const char *value = localeconv () -> mon_thousands_sep;
|
||||
if (strcmp (expected4, value) != 0)
|
||||
if (!streq (expected4, value))
|
||||
{
|
||||
fprintf (stderr, "thread4 disturbed by threadN!\n"); fflush (stderr);
|
||||
abort ();
|
||||
@@ -139,7 +139,7 @@ thread5_func (void *arg)
|
||||
for (;;)
|
||||
{
|
||||
const char *value = localeconv () -> currency_symbol;
|
||||
if (strcmp (expected5, value) != 0)
|
||||
if (!streq (expected5, value))
|
||||
{
|
||||
fprintf (stderr, "thread5 disturbed by threadN!\n"); fflush (stderr);
|
||||
abort ();
|
||||
@@ -157,7 +157,7 @@ thread6_func (void *arg)
|
||||
for (;;)
|
||||
{
|
||||
const char *value = localeconv () -> int_curr_symbol;
|
||||
if (strcmp (expected6, value) != 0)
|
||||
if (!streq (expected6, value))
|
||||
{
|
||||
fprintf (stderr, "thread6 disturbed by threadN!\n"); fflush (stderr);
|
||||
abort ();
|
||||
|
||||
@@ -76,7 +76,7 @@ main (int argc, char *argv[])
|
||||
p->if_index);
|
||||
return 1;
|
||||
}
|
||||
if (strcmp (p->if_name, q) != 0)
|
||||
if (!streq (p->if_name, q))
|
||||
{
|
||||
fprintf (stderr, "if_indextoname (%s) = %s ?!\n", p->if_name, q);
|
||||
return 1;
|
||||
|
||||
@@ -67,7 +67,7 @@ thread1_func (void *arg)
|
||||
for (;;)
|
||||
{
|
||||
const char *value = nl_langinfo (CODESET);
|
||||
if (strcmp (expected1, value) != 0)
|
||||
if (!streq (expected1, value))
|
||||
{
|
||||
fprintf (stderr, "thread1 disturbed by threadN!\n"); fflush (stderr);
|
||||
abort ();
|
||||
@@ -85,7 +85,7 @@ thread2_func (void *arg)
|
||||
for (;;)
|
||||
{
|
||||
const char *value = nl_langinfo (PM_STR);
|
||||
if (strcmp (expected2, value) != 0)
|
||||
if (!streq (expected2, value))
|
||||
{
|
||||
fprintf (stderr, "thread2 disturbed by threadN!\n"); fflush (stderr);
|
||||
abort ();
|
||||
@@ -103,7 +103,7 @@ thread3_func (void *arg)
|
||||
for (;;)
|
||||
{
|
||||
const char *value = nl_langinfo (DAY_2);
|
||||
if (strcmp (expected3, value) != 0)
|
||||
if (!streq (expected3, value))
|
||||
{
|
||||
fprintf (stderr, "thread3 disturbed by threadN!\n"); fflush (stderr);
|
||||
abort ();
|
||||
@@ -121,7 +121,7 @@ thread4_func (void *arg)
|
||||
for (;;)
|
||||
{
|
||||
const char *value = nl_langinfo (ALTMON_2);
|
||||
if (strcmp (expected4, value) != 0)
|
||||
if (!streq (expected4, value))
|
||||
{
|
||||
fprintf (stderr, "thread4 disturbed by threadN!\n"); fflush (stderr);
|
||||
abort ();
|
||||
@@ -139,7 +139,7 @@ thread5_func (void *arg)
|
||||
for (;;)
|
||||
{
|
||||
const char *value = nl_langinfo (CRNCYSTR);
|
||||
if (strcmp (expected5, value) != 0)
|
||||
if (!streq (expected5, value))
|
||||
{
|
||||
fprintf (stderr, "thread5 disturbed by threadN!\n"); fflush (stderr);
|
||||
abort ();
|
||||
@@ -157,7 +157,7 @@ thread6_func (void *arg)
|
||||
for (;;)
|
||||
{
|
||||
const char *value = nl_langinfo (RADIXCHAR);
|
||||
if (strcmp (expected6, value) != 0)
|
||||
if (!streq (expected6, value))
|
||||
{
|
||||
fprintf (stderr, "thread6 disturbed by threadN!\n"); fflush (stderr);
|
||||
abort ();
|
||||
|
||||
@@ -66,7 +66,7 @@ main (int argc, char *argv[])
|
||||
*/
|
||||
const char *fr_locale_name =
|
||||
getenv (pass == 1 ? "LOCALE_FR" : "LOCALE_FR_UTF8");
|
||||
if (strcmp (fr_locale_name, "none") != 0)
|
||||
if (!streq (fr_locale_name, "none"))
|
||||
{
|
||||
/* Use a per-thread locale. */
|
||||
locale_t fr_locale = newlocale (LC_ALL_MASK, fr_locale_name, NULL);
|
||||
|
||||
@@ -287,7 +287,7 @@ quarter_test (void)
|
||||
}
|
||||
|
||||
exp[0] = mon < 4 ? '1' : mon < 7 ? '2' : mon < 10 ? '3' : '4';
|
||||
if (strcmp (out, exp) != 0)
|
||||
if (!streq (out, exp))
|
||||
{
|
||||
printf ("%s %%q: expected \"%s\", got \"%s\"\n", FUNC_NAME, exp, out);
|
||||
fflush (stdout);
|
||||
|
||||
@@ -38,10 +38,10 @@ main (void)
|
||||
int forward = 1;
|
||||
int reverse = -1;
|
||||
qsort_r (buf, sizeof buf - 1, 1, cmp, &forward);
|
||||
if (strcmp (buf, "abcddeeeefghhijklmnoooopqrrsttuuvwxyz") != 0)
|
||||
if (!streq (buf, "abcddeeeefghhijklmnoooopqrrsttuuvwxyz"))
|
||||
return 1;
|
||||
qsort_r (buf, sizeof buf - 1, 1, cmp, &reverse);
|
||||
if (strcmp (buf, "zyxwvuuttsrrqpoooonmlkjihhgfeeeeddcba") != 0)
|
||||
if (!streq (buf, "zyxwvuuttsrrqpoooonmlkjihhgfeeeeddcba"))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ main (_GL_UNUSED int argc, char *argv[])
|
||||
{
|
||||
const char *locale_name = getenv ("LOCALE");
|
||||
|
||||
if (!(locale_name != NULL && strcmp (locale_name, "none") != 0
|
||||
if (!(locale_name != NULL && !streq (locale_name, "none")
|
||||
&& setenv ("LC_ALL", locale_name, 1) == 0
|
||||
&& setlocale (LC_ALL, "") != NULL))
|
||||
{
|
||||
|
||||
@@ -469,7 +469,7 @@ main (void)
|
||||
s = re_compile_pattern (pat_badback, sizeof pat_badback, ®ex);
|
||||
if (!s && re_search (®ex, "x", 1, 0, 1, ®s) != -1)
|
||||
s = "mishandled invalid back reference";
|
||||
if (s && strcmp (s, "Invalid back reference") != 0)
|
||||
if (s && !streq (s, "Invalid back reference"))
|
||||
report_error ("%s: %s", pat_badback, s);
|
||||
|
||||
#if 0
|
||||
|
||||
@@ -171,7 +171,7 @@ main (int argc, char *argv[])
|
||||
{
|
||||
if (text2 != NULL)
|
||||
{
|
||||
if (strcmp (text1, text2) != 0)
|
||||
if (!streq (text1, text2))
|
||||
{
|
||||
fprintf (stderr, "files %s and %s have different ACLs:\n%s\n%s\n",
|
||||
file1, file2, text1, text2);
|
||||
@@ -583,7 +583,7 @@ main (int argc, char *argv[])
|
||||
abort ();
|
||||
}
|
||||
|
||||
if (strcmp (text1, text2) != 0)
|
||||
if (!streq (text1, text2))
|
||||
{
|
||||
fprintf (stderr, "files %s and %s have different ACLs:\n%s\n%s\n",
|
||||
file1, file2, text1, text2);
|
||||
|
||||
@@ -99,7 +99,7 @@ main (int argc, _GL_UNUSED char *argv[])
|
||||
/* if we don't get back what we put in, there is no need to
|
||||
restore the original name as we will assume it was not
|
||||
properly changed. */
|
||||
if (strcmp (newname, TESTHOSTNAME) != 0)
|
||||
if (!streq (newname, TESTHOSTNAME))
|
||||
{
|
||||
fprintf (stderr, "set/get comparison failed.\n");
|
||||
return 1;
|
||||
|
||||
@@ -73,7 +73,7 @@ thread1_func (void *arg)
|
||||
|
||||
if (setlocale_null_r (LC_ALL, buf, sizeof (buf)))
|
||||
abort ();
|
||||
if (strcmp (expected, buf) != 0)
|
||||
if (!streq (expected, buf))
|
||||
{
|
||||
fprintf (stderr, "thread1 disturbed by thread2!\n"); fflush (stderr);
|
||||
abort ();
|
||||
|
||||
@@ -73,7 +73,7 @@ thread1_func (void *arg)
|
||||
|
||||
if (setlocale_null_r (LC_NUMERIC, buf, sizeof (buf)))
|
||||
abort ();
|
||||
if (strcmp (expected, buf) != 0)
|
||||
if (!streq (expected, buf))
|
||||
{
|
||||
fprintf (stderr, "thread1 disturbed by thread2!\n"); fflush (stderr);
|
||||
abort ();
|
||||
|
||||
@@ -84,8 +84,8 @@ main ()
|
||||
char *message = strerror_l (ERANGE, l1);
|
||||
ASSERT (message != NULL);
|
||||
/* German is neither English nor French. */
|
||||
ASSERT (strcmp (message, c_message) != 0);
|
||||
ASSERT (strcmp (message, fr_message) != 0);
|
||||
ASSERT (!streq (message, c_message));
|
||||
ASSERT (!streq (message, fr_message));
|
||||
freelocale (l1);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ main ()
|
||||
|
||||
/* gen_tempname arranges (via O_EXCL) to not return the name of an existing
|
||||
file. */
|
||||
ASSERT (strcmp (filename1, filename2) != 0);
|
||||
ASSERT (!streq (filename1, filename2));
|
||||
|
||||
/* Clean up. */
|
||||
close (fd1);
|
||||
@@ -75,7 +75,7 @@ main ()
|
||||
the probability of getting the same file name twice in a row should be
|
||||
1/62^6 < 1/10^10.
|
||||
But on 64-bit native Windows, this probability is ca. 0.1% to 0.3%. */
|
||||
ASSERT (strcmp (filename1, filename2) != 0);
|
||||
ASSERT (!streq (filename1, filename2));
|
||||
|
||||
/* Clean up. */
|
||||
close (fd2);
|
||||
|
||||
@@ -211,7 +211,7 @@ test_name_lookup ()
|
||||
fprintf (stderr, "\\u%04X name lookup failed!\n", i);
|
||||
error = 1;
|
||||
}
|
||||
else if (strcmp (result, unicode_names[i]) != 0)
|
||||
else if (!streq (result, unicode_names[i]))
|
||||
{
|
||||
fprintf (stderr, "\\u%04X name lookup returned wrong name: %s\n",
|
||||
i, result);
|
||||
@@ -362,7 +362,7 @@ main (int argc, char *argv[])
|
||||
int error = 0;
|
||||
int i;
|
||||
|
||||
for (i = 1; i < argc && strcmp (argv[i], "--") != 0; i++)
|
||||
for (i = 1; i < argc && !streq (argv[i], "--"); i++)
|
||||
fill_names (argv[i]);
|
||||
|
||||
if (i < argc)
|
||||
|
||||
Reference in New Issue
Block a user