Fix powerpc software sqrtf (bug 17967).
[glibc.git] / iconvdata / bug-iconv9.c
blob28f88d22e93277103bf7cec0bf5678d69761184b
1 // BZ 12814
2 #include <errno.h>
3 #include <iconv.h>
4 #include <stdio.h>
5 #include <string.h>
7 static int
8 do_test (void)
10 iconv_t h = iconv_open ("ISO-2022-JP-2", "UTF-8");
11 if (h == (iconv_t) -1)
13 printf ("cannot load iconv module: %m\n");
14 return 1;
17 // Euro sign
18 static const char inbuf[] = "\xe2\x82\xac";
19 char *in = (char *) inbuf;
20 size_t inlen = sizeof (inbuf) - 1;
22 char outbuf[100];
23 char *out = outbuf;
24 size_t outlen = sizeof (outbuf);
26 int res = 0;
27 size_t n = iconv (h, &in, &inlen, &out, &outlen);
28 if (n == (size_t) -1)
30 printf ("iconv failed with %d: %m\n", errno);
31 return 1;
33 if (n != 0)
35 printf ("iconv returned %zu, expected zero\n", n);
36 res = 1;
38 if (in != inbuf + sizeof (inbuf) - 1)
40 printf ("in advanced by %td, expected %zu\n",
41 in - inbuf, sizeof (inbuf) - 1);
42 res = 1;
44 static const char expected[] = "\x1b\x2e\x46\x1b\x4e\x24";
45 if (out - outbuf != sizeof (expected) - 1
46 || memcmp (outbuf, expected, sizeof (expected) - 1) != 0)
48 fputs ("generated sequence is: \"", stdout);
49 for (size_t i = 0; i < out - outbuf; ++i)
50 printf ("\\x%02hhx", outbuf[i]);
51 fputs ("\", expected \"", stdout);
52 for (size_t i = 0; i < sizeof (expected) - 1; ++i)
53 printf ("\\x%02hhx", expected[i]);
54 puts ("\"");
55 res = 1;
58 if (iconv_close (h) != 0)
60 puts ("failed closing iconv module");
61 res = 1;
64 return res;
67 #define TEST_FUNCTION do_test ()
68 #include "../test-skeleton.c"