From: Bruno Haible Date: Wed, 8 Oct 2025 12:12:51 +0000 (+0200) Subject: stdcountof-h tests: Test more kinds of string literals. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b46a2818376613dc33cf89820c359379d3758cf;p=thirdparty%2Fgnulib.git stdcountof-h tests: Test more kinds of string literals. * tests/test-stdcountof-h.c (test_func): Test also wide string literals and Unicode string literals. --- diff --git a/ChangeLog b/ChangeLog index 8714bd99dc..ec2d9651a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2025-10-08 Bruno Haible + + stdcountof-h tests: Test more kinds of string literals. + * tests/test-stdcountof-h.c (test_func): Test also wide string literals + and Unicode string literals. + 2025-10-08 Alejandro Colomar stdcountof-h tests: Test a string literal. diff --git a/tests/test-stdcountof-h.c b/tests/test-stdcountof-h.c index 4965cf7bd7..77cfbc4dec 100644 --- a/tests/test-stdcountof-h.c +++ b/tests/test-stdcountof-h.c @@ -47,12 +47,24 @@ test_func (int parameter[3]) (void) _gl_verify_is_array (bounded); (void) _gl_verify_is_array (multidimensional); (void) _gl_verify_is_array ("string"); + (void) _gl_verify_is_array (L"wide string"); +# if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L + (void) _gl_verify_is_array (u8"UTF-8 string"); + (void) _gl_verify_is_array (u"UTF-16 string"); + (void) _gl_verify_is_array (U"UTF-32 string"); +# endif #endif ASSERT (countof (bounded) == 10); ASSERT (countof (multidimensional) == 10); ASSERT (countof (local_bounded) == 20); ASSERT (countof ("string") == 6 + 1); + ASSERT (countof (L"wide string") == 11 + 1); +#if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L + ASSERT (countof (u8"UTF-8 string") == 12 + 1); + ASSERT (countof (u"UTF-16 string") == 13 + 1); + ASSERT (countof (U"UTF-32 string") == 13 + 1); +#endif #if 0 /* These produce compilation errors. */ # ifdef _gl_verify_is_array @@ -75,6 +87,12 @@ test_func (int parameter[3]) ASSERT (_Generic (countof (multidimensional), size_t: 1, default: 0)); ASSERT (_Generic (countof (local_bounded), size_t: 1, default: 0)); ASSERT (_Generic (countof ("string"), size_t: 1, default: 0)); + ASSERT (_Generic (countof (L"wide string"), size_t: 1, default: 0)); +# if __STDC_VERSION__ >= 201112L + ASSERT (_Generic (countof (u8"UTF-8 string"), size_t: 1, default: 0)); + ASSERT (_Generic (countof (u"UTF-16 string"), size_t: 1, default: 0)); + ASSERT (_Generic (countof (U"UTF-32 string"), size_t: 1, default: 0)); +# endif #endif }