]>
Commit | Line | Data |
---|---|---|
ec28fc7c UD |
1 | |
2 | #include <iconv.h> | |
3 | #include <errno.h> | |
1bc83d2b | 4 | #include <stddef.h> |
ec28fc7c UD |
5 | #include <stdio.h> |
6 | ||
7 | #define BUFSIZE 10000 | |
8 | ||
ca681b7b RM |
9 | static int |
10 | do_test (void) | |
ec28fc7c UD |
11 | { |
12 | char inbuf[BUFSIZE]; | |
13 | wchar_t outbuf[BUFSIZE]; | |
14 | ||
15 | iconv_t cd; | |
16 | int i; | |
17 | char *inptr; | |
18 | char *outptr; | |
19 | size_t inbytes_left, outbytes_left; | |
20 | int count; | |
21 | int result = 0; | |
22 | ||
23 | for (i=0; i < BUFSIZE; i++) | |
24 | inbuf[i] = 'a'; | |
25 | ||
26 | cd = iconv_open ("UCS-4LE", "UTF-8"); | |
27 | ||
28 | inbytes_left = BUFSIZE; | |
29 | outbytes_left = BUFSIZE * 4; | |
30 | inptr = inbuf; | |
31 | outptr = (char *) outbuf; | |
32 | ||
33 | count = iconv (cd, &inptr, &inbytes_left, &outptr, &outbytes_left); | |
34 | ||
35 | if (count < 0) | |
36 | { | |
37 | if (errno == E2BIG) | |
38 | printf ("Received E2BIG\n"); | |
39 | else | |
40 | printf ("Received something else\n"); | |
41 | ||
42 | printf ("inptr change: %td\n", inptr - inbuf); | |
8430ab40 | 43 | printf ("inlen change: %zd\n", BUFSIZE - inbytes_left); |
d347a4ab | 44 | printf ("outptr change: %td\n", outptr - (char *) outbuf); |
8430ab40 | 45 | printf ("outlen change: %zd\n", BUFSIZE * 4 - outbytes_left); |
ec28fc7c UD |
46 | result = 1; |
47 | } | |
48 | else | |
49 | printf ("Succeeded\n"); | |
50 | ||
d4eb8140 | 51 | iconv_close (cd); |
52 | ||
ec28fc7c UD |
53 | return result; |
54 | } | |
ca681b7b RM |
55 | |
56 | #define TEST_FUNCTION do_test () | |
57 | #include "../test-skeleton.c" |