diff options
author | Bruno Haible <bruno@clisp.org> | 2023-03-27 12:30:46 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2023-03-27 12:30:46 +0200 |
commit | 0569f76e2f67cba9a565c59486aac0dbebb9ac9a (patch) | |
tree | 8b61daec4818e6a629b977e461201d018d43502c /tests | |
parent | 55a1207abc196655b9ef7c34b3cb7d736e6e7fe7 (diff) | |
download | gnulib-0569f76e2f67cba9a565c59486aac0dbebb9ac9a.tar.gz |
uchar: ISO C 23: Define char8_t.
* lib/uchar.in.h (char8_t): New type or macro.
* m4/uchar_h.m4 (gl_TYPE_CHAR8_T): New macro.
(gl_UCHAR_H): Invoke it. Set CXX_HAS_CHAR8_TYPE.
* modules/uchar (Makefile.am): Substitute CXX_HAS_CHAR8_TYPE,
GNULIBHEADERS_OVERRIDE_CHAR8_T.
* tests/test-uchar.c: Add tests for char8_t.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-uchar.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/test-uchar.c b/tests/test-uchar.c index 0d5b7d77eb..38c5f2538e 100644 --- a/tests/test-uchar.c +++ b/tests/test-uchar.c @@ -23,15 +23,23 @@ /* Check that the types are defined. */ mbstate_t a = { 0 }; size_t b = 5; -char16_t c = 'x'; -char32_t d = 'y'; +char8_t c = 'x'; +char16_t d = 'y'; +char32_t e = 'z'; -/* Check that char16_t and char32_t are unsigned types. */ +/* Check that char8_t, char16_t, and char32_t are unsigned types. */ +static_assert ((char8_t)(-1) >= 0); static_assert ((char16_t)(-1) >= 0); #if !defined __HP_cc static_assert ((char32_t)(-1) >= 0); #endif +/* Check that char8_t is at least 8 bits wide. */ +static_assert ((char8_t)0xFF != (char8_t)0x7F); + +/* Check that char16_t is at least 16 bits wide. */ +static_assert ((char16_t)0xFFFF != (char16_t)0x7FFF); + /* Check that char32_t is at least 31 bits wide. */ static_assert ((char32_t)0x7FFFFFFF != (char32_t)0x3FFFFFFF); |