Use round-to-nearest internally in jn, test with ALL_RM_TEST (bug 18602).
[glibc.git] / iconvdata / bug-iconv5.c
blob1b9f50f58af0ec207e73341344a9be00d27032a1
1 #include <iconv.h>
2 #include <stdint.h>
3 #include <stdio.h>
6 static int
7 do_test (void)
9 iconv_t cd = iconv_open ("utf-8", "unicode");
10 if (cd == (iconv_t) -1)
12 puts ("cannot open iconv module");
13 return 1;
16 static const uint16_t us[] = { 0xfeff, 0x0041, 0x0042, 0x0043 };
17 char buf[100];
19 char *inbuf;
20 size_t inlen;
21 char *outbuf;
22 size_t outlen;
23 size_t n;
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)
32 puts ("first conversion failed");
33 return 1;
36 iconv (cd, NULL, NULL, NULL, NULL);
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)
45 puts ("second conversion failed");
46 return 1;
49 return 0;
52 #define TEST_FUNCTION do_test ()
53 #include "../test-skeleton.c"