3 test_description
='grep icase on non-English locales'
7 test_expect_success GETTEXT_LOCALE
'setup' '
8 test_write_lines "TILRAUN: Halló Heimur!" >file &&
10 LC_ALL="$is_IS_locale" &&
14 test_expect_success GETTEXT_LOCALE
'setup REGEX_LOCALE prerequisite' '
15 # This "test-tool" invocation is identical...
16 if test-tool regex "HALLÓ" "Halló" ICASE
18 test_set_prereq REGEX_LOCALE
21 # ... to this one, but this way "test_must_fail" will
22 # tell a segfault or abort() from the regexec() test
24 test_must_fail test-tool regex "HALLÓ" "Halló" ICASE
28 test_expect_success REGEX_LOCALE
'grep literal string, no -F' '
29 git grep -i "TILRAUN: Halló Heimur!" &&
30 git grep -i "TILRAUN: HALLÓ HEIMUR!"
33 test_expect_success GETTEXT_LOCALE
,PCRE
'grep pcre utf-8 icase' '
34 git grep --perl-regexp "TILRAUN: H.lló Heimur!" &&
35 git grep --perl-regexp -i "TILRAUN: H.lló Heimur!" &&
36 git grep --perl-regexp -i "TILRAUN: H.LLÓ HEIMUR!"
39 test_expect_success GETTEXT_LOCALE
,PCRE
'grep pcre utf-8 string with "+"' '
40 test_write_lines "TILRAUN: Hallóó Heimur!" >file2 &&
42 git grep -l --perl-regexp "TILRAUN: H.lló+ Heimur!" >actual &&
43 echo file >expected &&
44 echo file2 >>expected &&
45 test_cmp expected actual
48 test_expect_success REGEX_LOCALE
'grep literal string, with -F' '
49 git grep -i -F "TILRAUN: Halló Heimur!" &&
50 git grep -i -F "TILRAUN: HALLÓ HEIMUR!"
53 test_expect_success REGEX_LOCALE
'grep string with regex, with -F' '
54 test_write_lines "TILRAUN: Halló Heimur [abc]!" >file3 &&
56 git grep -i -F "TILRAUN: Halló Heimur [abc]!" file3
59 test_expect_success REGEX_LOCALE
'pickaxe -i on non-ascii' '
60 git commit -m first &&
61 git log --format=%f -i -S"TILRAUN: HALLÓ HEIMUR!" >actual &&
62 echo first >expected &&
63 test_cmp expected actual
66 test_expect_success GETTEXT_LOCALE
,LIBPCRE2
'PCRE v2: setup invalid UTF-8 data' '
67 printf "\\200\\n" >invalid-0x80 &&
68 echo "ævar" >expected &&
69 cat expected >>invalid-0x80 &&
70 git add invalid-0x80 &&
72 # Test for PCRE2_MATCH_INVALID_UTF bug
73 # https://bugs.exim.org/show_bug.cgi?id=2642
74 printf "\\345Aæ\\n" >invalid-0xe5 &&
78 test_expect_success GETTEXT_LOCALE
,LIBPCRE2
'PCRE v2: grep ASCII from invalid UTF-8 data' '
79 git grep -h "var" invalid-0x80 >actual &&
80 test_cmp expected actual &&
81 git grep -h "(*NO_JIT)var" invalid-0x80 >actual &&
82 test_cmp expected actual
85 test_expect_success GETTEXT_LOCALE
,LIBPCRE2
'PCRE v2: grep ASCII from invalid UTF-8 data (PCRE2 bug #2642)' '
86 git grep -h "Aæ" invalid-0xe5 >actual &&
87 test_cmp invalid-0xe5 actual &&
88 git grep -h "(*NO_JIT)Aæ" invalid-0xe5 >actual &&
89 test_cmp invalid-0xe5 actual
92 test_expect_success GETTEXT_LOCALE
,LIBPCRE2
'PCRE v2: grep non-ASCII from invalid UTF-8 data' '
93 git grep -h "æ" invalid-0x80 >actual &&
94 test_cmp expected actual &&
95 git grep -h "(*NO_JIT)æ" invalid-0x80 >actual &&
96 test_cmp expected actual
99 test_expect_success GETTEXT_LOCALE
,LIBPCRE2
'PCRE v2: grep non-ASCII from invalid UTF-8 data (PCRE2 bug #2642)' '
100 git grep -h "Aæ" invalid-0xe5 >actual &&
101 test_cmp invalid-0xe5 actual &&
102 git grep -h "(*NO_JIT)Aæ" invalid-0xe5 >actual &&
103 test_cmp invalid-0xe5 actual
106 test_lazy_prereq PCRE2_MATCH_INVALID_UTF
'
107 test-tool pcre2-config has-PCRE2_MATCH_INVALID_UTF
110 test_expect_success GETTEXT_LOCALE
,LIBPCRE2
'PCRE v2: grep non-ASCII from invalid UTF-8 data with -i' '
111 test_might_fail git grep -hi "Æ" invalid-0x80 >actual &&
112 test_might_fail git grep -hi "(*NO_JIT)Æ" invalid-0x80 >actual
115 test_expect_success GETTEXT_LOCALE
,LIBPCRE2
,PCRE2_MATCH_INVALID_UTF
'PCRE v2: grep non-ASCII from invalid UTF-8 data with -i' '
116 git grep -hi "Æ" invalid-0x80 >actual &&
117 test_cmp expected actual &&
118 git grep -hi "(*NO_JIT)Æ" invalid-0x80 >actual &&
119 test_cmp expected actual
122 test_expect_success GETTEXT_LOCALE
,LIBPCRE2
,PCRE2_MATCH_INVALID_UTF
'PCRE v2: grep non-ASCII from invalid UTF-8 data with -i (PCRE2 bug #2642)' '
123 git grep -hi "Æ" invalid-0xe5 >actual &&
124 test_cmp invalid-0xe5 actual &&
125 git grep -hi "(*NO_JIT)Æ" invalid-0xe5 >actual &&
126 test_cmp invalid-0xe5 actual &&
128 # Only the case of grepping the ASCII part in a way that
130 git grep -hi "aÆ" invalid-0xe5 >actual &&
131 test_cmp invalid-0xe5 actual &&
132 git grep -hi "(*NO_JIT)aÆ" invalid-0xe5 >actual &&
133 test_cmp invalid-0xe5 actual
136 test_expect_success GETTEXT_LOCALE
,LIBPCRE2
'PCRE v2: grep non-literal ASCII from UTF-8' '
137 git grep --perl-regexp -h -o -e ll. file >actual &&
138 echo "lló" >expected &&
139 test_cmp expected actual