summaryrefslogtreecommitdiff
path: root/tests/case-fold-titlecase
blob: d3de7a35743d9fc23b5a402112acf223ce664ff7 (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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#!/bin/sh
# Check that case folding works even with titlecase and similarly odd chars.

# Copyright 2014-2020 Free Software Foundation, Inc.

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

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

require_en_utf8_locale_
require_compiled_in_MB_support
LC_ALL=en_US.UTF-8
export LC_ALL

fail=0

for testcase in \
  0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
  case $testcase in
    0)
      a='\302\265'     # U+00B5
      b='\316\234'     # U+039C
      c='\316\274'     # U+03BC
      ;;
    1)
      a='\111'         # U+0049
      b='\151'         # U+0069
      c='\304\260'     # U+0130
      ;;
    2)
      a='\111'         # U+0049
      b='\151'         # U+0069
      c='\304\261'     # U+0131
      ;;
    3)
      a='\123'         # U+0053
      b='\163'         # U+0073
      c='\305\277'     # U+017F
      ;;
    4)
      a='\307\204'     # U+01C4
      b='\307\205'     # U+01C5
      c='\307\206'     # U+01C6
      ;;
    5)
      a='\307\207'     # U+01C7
      b='\307\210'     # U+01C8
      c='\307\211'     # U+01C9
      ;;
    6)
      a='\307\212'     # U+01CA
      b='\307\213'     # U+01CB
      c='\307\214'     # U+01CC
      ;;
    7)
      a='\307\261'     # U+01F1
      b='\307\262'     # U+01F2
      c='\307\263'     # U+01F3
      ;;
    8)
      a='\315\205'     # U+0345
      b='\316\231'     # U+0399
      c='\316\271'     # U+03B9
      ;;
    9)
      a='\316\243'     # U+03A3
      b='\317\202'     # U+03C2
      c='\317\203'     # U+03C3
      ;;
    10)
      a='\316\222'     # U+0392
      b='\316\262'     # U+03B2
      c='\317\220'     # U+03D0
      ;;
    11)
      a='\316\230'     # U+0398
      b='\316\270'     # U+03B8
      c='\317\221'     # U+03D1
      ;;
    12)
      a='\316\246'     # U+03A6
      b='\317\206'     # U+03C6
      c='\317\225'     # U+03D5
      ;;
    13)
      a='\316\240'     # U+03A0
      b='\317\200'     # U+03C0
      c='\317\226'     # U+03D6
      ;;
    14)
      a='\316\232'     # U+039A
      b='\316\272'     # U+03BA
      c='\317\260'     # U+03F0
      ;;
    15)
      a='\316\241'     # U+03A1
      b='\317\201'     # U+03C1
      c='\317\261'     # U+03F1
      ;;
    16)
      a='\316\230'     # U+0398
      b='\316\270'     # U+03B8
      c='\317\264'     # U+03F4
      ;;
    17)
      a='\316\225'     # U+0395
      b='\316\265'     # U+03B5
      c='\317\265'     # U+03F5
      ;;
    18)
      a='\341\271\240' # U+1E60
      b='\341\271\241' # U+1E61
      c='\341\272\233' # U+1E9B
      ;;
    19)
      a='\303\237'     # U+00DF
      b='\303\237'     # U+00DF
      c='\341\272\236' # U+1E9E
      ;;
    20)
      a='\316\231'     # U+0399
      b='\316\271'     # U+03B9
      c='\341\276\276' # U+1FBE
      ;;
    21)
      a='\316\251'     # U+03A9
      b='\317\211'     # U+03C9
      c='\342\204\246' # U+2126
      ;;
    22)
      a='\113'         # U+004B
      b='\153'         # U+006B
      c='\342\204\252' # U+212A
      ;;
    23)
      a='\303\205'     # U+00C5
      b='\303\245'     # U+00E5
      c='\342\204\253' # U+212B
      ;;
    24)
      a='\316\243'     # U+03A3
      b='\317\203'     # U+03C3
      c='\317\262'     # U+03F2
      ;;
  esac

  printf "$a\\n$b\\n$c\\n" >in || framework_failure_
  for pattern in "$a" "$b" "$c"; do
     pat=$(printf "$pattern\\n") || framework_failure_
     grep -i "\\(\\)\\1$pat" in >out-regex || fail=1
     grep -i "$pat" in >out-dfa || fail=1
     compare_ out-regex out-dfa || fail=1
     grep -iF "$pat" in >out-fixed || fail=1
     compare_ out-regex out-fixed || fail=1
  done
done

# Try a unibyte test with ISO 8859-7, if available.
if test "$(get-mb-cur-max el_GR.iso88597)" -eq 1; then
  LC_ALL=el_GR.iso88597
  export LC_ALL

  a='\323' # SIGMA
  b='\362' # stigma
  c='\363' # sigma

  printf "$a\\n$b\\n$c\\n" >in || framework_failure_
  for pattern in "$a" "$b" "$c"; do
     pat=$(printf "$pattern\\n") || framework_failure_
     grep -i "\\(\\)\\1$pat" in >out-regex || fail=1
     grep -i "$pat" in >out-dfa || fail=1
     compare_ out-regex out-dfa || fail=1
     grep -iF "$pat" in >out-fixed || fail=1
     compare_ out-regex out-fixed || fail=1
  done
fi

Exit $fail