Imported Upstream version 4.5.14
[platform/upstream/findutils.git] / locate / testsuite / locate.gnu / sv-bug-14535.exp
1 # NOTE: this file contains UTF8 characters.
2
3
4 proc selectlocale { pattern } {
5     if [ catch { set locale_list [ split [ eval exec locale -a ] "\n" ] } ] {
6         # Failed to figure out which tests are supported.
7         return ""
8     }
9     foreach locale $locale_list {
10         if { [string match $pattern $locale] } {
11             global env
12             set env(LC_ALL) $locale
13             return $locale
14         }
15     }
16     return ""
17 }
18
19 proc select_any_locale { patternlist } {
20     foreach pattern $patternlist {
21         set locale [ selectlocale $pattern ]
22         if { [ string length $locale ] } {
23             return $locale
24         }
25     }
26     return ""
27 }
28
29 # localeoptions contains a list (in order of preference) of the
30 # locales in which we want to perform part of this test.  If we can
31 # use any locale matching any of the patterns, we run an extra four
32 # tests.  Otherwise, we skip them and issue a warning message.
33 set localeoptions {
34     "hu_HU.UTF-8"
35     "hu_*.UTF-8"
36     "en_IE.utf8"
37     "en_GB.utf8"
38     "en_US.utf8"
39     "en_*.utf8"
40     "*.utf8"
41 }
42
43
44
45 # Do the regular case-fold tests which only need ASCII support.
46 locate_textonly p  a "teste\n" "-i teste" "teste\n"
47 locate_textonly p  b "testE\n" "-i testE" "testE\n"
48 locate_textonly p  c "testE\n" "-i teste" "testE\n"
49 locate_textonly p  d "teste\n" "-i testE" "teste\n"
50
51 set locale [ select_any_locale $localeoptions ]
52 if { [ string length $locale ] } {
53     # We have a UTF-8 locale.  Do the extra tests.
54     locate_textonly p  0 "testé\n" "-i testé" "testé\n"
55     locate_textonly p  1 "testÉ\n" "-i testé" "testÉ\n"
56     locate_textonly p  2 "testé\n" "-i testÉ" "testé\n"
57     locate_textonly p  3 "testÉ\n" "-i testÉ" "testÉ\n"
58 } else {
59     warning "Four tests have been skipped because I cannot find a UTF-8 locale configured on your system"
60 }