Manual typos: Library Maintenance
[glibc.git] / iconvdata / tst-iconv7.c
bloba01e3d8425dd0c3c41cf0d94c8b8a18bf6833985
1 #include <iconv.h>
2 #include <locale.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
7 static int
8 do_test (void)
10 setlocale (LC_ALL, "de_DE.UTF-8");
12 iconv_t cd = iconv_open ("ISO-2022-JP//TRANSLIT", "");
13 if (cd == (iconv_t) -1)
15 puts ("iconv_open failed");
16 return 1;
19 char instr1[] = "\xc2\xa3\xe2\x82\xac\n";
20 const char expstr1[] = "\033$B!r\033(BEUR\n";
21 char outstr[32];
22 size_t inlen = sizeof (instr1);
23 size_t outlen = sizeof (outstr);
24 char *inptr = instr1;
25 char *outptr = outstr;
26 size_t r = iconv (cd, &inptr, &inlen, &outptr, &outlen);
27 if (r != 1
28 || inlen != 0
29 || outlen != sizeof (outstr) - sizeof (expstr1)
30 || memcmp (outstr, expstr1, sizeof (expstr1)) != 0)
32 puts ("wrong first conversion");
33 return 1;
36 char instr2[] = "\xe3\x88\xb1\n";
37 const char expstr2[] = "(\033$B3t\033(B)\n";
38 inlen = sizeof (instr2);
39 outlen = sizeof (outstr);
40 inptr = instr2;
41 outptr = outstr;
42 r = iconv (cd, &inptr, &inlen, &outptr, &outlen);
43 if (r != 1
44 || inlen != 0
45 || outlen != sizeof (outstr) - sizeof (expstr2)
46 || memcmp (outstr, expstr2, sizeof (expstr2)) != 0)
48 puts ("wrong second conversion");
49 return 1;
52 if (iconv_close (cd) != 0)
54 puts ("iconv_close failed");
55 return 1;
57 return 0;
60 #define TEST_FUNCTION do_test ()
61 #include "../test-skeleton.c"