From: Bruno Haible Date: Sat, 25 May 2024 09:46:11 +0000 (+0200) Subject: tests: Refactor. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=44bfb9fa38a518afadd8dcc4647386c3bb63645d;p=gnulib.git tests: Refactor. * tests/test-inttostr.c (main): Report SKIP in the 'if' branch. * tests/test-quotearg.c (main): Likewise. --- diff --git a/ChangeLog b/ChangeLog index ba2fe6dbb1..e0daa9c705 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-05-25 Bruno Haible + + tests: Refactor. + * tests/test-inttostr.c (main): Report SKIP in the 'if' branch. + * tests/test-quotearg.c (main): Likewise. + 2024-05-25 Bruno Haible tests: Before declaring a SKIP, test if there were ASSERT failures. diff --git a/tests/test-inttostr.c b/tests/test-inttostr.c index e7632cb736..e85025ed9e 100644 --- a/tests/test-inttostr.c +++ b/tests/test-inttostr.c @@ -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; } diff --git a/tests/test-quotearg.c b/tests/test-quotearg.c index d454b5acd8..0283f1ca1c 100644 --- a/tests/test-quotearg.c +++ b/tests/test-quotearg.c @@ -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;