Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / charconst.c
blob5431c0820a3184cf2a79d301717007884bbd6056
1 /* Tests character constants.
2 */
3 #include <testfwk.h>
5 #ifdef __SDCC
6 #pragma std_c11
7 #endif
9 #include <stddef.h> // For wchar_t
11 #if defined(__SDCC) || defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__APPLE__) && !defined(__OpenBSD__) // As of 2023, macOS and OpenBSD are still not fully C11-compliant: they lack uchar.h.
12 #include <uchar.h> // For char16_t, char32_t
14 char16_t uc = u'c';
15 char32_t Uc = U'c';
16 #endif
18 char c = 'c';
19 wchar_t wc = L'c';
21 void
22 testCharConst(void)
24 #if defined(__SDCC) || defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
25 ASSERT (_Generic('c', default: 1, int: 0) == 0);
26 ASSERT (_Generic(L'c', default: 1, wchar_t: 0) == 0);
27 #if !defined(__APPLE__) && !defined(__OpenBSD__) // As of 2023, macOS and OpenBSD are still not C11-compliant: they lack uchar.h.
28 ASSERT (_Generic(u'c', default: 1, char16_t: 0) == 0);
29 ASSERT (_Generic(U'c', default: 1, char32_t: 0) == 0);
30 #endif
31 #endif