Wrapper around strtod.c to compile as strtof_l.
[glibc/history.git] / stdlib / testmb.c
blob117ade1a5b37e6ee707ffd5ca778bd99d8109f96
1 #include <stdio.h>
2 #include <stdlib.h>
4 int
5 main (int argc, char *argv[])
7 wchar_t w[10];
8 char c[10];
9 int i;
10 int lose = 0;
12 i = mbstowcs (w, "bar", 4);
13 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)
23 puts ("wcstombs FAILED!");
24 lose = 1;
27 if (mblen ("foobar", 7) != 1)
29 puts ("mblen 1 FAILED!");
30 lose = 1;
33 if (mblen ("", 1) != 0)
35 puts ("mblen 2 FAILED!");
36 lose = 1;
40 int r;
41 char c = 'x';
42 wchar_t wc;
43 char *mbc;
45 mbc = (char *) malloc (MB_CUR_MAX);
46 mbc[0] = c;
47 mbc[1] = '\0';
49 if ((r = mbtowc (&wc, &c, MB_CUR_MAX)) <= 0)
51 printf ("conversion to wide failed, result: %d\n", r);
52 lose = 1;
54 else
56 printf ("wide value: 0x%04lx\n", (unsigned long) wc);
57 mbc[0] = '\0';
58 if ((r = wctomb (mbc, wc)) <= 0)
60 printf ("conversion to multibyte failed, result: %d\n", r);
61 lose = 1;
67 puts (lose ? "Test FAILED!" : "Test succeeded.");
68 return lose;