diff options
author | Rob Landley <rob@landley.net> | 2024-02-05 07:42:01 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2024-02-05 07:42:01 -0600 |
commit | 792c5a2882e226046cbc83b69b7d16ad20edb038 (patch) | |
tree | bc678f9d0683a4220475be8070065ddb7fa8e88f | |
parent | 98f982d8b9fce9463dd4862237b574893cf6d6f8 (diff) | |
download | toybox-792c5a2882e226046cbc83b69b7d16ad20edb038.tar.gz |
Fix TEST_HOST for wc, adding "utf8locale" function.
-rw-r--r-- | scripts/runtest.sh | 10 | ||||
-rwxr-xr-x | tests/wc.test | 6 |
2 files changed, 14 insertions, 2 deletions
diff --git a/scripts/runtest.sh b/scripts/runtest.sh index 8992c8f7..1289d4c6 100644 --- a/scripts/runtest.sh +++ b/scripts/runtest.sh @@ -165,6 +165,16 @@ testcmd() testing "${1:-$CMDNAME $2}" "\"$C\" $2" "$3" "$4" "$5" } +utf8locale() +{ + local i + + for i in $LC_ALL C.UTF-8 en_US.UTF-8 + do + [ "$(LC_ALL=$i locale charmap 2>/dev/null)" == UTF-8 ] && LC_ALL=$i && break + done +} + # Simple implementation of "expect" written in shell. # txpect NAME COMMAND [I/O/E/X/R[OE]string]... diff --git a/tests/wc.test b/tests/wc.test index 4ab03868..66cf48be 100755 --- a/tests/wc.test +++ b/tests/wc.test @@ -4,6 +4,8 @@ #testing "name" "command" "result" "infile" "stdin" +utf8locale + cat >file1 <<EOF some words . @@ -19,7 +21,7 @@ testing "standard input -cl" "wc -cl" " 1 5\n" "" "a b\nc" testing "-c" "wc -c file1" "26 file1\n" "" "" testing "-l" "wc -l file1" "4 file1\n" "" "" testing "-w" "wc -w file1" "5 file1\n" "" "" -testing "one file" "wc file1" "4 5 26 file1\n" "" "" +NOSPACE=1 testing "one file" "wc file1" "4 5 26 file1\n" "" "" testing "multiple files" "wc input - file1" \ " 1 2 3 input\n 0 2 3 -\n 4 5 26 file1\n 5 9 32 total\n" "a\nb" "a b" @@ -29,5 +31,5 @@ for i in $(seq 1 512); do echo -n "üüüüüüüüüüüüüüüü" >> file1; d testing "-m" "wc -m file1" "8193 file1\n" "" "" testing "-m 2" 'cat "$FILES/utf8/test2.txt" | wc -m' "169\n" "" "" echo -n " " > file1 -testing "-mlw" "wc -mlw input" "1 2 11 input\n" "hello, 世界!\n" "" +NOSPACE=1 testing "-mlw" "wc -mlw input" "1 2 11 input\n" "hello, 世界!\n" "" rm file1 |