aboutsummaryrefslogtreecommitdiff
path: root/iconvdata/tst-iconv7.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2008-01-09 20:03:58 +0000
committerUlrich Drepper <drepper@redhat.com>2008-01-09 20:03:58 +0000
commit4b1b449d1d4fda5658a3eb8378413aa224de0cf6 (patch)
tree9ab935ce8338639475e800500b66527d0ddfc03f /iconvdata/tst-iconv7.c
parent148e12ed122d75506937cdc8ab2654f8449f2061 (diff)
downloadglibc-4b1b449d1d4fda5658a3eb8378413aa224de0cf6.zip
glibc-4b1b449d1d4fda5658a3eb8378413aa224de0cf6.tar.gz
glibc-4b1b449d1d4fda5658a3eb8378413aa224de0cf6.tar.bz2
008-01-08 Jakub Jelinek <jakub@redhat.com>
* iconv/loop.c (UPDATE_PARAMS): Define to empty statement if not defined. (REINIT_PARAMS): Likewise. Undefine before end of file. (STANDARD_TO_LOOP_ERR_HANDLER): Use UPDATE_PARAMS before calling transliteration hooks and REINIT_PARAMS afterwards. * iconvdata/iso-2022-jp.c (BODY): Use a separate variable for status. (REINIT_PARAMS): Define. * iconvdata/ibm1364.c (REINIT_PARAMS): Likewise. * iconvdata/ibm930.c (REINIT_PARAMS): Likewise. * iconvdata/ibm933.c (REINIT_PARAMS): Likewise. * iconvdata/ibm935.c (REINIT_PARAMS): Likewise. * iconvdata/ibm937.c (REINIT_PARAMS): Likewise. * iconvdata/ibm939.c (REINIT_PARAMS): Likewise. * iconvdata/iso-2022-cn.c (REINIT_PARAMS): Likewise. * iconvdata/iso-2022-cn-ext.c (REINIT_PARAMS): Likewise. * iconvdata/iso-2022-jp-3.c (REINIT_PARAMS): Likewise. * iconvdata/iso-2022-kr.c (REINIT_PARAMS): Likewise. * iconvdata/Makefile: Add rules to build and run tst-iconv7.c. * iconvdata/tst-iconv7.c: New test.
Diffstat (limited to 'iconvdata/tst-iconv7.c')
-rw-r--r--iconvdata/tst-iconv7.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/iconvdata/tst-iconv7.c b/iconvdata/tst-iconv7.c
new file mode 100644
index 0000000..a01e3d8
--- /dev/null
+++ b/iconvdata/tst-iconv7.c
@@ -0,0 +1,61 @@
+#include <iconv.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static int
+do_test (void)
+{
+ setlocale (LC_ALL, "de_DE.UTF-8");
+
+ iconv_t cd = iconv_open ("ISO-2022-JP//TRANSLIT", "");
+ if (cd == (iconv_t) -1)
+ {
+ puts ("iconv_open failed");
+ return 1;
+ }
+
+ char instr1[] = "\xc2\xa3\xe2\x82\xac\n";
+ const char expstr1[] = "\033$B!r\033(BEUR\n";
+ char outstr[32];
+ size_t inlen = sizeof (instr1);
+ size_t outlen = sizeof (outstr);
+ char *inptr = instr1;
+ char *outptr = outstr;
+ size_t r = iconv (cd, &inptr, &inlen, &outptr, &outlen);
+ if (r != 1
+ || inlen != 0
+ || outlen != sizeof (outstr) - sizeof (expstr1)
+ || memcmp (outstr, expstr1, sizeof (expstr1)) != 0)
+ {
+ puts ("wrong first conversion");
+ return 1;
+ }
+
+ char instr2[] = "\xe3\x88\xb1\n";
+ const char expstr2[] = "(\033$B3t\033(B)\n";
+ inlen = sizeof (instr2);
+ outlen = sizeof (outstr);
+ inptr = instr2;
+ outptr = outstr;
+ r = iconv (cd, &inptr, &inlen, &outptr, &outlen);
+ if (r != 1
+ || inlen != 0
+ || outlen != sizeof (outstr) - sizeof (expstr2)
+ || memcmp (outstr, expstr2, sizeof (expstr2)) != 0)
+ {
+ puts ("wrong second conversion");
+ return 1;
+ }
+
+ if (iconv_close (cd) != 0)
+ {
+ puts ("iconv_close failed");
+ return 1;
+ }
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"