Pass a valid pointer to pthread_setspecific to avoid GCC 11 warning.
[glibc.git] / iconv / tst-iconv3.c
blob625e4706c0f2283b4eecc19ab78138aad6283db0
1 /* Contributed by Owen Taylor <otaylor@redhat.com>. */
3 #include <iconv.h>
4 #include <errno.h>
5 #include <stddef.h>
6 #include <stdio.h>
8 #define BUFSIZE 10000
10 static int
11 do_test (void)
13 char inbuf[BUFSIZE];
14 wchar_t outbuf[BUFSIZE];
16 iconv_t cd;
17 int i;
18 char *inptr;
19 char *outptr;
20 size_t inbytes_left, outbytes_left;
21 int count;
22 int result = 0;
24 for (i=0; i < BUFSIZE; i++)
25 inbuf[i] = 'a';
27 cd = iconv_open ("UCS-4LE", "UTF-8");
29 inbytes_left = BUFSIZE;
30 outbytes_left = BUFSIZE * 4;
31 inptr = inbuf;
32 outptr = (char *) outbuf;
34 count = iconv (cd, &inptr, &inbytes_left, &outptr, &outbytes_left);
36 if (count < 0)
38 if (errno == E2BIG)
39 printf ("Received E2BIG\n");
40 else
41 printf ("Received something else\n");
43 printf ("inptr change: %td\n", inptr - inbuf);
44 printf ("inlen change: %zd\n", BUFSIZE - inbytes_left);
45 printf ("outptr change: %td\n", outptr - (char *) outbuf);
46 printf ("outlen change: %zd\n", BUFSIZE * 4 - outbytes_left);
47 result = 1;
49 else
50 printf ("Succeeded\n");
52 iconv_close (cd);
54 return result;
57 #define TEST_FUNCTION do_test ()
58 #include "../test-skeleton.c"