]> sourceware.org Git - glibc.git/blame - iconv/tst-iconv4.c
hppa: Update libm-test-ulps
[glibc.git] / iconv / tst-iconv4.c
CommitLineData
1b14353e
UD
1// Derived from BZ #9793
2#include <errno.h>
3#include <iconv.h>
4#include <stdio.h>
5
6
7static int
8do_test (void)
9{
10 iconv_t cd = iconv_open ("ASCII//TRANSLIT", "UTF-8");
11 if (cd == (iconv_t) -1)
12 {
13 puts ("iconv_open failed");
14 return 1;
15 }
16
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);
23
24 size_t ret = iconv (cd, &inptr, &insize, &outptr, &outsize);
25 if (ret != (size_t) -1)
26 {
27 puts ("iconv succeeded");
28 return 1;
29 }
30 if (errno != E2BIG)
31 {
32 puts ("iconv did not set errno to E2BIG");
33 return 1;
34 }
35 int res = 0;
36 if (inptr != input)
37 {
38 puts ("inptr changed");
39 res = 1;
40 }
41 if (insize != sizeof (input))
42 {
43 puts ("insize changed");
44 res = 1;
45 }
46 if (outptr != output)
47 {
48 puts ("outptr changed");
49 res = 1;
50 }
51 if (outsize != sizeof (output))
52 {
53 puts ("outsize changed");
54 res = 1;
55 }
56 if (iconv_close (cd) == -1)
57 {
58 puts ("iconv_close failed");
59 res = 1;
60 }
61 return res;
62}
63
64#define TEST_FUNCTION do_test ()
65#include "../test-skeleton.c"
This page took 0.317788 seconds and 6 git commands to generate.