1 #include <iconv.h>
2 #include <stdint.h>
3 #include <stdio.h>
4 
5 
6 static int
do_test(void)7 do_test (void)
8 {
9   iconv_t cd = iconv_open ("utf-8", "unicode");
10   if (cd == (iconv_t) -1)
11     {
12       puts ("cannot open iconv module");
13       return 1;
14     }
15 
16   static const uint16_t us[] = { 0xfeff, 0x0041, 0x0042, 0x0043 };
17   char buf[100];
18 
19   char *inbuf;
20   size_t inlen;
21   char *outbuf;
22   size_t outlen;
23   size_t n;
24 
25   inbuf = (char *) us;
26   inlen = sizeof (us);
27   outbuf = buf;
28   outlen = sizeof (buf);
29   n = iconv (cd, &inbuf, &inlen, &outbuf, &outlen);
30   if (n == (size_t) -1 || inlen != 0 || outlen != sizeof (buf) - 3)
31     {
32       puts ("first conversion failed");
33       return 1;
34     }
35 
36   iconv (cd, NULL, NULL, NULL, NULL);
37 
38   inbuf = (char *) us;
39   inlen = sizeof (us);
40   outbuf = buf;
41   outlen = sizeof (buf);
42   n = iconv (cd, &inbuf, &inlen, &outbuf, &outlen);
43   if (n == (size_t) -1 || inlen != 0 || outlen != sizeof (buf) - 3)
44     {
45       puts ("second conversion failed");
46       return 1;
47     }
48 
49   return 0;
50 }
51 
52 #define TEST_FUNCTION do_test ()
53 #include "../test-skeleton.c"
54