[BZ #3427]
[glibc.git] / iconvdata / tst-iconv4.c
blobe099ca87151d41d85b993b00c86ad02a06897eed
1 #include <errno.h>
2 #include <iconv.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
8 static int
9 do_test (void)
11 iconv_t cd = iconv_open ("ISO-8859-1", "UNICODE");
12 if (cd == (iconv_t) -1)
14 printf ("iconv_open failed: %m\n");
15 exit (EXIT_FAILURE);
18 char instr[] = "a";
19 char *inptr = instr;
20 size_t inlen = strlen (instr);
21 char buf[200];
22 char *outptr = buf;
23 size_t outlen = sizeof (outptr);
25 errno = 0;
26 size_t n = iconv (cd, &inptr, &inlen, &outptr, &outlen);
27 if (n != (size_t) -1)
29 printf ("n (= %zu) != (size_t) -1\n", n);
30 exit (EXIT_FAILURE);
32 if (errno != EINVAL)
34 printf ("errno = %m, not EINVAL\n");
35 exit (EXIT_FAILURE);
38 iconv_close (cd);
40 return 0;
43 #define TEST_FUNCTION do_test ()
44 #include "../test-skeleton.c"