]> Savannah Git Hosting - gnulib.git/commitdiff
tests: Use str_endswith.
authorBruno Haible <bruno@clisp.org>
Fri, 3 Jan 2025 09:43:15 +0000 (10:43 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 3 Jan 2025 09:43:15 +0000 (10:43 +0100)
* tests/test-canonicalize.c (main): Use str_endswith.
* tests/test-canonicalize-lgpl.c (main): Likewise.
* tests/test-setlocale-w32utf8.c (main): Likewise.
* modules/canonicalize-tests (Depends-on): Add str_endswith.
* modules/canonicalize-lgpl-tests (Depends-on): Likewise.
* modules/setlocale-tests (Depends-on): Likewise.

ChangeLog
modules/canonicalize-lgpl-tests
modules/canonicalize-tests
modules/setlocale-tests
tests/test-canonicalize-lgpl.c
tests/test-canonicalize.c
tests/test-setlocale-w32utf8.c

index b6a71b15e2356445405b527cfb48c6782fb0ccf6..300538b6825311e3acc1b2a9350a20017e5fd6bd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2025-01-03  Bruno Haible  <bruno@clisp.org>
 
+       tests: Use str_endswith.
+       * tests/test-canonicalize.c (main): Use str_endswith.
+       * tests/test-canonicalize-lgpl.c (main): Likewise.
+       * tests/test-setlocale-w32utf8.c (main): Likewise.
+       * modules/canonicalize-tests (Depends-on): Add str_endswith.
+       * modules/canonicalize-lgpl-tests (Depends-on): Likewise.
+       * modules/setlocale-tests (Depends-on): Likewise.
+
        gen-uni-tables, get-rusage-data, isatty: Use str_endswith.
        * lib/gen-uni-tables.c (fill_attributes): Use str_endswith.
        * lib/get-rusage-data.c (get_rusage_data_via_setrlimit): Likewise.
index 73a0e32abbbc7249a4d449f508f0c589e64b2493..d2b864842a830a90f3a1d30d8cbfb8dd4c54ba43 100644 (file)
@@ -8,6 +8,7 @@ Depends-on:
 ignore-value
 same-inode
 symlink
+str_endswith
 
 configure.ac:
 
index e043a8dacaccb882e0d4994193d536ed56b71ced..5984f665bbb7ade8d2afd35b69870388fd1f732a 100644 (file)
@@ -7,6 +7,7 @@ Depends-on:
 ignore-value
 same-inode
 symlink
+str_endswith
 
 configure.ac:
 
index 23cc6ddd17d97b66e323b1a9cc94f703db04f46a..bd85353d610febc324a7307ec09880bd55a6e753 100644 (file)
@@ -18,6 +18,7 @@ m4/windows-rc.m4
 
 Depends-on:
 strdup
+str_endswith
 test-xfail
 
 configure.ac:
index 2a4f5e2ecd03d66077871e03ec186d9547cfe469..5450bb9b149c91526729a5cbdfcc802b1fc24359 100644 (file)
@@ -178,8 +178,7 @@ main (void)
     ASSERT (result1 != NULL);
     ASSERT (result2 != NULL);
     ASSERT (strcmp (result1, result2) == 0);
-    ASSERT (strcmp (result1 + strlen (result1) - strlen ("/" BASE "/tra"),
-                    "/" BASE "/tra") == 0);
+    ASSERT (str_endswith (result1, "/" BASE "/tra"));
     free (result1);
     free (result2);
   }
@@ -194,8 +193,7 @@ main (void)
     ASSERT (result3 != NULL);
     ASSERT (strcmp (result1, result2) == 0);
     ASSERT (strcmp (result2, result3) == 0);
-    ASSERT (strcmp (result1 + strlen (result1) - strlen ("/" BASE "/lum"),
-                    "/" BASE "/lum") == 0);
+    ASSERT (str_endswith (result1, "/" BASE "/lum"));
     free (result1);
     free (result2);
     free (result3);
