+2025-10-08 Bruno Haible <bruno@clisp.org>
+
+ 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 <alx@kernel.org>
stdcountof-h tests: Test a string literal.
(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
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
}