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.
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);
}
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);
{
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);
}
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);
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);
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);
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);
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);
}
/* 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;"