1#!/bin/bash 2 3[ -f testing.sh ] && . testing.sh 4 5#testing "name" "command" "result" "infile" "stdin" 6 7utf8locale 8 9cat >file1 <<EOF 10some words . 11 12some 13lines 14EOF 15 16testcmd "wc" ">/dev/null && echo yes" "yes\n" "" "" 17testcmd "empty file" "" " 0 0 0\n" "" "" 18testcmd "standard input" "" " 1 3 5\n" "" "a b\nc" 19testcmd "standard input -c" "-c" "5\n" "" "a b\nc" 20testcmd "standard input -cl" "-cl" " 1 5\n" "" "a b\nc" 21testcmd "-c" "-c file1" "26 file1\n" "" "" 22testcmd "-l" "-l file1" "4 file1\n" "" "" 23testcmd "-w" "-w file1" "5 file1\n" "" "" 24testcmd "-L" "-L file1" "18 file1\n" "" "" 25NOSPACE=1 testcmd "one file" "file1" "4 5 26 file1\n" "" "" 26testcmd "multiple files" "input - file1" \ 27 " 1 2 3 input\n 0 2 3 -\n 4 5 26 file1\n 5 9 32 total\n" "a\nb" "a b" 28 29#Tests for wc -m 30echo -n " " > file1 31for i in $(seq 1 512); do echo -n "üüüüüüüüüüüüüüüü" >> file1; done 32testcmd "-m" "-m file1" "8193 file1\n" "" "" 33testing "-m 2" 'cat "$FILES/utf8/test2.txt" | wc -m' "169\n" "" "" 34echo -n " " > file1 35NOSPACE=1 testcmd "-mlw" "-mlw input" "1 2 11 input\n" "hello, 世界!\n" "" 36rm file1 37 38# Corner cases for "line length". Not QUITE fold because \b doesn't subtract 39 40testcmd '-L 2' '-L' '1\n' '' 'a\n' 41testcmd '-L 3' '-L' '1\n' '' 'a' 42testcmd '-L 4' '-L' '6\n' '' 'first\rsecond\n' 43testcmd '-L 5' '-L' '9\n' '' '\ta\n' 44testcmd '-L 6' '-L' '8\n' '' '\t\b\b\b\n' 45testcmd '-L 7' '-L' '9\n' '' 'abc\td\n' 46testcmd '-L 8' '-L' '4\n' '' 'abc\bd\n' 47testcmd '-L 9' '-L' '0\n' '' '\x01\n' 48testcmd '-L 10' '-L' '1\n' '' 'w\xcc\x88\n' 49NOSPACE=1 testcmd '-Lm incoherence' '-Lm' '2 0\n' '' '\x01\n' 50 51# 25 wide chars, also testing field order 52NOSPACE=1 testcmd '-cmlLw wide' '-cmlLw' '0 1 25 75 50\n' '' \ 53 "$(<"$FILES"/utf8/japan.txt)" 54