]> Savannah Git Hosting - gnulib.git/commitdiff
tests: Use str_startswith.
authorBruno Haible <bruno@clisp.org>
Fri, 3 Jan 2025 09:23:56 +0000 (10:23 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 3 Jan 2025 09:23:56 +0000 (10:23 +0100)
* tests/test-environ.c (main): Use str_startswith.
* tests/test-getprogname.c (main): Likewise.
* tests/test-libtextstyle.c (main): Likewise.
* tests/test-strsignal.c (ASSERT_DESCRIPTION): Likewise.
* modules/environ-tests (Depends-on): Add str_startswith.
* modules/getprogname-tests (Depends-on): Likewise.
* modules/libtextstyle-optional-tests (Depends-on): Likewise.
* modules/strsignal-tests (Depends-on): Likewise.

ChangeLog
modules/environ-tests
modules/getprogname-tests
modules/libtextstyle-optional-tests
modules/strsignal-tests
tests/test-environ.c
tests/test-getprogname.c
tests/test-libtextstyle.c
tests/test-strsignal.c

index 1355aa2361658751c15dcb81bdc877c80cfce00c..50b3f2e22e0cfaa81db0333c4b6d74ea2ace0d4e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2025-01-03  Bruno Haible  <bruno@clisp.org>
 
+       tests: Use str_startswith.
+       * tests/test-environ.c (main): Use str_startswith.
+       * tests/test-getprogname.c (main): Likewise.
+       * tests/test-libtextstyle.c (main): Likewise.
+       * tests/test-strsignal.c (ASSERT_DESCRIPTION): Likewise.
+       * modules/environ-tests (Depends-on): Add str_startswith.
+       * modules/getprogname-tests (Depends-on): Likewise.
+       * modules/libtextstyle-optional-tests (Depends-on): Likewise.
+       * modules/strsignal-tests (Depends-on): Likewise.
+
        git-merge-changelog, gen-uni-tables: Use str_startswith.
        * lib/git-merge-changelog.c (main): Use str_startswith.
        * lib/gen-uni-tables.c (output_predicate, is_property_composite,
index c4fe0fd11f8c98beb0cdc20258268ed1497801ff..056096baa59ce8e7cd2ac169d01f428ea0ba1907 100644 (file)
@@ -2,6 +2,7 @@ Files:
 tests/test-environ.c
 
 Depends-on:
+str_startswith
 
 configure.ac:
 
index bd7137f8eaffdd8a931e9db76e19bd87e0c1a1e0..1b1bc0a53a1462c1b1b8b22c9f7fd1e4e0b4ed56 100644 (file)
@@ -3,6 +3,7 @@ tests/test-getprogname.c
 
 Depends-on:
 string-h
+str_startswith
 
 configure.ac:
 
index e930a00fbe71b3dd69101821a5aa1d9e6aed4111..e4dbd5d220bfff0753c80b5daf2864dd4b3c2334 100644 (file)
@@ -5,6 +5,7 @@ tests/test-libtextstyle-default.css
 Depends-on:
 c99
 isatty
+str_startswith
 
 configure.ac:
 gl_LIBTEXTSTYLE_OPTIONAL
index ab67eb1b699d73f3a3b1a1bb80625996ad6e56aa..531451c4cd0ec460fc70376b5c582b48bbad06b1 100644 (file)
@@ -4,6 +4,7 @@ tests/signature.h
 tests/macros.h
 
 Depends-on:
+str_startswith
 
 configure.ac:
 
index a5c74ced793b64f7264ae16067e74ab7e771366a..21641b894c84e8b87e85ffa27cff7a49249a0c19 100644 (file)
@@ -35,7 +35,7 @@ main ()
 
   for (; (string = *remaining_variables) != NULL; remaining_variables++)
     {
-      if (strncmp (string, "PATH=", 5) == 0)
+      if (str_startswith (string, "PATH="))
         /* Found the PATH environment variable.  */
         return 0;
     }
index 088561cf30a7594e57f8b188be9640d5aec0176c..e1e8cb5350f6700df5ddf435e2e47ddeaba5436a 100644 (file)
@@ -36,7 +36,7 @@ main (void)
      with "lt-" (depends on the platform).  But the name of the temporary
      executable is a detail that should not be visible to the end user and to
      the test suite.  Remove this "lt-" prefix here.  */
-  if (strncmp (p, "lt-", 3) == 0)
+  if (str_startswith (p, "lt-"))
     p += 3;
 
   /* Note: You can make this test fail
index e992daf1f26424dbfde6ed52bd5a88c2a0e26f90..6545a00223c201d5af77fb6bbb3e924fbf097604 100644 (file)
@@ -34,9 +34,9 @@ main (int argc, char *argv[])
   for (i = 1; i < argc; i++)
     {
       const char *arg = argv[i];
-      if (strncmp (arg, "--color=", 8) == 0)
+      if (str_startswith (arg, "--color="))
         handle_color_option (arg + 8);
-      else if (strncmp (arg, "--style=", 8) == 0)
+      else if (str_startswith (arg, "--style="))
         handle_style_option (arg + 8);
       else if (arg[0] == '-')
         {
index 6c442037342b5b50f896e3bb27a3020ff0460f70..4ed4cc3e23871189fa951578cb4116807b3afd84 100644 (file)
@@ -33,7 +33,7 @@ SIGNATURE_CHECK (strsignal, char *, (int));
 /* In this case, we can guarantee some signal descriptions.
    But allow the actual result to be longer than the expected result.  */
 # define ASSERT_DESCRIPTION(actual, expected) \
-   ASSERT (strncmp (actual, expected, strlen (expected)) == 0)
+   ASSERT (str_startswith (actual, expected))
 #endif
 
 int