Consolidate off_t/off64_t syscall argument passing
[glibc.git] / iconv / tst-iconv4.c
blobb5ff39306c22c332abd11fa1d8e3aaccc5a3fbb8
1 // Derived from BZ #9793
2 #include <errno.h>
3 #include <iconv.h>
4 #include <stdio.h>
7 static int
8 do_test (void)
10 iconv_t cd = iconv_open ("ASCII//TRANSLIT", "UTF-8");
11 if (cd == (iconv_t) -1)
13 puts ("iconv_open failed");
14 return 1;
17 char input[2] = { 0xc2, 0xae }; /* Registered trademark */
18 char *inptr = input;
19 size_t insize = sizeof (input);
20 char output[2]; /* Too short to contain "(R)". */
21 char *outptr = output;
22 size_t outsize = sizeof (output);
24 size_t ret = iconv (cd, &inptr, &insize, &outptr, &outsize);
25 if (ret != (size_t) -1)
27 puts ("iconv succeeded");
28 return 1;
30 if (errno != E2BIG)
32 puts ("iconv did not set errno to E2BIG");
33 return 1;
35 int res = 0;
36 if (inptr != input)
38 puts ("inptr changed");
39 res = 1;
41 if (insize != sizeof (input))
43 puts ("insize changed");
44 res = 1;
46 if (outptr != output)
48 puts ("outptr changed");
49 res = 1;
51 if (outsize != sizeof (output))
53 puts ("outsize changed");
54 res = 1;
56 if (iconv_close (cd) == -1)
58 puts ("iconv_close failed");
59 res = 1;
61 return res;
64 #define TEST_FUNCTION do_test ()
65 #include "../test-skeleton.c"