struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / escape.c
blobc2d3d14715d5a34bce784aa07635ecb9cf7917d7
1 /* Tests escape sequences
2 */
3 #include <testfwk.h>
5 #ifdef __SDCC
6 #pragma std_c11
7 #endif
9 #include <stddef.h> // For wchar_t
10 #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.
11 #include <uchar.h> // For char16_t, char32_t
12 #endif
14 void
15 testEscape(void)
17 volatile char c;
18 #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.
19 volatile char16_t u;
20 #endif
22 ASSERT ('\x55' == 0x55);
23 c = '\x55';
24 ASSERT (c == 0x55);
26 #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.
27 ASSERT (u'\777' == 0777);
28 u = u'\777';
29 ASSERT (u == 0777);
31 ASSERT (u'\x55aa' == 0x55aau);
32 u = u'\x55aa';
33 ASSERT (u == 0x55aau);
35 ASSERT (u'\u55aa' == 0x55aau);
36 u = u'\u55aa';
37 ASSERT (u == 0x55aau);
38 #endif