1 /* Tests new wide character conversion functions.
7 #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.
16 #if !(defined (__SDCC_mcs51) && defined (__SDCC_MODEL_SMALL)) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Not enough memory
17 char mb_buffer
[BUF_MAX
+ 1];
18 char16_t c16_buffer
[BUF_MAX
+ 1];
20 ASSERT(__c16stombs(mb_buffer
, u
"teststring", BUF_MAX
) == strlen("teststring"));
22 ASSERT(!strcmp(mb_buffer
, "teststring"));
24 ASSERT(__mbstoc16s(c16_buffer
, "teststring2", BUF_MAX
) == strlen("teststring2"));
26 ASSERT(!memcmp (c16_buffer
, u
"teststring2", 12 * 2));
28 ASSERT(__c16stombs(mb_buffer
, c16_buffer
, BUF_MAX
) == strlen("teststring2"));
30 ASSERT(!strcmp(mb_buffer
, "teststring2"));
32 __c16stombs(mb_buffer
, u
"Größere Körbe kosten 10 € mehr", BUF_MAX
);
33 ASSERT(!strcmp(mb_buffer
, "Größere Körbe kosten 10 € mehr"));
35 __mbstoc16s(c16_buffer
, "Größere Körbe kosten 12 € mehr", BUF_MAX
);
37 ASSERT(!memcmp (c16_buffer
, u
"Größere Körbe kosten 12 € mehr", 20 * 2));
39 __c16stombs(mb_buffer
, c16_buffer
, BUF_MAX
);
41 ASSERT(!strcmp(mb_buffer
, "Größere Körbe kosten 12 € mehr"));