From 2c50de95f283a92003b0ce008cc3ce895b2c9f3c Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 23 Feb 2024 13:07:48 +0100 Subject: [PATCH] unistdio/*printf tests: Update expected test results regarding %n. * tests/unistdio/test-u8-printf1.h (test_xfunction): If NEED_PRINTF_WITH_N_DIRECTIVE is not defined, expect a NULL result in the %n test. * tests/unistdio/test-u16-printf1.h (test_xfunction): Likewise. * tests/unistdio/test-u32-printf1.h (test_xfunction): Likewise. * tests/unistdio/test-ulc-printf1.h (test_xfunction): Likewise. --- ChangeLog | 10 ++++++++++ tests/unistdio/test-u16-printf1.h | 4 ++++ tests/unistdio/test-u32-printf1.h | 4 ++++ tests/unistdio/test-u8-printf1.h | 4 ++++ tests/unistdio/test-ulc-printf1.h | 4 ++++ 5 files changed, 26 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2bd61f3052..1049bc0a91 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2024-02-23 Bruno Haible + + unistdio/*printf tests: Update expected test results regarding %n. + * tests/unistdio/test-u8-printf1.h (test_xfunction): If + NEED_PRINTF_WITH_N_DIRECTIVE is not defined, expect a NULL result in the + %n test. + * tests/unistdio/test-u16-printf1.h (test_xfunction): Likewise. + * tests/unistdio/test-u32-printf1.h (test_xfunction): Likewise. + * tests/unistdio/test-ulc-printf1.h (test_xfunction): Likewise. + 2024-02-22 Collin Funk gnulib-tool.py: Follow gnulib-tool changes, part 26. diff --git a/tests/unistdio/test-u16-printf1.h b/tests/unistdio/test-u16-printf1.h index 72655e7202..e501c9e462 100644 --- a/tests/unistdio/test-u16-printf1.h +++ b/tests/unistdio/test-u16-printf1.h @@ -1032,12 +1032,16 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) int count = -1; uint16_t *result = my_xasprintf ("%d %n", 123, &count, 33, 44, 55); +#if NEED_PRINTF_WITH_N_DIRECTIVE static const uint16_t expected[] = { '1', '2', '3', ' ', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); ASSERT (count == 4); free (result); +#else + ASSERT (result == NULL); +#endif } /* Test the support of the POSIX/XSI format strings with positions. */ diff --git a/tests/unistdio/test-u32-printf1.h b/tests/unistdio/test-u32-printf1.h index 0cebba2819..ae0edc6a63 100644 --- a/tests/unistdio/test-u32-printf1.h +++ b/tests/unistdio/test-u32-printf1.h @@ -1032,12 +1032,16 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) int count = -1; uint32_t *result = my_xasprintf ("%d %n", 123, &count, 33, 44, 55); +#if NEED_PRINTF_WITH_N_DIRECTIVE static const uint32_t expected[] = { '1', '2', '3', ' ', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); ASSERT (count == 4); free (result); +#else + ASSERT (result == NULL); +#endif } /* Test the support of the POSIX/XSI format strings with positions. */ diff --git a/tests/unistdio/test-u8-printf1.h b/tests/unistdio/test-u8-printf1.h index 2b762737f1..3e8999b638 100644 --- a/tests/unistdio/test-u8-printf1.h +++ b/tests/unistdio/test-u8-printf1.h @@ -786,11 +786,15 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) int count = -1; uint8_t *result = my_xasprintf ("%d %n", 123, &count, 33, 44, 55); +#if NEED_PRINTF_WITH_N_DIRECTIVE static const uint8_t expected[] = "123 "; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); ASSERT (count == 4); free (result); +#else + ASSERT (result == NULL); +#endif } /* Test the support of the POSIX/XSI format strings with positions. */ diff --git a/tests/unistdio/test-ulc-printf1.h b/tests/unistdio/test-ulc-printf1.h index 7617185a08..49089c1bfd 100644 --- a/tests/unistdio/test-ulc-printf1.h +++ b/tests/unistdio/test-ulc-printf1.h @@ -670,10 +670,14 @@ test_xfunction (char * (*my_xasprintf) (const char *, ...)) int count = -1; char *result = my_xasprintf ("%d %n", 123, &count, 33, 44, 55); +#if NEED_PRINTF_WITH_N_DIRECTIVE ASSERT (result != NULL); ASSERT (strcmp (result, "123 ") == 0); ASSERT (count == 4); free (result); +#else + ASSERT (result == NULL); +#endif } /* Test the support of the POSIX/XSI format strings with positions. */ -- 2.39.5