headers/bsd: Add sys/queue.h.
[haiku.git] / src / tests / system / libroot / posix / testmb.c
blob297373b945c5624d3831fd06d4d6ce6a41a73a5e
1 #include <stdio.h>
2 #include <stdlib.h>
5 int
6 main(int argc, char *argv[])
8 wchar_t w[10];
9 char c[10];
10 int i;
11 int lose = 0;
13 i = mbstowcs(w, "bar", 4);
14 if (!(i == 3 && w[1] == 'a')) {
15 puts("mbstowcs FAILED!");
16 lose = 1;
19 mbstowcs(w, "blah", 5);
20 i = wcstombs(c, w, 10);
21 if (i != 4) {
22 puts("wcstombs FAILED!");
23 lose = 1;
26 if (mblen("foobar", 7) != 1) {
27 puts("mblen 1 FAILED!");
28 lose = 1;
31 if (mblen("", 1) != 0) {
32 puts("mblen 2 FAILED!");
33 lose = 1;
37 int r;
38 char c = 'x';
39 wchar_t wc;
40 char mbc[MB_CUR_MAX];
42 if ((r = mbtowc(&wc, &c, MB_CUR_MAX)) <= 0) {
43 printf("conversion to wide failed, result: %d\n", r);
44 lose = 1;
45 } else {
46 printf("wide value: 0x%04lx\n", (unsigned long) wc);
47 mbc[0] = '\0';
48 if ((r = wctomb(mbc, wc)) <= 0) {
49 printf("conversion to multibyte failed, result: %d\n", r);
50 lose = 1;
56 puts(lose ? "Test FAILED!" : "Test succeeded.");
57 return lose;