]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
savedir tests: Check the length of the file names.
authorCollin Funk <collin.funk1@gmail.com>
Sat, 18 Oct 2025 03:04:59 +0000 (20:04 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Sat, 18 Oct 2025 03:04:59 +0000 (20:04 -0700)
Suggested by Bruno Haible in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-10/msg00049.html>.

* tests/test-savedir.c (test_savedir_sort_none)
(test_savedir_sort_name): Check that the file names are only one
character long.

ChangeLog
tests/test-savedir.c

index c111b6214a71fb69dc294404aac832866873ef99..ebb923c842feed1d6528249aa202003d842edc99 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2025-10-17  Collin Funk  <collin.funk1@gmail.com>
 
+       savedir tests: Check the length of the file names.
+       Suggested by Bruno Haible in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2025-10/msg00049.html>.
+       * tests/test-savedir.c (test_savedir_sort_none)
+       (test_savedir_sort_name): Check that the file names are only one
+       character long.
+
        savedir: Add tests.
        * tests/test-savedir.c: New file.
        * modules/savedir-tests: Likewise.
index 5b7e8401eee3257cd3afb2f5cdfc1566558a7cb5..1e58e8beafc8566ce1612435e1ab2c96fb438528 100644 (file)
@@ -47,6 +47,7 @@ test_savedir_sort_none (void)
   for (char *namep = name_space; *namep != '\0'; namep += strlen (namep) + 1)
     {
       int index = *namep - 'a';
+      ASSERT (strlen (namep) == 1);
       ASSERT (index < sizeof seen);
       seen[index] = true;
     }
@@ -68,7 +69,10 @@ test_savedir_sort_name (void)
   /* Check that files "a" to "z" appear in order.  */
   for (char *namep = name_space; *namep != '\0';
        namep += strlen (namep) + 1, i += 1)
-    ASSERT (*namep - 'a' == i);
+    {
+      ASSERT (strlen (namep) == 1);
+      ASSERT (*namep - 'a' == i);
+    }
 
   /* Make sure no extra files were seen.  */
   ASSERT (i == ('z' - 'a') + 1);