]> Savannah Git Hosting - gnulib.git/commitdiff
tests: Refactor.
authorBruno Haible <bruno@clisp.org>
Sat, 25 May 2024 09:46:11 +0000 (11:46 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 25 May 2024 10:03:09 +0000 (12:03 +0200)
* tests/test-inttostr.c (main): Report SKIP in the 'if' branch.
* tests/test-quotearg.c (main): Likewise.

ChangeLog
tests/test-inttostr.c
tests/test-quotearg.c

index ba2fe6dbb1ebc65d80c92fb750e8205e7d864858..e0daa9c7057aa5e8c75fc408f8101b04cd189cdb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-05-25  Bruno Haible  <bruno@clisp.org>
+
+       tests: Refactor.
+       * tests/test-inttostr.c (main): Report SKIP in the 'if' branch.
+       * tests/test-quotearg.c (main): Likewise.
+
 2024-05-25  Bruno Haible  <bruno@clisp.org>
 
        tests: Before declaring a SKIP, test if there were ASSERT failures.
index e7632cb736eba25495d9a04842b83b4a9dd603c3..e85025ed9ebbf3ec0de776c716ea8cae9791d4fe 100644 (file)
@@ -76,19 +76,20 @@ main (void)
   /* Ideally we would rely on the snprintf-posix module, in which case
      this guard would not be required, but due to limitations in gnulib's
      implementation (see modules/snprintf-posix), we cannot.  */
-  if (snprintf (b, b_size, "%ju", (uintmax_t) 3) == 1
-      && b[0] == '3' && b[1] == '\0')
+  if (!(snprintf (b, b_size, "%ju", (uintmax_t) 3) == 1
+        && b[0] == '3' && b[1] == '\0'))
     {
-      CK (int,          inttostr);
-      CK (unsigned int, uinttostr);
-      CK (off_t,        offtostr);
-      CK (uintmax_t,    umaxtostr);
-      CK (intmax_t,     imaxtostr);
+      /* snprintf doesn't accept %ju; skip this test.  */
       free (b);
-      return test_exit_status;
+      fputs ("Skipping test: %ju format directive not supported\n", stderr);
+      return 77;
     }
 
-  /* snprintf doesn't accept %ju; skip this test.  */
+  CK (int,          inttostr);
+  CK (unsigned int, uinttostr);
+  CK (off_t,        offtostr);
+  CK (uintmax_t,    umaxtostr);
+  CK (intmax_t,     imaxtostr);
   free (b);
-  return 77;
+  return test_exit_status;
 }
index d454b5acd8d2519934318db52720e4f1201ace75..0283f1ca1c246c358a4a7038947fa64ad1be4f4d 100644 (file)
@@ -75,30 +75,30 @@ main (_GL_UNUSED int argc, char *argv[])
   {
     const char *locale_name = getenv ("LOCALE");
 
-    if (locale_name != NULL && strcmp (locale_name, "none") != 0
-        && setenv ("LC_ALL", locale_name, 1) == 0
-        && setlocale (LC_ALL, "") != NULL)
+    if (!(locale_name != NULL && strcmp (locale_name, "none") != 0
+          && setenv ("LC_ALL", locale_name, 1) == 0
+          && setlocale (LC_ALL, "") != NULL))
       {
-        textdomain ("test-quotearg");
-        bindtextdomain ("test-quotearg", getenv ("LOCALEDIR"));
+        fputs ("Skipping test: no french Unicode locale is installed\n", stderr);
+        return 77;
+      }
+    textdomain ("test-quotearg");
+    bindtextdomain ("test-quotearg", getenv ("LOCALEDIR"));
 
-        set_quoting_style (NULL, locale_quoting_style);
-        compare_strings (use_quotearg_buffer, &locale_results[0].group1, false);
-        compare_strings (use_quotearg, &locale_results[0].group2, false);
-        compare_strings (use_quotearg_colon, &locale_results[0].group3, false);
+    set_quoting_style (NULL, locale_quoting_style);
+    compare_strings (use_quotearg_buffer, &locale_results[0].group1, false);
+    compare_strings (use_quotearg, &locale_results[0].group2, false);
+    compare_strings (use_quotearg_colon, &locale_results[0].group3, false);
 
-        set_quoting_style (NULL, clocale_quoting_style);
-        compare_strings (use_quotearg_buffer, &locale_results[1].group1, false);
-        compare_strings (use_quotearg, &locale_results[1].group2, false);
-        compare_strings (use_quotearg_colon, &locale_results[1].group3, false);
+    set_quoting_style (NULL, clocale_quoting_style);
+    compare_strings (use_quotearg_buffer, &locale_results[1].group1, false);
+    compare_strings (use_quotearg, &locale_results[1].group2, false);
+    compare_strings (use_quotearg_colon, &locale_results[1].group3, false);
 
-        quotearg_free ();
-        return test_exit_status;
-      }
+    quotearg_free ();
+    return test_exit_status;
   }
 
-  fputs ("Skipping test: no french Unicode locale is installed\n", stderr);
-  return 77;
 #else
   fputs ("Skipping test: internationalization is disabled\n", stderr);
   return 77;