summaryrefslogtreecommitdiff
path: root/regress/lib/libedit/read
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2016-02-11 20:54:07 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2016-02-11 20:54:07 +0000
commit8f6fb2ebd6556bd6e616bc34e23dcd2c3d8020ca (patch)
tree99350a83fe17fedfadde4f615bc9ebd3ee67771a /regress/lib/libedit/read
parenta1d5bc2533c49010727a53820497ae006a0c0de7 (diff)
Test the C/POSIX locale too, in addition to UTF-8.
Diffstat (limited to 'regress/lib/libedit/read')
-rw-r--r--regress/lib/libedit/read/test_read_char.c2
-rw-r--r--regress/lib/libedit/read/test_read_char.sh52
2 files changed, 37 insertions, 17 deletions
diff --git a/regress/lib/libedit/read/test_read_char.c b/regress/lib/libedit/read/test_read_char.c
index 94487134c05..75184edac40 100644
--- a/regress/lib/libedit/read/test_read_char.c
+++ b/regress/lib/libedit/read/test_read_char.c
@@ -79,7 +79,7 @@ main(void)
int irc;
Char cp;
- if (setlocale(LC_CTYPE, "en_US.UTF-8") == NULL)
+ if (setlocale(LC_CTYPE, "") == NULL)
err(1, "setlocale");
el.el_flags = CHARSET_IS_UTF8;
el.el_infd = STDIN_FILENO;
diff --git a/regress/lib/libedit/read/test_read_char.sh b/regress/lib/libedit/read/test_read_char.sh
index 5ed2f1b7f41..2493c73915e 100644
--- a/regress/lib/libedit/read/test_read_char.sh
+++ b/regress/lib/libedit/read/test_read_char.sh
@@ -17,30 +17,50 @@
testrc()
{
stdin=$1
- expected=$2
- result=`echo -n "$stdin" | ./test_read_char`
- if [ "$result" != "${expected}" ]; then
+ e_utf8=$2
+ e_ascii=$3
+ [ -n "$e_ascii" ] || e_ascii=$e_utf8
+ result=`echo -n "$stdin" | LC_CTYPE=en_US.UTF-8 ./test_read_char`
+ if [ "$result" != "${e_utf8}" ]; then
echo "input: >>>$stdin<<<"
- echo "expected: >>>$expected<<<"
+ echo "expected: >>>$e_utf8<<< UTF-8"
+ echo "result: >>>$result<<<"
+ exit 1;
+ fi
+ result=`echo -n "$stdin" | LC_CTYPE=C ./test_read_char`
+ if [ "$result" != "${e_ascii}" ]; then
+ echo "input: >>>$stdin<<<"
+ echo "expected: >>>$e_ascii<<< ASCII"
echo "result: >>>$result<<<"
exit 1;
fi
}
+# Valid ASCII.
testrc "" "0."
testrc "a" "61,0."
testrc "ab" "61,62,0."
-testrc "\0303\0251" "e9,0." # valid UTF-8
-testrc "\0303" "0." # incomplete UTF-8
-testrc "\0303a" "*61,0."
-testrc "\0303ab" "*61,62,0."
-testrc "\0355\0277\0277ab" "*61,62,0." # surrogate
-testrc "\0200" "*0." # isolated continuation byte
-testrc "\0200ab" "*61,62,0."
-testrc "a\0200bc" "61,*62,63,0."
-testrc "\0200\0303\0251" "*e9,0."
-testrc "\0200\0303ab" "*61,62,0."
-testrc "\0377ab" "*61,62,0." # invalid byte
-testrc "\0355\0277\0377ab" "*61,62,0."
+
+# Valid UTF-8.
+testrc "\0303\0251" "e9,0." "c3,a9,0."
+
+# Incomplete UTF-8.
+testrc "\0303" "0." "c3,0."
+testrc "\0303a" "*61,0." "c3,61,0."
+testrc "\0303ab" "*61,62,0." "c3,61,62,0."
+
+# UTF-16 surrogate.
+testrc "\0355\0277\0277ab" "*61,62,0." "ed,bf,bf,61,62,0."
+
+# Isolated UTF-8 continuation bytes.
+testrc "\0200" "*0." "80,0."
+testrc "\0200ab" "*61,62,0." "80,61,62,0."
+testrc "a\0200bc" "61,*62,63,0." "61,80,62,63,0."
+testrc "\0200\0303\0251" "*e9,0." "80,c3,a9,0."
+testrc "\0200\0303ab" "*61,62,0." "80,c3,61,62,0."
+
+# Invalid bytes.
+testrc "\0377ab" "*61,62,0." "ff,61,62,0."
+testrc "\0355\0277\0377ab" "*61,62,0." "ed,bf,ff,61,62,0."
exit 0