]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
stdcountof-h tests: Test more kinds of string literals.
authorBruno Haible <bruno@clisp.org>
Wed, 8 Oct 2025 12:12:51 +0000 (14:12 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 8 Oct 2025 12:13:21 +0000 (14:13 +0200)
* tests/test-stdcountof-h.c (test_func): Test also wide string literals
and Unicode string literals.

ChangeLog
tests/test-stdcountof-h.c

index 8714bd99dcd38f559920ff05b513a3d9a83e4aab..ec2d9651a5b2dfd98ab6d3b06c0d298688ce5933 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+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.
index 4965cf7bd7ee9207f61a1e8e3ac91abb29ba1465..77cfbc4dec4580355075e0dc3b9fcf8a26f5f557 100644 (file)
@@ -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
 }