index 0f69f98714b4129427bda68e10e5e4ce4eaf8554..083bf1703ad479d94c0a0e7ea268e1dede27c46c 100644 (file)
@@ -204,8 +204,7 @@ main (void)
   {
     char *result1 = canonicalize_filename_mode (BASE "/huk", CAN_NOLINKS);
     ASSERT (result1 != NULL);
-    ASSERT (strcmp (result1 + strlen (result1) - strlen ("/" BASE "/huk"),
-                    "/" BASE "/huk") == 0);
+    ASSERT (str_endswith (result1, "/" BASE "/huk"));
     free (result1);
   }
 
@@ -219,8 +218,7 @@ main (void)
     ASSERT (result3 != NULL);
     ASSERT (strcmp (result1, result2) == 0);
     ASSERT (strcmp (result2, result3) == 0);
-    ASSERT (strcmp (result1 + strlen (result1) - strlen ("/" BASE "/tra"),
-                    "/" BASE "/tra") == 0);
+    ASSERT (str_endswith (result1, "/" BASE "/tra"));
     free (result1);
     free (result2);
     free (result3);
@@ -239,8 +237,7 @@ main (void)
     ASSERT (strcmp (result1, result2) == 0);
     ASSERT (strcmp (result2, result3) == 0);
     ASSERT (strcmp (result3, result4) == 0);
-    ASSERT (strcmp (result1 + strlen (result1) - strlen ("/" BASE "/lum"),
-                    "/" BASE "/lum") == 0);
+    ASSERT (str_endswith (result1, "/" BASE "/lum"));
     free (result1);
     free (result2);
     free (result3);
@@ -330,8 +327,7 @@ main (void)
     ASSERT (strcmp (result1, result2) == 0);
     ASSERT (strcmp (result2, result3) == 0);
     ASSERT (strcmp (result3, result4) == 0);
-    ASSERT (strcmp (result1 + strlen (result1) - strlen ("/" BASE "/zzz"),
-                    "/" BASE "/zzz") == 0);
+    ASSERT (str_endswith (result1, "/" BASE "/zzz"));
     free (result1);
     free (result2);
     free (result3);
@@ -351,8 +347,7 @@ main (void)
     ASSERT (strcmp (result1, result2) == 0);
     ASSERT (strcmp (result2, result3) == 0);
     ASSERT (strcmp (result3, result4) == 0);
-    ASSERT (strcmp (result1 + strlen (result1) - strlen ("/" BASE "/wum"),
-                    "/" BASE "/wum") == 0);
+    ASSERT (str_endswith (result1, "/" BASE "/wum"));
     free (result1);
     free (result2);
     free (result3);
@@ -365,7 +360,7 @@ main (void)
     char *result2 = canonicalize_filename_mode ("t-can.zzz/zzz", CAN_MISSING);
     ASSERT (result1 == NULL);
     ASSERT (result2 != NULL);
-    ASSERT (strcmp (result2 + strlen (result2) - 14, "/t-can.zzz/zzz") == 0);
+    ASSERT (str_endswith (result2, "/t-can.zzz/zzz"));
     free (result2);
   }
 
index 92156c7c01bf533b5dcdc6fccb6bcaa0456af072..51828db18e61283aa0527877272baa0331830f94 100644 (file)
@@ -41,7 +41,7 @@ main (void)
   /* With the legacy system settings, expect some mixed locale, due to the
      limitations of the native setlocale().
      With the modern system settings, expect some "ll_CC.UTF-8" name.  */
-  if (!((strlen (name) > 6 && strcmp (name + strlen (name) - 6, ".UTF-8") == 0)
+  if (!((strlen (name) > 6 && str_endswith (name, ".UTF-8"))
         || strcmp (name, "LC_COLLATE=English_United States.65001;"
                          "LC_CTYPE=English_United States.65001;"
                          "LC_MONETARY=English_United States.65001;"