diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 3 | ||||
-rwxr-xr-x | tests/fmbtest.sh | 111 | ||||
-rwxr-xr-x | tests/foad1.sh | 15 |
3 files changed, 128 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index f2caf4d9..989ecf82 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -3,7 +3,8 @@ AWK=@AWK@ TESTS = warning.sh khadafy.sh spencer1.sh bre.sh ere.sh \ - status.sh empty.sh options.sh backref.sh file.sh foad1.sh + status.sh empty.sh options.sh backref.sh file.sh foad1.sh \ + fmbtest.sh EXTRA_DIST = $(TESTS) \ khadafy.lines khadafy.regexp \ spencer1.awk spencer1.tests \ diff --git a/tests/fmbtest.sh b/tests/fmbtest.sh new file mode 100755 index 00000000..7fd5ca14 --- /dev/null +++ b/tests/fmbtest.sh @@ -0,0 +1,111 @@ +#!/bin/sh + +: ${srcdir=.} + +# If cs_CZ.UTF-8 locale doesn't work, skip this test silently +LC_ALL=cs_CZ.UTF-8 locale -k LC_CTYPE 2>/dev/null | ${GREP} -q charmap.*UTF-8 \ + || exit 77 + +failures=0 + +cat > csinput <<EOF +01 Žluťoučká číše +ČíŠE 02 +03 Z číší Čiší cosi +04 Čí +Še 05 +06 ČČČČČČČíšČÍŠčíš +07 ČČČ ČČČČíšČÍŠčíšEEEE +čAs 08 +09Čapka +10ČaSy se měnÍ +ČÍšE11 +Čas12 +𝇕ČÍšE𝇓13 +ŽČÍšE𝇓14 +𝇕ČÍšEŽ15 +ŽČÍšEŽ16 +ČÍšE𝇓17 +ČÍšEŽ18 +19𝇕ČÍše +20ŽČÍše +EOF +cat > cspatfile <<EOF +ČÍšE +Čas +EOF + +for mode in F G E; do + +test1="$(echo `LC_ALL=cs_CZ.UTF-8 ${GREP} -${mode} -f cspatfile csinput \ + | LC_ALL=C sed 's/^.*\([0-9][0-9]\).*$/\1/'`)" +if test "$test1" != "11 12 13 14 15 16 17 18"; then + echo "Test #1 ${mode} failed: $test1" + failures=1 +fi + +test2="$(echo `LC_ALL=cs_CZ.UTF-8 ${GREP} -${mode}i -f cspatfile csinput \ + | LC_ALL=C sed 's/^.*\([0-9][0-9]\).*$/\1/'`)" +if test "$test2" != "01 02 07 08 10 11 12 13 14 15 16 17 18 19 20"; then + echo "Test #2 ${mode} failed: $test2" + failures=1 +fi + +test3="$(echo `LC_ALL=cs_CZ.UTF-8 ${GREP} -${mode}i -e 'ČÍšE' -e 'Čas' csinput \ + | LC_ALL=C sed 's/^.*\([0-9][0-9]\).*$/\1/'`)" +if test "$test3" != "01 02 07 08 10 11 12 13 14 15 16 17 18 19 20"; then + echo "Test #3 ${mode} failed: $test3" + failures=1 +fi + +test4="$(echo `LC_ALL=cs_CZ.UTF-8 ${GREP} -${mode}iw -f cspatfile csinput \ + | LC_ALL=C sed 's/^.*\([0-9][0-9]\).*$/\1/'`)" +if test "$test4" != "01 02 08 13 17 19"; then + echo "Test #4 ${mode} failed: $test4" + failures=1 +fi + +done + +# Test that -F --color=always prefers longer matches. +test5="`echo 'Cosi tu ČišÍ...' \ + | LC_ALL=cs_CZ.UTF-8 ${GREP} --color=always -Fi -e 'čiš' -e 'čiší'`" +if echo "$test5" | LC_ALL=C ${GREP} -q 'Cosi tu .*\[.*mČišÍ.*\[.*m\(.\[K\)\?\.\.\.'; then + : +else + echo "Test #5 F failed: $test5" + failures=1 +fi + +for mode in G E; do + +# Test that -{G,E} --color=always prefers earlier pattern matches. +test6="`echo 'Cosi tu ČišÍ...' \ + | LC_ALL=cs_CZ.UTF-8 ${GREP} --color=always -${mode}i -e 'čiš' -e 'čiší'`" +if echo "$test6" | LC_ALL=C ${GREP} -q 'Cosi tu .*\[.*mČiš.*\[.*m\(.\[K\)\?Í\.\.\.'; then + : +else + echo "Test #6 ${mode} failed: $test6" + failures=1 +fi + +# Test that -{G,E} --color=always prefers earlier pattern matches. +test7="`echo 'Cosi tu ČišÍ...' \ + | LC_ALL=cs_CZ.UTF-8 ${GREP} --color=always -${mode}i -e 'čiší' -e 'čiš'`" +if echo "$test7" | LC_ALL=C ${GREP} -q 'Cosi tu .*\[.*mČišÍ.*\[.*m\(.\[K\)\?\.\.\.'; then + : +else + echo "Test #7 ${mode} failed: $test7" + failures=1 +fi + +test8="$(echo `LC_ALL=cs_CZ.UTF-8 ${GREP} -${mode}i -e 'Č.šE' -e 'Č[a-f]s' csinput \ + | LC_ALL=C sed 's/^.*\([0-9][0-9]\).*$/\1/'`)" +if test "$test8" != "01 02 07 08 10 11 12 13 14 15 16 17 18 19 20"; then + echo "Test #8 ${mode} failed: $test8" + failures=1 +fi + +done + +exit $failures diff --git a/tests/foad1.sh b/tests/foad1.sh index 5fa64933..6c590265 100755 --- a/tests/foad1.sh +++ b/tests/foad1.sh @@ -47,6 +47,21 @@ grep_test "word_word/" "word_/" "^word_*" -o grep_test "wordword/" "word/" "\<word" -o +# Test "--color" option + +CB="[01;31m" +CE="[00m" + +# "--color" with "-i" should output an exact copy of the matching input text. +grep_test "WordA/wordb/WORDC/" "${CB}Word${CE}A/${CB}word${CE}b/${CB}WORD${CE}C/" "Word" --color=always -i +grep_test "WordA/wordb/WORDC/" "${CB}Word${CE}A/${CB}word${CE}b/${CB}WORD${CE}C/" "word" --color=always -i +grep_test "WordA/wordb/WORDC/" "${CB}Word${CE}A/${CB}word${CE}b/${CB}WORD${CE}C/" "WORD" --color=always -i + +# End of a previous match should not match a "start of ..." expression. +grep_test "word_word/" "${CB}word_${CE}word/" "^word_*" --color=always +grep_test "wordword/" "${CB}word${CE}word/" "\<word" --color=always + + # Test combination of "-m" with "-A" and anchors. # Based on a report from Pavol Gono. grep_test "4/40/" "4/40/" "^4$" -m1 -A99 |