summaryrefslogtreecommitdiffstats
path: root/contrib/idn/idnkit-1.0-src/lib/tests
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/idn/idnkit-1.0-src/lib/tests')
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/Makefile.in304
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/api-init1.tsy113
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/api-init2.tsy113
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/api-init3.tsy117
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/api-init4-1.tsy96
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/api-init4-2.tsy96
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/api-init4-3.tsy102
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/api-init5-1.tsy102
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/api-init5-2.tsy102
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/api-init5-3.tsy109
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/api.tsy1009
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/checker.tsy610
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/codeset.h71
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/converter.tsy822
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/delimitermap.tsy257
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/iconvchk.c132
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/mapper.tsy497
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/mapselector.tsy592
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/nameprep.tsy340
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/normalizer.tsy346
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/res.tsy1026
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/resconf.tsy1026
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/setenv.c134
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/setenv.h61
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/testsuite.c578
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/testsuite.h276
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/testutil.c83
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/testutil.h71
-rwxr-xr-xcontrib/idn/idnkit-1.0-src/lib/tests/testygen557
-rw-r--r--contrib/idn/idnkit-1.0-src/lib/tests/ucs4.tsy257
-rwxr-xr-xcontrib/idn/idnkit-1.0-src/lib/tests/utffilter82
31 files changed, 10081 insertions, 0 deletions
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/Makefile.in b/contrib/idn/idnkit-1.0-src/lib/tests/Makefile.in
new file mode 100644
index 0000000..124ccec
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/Makefile.in
@@ -0,0 +1,304 @@
+# $Id: Makefile.in,v 1.2 2004/07/20 07:13:39 marka Exp $
+# Copyright (c) 2000, 2002 Japan Network Information Center.
+# All rights reserved.
+#
+# By using this file, you agree to the terms and conditions set forth bellow.
+#
+# LICENSE TERMS AND CONDITIONS
+#
+# The following License Terms and Conditions apply, unless a different
+# license is obtained from Japan Network Information Center ("JPNIC"),
+# a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+# Chiyoda-ku, Tokyo 101-0047, Japan.
+#
+# 1. Use, Modification and Redistribution (including distribution of any
+# modified or derived work) in source and/or binary forms is permitted
+# under this License Terms and Conditions.
+#
+# 2. Redistribution of source code must retain the copyright notices as they
+# appear in each source code file, this License Terms and Conditions.
+#
+# 3. Redistribution in binary form must reproduce the Copyright Notice,
+# this License Terms and Conditions, in the documentation and/or other
+# materials provided with the distribution. For the purposes of binary
+# distribution the "Copyright Notice" refers to the following language:
+# "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+#
+# 4. The name of JPNIC may not be used to endorse or promote products
+# derived from this Software without specific prior written approval of
+# JPNIC.
+#
+# 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+.SUFFIXES:
+.SUFFIXES: .tsy .c
+
+top_builddir = ../..
+
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+CC = @CC@
+SHELL = @SHELL@
+LIBTOOL = @LIBTOOL@
+
+ICONVINC = @ICONVINC@
+ICONVLIB = @ICONVLIB@
+IDNLIB = ../libidntest.la
+IDNLITELIB = ../libidntestlite.la
+
+INCS = -I. -I$(srcdir) -I$(srcdir)/../../include -I../../include $(ICONVINC)
+DEFS =
+
+CFLAGS = $(INCS) $(DEFS) @CPPFLAGS@ @CFLAGS@
+LDFLAGS = @LDFLAGS@
+TSYFLAGS =
+
+PERL = @PERL@
+
+COMMONSRCS = testsuite.c testutil.c setenv.c
+COMMONOBJS = testsuite.lo testutil.lo setenv.lo
+BUILTSRCS = api.c api-init1.c api-init2.c api-init3.c \
+ api-init4-1.c api-init4-2.c api-init4-3.c \
+ api-init5-1.c api-init5-2.c api-init5-3.c \
+ res.c resconf.c mapselector.c checker.c converter.c mapper.c \
+ normalizer.c delimitermap.c ucs4.c nameprep.c \
+ testconfig.h
+
+TESTS = api-test \
+ api-init1-test \
+ api-init2-test \
+ api-init3-test \
+ api-init4-1-test \
+ api-init4-2-test \
+ api-init4-3-test \
+ api-init5-1-test \
+ api-init5-2-test \
+ api-init5-3-test \
+ res-test \
+ resconf-test \
+ mapselector-test \
+ converter-test \
+ checker-test \
+ mapper-test \
+ normalizer-test \
+ delimitermap-test \
+ ucs4-test \
+ nameprep-test
+
+LITETESTS = apilite-test \
+ reslite-test \
+ resconflite-test \
+ converterlite-test
+
+.tsy.c:
+ rm -f $@ $@.tmp
+ $(PERL) $(srcdir)/testygen -o $@ $(TSYFLAGS) $<
+ $(PERL) $(srcdir)/utffilter $@ > $@.tmp
+ mv -f $@.tmp $@
+
+all:
+
+install:
+
+clean:
+ rm -f *.o *.lo *.tmp core *.core *~
+ rm -f $(TESTS) $(LITETESTS) $(BUILTSRCS)
+ rm -f test.conf testalias.conf test.map
+ rm -f iconvchk
+ rm -fr .libs/
+
+distclean: clean
+ rm -f Makefile
+
+@LITEONLY_TRUE@test check: test-lite
+@LITEONLY_FALSE@test check: test-nolite
+
+test-lite: $(LITETESTS)
+ @for i in $(LITETESTS); do \
+ echo "Run test program: $$i"; \
+ ./$$i; \
+ echo; \
+ done
+
+test-nolite: $(TESTS) $(LITETESTS) iconvchk
+ @./iconvchk
+ @for i in $(TESTS) $(LITETESTS); do \
+ echo "Run test program: $$i"; \
+ ./$$i; \
+ echo; \
+ done
+
+api-test: api.lo $(IDNLIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ api.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB)
+api.lo: api.c testconfig.h
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c api.c
+
+apilite-test: apilite.lo $(IDNLITELIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ apilite.lo $(COMMONOBJS) $(IDNLITELIB)
+apilite.lo: api.c testconfig.h
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -DWITHOUT_ICONV -o $@ \
+ -c api.c
+
+api-init1-test: api-init1.lo $(IDNLIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ api-init1.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB)
+api-init1.lo: api-init1.c testconfig.h
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c api-init1.c
+
+api-init2-test: api-init2.lo $(IDNLIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ api-init2.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB)
+api-init2.lo: api-init2.c testconfig.h
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c api-init2.c
+
+api-init3-test: api-init3.lo $(IDNLIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ api-init3.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB)
+api-init3.lo: api-init3.c testconfig.h
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c api-init3.c
+
+api-init4-1-test: api-init4-1.lo $(IDNLIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ api-init4-1.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB)
+api-init4-1.lo: api-init4-1.c testconfig.h
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c api-init4-1.c
+
+api-init4-2-test: api-init4-2.lo $(IDNLIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ api-init4-2.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB)
+api-init4-2.lo: api-init4-2.c testconfig.h
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c api-init4-2.c
+
+api-init4-3-test: api-init4-3.lo $(IDNLIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ api-init4-3.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB)
+api-init4-3.lo: api-init4-3.c testconfig.h
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c api-init4-3.c
+
+api-init5-1-test: api-init5-1.lo $(IDNLIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ api-init5-1.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB)
+api-init5-1.lo: api-init5-1.c testconfig.h
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c api-init5-1.c
+
+api-init5-2-test: api-init5-2.lo $(IDNLIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ api-init5-2.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB)
+api-init5-2.lo: api-init5-2.c testconfig.h
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c api-init5-2.c
+
+api-init5-3-test: api-init5-3.lo $(IDNLIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ api-init5-3.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB)
+api-init5-3.lo: api-init5-3.c testconfig.h
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c api-init5-3.c
+
+res-test: res.lo $(IDNLIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ res.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB)
+res.lo: res.c testconfig.h
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c res.c
+
+reslite-test: reslite.lo $(IDNLITELIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ reslite.lo $(COMMONOBJS) $(IDNLITELIB)
+reslite.lo: res.c testconfig.h
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -DWITHOUT_ICONV -o $@ \
+ -c res.c
+
+resconf-test: resconf.lo $(IDNLIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ resconf.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB)
+resconf.lo: resconf.c testconfig.h
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c resconf.c
+
+resconflite-test: resconflite.lo $(IDNLITELIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ resconflite.lo $(COMMONOBJS) $(IDNLITELIB)
+resconflite.lo: resconf.c testconfig.h
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -DWITHOUT_ICONV -o $@ \
+ -c resconf.c
+
+mapselector-test: mapselector.lo $(IDNLIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ mapselector.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB)
+mapselector.lo: mapselector.c
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c mapselector.c
+
+converter-test: converter.lo $(IDNLIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ converter.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB)
+converter.lo: converter.c
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c converter.c
+
+converterlite-test: converterlite.lo $(IDNLITELIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ converterlite.lo $(COMMONOBJS) $(IDNLITELIB)
+converterlite.lo: converter.c
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -DWITHOUT_ICONV -o $@ \
+ -c converter.c
+
+checker-test: checker.lo $(IDNLIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ checker.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB)
+checker.lo: checker.c
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c checker.c
+
+mapper-test: mapper.lo $(IDNLIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ mapper.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB)
+mapper.lo: mapper.c
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c mapper.c
+
+normalizer-test: normalizer.lo $(IDNLIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ normalizer.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB)
+normalizer.lo: normalizer.c
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c normalizer.c
+
+delimitermap-test: delimitermap.lo $(IDNLIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ delimitermap.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB)
+delimitermap.lo: delimitermap.c
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c delimitermap.c
+
+ucs4-test: ucs4.lo $(IDNLIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ ucs4.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB)
+ucs4.lo: ucs4.c
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c ucs4.c
+
+nameprep-test: nameprep.lo $(IDNLIB) $(COMMONOBJS)
+ $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+ nameprep.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB)
+nameprep.lo: nameprep.c
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c nameprep.c
+
+testsuite.lo: testsuite.c testsuite.h
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -o $@ -c $(srcdir)/testsuite.c
+testutil.lo: testutil.c testutil.h
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -o $@ -c $(srcdir)/testutil.c
+setenv.lo: setenv.c
+ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -o $@ -c $(srcdir)/setenv.c
+
+testconfig.h: ../../include/config.h
+ rm -f testconfig.h
+ sed -n -e '/HAVE_SETENV/p' -e '/HAVE_UNSETENV/p' \
+ ../../include/config.h > testconfig.h
+
+iconvchk: iconvchk.c codeset.h
+ $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ \
+ $(srcdir)/iconvchk.c $(IDNLIB) $(ICONVLIB)
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/api-init1.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/api-init1.tsy
new file mode 100644
index 0000000..202db15
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/api-init1.tsy
@@ -0,0 +1,113 @@
+#ifndef lint
+static char *rcsid = "$Id: api-init1.tsy,v 1.1.1.1 2003/06/04 00:26:46 marka Exp $";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <idn/api.h>
+#include <idn/log.h>
+
+#include "codeset.h"
+#include "setenv.h"
+#include "testutil.h"
+
+#ifndef EUCJP_ENCODING_NAME
+#define EUCJP_ENCODING_NAME "eucJP"
+#endif
+
+#define CONF_FILENAME "test.conf"
+
+//--------------------------------------------------------------------
+// Setups and Teardowns.
+//--------------------------------------------------------------------
+
+//# SETUP
+// group: init
+{
+ char to[256];
+ idn_result_t r;
+
+ setenv("IDN_LOCAL_CODESET", "UTF-8", 1);
+ unsetenv("IDN_DISABLE");
+ create_conf_file(CONF_FILENAME, 0,
+ "idn-encoding UTF-8",
+ NULL);
+}
+
+//# TEARDOWN
+// group: init
+{
+ remove(CONF_FILENAME);
+}
+
+//--------------------------------------------------------------------
+// Testcases.
+//--------------------------------------------------------------------
+
+//# TESTCASE
+// title: nameinit(0)
+// group: init
+{
+ r = idn__setconffile(CONF_FILENAME);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_nameinit(0);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_encodename(IDN_ENCODE_APP, "<U+3042>", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "xn--l8j");
+
+ r = idn_decodename(IDN_DECODE_APP, "xn--l8j", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "<U+3042>");
+
+ r = idn_decodename2(IDN_DECODE_APP, "xn--l8j", to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "<U+3042>");
+}
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/api-init2.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/api-init2.tsy
new file mode 100644
index 0000000..e1561a4
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/api-init2.tsy
@@ -0,0 +1,113 @@
+#ifndef lint
+static char *rcsid = "$Id: api-init2.tsy,v 1.1.1.1 2003/06/04 00:26:47 marka Exp $";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <idn/api.h>
+#include <idn/log.h>
+
+#include "codeset.h"
+#include "setenv.h"
+#include "testutil.h"
+
+#ifndef EUCJP_ENCODING_NAME
+#define EUCJP_ENCODING_NAME "eucJP"
+#endif
+
+#define CONF_FILENAME "test.conf"
+
+//--------------------------------------------------------------------
+// Setups and Teardowns.
+//--------------------------------------------------------------------
+
+//# SETUP
+// group: init
+{
+ char to[256];
+ idn_result_t r;
+
+ setenv("IDN_LOCAL_CODESET", "UTF-8", 1);
+ unsetenv("IDN_DISABLE");
+ create_conf_file(CONF_FILENAME, 0,
+ "idn-encoding UTF-8",
+ NULL);
+}
+
+//# TEARDOWN
+// group: init
+{
+ remove(CONF_FILENAME);
+}
+
+//--------------------------------------------------------------------
+// Testcases.
+//--------------------------------------------------------------------
+
+//# TESTCASE
+// title: nameinit(1)
+// group: init
+{
+ r = idn__setconffile(CONF_FILENAME);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_nameinit(1);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_encodename(IDN_ENCODE_APP, "<U+3042>", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "<U+3042>");
+
+ r = idn_decodename(IDN_DECODE_APP, "xn--l8j", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "xn--l8j");
+
+ r = idn_decodename2(IDN_DECODE_APP, "xn--l8j", to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "xn--l8j");
+}
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/api-init3.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/api-init3.tsy
new file mode 100644
index 0000000..9035cab
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/api-init3.tsy
@@ -0,0 +1,117 @@
+#ifndef lint
+static char *rcsid = "$Id: api-init3.tsy,v 1.1.1.1 2003/06/04 00:26:47 marka Exp $";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <idn/api.h>
+#include <idn/log.h>
+
+#include "codeset.h"
+#include "setenv.h"
+#include "testutil.h"
+
+#ifndef EUCJP_ENCODING_NAME
+#define EUCJP_ENCODING_NAME "eucJP"
+#endif
+
+#define CONF_FILENAME "test.conf"
+
+//--------------------------------------------------------------------
+// Setups and Teardowns.
+//--------------------------------------------------------------------
+
+//# SETUP
+// group: init
+{
+ char to[256];
+ idn_result_t r;
+
+ setenv("IDN_LOCAL_CODESET", "UTF-8", 1);
+ unsetenv("IDN_DISABLE");
+ create_conf_file(CONF_FILENAME, 0,
+ "idn-encoding UTF-8",
+ NULL);
+}
+
+//# TEARDOWN
+// group: init
+{
+ remove(CONF_FILENAME);
+}
+
+//--------------------------------------------------------------------
+// Testcases.
+//--------------------------------------------------------------------
+
+//# TESTCASE
+// title: call nameinit() twice
+// group: init
+{
+ r = idn__setconffile(CONF_FILENAME);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_nameinit(1);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_nameinit(0);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_encodename(IDN_ENCODE_APP, "<U+3042>", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "<U+3042>");
+
+ r = idn_decodename(IDN_DECODE_APP, "xn--l8j", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "xn--l8j");
+
+ r = idn_decodename2(IDN_DECODE_APP, "xn--l8j", to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "xn--l8j");
+
+ remove(CONF_FILENAME);
+}
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/api-init4-1.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/api-init4-1.tsy
new file mode 100644
index 0000000..585b581
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/api-init4-1.tsy
@@ -0,0 +1,96 @@
+#ifndef lint
+static char *rcsid = "$Id: api-init4-1.tsy,v 1.1.1.1 2003/06/04 00:26:47 marka Exp $";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <idn/api.h>
+#include <idn/log.h>
+
+#include "setenv.h"
+#include "testutil.h"
+
+#define CONF_FILENAME "test.conf"
+
+//--------------------------------------------------------------------
+// Setups and Teardowns.
+//--------------------------------------------------------------------
+
+//# SETUP
+// group: init
+{
+ char to[256];
+ idn_result_t r;
+
+ setenv("IDN_LOCAL_CODESET", "UTF-8", 1);
+ unsetenv("IDN_DISABLE");
+ create_conf_file(CONF_FILENAME, 0,
+ "idn-encoding UTF-8",
+ NULL);
+}
+
+//# TEARDOWN
+// group: init
+{
+ remove(CONF_FILENAME);
+}
+
+//--------------------------------------------------------------------
+// Testcases.
+//--------------------------------------------------------------------
+
+//# TESTCASE
+// title: call encodename() without initialization
+// group: init
+{
+ r = idn__setconffile(CONF_FILENAME);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_encodename(IDN_ENCODE_APP, "<U+3042>", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "xn--l8j");
+}
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/api-init4-2.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/api-init4-2.tsy
new file mode 100644
index 0000000..fd0150b
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/api-init4-2.tsy
@@ -0,0 +1,96 @@
+#ifndef lint
+static char *rcsid = "$Id: api-init4-2.tsy,v 1.1.1.1 2003/06/04 00:26:47 marka Exp $";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <idn/api.h>
+#include <idn/log.h>
+
+#include "setenv.h"
+#include "testutil.h"
+
+#define CONF_FILENAME "test.conf"
+
+//--------------------------------------------------------------------
+// Setups and Teardowns.
+//--------------------------------------------------------------------
+
+//# SETUP
+// group: init
+{
+ char to[256];
+ idn_result_t r;
+
+ setenv("IDN_LOCAL_CODESET", "UTF-8", 1);
+ unsetenv("IDN_DISABLE");
+ create_conf_file(CONF_FILENAME, 0,
+ "idn-encoding UTF-8",
+ NULL);
+}
+
+//# TEARDOWN
+// group: init
+{
+ remove(CONF_FILENAME);
+}
+
+//--------------------------------------------------------------------
+// Testcases.
+//--------------------------------------------------------------------
+
+//# TESTCASE
+// title: call decodename() without initialization
+// group: init
+{
+ r = idn__setconffile(CONF_FILENAME);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_decodename(IDN_DECODE_APP, "xn--l8j", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "<U+3042>");
+}
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/api-init4-3.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/api-init4-3.tsy
new file mode 100644
index 0000000..7da74b9
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/api-init4-3.tsy
@@ -0,0 +1,102 @@
+#ifndef lint
+static char *rcsid = "$Id: api-init4-3.tsy,v 1.1.1.1 2003/06/04 00:26:47 marka Exp $";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <idn/api.h>
+#include <idn/log.h>
+
+#include "codeset.h"
+#include "setenv.h"
+#include "testutil.h"
+
+#ifndef EUCJP_ENCODING_NAME
+#define EUCJP_ENCODING_NAME "eucJP"
+#endif
+
+#define CONF_FILENAME "test.conf"
+
+//--------------------------------------------------------------------
+// Setups and Teardowns.
+//--------------------------------------------------------------------
+
+//# SETUP
+// group: init
+{
+ char to[256];
+ idn_result_t r;
+
+ setenv("IDN_LOCAL_CODESET", "UTF-8", 1);
+ unsetenv("IDN_DISABLE");
+ create_conf_file(CONF_FILENAME, 0,
+ "idn-encoding UTF-8",
+ NULL);
+}
+
+//# TEARDOWN
+// group: init
+{
+ remove(CONF_FILENAME);
+}
+
+//--------------------------------------------------------------------
+// Testcases.
+//--------------------------------------------------------------------
+
+//# TESTCASE
+// title: call decodename2() without initialization
+// group: init
+{
+ r = idn__setconffile(CONF_FILENAME);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_decodename2(IDN_DECODE_APP, "xn--l8j", to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "<U+3042>");
+}
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/api-init5-1.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/api-init5-1.tsy
new file mode 100644
index 0000000..5669502
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/api-init5-1.tsy
@@ -0,0 +1,102 @@
+#ifndef lint
+static char *rcsid = "$Id: api-init5-1.tsy,v 1.1.1.1 2003/06/04 00:26:48 marka Exp $";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <idn/api.h>
+#include <idn/log.h>
+
+#include "setenv.h"
+#include "testutil.h"
+
+#define CONF_FILENAME "test.conf"
+
+//--------------------------------------------------------------------
+// Setups and Teardowns.
+//--------------------------------------------------------------------
+
+//# SETUP
+// group: init
+{
+ char to[256];
+ idn_result_t r;
+
+ setenv("IDN_LOCAL_CODESET", "UTF-8", 1);
+ unsetenv("IDN_DISABLE");
+ create_conf_file(CONF_FILENAME, 0,
+ "idn-encoding UTF-8",
+ NULL);
+}
+
+//# TEARDOWN
+// group: init
+{
+ remove(CONF_FILENAME);
+}
+
+//--------------------------------------------------------------------
+// Testcases.
+//--------------------------------------------------------------------
+
+//# TESTCASE
+// title: call encodename() and nameinit()
+// group: init
+{
+ r = idn__setconffile(CONF_FILENAME);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_encodename(IDN_ENCODE_APP, "aaa", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_nameinit(1);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_encodename(IDN_ENCODE_APP, "<U+3042>", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "xn--l8j");
+}
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/api-init5-2.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/api-init5-2.tsy
new file mode 100644
index 0000000..bf08862
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/api-init5-2.tsy
@@ -0,0 +1,102 @@
+#ifndef lint
+static char *rcsid = "$Id: api-init5-2.tsy,v 1.1.1.1 2003/06/04 00:26:48 marka Exp $";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <idn/api.h>
+#include <idn/log.h>
+
+#include "setenv.h"
+#include "testutil.h"
+
+#define CONF_FILENAME "test.conf"
+
+//--------------------------------------------------------------------
+// Setups and Teardowns.
+//--------------------------------------------------------------------
+
+//# SETUP
+// group: init
+{
+ char to[256];
+ idn_result_t r;
+
+ setenv("IDN_LOCAL_CODESET", "UTF-8", 1);
+ unsetenv("IDN_DISABLE");
+ create_conf_file(CONF_FILENAME, 0,
+ "idn-encoding UTF-8",
+ NULL);
+}
+
+//# TEARDOWN
+// group: init
+{
+ remove(CONF_FILENAME);
+}
+
+//--------------------------------------------------------------------
+// Testcases.
+//--------------------------------------------------------------------
+
+//# TESTCASE
+// title: call decodename() and nameinit()
+// group: init
+{
+ r = idn__setconffile(CONF_FILENAME);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_decodename(IDN_DECODE_APP, "aaa", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_nameinit(1);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_decodename(IDN_DECODE_APP, "xn--l8j", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "<U+3042>");
+}
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/api-init5-3.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/api-init5-3.tsy
new file mode 100644
index 0000000..fae1942
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/api-init5-3.tsy
@@ -0,0 +1,109 @@
+#ifndef lint
+static char *rcsid = "$Id: api-init5-3.tsy,v 1.1.1.1 2003/06/04 00:26:48 marka Exp $";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <idn/api.h>
+#include <idn/log.h>
+
+#include "codeset.h"
+#include "setenv.h"
+#include "testutil.h"
+
+#ifndef EUCJP_ENCODING_NAME
+#define EUCJP_ENCODING_NAME "eucJP"
+#endif
+
+#define CONF_FILENAME "test.conf"
+
+//--------------------------------------------------------------------
+// Setups and Teardowns.
+//--------------------------------------------------------------------
+
+//# SETUP
+// group: init
+{
+ char to[256];
+ idn_result_t r;
+
+ setenv("IDN_LOCAL_CODESET", "UTF-8", 1);
+ unsetenv("IDN_DISABLE");
+ create_conf_file(CONF_FILENAME, 0,
+ "idn-encoding UTF-8",
+ NULL);
+}
+
+//# TEARDOWN
+// group: init
+{
+ remove(CONF_FILENAME);
+}
+
+//--------------------------------------------------------------------
+// Testcases.
+//--------------------------------------------------------------------
+
+//# TESTCASE
+// title: call decodename2() and nameinit()
+// group: init
+{
+ r = idn__setconffile(CONF_FILENAME);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_decodename2(IDN_DECODE_APP, "aaa", to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_nameinit(1);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_decodename2(IDN_DECODE_APP, "xn--l8j", to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "<U+3042>");
+}
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/api.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/api.tsy
new file mode 100644
index 0000000..3ecfb20
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/api.tsy
@@ -0,0 +1,1009 @@
+#ifndef lint
+static char *rcsid = "$Id: api.tsy,v 1.1.1.1 2003/06/04 00:26:50 marka Exp $";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <idn/api.h>
+#include <idn/log.h>
+
+#include "codeset.h"
+#include "setenv.h"
+
+#ifndef EUCJP_ENCODING_NAME
+#define EUCJP_ENCODING_NAME "eucJP"
+#endif
+
+/*
+ * U+304B: hiragana letter KA
+ * U+3099: combining katakana-hiragana voiced sound mark
+ *
+ * map("U+304B U+3099") -> "U+304C"
+ *
+ * U+304C: hiragana letter GA
+ */
+#define UTF8_NAME "A<U+304B><U+3099>"
+#define UTF8_REVNAME "a<U+304C>"
+
+/*
+ * A4AC: hiragana letter GA (in EUC-JP)
+ */
+#define EUCJP_NAME "\xa4\xac"
+#define EUCJP_REVNAME "\xa4\xac"
+
+/*
+ * Conversion result of "U+304B U+3099 A"
+ */
+#define PUNYCODE_NAME "xn--a-i8t"
+
+/*
+ * Conversion result of "A U+304B U+3099" (in EUC-JP).
+ */
+#define AUX_EUCJP_NAME "xn--a-i\xa3\xb8t"
+
+
+//--------------------------------------------------------------------
+// Setups and Teardowns.
+//--------------------------------------------------------------------
+
+//# SETUP
+// group: generic-conversion
+//--
+// Initialize the `api' module.
+// Set local encoding to `UTF-8'.
+{
+ char to[256];
+ idn_result_t r;
+
+ setenv("IDN_LOCAL_CODESET", "UTF-8", 1);
+ unsetenv("IDN_DISABLE");
+ idn_nameinit(0);
+}
+
+//# SETUP
+// group: quiet
+//--
+// Set log level to `fatal' to supress log messages.
+{
+ int saved_log_level;
+
+ saved_log_level = idn_log_getlevel();
+ idn_log_setlevel(idn_log_level_fatal);
+}
+
+//# TEARDOWN
+// group: quiet
+//--
+// Restore log level.
+{
+ idn_log_setlevel(saved_log_level);
+}
+
+//--------------------------------------------------------------------
+// Testcases.
+//--------------------------------------------------------------------
+
+//# TESTCASE
+// title: basic conversion by encodename()
+// group: generic-conversion
+{
+ r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, PUNYCODE_NAME);
+}
+
+//# TESTCASE
+// title: basic conversion by decodename()
+// group: generic-conversion
+{
+ r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_REVNAME);
+}
+
+//# TESTCASE
+// title: basic conversion by decodename2()
+// group: generic-conversion
+{
+ r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+#ifdef WITHOUT_ICONV
+ ASSERT_RESULT(r, idn_failure);
+#else
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_REVNAME);
+#endif
+}
+
+//# TESTCASE
+// title: call decodename2() with auxencoding=NULL
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_decodename2(IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to),
+ NULL);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_REVNAME);
+#endif
+}
+
+//# TESTCASE
+// title: call encodename() with actions=0
+// group: generic-conversion
+{
+ r = idn_encodename(0, UTF8_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_NAME);
+}
+
+//# TESTCASE
+// title: call decodename() with actions=0
+// group: generic-conversion
+{
+ r = idn_decodename(0, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, PUNYCODE_NAME);
+}
+
+//# TESTCASE
+// title: call decodename2() with actions=0
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_decodename2(0, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, AUX_EUCJP_NAME);
+#endif
+}
+
+//# TESTCASE
+// title: call encodename() with actions=rtcheck
+// group: generic-conversion quiet
+{
+ r = idn_encodename(IDN_RTCHECK, EUCJP_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+}
+
+//# TESTCASE
+// title: call encodename() with actions=decode-query
+// group: generic-conversion quiet
+{
+ r = idn_encodename(IDN_DECODE_QUERY, EUCJP_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+}
+
+//# TESTCASE
+// title: call encodename() with actions=decode-app
+// group: generic-conversion quiet
+{
+ r = idn_encodename(IDN_DECODE_APP, EUCJP_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+}
+
+//# TESTCASE
+// title: call encodename() with actions=decode-stored
+// group: generic-conversion quiet
+{
+ r = idn_encodename(IDN_DECODE_STORED, EUCJP_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+}
+
+//# TESTCASE
+// title: call encodename() with actions=(1<<31)
+// group: generic-conversion quiet
+{
+ r = idn_encodename(1 << 31, EUCJP_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+}
+
+//# TESTCASE
+// title: call decodename() with actions=localmap
+// group: generic-conversion quiet
+{
+ r = idn_decodename(IDN_LOCALMAP, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+}
+
+//# TESTCASE
+// title: call decodename2() with actions=localmap
+// group: generic-conversion quiet
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_decodename2(IDN_LOCALMAP, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_invalid_action);
+#endif
+}
+
+//# TESTCASE
+// title: call decodename() with actions=lencheck
+// group: generic-conversion quiet
+{
+ r = idn_decodename(IDN_LENCHECK, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+}
+
+//# TESTCASE
+// title: call decodename2() with actions=lencheck
+// group: generic-conversion quiet
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_decodename2(IDN_LENCHECK, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_invalid_action);
+#endif
+}
+
+//# TESTCASE
+// title: call decodename() with actions=encode-query
+// group: generic-conversion quiet
+{
+ r = idn_decodename(IDN_ENCODE_QUERY, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+}
+
+//# TESTCASE
+// title: call decodename2() with actions=encode-query
+// group: generic-conversion quiet
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_decodename2(IDN_ENCODE_QUERY, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_invalid_action);
+#endif
+}
+
+//# TESTCASE
+// title: call decodename() with actions=encode-app
+// group: generic-conversion quiet
+{
+ r = idn_decodename(IDN_ENCODE_APP, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+}
+
+//# TESTCASE
+// title: call decodename2() with actions=encode-app
+// group: generic-conversion quiet
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_decodename2(IDN_ENCODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_invalid_action);
+#endif
+}
+
+//# TESTCASE
+// title: call decodename() with actions=encode-stored
+// group: generic-conversion quiet
+{
+ r = idn_decodename(IDN_ENCODE_STORED, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+}
+
+//# TESTCASE
+// title: call decodename2() with actions=encode-stored
+// group: generic-conversion quiet
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_decodename2(IDN_ENCODE_STORED, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_invalid_action);
+#endif
+}
+
+//# TESTCASE
+// title: call decodename() with actions=(1<<31)
+// group: generic-conversion quiet
+{
+ r = idn_decodename(1 << 31, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+}
+
+//# TESTCASE
+// title: call decodename2() with actions=(1<<31)
+// group: generic-conversion quiet
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_decodename2(1 << 31, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_invalid_action);
+#endif
+}
+
+//# TESTCASE
+// title: call encodename() with actions=localconv
+// group: generic-conversion quiet
+{
+#ifndef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_encodename(IDN_LOCALCONV, UTF8_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+#endif
+}
+
+//# TESTCASE
+// title: call decodename() with actions=localconv
+// group: generic-conversion quiet
+{
+#ifndef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_decodename(IDN_LOCALCONV, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+#endif
+}
+
+//# TESTCASE
+// title: call decodename2() with actions=localconv
+// group: generic-conversion
+{
+#ifndef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_decodename2(IDN_LOCALCONV, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_failure);
+#endif
+}
+
+//# TESTCASE
+// title: call enable(0) and then encodename()
+// group: generic-conversion
+{
+ idn_enable(0);
+ r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_NAME);
+}
+
+//# TESTCASE
+// title: call decodename() when IDN_DISABLE is defined
+// group: generic-conversion
+{
+ idn_enable(0);
+ r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, PUNYCODE_NAME);
+}
+
+//# TESTCASE
+// title: call decodename() when IDN_DISABLE is defined
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ idn_enable(0);
+ r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, AUX_EUCJP_NAME);
+#endif
+}
+
+//# TESTCASE
+// title: call enable(0) and then encodename()
+// group: generic-conversion
+{
+ idn_enable(0);
+ r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_NAME);
+}
+
+//# TESTCASE
+// title: call enable(0) and then decodename()
+// group: generic-conversion
+{
+ idn_enable(0);
+ r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, PUNYCODE_NAME);
+}
+
+//# TESTCASE
+// title: call enable(0) and then decodename2()
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ idn_enable(0);
+ r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, AUX_EUCJP_NAME);
+#endif
+}
+
+//# TESTCASE
+// title: set IDN_DISABLE and call encodename()
+// group: generic-conversion
+{
+ setenv("IDN_DISABLE", "1", 1);
+ r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_NAME);
+}
+
+//# TESTCASE
+// title: set IDN_DISABLE and call decodename()
+// group: generic-conversion
+{
+ setenv("IDN_DISABLE", "1", 1);
+ r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, PUNYCODE_NAME);
+}
+
+//# TESTCASE
+// title: set IDN_DISABLE and call decodename2()
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ setenv("IDN_DISABLE", "1", 1);
+ r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, AUX_EUCJP_NAME);
+#endif
+}
+
+//# TESTCASE
+// title: set IDN_DISABLE, and then call enable(1) and encodename()
+// group: generic-conversion
+{
+ setenv("IDN_DISABLE", "1", 1);
+ idn_enable(1);
+ r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, PUNYCODE_NAME);
+}
+
+//# TESTCASE
+// title: set IDN_DISABLE, and then call enable(1) and decodename()
+// group: generic-conversion
+{
+ setenv("IDN_DISABLE", "1", 1);
+ idn_enable(1);
+ r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_REVNAME);
+}
+
+//# TESTCASE
+// title: set IDN_DISABLE, and then call enable(1) and decodename2()
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ setenv("IDN_DISABLE", "1", 1);
+ idn_enable(1);
+ r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_REVNAME);
+#endif
+}
+
+//# TESTCASE
+// title: overrun test for arg `to' of encodename()
+// group: generic-conversion
+{
+ /* Normal case */
+ r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to,
+ strlen(PUNYCODE_NAME) + 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, PUNYCODE_NAME);
+
+ r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to,
+ strlen(PUNYCODE_NAME));
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ /* enable(0) case */
+ idn_enable(0);
+ r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to,
+ strlen(UTF8_NAME) + 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_NAME);
+
+ r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to,
+ strlen(UTF8_NAME));
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ /* actions=0 case */
+ idn_enable(1);
+ r = idn_encodename(0, UTF8_NAME, to, strlen(UTF8_NAME) + 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_NAME);
+
+ r = idn_encodename(0, UTF8_NAME, to, strlen(UTF8_NAME));
+ ASSERT_RESULT(r, idn_buffer_overflow);
+}
+
+//# TESTCASE
+// title: overrun test for arg `to' of decodename()
+// group: generic-conversion
+{
+ /* Normal case */
+ r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to,
+ strlen(UTF8_REVNAME) + 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_REVNAME);
+
+ r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to,
+ strlen(UTF8_REVNAME));
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ /* idn_enable(0) case */
+ idn_enable(0);
+ r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to,
+ strlen(PUNYCODE_NAME) + 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, PUNYCODE_NAME);
+
+ r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to,
+ strlen(PUNYCODE_NAME));
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ /* actions=0 case */
+ idn_enable(1);
+ r = idn_decodename(0, PUNYCODE_NAME, to, strlen(PUNYCODE_NAME) + 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, PUNYCODE_NAME);
+
+ r = idn_decodename(0, PUNYCODE_NAME, to, strlen(PUNYCODE_NAME));
+ ASSERT_RESULT(r, idn_buffer_overflow);
+}
+
+//# TESTCASE
+// title: overrun test for arg `to' of decodename2()
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ /* Normal case */
+ r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to,
+ strlen(UTF8_REVNAME) + 1, EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_REVNAME);
+
+ r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to,
+ strlen(UTF8_REVNAME), EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ /* idn_enable(0) case */
+ idn_enable(0);
+ r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to,
+ strlen(AUX_EUCJP_NAME) + 1, EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, AUX_EUCJP_NAME);
+
+ r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to,
+ strlen(AUX_EUCJP_NAME), EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ /* actions=0 case */
+ idn_enable(1);
+ r = idn_decodename2(0, AUX_EUCJP_NAME, to, strlen(AUX_EUCJP_NAME) + 1,
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, AUX_EUCJP_NAME);
+
+ r = idn_decodename2(0, AUX_EUCJP_NAME, to, strlen(AUX_EUCJP_NAME),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+#endif
+}
+
+//# TESTCASE
+// title: call encodename() with tolen=0
+// group: generic-conversion
+{
+ r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to, 0);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+}
+
+//# TESTCASE
+// title: call decodename() with tolen=0
+// group: generic-conversion
+{
+ r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to, 0);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+}
+
+//# TESTCASE
+// title: call decodename2() with tolen=0
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to, 0,
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+#endif
+}
+
+//# TESTCASE
+// title: convert an empty string using encodename()
+// group: generic-conversion
+{
+ r = idn_encodename(IDN_ENCODE_APP, "", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "");
+}
+
+//# TESTCASE
+// title: convert an empty string using decodename()
+// group: generic-conversion
+{
+ r = idn_decodename(IDN_DECODE_APP, "", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "");
+}
+
+//# TESTCASE
+// title: convert an empty string using decodename2()
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_decodename2(IDN_DECODE_APP, "", to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "");
+#endif
+}
+
+//# TESTCASE
+// title: prohcheck by encodename()
+// group: generic-conversion
+{
+ /* U+1680: prohibited character */
+ r = idn_encodename(IDN_PROHCHECK, "<U+1680>", to, sizeof(to));
+ ASSERT_RESULT(r, idn_prohibited);
+}
+
+//# TESTCASE
+// title: unascheck by encodename()
+// group: generic-conversion
+{
+ /* U+0221: unassigned codepoint */
+ r = idn_encodename(IDN_UNASCHECK, "<U+0221>", to, sizeof(to));
+ ASSERT_RESULT(r, idn_prohibited);
+}
+
+//# TESTCASE
+// title: bidicheck by encodename()
+// group: generic-conversion
+{
+ /* U+05D0: bidirectional property is "R" */
+ /* `a': bidirectional property is "L" */
+ /* `0', `-': bidirectional property is "N" */
+ r = idn_encodename(IDN_BIDICHECK, "<U+05D0>", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_encodename(IDN_BIDICHECK, "<U+05D0><U+05D0>",
+ to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_encodename(IDN_BIDICHECK, "<U+05D0><U+05D0>-a",
+ to, sizeof(to));
+ ASSERT_RESULT(r, idn_prohibited);
+
+ r = idn_encodename(IDN_BIDICHECK, "<U+05D0>-a-<U+05D0>",
+ to, sizeof(to));
+ ASSERT_RESULT(r, idn_prohibited);
+
+ r = idn_encodename(IDN_BIDICHECK, "a-<U+05D0><U+05D0>",
+ to, sizeof(to));
+ ASSERT_RESULT(r, idn_prohibited);
+
+ r = idn_encodename(IDN_BIDICHECK, "<U+05D0><U+05D0>-0",
+ to, sizeof(to));
+ ASSERT_RESULT(r, idn_prohibited);
+
+ r = idn_encodename(IDN_BIDICHECK, "<U+05D0>-0-<U+05D0>",
+ to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_encodename(IDN_BIDICHECK, "0-<U+05D0><U+05D0>",
+ to, sizeof(to));
+ ASSERT_RESULT(r, idn_prohibited);
+}
+
+//# TESTCASE
+// title: asccheck by encodename()
+// group: generic-conversion
+{
+ r = idn_encodename(IDN_ASCCHECK, "-name", to, sizeof(to));
+ ASSERT_RESULT(r, idn_prohibited);
+
+ r = idn_encodename(IDN_ASCCHECK, "name-", to, sizeof(to));
+ ASSERT_RESULT(r, idn_prohibited);
+
+ r = idn_encodename(IDN_ASCCHECK, "n ame", to, sizeof(to));
+ ASSERT_RESULT(r, idn_prohibited);
+}
+
+//# TESTCASE
+// title: lencheck by encodename()
+// group: generic-conversion
+{
+ r = idn_encodename(IDN_LENCHECK,
+ "123456789-123456789-123456789-123456789-"
+ "123456789-123456789-123", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_encodename(IDN_LENCHECK,
+ "123456789-123456789-123456789-123456789-"
+ "123456789-123456789-1234", to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_length);
+
+ r = idn_encodename(IDN_LENCHECK, "a..b", to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_length);
+}
+
+//# TESTCASE
+// title: rtcheck non-prohchecked label by decodename()
+// group: generic-conversion
+{
+ /* "xn--6ue" -> "U+1680" (prohibited character) */
+ r = idn_decodename(IDN_RTCHECK, "xn--6ue", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "xn--6ue");
+}
+
+//# TESTCASE
+// title: rtcheck non-unaschecked label by decodename()
+// group: generic-conversion
+{
+ /* "xn--6la" -> "U+0221" (unassigned codepoint) */
+ r = idn_decodename(IDN_IDNCONV | IDN_RTCHECK | IDN_UNASCHECK,
+ "xn--6la", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "xn--6la");
+}
+
+//# TESTCASE
+// title: rtcheck non-ascchecked label by decodename()
+// group: generic-conversion
+{
+ /* "xn----x7t" -> "- U+3042" */
+ r = idn_decodename(IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK,
+ "xn----x7t", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "xn----x7t");
+
+ /* "xn----w7t" -> "U+3042 -" */
+ r = idn_decodename(IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK,
+ "xn----w7t", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "xn----w7t");
+}
+
+//# TESTCASE
+// title: rtcheck non-lenchecked label by decodename()
+// group: generic-conversion
+{
+ /* `s1' has 63 characters */
+ const char *s1 =
+ "xn--l8jaa5522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b";
+
+ const char *s1rev =
+ "<U+9752><U+68EE><U+5CA9><U+624B><U+5BAE><U+57CE><U+79CB><U+7530>"
+ "<U+5C71><U+5F62><U+798F><U+5CF6><U+6771><U+4EAC><U+795E><U+5948>"
+ "<U+5DDD><U+3042><U+3042><U+3042>";
+
+ /* `s2' has 64 characters */
+ const char *s2 =
+ "xn--a-w7ta6522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b";
+
+ /* `s3' has an empty label */
+ const char *s3 = "a..b";
+
+ r = idn_decodename(IDN_IDNCONV | IDN_RTCHECK, s1, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, s1rev);
+
+ r = idn_decodename(IDN_IDNCONV | IDN_RTCHECK, s2, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, s2);
+
+ r = idn_decodename(IDN_IDNCONV | IDN_RTCHECK, s3, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, s3);
+}
+
+//# TESTCASE
+// title: rtcheck non-prohchecked label by decodename2()
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ /* "xn--6ue" -> "U+1680" (prohibited character) */
+ r = idn_decodename2(IDN_RTCHECK, "xn--6ue", to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "xn--6ue");
+#endif
+}
+
+//# TESTCASE
+// title: rtcheck non-unaschecked label by decodename2()
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ /* "xn--6la" -> "U+0221" (unassigned codepoint) */
+ r = idn_decodename2(IDN_IDNCONV | IDN_RTCHECK | IDN_UNASCHECK,
+ "xn--6la", to, sizeof(to), EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "xn--6la");
+#endif
+}
+
+//# TESTCASE
+// title: rtcheck non-ascchecked label by decodename2()
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ /* "xn----x7t" -> "- U+3042" */
+ r = idn_decodename2(IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK,
+ "xn----x7t", to, sizeof(to), EUCJP_ENCODING_NAME);
+
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "xn----x7t");
+
+ /* "xn----w7t" -> "U+3042 -" */
+ r = idn_decodename2(IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK,
+ "xn----w7t", to, sizeof(to), EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "xn----w7t");
+#endif
+}
+
+//# TESTCASE
+// title: rtcheck non-lenchecked label by decodename2()
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ /* `s1' has 63 characters */
+ const char *s1 =
+ "xn--l8jaa5522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b";
+
+ const char *s1rev =
+ "<U+9752><U+68EE><U+5CA9><U+624B><U+5BAE><U+57CE><U+79CB><U+7530>"
+ "<U+5C71><U+5F62><U+798F><U+5CF6><U+6771><U+4EAC><U+795E><U+5948>"
+ "<U+5DDD><U+3042><U+3042><U+3042>";
+
+ /* `s2' has 64 characters */
+ const char *s2 =
+ "xn--a-w7ta6522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b";
+
+ /* `s3' has an empty label */
+ const char *s3 = "a..b";
+
+ r = idn_decodename2(IDN_IDNCONV | IDN_RTCHECK, s1, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, s1rev);
+
+ r = idn_decodename2(IDN_IDNCONV | IDN_RTCHECK, s2, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, s2);
+
+ r = idn_decodename(IDN_IDNCONV | IDN_RTCHECK, s3, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, s3);
+#endif
+}
+
+//# TESTCASE
+// title: pass broken string as `from' to encodename()
+// group: generic-conversion quiet
+{
+ /* "\xe3\x21" is not valid UTF-8 string */
+ r = idn_encodename(IDN_ENCODE_APP, "\xe3\x21", to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_encoding);
+}
+
+//# TESTCASE
+// title: pass broken string as `from' to decodename()
+// group: generic-conversion quiet
+{
+ /* "\xe3\x21" is not valid UTF-8 string */
+ r = idn_decodename(IDN_DECODE_APP, "\xe3\x21", to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_encoding);
+}
+
+//# TESTCASE
+// title: pass broken string as `from' to decodename2()
+// group: generic-conversion quiet
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ /* "\xa4\x21" is not valid EUC-JP string */
+ r = idn_decodename2(IDN_DECODE_APP, "\xa4\x21", to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_invalid_encoding);
+#endif
+}
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/checker.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/checker.tsy
new file mode 100644
index 0000000..54f8ea0
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/checker.tsy
@@ -0,0 +1,610 @@
+#ifndef lint
+static char *rcsid = "$Id: checker.tsy,v 1.1.1.1 2003/06/04 00:26:51 marka Exp $";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <idn/checker.h>
+#include <idn/log.h>
+#include <idn/ucs4.h>
+#include "testutil.h"
+
+#define SIZEOFUCS4(x) (sizeof(x) / sizeof(unsigned long))
+
+#define UCS4_NAME_STR "U+304C" /* hiragana letter ga */
+#define UCS4_NAME 0x304C
+
+#define BUF_SIZE 128
+#define ARRAY_SIZE 9
+
+#define CONF_FILENAME "test.map"
+
+#define LINEBUF_SIZE 2001
+
+/*
+ * Sample strings for `from' argument of normalize(),
+ * and its expected outputs.
+ */
+const unsigned long from[4] = {
+ UCS4_NAME,
+ 0x00A0, /* no-break space: prohibited character */
+ 0x0221, /* unassigned character */
+ 0x0000
+};
+
+
+#define FROM_UCS4NAME_OFFSET 0
+#define FROM_PROH_OFFSET 1
+#define FROM_UNAS_OFFSET 2
+
+const unsigned long from2[4] = {
+ UCS4_NAME,
+ 0x0221, /* unassigned character */
+ 0x00A0, /* no-break space: prohibited character */
+ 0x0000
+};
+
+#define FROM2_UCS4NAME_OFFSET 0
+#define FROM2_PROH_OFFSET 2
+#define FROM2_UNAS_OFFSET 1
+
+static const unsigned long bidi_from[4] = {
+ 0x05BE, /* hebrew punctuation maqaf */
+ 0x0041, /* latin capital letter a */
+ 0xFEFC, /* arabic ligature lam with alef final form */
+ 0x0000
+};
+#define BIDIFROM_OFFSET 1
+
+idn_result_t
+test_createproc(const char *parameter, void **ctxp)
+{
+ return (idn_success);
+}
+
+void
+test_destroyproc(void *ctx)
+{
+}
+
+#define FOUNDPTR_OFFSET 2
+idn_result_t
+test_lookupproc(void *ctx, const unsigned long *ucs4,
+ const unsigned long **found)
+{
+ *found = ucs4 + FOUNDPTR_OFFSET;
+ return (idn_success);
+}
+
+//--------------------------------------------------------------------
+// Setups and Teardowns.
+//--------------------------------------------------------------------
+
+//# SETUP
+// group: generic
+//--
+// Initialize the module and create context.
+{
+ idn_result_t r;
+ idn_checker_t ctx = NULL;
+ char name[BUF_SIZE];
+
+ r = idn_checker_initialize();
+ ASSERT_RESULT(r, idn_success);
+ r = idn_checker_create(&ctx);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TEARDOWN
+// group: generic
+//--
+// Destroy context.
+{
+ if (ctx != NULL)
+ idn_checker_destroy(ctx);
+}
+
+//# SETUP
+// group: lookup
+//--
+// Initialize the module and create context.
+{
+ idn_result_t r;
+ idn_checker_t ctx = NULL;
+ char name[BUF_SIZE];
+ const unsigned long *ptr;
+
+ r = idn_checker_initialize();
+ ASSERT_RESULT(r, idn_success);
+ r = idn_checker_create(&ctx);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TEARDOWN
+// group: lookup
+//--
+// Destroy context.
+{
+ if (ctx != NULL)
+ idn_checker_destroy(ctx);
+}
+
+//# SETUP
+// group: addall
+//--
+// Initialize the module and create context.
+{
+ idn_result_t r;
+ idn_checker_t ctx = NULL;
+ char *names[ARRAY_SIZE];
+ int i;
+ const unsigned long *ptr;
+
+ for (i = 0; i < ARRAY_SIZE; i++) {
+ names[i] = malloc(BUF_SIZE);
+ if (names[i] == NULL) {
+ ASSERT("malloc failed\n");
+ }
+ }
+
+ r = idn_checker_initialize();
+ ASSERT_RESULT(r, idn_success);
+ r = idn_checker_create(&ctx);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TEARDOWN
+// group: addall
+//--
+// Destroy context and free some blocks.
+{
+ if (ctx != NULL)
+ idn_checker_destroy(ctx);
+ for (i = 0; i < ARRAY_SIZE; i++) {
+ free(names[i]);
+ }
+}
+
+//# SETUP
+// group: quiet
+//--
+// Set log level to `fatal' to supress log messages.
+{
+ int saved_log_level;
+
+ saved_log_level = idn_log_getlevel();
+ idn_log_setlevel(idn_log_level_fatal);
+}
+
+//# TEARDOWN
+// group: quiet
+//--
+// Restore log level.
+{
+ idn_log_setlevel(saved_log_level);
+}
+
+//--------------------------------------------------------------------
+// Testcases.
+//--------------------------------------------------------------------
+
+//# TESTCASE
+// title: idn_checker_add() - boundary condition
+// group: generic quiet
+{
+ r = idn_checker_add(ctx, "");
+ ASSERT_RESULT(r, idn_invalid_name);
+}
+
+//# TESTCASE
+// title: idn_checker_add() - builtin schemes, prohibit
+// group: generic quiet
+{
+ sprintf(name, "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491");
+ r = idn_checker_add(ctx, name);
+ ASSERT_RESULT(r, idn_success);
+
+ sprintf(name, "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "nameprep-01");
+ r = idn_checker_add(ctx, name);
+ ASSERT_RESULT(r, idn_invalid_name);
+}
+
+//# TESTCASE
+// title: idn_checker_add() - builtin schemes, unassigned
+// group: generic quiet
+{
+ sprintf(name, "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491");
+ r = idn_checker_add(ctx, name);
+ ASSERT_RESULT(r, idn_success);
+
+ sprintf(name, "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "nameprep-01");
+ r = idn_checker_add(ctx, name);
+ ASSERT_RESULT(r, idn_invalid_name);
+}
+
+//# TESTCASE
+// title: idn_checker_add() - builtin schemes, bidi
+// group: generic quiet
+{
+ sprintf(name, "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491");
+ r = idn_checker_add(ctx, name);
+ ASSERT_RESULT(r, idn_success);
+
+ sprintf(name, "%s%s", IDN_CHECKER_BIDI_PREFIX, "nameprep-01");
+ r = idn_checker_add(ctx, name);
+ ASSERT_RESULT(r, idn_invalid_name);
+}
+
+//# TESTCASE
+// title: idn_checker_add() - file - boundary condition
+// group: generic quiet
+{
+ sprintf(name, "%sfileset:%s", IDN_CHECKER_UNASSIGNED_PREFIX, "");
+ r = idn_checker_add(ctx, name);
+ ASSERT_RESULT(r, idn_nofile);
+ sprintf(name, "%sfileset:%s", IDN_CHECKER_PROHIBIT_PREFIX, "");
+ r = idn_checker_add(ctx, name);
+ ASSERT_RESULT(r, idn_nofile);
+ sprintf(name, "%sfileset:%s", IDN_CHECKER_BIDI_PREFIX, "");
+ r = idn_checker_add(ctx, name);
+ ASSERT_RESULT(r, idn_invalid_name);
+}
+
+//# TESTCASE
+// title: idn_checker_add() - file - long line
+// group: generic quiet
+{
+ char line[LINEBUF_SIZE];
+ const char *first_entry = "304C;";
+ const char *other_entry = " 304D";
+ int i;
+ int len;
+
+ memcpy(line, first_entry, strlen(first_entry));
+ len = strlen(other_entry);
+ for (i = len; i < LINEBUF_SIZE - len; i += len) {
+ memcpy(line + i, other_entry, len);
+ }
+ *(line + i) = '\0';
+
+ create_conf_file(CONF_FILENAME, 0, line, NULL);
+ sprintf(name, "%sfileset:%s", IDN_CHECKER_UNASSIGNED_PREFIX,
+ CONF_FILENAME);
+ r = idn_checker_add(ctx, name);
+ ASSERT_RESULT(r, idn_invalid_syntax);
+ sprintf(name, "%sfileset:%s", IDN_CHECKER_PROHIBIT_PREFIX,
+ CONF_FILENAME);
+ r = idn_checker_add(ctx, name);
+ ASSERT_RESULT(r, idn_invalid_syntax);
+}
+
+//# TESTCASE
+// title: idn_checker_add() - file, prohibit
+// group: lookup
+{
+ create_conf_file(CONF_FILENAME, 0,
+ UCS4_NAME_STR,
+ NULL);
+ sprintf(name, "%sfileset:%s", IDN_CHECKER_PROHIBIT_PREFIX,
+ CONF_FILENAME);
+ r = idn_checker_add(ctx, name);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_checker_lookup(ctx, from, &ptr);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(ptr, from + FROM_UCS4NAME_OFFSET);
+ r = idn_checker_lookup(ctx, from2, &ptr);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(ptr, from2 + FROM2_UCS4NAME_OFFSET);
+}
+
+//# TESTCASE
+// title: idn_checker_add() - file, unassigned
+// group: lookup
+{
+ create_conf_file(CONF_FILENAME, 0,
+ UCS4_NAME_STR,
+ NULL);
+ sprintf(name, "%sfileset:%s", IDN_CHECKER_UNASSIGNED_PREFIX,
+ CONF_FILENAME);
+ r = idn_checker_add(ctx, name);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_checker_lookup(ctx, from, &ptr);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(ptr, from + FROM_UCS4NAME_OFFSET);
+ r = idn_checker_lookup(ctx, from2, &ptr);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(ptr, from2 + FROM2_UCS4NAME_OFFSET);
+}
+
+//# TESTCASE
+// title: idn_checker_add() - file, bidi
+// group: lookup quiet
+{
+ create_conf_file(CONF_FILENAME, 0,
+ UCS4_NAME_STR,
+ NULL);
+ sprintf(name, "%sfileset:%s", IDN_CHECKER_BIDI_PREFIX,
+ CONF_FILENAME);
+ r = idn_checker_add(ctx, name);
+ ASSERT_RESULT(r, idn_invalid_name);
+}
+
+//# TESTCASE
+// title: idn_checker_addall() - boundary condition - scheme name
+// group: addall quiet
+{
+ sprintf(names[0], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491");
+ sprintf(names[1], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491");
+ sprintf(names[2], "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491");
+ sprintf(names[3], "%s%s", IDN_CHECKER_BIDI_PREFIX, "");
+ r = idn_checker_addall(ctx, (const char **)names, 4);
+ ASSERT_RESULT(r, idn_invalid_name);
+}
+
+//# TESTCASE
+// title: idn_checker_addall() - boundary condition - nschemes = 0
+// group: addall quiet
+{
+ sprintf(names[0], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "nameprep-01");
+ sprintf(names[1], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "nameprep-01");
+ sprintf(names[2], "%s%s", IDN_CHECKER_BIDI_PREFIX, "");
+ sprintf(names[3], "%s%s", IDN_CHECKER_BIDI_PREFIX, "nameprep-01");
+ r = idn_checker_addall(ctx, (const char **)names, 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_checker_lookup(ctx, from, &ptr);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(ptr, NULL);
+}
+
+//# TESTCASE
+// title: idn_checker_addall() - add a lot of schemes #1
+// group: addall
+{
+ sprintf(names[0], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491");
+ sprintf(names[1], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491");
+ sprintf(names[2], "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491");
+ sprintf(names[3], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491");
+ sprintf(names[4], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491");
+ sprintf(names[5], "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491");
+ sprintf(names[6], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491");
+ sprintf(names[7], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491");
+ sprintf(names[8], "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491");
+
+ r = idn_checker_addall(ctx, (const char **)names, 9);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_checker_lookup(ctx, from, &ptr);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(ptr, from + FROM_PROH_OFFSET);
+
+ r = idn_checker_lookup(ctx, from2, &ptr);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(ptr, from2 + FROM2_PROH_OFFSET);
+
+ r = idn_checker_lookup(ctx, bidi_from, &ptr);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(ptr, bidi_from + BIDIFROM_OFFSET);
+}
+
+//# TESTCASE
+// title: idn_checker_addall() - add a lot of schemes #2
+// group: addall
+{
+ sprintf(names[0], "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491");
+ sprintf(names[1], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491");
+ sprintf(names[2], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491");
+ sprintf(names[3], "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491");
+ sprintf(names[4], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491");
+ sprintf(names[5], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491");
+ sprintf(names[6], "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491");
+ sprintf(names[7], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491");
+ sprintf(names[8], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491");
+
+ r = idn_checker_addall(ctx, (const char **)names, 9);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_checker_lookup(ctx, from, &ptr);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(ptr, from + FROM_UNAS_OFFSET);
+
+ r = idn_checker_lookup(ctx, from2, &ptr);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(ptr, from2 + FROM2_UNAS_OFFSET);
+
+ r = idn_checker_lookup(ctx, bidi_from, &ptr);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(ptr, bidi_from + BIDIFROM_OFFSET);
+}
+
+//# TESTCASE
+// title: idn_checker_addall() - add same scheme repetedly
+// group: addall
+{
+ int i;
+
+ sprintf(names[0], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491");
+ for (i = 1; i < ARRAY_SIZE; i++) {
+ strcpy(names[i], names[0]);
+ }
+ r = idn_checker_addall(ctx, (const char **)names, ARRAY_SIZE);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_checker_lookup(ctx, from, &ptr);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(ptr, from + FROM_PROH_OFFSET);
+
+ r = idn_checker_lookup(ctx, from2, &ptr);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(ptr, from2 + FROM2_PROH_OFFSET);
+}
+
+//# TESTCASE
+// title: idn_checker_lookup() - builtin schemes - RFC3491 prohibit
+// group: lookup
+{
+ sprintf(name, "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491");
+
+ r = idn_checker_add(ctx, name);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_checker_lookup(ctx, from, &ptr);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(ptr, from + FROM_PROH_OFFSET);
+
+ r = idn_checker_lookup(ctx, from2, &ptr);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(ptr, from2 + FROM2_PROH_OFFSET);
+}
+
+//# TESTCASE
+// title: idn_checker_lookup() - builtin schemes - RFC3491 unassigned
+// group: lookup
+{
+ sprintf(name, "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491");
+
+ r = idn_checker_add(ctx, name);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_checker_lookup(ctx, from, &ptr);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(ptr, from + FROM_UNAS_OFFSET);
+
+ r = idn_checker_lookup(ctx, from2, &ptr);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(ptr, from2 + FROM2_UNAS_OFFSET);
+}
+
+//# TESTCASE
+// title: idn_checker_lookup() - builtin schemes - RFC3491 bidi
+// group: lookup
+{
+ sprintf(name, "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491");
+
+ r = idn_checker_add(ctx, name);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_checker_lookup(ctx, bidi_from, &ptr);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(ptr, bidi_from + BIDIFROM_OFFSET);
+
+ r = idn_checker_lookup(ctx, from, &ptr);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(ptr, NULL);
+
+ r = idn_checker_lookup(ctx, from2, &ptr);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(ptr, NULL);
+}
+
+//# TESTCASE
+// title: idn_checker_lookup() - context without procedure
+// group: lookup
+{
+ r = idn_checker_lookup(ctx, from, &ptr);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(ptr, NULL);
+}
+
+//# TESTCASE
+// title: idn_checker_lookup() - string in ascii
+// group: lookup
+{
+ char *ascii_str = "test";
+ unsigned long ucs4_str[5];
+
+ r = idn_ucs4_utf8toucs4(ascii_str, ucs4_str, SIZEOFUCS4(ucs4_str));
+
+ sprintf(name, "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491");
+ r = idn_checker_add(ctx, name);
+ ASSERT_RESULT(r, idn_success);
+ sprintf(name, "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491");
+ r = idn_checker_add(ctx, name);
+ ASSERT_RESULT(r, idn_success);
+ sprintf(name, "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491");
+ r = idn_checker_add(ctx, name);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_checker_lookup(ctx, ucs4_str, &ptr);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(ptr, NULL);
+}
+
+//# TESTCASE
+// title: idn_checker_destroy(), idn_checker_incrref()
+// group:
+{
+ idn_result_t r;
+ idn_checker_t ctx = NULL;
+
+ r = idn_checker_initialize();
+ ASSERT_RESULT(r, idn_success);
+ r = idn_checker_create(&ctx);
+ ASSERT_RESULT(r, idn_success);
+ idn_checker_incrref(ctx);
+ idn_checker_destroy(ctx);
+ idn_checker_destroy(ctx);
+}
+
+//# TESTCASE
+// title: idn_checker_register()
+// group: generic
+{
+ const unsigned long *ptr = NULL;
+
+ r = idn_checker_register("test",
+ test_createproc,
+ test_destroyproc,
+ test_lookupproc);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_checker_add(ctx, "test");
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_checker_lookup(ctx, from, &ptr);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(ptr, from + FOUNDPTR_OFFSET);
+}
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/codeset.h b/contrib/idn/idnkit-1.0-src/lib/tests/codeset.h
new file mode 100644
index 0000000..735a023
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/codeset.h
@@ -0,0 +1,71 @@
+/* $Id: codeset.h,v 1.1.1.1 2003/06/04 00:26:51 marka Exp $ */
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#ifndef CODESET_H
+#define CODESET_H
+
+/*
+ * Character encoding name that iconv() recognizes as Japanese EUC.
+ *
+ * Please edit the cpp macro definition if iconv() on the system doesn't
+ * recognize "EUC-JP".
+ *
+ * NOTE:
+ * Konstantin Chuguev's iconv-2.0 doesn't accept "eucJP", but "euc-jp".
+ */
+#define EUCJP_ENCODING_NAME "eucJP"
+
+
+/*
+ * Character encoding name that iconv() recognizes as Japanese Shift JIS.
+ *
+ * Please edit the cpp macro definition if iconv() on the system doesn't
+ * recognize "SJIS".
+ *
+ * NOTE:
+ * Konstantin Chuguev's iconv-2.0 doesn't accept "SJIS", but "Shift_JIS".
+ */
+#define SJIS_ENCODING_NAME "SJIS"
+
+#endif /* CODESET_H */
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/converter.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/converter.tsy
new file mode 100644
index 0000000..94c865e
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/converter.tsy
@@ -0,0 +1,822 @@
+#ifndef lint
+static char *rcsid = "$Id: converter.tsy,v 1.1.1.1 2003/06/04 00:26:53 marka Exp $";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <idn/converter.h>
+#include <idn/log.h>
+
+#include "codeset.h"
+#include "testutil.h"
+
+
+#ifndef IDN_PUNYCODE_ENCODING_NAME
+#define IDN_PUNYCODE_ENCODING_NAME "Punycode"
+#endif
+
+#ifndef IDN_UTF8_ENCODING_NAME
+#define IDN_UTF8_ENCODING_NAME "UTF-8" /* by IANA */
+#endif
+
+#ifndef EUCJP_ENCODING_NAME
+#define EUCJP_ENCODING_NAME "eucJP"
+#endif
+
+#ifndef SJIS_ENCODING_NAME
+#define SJIS_ENCODING_NAME "SJIS"
+#endif
+
+#define CONF_FILENAME "testalias.conf"
+#define LINEBUF_SIZE 2001
+
+#define SIZEOFUCS4(x) (sizeof(x) / sizeof(unsigned long))
+
+/*
+ * U+1820: mongorian letter a
+ */
+#define UCS4_INVALID_NAME_FOR_EUCJP 0x1820
+
+/*
+ * A4AC: hiragana letter GA (in EUC-JP)
+ */
+#define EUCJP_NAME "\xa4\xac"
+#define EUCJP_NAME_SIZE 3
+
+/*
+ * U+304C: hiragana letter GA
+ */
+#define UCS4_NAME 0x304C
+
+/*
+ * Conversion result of "U+304C"
+ */
+#define PUNYCODE_NAME "xn--v8j"
+#define PUNYCODE_NAME_SIZE 8
+
+#define BUF_SIZE 128
+
+idn_result_t
+idn_test_encode(idn_converter_t ctx, void *privdata,
+ const unsigned long *from, char *to, size_t tolen)
+{
+ idn_result_t r;
+
+ if (tolen >= EUCJP_NAME_SIZE) {
+ strcpy(to, EUCJP_NAME);
+ r = idn_success;
+ } else {
+ r = idn_buffer_overflow;
+ }
+ return (r);
+
+}
+
+idn_result_t
+idn_test_decode(idn_converter_t ctx, void *privdata,
+ const char *from, unsigned long *to, size_t tolen)
+{
+ idn_result_t r;
+
+ if (tolen >= 2) {
+ to[0] = UCS4_NAME;
+ to[1] = 0x0000;
+ r = idn_success;
+ } else {
+ r = idn_buffer_overflow;
+ }
+ return (r);
+}
+
+
+//--------------------------------------------------------------------
+// Setups and Teardowns.
+//--------------------------------------------------------------------
+
+//# SETUP
+// group: noinit
+//--
+// Do nothing
+{
+ idn_result_t r;
+}
+
+//# SETUP
+// group: generic
+//--
+// Initialize the module.
+{
+ idn_result_t r;
+ idn_converter_t ctx = NULL;
+ const char *name;
+
+ r = idn_converter_initialize();
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_resetalias();
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# SETUP
+// group: localencoding
+//--
+// Initialize the module and load alias file.
+{
+ idn_result_t r;
+ idn_converter_t ctx = NULL;
+ const char *name;
+
+ r = idn_converter_initialize();
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_resetalias();
+ ASSERT_RESULT(r, idn_success);
+ create_conf_file(CONF_FILENAME, 0,
+ "*.KOI8-R KOI8-R",
+ "*.ISO_8859-1 ISO-8859-1",
+ "*.ISO_8859-2 ISO-8859-1",
+ "*.UTF-8 UTF-8",
+ "ja_JP.EUC eucJP",
+ "japanese eucJP",
+ NULL);
+ r = idn_converter_aliasfile(CONF_FILENAME);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TEARDOWN
+// group: localencoding
+//--
+// reset alias information.
+{
+ idn_converter_resetalias();
+}
+
+//# SETUP
+// group: conversion
+//--
+// Initialize the module and create contexts.
+{
+ idn_result_t r;
+ idn_converter_t punycode_ctx = NULL;
+ idn_converter_t utf8_ctx = NULL;
+#ifndef WITHOUT_ICONV
+ idn_converter_t eucjp_ctx = NULL;
+#endif
+
+ r = idn_converter_initialize();
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_create(IDN_PUNYCODE_ENCODING_NAME, &punycode_ctx,
+ 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_create(IDN_UTF8_ENCODING_NAME, &utf8_ctx,
+ IDN_CONVERTER_DELAYEDOPEN);
+ ASSERT_RESULT(r, idn_success);
+#ifndef WITHOUT_ICONV
+ r = idn_converter_create(EUCJP_ENCODING_NAME, &eucjp_ctx,
+ IDN_CONVERTER_DELAYEDOPEN);
+ ASSERT_RESULT(r, idn_success);
+#endif
+}
+
+//# TEARDOWN
+// group: conversion
+//--
+// Destroy contexts.
+{
+ if (punycode_ctx != NULL) {
+ idn_converter_destroy(punycode_ctx);
+ }
+ if (utf8_ctx != NULL) {
+ idn_converter_destroy(utf8_ctx);
+ }
+#ifndef WITHOUT_ICONV
+ if (eucjp_ctx != NULL) {
+ idn_converter_destroy(eucjp_ctx);
+ }
+#endif
+}
+
+//# SETUP
+// group: quiet
+//--
+// Set log level to `fatal' to supress log messages.
+{
+ int saved_log_level;
+
+ saved_log_level = idn_log_getlevel();
+ idn_log_setlevel(idn_log_level_fatal);
+}
+
+//# TEARDOWN
+// group: quiet
+//--
+// Restore log level.
+{
+ idn_log_setlevel(saved_log_level);
+}
+
+//--------------------------------------------------------------------
+// Testcases.
+//--------------------------------------------------------------------
+
+//# TESTCASE
+// title: idn_converter_addalias() test - without initialization
+// group: noinit quiet
+{
+ r = idn_converter_addalias("a", "b", 0);
+ ASSERT_RESULT(r, idn_failure);
+}
+
+//# TESTCASE
+// title: idn_converter_aliasfile() - without initialization
+// group: noinit quiet
+{
+ r = idn_converter_aliasfile("a");
+ ASSERT_RESULT(r, idn_failure);
+}
+
+//# TESTCASE
+// title: idn_converter_resetalias() - without initialization
+// group: noinit quiet
+{
+ r = idn_converter_resetalias();
+ ASSERT_RESULT(r, idn_failure);
+}
+
+//# TESTCASE
+// title: idn_converter_getrealname() - without initialization
+// group: noinit quiet
+{
+ const char *name;
+
+ name = idn_converter_getrealname("test");
+ ASSERT_STRING(name, "test");
+}
+
+//# TESTCASE
+// title: idn_converter_create()
+// group: generic quiet
+{
+#ifdef WITHOUT_ICONV
+ r = idn_converter_addalias("*pc", "Punycode", 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("*ej", EUCJP_ENCODING_NAME, 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("*sj", SJIS_ENCODING_NAME, 0);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_converter_create("abcsj", &ctx, 0);
+ ASSERT_RESULT(r, idn_invalid_name);
+
+ r = idn_converter_create("notresolved", &ctx, 0);
+ ASSERT_RESULT(r, idn_invalid_name);
+ r = idn_converter_create("notresolved", &ctx,
+ IDN_CONVERTER_DELAYEDOPEN);
+ ASSERT_RESULT(r, idn_invalid_name);
+#else
+ r = idn_converter_addalias("*pc", IDN_PUNYCODE_ENCODING_NAME, 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("*ej", EUCJP_ENCODING_NAME, 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("*sj", SJIS_ENCODING_NAME, 0);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_converter_create("abcsj", &ctx, 0);
+ ASSERT_RESULT(r, idn_success);
+ idn_converter_destroy(ctx);
+
+ r = idn_converter_create("notresolved", &ctx, 0);
+ ASSERT_RESULT(r, idn_invalid_name);
+ r = idn_converter_create("notresolved", &ctx,
+ IDN_CONVERTER_DELAYEDOPEN);
+ ASSERT_RESULT(r, idn_success);
+ {
+ unsigned long ucs4_to[BUF_SIZE];
+
+ r = idn_converter_convtoucs4(ctx, "a", ucs4_to, BUF_SIZE);
+ ASSERT_RESULT(r, idn_invalid_name);
+ idn_converter_destroy(ctx);
+ }
+#endif /* WITHOUT_ICONV */
+}
+
+//# TESTCASE
+// title: idn_converter_addalias() - #1
+// group: generic
+{
+ r = idn_converter_addalias("test", "result-a", 0);
+ ASSERT_RESULT(r, idn_success);
+ name = idn_converter_getrealname("test");
+ ASSERT_STRING(name, "result-a");
+}
+
+//# TESTCASE
+// title: idn_converter_addalias() - #2
+// group: generic
+{
+ r = idn_converter_addalias("test", "result-b", 1);
+ ASSERT_RESULT(r, idn_success);
+ name = idn_converter_getrealname("test");
+ ASSERT_STRING(name, "result-b");
+}
+
+//# TESTCASE
+// title: idn_converter_addalias() - #3
+// group: generic
+{
+ r = idn_converter_addalias("test", "result-a", 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-b", 0);
+ ASSERT_RESULT(r, idn_success);
+ name = idn_converter_getrealname("test");
+ ASSERT_STRING(name, "result-a");
+}
+
+//# TESTCASE
+// title: idn_converter_addalias() - #4
+// group: generic
+{
+ r = idn_converter_addalias("test", "result-a", 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-b", 1);
+ ASSERT_RESULT(r, idn_success);
+ name = idn_converter_getrealname("test");
+ ASSERT_STRING(name, "result-b");
+}
+
+//# TESTCASE
+// title: idn_converter_addalias() - #5
+// group: generic
+{
+ r = idn_converter_addalias("test", "result-a", 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-b", 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-c", 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-d", 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-e", 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-f", 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-g", 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-h", 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-i", 0);
+ ASSERT_RESULT(r, idn_success);
+ name = idn_converter_getrealname("test");
+ ASSERT_STRING(name, "result-a");
+}
+
+//# TESTCASE
+// title: idn_converter_addalias() - #6
+// group: generic
+{
+ r = idn_converter_addalias("test", "result-a", 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-b", 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-c", 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-d", 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-e", 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-f", 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-g", 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-h", 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-i", 1);
+ ASSERT_RESULT(r, idn_success);
+ name = idn_converter_getrealname("test");
+ ASSERT_STRING(name, "result-i");
+}
+
+//# TESTCASE
+// title: idn_converter_addalias() - null character
+// group: generic
+{
+ r = idn_converter_addalias("", "result", 0);
+ ASSERT_RESULT(r, idn_invalid_syntax);
+ r = idn_converter_addalias("test", "", 0);
+ ASSERT_RESULT(r, idn_invalid_syntax);
+ r = idn_converter_addalias("", "", 0);
+ ASSERT_RESULT(r, idn_invalid_syntax);
+}
+
+//# TESTCASE
+// title: idn_converter_resetalias() - no alias added
+// group: generic
+{
+ r = idn_converter_resetalias();
+ ASSERT_RESULT(r, idn_success);
+ name = idn_converter_getrealname("test");
+ ASSERT_STRING(name, "test");
+
+}
+
+//# TESTCASE
+// title: idn_converter_resetalias() - one alias added
+// group: generic
+{
+ r = idn_converter_addalias("test", "result-a", 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_resetalias();
+ ASSERT_RESULT(r, idn_success);
+ name = idn_converter_getrealname("test");
+ ASSERT_STRING(name, "test");
+
+}
+
+//# TESTCASE
+// title: idn_converter_resetalias() - many aliases added
+// group: generic
+{
+ r = idn_converter_addalias("test", "result-a", 1);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-b", 1);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-c", 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-d", 1);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-e", 1);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-f", 1);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-g", 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-h", 0);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_addalias("test", "result-i", 1);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_resetalias();
+ ASSERT_RESULT(r, idn_success);
+ name = idn_converter_getrealname("test");
+ ASSERT_STRING(name, "test");
+}
+
+//# TESTCASE
+// title: idn_converter_aliasfile() - boundary condition
+// group: generic quiet
+{
+ r = idn_converter_aliasfile("");
+ ASSERT_RESULT(r, idn_nofile);
+
+ r = idn_converter_aliasfile("idnalias-not-found.conf");
+ ASSERT_RESULT(r, idn_nofile);
+}
+
+//# TESTCASE
+// title: idn_converter_aliasfile() - long line
+// group: generic quiet
+{
+ char line[LINEBUF_SIZE];
+ const char *entry = "aaaaaaaaaa";
+ int i;
+ int len;
+
+ len = strlen(entry);
+ for (i = 0; i < LINEBUF_SIZE - len; i += len) {
+ memcpy(line + i, entry, len);
+ }
+ *(line + (LINEBUF_SIZE / 2)) = ' ';
+ *(line + i) = '\0';
+ create_conf_file(CONF_FILENAME, 0, line, NULL);
+ r = idn_converter_aliasfile(CONF_FILENAME);
+ ASSERT_RESULT(r, idn_invalid_syntax);
+}
+
+//# TESTCASE
+// title: idn_converter_aliasfile() - no new line at end of file
+// group: generic quiet
+{
+ create_conf_file(CONF_FILENAME, CONF_NO_EOF_NEWLINE,
+ "*.ISO_8859-1 ISO-8859-1",
+ "*.ISO_8859-2 ISO-8859-1",
+ "*.SJIS Shift_JIS",
+ "*.Shift_JIS Shift_JIS",
+ "ja_JP.EUC eucJP",
+ "japanese eucJP",
+ NULL);
+ r = idn_converter_aliasfile(CONF_FILENAME);
+ ASSERT_RESULT(r, idn_success);
+ name = idn_converter_getrealname("japanese");
+ ASSERT_STRING(name, "eucJP");
+
+}
+
+//# TESTCASE
+// title: idn_converter_aliasfile() - invalid entries
+// group: generic quiet
+{
+ create_conf_file(CONF_FILENAME, 0,
+ "*.ISO_8859-1 ISO-8859-1",
+ "*.ISO_8859-2 ISO-8859-1",
+ "*.SJIS",
+ "*.Shift_JIS",
+ "ja_JP.EUC eucJP",
+ "japanese eucJP",
+ NULL);
+ r = idn_converter_aliasfile(CONF_FILENAME);
+ ASSERT_RESULT(r, idn_invalid_syntax);
+}
+
+//# TESTCASE
+// title: idn_converter_aliasfile() - more then two items in one line
+// group: generic quiet
+{
+ create_conf_file(CONF_FILENAME, 0,
+ "*.ISO_8859-1 ISO-8859-1",
+ "*.ISO_8859-2 ISO-8859-1",
+ "*.SJIS Shift_JIS ko_KR.EUC",
+ "*.Shift_JIS Shift_JIS",
+ "*.big5 Big5 *.big5 *.big5",
+ "ja_JP.EUC eucJP",
+ "japanese eucJP",
+ NULL);
+ r = idn_converter_aliasfile(CONF_FILENAME);
+ ASSERT_RESULT(r, idn_success);
+ name = idn_converter_getrealname("japanese");
+ ASSERT_STRING(name, "eucJP");
+}
+
+//# TESTCASE
+// title: idn_converter_localencoding() - #1
+// group: localencoding
+{
+ r = idn_converter_create("test.UTF-8", &ctx,
+ IDN_CONVERTER_DELAYEDOPEN);
+ ASSERT_RESULT(r, idn_success);
+ name = idn_converter_localencoding(ctx);
+ ASSERT_STRING(name, "UTF-8");
+ idn_converter_destroy(ctx);
+}
+
+//# TESTCASE
+// title: idn_converter_localencoding() - #2
+// group: localencoding
+{
+ r = idn_converter_create("test.KOI8-R", &ctx,
+ IDN_CONVERTER_DELAYEDOPEN);
+#ifdef WITHOUT_ICONV
+ ASSERT_RESULT(r, idn_invalid_name);
+#else
+ ASSERT_RESULT(r, idn_success);
+ name = idn_converter_localencoding(ctx);
+ ASSERT_STRING(name, "KOI8-R");
+ idn_converter_destroy(ctx);
+#endif
+}
+
+//# TESTCASE
+// title: idn_converter_localencoding() - #3
+// group: localencoding
+{
+ r = idn_converter_create("unresolvedname", &ctx,
+ IDN_CONVERTER_DELAYEDOPEN);
+#ifdef WITHOUT_ICONV
+ ASSERT_RESULT(r, idn_invalid_name);
+#else
+ ASSERT_RESULT(r, idn_success);
+ name = idn_converter_localencoding(ctx);
+ ASSERT_STRING(name, "unresolvedname");
+ idn_converter_destroy(ctx);
+#endif
+}
+
+//# TESTCASE
+// title: idn_converter_encodingtype()
+// group: conversion
+{
+ ASSERT_INT(idn_converter_encodingtype(punycode_ctx),
+ IDN_ACE_STRICTCASE);
+ ASSERT_INT(idn_converter_encodingtype(utf8_ctx),
+ IDN_NONACE);
+#ifndef WITHOUT_ICONV
+ ASSERT_INT(idn_converter_encodingtype(eucjp_ctx),
+ IDN_NONACE);
+#endif
+}
+
+//# TESTCASE
+// title: idn_converter_isasciicompatible()
+// group: conversion
+{
+ ASSERT_INT(idn_converter_isasciicompatible(punycode_ctx), 1);
+ ASSERT_INT(idn_converter_isasciicompatible(utf8_ctx), 0);
+#ifndef WITHOUT_ICONV
+ ASSERT_INT(idn_converter_isasciicompatible(eucjp_ctx), 0);
+#endif
+}
+
+//# TESTCASE
+// title: idn_converter_convfromucs4()
+// group: conversion quiet
+{
+ unsigned long from_nullchar = 0x0000;
+ unsigned long from[2] = { UCS4_NAME, 0x0000 };
+ char to[1];
+ char to_punycode[PUNYCODE_NAME_SIZE];
+#ifndef WITHOUT_ICONV
+ char to_eucjp[EUCJP_NAME_SIZE];
+#endif
+
+ r = idn_converter_convfromucs4(punycode_ctx, &from_nullchar, to, 0);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ r = idn_converter_convfromucs4(punycode_ctx, &from_nullchar, to, 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "");
+
+ r = idn_converter_convfromucs4(punycode_ctx, from, to_punycode, 0);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ r = idn_converter_convfromucs4(punycode_ctx, from, to_punycode,
+ PUNYCODE_NAME_SIZE - 1);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+ r = idn_converter_convfromucs4(punycode_ctx, from, to_punycode,
+ PUNYCODE_NAME_SIZE);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to_punycode, PUNYCODE_NAME);
+
+#ifndef WITHOUT_ICONV
+ r = idn_converter_convfromucs4(eucjp_ctx, &from_nullchar, to, 0);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ r = idn_converter_convfromucs4(eucjp_ctx, &from_nullchar, to, 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "");
+
+ r = idn_converter_convfromucs4(eucjp_ctx, from, to_eucjp, 0);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ r = idn_converter_convfromucs4(eucjp_ctx, from, to_eucjp,
+ EUCJP_NAME_SIZE - 1);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ r = idn_converter_convfromucs4(eucjp_ctx, from, to_eucjp,
+ EUCJP_NAME_SIZE);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to_eucjp, EUCJP_NAME);
+
+ from[0] = 0x80000000;
+ r = idn_converter_convfromucs4(eucjp_ctx, from, to_eucjp,
+ EUCJP_NAME_SIZE);
+ ASSERT_RESULT(r, idn_invalid_encoding);
+
+ from[0] = UCS4_INVALID_NAME_FOR_EUCJP;
+ r = idn_converter_convfromucs4(eucjp_ctx, from, to_eucjp,
+ EUCJP_NAME_SIZE);
+ ASSERT_RESULT(r, idn_nomapping);
+#endif
+}
+
+//# TESTCASE
+// title: idn_converter_convtoucs4()
+// group: conversion
+{
+ unsigned long to_nullchar = 0x0000;
+ unsigned long to[1];
+ unsigned long punycode_to[2];
+#ifndef WITHOUT_ICONV
+ unsigned long eucjp_to[2];
+#endif
+ unsigned long ucs4_name[2] = { UCS4_NAME, 0x0000 };
+
+ r = idn_converter_convtoucs4(punycode_ctx, "", to, 0);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ r = idn_converter_convtoucs4(punycode_ctx, "", to, 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, &to_nullchar);
+
+ r = idn_converter_convtoucs4(punycode_ctx, PUNYCODE_NAME,
+ punycode_to, 0);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ r = idn_converter_convtoucs4(punycode_ctx, PUNYCODE_NAME,
+ punycode_to, 1);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+ r = idn_converter_convtoucs4(punycode_ctx, PUNYCODE_NAME, punycode_to,
+ 2);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING_THRU(punycode_to, ucs4_name);
+
+#ifndef WITHOUT_ICONV
+ r = idn_converter_convtoucs4(eucjp_ctx, "", to, 0);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ r = idn_converter_convtoucs4(eucjp_ctx, "", to, 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, &to_nullchar);
+
+ r = idn_converter_convtoucs4(eucjp_ctx, EUCJP_NAME, eucjp_to, 0);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ r = idn_converter_convtoucs4(eucjp_ctx, EUCJP_NAME, eucjp_to, 1);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ r = idn_converter_convtoucs4(eucjp_ctx, EUCJP_NAME, eucjp_to, 2);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, &to_nullchar);
+
+ r = idn_converter_convtoucs4(eucjp_ctx, "\xFF\xFF", eucjp_to, 2);
+ ASSERT_RESULT(r, idn_invalid_encoding);
+#endif
+}
+
+//# TESTCASE
+// title: idn_converter_destroy(), idn_converter_incrref()
+// group: generic
+{
+ idn_converter_t ctx2;
+
+ r = idn_converter_create(IDN_UTF8_ENCODING_NAME, &ctx, 0);
+ ASSERT_RESULT(r, idn_success);
+ idn_converter_destroy(ctx);
+
+ r = idn_converter_create(IDN_UTF8_ENCODING_NAME, &ctx2, 0);
+ ASSERT_RESULT(r, idn_success);
+ idn_converter_incrref(ctx2);
+ ASSERT_RESULT(r, idn_success);
+ idn_converter_destroy(ctx2);
+ idn_converter_destroy(ctx2);
+}
+
+//# TESTCASE
+// title: idn_converter_register()
+// group: generic
+{
+ char eucjp_to[3];
+ unsigned long ucs4_to[2];
+ unsigned long ucs4_name[2] = { UCS4_NAME, 0x0000 };
+
+ r = idn_converter_register("test",
+ NULL,
+ NULL,
+ idn_test_encode,
+ idn_test_decode,
+ NULL,
+ IDN_ACE_STRICTCASE);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_converter_create("test", &ctx, 0);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_converter_convfromucs4(ctx, ucs4_name, eucjp_to, sizeof(eucjp_to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(eucjp_to, EUCJP_NAME);
+
+ r = idn_converter_convtoucs4(ctx, "", ucs4_to, SIZEOFUCS4(ucs4_to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(ucs4_to, ucs4_name);
+
+ idn_converter_destroy(ctx);
+}
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/delimitermap.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/delimitermap.tsy
new file mode 100644
index 0000000..aeaa46c
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/delimitermap.tsy
@@ -0,0 +1,257 @@
+#ifndef lint
+static char *rcsid = "$Id: delimitermap.tsy,v 1.1.1.1 2003/06/04 00:26:53 marka Exp $";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <idn/delimitermap.h>
+#include <idn/ucs4.h>
+#include <idn/log.h>
+#include "testutil.h"
+
+/*
+ * Codepoions to test the add() function.
+ */
+#define ADDITIONAL_DELIMITER0 0xe0
+#define ADDITIONAL_DELIMITER1 0xe1
+
+/*
+ * Sample string for `from' argument of map(),
+ * and its expected outputs.
+ */
+static const unsigned long from[] = {
+ 0x002e, /* full stop */
+ 0x3002, /* ideographic full stop */
+ 0xff0e, /* fullwidth full stop */
+ 0xff61, /* halfwidth ideographic full stop */
+ ADDITIONAL_DELIMITER0,
+ ADDITIONAL_DELIMITER1,
+ 0x0000
+};
+
+static const unsigned long expected_default[] = {
+ 0x002e, /* full stop */
+ 0x002e, /* full stop */
+ 0x002e, /* full stop */
+ 0x002e, /* full stop */
+ ADDITIONAL_DELIMITER0,
+ ADDITIONAL_DELIMITER1,
+ 0x0000
+};
+
+static const unsigned long expected_add[] = {
+ 0x002e, /* full stop */
+ 0x002e, /* full stop */
+ 0x002e, /* full stop */
+ 0x002e, /* full stop */
+ 0x002e, /* full stop */
+ ADDITIONAL_DELIMITER1,
+ 0x0000
+};
+
+static const unsigned long expected_addall[] = {
+ 0x002e, /* full stop */
+ 0x002e, /* full stop */
+ 0x002e, /* full stop */
+ 0x002e, /* full stop */
+ 0x002e, /* full stop */
+ 0x002e, /* full stop */
+ 0x0000
+};
+
+//--------------------------------------------------------------------
+// Setups and Teardowns.
+//--------------------------------------------------------------------
+
+//# SETUP
+// group: generic-init
+{
+ idn_result_t r;
+ idn_delimitermap_t ctx;
+ unsigned long to[256];
+
+ r = idn_delimitermap_create(&ctx);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TEARDOWN
+// group: generic-init
+{
+ if (ctx != NULL)
+ idn_delimitermap_destroy(ctx);
+}
+
+//# SETUP
+// group: quiet
+{
+ int saved_log_level;
+
+ saved_log_level = idn_log_getlevel();
+ idn_log_setlevel(idn_log_level_fatal);
+}
+
+//# TEARDOWN
+// group: quiet
+{
+ idn_log_setlevel(saved_log_level);
+}
+
+//--------------------------------------------------------------------
+// Testcases.
+//--------------------------------------------------------------------
+
+//# TESTCASE
+// title: call create()
+// group: generic-init
+{
+}
+
+//# TESTCASE
+// title: call map() without additional delimiters
+// group: generic-init
+{
+ r = idn_delimitermap_map(ctx, from, to, sizeof(to) / sizeof(*to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, expected_default);
+}
+
+//# TESTCASE
+// title: call add() and map()
+// group: generic-init
+{
+ r = idn_delimitermap_add(ctx, ADDITIONAL_DELIMITER0);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_delimitermap_map(ctx, from, to, sizeof(to) / sizeof(*to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, expected_add);
+}
+
+//# TESTCASE
+// title: call addall()
+// group: generic-init
+{
+ unsigned long delimiters[2];
+
+ delimiters[0] = ADDITIONAL_DELIMITER0;
+ delimiters[1] = ADDITIONAL_DELIMITER1;
+ r = idn_delimitermap_addall(ctx, delimiters, 2);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_delimitermap_map(ctx, from, to, sizeof(to) / sizeof(*to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, expected_addall);
+}
+
+//# TESTCASE
+// title: call addall() with nnames=0
+// group: generic-init
+{
+ unsigned long delimiters[2];
+
+ r = idn_delimitermap_addall(ctx, delimiters, 0);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_delimitermap_map(ctx, from, to, sizeof(to) / sizeof(*to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, expected_default);
+}
+
+//# TESTCASE
+// title: call add() with invalid codepoint
+// group: generic-init quiet
+{
+ r = idn_delimitermap_add(ctx, 0x0000); /* NUL */
+ ASSERT_RESULT(r, idn_invalid_codepoint);
+
+ r = idn_delimitermap_add(ctx, 0xd800); /* surrogate */
+ ASSERT_RESULT(r, idn_invalid_codepoint);
+
+ r = idn_delimitermap_add(ctx, 0x110000); /* out of range */
+ ASSERT_RESULT(r, idn_invalid_codepoint);
+}
+
+//# TESTCASE
+// title: call addall() with invalid codepoint
+// group: generic-init quiet
+{
+ unsigned long delimiters[1];
+
+ delimiters[0] = 0x0000; /* NUL */
+ r = idn_delimitermap_addall(ctx, delimiters, 1);
+ ASSERT_RESULT(r, idn_invalid_codepoint);
+
+ delimiters[0] = 0xd800; /* surrogate */
+ r = idn_delimitermap_addall(ctx, delimiters, 1);
+ ASSERT_RESULT(r, idn_invalid_codepoint);
+
+ delimiters[0] = 0x110000; /* out of range */
+ r = idn_delimitermap_addall(ctx, delimiters, 1);
+ ASSERT_RESULT(r, idn_invalid_codepoint);
+}
+
+//# TESTCASE
+// title: overrun test for arg `to' of map()
+// group: generic-init
+{
+ r = idn_delimitermap_map(ctx, from, to,
+ idn_ucs4_strlen(expected_default) + 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, expected_default);
+ r = idn_delimitermap_map(ctx, from, to,
+ idn_ucs4_strlen(expected_default));
+ ASSERT_RESULT(r, idn_buffer_overflow);
+}
+
+//# TESTCASE
+// title: call map() with tolen=0
+// group: generic-init
+{
+ r = idn_delimitermap_map(ctx, from, to, 0);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+}
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/iconvchk.c b/contrib/idn/idnkit-1.0-src/lib/tests/iconvchk.c
new file mode 100644
index 0000000..895b197
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/iconvchk.c
@@ -0,0 +1,132 @@
+#ifndef lint
+static char *rcsid = "$Id: iconvchk.c,v 1.1.1.1 2003/06/04 00:26:54 marka Exp $";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <idn/api.h>
+#include <idn/converter.h>
+#include <idn/result.h>
+
+#include "codeset.h"
+
+#define IDN_UTF8_ENCODING_NAME "UTF-8"
+
+void
+eucjp_check(void)
+{
+ idn_result_t r;
+ idn_converter_t eucjp_ctx = NULL;
+
+ r = idn_nameinit(0);
+ if (r != idn_success) {
+ fprintf(stderr, "idn_nameinit(): failed\n");
+ exit (1);
+ }
+
+ r = idn_converter_create(EUCJP_ENCODING_NAME, &eucjp_ctx, 0);
+
+ if (eucjp_ctx != NULL) {
+ idn_converter_destroy(eucjp_ctx);
+ }
+
+ if (r != idn_success) {
+ if (r == idn_invalid_name) {
+ fprintf(stderr, \
+ "\"%s\" is invalid codeset name, edit codeset.h\n", \
+ EUCJP_ENCODING_NAME);
+ exit (1);
+ } else {
+ fprintf(stderr, \
+ "idn_converter_create() failed with error \"%s\"\n", \
+ idn_result_tostring(r));
+ exit (1);
+ }
+ }
+}
+
+void
+sjis_check(void)
+{
+ idn_result_t r;
+ idn_converter_t sjis_ctx = NULL;
+
+ r = idn_nameinit(0);
+ if (r != idn_success) {
+ fprintf(stderr, "idn_nameinit(): failed\n");
+ exit (1);
+ }
+
+ r = idn_converter_create(SJIS_ENCODING_NAME, &sjis_ctx, 0);
+
+ if (sjis_ctx != NULL) {
+ idn_converter_destroy(sjis_ctx);
+ }
+
+ if (r != idn_success) {
+ if (r == idn_invalid_name) {
+ fprintf(stderr, \
+ "\"%s\" is invalid codeset name, edit codeset.h\n", \
+ SJIS_ENCODING_NAME);
+ exit (1);
+ } else {
+ fprintf(stderr, \
+ "idn_converter_create() failed with error \"%s\"\n", \
+ idn_result_tostring(r));
+ exit (1);
+ }
+ }
+}
+
+int
+main (int ac, char **av)
+{
+ eucjp_check();
+ sjis_check();
+
+ exit (0);
+}
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/mapper.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/mapper.tsy
new file mode 100644
index 0000000..5db6c65
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/mapper.tsy
@@ -0,0 +1,497 @@
+#ifndef lint
+static char *rcsid = "$Id: mapper.tsy,v 1.1.1.1 2003/06/04 00:26:54 marka Exp $";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <idn/mapper.h>
+#include <idn/log.h>
+#include <idn/ucs4.h>
+#include "testutil.h"
+
+#define SIZEOFUCS4(x) (sizeof(x) / sizeof(unsigned long))
+
+#define UCS4_NAME_STR "U+304C" /* hiragana letter ga */
+#define UCS4_NAME 0x304C
+
+#define BUF_SIZE 128
+#define ARRAY_SIZE 9
+#define CONF_FILENAME "test.map"
+
+#define LINEBUF_SIZE 2001
+
+/*
+ * Sample string for `from' argument of map(),
+ * and its expected outputs.
+ */
+static const unsigned long from[] = {
+ 0x0041, /* latin capital letter a */
+ 0x0042, /* latin capital letter b */
+ UCS4_NAME,
+ 0x0000
+};
+
+static const unsigned long expected_default[] = {
+ 0x0061, /* latin small letter a */
+ 0x0062, /* latin small letter b */
+ UCS4_NAME,
+ 0x0000
+};
+
+idn_result_t
+test_create(const char *parameter, void **ctxp)
+{
+ return (idn_success);
+}
+
+void
+test_destroy(void *ctxp)
+{
+}
+
+idn_result_t
+test_map(void *ctx, const unsigned long *from, unsigned long *to,
+ size_t tolen)
+{
+ if (tolen > idn_ucs4_strlen(from)) {
+ idn_ucs4_strcpy(to, from);
+ } else {
+ return (idn_buffer_overflow);
+ }
+
+ return (idn_success);
+}
+
+//--------------------------------------------------------------------
+// Setups and Teardowns.
+//--------------------------------------------------------------------
+
+//# SETUP
+// group: noinit
+//--
+// Do nothing
+{
+ idn_result_t r;
+ const char *name;
+}
+
+//# SETUP
+// group: generic
+//--
+// Initialize the module and create context.
+{
+ idn_result_t r;
+ idn_mapper_t ctx = NULL;
+
+ r = idn_mapper_initialize();
+ ASSERT_RESULT(r, idn_success);
+ r = idn_mapper_create(&ctx);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TEARDOWN
+// group: generic
+//--
+// Destroy context.
+{
+ idn_mapper_destroy(ctx);
+}
+
+//# SETUP
+// group: addall
+//--
+// Initialize the module and create context.
+{
+ idn_result_t r;
+ idn_mapper_t ctx = NULL;
+ char *names[ARRAY_SIZE];
+ int i;
+ unsigned long to[4];
+
+ for (i = 0; i < ARRAY_SIZE; i++) {
+ names[i] = malloc(BUF_SIZE);
+ if (names[i] == NULL) {
+ ASSERT("malloc failed\n");
+ }
+ }
+
+ r = idn_mapper_initialize();
+ ASSERT_RESULT(r, idn_success);
+ r = idn_mapper_create(&ctx);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TEARDOWN
+// group: addall
+//--
+// Destroy context and free some blocks.
+{
+ idn_mapper_destroy(ctx);
+ for (i = 0; i < ARRAY_SIZE; i++) {
+ free(names[i]);
+ }
+}
+
+//# SETUP
+// group: quiet
+//--
+// Set log level to `fatal' to supress log messages.
+{
+ int saved_log_level;
+
+ saved_log_level = idn_log_getlevel();
+ idn_log_setlevel(idn_log_level_fatal);
+}
+
+//# TEARDOWN
+// group: quiet
+//--
+// Restore log level.
+{
+ idn_log_setlevel(saved_log_level);
+}
+
+//--------------------------------------------------------------------
+// Testcases.
+//--------------------------------------------------------------------
+
+//# TESTCASE
+// title: idn_mapper_add() - boundary condition
+// group: generic quiet
+{
+ r = idn_mapper_add(ctx, "");
+ ASSERT_RESULT(r, idn_invalid_name);
+}
+
+//# TESTCASE
+// title: idn_mapper_add() - builtin schemes
+// group: generic quiet
+{
+ r = idn_mapper_add(ctx, "RFC3491");
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_mapper_add(ctx, "nameprep-01");
+ ASSERT_RESULT(r, idn_invalid_name);
+}
+
+//# TESTCASE
+// title: idn_mapper_add() - boundary condition
+// group: generic quiet
+{
+ r = idn_mapper_add(ctx, "");
+ ASSERT_RESULT(r, idn_invalid_name);
+ r = idn_mapper_add(ctx, "filemap:");
+ ASSERT_RESULT(r, idn_nofile);
+ r = idn_mapper_add(ctx, "filemap:notfound.map");
+ ASSERT_RESULT(r, idn_nofile);
+}
+
+//# TESTCASE
+// title: idn_mapper_add() - file
+// group: generic quiet
+{
+ char name[BUF_SIZE];
+ unsigned long to[4];
+
+ create_conf_file(CONF_FILENAME, 0,
+ "0041; 0061;",
+ "0042; 0062;",
+ NULL);
+ sprintf(name, "filemap:%s", CONF_FILENAME);
+
+ r = idn_mapper_add(ctx, name);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_mapper_map(ctx, from, to, SIZEOFUCS4(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, expected_default);
+}
+
+//# TESTCASE
+// title: idn_mapper_add() - file - long line
+// group: generic quiet
+{
+ char line[LINEBUF_SIZE];
+ char name[BUF_SIZE];
+ const char *first_entry = "0041;";
+ const char *other_entry = " 0061";
+ int i;
+ int len;
+
+ memcpy(line, first_entry, strlen(first_entry));
+ len = strlen(other_entry);
+ for (i = len; i < LINEBUF_SIZE - len; i += len) {
+ memcpy(line + i, other_entry, len);
+ }
+ *(line + i) = '\0';
+
+ create_conf_file(CONF_FILENAME, 0, line, NULL);
+ sprintf(name, "filemap:%s", CONF_FILENAME);
+ r = idn_mapper_add(ctx, name);
+ ASSERT_RESULT(r, idn_invalid_syntax);
+}
+
+//# TESTCASE
+// title: idn_mapper_add() - file - no new line at end of file
+// group: generic quiet
+{
+ char name[BUF_SIZE];
+ unsigned long to[4];
+
+ create_conf_file(CONF_FILENAME, CONF_NO_EOF_NEWLINE,
+ "0041; 0061;",
+ "0042; 0062;",
+ NULL);
+ sprintf(name, "filemap:%s", CONF_FILENAME);
+ r = idn_mapper_add(ctx, name);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_mapper_map(ctx, from, to, SIZEOFUCS4(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, expected_default);
+}
+
+//# TESTCASE
+// title: idn_mapper_add() - file - one item in one line #1
+// group: generic quiet
+{
+ char name[BUF_SIZE];
+ unsigned long to[3];
+ unsigned long expected[] = {
+ 0x0061,
+ UCS4_NAME,
+ 0x0000
+ };
+
+ create_conf_file(CONF_FILENAME, 0,
+ "0041; 0061;",
+ "0042;",
+ NULL);
+ sprintf(name, "filemap:%s", CONF_FILENAME);
+ r = idn_mapper_add(ctx, name);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_mapper_map(ctx, from, to, SIZEOFUCS4(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, expected);
+}
+
+//# TESTCASE
+// title: idn_mapper_add() - file - one item in one line #2
+// group: generic quiet
+{
+ char name[BUF_SIZE];
+ unsigned long to[3];
+ unsigned long expected[] = {
+ 0x0061,
+ UCS4_NAME,
+ 0x0000
+ };
+
+ create_conf_file(CONF_FILENAME, 0,
+ "0041; 0061;",
+ "0042; ;",
+ NULL);
+ sprintf(name, "filemap:%s", CONF_FILENAME);
+ r = idn_mapper_add(ctx, name);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_mapper_map(ctx, from, to, SIZEOFUCS4(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, expected);
+}
+
+//# TESTCASE
+// title: idn_mapper_add() - file - more then two items in one line #1
+// group: generic quiet
+{
+ char name[BUF_SIZE];
+ unsigned long to[4];
+
+ create_conf_file(CONF_FILENAME, 0,
+ "0041; 0061; 0062;",
+ "0042; 0062; 0063;",
+ NULL);
+ sprintf(name, "filemap:%s", CONF_FILENAME);
+ r = idn_mapper_add(ctx, name);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_mapper_map(ctx, from, to, SIZEOFUCS4(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, expected_default);
+}
+
+//# TESTCASE
+// title: idn_mapper_add() - file - more then two items in one line #2
+// group: generic quiet
+{
+ char name[BUF_SIZE];
+ unsigned long to[6];
+ unsigned long expected_to[] = {
+ 0x0061,
+ 0x0062,
+ 0x0062,
+ 0x0063,
+ UCS4_NAME,
+ 0x0000
+ };
+
+ create_conf_file(CONF_FILENAME, 0,
+ "0041; 0061 0062;",
+ "0042; 0062 0063;",
+ NULL);
+ sprintf(name, "filemap:%s", CONF_FILENAME);
+ r = idn_mapper_add(ctx, name);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_mapper_map(ctx, from, to, SIZEOFUCS4(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, expected_to);
+}
+
+//# TESTCASE
+// title: idn_mapper_add() - file - more then two items in one line #3
+// group: generic quiet
+{
+ char name[BUF_SIZE];
+ unsigned long to[3];
+
+ create_conf_file(CONF_FILENAME, 0,
+ "0041 0042; 0063;",
+ NULL);
+ sprintf(name, "filemap:%s", CONF_FILENAME);
+ r = idn_mapper_add(ctx, name);
+ ASSERT_RESULT(r, idn_invalid_syntax);
+}
+
+//# TESTCASE
+// title: idn_mapper_addall() - add all builtin schemes
+// group: addall quiet
+{
+ strcpy(names[0], "RFC3491");
+ strcpy(names[1], "RFC3491");
+ strcpy(names[2], "RFC3491");
+ strcpy(names[3], "RFC3491");
+ strcpy(names[4], "RFC3491");
+ strcpy(names[5], "RFC3491");
+ strcpy(names[6], "RFC3491");
+ strcpy(names[7], "RFC3491");
+ strcpy(names[8], "RFC3491");
+
+ r = idn_mapper_addall(ctx, (const char **)names, 9);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_mapper_map(ctx, from, to, SIZEOFUCS4(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, expected_default);
+}
+
+//# TESTCASE
+// title: idn_mapper_addall() - add same scheme repetedly
+// group: addall quiet
+{
+ for (i = 0; i < ARRAY_SIZE; i++) {
+ strcpy(names[i], "RFC3491");
+ }
+ r = idn_mapper_addall(ctx, (const char **)names, 3);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_mapper_map(ctx, from, to, SIZEOFUCS4(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, expected_default);
+}
+
+//# TESTCASE
+// title: idn_mapper_map() - builtin schemes check - RFC3491
+// group: generic quiet
+{
+ unsigned long to[4];
+
+ r = idn_mapper_add(ctx, "RFC3491");
+ ASSERT_RESULT(r, idn_success);
+ r = idn_mapper_map(ctx, from, to, SIZEOFUCS4(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, expected_default);
+}
+
+//# TESTCASE
+// title: idn_mapper_map() - context without procedure
+// group: generic
+{
+ unsigned long to[4];
+
+ r = idn_mapper_map(ctx, from, to, SIZEOFUCS4(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, from);
+}
+
+//# TESTCASE
+// title: idn_mapper_destroy(), idn_mapper_incrref()
+// group:
+{
+ idn_result_t r;
+ idn_mapper_t ctx = NULL;
+
+ r = idn_mapper_initialize();
+ ASSERT_RESULT(r, idn_success);
+ r = idn_mapper_create(&ctx);
+ ASSERT_RESULT(r, idn_success);
+ idn_mapper_incrref(ctx);
+ idn_mapper_destroy(ctx);
+ idn_mapper_destroy(ctx);
+}
+
+//# TESTCASE
+// title: idn_mapper_register()
+// group: generic quiet
+{
+ unsigned long to[10];
+
+ r = idn_mapper_register("test", test_create, test_destroy, test_map);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_mapper_add(ctx, "test");
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_mapper_map(ctx, from, to, SIZEOFUCS4(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, from);
+}
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/mapselector.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/mapselector.tsy
new file mode 100644
index 0000000..1484f6c
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/mapselector.tsy
@@ -0,0 +1,592 @@
+#ifndef lint
+static char *rcsid = "$Id: mapselector.tsy,v 1.1.1.1 2003/06/04 00:26:55 marka Exp $";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <idn/mapselector.h>
+#include <idn/ucs4.h>
+#include <idn/log.h>
+
+#include "testutil.h"
+
+#define CONF_FILENAME "test.conf"
+#define MAP_FILENAME "test.map"
+
+/*
+ * Sample TLDs.
+ */
+static const char *utf8_tlds_jp[] = {"jp", ".jp", "JP", ".JP"};
+static const char *utf8_tlds_tw[] = {"tw", ".tw", "TW", ".TW"};
+
+static const unsigned long ucs4_tlds_jp[][4] = {{'j', 'p', '\0', '\0'},
+ {'.', 'j', 'p', '\0'},
+ {'J', 'P', '\0', '\0'},
+ {'.', 'J', 'P', '\0'}};
+
+static const unsigned long ucs4_tlds_tw[][4] = {{'t', 'w', '\0', '\0'},
+ {'.', 't', 'w', '\0'},
+ {'T', 'W', '\0', '\0'},
+ {'.', 'T', 'W', '\0'}};
+
+/* How many elements in `utf8_tlds_{jp|tw}[]' and `ucs4_tlds_{jp|tw}[]'. */
+#define TLD_NVARIANTS 4
+
+/*
+ * Sample input string for mapping. (UCS4)
+ */
+static const unsigned long in_string[] = {0x00C0, 0x2212, 0};
+
+/*
+ * Sample mapping results of IN_STRING.
+ *
+ * OUT_STRING_FILEMAP is the result of file-mapping (U+2212 -> U+002D).
+ * OUT_STRING_NAMEPREP is the result of the latest nameprep
+ * OUT_STRING_BOTH is the result of both file-mapping and nameprep.
+ */
+static const unsigned long out_string_filemap[] = {0x00C0, 0x002D, 0};
+static const unsigned long out_string_nameprep[] = {0x00E0, 0x2212, 0};
+static const unsigned long out_string_both[] = {0x00E0, 0x002D, 0};
+
+#define MAP_FILENAME "test.map"
+
+//--------------------------------------------------------------------
+// Setups and Teardowns.
+//--------------------------------------------------------------------
+
+//# SETUP
+// group: generic-init
+{
+ idn_result_t r;
+ idn_mapselector_t ctxs[TLD_NVARIANTS];
+ unsigned long to[256];
+
+ {
+ int i;
+ for (i = 0; i < TLD_NVARIANTS; i++)
+ ctxs[i] = NULL;
+ }
+
+ r = idn_mapselector_initialize();
+ ASSERT_RESULT(r, idn_success);
+
+ {
+ int i;
+ for (i = 0; i < TLD_NVARIANTS; i++) {
+ r = idn_mapselector_create(&ctxs[i]);
+ ASSERT_RESULT(r, idn_success);
+ }
+ }
+}
+
+//# TEARDOWN
+// group: generic-init
+{
+ {
+ int i;
+
+ for (i = 0; i < TLD_NVARIANTS; i++) {
+ if (ctxs[i] != NULL)
+ idn_mapselector_destroy(ctxs[i]);
+ remove(CONF_FILENAME);
+ }
+ }
+}
+
+//# SETUP
+// group: quiet
+{
+ int saved_log_level;
+
+ saved_log_level = idn_log_getlevel();
+ idn_log_setlevel(idn_log_level_fatal);
+}
+
+//# TEARDOWN
+// group: quiet
+{
+ idn_log_setlevel(saved_log_level);
+}
+
+//# SETUP
+// group: generic-filemap
+{
+ create_conf_file(MAP_FILENAME, 0,
+ "U+2212; U+002D",
+ NULL);
+}
+
+//# TEARDOWN
+// group: generic-filemap
+{
+ remove(MAP_FILENAME);
+}
+
+//--------------------------------------------------------------------
+// Testcases.
+//--------------------------------------------------------------------
+
+//# TESTCASE
+// title: call initialize() twice.
+//
+{
+ idn_result_t r;
+
+ r = idn_mapselector_initialize();
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_mapselector_initialize();
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TESTCASE
+// title: call create()
+{
+ idn_result_t r;
+ idn_mapselector_t ctx;
+
+ r = idn_mapselector_initialize();
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_mapselector_create(&ctx);
+ ASSERT_RESULT(r, idn_success);
+
+ idn_mapselector_destroy(ctx);
+}
+
+//# TESTCASE
+// title: call add(filemap) and map()
+// group: generic-init generic-filemap
+{
+ int i, j;
+
+ for (i = 0; i < TLD_NVARIANTS; i++) {
+ r = idn_mapselector_add(ctxs[i], utf8_tlds_jp[i],
+ "filemap:" MAP_FILENAME);
+ ASSERT_RESULT(r, idn_success);
+ }
+
+ for (i = 0; i < TLD_NVARIANTS; i++) {
+ for (j = 0; j < TLD_NVARIANTS; j++) {
+ r = idn_mapselector_map(ctxs[i], in_string,
+ utf8_tlds_jp[j], to,
+ sizeof(to) / sizeof(*to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, out_string_filemap);
+
+ r = idn_mapselector_map(ctxs[i], in_string,
+ utf8_tlds_tw[j], to,
+ sizeof(to) / sizeof(*to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, in_string);
+ }
+ }
+}
+
+//# TESTCASE
+// title: call add(nameprep) and map()
+// group: generic-init generic-filemap
+{
+ int i, j;
+
+ for (i = 0; i < TLD_NVARIANTS; i++) {
+ r = idn_mapselector_add(ctxs[i], utf8_tlds_jp[i],
+ IDN_NAMEPREP_CURRENT);
+ ASSERT_RESULT(r, idn_success);
+ }
+
+ for (i = 0; i < TLD_NVARIANTS; i++) {
+ for (j = 0; j < TLD_NVARIANTS; j++) {
+ r = idn_mapselector_map(ctxs[i], in_string,
+ utf8_tlds_jp[j], to,
+ sizeof(to) / sizeof(*to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, out_string_nameprep);
+
+ r = idn_mapselector_map(ctxs[i], in_string,
+ utf8_tlds_tw[j], to,
+ sizeof(to) / sizeof(*to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, in_string);
+ }
+ }
+}
+
+//# TESTCASE
+// title: call add(filemap) and map2()
+// group: generic-init generic-filemap
+{
+ int i, j;
+
+ for (i = 0; i < TLD_NVARIANTS; i++) {
+ r = idn_mapselector_add(ctxs[i], utf8_tlds_jp[i],
+ "filemap:" MAP_FILENAME);
+ ASSERT_RESULT(r, idn_success);
+ }
+
+ for (i = 0; i < TLD_NVARIANTS; i++) {
+ for (j = 0; j < TLD_NVARIANTS; j++) {
+ r = idn_mapselector_map2(ctxs[i], in_string,
+ ucs4_tlds_jp[j], to,
+ sizeof(to) / sizeof(*to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, out_string_filemap);
+
+ r = idn_mapselector_map2(ctxs[i], in_string,
+ ucs4_tlds_tw[j], to,
+ sizeof(to) / sizeof(*to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, in_string);
+ }
+ }
+}
+
+//# TESTCASE
+// title: call add(nameprep) and map2()
+// group: generic-init generic-filemap
+{
+ int i, j;
+
+ for (i = 0; i < TLD_NVARIANTS; i++) {
+ r = idn_mapselector_add(ctxs[i], utf8_tlds_jp[i],
+ IDN_NAMEPREP_CURRENT);
+ ASSERT_RESULT(r, idn_success);
+ }
+
+ for (i = 0; i < TLD_NVARIANTS; i++) {
+ for (j = 0; j < TLD_NVARIANTS; j++) {
+ r = idn_mapselector_map2(ctxs[i], in_string,
+ ucs4_tlds_jp[j], to,
+ sizeof(to) / sizeof(*to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, out_string_nameprep);
+
+ r = idn_mapselector_map2(ctxs[i], in_string,
+ ucs4_tlds_tw[j], to,
+ sizeof(to) / sizeof(*to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, in_string);
+ }
+ }
+}
+
+//# TESTCASE
+// title: call add(filemap) and map()
+// group: generic-init generic-filemap
+{
+ int i, j;
+
+ for (i = 0; i < TLD_NVARIANTS; i++) {
+ r = idn_mapselector_add(ctxs[i], utf8_tlds_jp[i],
+ "filemap:" MAP_FILENAME);
+ ASSERT_RESULT(r, idn_success);
+ }
+
+ for (i = 0; i < TLD_NVARIANTS; i++) {
+ for (j = 0; j < TLD_NVARIANTS; j++) {
+ r = idn_mapselector_map(ctxs[i], in_string,
+ utf8_tlds_jp[j], to,
+ sizeof(to) / sizeof(*to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, out_string_filemap);
+
+ r = idn_mapselector_map(ctxs[i], in_string,
+ utf8_tlds_tw[j], to,
+ sizeof(to) / sizeof(*to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, in_string);
+ }
+ }
+}
+
+//# TESTCASE
+// title: call add(nameprep) and map()
+// group: generic-init generic-filemap
+{
+ int i, j;
+
+ for (i = 0; i < TLD_NVARIANTS; i++) {
+ r = idn_mapselector_add(ctxs[i], utf8_tlds_jp[i],
+ IDN_NAMEPREP_CURRENT);
+ ASSERT_RESULT(r, idn_success);
+ }
+
+ for (i = 0; i < TLD_NVARIANTS; i++) {
+ for (j = 0; j < TLD_NVARIANTS; j++) {
+ r = idn_mapselector_map(ctxs[i], in_string,
+ utf8_tlds_jp[j], to,
+ sizeof(to) / sizeof(*to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, out_string_nameprep);
+
+ r = idn_mapselector_map(ctxs[i], in_string,
+ utf8_tlds_tw[j], to,
+ sizeof(to) / sizeof(*to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, in_string);
+ }
+ }
+}
+
+//# TESTCASE
+// title: call addall()
+// group: generic-init generic-filemap
+{
+ static const char *names[] = {
+ "filemap:" MAP_FILENAME,
+ IDN_NAMEPREP_CURRENT
+ };
+ int i, j;
+
+ for (i = 0; i < TLD_NVARIANTS; i++) {
+ r = idn_mapselector_addall(ctxs[i], utf8_tlds_jp[i], names,
+ sizeof(names) / sizeof(*names));
+ ASSERT_RESULT(r, idn_success);
+ }
+
+ for (i = 0; i < TLD_NVARIANTS; i++) {
+ for (j = 0; j < TLD_NVARIANTS; j++) {
+ r = idn_mapselector_map2(ctxs[i], in_string,
+ ucs4_tlds_jp[j], to,
+ sizeof(to) / sizeof(*to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, out_string_both);
+
+ r = idn_mapselector_map2(ctxs[i], in_string,
+ ucs4_tlds_tw[j], to,
+ sizeof(to) / sizeof(*to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, in_string);
+ }
+ }
+}
+
+//# TESTCASE
+// title: call addall() with nnames=0
+// group: generic-init
+{
+ static const char *names[] = {IDN_NAMEPREP_CURRENT};
+
+ r = idn_mapselector_addall(ctxs[0], ".", names, 0);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TESTCASE
+// title: call add() with empty tld
+// group: generic-init
+{
+ r = idn_mapselector_add(ctxs[0], "", IDN_NAMEPREP_CURRENT);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TESTCASE
+// title: call addall() with empty tld
+// group: generic-init
+{
+ static const char *names[] = {IDN_NAMEPREP_CURRENT};
+
+ r = idn_mapselector_addall(ctxs[0], "", names, 1);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TESTCASE
+// title: call add() with too long tld
+// group: generic-init quiet
+{
+ r = idn_mapselector_add(ctxs[0],
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "ABCDEFGHIJK",
+ IDN_NAMEPREP_CURRENT);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_mapselector_add(ctxs[0],
+ "."
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "ABCDEFGHIJK",
+ IDN_NAMEPREP_CURRENT);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_mapselector_add(ctxs[0],
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "ABCDEFGHIJKL",
+ IDN_NAMEPREP_CURRENT);
+ ASSERT_RESULT(r, idn_invalid_name);
+
+ r = idn_mapselector_add(ctxs[0],
+ "."
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "ABCDEFGHIJKL",
+ IDN_NAMEPREP_CURRENT);
+ ASSERT_RESULT(r, idn_invalid_name);
+}
+
+//# TESTCASE
+// title: call addall() with too long tld
+// group: generic-init quiet
+{
+ static const char *names[] = {IDN_NAMEPREP_CURRENT};
+
+ r = idn_mapselector_addall(ctxs[0],
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "ABCDEFGHIJK",
+ names, 1);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_mapselector_addall(ctxs[0],
+ "."
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "ABCDEFGHIJK",
+ names, 1);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_mapselector_addall(ctxs[0],
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "ABCDEFGHIJKL",
+ names, 1);
+ ASSERT_RESULT(r, idn_invalid_name);
+
+ r = idn_mapselector_addall(ctxs[0],
+ "."
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "ABCDEFGHIJKL",
+ names, 1);
+ ASSERT_RESULT(r, idn_invalid_name);
+}
+
+//# TESTCASE
+// title: overrun test for arg `to' of map()
+// group: generic-init
+{
+ r = idn_mapselector_add(ctxs[0], utf8_tlds_jp[0],
+ IDN_NAMEPREP_CURRENT);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_mapselector_map(ctxs[0], in_string, utf8_tlds_jp[0], to,
+ idn_ucs4_strlen(out_string_nameprep) + 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, out_string_nameprep);
+
+ r = idn_mapselector_map(ctxs[0], in_string, utf8_tlds_tw[0], to,
+ idn_ucs4_strlen(in_string) + 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, in_string);
+
+ r = idn_mapselector_map(ctxs[0], in_string, utf8_tlds_jp[0], to,
+ idn_ucs4_strlen(out_string_nameprep));
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ r = idn_mapselector_map(ctxs[0], in_string, utf8_tlds_tw[0], to,
+ idn_ucs4_strlen(in_string));
+ ASSERT_RESULT(r, idn_buffer_overflow);
+}
+
+//# TESTCASE
+// title: overrun test for arg `to' of map2()
+// group: generic-init
+{
+ r = idn_mapselector_add(ctxs[0], utf8_tlds_jp[0],
+ IDN_NAMEPREP_CURRENT);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_mapselector_map2(ctxs[0], in_string, ucs4_tlds_jp[0], to,
+ idn_ucs4_strlen(out_string_nameprep) + 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, out_string_nameprep);
+
+ r = idn_mapselector_map2(ctxs[0], in_string, ucs4_tlds_tw[0], to,
+ idn_ucs4_strlen(in_string) + 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, in_string);
+
+ r = idn_mapselector_map2(ctxs[0], in_string, ucs4_tlds_jp[0], to,
+ idn_ucs4_strlen(out_string_nameprep));
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ r = idn_mapselector_map2(ctxs[0], in_string, ucs4_tlds_tw[0], to,
+ idn_ucs4_strlen(in_string));
+ ASSERT_RESULT(r, idn_buffer_overflow);
+}
+
+//# TESTCASE
+// title: call map() with tolen=0
+// group: generic-init
+{
+ r = idn_mapselector_add(ctxs[0], utf8_tlds_jp[0],
+ IDN_NAMEPREP_CURRENT);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_mapselector_map(ctxs[0], in_string, utf8_tlds_jp[0], to, 0);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ r = idn_mapselector_map(ctxs[0], in_string, utf8_tlds_tw[0], to, 0);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+}
+
+//# TESTCASE
+// title: call map2() with tolen=0
+// group: generic-init
+{
+ r = idn_mapselector_add(ctxs[0], utf8_tlds_jp[0],
+ IDN_NAMEPREP_CURRENT);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_mapselector_map2(ctxs[0], in_string, ucs4_tlds_jp[0], to, 0);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ r = idn_mapselector_map2(ctxs[0], in_string, ucs4_tlds_tw[0], to, 0);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+}
+
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/nameprep.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/nameprep.tsy
new file mode 100644
index 0000000..bba49c7
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/nameprep.tsy
@@ -0,0 +1,340 @@
+#ifndef lint
+static char *rcsid = "$Id: nameprep.tsy,v 1.1.1.1 2003/06/04 00:26:56 marka Exp $";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <idn/nameprep.h>
+#include <idn/log.h>
+#include "testutil.h"
+
+#define UCS4_NAME 0x304C /* hiragana letter ga */
+#define BUF_SIZE 4
+/*
+ * Sample string for `from' argument for map(),
+ * and its expected outputs.
+ */
+static const unsigned long map_from[] = {
+ 0x0041, /* latin capital letter a */
+ 0x0042, /* latin capital letter b */
+ UCS4_NAME,
+ 0x0000
+};
+
+static const unsigned long map_expected[] = {
+ 0x0061, /* latin small letter a */
+ 0x0062, /* latin small letter b */
+ UCS4_NAME,
+ 0x0000
+};
+
+/*
+ * Sample string for `from' argument for isprohibited().
+ */
+static const unsigned long check_from[4] = {
+ UCS4_NAME,
+ 0x00A0, /* no-break space: prohibited character */
+ 0x0221, /* unassigned character */
+ 0x0000
+};
+
+#define FROM_UCS4NAME_OFFSET 0
+#define FROM_PROH_OFFSET 1
+#define FROM_UNAS_OFFSET 2
+
+/*
+ * Sample string for `from' argument for isunassigned().
+ */
+static const unsigned long check_from2[4] = {
+ UCS4_NAME,
+ 0x0221, /* unassigned character */
+ 0x00A0, /* no-break space: prohibited character */
+ 0x0000
+};
+
+#define FROM2_UCS4NAME_OFFSET 0
+#define FROM2_PROH_OFFSET 2
+#define FROM2_UNAS_OFFSET 1
+
+/*
+ * Sample string for `from' argument for isvalidbidi().
+ * (It is not a valid bidi label.)
+ */
+static const unsigned long bidi_from[4] = {
+ 0x05BE, /* hebrew punctuation maqaf */
+ 0x0041, /* latin capital letter a */
+ 0xFEFC, /* arabic ligature lam with alef final form */
+ 0x0000
+};
+#define BIDIFROM_OFFSET 1
+
+/*
+ * Empty string.
+ */
+static const unsigned long ucs4_nullstr[] = {
+ 0x0000
+};
+
+//--------------------------------------------------------------------
+// Setups and Teardowns.
+//--------------------------------------------------------------------
+
+//# SETUP
+// group: generic
+//--
+// Nothing happens.
+{
+ idn_result_t r;
+ idn_nameprep_t handle = NULL;
+
+}
+
+//# SETUP
+// group: check
+//--
+// Initialize the module and create contexts.
+{
+ idn_result_t r;
+ idn_nameprep_t handle11 = NULL;
+
+ r = idn_nameprep_create("RFC3491", &handle11);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TEARDOWN
+// group: check
+//--
+// Destroy contexts.
+{
+ if (handle11 != NULL) {
+ idn_nameprep_destroy(handle11);
+ }
+}
+
+//# SETUP
+// group: quiet
+//--
+// Set log level to `fatal' to supress log messages.
+{
+ int saved_log_level;
+
+ saved_log_level = idn_log_getlevel();
+ idn_log_setlevel(idn_log_level_fatal);
+}
+
+//# TEARDOWN
+// group: quiet
+//--
+// Restore log level.
+{
+ idn_log_setlevel(saved_log_level);
+}
+
+//--------------------------------------------------------------------
+// Testcases.
+//--------------------------------------------------------------------
+
+//# TESTCASE
+// title: idn_nameprep_create() - boundary condition
+// group: generic quiet
+{
+ r = idn_nameprep_create("", &handle);
+ ASSERT_RESULT(r, idn_notfound);
+}
+
+//# TESTCASE
+// title: idn_nameprep_create() - version is NULL (current nameprep)
+// group: generic quiet
+{
+ unsigned long to[BUF_SIZE];
+ const unsigned long *found;
+
+ r = idn_nameprep_create(NULL, &handle);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_nameprep_map(handle, map_from, to, BUF_SIZE);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, map_expected);
+
+ r = idn_nameprep_isunassigned(handle, check_from, &found);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(found, check_from + FROM_UNAS_OFFSET);
+
+ r = idn_nameprep_isprohibited(handle, check_from, &found);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(found, check_from + FROM_PROH_OFFSET);
+
+ r = idn_nameprep_isvalidbidi(handle, bidi_from, &found);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(found, bidi_from + BIDIFROM_OFFSET);
+
+ idn_nameprep_destroy(handle);
+}
+
+//# TESTCASE
+// title: idn_nameprep_create() - nameprep-01
+// group: generic quiet
+{
+ r = idn_nameprep_create("nameprep-01", &handle);
+ ASSERT_RESULT(r, idn_notfound);
+}
+
+//# TESTCASE
+// title: idn_nameprep_create() - RFC3491
+// group: generic
+{
+ r = idn_nameprep_create("RFC3491", &handle);
+ ASSERT_RESULT(r, idn_success);
+ idn_nameprep_destroy(handle);
+}
+
+//# TESTCASE
+// title: idn_nameprep_map() - boundary condition
+// group: check
+{
+ unsigned long to[BUF_SIZE];
+
+ r = idn_nameprep_map(handle11, ucs4_nullstr, to, 0);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+ r = idn_nameprep_map(handle11, ucs4_nullstr, to, 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, ucs4_nullstr);
+}
+
+//# TESTCASE
+// title: idn_nameprep_map() - RFC3491
+// group: check
+{
+ unsigned long to[BUF_SIZE];
+
+ r = idn_nameprep_map(handle11, map_from, to, 0);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+ r = idn_nameprep_map(handle11, map_from, to, BUF_SIZE - 1);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+ r = idn_nameprep_map(handle11, map_from, to, BUF_SIZE);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, map_expected);
+}
+
+//# TESTCASE
+// title: idn_nameprep_isunassigned() - boundary condition
+// group: check
+{
+ const unsigned long *found;
+
+ r = idn_nameprep_isunassigned(handle11, ucs4_nullstr, &found);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(found, NULL);
+}
+
+//# TESTCASE
+// title: idn_nameprep_isunassigned() - RFC3491
+// group: check
+{
+ const unsigned long *found;
+
+ r = idn_nameprep_isunassigned(handle11, check_from, &found);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(found, check_from + FROM_UNAS_OFFSET);
+
+ r = idn_nameprep_isunassigned(handle11, check_from2, &found);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(found, check_from2 + FROM2_UNAS_OFFSET);
+}
+
+//# TESTCASE
+// title: idn_nameprep_isprohibited() - boundary condition
+// group: check
+{
+ const unsigned long *found;
+
+ r = idn_nameprep_isprohibited(handle11, ucs4_nullstr, &found);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(found, NULL);
+}
+
+//# TESTCASE
+// title: idn_nameprep_isprohibited() - RFC3491
+// group: check
+{
+ const unsigned long *found;
+
+ r = idn_nameprep_isprohibited(handle11, check_from, &found);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(found, check_from + FROM_PROH_OFFSET);
+
+ r = idn_nameprep_isprohibited(handle11, check_from2, &found);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(found, check_from2 + FROM2_PROH_OFFSET);
+}
+
+//# TESTCASE
+// title: idn_nameprep_isvalidbidi() - boundary condition
+// group: check
+{
+ const unsigned long *found;
+
+ r = idn_nameprep_isvalidbidi(handle11, ucs4_nullstr, &found);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(found, NULL);
+}
+
+//# TESTCASE
+// title: idn_nameprep_isvalidbidi() - RFC3491
+// group: check
+{
+ const unsigned long *found;
+
+ r = idn_nameprep_isvalidbidi(handle11, bidi_from, &found);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(found, bidi_from + BIDIFROM_OFFSET);
+
+ r = idn_nameprep_isvalidbidi(handle11, check_from2, &found);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_PTR(found, NULL);
+}
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/normalizer.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/normalizer.tsy
new file mode 100644
index 0000000..dc9906d
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/normalizer.tsy
@@ -0,0 +1,346 @@
+#ifndef lint
+static char *rcsid = "$Id: normalizer.tsy,v 1.1.1.1 2003/06/04 00:26:57 marka Exp $";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <idn/normalizer.h>
+#include <idn/log.h>
+#include <idn/ucs4.h>
+
+#define BUF_SIZE 64
+#define TOBUF_SIZE 4
+#define ARRAY_SIZE 20
+#define CONF_FILENAME "test.map"
+
+/*
+ * Sample string for `from' argument of normalize(),
+ * and its expected outputs.
+ */
+static const unsigned long from[4] = {
+ 0x304B, /* hiragana letter ka */
+ 0x3099, /* combining katakana-hiragana voiced sound mark */
+ 0x32D0, /* circled katakana a */
+ 0x0000
+};
+
+static const unsigned long normalized_kc_str[3] = {
+ 0x304C, /* hiragana letter ga */
+ 0x30A2, /* katakana letter a */
+ 0x0000
+};
+
+static const unsigned long normalized_c_str[3] = {
+ 0x304C, /* hiragana letter ga */
+ 0x32D0, /* circled katakana a */
+ 0x0000
+};
+
+idn_result_t
+test_proc(const unsigned long *from, unsigned long *to, size_t tolen)
+{
+ if (tolen > idn_ucs4_strlen(from)) {
+ idn_ucs4_strcpy(to, from);
+ } else {
+ return (idn_buffer_overflow);
+ }
+
+ return (idn_success);
+}
+
+//--------------------------------------------------------------------
+// Setups and Teardowns.
+//--------------------------------------------------------------------
+
+//# SETUP
+// group: noinit
+//--
+// Do nothing
+{
+ idn_result_t r;
+ const char *name;
+}
+
+//# SETUP
+// group: generic
+//--
+// Initialize the module and create context.
+{
+ idn_result_t r;
+ idn_normalizer_t ctx = NULL;
+
+ r = idn_normalizer_initialize();
+ ASSERT_RESULT(r, idn_success);
+ r = idn_normalizer_create(&ctx);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TEARDOWN
+// group: generic
+//--
+// Destroy context.
+{
+ idn_normalizer_destroy(ctx);
+}
+
+//# SETUP
+// group: addall
+//--
+// Initialize the module and create context.
+{
+ idn_result_t r;
+ idn_normalizer_t ctx = NULL;
+ char *names[ARRAY_SIZE];
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE; i++) {
+ names[i] = malloc(BUF_SIZE);
+ if (names[i] == NULL) {
+ ASSERT("malloc failed\n");
+ }
+ }
+
+ strcpy(names[0], "RFC3491");
+ strcpy(names[1], "unicode-form-kc");
+ strcpy(names[2], "unicode-form-kc/3.2.0");
+ strcpy(names[3], "RFC3491");
+ strcpy(names[4], "unicode-form-kc");
+ strcpy(names[5], "unicode-form-kc/3.2.0");
+ strcpy(names[6], "RFC3491");
+ strcpy(names[7], "unicode-form-kc");
+ strcpy(names[8], "unicode-form-kc/3.2.0");
+ strcpy(names[9], "RFC3491");
+ strcpy(names[10], "unicode-form-kc");
+ strcpy(names[11], "unicode-form-kc/3.2.0");
+ strcpy(names[12], "RFC3491");
+ strcpy(names[13], "unicode-form-kc");
+ strcpy(names[14], "unicode-form-kc/3.2.0");
+ strcpy(names[15], "RFC3491");
+ strcpy(names[16], "unicode-form-kc");
+ strcpy(names[17], "unicode-form-kc/3.2.0");
+ strcpy(names[18], "RFC3491");
+ strcpy(names[19], "unicode-form-kc");
+
+ r = idn_normalizer_initialize();
+ ASSERT_RESULT(r, idn_success);
+ r = idn_normalizer_create(&ctx);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TEARDOWN
+// group: addall
+//--
+// Destroy context.
+{
+ idn_normalizer_destroy(ctx);
+ for (i = 0; i < ARRAY_SIZE; i++) {
+ free(names[i]);
+ }
+}
+
+//# SETUP
+// group: quiet
+//--
+// Set log level to `fatal' to supress log messages.
+{
+ int saved_log_level;
+
+ saved_log_level = idn_log_getlevel();
+ idn_log_setlevel(idn_log_level_fatal);
+}
+
+//# TEARDOWN
+// group: quiet
+//--
+// Restore log level.
+{
+ idn_log_setlevel(saved_log_level);
+}
+
+//--------------------------------------------------------------------
+// Testcases.
+//--------------------------------------------------------------------
+
+//# TESTCASE
+// title: idn_normalizer_add() - boundary condition
+// group: generic quiet
+{
+ r = idn_normalizer_add(ctx, "");
+ ASSERT_RESULT(r, idn_invalid_name);
+}
+
+//# TESTCASE
+// title: idn_normalizer_add() - builtin schemes
+// group: generic quiet
+{
+ r = idn_normalizer_add(ctx, "RFC3491");
+ ASSERT_RESULT(r, idn_success);
+ r = idn_normalizer_add(ctx, "unicode-form-kc");
+ ASSERT_RESULT(r, idn_success);
+ r = idn_normalizer_add(ctx, "unicode-form-kc/3.2.0");
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_normalizer_add(ctx, "nameprep-01");
+ ASSERT_RESULT(r, idn_invalid_name);
+}
+
+//# TESTCASE
+// title: idn_normalizer_addall() - boundary condition
+// group: addall quiet
+{
+ strcpy(names[3], "");
+ r = idn_normalizer_addall(ctx, (const char **)names, ARRAY_SIZE);
+ ASSERT_RESULT(r, idn_invalid_name);
+}
+
+//# TESTCASE
+// title: idn_normalizer_addall() - nschemes is 0
+// group: addall quiet
+{
+ r = idn_normalizer_addall(ctx, (const char **)names, 0);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TESTCASE
+// title: idn_normalizer_addall() - add a lot of schemes
+// group: addall quiet
+{
+ unsigned long to[TOBUF_SIZE];
+
+ r = idn_normalizer_addall(ctx, (const char **)names, ARRAY_SIZE);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_normalizer_normalize(ctx, from, to, TOBUF_SIZE);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, normalized_kc_str);
+}
+
+//# TESTCASE
+// title: idn_normalizer_addall() - add same scheme repetedly
+// group: addall quiet
+{
+ int i;
+ unsigned long to[TOBUF_SIZE];
+
+ for (i = 0; i < ARRAY_SIZE; i++) {
+ strcpy(names[i], "RFC3491");
+ }
+ r = idn_normalizer_addall(ctx, (const char **)names, ARRAY_SIZE);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_normalizer_normalize(ctx, from, to, TOBUF_SIZE);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, normalized_kc_str);
+}
+
+//# TESTCASE
+// title: idn_normalizer_normalize() - schemes check - RFC3491
+// group: generic quiet
+{
+ unsigned long to[TOBUF_SIZE];
+
+ r = idn_normalizer_add(ctx, "RFC3491");
+ ASSERT_RESULT(r, idn_success);
+ r = idn_normalizer_normalize(ctx, from, to, TOBUF_SIZE);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, normalized_kc_str);
+}
+
+//# TESTCASE
+// title: idn_normalizer_normalize() - schemes check - unicode-form-kc/3.2.0
+// group: generic quiet
+{
+ unsigned long to[TOBUF_SIZE];
+
+ r = idn_normalizer_add(ctx, "unicode-form-kc/3.2.0");
+ ASSERT_RESULT(r, idn_success);
+ r = idn_normalizer_normalize(ctx, from, to, TOBUF_SIZE);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, normalized_kc_str);
+}
+
+//# TESTCASE
+// title: idn_normalizer_normalize() - context without procedure
+// group: generic quiet
+{
+ unsigned long to[TOBUF_SIZE];
+
+ r = idn_normalizer_normalize(ctx, from, to, TOBUF_SIZE);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, from);
+}
+
+//# TESTCASE
+// title: idn_normalizer_destroy(), idn_normalizer_incrref()
+// group:
+{
+ idn_result_t r;
+ idn_normalizer_t ctx = NULL;
+
+ r = idn_normalizer_initialize();
+ ASSERT_RESULT(r, idn_success);
+ r = idn_normalizer_create(&ctx);
+ ASSERT_RESULT(r, idn_success);
+ idn_normalizer_incrref(ctx);
+ idn_normalizer_destroy(ctx);
+ idn_normalizer_destroy(ctx);
+}
+
+//# TESTCASE
+// title: idn_normalizer_register()
+// group: generic quiet
+{
+ unsigned long to[TOBUF_SIZE];
+
+ r = idn_normalizer_register("test", test_proc);
+ ASSERT_RESULT(r, idn_success);
+ r = idn_normalizer_add(ctx, "test");
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_normalizer_normalize(ctx, from, to, TOBUF_SIZE);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, from);
+}
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/res.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/res.tsy
new file mode 100644
index 0000000..39c3895
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/res.tsy
@@ -0,0 +1,1026 @@
+#ifndef lint
+static char *rcsid = "$Id: res.tsy,v 1.1.1.1 2003/06/04 00:26:59 marka Exp $";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <idn/res.h>
+#include <idn/log.h>
+
+#include "codeset.h"
+#include "setenv.h"
+
+#ifndef EUCJP_ENCODING_NAME
+#define EUCJP_ENCODING_NAME "eucJP"
+#endif
+
+/*
+ * U+304B: hiragana letter KA
+ * U+3099: combining katakana-hiragana voiced sound mark
+ *
+ * map("U+304B U+3099") -> "U+304C"
+ *
+ * U+304C: hiragana letter GA
+ */
+#define UTF8_NAME "A<U+304B><U+3099>"
+#define UTF8_REVNAME "a<U+304C>"
+
+/*
+ * A4AC: hiragana letter GA (in EUC-JP)
+ */
+#define EUCJP_NAME "\xa4\xac"
+#define EUCJP_REVNAME "\xa4\xac"
+
+/*
+ * Conversion result of "U+304B U+3099 A"
+ */
+#define PUNYCODE_NAME "xn--a-i8t"
+
+/*
+ * Conversion result of "A U+304B U+3099" (in EUC-JP).
+ */
+#define AUX_EUCJP_NAME "xn--a-i\xa3\xb8t"
+
+//--------------------------------------------------------------------
+// Setups and Teardowns.
+//--------------------------------------------------------------------
+
+//# SETUP
+// group: generic-conversion
+//--
+// Initialize the `resconf' context.
+// Set local encoding to `UTF-8'.
+{
+ char to[256];
+ idn_result_t r;
+ idn_resconf_t ctx;
+
+ setenv("IDN_LOCAL_CODESET", "UTF-8", 1);
+ unsetenv("IDN_DISABLE");
+
+ r = idn_resconf_initialize();
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_resconf_create(&ctx);
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_resconf_setdefaults(ctx);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TEARDOWN
+// group: generic-conversion
+{
+ idn_resconf_destroy(ctx);
+}
+
+//# SETUP
+// group: quiet
+//--
+// Set log level to `fatal' to supress log messages.
+{
+ int saved_log_level;
+
+ saved_log_level = idn_log_getlevel();
+ idn_log_setlevel(idn_log_level_fatal);
+}
+
+//# TEARDOWN
+// group: quiet
+//--
+// Restore log level.
+{
+ idn_log_setlevel(saved_log_level);
+}
+
+//--------------------------------------------------------------------
+// Testcases.
+//--------------------------------------------------------------------
+
+//# TESTCASE
+// title: basic conversion by encodename()
+// group: generic-conversion
+{
+ r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, PUNYCODE_NAME);
+}
+
+//# TESTCASE
+// title: basic conversion by decodename()
+// group: generic-conversion
+{
+ r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_REVNAME);
+}
+
+//# TESTCASE
+// title: basic conversion by decodename2()
+// group: generic-conversion
+{
+ r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+#ifdef WITHOUT_ICONV
+ ASSERT_RESULT(r, idn_failure);
+#else
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_REVNAME);
+#endif
+}
+
+//# TESTCASE
+// title: call decodename2() with auxencoding=NULL
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_res_decodename2(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to),
+ NULL);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_REVNAME);
+#endif
+}
+
+//# TESTCASE
+// title: call encodename() with actions=0
+// group: generic-conversion
+{
+ r = idn_res_encodename(ctx, 0, UTF8_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_NAME);
+}
+
+//# TESTCASE
+// title: call decodename() with actions=0
+// group: generic-conversion
+{
+ r = idn_res_decodename(ctx, 0, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, PUNYCODE_NAME);
+}
+
+//# TESTCASE
+// title: call decodename2() with actions=0
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_res_decodename2(ctx, 0, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, AUX_EUCJP_NAME);
+#endif
+}
+
+//# TESTCASE
+// title: call encodename() with actions=rtcheck
+// group: generic-conversion quiet
+{
+ r = idn_res_encodename(ctx, IDN_RTCHECK, EUCJP_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+}
+
+//# TESTCASE
+// title: call encodename() with actions=decode-query
+// group: generic-conversion quiet
+{
+ r = idn_res_encodename(ctx, IDN_DECODE_QUERY, EUCJP_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+}
+
+//# TESTCASE
+// title: call encodename() with actions=decode-app
+// group: generic-conversion quiet
+{
+ r = idn_res_encodename(ctx, IDN_DECODE_APP, EUCJP_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+}
+
+//# TESTCASE
+// title: call encodename() with actions=decode-stored
+// group: generic-conversion quiet
+{
+ r = idn_res_encodename(ctx, IDN_DECODE_STORED, EUCJP_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+}
+
+//# TESTCASE
+// title: call encodename() with actions=(1<<31)
+// group: generic-conversion quiet
+{
+ r = idn_res_encodename(ctx, 1 << 31, EUCJP_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+}
+
+//# TESTCASE
+// title: call decodename() with actions=localmap
+// group: generic-conversion quiet
+{
+ r = idn_res_decodename(ctx, IDN_LOCALMAP, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+}
+
+//# TESTCASE
+// title: call decodename2() with actions=localmap
+// group: generic-conversion quiet
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_res_decodename2(ctx, IDN_LOCALMAP, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_invalid_action);
+#endif
+}
+
+//# TESTCASE
+// title: call decodename() with actions=lencheck
+// group: generic-conversion quiet
+{
+ r = idn_res_decodename(ctx, IDN_LENCHECK, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+}
+
+//# TESTCASE
+// title: call decodename2() with actions=lencheck
+// group: generic-conversion quiet
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_res_decodename2(ctx, IDN_LENCHECK, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_invalid_action);
+#endif
+}
+
+//# TESTCASE
+// title: call decodename() with actions=encode-query
+// group: generic-conversion quiet
+{
+ r = idn_res_decodename(ctx, IDN_ENCODE_QUERY, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+}
+
+//# TESTCASE
+// title: call decodename2() with actions=encode-query
+// group: generic-conversion quiet
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_res_decodename2(ctx, IDN_ENCODE_QUERY, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_invalid_action);
+#endif
+}
+
+//# TESTCASE
+// title: call decodename() with actions=encode-app
+// group: generic-conversion quiet
+{
+ r = idn_res_decodename(ctx, IDN_ENCODE_APP, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+}
+
+//# TESTCASE
+// title: call decodename2() with actions=encode-app
+// group: generic-conversion quiet
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_res_decodename2(ctx, IDN_ENCODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_invalid_action);
+#endif
+}
+
+//# TESTCASE
+// title: call decodename() with actions=encode-stored
+// group: generic-conversion quiet
+{
+ r = idn_res_decodename(ctx, IDN_ENCODE_STORED, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+}
+
+//# TESTCASE
+// title: call decodename2() with actions=encode-stored
+// group: generic-conversion quiet
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_res_decodename2(ctx, IDN_ENCODE_STORED, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_invalid_action);
+#endif
+}
+
+//# TESTCASE
+// title: call decodename() with actions=(1<<31)
+// group: generic-conversion quiet
+{
+ r = idn_res_decodename(ctx, 1 << 31, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+}
+
+//# TESTCASE
+// title: call decodename2() with actions=(1<<31)
+// group: generic-conversion quiet
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_res_decodename2(ctx, 1 << 31, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_invalid_action);
+#endif
+}
+
+//# TESTCASE
+// title: call encodename() with actions=localconv
+// group: generic-conversion quiet
+{
+#ifndef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_res_encodename(ctx, IDN_LOCALCONV, UTF8_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+#endif
+}
+
+//# TESTCASE
+// title: call decodename() with actions=localconv
+// group: generic-conversion quiet
+{
+#ifndef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_res_decodename(ctx, IDN_LOCALCONV, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_action);
+#endif
+}
+
+//# TESTCASE
+// title: call decodename2() with actions=localconv
+// group: generic-conversion
+{
+#ifndef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_res_decodename2(ctx, IDN_LOCALCONV, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_failure);
+#endif
+}
+
+//# TESTCASE
+// title: call enable(0) and then encodename()
+// group: generic-conversion
+{
+ idn_res_enable(0);
+ r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_NAME);
+}
+
+//# TESTCASE
+// title: call decodename() when IDN_DISABLE is defined
+// group: generic-conversion
+{
+ idn_res_enable(0);
+ r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, PUNYCODE_NAME);
+}
+
+//# TESTCASE
+// title: call decodename() when IDN_DISABLE is defined
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ idn_res_enable(0);
+ r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, AUX_EUCJP_NAME);
+#endif
+}
+
+//# TESTCASE
+// title: call enable(0) and then encodename()
+// group: generic-conversion
+{
+ idn_res_enable(0);
+ r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_NAME);
+}
+
+//# TESTCASE
+// title: call enable(0) and then decodename()
+// group: generic-conversion
+{
+ idn_res_enable(0);
+ r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, PUNYCODE_NAME);
+}
+
+//# TESTCASE
+// title: call enable(0) and then decodename2()
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ idn_res_enable(0);
+ r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, AUX_EUCJP_NAME);
+#endif
+}
+
+//# TESTCASE
+// title: set IDN_DISABLE and call encodename()
+// group: generic-conversion
+{
+ setenv("IDN_DISABLE", "1", 1);
+ r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_NAME);
+}
+
+//# TESTCASE
+// title: set IDN_DISABLE and call decodename()
+// group: generic-conversion
+{
+ setenv("IDN_DISABLE", "1", 1);
+ r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, PUNYCODE_NAME);
+}
+
+//# TESTCASE
+// title: set IDN_DISABLE and call decodename2()
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ setenv("IDN_DISABLE", "1", 1);
+ r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, AUX_EUCJP_NAME);
+#endif
+}
+
+//# TESTCASE
+// title: set IDN_DISABLE, and then call enable(1) and encodename()
+// group: generic-conversion
+{
+ setenv("IDN_DISABLE", "1", 1);
+ idn_res_enable(1);
+ r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, PUNYCODE_NAME);
+}
+
+//# TESTCASE
+// title: set IDN_DISABLE, and then call enable(1) and decodename()
+// group: generic-conversion
+{
+ setenv("IDN_DISABLE", "1", 1);
+ idn_res_enable(1);
+ r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_REVNAME);
+}
+
+//# TESTCASE
+// title: set IDN_DISABLE, and then call enable(1) and decodename2()
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ setenv("IDN_DISABLE", "1", 1);
+ idn_res_enable(1);
+ r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_REVNAME);
+#endif
+}
+
+//# TESTCASE
+// title: overrun test for arg `to' of encodename()
+// group: generic-conversion
+{
+ /* Normal case */
+ r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to,
+ strlen(PUNYCODE_NAME) + 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, PUNYCODE_NAME);
+
+ r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to,
+ strlen(PUNYCODE_NAME));
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ /* enable(0) case */
+ idn_res_enable(0);
+ r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to,
+ strlen(UTF8_NAME) + 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_NAME);
+
+ r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to,
+ strlen(UTF8_NAME));
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ /* actions=0 case */
+ idn_res_enable(1);
+ r = idn_res_encodename(ctx, 0, UTF8_NAME, to, strlen(UTF8_NAME) + 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_NAME);
+
+ r = idn_res_encodename(ctx, 0, UTF8_NAME, to, strlen(UTF8_NAME));
+ ASSERT_RESULT(r, idn_buffer_overflow);
+}
+
+//# TESTCASE
+// title: overrun test for arg `to' of decodename()
+// group: generic-conversion
+{
+ /* Normal case */
+ r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to,
+ strlen(UTF8_REVNAME) + 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_REVNAME);
+
+ r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to,
+ strlen(UTF8_REVNAME));
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ /* idn_res_enable(0) case */
+ idn_res_enable(0);
+ r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to,
+ strlen(PUNYCODE_NAME) + 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, PUNYCODE_NAME);
+
+ r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to,
+ strlen(PUNYCODE_NAME));
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ /* actions=0 case */
+ idn_res_enable(1);
+ r = idn_res_decodename(ctx, 0, PUNYCODE_NAME, to,
+ strlen(PUNYCODE_NAME) + 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, PUNYCODE_NAME);
+
+ r = idn_res_decodename(ctx, 0, PUNYCODE_NAME, to,
+ strlen(PUNYCODE_NAME));
+ ASSERT_RESULT(r, idn_buffer_overflow);
+}
+
+//# TESTCASE
+// title: overrun test for arg `to' of decodename2()
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ /* Normal case */
+ r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to,
+ strlen(UTF8_REVNAME) + 1, EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, UTF8_REVNAME);
+
+ r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to,
+ strlen(UTF8_REVNAME), EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ /* idn_res_enable(0) case */
+ idn_res_enable(0);
+ r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to,
+ strlen(AUX_EUCJP_NAME) + 1, EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, AUX_EUCJP_NAME);
+
+ r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to,
+ strlen(AUX_EUCJP_NAME), EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ /* actions=0 case */
+ idn_res_enable(1);
+ r = idn_res_decodename2(ctx, 0, AUX_EUCJP_NAME, to,
+ strlen(AUX_EUCJP_NAME) + 1, EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, AUX_EUCJP_NAME);
+
+ r = idn_res_decodename2(ctx, 0, AUX_EUCJP_NAME, to,
+ strlen(AUX_EUCJP_NAME), EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+#endif
+}
+
+//# TESTCASE
+// title: call encodename() with tolen=0
+// group: generic-conversion
+{
+ r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to, 0);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+}
+
+//# TESTCASE
+// title: call decodename() with tolen=0
+// group: generic-conversion
+{
+ r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to, 0);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+}
+
+//# TESTCASE
+// title: call decodename2() with tolen=0
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to, 0,
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+#endif
+}
+
+//# TESTCASE
+// title: convert an empty string using encodename()
+// group: generic-conversion
+{
+ r = idn_res_encodename(ctx, IDN_ENCODE_APP, "", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "");
+}
+
+//# TESTCASE
+// title: convert an empty string using decodename()
+// group: generic-conversion
+{
+ r = idn_res_decodename(ctx, IDN_DECODE_APP, "", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "");
+}
+
+//# TESTCASE
+// title: convert an empty string using decodename2()
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ r = idn_res_decodename2(ctx, IDN_DECODE_APP, "", to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "");
+#endif
+}
+
+//# TESTCASE
+// title: prohcheck by encodename()
+// group: generic-conversion
+{
+ /* U+1680: prohibited character */
+ r = idn_res_encodename(ctx, IDN_PROHCHECK, "<U+1680>", to, sizeof(to));
+ ASSERT_RESULT(r, idn_prohibited);
+}
+
+//# TESTCASE
+// title: unascheck by encodename()
+// group: generic-conversion
+{
+ /* U+0221: unassigned codepoint */
+ r = idn_res_encodename(ctx, IDN_UNASCHECK, "<U+0221>", to, sizeof(to));
+ ASSERT_RESULT(r, idn_prohibited);
+}
+
+//# TESTCASE
+// title: bidicheck by encodename()
+// group: generic-conversion
+{
+ /* U+05D0: bidirectional property is "R" */
+ /* `a': bidirectional property is "L" */
+ /* `0', `-': bidirectional property is "N" */
+ r = idn_res_encodename(ctx, IDN_BIDICHECK, "<U+05D0>", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_res_encodename(ctx, IDN_BIDICHECK, "<U+05D0><U+05D0>",
+ to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_res_encodename(ctx, IDN_BIDICHECK, "<U+05D0><U+05D0>-a",
+ to, sizeof(to));
+ ASSERT_RESULT(r, idn_prohibited);
+
+ r = idn_res_encodename(ctx, IDN_BIDICHECK, "<U+05D0>-a-<U+05D0>",
+ to, sizeof(to));
+ ASSERT_RESULT(r, idn_prohibited);
+
+ r = idn_res_encodename(ctx, IDN_BIDICHECK, "a-<U+05D0><U+05D0>",
+ to, sizeof(to));
+ ASSERT_RESULT(r, idn_prohibited);
+
+ r = idn_res_encodename(ctx, IDN_BIDICHECK, "<U+05D0><U+05D0>-0",
+ to, sizeof(to));
+ ASSERT_RESULT(r, idn_prohibited);
+
+ r = idn_res_encodename(ctx, IDN_BIDICHECK, "<U+05D0>-0-<U+05D0>",
+ to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_res_encodename(ctx, IDN_BIDICHECK, "0-<U+05D0><U+05D0>",
+ to, sizeof(to));
+ ASSERT_RESULT(r, idn_prohibited);
+}
+
+//# TESTCASE
+// title: asccheck by encodename()
+// group: generic-conversion
+{
+ r = idn_res_encodename(ctx, IDN_ASCCHECK, "-name", to, sizeof(to));
+ ASSERT_RESULT(r, idn_prohibited);
+
+ r = idn_res_encodename(ctx, IDN_ASCCHECK, "name-", to, sizeof(to));
+ ASSERT_RESULT(r, idn_prohibited);
+
+ r = idn_res_encodename(ctx, IDN_ASCCHECK, "n ame", to, sizeof(to));
+ ASSERT_RESULT(r, idn_prohibited);
+}
+
+//# TESTCASE
+// title: lencheck by encodename()
+// group: generic-conversion
+{
+ r = idn_res_encodename(ctx, IDN_LENCHECK,
+ "123456789-123456789-123456789-123456789-"
+ "123456789-123456789-123", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_res_encodename(ctx, IDN_LENCHECK,
+ "123456789-123456789-123456789-123456789-"
+ "123456789-123456789-1234", to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_length);
+
+ r = idn_res_encodename(ctx, IDN_LENCHECK, "a..b", to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_length);
+}
+
+//# TESTCASE
+// title: rtcheck non-prohchecked label by decodename()
+// group: generic-conversion
+{
+ /* "xn--6ue" -> "U+1680" (prohibited character) */
+ r = idn_res_decodename(ctx, IDN_RTCHECK, "xn--6ue", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "xn--6ue");
+}
+
+//# TESTCASE
+// title: rtcheck non-unaschecked label by decodename()
+// group: generic-conversion
+{
+ /* "xn--6la" -> "U+0221" (unassigned codepoint) */
+ r = idn_res_decodename(ctx, IDN_IDNCONV | IDN_RTCHECK | IDN_UNASCHECK,
+ "xn--6la", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "xn--6la");
+}
+
+//# TESTCASE
+// title: rtcheck non-ascchecked label by decodename()
+// group: generic-conversion
+{
+ /* "xn----x7t" -> "- U+3042" */
+ r = idn_res_decodename(ctx, IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK,
+ "xn----x7t", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "xn----x7t");
+
+ /* "xn----w7t" -> "U+3042 -" */
+ r = idn_res_decodename(ctx, IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK,
+ "xn----w7t", to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "xn----w7t");
+}
+
+//# TESTCASE
+// title: rtcheck non-lenchecked label by decodename()
+// group: generic-conversion
+{
+ /* `s1' has 63 characters */
+ const char *s1 =
+ "xn--l8jaa5522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b";
+
+ const char *s1rev =
+ "<U+9752><U+68EE><U+5CA9><U+624B><U+5BAE><U+57CE><U+79CB><U+7530>"
+ "<U+5C71><U+5F62><U+798F><U+5CF6><U+6771><U+4EAC><U+795E><U+5948>"
+ "<U+5DDD><U+3042><U+3042><U+3042>";
+
+ /* `s2' has 64 characters */
+ const char *s2 =
+ "xn--a-w7ta6522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b";
+
+ /* `s3' has an empty label */
+ const char *s3 = "a..b";
+
+ r = idn_res_decodename(ctx, IDN_IDNCONV | IDN_RTCHECK, s1, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, s1rev);
+
+ r = idn_res_decodename(ctx, IDN_IDNCONV | IDN_RTCHECK, s2, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, s2);
+
+ r = idn_res_decodename(ctx, IDN_IDNCONV | IDN_RTCHECK, s3, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, s3);
+}
+
+//# TESTCASE
+// title: rtcheck non-prohchecked label by decodename2()
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ /* "xn--6ue" -> "U+1680" (prohibited character) */
+ r = idn_res_decodename2(ctx, IDN_RTCHECK, "xn--6ue", to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "xn--6ue");
+#endif
+}
+
+//# TESTCASE
+// title: rtcheck non-unaschecked label by decodename2()
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ /* "xn--6la" -> "U+0221" (unassigned codepoint) */
+ r = idn_res_decodename2(ctx, IDN_IDNCONV | IDN_RTCHECK | IDN_UNASCHECK,
+ "xn--6la", to, sizeof(to), EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "xn--6la");
+#endif
+}
+
+//# TESTCASE
+// title: rtcheck non-ascchecked label by decodename2()
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ /* "xn----x7t" -> "- U+3042" */
+ r = idn_res_decodename2(ctx, IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK,
+ "xn----x7t", to, sizeof(to), EUCJP_ENCODING_NAME);
+
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "xn----x7t");
+
+ /* "xn----w7t" -> "U+3042 -" */
+ r = idn_res_decodename2(ctx, IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK,
+ "xn----w7t", to, sizeof(to), EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "xn----w7t");
+#endif
+}
+
+//# TESTCASE
+// title: rtcheck non-lenchecked label by decodename2()
+// group: generic-conversion
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ /* `s1' has 63 characters */
+ const char *s1 =
+ "xn--l8jaa5522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b";
+
+ const char *s1rev =
+ "<U+9752><U+68EE><U+5CA9><U+624B><U+5BAE><U+57CE><U+79CB><U+7530>"
+ "<U+5C71><U+5F62><U+798F><U+5CF6><U+6771><U+4EAC><U+795E><U+5948>"
+ "<U+5DDD><U+3042><U+3042><U+3042>";
+
+ /* `s2' has 64 characters */
+ const char *s2 =
+ "xn--a-w7ta6522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b";
+
+ /* `s3' has an empty label */
+ const char *s3 = "a..b";
+
+ r = idn_res_decodename2(ctx, IDN_IDNCONV | IDN_RTCHECK, s1, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, s1rev);
+
+ r = idn_res_decodename2(ctx, IDN_IDNCONV | IDN_RTCHECK, s2, to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, s2);
+
+ r = idn_res_decodename(ctx, IDN_IDNCONV | IDN_RTCHECK, s3, to, sizeof(to));
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, s3);
+#endif
+}
+
+//# TESTCASE
+// title: pass broken string as `from' to encodename()
+// group: generic-conversion quiet
+{
+ /* "\xe3\x21" is not valid UTF-8 string */
+ r = idn_res_encodename(ctx, IDN_ENCODE_APP, "\xe3\x21", to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_encoding);
+}
+
+//# TESTCASE
+// title: pass broken string as `from' to decodename()
+// group: generic-conversion quiet
+{
+ /* "\xe3\x21" is not valid UTF-8 string */
+ r = idn_res_decodename(ctx, IDN_DECODE_APP, "\xe3\x21", to, sizeof(to));
+ ASSERT_RESULT(r, idn_invalid_encoding);
+}
+
+//# TESTCASE
+// title: pass broken string as `from' to decodename2()
+// group: generic-conversion quiet
+{
+#ifdef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ /* "\xa4\x21" is not valid EUC-JP string */
+ r = idn_res_decodename2(ctx, IDN_DECODE_APP, "\xa4\x21", to, sizeof(to),
+ EUCJP_ENCODING_NAME);
+ ASSERT_RESULT(r, idn_invalid_encoding);
+#endif
+}
+
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/resconf.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/resconf.tsy
new file mode 100644
index 0000000..a4c2f35
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/resconf.tsy
@@ -0,0 +1,1026 @@
+#ifndef lint
+static char *rcsid = "$Id: resconf.tsy,v 1.1.1.1 2003/06/04 00:27:00 marka Exp $";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <idn/resconf.h>
+#include <idn/converter.h>
+#include <idn/log.h>
+
+#include "setenv.h"
+#include "testutil.h"
+
+#define CONF_FILENAME "test.conf"
+#define MAP_FILENAME "test.map"
+
+//--------------------------------------------------------------------
+// Setups and Teardowns.
+//--------------------------------------------------------------------
+
+//# SETUP
+// group: generic-init
+{
+ idn_result_t r;
+ idn_resconf_t ctx = NULL;
+
+ setenv("IDN_LOCAL_CODESET", "UTF-8", 1);
+
+ r = idn_resconf_initialize();
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_resconf_create(&ctx);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TEARDOWN
+// group: generic-init
+{
+ if (ctx != NULL)
+ idn_resconf_destroy(ctx);
+ remove(CONF_FILENAME);
+ remove(MAP_FILENAME);
+}
+
+//# SETUP
+// group: set-defaults
+{
+ r = idn_resconf_setdefaults(ctx);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TEARDOWN
+// group: set-defaults
+{
+}
+
+//# SETUP
+// group: quiet
+{
+ int saved_log_level;
+
+ saved_log_level = idn_log_getlevel();
+ idn_log_setlevel(idn_log_level_fatal);
+}
+
+//# TEARDOWN
+// group: quiet
+{
+ idn_log_setlevel(saved_log_level);
+}
+
+//# SETUP
+// group: delimitermap_ctx
+{
+ idn_delimitermap_t delimitermap_ctx1 = NULL;
+ idn_delimitermap_t delimitermap_ctx2 = NULL;
+}
+
+//# TEARDOWN
+// group: delimitermap_ctx
+{
+ if (delimitermap_ctx1 != NULL)
+ idn_delimitermap_destroy(delimitermap_ctx1);
+ if (delimitermap_ctx2 != NULL)
+ idn_delimitermap_destroy(delimitermap_ctx2);
+}
+
+//# SETUP
+// group: idnconverter_ctx
+{
+ idn_converter_t idnconverter_ctx1 = NULL;
+ idn_converter_t idnconverter_ctx2 = NULL;
+}
+
+//# TEARDOWN
+// group: idnconverter_ctx
+{
+ if (idnconverter_ctx1 != NULL)
+ idn_converter_destroy(idnconverter_ctx1);
+ if (idnconverter_ctx2 != NULL)
+ idn_converter_destroy(idnconverter_ctx2);
+}
+
+//# SETUP
+// group: localconverter_ctx
+{
+ idn_converter_t localconverter_ctx1 = NULL;
+ idn_converter_t localconverter_ctx2 = NULL;
+}
+
+//# TEARDOWN
+// group: localconverter_ctx
+{
+ if (localconverter_ctx1 != NULL)
+ idn_converter_destroy(localconverter_ctx1);
+ if (localconverter_ctx2 != NULL)
+ idn_converter_destroy(localconverter_ctx2);
+}
+
+//# SETUP
+// group: auxidnconverter_ctx
+{
+ idn_converter_t auxidnconverter_ctx1 = NULL;
+ idn_converter_t auxidnconverter_ctx2 = NULL;
+}
+
+//# TEARDOWN
+// group: auxidnconverter_ctx
+{
+ if (auxidnconverter_ctx1 != NULL)
+ idn_converter_destroy(auxidnconverter_ctx1);
+ if (auxidnconverter_ctx2 != NULL)
+ idn_converter_destroy(auxidnconverter_ctx2);
+}
+
+//# SETUP
+// group: mapselector_ctx
+{
+ idn_mapselector_t mapselector_ctx1 = NULL;
+ idn_mapselector_t mapselector_ctx2 = NULL;
+}
+
+//# TEARDOWN
+// group: mapselector_ctx
+{
+ if (mapselector_ctx1 != NULL)
+ idn_mapselector_destroy(mapselector_ctx1);
+ if (mapselector_ctx2 != NULL)
+ idn_mapselector_destroy(mapselector_ctx2);
+}
+
+//# SETUP
+// group: mapper_ctx
+{
+ idn_mapper_t mapper_ctx1 = NULL;
+ idn_mapper_t mapper_ctx2 = NULL;
+}
+
+//# TEARDOWN
+// group: mapper_ctx
+{
+ if (mapper_ctx1 != NULL)
+ idn_mapper_destroy(mapper_ctx1);
+ if (mapper_ctx2 != NULL)
+ idn_mapper_destroy(mapper_ctx2);
+}
+
+//# SETUP
+// group: normalizer_ctx
+{
+ idn_normalizer_t normalizer_ctx1 = NULL;
+ idn_normalizer_t normalizer_ctx2 = NULL;
+}
+
+//# TEARDOWN
+// group: normalizer_ctx
+{
+ if (normalizer_ctx1 != NULL)
+ idn_normalizer_destroy(normalizer_ctx1);
+ if (normalizer_ctx2 != NULL)
+ idn_normalizer_destroy(normalizer_ctx2);
+}
+
+//# SETUP
+// group: prohibitchecker_ctx
+{
+ idn_checker_t prohibitchecker_ctx1 = NULL;
+ idn_checker_t prohibitchecker_ctx2 = NULL;
+}
+
+//# TEARDOWN
+// group: prohibitchecker_ctx
+{
+ if (prohibitchecker_ctx1 != NULL)
+ idn_checker_destroy(prohibitchecker_ctx1);
+ if (prohibitchecker_ctx2 != NULL)
+ idn_checker_destroy(prohibitchecker_ctx2);
+}
+
+//# SETUP
+// group: unassignedchecker_ctx
+{
+ idn_checker_t unassignedchecker_ctx1 = NULL;
+ idn_checker_t unassignedchecker_ctx2 = NULL;
+}
+
+//# TEARDOWN
+// group: unassignedchecker_ctx
+{
+ if (unassignedchecker_ctx1 != NULL)
+ idn_checker_destroy(unassignedchecker_ctx1);
+ if (unassignedchecker_ctx2 != NULL)
+ idn_checker_destroy(unassignedchecker_ctx2);
+}
+
+//# SETUP
+// group: bidichecker_ctx
+{
+ idn_checker_t bidichecker_ctx1 = NULL;
+ idn_checker_t bidichecker_ctx2 = NULL;
+}
+
+//# TEARDOWN
+// group: bidichecker_ctx
+{
+ if (bidichecker_ctx1 != NULL)
+ idn_checker_destroy(bidichecker_ctx1);
+ if (bidichecker_ctx2 != NULL)
+ idn_checker_destroy(bidichecker_ctx2);
+}
+
+//--------------------------------------------------------------------
+// Testcases.
+//--------------------------------------------------------------------
+
+//# TESTCASE
+// title: call create() without initialization.
+//--
+// This must be the first test case.
+{
+ idn_result_t r;
+ idn_resconf_t ctx = NULL;
+
+ r = idn_resconf_create(&ctx);
+ ASSERT_RESULT(r, idn_failure);
+
+ if (ctx != NULL)
+ idn_resconf_destroy(ctx);
+}
+
+//# TESTCASE
+// title: call initialize() twice.
+//
+{
+ idn_result_t r;
+
+ r = idn_resconf_initialize();
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_resconf_initialize();
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TESTCASE
+// title: call create()
+{
+ idn_result_t r;
+ idn_resconf_t ctx;
+
+ r = idn_resconf_initialize();
+ ASSERT_RESULT(r, idn_success);
+
+ r = idn_resconf_create(&ctx);
+ ASSERT_RESULT(r, idn_success);
+
+ if (ctx != NULL)
+ idn_resconf_destroy(ctx);
+}
+
+//# TESTCASE
+// title: load file (idn-encoding)
+// group: generic-init
+{
+ const char *idn_encoding;
+
+ create_conf_file(CONF_FILENAME, 0,
+ "idn-encoding Punycode",
+ NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TESTCASE
+// title: load file (nameprep)
+// group: generic-init
+{
+ const char *idn_encoding;
+
+ create_conf_file(CONF_FILENAME, 0,
+ "nameprep " IDN_NAMEPREP_CURRENT,
+ NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TESTCASE
+// title: load file (idn-encoding & nameprep)
+// group: generic-init
+{
+ const char *idn_encoding;
+
+ create_conf_file(CONF_FILENAME, 0,
+ "idn-encoding Punycode",
+ "nameprep " IDN_NAMEPREP_CURRENT,
+ NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TESTCASE
+// title: load file (empty)
+// group: generic-init
+{
+ const char *idn_encoding;
+
+ create_conf_file(CONF_FILENAME, 0,
+ NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TESTCASE
+// title: load file (local-map filemap)
+// group: generic-init
+{
+ const char *idn_encoding;
+
+ create_conf_file(CONF_FILENAME, 0,
+ "local-map .jp filemap:" MAP_FILENAME,
+ NULL);
+ create_conf_file(MAP_FILENAME, 0,
+ "2212; FF0D",
+ NULL);
+
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TESTCASE
+// title: load file (local-map nameprep)
+// group: generic-init
+{
+ const char *idn_encoding;
+
+ create_conf_file(CONF_FILENAME, 0,
+ "local-map .jp " IDN_NAMEPREP_CURRENT,
+ NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TESTCASE
+// title: set defaults
+// group: generic-init set-defaults
+{
+}
+
+//# TESTCASE
+// title: load file (no file)
+// group: generic-init
+{
+ r = idn_resconf_loadfile(ctx, "no-such-file");
+ ASSERT_RESULT(r, idn_nofile);
+}
+
+//# TESTCASE
+// title: load file (empty file name)
+// group: generic-init
+{
+ r = idn_resconf_loadfile(ctx, "");
+ ASSERT_RESULT(r, idn_nofile);
+}
+
+//# TESTCASE
+// title: load file (unknown command)
+// group: generic-init quiet
+{
+ create_conf_file(CONF_FILENAME, 0,
+ "unknown-command " IDN_NAMEPREP_CURRENT,
+ NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_invalid_syntax);
+}
+
+//# TESTCASE
+// title: load file (no newline at the end of file)
+// group: generic-init quiet
+{
+ create_conf_file(CONF_FILENAME, CONF_NO_EOF_NEWLINE,
+ "nameprep " IDN_NAMEPREP_CURRENT,
+ NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TESTCASE
+// title: load file (too long line)
+// group: generic-init quiet
+{
+ char arg[1024];
+ char *line;
+
+ /* arg = "local-map . ////..." */
+ memset(arg, '/', sizeof(arg));
+ arg[sizeof(arg) - 1] = '\0';
+ line = "local-map . ";
+ memcpy(arg, line, strlen(line));
+
+ create_conf_file(CONF_FILENAME, 0, arg, NULL);
+
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_invalid_syntax);
+}
+
+//# TESTCASE
+// title: load file (empty file)
+// group: generic-init
+{
+ create_conf_file(CONF_FILENAME, 0, "", NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TESTCASE
+// title: load file (invalid parameter for idn-encoding)
+// group: generic-init quiet
+{
+#ifndef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ create_conf_file(CONF_FILENAME, 0,
+ "idn-encoding invalid-encoding-name",
+ NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_invalid_name);
+#endif
+}
+
+//# TESTCASE
+// title: load file (define idn-encoding twice)
+// group: generic-init quiet
+{
+#ifndef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ create_conf_file(CONF_FILENAME, CONF_NO_EOF_NEWLINE,
+ "idn-encoding Punycode",
+ "idn-encoding Punycode",
+ NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_invalid_syntax);
+#endif
+}
+
+//# TESTCASE
+// title: load file (invalid parameter for nameprep)
+// group: generic-init quiet
+{
+ create_conf_file(CONF_FILENAME, 0,
+ "nameprep invalid-version",
+ NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_invalid_name);
+}
+
+//# TESTCASE
+// title: load file (define nameprep twice)
+// group: generic-init quiet
+{
+#ifndef WITHOUT_ICONV
+ SKIP_TESTCASE;
+#else
+ create_conf_file(CONF_FILENAME, CONF_NO_EOF_NEWLINE,
+ "nameprep " IDN_NAMEPREP_CURRENT,
+ "nameprep " IDN_NAMEPREP_CURRENT,
+ NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_invalid_syntax);
+#endif
+}
+
+//# TESTCASE
+// title: load file (invalid parameter for local-map)
+// group: generic-init quiet
+{
+ create_conf_file(CONF_FILENAME, 0,
+ "local-map .jp :",
+ NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_invalid_name);
+
+ create_conf_file(CONF_FILENAME, 0,
+ "local-map .jp invalid:/dev/null",
+ NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_invalid_name);
+
+ create_conf_file(CONF_FILENAME, 0,
+ "local-map .jp filemap",
+ NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_nofile);
+
+ create_conf_file(CONF_FILENAME, 0,
+ "local-map .jp filemap:",
+ NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_nofile);
+
+ create_conf_file(CONF_FILENAME, 0,
+ "local-map .jp filemap:no-such-file",
+ NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_nofile);
+
+ create_conf_file(CONF_FILENAME, 0,
+ "local-map "
+ "abcdefghijklmnopqrstuvwxyz0123"
+ "abcdefghijklmnopqrstuvwxyz0123"
+ "4567 "
+ IDN_NAMEPREP_CURRENT,
+ NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_invalid_name);
+}
+
+//# TESTCASE
+// title: load file (pass wrong number of parameters to idn-encoding)
+// group: generic-init quiet
+{
+ create_conf_file(CONF_FILENAME, 0,
+ "idn-encoding ",
+ NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_invalid_syntax);
+
+ create_conf_file(CONF_FILENAME, 0,
+ "idn-encoding Punycode ?",
+ NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_invalid_syntax);
+}
+
+//# TESTCASE
+// title: load file (pass wrong number of parameters to nameprep)
+// group: generic-init quiet
+{
+ create_conf_file(CONF_FILENAME, 0,
+ "nameprep ",
+ NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_invalid_syntax);
+
+ create_conf_file(CONF_FILENAME, 0,
+ "nameprep " IDN_NAMEPREP_CURRENT " ?",
+ NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_invalid_syntax);
+}
+
+//# TESTCASE
+// title: load file (pass wrong number of parameters to local-map)
+// group: generic-init quiet
+{
+ create_conf_file(CONF_FILENAME, 0,
+ "local-map ",
+ NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_invalid_syntax);
+
+ create_conf_file(CONF_FILENAME, 0,
+ "local-map .jp ",
+ NULL);
+ r = idn_resconf_loadfile(ctx, CONF_FILENAME);
+ ASSERT_RESULT(r, idn_invalid_syntax);
+}
+
+//# TESTCASE
+// title: getdelimitermap
+// group: generic-init set-defaults delimitermap_ctx
+{
+ delimitermap_ctx1 = idn_resconf_getdelimitermap(ctx);
+ ASSERT_PTR_NE(delimitermap_ctx1, NULL);
+}
+
+//# TESTCASE
+// title: setdelimitermap
+// group: generic-init set-defaults delimitermap_ctx
+{
+ r = idn_delimitermap_create(&delimitermap_ctx1);
+ ASSERT_RESULT(r, idn_success);
+
+ /* set delimitermap context. */
+ idn_resconf_setdelimitermap(ctx, delimitermap_ctx1);
+ delimitermap_ctx2 = idn_resconf_getdelimitermap(ctx);
+ ASSERT_PTR(delimitermap_ctx2, delimitermap_ctx1);
+ idn_delimitermap_destroy(delimitermap_ctx2);
+
+ /* set NULL as delimitermap context */
+ idn_resconf_setdelimitermap(ctx, NULL);
+ delimitermap_ctx2 = idn_resconf_getdelimitermap(ctx);
+ ASSERT_PTR(delimitermap_ctx2, NULL);
+}
+
+//# TESTCASE
+// title: addalldelimitermapucs
+// group: generic-init set-defaults
+{
+ static unsigned long v[] = {0x002C, 0x3001, 0xFF0C};
+ int nv = sizeof(v) / sizeof(*v);
+
+ r = idn_resconf_addalldelimitermapucs(ctx, v, nv);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TESTCASE
+// title: getidnconverter
+// group: generic-init set-defaults idnconverter_ctx
+{
+ idnconverter_ctx1 = idn_resconf_getidnconverter(ctx);
+ ASSERT_PTR_NE(idnconverter_ctx1, NULL);
+}
+
+//# TESTCASE
+// title: setidnconverter
+// group: generic-init set-defaults idnconverter_ctx
+{
+ r = idn_converter_create("Punycode", &idnconverter_ctx1, 0);
+ ASSERT_RESULT(r, idn_success);
+
+ /* set idnconverter context. */
+ idn_resconf_setidnconverter(ctx, idnconverter_ctx1);
+ idnconverter_ctx2 = idn_resconf_getidnconverter(ctx);
+ ASSERT_PTR(idnconverter_ctx2, idnconverter_ctx1);
+ idn_converter_destroy(idnconverter_ctx2);
+
+ /* set NULL as idnconverter context */
+ idn_resconf_setidnconverter(ctx, NULL);
+ idnconverter_ctx2 = idn_resconf_getidnconverter(ctx);
+ ASSERT_PTR(idnconverter_ctx2, NULL);
+}
+
+//# TESTCASE
+// title: getlocalconverter
+// group: generic-init set-defaults localconverter_ctx
+{
+ localconverter_ctx1 = idn_resconf_getlocalconverter(ctx);
+#ifdef WITHOUT_ICONV
+ ASSERT_PTR(localconverter_ctx1, NULL);
+#else
+ ASSERT_PTR_NE(localconverter_ctx1, NULL);
+#endif
+}
+
+//# TESTCASE
+// title: setlocalconverter
+// group: generic-init set-defaults localconverter_ctx
+{
+ r = idn_converter_create("UTF-8", &localconverter_ctx1, 0);
+ ASSERT_RESULT(r, idn_success);
+
+ /* set localconverter context. */
+ idn_resconf_setlocalconverter(ctx, localconverter_ctx1);
+ localconverter_ctx2 = idn_resconf_getlocalconverter(ctx);
+#ifdef WITHOUT_ICONV
+ ASSERT_PTR(localconverter_ctx2, NULL);
+#else
+ ASSERT_PTR(localconverter_ctx2, localconverter_ctx1);
+ idn_converter_destroy(localconverter_ctx2);
+#endif
+
+ /* set NULL as localconverter context */
+ idn_resconf_setlocalconverter(ctx, NULL);
+ localconverter_ctx2 = idn_resconf_getlocalconverter(ctx);
+#ifdef WITHOUT_ICONV
+ ASSERT_PTR(localconverter_ctx2, NULL);
+#else
+ ASSERT_PTR_NE(localconverter_ctx2, NULL);
+#endif
+}
+
+//# TESTCASE
+// title: getauxidnconverter
+// group: generic-init set-defaults auxidnconverter_ctx
+{
+ auxidnconverter_ctx1 = idn_resconf_getauxidnconverter(ctx);
+ ASSERT_PTR(auxidnconverter_ctx1, NULL);
+}
+
+//# TESTCASE
+// title: setauxidnconverter
+// group: generic-init set-defaults auxidnconverter_ctx
+{
+ r = idn_converter_create("Punycode", &auxidnconverter_ctx1, 0);
+ ASSERT_RESULT(r, idn_success);
+
+ /* set auxidnconverter context. */
+ idn_resconf_setauxidnconverter(ctx, auxidnconverter_ctx1);
+ auxidnconverter_ctx2 = idn_resconf_getauxidnconverter(ctx);
+ ASSERT_PTR(auxidnconverter_ctx2, auxidnconverter_ctx1);
+ idn_converter_destroy(auxidnconverter_ctx2);
+
+ /* set NULL as auxidnconverter context */
+ idn_resconf_setauxidnconverter(ctx, NULL);
+ auxidnconverter_ctx2 = idn_resconf_getauxidnconverter(ctx);
+ ASSERT_PTR(auxidnconverter_ctx2, NULL);
+}
+
+//# TESTCASE
+// title: getlocalmapselector
+// group: generic-init set-defaults mapselector_ctx
+{
+ mapselector_ctx1 = idn_resconf_getlocalmapselector(ctx);
+ ASSERT_PTR(mapselector_ctx1, NULL);
+}
+
+//# TESTCASE
+// title: setlocalmapselector
+// group: generic-init set-defaults mapselector_ctx
+{
+ r = idn_mapselector_create(&mapselector_ctx1);
+ ASSERT_RESULT(r, idn_success);
+
+ /* set localmapselector context. */
+ idn_resconf_setlocalmapselector(ctx, mapselector_ctx1);
+ mapselector_ctx2 = idn_resconf_getlocalmapselector(ctx);
+ ASSERT_PTR(mapselector_ctx2, mapselector_ctx1);
+ idn_mapselector_destroy(mapselector_ctx2);
+
+ /* set NULL as localmapselector context */
+ idn_resconf_setlocalmapselector(ctx, NULL);
+ mapselector_ctx2 = idn_resconf_getlocalmapselector(ctx);
+ ASSERT_PTR(mapselector_ctx2, NULL);
+}
+
+//# TESTCASE
+// title: addalllocalmapselectornames
+// group: generic-init set-defaults
+{
+ static const char *names[] = {
+ "filemap:" MAP_FILENAME,
+ "filemap:" MAP_FILENAME,
+ "filemap:" MAP_FILENAME
+ };
+ int nnames = sizeof(names) / sizeof(*names);
+
+ create_conf_file(MAP_FILENAME, 0,
+ "2212; FF0D",
+ NULL);
+ r = idn_resconf_addalllocalmapselectornames(ctx, ".jp", names, nnames);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TESTCASE
+// title: getmapper
+// group: generic-init set-defaults mapper_ctx
+{
+ mapper_ctx1 = idn_resconf_getmapper(ctx);
+ ASSERT_PTR_NE(mapper_ctx1, NULL);
+}
+
+//# TESTCASE
+// title: setmapper
+// group: generic-init set-defaults mapper_ctx
+{
+ r = idn_mapper_create(&mapper_ctx1);
+ ASSERT_RESULT(r, idn_success);
+
+ /* set mapper context. */
+ idn_resconf_setmapper(ctx, mapper_ctx1);
+ mapper_ctx2 = idn_resconf_getmapper(ctx);
+ ASSERT_PTR(mapper_ctx2, mapper_ctx1);
+ idn_mapper_destroy(mapper_ctx2);
+
+ /* set NULL as mapper context */
+ idn_resconf_setmapper(ctx, NULL);
+ mapper_ctx2 = idn_resconf_getmapper(ctx);
+ ASSERT_PTR(mapper_ctx2, NULL);
+}
+
+//# TESTCASE
+// title: addallmappernames
+// group: generic-init set-defaults
+{
+ static const char *names[] = {
+ IDN_NAMEPREP_CURRENT,
+ IDN_NAMEPREP_CURRENT,
+ IDN_NAMEPREP_CURRENT
+ };
+ int nnames = sizeof(names) / sizeof(*names);
+
+ r = idn_resconf_addallmappernames(ctx, names, nnames);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TESTCASE
+// title: getnormalizer
+// group: generic-init set-defaults normalizer_ctx
+{
+ normalizer_ctx1 = idn_resconf_getnormalizer(ctx);
+ ASSERT_PTR_NE(normalizer_ctx1, NULL);
+}
+
+//# TESTCASE
+// title: setnormalizer
+// group: generic-init set-defaults normalizer_ctx
+{
+ r = idn_normalizer_create(&normalizer_ctx1);
+ ASSERT_RESULT(r, idn_success);
+
+ /* set normalizer context. */
+ idn_resconf_setnormalizer(ctx, normalizer_ctx1);
+ normalizer_ctx2 = idn_resconf_getnormalizer(ctx);
+ ASSERT_PTR(normalizer_ctx2, normalizer_ctx1);
+ idn_normalizer_destroy(normalizer_ctx2);
+
+ /* set NULL as normalizer context */
+ idn_resconf_setnormalizer(ctx, NULL);
+ normalizer_ctx2 = idn_resconf_getnormalizer(ctx);
+ ASSERT_PTR(normalizer_ctx2, NULL);
+}
+
+//# TESTCASE
+// title: addallnormalizernames
+// group: generic-init set-defaults
+{
+ static const char *names[] = {
+ IDN_NAMEPREP_CURRENT,
+ IDN_NAMEPREP_CURRENT,
+ IDN_NAMEPREP_CURRENT
+ };
+ int nnames = sizeof(names) / sizeof(*names);
+
+ r = idn_resconf_addallnormalizernames(ctx, names, nnames);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TESTCASE
+// title: getprohibitchecker
+// group: generic-init set-defaults prohibitchecker_ctx
+{
+ prohibitchecker_ctx1 = idn_resconf_getprohibitchecker(ctx);
+ ASSERT_PTR_NE(prohibitchecker_ctx1, NULL);
+}
+
+//# TESTCASE
+// title: setprohibitchecker
+// group: generic-init set-defaults prohibitchecker_ctx
+{
+ r = idn_checker_create(&prohibitchecker_ctx1);
+ ASSERT_RESULT(r, idn_success);
+
+ /* set checker context. */
+ idn_resconf_setprohibitchecker(ctx, prohibitchecker_ctx1);
+ prohibitchecker_ctx2 = idn_resconf_getprohibitchecker(ctx);
+ ASSERT_PTR(prohibitchecker_ctx2, prohibitchecker_ctx1);
+ idn_checker_destroy(prohibitchecker_ctx2);
+
+ /* set NULL as checker context */
+ idn_resconf_setprohibitchecker(ctx, NULL);
+ prohibitchecker_ctx2 = idn_resconf_getprohibitchecker(ctx);
+ ASSERT_PTR(prohibitchecker_ctx2, NULL);
+}
+
+//# TESTCASE
+// title: addallprohibitcheckernames
+// group: generic-init set-defaults
+{
+ static const char *names[] = {
+ IDN_NAMEPREP_CURRENT,
+ IDN_NAMEPREP_CURRENT,
+ IDN_NAMEPREP_CURRENT
+ };
+ int nnames = sizeof(names) / sizeof(*names);
+
+ r = idn_resconf_addallprohibitcheckernames(ctx, names, nnames);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TESTCASE
+// title: getunassignedchecker
+// group: generic-init set-defaults unassignedchecker_ctx
+{
+ unassignedchecker_ctx1 = idn_resconf_getunassignedchecker(ctx);
+ ASSERT_PTR_NE(unassignedchecker_ctx1, NULL);
+}
+
+//# TESTCASE
+// title: setunassignedchecker
+// group: generic-init set-defaults unassignedchecker_ctx
+{
+ r = idn_checker_create(&unassignedchecker_ctx1);
+ ASSERT_RESULT(r, idn_success);
+
+ /* set checker context. */
+ idn_resconf_setunassignedchecker(ctx, unassignedchecker_ctx1);
+ unassignedchecker_ctx2 = idn_resconf_getunassignedchecker(ctx);
+ ASSERT_PTR(unassignedchecker_ctx2, unassignedchecker_ctx1);
+ idn_checker_destroy(unassignedchecker_ctx2);
+
+ /* set NULL as checker context */
+ idn_resconf_setunassignedchecker(ctx, NULL);
+ unassignedchecker_ctx2 = idn_resconf_getunassignedchecker(ctx);
+ ASSERT_PTR(unassignedchecker_ctx2, NULL);
+}
+
+//# TESTCASE
+// title: addallunassignedcheckernames
+// group: generic-init set-defaults
+{
+ static const char *names[] = {
+ IDN_NAMEPREP_CURRENT,
+ IDN_NAMEPREP_CURRENT,
+ IDN_NAMEPREP_CURRENT
+ };
+ int nnames = sizeof(names) / sizeof(*names);
+
+ r = idn_resconf_addallunassignedcheckernames(ctx, names, nnames);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TESTCASE
+// title: getbidichecker
+// group: generic-init set-defaults bidichecker_ctx
+{
+ bidichecker_ctx1 = idn_resconf_getbidichecker(ctx);
+ ASSERT_PTR_NE(bidichecker_ctx1, NULL);
+}
+
+//# TESTCASE
+// title: setbidichecker
+// group: generic-init set-defaults bidichecker_ctx
+{
+ r = idn_checker_create(&bidichecker_ctx1);
+ ASSERT_RESULT(r, idn_success);
+
+ /* set checker context. */
+ idn_resconf_setbidichecker(ctx, bidichecker_ctx1);
+ bidichecker_ctx2 = idn_resconf_getbidichecker(ctx);
+ ASSERT_PTR(bidichecker_ctx2, bidichecker_ctx1);
+ idn_checker_destroy(bidichecker_ctx2);
+
+ /* set NULL as checker context */
+ idn_resconf_setbidichecker(ctx, NULL);
+ bidichecker_ctx2 = idn_resconf_getbidichecker(ctx);
+ ASSERT_PTR(bidichecker_ctx2, NULL);
+}
+
+//# TESTCASE
+// title: addallbidicheckernames
+// group: generic-init set-defaults
+{
+ static const char *names[] = {
+ IDN_NAMEPREP_CURRENT,
+ IDN_NAMEPREP_CURRENT,
+ IDN_NAMEPREP_CURRENT
+ };
+ int nnames = sizeof(names) / sizeof(*names);
+
+ r = idn_resconf_addallbidicheckernames(ctx, names, nnames);
+ ASSERT_RESULT(r, idn_success);
+}
+
+//# TESTCASE
+// title: setnameprepversion
+// group: generic-init set-defaults
+{
+ idn_resconf_setnameprepversion(ctx, IDN_NAMEPREP_CURRENT);
+ ASSERT_RESULT(r, idn_success);
+}
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/setenv.c b/contrib/idn/idnkit-1.0-src/lib/tests/setenv.c
new file mode 100644
index 0000000..9c12bf1
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/setenv.c
@@ -0,0 +1,134 @@
+#ifndef lint
+static char *rcsid = "$Id: setenv.c,v 1.1.1.1 2003/06/04 00:27:01 marka Exp $";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stddef.h>
+#include <string.h>
+
+/*
+ * We don't include <stdlib.h> here.
+ * Also <stdlib.h> may declare `environ' and its type might be different
+ * from ours.
+ */
+extern char **environ;
+
+typedef struct myenv myenv_t;
+
+struct myenv {
+ char *pointer;
+ myenv_t *next;
+ myenv_t *prev;
+};
+
+static myenv_t *myenvs = NULL;
+
+void
+myunsetenv(const char *name) {
+ char **e;
+ myenv_t *mye;
+ size_t namelen;
+ extern void free(void *);
+
+ namelen = strlen(name);
+ for (e = environ; *e != NULL; e++) {
+ if (strncmp(*e, name, namelen) == 0 && (*e)[namelen] == '=')
+ break;
+ }
+ if (*e == NULL)
+ return;
+
+ for (mye = myenvs; mye != NULL; mye = mye->next) {
+ if (mye->pointer == *e) {
+ if (mye->next != NULL)
+ mye->next->prev = mye->prev;
+ if (mye->prev != NULL)
+ mye->prev->next = mye->next;
+ if (mye->next == NULL && mye->prev == NULL)
+ myenvs = NULL;
+ free(mye);
+ free(*e);
+ break;
+ }
+ }
+
+ for ( ; *e != NULL; e++)
+ *e = *(e + 1);
+}
+
+#include <stdlib.h>
+
+int
+mysetenv(const char *name, const char *value, int overwrite) {
+ myenv_t *mye;
+ char *buffer;
+ int result;
+
+ if (getenv(name) != NULL && !overwrite)
+ return 0;
+
+ buffer = (char *) malloc(strlen(name) + strlen(value) + 2);
+ if (buffer == NULL)
+ return -1;
+ strcpy(buffer, name);
+ strcat(buffer, "=");
+ strcat(buffer, value);
+
+ myunsetenv(name);
+
+ mye = (myenv_t *) malloc(sizeof(myenv_t));
+ if (mye == NULL)
+ return -1;
+ mye->pointer = buffer;
+ mye->next = myenvs;
+ mye->prev = NULL;
+ if (myenvs != NULL)
+ myenvs->prev = mye;
+ myenvs = mye;
+
+ result = putenv(buffer);
+
+ return result;
+}
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/setenv.h b/contrib/idn/idnkit-1.0-src/lib/tests/setenv.h
new file mode 100644
index 0000000..704c179
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/setenv.h
@@ -0,0 +1,61 @@
+/* $Id: setenv.h,v 1.1.1.1 2003/06/04 00:27:01 marka Exp $ */
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#ifndef IDN_SETENV_H
+#define IDN_SETENV_H
+
+#include "testconfig.h"
+
+#ifndef HAVE_SETENV
+#define unsetenv(a1) myunsetenv(a1)
+#endif
+
+#ifndef HAVE_SETENV
+#define setenv(a1, a2, a3) mysetenv(a1, a2, a3)
+#endif
+
+void myunsetenv(const char *name);
+int mysetenv(const char *name, const char *value, int overwrite);
+
+#endif /* IDN_SETENV_H */
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/testsuite.c b/contrib/idn/idnkit-1.0-src/lib/tests/testsuite.c
new file mode 100644
index 0000000..14b202f
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/testsuite.c
@@ -0,0 +1,578 @@
+#ifndef lint
+static char *rcsid = "$Id";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include <idn/result.h>
+#include <idn/ucs4.h>
+#include <testsuite.h>
+
+typedef struct idn_testcase *idn_testcase_t;
+
+struct idn_testcase {
+ char *title;
+ idn_testsuite_testproc_t proc;
+};
+
+struct idn_testsuite {
+ idn_testcase_t testcases;
+ int ntestcases;
+ int testcase_size;
+
+ int npassed;
+ int nfailed;
+ int nskipped;
+ idn_testcase_t current_testcase;
+ idn_teststatus_t current_status;
+
+ idn_testsuite_msgproc_t msgproc;
+ int verbose;
+};
+
+#define INITIAL_TESTCASE_SIZE 16
+#define INITIAL_SETUP_SIZE 4
+#define INITIAL_TEARDOWN_SIZE 4
+
+static void run_internal(idn_testsuite_t ctx, char *titles[]);
+static char *make_hex_string(const char *string);
+static char *make_hex_ucs4string(const unsigned long *string);
+static void put_failure_message(idn_testsuite_t ctx, const char *msg,
+ const char *file, int lineno);
+static void idn_testsuite_msgtostderr(const char *msg);
+
+int
+idn_testsuite_create(idn_testsuite_t *ctxp) {
+ idn_testsuite_t ctx = NULL;
+
+ assert(ctxp != NULL);
+
+ ctx = (idn_testsuite_t) malloc(sizeof(struct idn_testsuite));
+ if (ctx == NULL)
+ goto error;
+
+ ctx->testcases = NULL;
+ ctx->ntestcases = 0;
+ ctx->testcase_size = 0;
+ ctx->npassed = 0;
+ ctx->nfailed = 0;
+ ctx->nskipped = 0;
+ ctx->current_testcase = NULL;
+ ctx->current_status = idn_teststatus_pass;
+ ctx->msgproc = NULL;
+ ctx->verbose = 0;
+
+ ctx->testcases = (idn_testcase_t) malloc(sizeof(struct idn_testcase)
+ * INITIAL_TESTCASE_SIZE);
+ if (ctx->testcases == NULL)
+ goto error;
+ ctx->testcase_size = INITIAL_TESTCASE_SIZE;
+
+ *ctxp = ctx;
+ return (1);
+
+error:
+ if (ctx != NULL)
+ free(ctx->testcases);
+ free(ctx);
+ return (0);
+}
+
+void
+idn_testsuite_destroy(idn_testsuite_t ctx) {
+ int i;
+
+ assert(ctx != NULL);
+
+ for (i = 0; i < ctx->ntestcases; i++)
+ free(ctx->testcases[i].title);
+
+ free(ctx->testcases);
+ free(ctx);
+}
+
+int
+idn_testsuite_addtestcase(idn_testsuite_t ctx, const char *title,
+ idn_testsuite_testproc_t proc) {
+ char *dup_title = NULL;
+ idn_testcase_t new_buffer = NULL;
+ idn_testcase_t new_testcase;
+ int new_size;
+
+ assert(ctx != NULL && title != NULL && proc != NULL);
+
+ dup_title = (char *)malloc(strlen(title) + 1);
+ if (dup_title == NULL)
+ goto error;
+ strcpy(dup_title, title);
+
+ if (ctx->ntestcases == ctx->testcase_size) {
+ new_size = ctx->testcase_size + INITIAL_TESTCASE_SIZE;
+ new_buffer = (idn_testcase_t)
+ realloc(ctx->testcases,
+ sizeof(struct idn_testcase) * new_size);
+ if (new_buffer == NULL)
+ goto error;
+ ctx->testcases = new_buffer;
+ ctx->testcase_size = new_size;
+ }
+
+ new_testcase = ctx->testcases + ctx->ntestcases;
+ new_testcase->title = dup_title;
+ new_testcase->proc = proc;
+ ctx->ntestcases++;
+ return (1);
+
+error:
+ free(dup_title);
+ free(new_buffer);
+ return (0);
+}
+
+int
+idn_testsuite_ntestcases(idn_testsuite_t ctx) {
+ assert(ctx != NULL);
+ return (ctx->ntestcases);
+}
+
+void
+idn_testsuite_setverbose(idn_testsuite_t ctx) {
+ assert(ctx != NULL);
+ ctx->verbose = 1;
+}
+
+void
+idn_testsuite_unsetverbose(idn_testsuite_t ctx) {
+ assert(ctx != NULL);
+ ctx->verbose = 0;
+}
+
+static void
+run_internal(idn_testsuite_t ctx, char *titles[]) {
+ int i, j;
+ int run_testcase;
+ const char *status;
+
+ assert(ctx != NULL);
+
+ ctx->npassed = 0;
+ ctx->nfailed = 0;
+ ctx->nskipped = 0;
+
+ for (i = 0; i < ctx->ntestcases; i++) {
+ ctx->current_testcase = ctx->testcases + i;
+ ctx->current_status = idn_teststatus_pass;
+
+ if (titles == NULL)
+ run_testcase = 1;
+ else {
+ run_testcase = 0;
+ for (j = 0; titles[j] != NULL; j++) {
+ if (strcmp(ctx->current_testcase->title,
+ titles[j]) == 0) {
+ run_testcase = 1;
+ break;
+ }
+ }
+ }
+
+ if (!run_testcase) {
+ ctx->nskipped++;
+ continue;
+ }
+ if (ctx->verbose) {
+ fprintf(stderr, "start testcase %d: %s\n", i + 1,
+ ctx->testcases[i].title);
+ }
+ (ctx->testcases[i].proc)(ctx);
+ status = idn_teststatus_tostring(ctx->current_status);
+ if (ctx->verbose) {
+ fprintf(stderr, "end testcase %d: %s\n", i + 1,
+ status);
+ }
+
+ switch (ctx->current_status) {
+ case idn_teststatus_pass:
+ ctx->npassed++;
+ break;
+ case idn_teststatus_fail:
+ ctx->nfailed++;
+ break;
+ case idn_teststatus_skip:
+ ctx->nskipped++;
+ break;
+ }
+ }
+}
+
+void
+idn_testsuite_runall(idn_testsuite_t ctx) {
+ assert(ctx != NULL);
+ run_internal(ctx, NULL);
+}
+
+void
+idn_testsuite_run(idn_testsuite_t ctx, char *titles[]) {
+ assert(ctx != NULL && titles != NULL);
+ run_internal(ctx, titles);
+}
+
+int
+idn_testsuite_npassed(idn_testsuite_t ctx) {
+ assert(ctx != NULL);
+ return (ctx->npassed);
+}
+
+int
+idn_testsuite_nfailed(idn_testsuite_t ctx) {
+ assert(ctx != NULL);
+ return (ctx->nfailed);
+}
+
+int
+idn_testsuite_nskipped(idn_testsuite_t ctx) {
+ assert(ctx != NULL);
+ return (ctx->nskipped);
+}
+
+idn_teststatus_t
+idn_testsuite_getstatus(idn_testsuite_t ctx) {
+ assert(ctx != NULL);
+ return (ctx->current_status);
+}
+
+void
+idn_testsuite_setstatus(idn_testsuite_t ctx, idn_teststatus_t status) {
+ assert(ctx != NULL);
+ assert(status == idn_teststatus_pass ||
+ status == idn_teststatus_fail ||
+ status == idn_teststatus_skip);
+
+ ctx->current_status = status;
+}
+
+const char *
+idn_teststatus_tostring(idn_teststatus_t status) {
+ assert(status == idn_teststatus_pass ||
+ status == idn_teststatus_fail ||
+ status == idn_teststatus_skip);
+
+ switch (status) {
+ case idn_teststatus_pass:
+ return "pass";
+ break;
+ case idn_teststatus_fail:
+ return "failed";
+ break;
+ case idn_teststatus_skip:
+ return "skipped";
+ break;
+ }
+
+ return "unknown";
+}
+
+void
+idn_testsuite_assert(idn_testsuite_t ctx, const char *msg,
+ const char *file, int lineno) {
+ assert(ctx != NULL && msg != NULL && file != NULL);
+
+ if (idn_testsuite_getstatus(ctx) != idn_teststatus_pass)
+ return;
+ idn_testsuite_setstatus(ctx, idn_teststatus_fail);
+ put_failure_message(ctx, msg, file, lineno);
+}
+
+void
+idn_testsuite_assertint(idn_testsuite_t ctx, int gotten, int expected,
+ const char *file, int lineno) {
+ char msg[256]; /* large enough */
+
+ assert(ctx != NULL && file != NULL);
+
+ if (idn_testsuite_getstatus(ctx) != idn_teststatus_pass)
+ return;
+ if (expected == gotten)
+ return;
+ idn_testsuite_setstatus(ctx, idn_teststatus_fail);
+
+ sprintf(msg, "`%d' expected, but got `%d'", expected, gotten);
+ put_failure_message(ctx, msg, file, lineno);
+}
+
+void
+idn_testsuite_assertstring(idn_testsuite_t ctx,
+ const char *gotten, const char *expected,
+ const char *file, int lineno) {
+ char *expected_hex = NULL;
+ char *gotten_hex = NULL;
+ char *msg;
+
+ assert(ctx != NULL && gotten != NULL && expected != NULL &&
+ file != NULL);
+
+ if (idn_testsuite_getstatus(ctx) != idn_teststatus_pass)
+ return;
+ if (strcmp(expected, gotten) == 0)
+ return;
+ idn_testsuite_setstatus(ctx, idn_teststatus_fail);
+
+ msg = (char *)malloc(strlen(expected) * 4 + strlen(gotten) * 4 + 32);
+ expected_hex = make_hex_string(expected);
+ gotten_hex = make_hex_string(gotten);
+ if (msg == NULL || expected_hex == NULL || gotten_hex == NULL) {
+ msg = "";
+ } else {
+ sprintf(msg, "`%s' expected, but got `%s'",
+ expected_hex, gotten_hex);
+ }
+
+ put_failure_message(ctx, msg, file, lineno);
+
+ free(msg);
+ free(expected_hex);
+ free(gotten_hex);
+}
+
+void
+idn_testsuite_assertptr(idn_testsuite_t ctx, const void *gotten,
+ const void *expected, const char *file, int lineno) {
+ char *msg;
+
+ assert(ctx != NULL && file != NULL);
+
+ if (idn_testsuite_getstatus(ctx) != idn_teststatus_pass)
+ return;
+ if (expected == gotten)
+ return;
+ idn_testsuite_setstatus(ctx, idn_teststatus_fail);
+
+ if (expected == NULL)
+ msg = "NULL expected, but got non-NULL";
+ else if (gotten == NULL)
+ msg = "non-NULL expected, but got NULL";
+ else
+ msg = "expected pointer != gotten pointer";
+ put_failure_message(ctx, msg, file, lineno);
+}
+
+void
+idn_testsuite_assertptrne(idn_testsuite_t ctx,
+ const void *gotten, const void *unexpected,
+ const char *file, int lineno) {
+ char *msg;
+
+ assert(ctx != NULL && file != NULL);
+
+ if (idn_testsuite_getstatus(ctx) != idn_teststatus_pass)
+ return;
+ if (unexpected != gotten)
+ return;
+ idn_testsuite_setstatus(ctx, idn_teststatus_fail);
+
+ if (unexpected == NULL)
+ msg = "non-NULL unexpected, but got NULL";
+ else if (gotten == NULL)
+ msg = "non-NULL expected, but got NULL";
+ else
+ msg = "expected pointer == gotten pointer";
+ put_failure_message(ctx, msg, file, lineno);
+}
+
+void
+idn_testsuite_assertresult(idn_testsuite_t ctx,
+ idn_result_t gotten, idn_result_t expected,
+ const char *file, int lineno) {
+ char msg[256]; /* large enough */
+
+ assert(ctx != NULL && file != NULL);
+
+ if (idn_testsuite_getstatus(ctx) != idn_teststatus_pass)
+ return;
+ if (expected == gotten)
+ return;
+ idn_testsuite_setstatus(ctx, idn_teststatus_fail);
+
+ sprintf(msg, "`%s' expected, but got `%s'",
+ idn_result_tostring(expected), idn_result_tostring(gotten));
+ put_failure_message(ctx, msg, file, lineno);
+}
+
+void
+idn_testsuite_assertucs4string(idn_testsuite_t ctx,
+ const unsigned long *gotten,
+ const unsigned long *expected,
+ const char *file, int lineno) {
+ char *expected_hex = NULL;
+ char *gotten_hex = NULL;
+ char *msg;
+
+ assert(ctx != NULL && gotten != NULL && expected != NULL &&
+ file != NULL);
+
+ if (idn_testsuite_getstatus(ctx) != idn_teststatus_pass)
+ return;
+ if (idn_ucs4_strcmp(expected, gotten) == 0)
+ return;
+ idn_testsuite_setstatus(ctx, idn_teststatus_fail);
+
+ msg = (char *)malloc(idn_ucs4_strlen(expected) * 8 +
+ idn_ucs4_strlen(gotten) * 8 + 32);
+ expected_hex = make_hex_ucs4string(expected);
+ gotten_hex = make_hex_ucs4string(gotten);
+ if (msg == NULL || expected_hex == NULL || gotten_hex == NULL) {
+ msg = "";
+ } else {
+ sprintf(msg, "`%s' expected, but got `%s'",
+ expected_hex, gotten_hex);
+ }
+
+ put_failure_message(ctx, msg, file, lineno);
+
+ free(msg);
+ free(expected_hex);
+ free(gotten_hex);
+}
+
+static char *
+make_hex_string(const char *string) {
+ static const char hex[] = {"0123456789abcdef"};
+ char *hex_string;
+ const char *src;
+ char *dst;
+
+ hex_string = (char *)malloc((strlen(string)) * 4 + 1);
+ if (hex_string == NULL)
+ return NULL;
+
+ for (src = string, dst = hex_string; *src != '\0'; src++) {
+ if (0x20 <= *src && *src <= 0x7e && *src != '\\') {
+ *dst++ = *src;
+ } else {
+ *dst++ = '\\';
+ *dst++ = 'x';
+ *dst++ = hex[*(const unsigned char *)src >> 4];
+ *dst++ = hex[*src & 0x0f];
+ }
+ }
+ *dst = '\0';
+
+ return hex_string;
+}
+
+#define UCS4_MAX 0x10fffffUL
+
+static char *
+make_hex_ucs4string(const unsigned long *string) {
+ static const char hex[] = {"0123456789abcdef"};
+ char *hex_string;
+ const unsigned long *src;
+ char *dst;
+
+ hex_string = (char *)malloc((idn_ucs4_strlen(string)) * 8 + 1);
+ if (hex_string == NULL)
+ return NULL;
+
+ for (src = string, dst = hex_string; *src != '\0'; src++) {
+ if (0x20 <= *src && *src <= 0x7e && *src != '\\') {
+ *dst++ = *src;
+ } else if (*src <= UCS4_MAX) {
+ *dst++ = '\\';
+ *dst++ = 'u';
+ if (*src >= 0x100000) {
+ *dst++ = hex[(*src >> 20) & 0x0f];
+ }
+ if (*src >= 0x10000) {
+ *dst++ = hex[(*src >> 16) & 0x0f];
+ }
+ *dst++ = hex[(*src >> 12) & 0x0f];
+ *dst++ = hex[(*src >> 8) & 0x0f];
+ *dst++ = hex[(*src >> 4) & 0x0f];
+ *dst++ = hex[*src & 0x0f];
+ } else {
+ *dst++ = '\\';
+ *dst++ = 'u';
+ *dst++ = '?';
+ *dst++ = '?';
+ *dst++ = '?';
+ *dst++ = '?';
+ }
+ }
+ *dst = '\0';
+
+ return hex_string;
+}
+
+static void
+put_failure_message(idn_testsuite_t ctx, const char *msg, const char *file,
+ int lineno) {
+ idn_testsuite_msgproc_t proc;
+ char buffer[256];
+ const char *title;
+
+ proc = (ctx->msgproc == NULL) ?
+ idn_testsuite_msgtostderr : ctx->msgproc;
+ title = (ctx->current_testcase != NULL &&
+ ctx->current_testcase->title != NULL) ?
+ ctx->current_testcase->title : "anonymous";
+
+ sprintf(buffer, "%.100s: In test `%.100s':", file, title);
+ (*proc)(buffer);
+
+ sprintf(buffer, "%.100s:%d: failed (%.100s)", file, lineno, msg);
+ (*proc)(buffer);
+}
+
+
+static void
+idn_testsuite_msgtostderr(const char *msg) {
+ fputs(msg, stderr);
+ fputc('\n', stderr);
+}
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/testsuite.h b/contrib/idn/idnkit-1.0-src/lib/tests/testsuite.h
new file mode 100644
index 0000000..a5e4774
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/testsuite.h
@@ -0,0 +1,276 @@
+/* $Id: testsuite.h,v 1.1.1.1 2003/06/04 00:27:03 marka Exp $ */
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#ifndef IDN_TESTSUITE_H
+#define IDN_TESTSUITE_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Result codes for test case.
+ */
+typedef enum {
+ idn_teststatus_pass,
+ idn_teststatus_fail,
+ idn_teststatus_skip
+} idn_teststatus_t;
+
+/*
+ * Testsuite manager type (opaque).
+ */
+typedef struct idn_testsuite *idn_testsuite_t;
+
+/*
+ * Testcase function type.
+ */
+typedef void (*idn_testsuite_testproc_t)(idn_testsuite_t ctx);
+
+/*
+ * Message handler type.
+ */
+typedef void (*idn_testsuite_msgproc_t)(const char *msg);
+
+/*
+ * Create a testsuite manager context.
+ *
+ * Create an empty context and store it in '*ctxp'.
+ * Return 1 on success. Return 0 if memory is exhausted.
+ */
+extern int
+idn_testsuite_create(idn_testsuite_t *ctxp);
+
+/*
+ * Destory the testsuite manager context.
+ *
+ * Destroy the context created by idn_testsuite_create(), and release
+ * memory allocated to the context.
+ */
+extern void
+idn_testsuite_destroy(idn_testsuite_t ctx);
+
+/*
+ * Add a test case to the `group' test group.
+ * Return 1 on success. Return 0 if memory is exhausted.
+ */
+extern int
+idn_testsuite_addtestcase(idn_testsuite_t ctx, const char *title,
+ idn_testsuite_testproc_t proc);
+
+/*
+ * Return the number of test cases registered in the context.
+ */
+extern int
+idn_testsuite_ntestcases(idn_testsuite_t ctx);
+
+/*
+ * Run test cases registered in the context.
+ */
+extern void
+idn_testsuite_runall(idn_testsuite_t ctx);
+extern void
+idn_testsuite_run(idn_testsuite_t ctx, char *titles[]);
+
+/*
+ * Return the string description of `status'.
+ */
+extern const char *
+idn_teststatus_tostring(idn_teststatus_t status);
+
+/*
+ * Return the number of passed/failed/skipped test cases.
+ */
+extern int
+idn_testsuite_npassed(idn_testsuite_t ctx);
+extern int
+idn_testsuite_nfailed(idn_testsuite_t ctx);
+extern int
+idn_testsuite_nskipped(idn_testsuite_t ctx);
+
+/*
+ * Set/Get status of the test case running currently.
+ *
+ * These functions must be called by test case function.
+ */
+extern idn_teststatus_t
+idn_testsuite_getstatus(idn_testsuite_t ctx);
+extern void
+idn_testsuite_setstatus(idn_testsuite_t ctx, idn_teststatus_t status);
+
+/*
+ * Enable/Disable verbose mode.
+ */
+extern void
+idn_testsuite_setverbose(idn_testsuite_t ctx);
+extern void
+idn_testsuite_unsetverbose(idn_testsuite_t ctx);
+
+/*
+ * Generic assertion with message
+ */
+extern void
+idn_testsuite_assert(idn_testsuite_t ctx, const char *msg,
+ const char *file, int lineno);
+
+#define ASSERT_THRU(msg) \
+ idn_testsuite_assert(ctx__, msg, __FILE__, __LINE__)
+#define ASSERT(msg) \
+ do { \
+ ASSERT_THRU(msg); \
+ if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
+ goto EXIT__; \
+ } while (0)
+
+/*
+ * Assertion function and macro to compare two `int' values.
+ * The assertion passes if `gotten' is equal to `expected'.
+ */
+extern void
+idn_testsuite_assertint(idn_testsuite_t ctx, int gotten, int expected,
+ const char *file, int lineno);
+
+#define ASSERT_INT(gotten, expected) \
+ do { \
+ idn_testsuite_assertint(ctx__, gotten, expected, __FILE__, __LINE__); \
+ if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
+ goto EXIT__; \
+ } while (0)
+
+/*
+ * Assertion function and macro to compare two strings.
+ * The assertion passes if `gotten' is lexically equal to `expected'.
+ */
+extern void
+idn_testsuite_assertstring(idn_testsuite_t ctx, const char *gotten,
+ const char *expected, const char *file, int lineno);
+
+#define ASSERT_STRING(gotten, expected) \
+ do { \
+ idn_testsuite_assertstring(ctx__, gotten, expected, __FILE__, __LINE__); \
+ if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
+ goto EXIT__; \
+ } while (0)
+
+/*
+ * Assertion function and macro to compare two pointers.
+ * The assertion passes if `gotten' is equal to `expected'.
+ */
+extern void
+idn_testsuite_assertptr(idn_testsuite_t ctx, const void *gotten,
+ const void *expected, const char *file, int lineno);
+
+#define ASSERT_PTR(gotten, expected) \
+ do { \
+ idn_testsuite_assertptr(ctx__, gotten, expected, __FILE__, __LINE__); \
+ if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
+ goto EXIT__; \
+ } while (0)
+
+/*
+ * Assertion function and macro to compare two pointers.
+ * The assertion passes if `gotten' is NOT equal to `expected'.
+ */
+extern void
+idn_testsuite_assertptrne(idn_testsuite_t ctx,
+ const void *gotten, const void *unexpected,
+ const char *file, int lineno);
+
+#define ASSERT_PTR_NE(gotten, unexpected) \
+ do { \
+ idn_testsuite_assertptrne(ctx__, gotten, unexpected, __FILE__, __LINE__); \
+ if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
+ goto EXIT__; \
+ } while (0)
+
+/*
+ * Assertion function and macro to compare two `idn_result_t' values.
+ * The assertion passes if `gotten' is equal to `expected'.
+ */
+extern void
+idn_testsuite_assertresult(idn_testsuite_t ctx,
+ idn_result_t gotten, idn_result_t expected,
+ const char *file, int lineno);
+
+#define ASSERT_RESULT(gotten, expected) \
+ do { \
+ idn_testsuite_assertresult(ctx__, gotten, expected, __FILE__, __LINE__); \
+ if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
+ goto EXIT__; \
+ } while (0)
+
+/*
+ * Assertion function and macro to compare two UCS4 strings.
+ * The assertion passes if `gotten' is lexically equal to `expected'.
+ */
+extern void
+idn_testsuite_assertucs4string(idn_testsuite_t ctx,
+ const unsigned long *gotten,
+ const unsigned long *expected,
+ const char *file,
+ int lineno);
+
+#define ASSERT_UCS4STRING_THRU(gotten, expected) \
+ idn_testsuite_assertucs4string(ctx__, gotten, expected, __FILE__, __LINE__)
+#define ASSERT_UCS4STRING(gotten, expected) \
+ do { \
+ ASSERT_UCS4STRING_THRU(gotten, expected); \
+ if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
+ goto EXIT__; \
+ } while (0)
+
+/*
+ * Shorthands.
+ */
+#define SKIP_TESTCASE \
+ do { \
+ idn_testsuite_setstatus(ctx__, idn_teststatus_skip); \
+ goto EXIT__; \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_TESTSUITE_H */
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/testutil.c b/contrib/idn/idnkit-1.0-src/lib/tests/testutil.c
new file mode 100644
index 0000000..c1872fd
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/testutil.c
@@ -0,0 +1,83 @@
+#ifndef lint
+static char *rcsid = "$Id: testutil.c,v 1.1.1.1 2003/06/04 00:27:03 marka Exp $";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include "testutil.h"
+
+int
+create_conf_file(const char *filename, unsigned int flags, ...) {
+ FILE *file;
+ va_list ap;
+ const char *arg;
+ int arg_index;
+
+ file = fopen(filename, "w");
+ if (file == NULL) {
+ fprintf(stderr, "failed to create config file `%s'\n",
+ filename);
+ return 0;
+ }
+
+ arg_index = 0;
+ va_start(ap, flags);
+ for (;;) {
+ arg = va_arg(ap, const char *);
+ if (arg == NULL)
+ break;
+ if (arg_index++ > 0)
+ fputc('\n', file);
+ fputs(arg, file);
+ }
+ if (!(flags & CONF_NO_EOF_NEWLINE) && arg_index > 0)
+ fputc('\n', file);
+
+ fclose(file);
+ return 1;
+}
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/testutil.h b/contrib/idn/idnkit-1.0-src/lib/tests/testutil.h
new file mode 100644
index 0000000..0e6405d
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/testutil.h
@@ -0,0 +1,71 @@
+/* $Id: testutil.h,v 1.1.1.1 2003/06/04 00:27:03 marka Exp $ */
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#ifndef IDN_TESTUTIL_H
+#define IDN_TESTUTIL_H 1
+
+/*
+ * Option flags for create_conf_file().
+ *
+ * CONF_NO_EOF_NEWLINE -- Don't put newline character
+ * at the end of file.
+ */
+#define CONF_NO_EOF_NEWLINE 0x0001
+
+/*
+ * Create a configuration file.
+ *
+ * Write strings specified as variable length arguments (`...') to
+ * `filename'. Note that the arguments must be terminated with `NULL'.
+ *
+ * In the created config file, each string in the variable length
+ * arguments becomes a line. In other words, newline characters are
+ * added automatically.
+ *
+ * This function returns 1 upon success, 0 otherwise.
+ */
+int
+create_conf_file(const char *filename, unsigned int flags, ...);
+
+#endif /* IDN_TESTUTIL_H */
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/testygen b/contrib/idn/idnkit-1.0-src/lib/tests/testygen
new file mode 100755
index 0000000..5d2f9ca
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/testygen
@@ -0,0 +1,557 @@
+#! /usr/bin/perl -w
+#
+# Copyright (c) 2002 Japan Network Information Center.
+# All rights reserved.
+#
+# By using this file, you agree to the terms and conditions set forth bellow.
+#
+# LICENSE TERMS AND CONDITIONS
+#
+# The following License Terms and Conditions apply, unless a different
+# license is obtained from Japan Network Information Center ("JPNIC"),
+# a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+# Chiyoda-ku, Tokyo 101-0047, Japan.
+#
+# 1. Use, Modification and Redistribution (including distribution of any
+# modified or derived work) in source and/or binary forms is permitted
+# under this License Terms and Conditions.
+#
+# 2. Redistribution of source code must retain the copyright notices as they
+# appear in each source code file, this License Terms and Conditions.
+#
+# 3. Redistribution in binary form must reproduce the Copyright Notice,
+# this License Terms and Conditions, in the documentation and/or other
+# materials provided with the distribution. For the purposes of binary
+# distribution the "Copyright Notice" refers to the following language:
+# "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+#
+# 4. The name of JPNIC may not be used to endorse or promote products
+# derived from this Software without specific prior written approval of
+# JPNIC.
+#
+# 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+#
+use FileHandle;
+use Getopt::Std;
+
+#
+# Parsing status.
+#
+my $STATUS_HEADER = 0;
+my $STATUS_HEADER_COMMENT = 1;
+my $STATUS_SEPARATOR = 2;
+my $STATUS_BODY = 3;
+my $STATUS_GLOBAL = 4;
+my $STATUS_GLOBAL_COMMENT = 5;
+my $STATUS_PREAMBLE = 6;
+
+my $LINENO_MARK = "<LINENO>";
+
+#
+# Create a new testsuite context.
+#
+sub new_testsuite {
+ return {'ntests' => 0,
+ 'setups' => {},
+ 'teardowns' => {},
+ 'tests' => [],
+ 'titles' => [],
+ 'preambles' => ''};
+}
+
+#
+# Read `$file' and put the result into `$testsutie'.
+#
+sub parse_file {
+ my ($testsuite, $file, $lineinfo) = @_;
+ my $parser = {'type' => '',
+ 'group' => '',
+ 'title' => '',
+ 'status' => $STATUS_PREAMBLE,
+ 'error' => '',
+ 'file' => $file,
+ 'lineno' => 0,
+ 'lineinfo' => $lineinfo};
+
+ my $handle = FileHandle->new($file, 'r');
+ if (!defined($handle)) {
+ die "failed to open the file, $!: $file\n";
+ }
+
+ my ($result, $line);
+ for (;;) {
+ $line = $handle->getline();
+ last if (!defined($line));
+
+ chomp($line);
+ $line .= "\n";
+ $parser->{lineno}++;
+ $result = parse_line($testsuite, $parser, $line);
+ if (!$result) {
+ die sprintf("%s, at line %d\n",
+ $parser->{error}, $parser->{lineno});
+ }
+ }
+
+ if ($parser->{status} != $STATUS_GLOBAL) {
+ die "unexpected EOF, at line $.\n";
+ }
+
+ $handle->close();
+}
+
+sub parse_line {
+ my ($testsuite, $parser, $line) = @_;
+ my $result = 1;
+
+ if ($parser->{status} == $STATUS_HEADER) {
+ if ($line =~ /^\/\/--/) {
+ $parser->{status} = $STATUS_HEADER_COMMENT;
+ } elsif ($line =~ /^\/\//) {
+ $result = parse_header($testsuite, $parser, $line);
+ } elsif ($line =~ /^\s*$/) {
+ $parser->{status} = $STATUS_SEPARATOR;
+ $result = parse_endheader($testsuite, $parser, $line);
+ } elsif ($line =~ /^\{\s*$/) {
+ $parser->{status} = $STATUS_BODY;
+ $result = parse_endheader($testsuite, $parser, $line)
+ && parse_startbody($testsuite, $parser, $line);
+ } else {
+ $parser->{error} = 'syntax error';
+ $result = 0;
+ }
+
+ } elsif ($parser->{status} == $STATUS_HEADER_COMMENT) {
+ if ($line =~ /^\/\//) {
+ # nothing to be done.
+ } elsif ($line =~ /^\s*$/) {
+ $parser->{status} = $STATUS_SEPARATOR;
+ $result = parse_endheader($testsuite, $parser, $line);
+ } elsif ($line =~ /^\{\s*$/) {
+ $parser->{status} = $STATUS_BODY;
+ $result = parse_endheader($testsuite, $parser, $line)
+ && parse_startbody($testsuite, $parser, $line);
+ } else {
+ $parser->{error} = 'syntax error';
+ $result = 0;
+ }
+
+ } elsif ($parser->{status} == $STATUS_SEPARATOR) {
+ if ($line =~ /^\s*$/) {
+ # nothing to be done.
+ } elsif ($line =~ /^\{\s*$/) {
+ $parser->{status} = $STATUS_BODY;
+ $result = parse_startbody($testsuite, $parser, $line);
+ } else {
+ $parser->{error} = 'syntax error';
+ $result = 0;
+ }
+
+ } elsif ($parser->{status} == $STATUS_BODY) {
+ if ($line =~ /^\}\s*$/) {
+ $parser->{status} = $STATUS_GLOBAL;
+ $result = parse_endbody($testsuite, $parser, $line);
+ } else {
+ $result = parse_body($testsuite, $parser, $line);
+ }
+
+ } elsif ($parser->{status} == $STATUS_GLOBAL) {
+ if ($line =~ /^\/\/\#/) {
+ $parser->{status} = $STATUS_HEADER;
+ $result = parse_startheader($testsuite, $parser, $line);
+ } elsif ($line =~ /^\/\/--/) {
+ $parser->{status} = $STATUS_GLOBAL_COMMENT;
+ } elsif ($line =~ /^\s*$/) {
+ # nothing to be done.
+ } else {
+ $parser->{error} = 'syntax error';
+ $result = 0;
+ }
+
+ } elsif ($parser->{status} == $STATUS_GLOBAL_COMMENT) {
+ if ($line =~ /^\/\//) {
+ # nothing to be done.
+ } elsif ($line =~ /^\s*$/) {
+ $parser->{status} = $STATUS_GLOBAL;
+ } else {
+ $parser->{error} = 'syntax error';
+ $result = 0;
+ }
+
+ } elsif ($parser->{status} == $STATUS_PREAMBLE) {
+ if ($line =~ /^\/\/\#/) {
+ $parser->{status} = $STATUS_HEADER;
+ $result = parse_startheader($testsuite, $parser, $line);
+ } elsif ($line =~ /^\/\/--/) {
+ $parser->{status} = $STATUS_GLOBAL_COMMENT;
+ } else {
+ $result = parse_preamble($testsuite, $parser, $line);
+ }
+
+ } else {
+ $parser->{error} = 'syntax error';
+ $result = 0;
+ }
+
+ return $result;
+}
+
+sub parse_startheader {
+ my ($testsuite, $parser, $line) = @_;
+
+ if ($line =~ /^\/\/\#\s*(SETUP|TEARDOWN|TESTCASE)\s*$/) {
+ $parser->{type} = $1;
+ $parser->{group} = '';
+ $parser->{title} = '';
+ } else {
+ $parser->{error} = 'invalid test-header format';
+ return 0;
+ }
+
+
+ return 1;
+}
+
+sub parse_header {
+ my ($testsuite, $parser, $line) = @_;
+
+ my $field = $line;
+ $field =~ s/^\/\/\s*//;
+ $field =~ s/^(\S+):\s*/$1:/;
+ $field =~ s/\s+$//;
+
+ return 1 if ($field eq '');
+
+ if ($field =~ /^group:(.*)$/) {
+ my $group = $1;
+
+ if ($parser->{group} ne '') {
+ $parser->{error} = "group defined twice in a header";
+ return 0;
+ }
+ if ($parser->{type} eq 'SETUP') {
+ if ($group !~ /^[0-9A-Za-z_\-]+$/) {
+ $parser->{error} = "invalid group name";
+ return 0;
+ }
+ if (defined($testsuite->{setups}->{$group})) {
+ $parser->{error} = sprintf("SETUP \`%s' redefined", $group);
+ return 0;
+ }
+ } elsif ($parser->{type} eq 'TEARDOWN') {
+ if ($group !~ /^[0-9A-Za-z_\-]+$/) {
+ $parser->{error} = "invalid group name";
+ return 0;
+ }
+ if (defined($testsuite->{teardowns}->{$group})) {
+ $parser->{error} = sprintf("TEARDOWN \`%s' redefined", $group);
+ return 0;
+ }
+ } else {
+ foreach my $i (split(/[ \t]+/, $group)) {
+ if ($i !~ /^[0-9A-Za-z_\-]+$/) {
+ $parser->{error} = "invalid group name \`$i'";
+ return 0;
+ }
+ if (!defined($testsuite->{setups}->{$i})
+ && !defined($testsuite->{teardowns}->{$i})) {
+ $parser->{error} = sprintf("group \'%s' not defined", $i);
+ return 0;
+ }
+ }
+ }
+ $parser->{group} = $group;
+
+ } elsif ($field =~ /^title:(.*)$/) {
+ my $title = $1;
+
+ if ($parser->{title} ne '') {
+ $parser->{error} = "title defined twice in a header";
+ return 0;
+ }
+ if ($title =~ /[\x00-\x1f\x7f-\xff\"\\]/ || $title eq '') {
+ $parser->{error} = "invalid title";
+ return 0;
+ }
+ if ($parser->{type} ne 'TESTCASE') {
+ $parser->{error} = sprintf("title for %s is not permitted",
+ $parser->{type});
+ return 0;
+ }
+ $parser->{title} = $title;
+
+ } else {
+ $parser->{error} = "invalid test-header field";
+ return 0;
+ }
+
+ return 1;
+}
+
+sub parse_endheader {
+ my ($testsuite, $parser, $line) = @_;
+
+ if ($parser->{type} ne 'TESTCASE' && $parser->{group} eq '') {
+ $parser->{error} = "missing \`group' in the header";
+ return 0;
+ }
+
+ if ($parser->{type} eq 'TESTCASE' && $parser->{title} eq '') {
+ $parser->{error} = "missing \`title' in the header";
+ return 0;
+ }
+
+ return 1;
+}
+
+sub parse_startbody {
+ my ($testsuite, $parser, $line) = @_;
+ my $group = $parser->{group};
+
+ if ($parser->{type} eq 'SETUP') {
+ if ($parser->{lineinfo}) {
+ $testsuite->{setups}->{$group} =
+ generate_line_info($parser->{lineno} + 1, $parser->{file});
+ }
+ } elsif ($parser->{type} eq 'TEARDOWN') {
+ if ($parser->{lineinfo}) {
+ $testsuite->{teardowns}->{$group} =
+ generate_line_info($parser->{lineno} + 1, $parser->{file});
+ }
+ } else {
+ $testsuite->{ntests}++;
+ push(@{$testsuite->{tests}}, '');
+ push(@{$testsuite->{titles}}, $parser->{title});
+
+ $testsuite->{tests}->[-1] .= "\n";
+ $testsuite->{tests}->[-1] .= "$LINENO_MARK\n";
+ $testsuite->{tests}->[-1] .=
+ sprintf("static void\ntestcase\%d(idn_testsuite_t ctx__) {\n",
+ $testsuite->{ntests});
+
+ my (@group_names) = split(/[ \t]+/, $group);
+ for (my $i = 0; $i < @group_names; $i++) {
+ if (defined($testsuite->{setups}->{$group_names[$i]})) {
+ $testsuite->{tests}->[-1] .= "\t\{\n";
+ $testsuite->{tests}->[-1] .= "#undef EXIT__\n";
+ $testsuite->{tests}->[-1] .= "#define EXIT__ exit${i}__\n";
+ $testsuite->{tests}->[-1] .=
+ $testsuite->{setups}->{$group_names[$i]};
+ }
+ }
+ $testsuite->{tests}->[-1] .= "$LINENO_MARK\n";
+ $testsuite->{tests}->[-1] .= "\t\{\n";
+ $testsuite->{tests}->[-1] .= "#undef EXIT__\n";
+ $testsuite->{tests}->[-1] .= "#define EXIT__ exit__\n";
+ if ($parser->{lineinfo}) {
+ $testsuite->{tests}->[-1] .=
+ generate_line_info($parser->{lineno} + 1, $parser->{file});
+ }
+ }
+
+ return 1;
+}
+
+sub parse_body {
+ my ($testsuite, $parser, $line) = @_;
+ my ($group) = $parser->{group};
+
+ if ($parser->{type} eq 'SETUP') {
+ $testsuite->{setups}->{$group} .= $line;
+ } elsif ($parser->{type} eq 'TEARDOWN') {
+ $testsuite->{teardowns}->{$group} .= $line;
+ } else {
+ $testsuite->{tests}->[-1] .= $line;
+ }
+
+ return 1;
+}
+
+sub parse_endbody {
+ my ($testsuite, $parser, $line) = @_;
+ my ($group) = $parser->{group};
+
+ if ($parser->{type} eq 'TESTCASE') {
+ $testsuite->{tests}->[-1] .= "$LINENO_MARK\n";
+ $testsuite->{tests}->[-1] .= "\t\}\n";
+ $testsuite->{tests}->[-1] .= " exit__:\n";
+ $testsuite->{tests}->[-1] .= "\t;\n";
+
+ my (@group_names) = split(/[ \t]+/, $group);
+ for (my $i = @group_names - 1; $i >= 0; $i--) {
+ $testsuite->{tests}->[-1] .= " exit${i}__:\n";
+ $testsuite->{tests}->[-1] .= "\t;\n";
+ if (defined($testsuite->{teardowns}->{$group_names[$i]})) {
+ $testsuite->{tests}->[-1] .=
+ $testsuite->{teardowns}->{$group_names[$i]};
+ }
+ $testsuite->{tests}->[-1] .= "$LINENO_MARK\n";
+ $testsuite->{tests}->[-1] .= "\t\}\n";
+ }
+
+ $testsuite->{tests}->[-1] .= "}\n";
+ }
+
+ return 1;
+}
+
+sub parse_preamble {
+ my ($testsuite, $parser, $line) = @_;
+
+ if ($parser->{lineinfo} && $parser->{lineno} == 1) {
+ $testsuite->{preambles} .= generate_line_info(1, $parser->{file});
+ }
+ $testsuite->{preambles} .= $line;
+ return 1;
+}
+
+sub generate_line_info {
+ my ($lineno, $file) = @_;
+ return "#line $lineno \"$file\"\n";
+}
+
+#
+# Output `$testsuite' as source codes of C.
+#
+sub output_tests {
+ my ($testsuite, $file, $lineinfo) = @_;
+
+ my $generator = {
+ 'file' => $file,
+ 'lineno' => 0
+ };
+
+ my $handle = FileHandle->new($file, 'w');
+ if (!defined($handle)) {
+ die "failed to open the file, $!: $file\n";
+ }
+
+ my $preamble_header =
+ "/* This file is automatically generated by testygen. */\n\n"
+ . "#define TESTYGEN 1\n"
+ . "\n";
+ output_lines($preamble_header, $generator, $handle, $lineinfo);
+
+ output_lines($testsuite->{preambles}, $generator, $handle, $lineinfo);
+
+ my $preamble_footer =
+ "\n"
+ . "$LINENO_MARK\n"
+ . "#include \"testsuite.h\"\n"
+ . "\n";
+ output_lines($preamble_footer, $generator, $handle, $lineinfo);
+
+
+ for (my $i = 0; $i < $testsuite->{ntests}; $i++) {
+ output_lines($testsuite->{tests}->[$i], $generator, $handle,
+ $lineinfo);
+ }
+
+ my $main_header =
+ "\n"
+ . "$LINENO_MARK\n"
+ . "int\n"
+ . "main(int argc, char *argv[]) {\n"
+ . "\tidn_testsuite_t ctx;\n"
+ . "\tconst char *title;\n"
+ . "\n"
+ . "\tidn_testsuite_create(&ctx);\n";
+ output_lines($main_header, $generator, $handle, $lineinfo);
+
+ for (my $i = 0; $i < $testsuite->{ntests}; $i++) {
+ my $title = $testsuite->{titles}->[$i];
+ my $proc = sprintf("testcase%d", $i + 1);
+ output_lines("\tidn_testsuite_addtestcase(ctx, \"$title\", $proc);\n",
+ $generator, $handle, $lineinfo);
+ }
+
+ my $main_footer =
+ "\n"
+ . "\tif (argc > 1 && strcmp(argv[1], \"-v\") == 0) {\n"
+ . "\t idn_testsuite_setverbose(ctx);\n"
+ . "\t argc--;\n"
+ . "\t argv++;\n"
+ . "\t}\n"
+ . "\tif (argc == 1)\n"
+ . "\t idn_testsuite_runall(ctx);\n"
+ . "\telse\n"
+ . "\t idn_testsuite_run(ctx, argv + 1);\n"
+ . "\n"
+ . "\tprintf(\"passed=%d, failed=%d, total=%d\\n\",\n"
+ . "\t idn_testsuite_npassed(ctx),\n"
+ . "\t idn_testsuite_nfailed(ctx),\n"
+ . "\t idn_testsuite_ntestcases(ctx) - idn_testsuite_nskipped(ctx));\n"
+ . "\n"
+ . "\tidn_testsuite_destroy(ctx);\n"
+ . "\treturn (0);\n"
+ . "\}\n";
+ output_lines($main_footer, $generator, $handle, $lineinfo);
+
+ $handle->close();
+}
+
+sub output_lines {
+ my ($lines, $generator, $handle, $lineinfo) = @_;
+ my ($line);
+
+ chomp($lines);
+ $lines .= "\n";
+
+ while ($lines ne '') {
+ $lines =~ s/^([^\n]*)\n//;
+ $line = $1;
+ $generator->{lineno}++;
+ if ($line eq $LINENO_MARK) {
+ if ($lineinfo) {
+ $handle->printf("#line %d \"%s\"\n", $generator->{lineno} + 1,
+ $generator->{file});
+ }
+ } else {
+ $handle->print("$line\n");
+ }
+ }
+}
+
+sub output_usage {
+ warn "$0: [-o output-file] input-file\n";
+}
+
+#
+# main.
+#
+my (%options);
+
+if (!getopts('Lo:', \%options)) {
+ output_usage;
+ exit(1);
+}
+if (@ARGV != 1) {
+ output_usage;
+ exit(1);
+}
+
+my ($in_file) = $ARGV[0];
+my ($out_file);
+if (!defined($options{o})) {
+ $out_file = $in_file;
+ $out_file .= '\.tsy' if ($out_file !~ /\.tsy$/);
+ $out_file =~ s/\.tsy$/\.c/;
+} else {
+ $out_file = $options{o};
+}
+
+my $testsuite = new_testsuite();
+parse_file($testsuite, $in_file, !$options{L});
+output_tests($testsuite, $out_file, !$options{L});
+
+exit(0);
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/ucs4.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/ucs4.tsy
new file mode 100644
index 0000000..205edae
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/ucs4.tsy
@@ -0,0 +1,257 @@
+#ifndef lint
+static char *rcsid = "$Id: ucs4.tsy,v 1.1.1.1 2003/06/04 00:27:04 marka Exp $";
+#endif
+
+/*
+ * Copyright (c) 2002 Japan Network Information Center.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set forth bellow.
+ *
+ * LICENSE TERMS AND CONDITIONS
+ *
+ * The following License Terms and Conditions apply, unless a different
+ * license is obtained from Japan Network Information Center ("JPNIC"),
+ * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+ * Chiyoda-ku, Tokyo 101-0047, Japan.
+ *
+ * 1. Use, Modification and Redistribution (including distribution of any
+ * modified or derived work) in source and/or binary forms is permitted
+ * under this License Terms and Conditions.
+ *
+ * 2. Redistribution of source code must retain the copyright notices as they
+ * appear in each source code file, this License Terms and Conditions.
+ *
+ * 3. Redistribution in binary form must reproduce the Copyright Notice,
+ * this License Terms and Conditions, in the documentation and/or other
+ * materials provided with the distribution. For the purposes of binary
+ * distribution the "Copyright Notice" refers to the following language:
+ * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+ *
+ * 4. The name of JPNIC may not be used to endorse or promote products
+ * derived from this Software without specific prior written approval of
+ * JPNIC.
+ *
+ * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <idn/ucs4.h>
+#include <idn/log.h>
+#include "testutil.h"
+
+/*
+ * Sample UTF8 and UCS4 strings.
+ */
+static const char *utf8_string =
+ "\x7f" /* 0x0000007f */
+ "\xdf\xbf" /* 0x000007ff */
+ "\xef\xbf\xbf" /* 0x0000ffff */
+ "\xf7\xbf\xbf\xbf" /* 0x001fffff */
+ "\xfb\xbf\xbf\xbf\xbf" /* 0x03ffffff */
+ "\xfd\xbf\xbf\xbf\xbf\xbf"; /* 0x7fffffff */
+
+static const unsigned long ucs4_string[] = {
+ 0x0000007f,
+ 0x000007ff,
+ 0x0000ffff,
+ 0x001fffff,
+ 0x03ffffff,
+ 0x7fffffff,
+ 0x00000000
+};
+
+//--------------------------------------------------------------------
+// Setups and Teardowns.
+//--------------------------------------------------------------------
+
+//# SETUP
+// group: utf8-init
+{
+ unsigned long to[256];
+ size_t tolen = 256;
+ idn_result_t r;
+}
+
+//# SETUP
+// group: ucs4-init
+{
+ char to[256];
+ size_t tolen = 256;
+ idn_result_t r;
+}
+
+//# SETUP
+// group: quiet
+{
+ int saved_log_level;
+
+ saved_log_level = idn_log_getlevel();
+ idn_log_setlevel(idn_log_level_fatal);
+}
+
+//# TEARDOWN
+// group: quiet
+{
+ idn_log_setlevel(saved_log_level);
+}
+
+//--------------------------------------------------------------------
+// Testcases.
+//--------------------------------------------------------------------
+
+//# TESTCASE
+// title: call utf8toucs4()
+// group: utf8-init
+{
+ r = idn_ucs4_utf8toucs4(utf8_string, to, tolen);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, ucs4_string);
+}
+
+//# TESTCASE
+// title: call ucs4toutf8()
+// group: ucs4-init
+{
+ r = idn_ucs4_ucs4toutf8(ucs4_string, to, tolen);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, utf8_string);
+}
+
+//# TESTCASE
+// title: call utf8toucs4() with empty from
+// group: utf8-init
+{
+ static unsigned long empty_ucs4_string[] = {0};
+
+ r = idn_ucs4_utf8toucs4("", to, tolen);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, empty_ucs4_string);
+}
+
+//# TESTCASE
+// title: call ucs4toutf8() with empty from
+// group: ucs4-init
+{
+ static unsigned long empty_ucs4_string[] = {0};
+
+ r = idn_ucs4_ucs4toutf8(empty_ucs4_string, to, tolen);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, "");
+}
+
+//# TESTCASE
+// title: call utf8toucs4() with broken string
+// group: utf8-init quiet
+{
+ /* "\xfe" as the 1st byte is out of range. */
+ r = idn_ucs4_utf8toucs4("\xfe\xbf\xbf\xbf\xbf\xbf\xbf", to, tolen);
+ ASSERT_RESULT(r, idn_invalid_encoding);
+
+ /* "\x7f" as the 2nd byte is out of range. */
+ r = idn_ucs4_utf8toucs4("\xdf\x7f", to, tolen);
+ ASSERT_RESULT(r, idn_invalid_encoding);
+
+ /* "\xc0" as the 2nd byte is out of range. */
+ r = idn_ucs4_utf8toucs4("\xdf\xc0", to, tolen);
+ ASSERT_RESULT(r, idn_invalid_encoding);
+
+ /* "\x7f" as the 3rd byte is out of range. */
+ r = idn_ucs4_utf8toucs4("\xef\xbf\x7f", to, tolen);
+ ASSERT_RESULT(r, idn_invalid_encoding);
+
+ /* "\xc0" as the 3rd byte is out of range. */
+ r = idn_ucs4_utf8toucs4("\xef\xbf\xc0", to, tolen);
+ ASSERT_RESULT(r, idn_invalid_encoding);
+
+ /* "\x7f" as the 4th byte is out of range. */
+ r = idn_ucs4_utf8toucs4("\xf7\xbf\xbf\x7f", to, tolen);
+ ASSERT_RESULT(r, idn_invalid_encoding);
+
+ /* "\xc0" as the 4th byte is out of range. */
+ r = idn_ucs4_utf8toucs4("\xf7\xbf\xbf\xc0", to, tolen);
+ ASSERT_RESULT(r, idn_invalid_encoding);
+
+ /* "\x7f" as the 5th byte is out of range. */
+ r = idn_ucs4_utf8toucs4("\xfb\xbf\xbf\xbf\x7f", to, tolen);
+ ASSERT_RESULT(r, idn_invalid_encoding);
+
+ /* "\xc0" as the 5th byte is out of range. */
+ r = idn_ucs4_utf8toucs4("\xfb\xbf\xbf\xbf\xc0", to, tolen);
+ ASSERT_RESULT(r, idn_invalid_encoding);
+
+ /* "\x7f" as the 6th byte is out of range. */
+ r = idn_ucs4_utf8toucs4("\xfd\xbf\xbf\xbf\xbf\x7f", to, tolen);
+ ASSERT_RESULT(r, idn_invalid_encoding);
+
+ /* "\xc0" as the 6th byte is out of range. */
+ r = idn_ucs4_utf8toucs4("\xfd\xbf\xbf\xbf\xbf\xc0", to, tolen);
+ ASSERT_RESULT(r, idn_invalid_encoding);
+
+ /* `from' contains surrogate pair */
+ r = idn_ucs4_utf8toucs4("\xed\xa0\x80\xed\xbf\xbf", to, tolen);
+ ASSERT_RESULT(r, idn_invalid_encoding);
+}
+
+//# TESTCASE
+// title: call ucs4toutf8() with broken string
+// group: ucs4-init quiet
+{
+ static unsigned long invalid_ucs4_string0[] = {0x80000000, 0};
+ static unsigned long invalid_ucs4_string1[] = {0xd800, 0xdfff, 0};
+
+ /* 0x80000000 is out of range */
+ r = idn_ucs4_ucs4toutf8(invalid_ucs4_string0, to, tolen);
+ ASSERT_RESULT(r, idn_invalid_encoding);
+
+ /* `from' contains surrogate pair */
+ r = idn_ucs4_ucs4toutf8(invalid_ucs4_string1, to, tolen);
+ ASSERT_RESULT(r, idn_invalid_encoding);
+}
+
+//# TESTCASE
+// title: buffer overrun test for utf8toucs4()
+// group: utf8-init
+{
+ r = idn_ucs4_utf8toucs4(utf8_string, to,
+ idn_ucs4_strlen(ucs4_string) + 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_UCS4STRING(to, ucs4_string);
+
+ r = idn_ucs4_utf8toucs4(utf8_string, to,
+ idn_ucs4_strlen(ucs4_string));
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ r = idn_ucs4_utf8toucs4(utf8_string, to, 0);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+}
+
+//# TESTCASE
+// title: buffer overrun test for ucs4toutf8()
+// group: ucs4-init
+{
+ r = idn_ucs4_ucs4toutf8(ucs4_string, to, strlen(utf8_string) + 1);
+ ASSERT_RESULT(r, idn_success);
+ ASSERT_STRING(to, utf8_string);
+
+ r = idn_ucs4_ucs4toutf8(ucs4_string, to, strlen(utf8_string));
+ ASSERT_RESULT(r, idn_buffer_overflow);
+
+ r = idn_ucs4_ucs4toutf8(ucs4_string, to, 0);
+ ASSERT_RESULT(r, idn_buffer_overflow);
+}
+
diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/utffilter b/contrib/idn/idnkit-1.0-src/lib/tests/utffilter
new file mode 100755
index 0000000..cebd4dc
--- /dev/null
+++ b/contrib/idn/idnkit-1.0-src/lib/tests/utffilter
@@ -0,0 +1,82 @@
+#! /usr/bin/perl -wp
+#
+# Copyright (c) 2002 Japan Network Information Center.
+# All rights reserved.
+#
+# By using this file, you agree to the terms and conditions set forth bellow.
+#
+# LICENSE TERMS AND CONDITIONS
+#
+# The following License Terms and Conditions apply, unless a different
+# license is obtained from Japan Network Information Center ("JPNIC"),
+# a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+# Chiyoda-ku, Tokyo 101-0047, Japan.
+#
+# 1. Use, Modification and Redistribution (including distribution of any
+# modified or derived work) in source and/or binary forms is permitted
+# under this License Terms and Conditions.
+#
+# 2. Redistribution of source code must retain the copyright notices as they
+# appear in each source code file, this License Terms and Conditions.
+#
+# 3. Redistribution in binary form must reproduce the Copyright Notice,
+# this License Terms and Conditions, in the documentation and/or other
+# materials provided with the distribution. For the purposes of binary
+# distribution the "Copyright Notice" refers to the following language:
+# "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
+#
+# 4. The name of JPNIC may not be used to endorse or promote products
+# derived from this Software without specific prior written approval of
+# JPNIC.
+#
+# 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+#
+
+sub to_utf8 ($) {
+ my ($utf32) = hex($_[0]);
+ my ($mask, $length);
+
+ if ($utf32 < 0x80) {
+ $mask = 0;
+ $length = 1;
+ } elsif ($utf32 < 0x800) {
+ $mask = 0xc0;
+ $length = 2;
+ } elsif ($utf32 < 0x10000) {
+ $mask = 0xe0;
+ $length = 3;
+ } elsif ($utf32 < 0x200000) {
+ $mask = 0xf0;
+ $length = 4;
+ } elsif ($utf32 < 0x4000000) {
+ $mask = 0xf8;
+ $length = 5;
+ } elsif ($utf32 < 0x80000000) {
+ $mask = 0xfc;
+ $length = 6;
+ } else {
+ return '';
+ }
+
+ my ($result, $offset);
+ $offset = 6 * ($length - 1);
+ $result .= sprintf('\\x%02x', ($utf32 >> $offset) | $mask);
+ while ($offset > 0) {
+ $offset -= 6;
+ $result .= sprintf('\\x%02x', (($utf32 >> $offset) & 0x3f) | 0x80);
+ }
+
+ return $result;
+}
+
+s/<U\+([0-9A-Fa-f]+)>/&to_utf8($1)/eg;