| 1 |
/* Test of <uchar.h> substitute. |
| 2 |
Copyright (C) 2019-2025 Free Software Foundation, Inc. |
| 3 |
|
| 4 |
This program is free software: you can redistribute it and/or modify |
| 5 |
it under the terms of the GNU General Public License as published by |
| 6 |
the Free Software Foundation, either version 3 of the License, or |
| 7 |
(at your option) any later version. |
| 8 |
|
| 9 |
This program is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public License |
| 15 |
along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
| 16 |
|
| 17 |
/* Written by Bruno Haible <[email protected]>, 2019. */ |
| 18 |
|
| 19 |
#include <config.h> |
| 20 |
|
| 21 |
#include <uchar.h> |
| 22 |
|
| 23 |
/* Check that the types are defined. */ |
| 24 |
mbstate_t a = { 0 }; |
| 25 |
size_t b = 5; |
| 26 |
char8_t c = 'x'; |
| 27 |
char16_t d = 'y'; |
| 28 |
char32_t e = 'z'; |
| 29 |
|
| 30 |
/* Check that char8_t, char16_t, and char32_t are unsigned types. */ |
| 31 |
static_assert ((char8_t)(-1) >= 0); |
| 32 |
static_assert ((char16_t)(-1) >= 0); |
| 33 |
#if !defined __HP_cc |
| 34 |
static_assert ((char32_t)(-1) >= 0); |
| 35 |
#endif |
| 36 |
|
| 37 |
/* Check that char8_t is at least 8 bits wide. */ |
| 38 |
static_assert ((char8_t)0xFF != (char8_t)0x7F); |
| 39 |
|
| 40 |
/* Check that char16_t is at least 16 bits wide. */ |
| 41 |
static_assert ((char16_t)0xFFFF != (char16_t)0x7FFF); |
| 42 |
|
| 43 |
/* Check that char32_t is at least 31 bits wide. */ |
| 44 |
static_assert ((char32_t)0x7FFFFFFF != (char32_t)0x3FFFFFFF); |
| 45 |
|
| 46 |
/* Check that _GL_SMALL_WCHAR_T is correctly defined. */ |
| 47 |
#if _GL_SMALL_WCHAR_T |
| 48 |
static_assert (sizeof (wchar_t) < sizeof (char32_t)); |
| 49 |
#else |
| 50 |
static_assert (sizeof (wchar_t) == sizeof (char32_t)); |
| 51 |
#endif |
| 52 |
|
| 53 |
int |
| 54 |
main (void) |
| 55 |
{ |
| 56 |
return 0; |
| 57 |
} |