]> git.ipfire.org Git - thirdparty/glibc.git/blame - iconv/tst-iconv3.c
alloc_buffer: Return unqualified pointer type in alloc_buffer_next
[thirdparty/glibc.git] / iconv / tst-iconv3.c
CommitLineData
ec28fc7c
UD
1/* Contributed by Owen Taylor <otaylor@redhat.com>. */
2
3#include <iconv.h>
4#include <errno.h>
1bc83d2b 5#include <stddef.h>
ec28fc7c
UD
6#include <stdio.h>
7
8#define BUFSIZE 10000
9
ca681b7b
RM
10static int
11do_test (void)
ec28fc7c
UD
12{
13 char inbuf[BUFSIZE];
14 wchar_t outbuf[BUFSIZE];
15
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;
23
24 for (i=0; i < BUFSIZE; i++)
25 inbuf[i] = 'a';
26
27 cd = iconv_open ("UCS-4LE", "UTF-8");
28
29 inbytes_left = BUFSIZE;
30 outbytes_left = BUFSIZE * 4;
31 inptr = inbuf;
32 outptr = (char *) outbuf;
33
34 count = iconv (cd, &inptr, &inbytes_left, &outptr, &outbytes_left);
35
36 if (count < 0)
37 {
38 if (errno == E2BIG)
39 printf ("Received E2BIG\n");
40 else
41 printf ("Received something else\n");
42
43 printf ("inptr change: %td\n", inptr - inbuf);
8430ab40 44 printf ("inlen change: %zd\n", BUFSIZE - inbytes_left);
d347a4ab 45 printf ("outptr change: %td\n", outptr - (char *) outbuf);
8430ab40 46 printf ("outlen change: %zd\n", BUFSIZE * 4 - outbytes_left);
ec28fc7c
UD
47 result = 1;
48 }
49 else
50 printf ("Succeeded\n");
51
52 return result;
53}
ca681b7b
RM
54
55#define TEST_FUNCTION do_test ()
56#include "../test-skeleton.c"