summaryrefslogtreecommitdiff
path: root/tests/fmbtest
blob: 7e53e5117162ce3212eb2e17c635e49585be634b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#! /bin/sh
# Copyright (C) 2001, 2006, 2009-2020 Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.

. "${srcdir=.}/init.sh"; path_prepend_ ../src

cz=cs_CZ.UTF-8

# If cs_CZ.UTF-8 locale doesn't work, skip this test.
LC_ALL=$cz locale -k LC_CTYPE 2>/dev/null | grep -q charmap.*UTF-8 \
  || skip_ this system lacks the $cz locale

# If matching is done in single-byte mode, skip this test too
printf 'é\n' | LC_ALL=$cz grep -Eq '^[é]{2}$'
case $? in
  0) skip_ "built without multi-byte support";;
  1) ;;
  *) fail_ "unexpected exit status: $?";;
esac

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=$cz grep -${mode} -f cspatfile csinput |
               tr -cs '0-9' '[ *]'))
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=$cz grep -${mode}i -f cspatfile csinput |
               tr -cs '0-9' '[ *]'))
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=$cz grep -${mode}i -e 'ČÍšE' -e 'Čas' csinput |
               tr -cs '0-9' '[ *]'))
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

# Skip the next test - known to fail. TAA.
#test4=$(echo $(LC_ALL=$cz; export LC_ALL
#               grep -${mode}iw -f cspatfile csinput |
#                 sed 's/[^0123456789]/ /g'))
#if test "$test4" != "01 02 08 13 17 19"; then
#  echo "Test #4 ${mode} failed: $test4"
#  failures=1
#fi

# Test that --color=always does not depend on individual pattern order
# within the pattern list, and that a longer match is preferred to a
# shorter one starting at the same point.
test6="$(echo 'Cosi tu ČišÍ...' \
  | LC_ALL=$cz grep --color=always -${mode}i -e 'čiš' -e 'čiší')"
if echo "$test6" \
  | LC_ALL=C grep -q 'Cosi tu .*\[.*m\(.\[K\)\?ČišÍ.*\[.*m\(.\[K\)\?\.\.\.'; \
then
  :
else
  echo "Test #6 ${mode} failed: $test6"
  failures=1
fi

# Test that --color=always does not depend on individual pattern order
# within the pattern list, and that a longer match is preferred to a
# shorter one starting at the same point.
test7="$(echo 'Cosi tu ČišÍ...' \
  | LC_ALL=$cz grep --color=always -${mode}i -e 'čiší' -e 'čiš')"
if echo "$test7" \
  | LC_ALL=C grep -q 'Cosi tu .*\[.*m\(.\[K\)\?ČišÍ.*\[.*m\(.\[K\)\?\.\.\.'; \
then
  :
else
  echo "Test #7 ${mode} failed: $test7"
  failures=1
fi

done

for mode in G E; do

test8=$(echo $(LC_ALL=$cz grep -${mode}i -e 'Č.šE' -e 'Č[a-f]s' csinput |
               tr -cs '0-9' '[ *]'))
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