removed old libs
[TestXSLT.git] / libiconv / tests / check-stateless
1 #!/bin/sh
2 # Complete check of a stateless encoding.
3 # Usage: check-stateless SRCDIR CHARSET
4 srcdir="$1"
5 charset="$2"
6 set -e
7
8 # iconv in one direction.
9 ./table-from "$charset" > tmp-"$charset".TXT
10
11 # iconv in the other direction.
12 ./table-to "$charset" | sort > tmp-"$charset".INVERSE.TXT
13
14 # Check 1: charmap and iconv forward should be identical.
15 cmp "${srcdir}"/"$charset".TXT tmp-"$charset".TXT 2> /dev/null
16
17 # Check 2: the difference between the charmap and iconv backward.
18 sed -e '/       .* 0x/d' < "${srcdir}"/"$charset".TXT > tmp-noprecomposed-"$charset".TXT
19 if test -f "${srcdir}"/"$charset".IRREVERSIBLE.TXT; then
20   cat tmp-noprecomposed-"$charset".TXT "${srcdir}"/"$charset".IRREVERSIBLE.TXT | sort | uniq -u > tmp-orig-"$charset".INVERSE.TXT
21 else
22   cp tmp-noprecomposed-"$charset".TXT tmp-orig-"$charset".INVERSE.TXT
23 fi
24 cmp tmp-orig-"$charset".INVERSE.TXT tmp-"$charset".INVERSE.TXT 2> /dev/null
25
26 rm -f tmp-"$charset".TXT tmp-"$charset".INVERSE.TXT tmp-noprecomposed-"$charset".TXT tmp-orig-"$charset".INVERSE.TXT
27 exit 0
28 # For a new encoding:
29 # You can create the "$charset".TXT like this:
30 #   ./table-from "$charset" > "$charset".TXT
31 # You can create the "$charset".IRREVERSIBLE.TXT like this:
32 #   ./table-to "$charset" | sort > "$charset".INVERSE.TXT
33 #   diff "$charset".TXT "$charset".INVERSE.TXT | grep '^[<>]' | sed -e 's,^. ,,' > "$charset".IRREVERSIBLE.TXT