summaryrefslogtreecommitdiff
path: root/jni/iconv/tests/check-stateless
diff options
context:
space:
mode:
authorJari Vetoniemi <jari.vetoniemi@indooratlas.com>2020-03-16 18:49:26 +0900
committerJari Vetoniemi <jari.vetoniemi@indooratlas.com>2020-03-30 00:39:06 +0900
commitfcbf63e62c627deae76c1b8cb8c0876c536ed811 (patch)
tree64cb17de3f41a2b6fef2368028fbd00349946994 /jni/iconv/tests/check-stateless
Fresh start
Diffstat (limited to 'jni/iconv/tests/check-stateless')
-rwxr-xr-xjni/iconv/tests/check-stateless36
1 files changed, 36 insertions, 0 deletions
diff --git a/jni/iconv/tests/check-stateless b/jni/iconv/tests/check-stateless
new file mode 100755
index 0000000..7104ea1
--- /dev/null
+++ b/jni/iconv/tests/check-stateless
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Complete check of a stateless encoding.
+# Usage: check-stateless SRCDIR CHARSET
+srcdir="$1"
+charset="$2"
+set -e
+
+# charset, modified for use in filenames.
+charsetf=`echo "$charset" | sed -e 's,:,-,g'`
+
+# iconv in one direction.
+./table-from "$charset" > tmp-"$charsetf".TXT
+
+# iconv in the other direction.
+./table-to "$charset" | sort > tmp-"$charsetf".INVERSE.TXT
+
+# Check 1: charmap and iconv forward should be identical.
+cmp "${srcdir}"/"$charsetf".TXT tmp-"$charsetf".TXT 2> /dev/null
+
+# Check 2: the difference between the charmap and iconv backward.
+sed -e '/ .* 0x/d' < "${srcdir}"/"$charsetf".TXT > tmp-noprecomposed-"$charsetf".TXT
+if test -f "${srcdir}"/"$charsetf".IRREVERSIBLE.TXT; then
+ cat tmp-noprecomposed-"$charsetf".TXT "${srcdir}"/"$charsetf".IRREVERSIBLE.TXT | sort | uniq -u > tmp-orig-"$charsetf".INVERSE.TXT
+else
+ cp tmp-noprecomposed-"$charsetf".TXT tmp-orig-"$charsetf".INVERSE.TXT
+fi
+cmp tmp-orig-"$charsetf".INVERSE.TXT tmp-"$charsetf".INVERSE.TXT 2> /dev/null
+
+rm -f tmp-"$charsetf".TXT tmp-"$charsetf".INVERSE.TXT tmp-noprecomposed-"$charsetf".TXT tmp-orig-"$charsetf".INVERSE.TXT
+exit 0
+# For a new encoding:
+# You can create the "$charsetf".TXT like this:
+# ./table-from "$charset" > "$charsetf".TXT
+# You can create the "$charsetf".IRREVERSIBLE.TXT like this:
+# ./table-to "$charset" | sort > "$charsetf".INVERSE.TXT
+# diff "$charsetf".TXT "$charsetf".INVERSE.TXT | grep '^[<>]' | sed -e 's,^. ,,' > "$charsetf".IRREVERSIBLE.TXT