Debian Codegraph @

tests/fmbtest

raw
1 #! /bin/sh
2 # Copyright (C) 2001, 2006, 2009-2025 Free Software Foundation, Inc.
3 #
4 # Copying and distribution of this file, with or without modification,
5 # are permitted in any medium without royalty provided the copyright
6 # notice and this notice are preserved.
7
8 . "${srcdir=.}/init.sh"; path_prepend_ ../src
9
10 cz=cs_CZ.UTF-8
11
12 # If cs_CZ.UTF-8 locale doesn't work, skip this test.
13 test "`LC_ALL=$cz locale charmap 2>/dev/null`" = UTF-8 \
14 || skip_ this system lacks the $cz locale
15
16 # If matching is done in single-byte mode, skip this test too
17 printf 'é\n' | LC_ALL=$cz grep -Eq '^[é]{2}$'
18 case $? in
19 0) skip_ "built without multi-byte support";;
20 1) ;;
21 *) fail_ "unexpected exit status: $?";;
22 esac
23
24 failures=0
25
26 cat > csinput <<EOF
27 01 Žluťoučká číše
28 ČíŠE 02
29 03 Z číší Čiší cosi
30 04 Čí
31 Še 05
32 06 ČČČČČČČíšČÍŠčíš
33 07 ČČČ ČČČČíšČÍŠčíšEEEE
34 čAs 08
35 09Čapka
36 10ČaSy se měnÍ
37 ČÍšE11
38 Čas12
39 𝇕ČÍšE𝇓13
40 ŽČÍšE𝇓14
41 𝇕ČÍšEŽ15
42 ŽČÍšEŽ16
43 ČÍšE𝇓17
44 ČÍšEŽ18
45 19𝇕ČÍše
46 20ŽČÍše
47 EOF
48 cat > cspatfile <<EOF
49 ČÍšE
50 Čas
51 EOF
52
53 for mode in F G E; do
54
55 test1=$(echo $(LC_ALL=$cz grep -${mode} -f cspatfile csinput |
56 tr '\n' ' ' | tr -cd '0-9 '))
57 if test "$test1" != "11 12 13 14 15 16 17 18"; then
58 echo "Test #1 ${mode} failed: $test1"
59 failures=1
60 fi
61
62 test2=$(echo $(LC_ALL=$cz grep -${mode}i -f cspatfile csinput |
63 tr '\n' ' ' | tr -cd '0-9 '))
64 if test "$test2" != "01 02 07 08 10 11 12 13 14 15 16 17 18 19 20"; then
65 echo "Test #2 ${mode} failed: $test2"
66 failures=1
67 fi
68
69 test3=$(echo $(LC_ALL=$cz grep -${mode}i -e 'ČÍšE' -e 'Čas' csinput |
70 tr '\n' ' ' | tr -cd '0-9 '))
71 if test "$test3" != "01 02 07 08 10 11 12 13 14 15 16 17 18 19 20"; then
72 echo "Test #3 ${mode} failed: $test3"
73 failures=1
74 fi
75
76 # Skip the next test - known to fail. TAA.
77 #test4=$(echo $(LC_ALL=$cz; export LC_ALL
78 # grep -${mode}iw -f cspatfile csinput |
79 # sed 's/[^0123456789]/ /g'))
80 #if test "$test4" != "01 02 08 13 17 19"; then
81 # echo "Test #4 ${mode} failed: $test4"
82 # failures=1
83 #fi
84
85 # Test that --color=always does not depend on individual pattern order
86 # within the pattern list, and that a longer match is preferred to a
87 # shorter one starting at the same point.
88 test6="$(echo 'Cosi tu ČišÍ...' \
89 | LC_ALL=$cz grep --color=always -${mode}i -e 'čiš' -e 'čiší')"
90 if echo "$test6" \
91 | LC_ALL=C grep -q 'Cosi tu .*\[.*m\(.\[K\)\?ČišÍ.*\[.*m\(.\[K\)\?\.\.\.'; \
92 then
93 :
94 else
95 echo "Test #6 ${mode} failed: $test6"
96 failures=1
97 fi
98
99 # Test that --color=always does not depend on individual pattern order
100 # within the pattern list, and that a longer match is preferred to a
101 # shorter one starting at the same point.
102 test7="$(echo 'Cosi tu ČišÍ...' \
103 | LC_ALL=$cz grep --color=always -${mode}i -e 'čiší' -e 'čiš')"
104 if echo "$test7" \
105 | LC_ALL=C grep -q 'Cosi tu .*\[.*m\(.\[K\)\?ČišÍ.*\[.*m\(.\[K\)\?\.\.\.'; \
106 then
107 :
108 else
109 echo "Test #7 ${mode} failed: $test7"
110 failures=1
111 fi
112
113 done
114
115 for mode in G E; do
116
117 test8=$(echo $(LC_ALL=$cz grep -${mode}i -e 'Č.šE' -e 'Č[a-f]s' csinput |
118 tr '\n' ' ' | tr -cd '0-9 '))
119 if test "$test8" != "01 02 07 08 10 11 12 13 14 15 16 17 18 19 20"; then
120 echo "Test #8 ${mode} failed: $test8"
121 failures=1
122 fi
123
124 done
125
126 Exit $failures