| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3567d13 commit 994252c
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,8 @@ | |||
| 9 | 9 | # endif | |
| 10 | 10 | #endif | |
| 11 | 11 | ||
| 12 | + #include <locale.h> | ||
| 13 | + | ||
| 12 | 14 | #include "clar_libgit2.h" | |
| 13 | 15 | #include "posix.h" | |
| 14 | 16 | #include "userdiff.h" | |
@@ -148,26 +150,39 @@ void test_core_posix__utimes(void) | |||
| 148 | 150 | p_unlink("foo"); | |
| 149 | 151 | } | |
| 150 | 152 | ||
| 151 | - void test_core_posix__p_regcomp_compile_single_byte_regexps(void) | ||
| 153 | + void test_core_posix__p_regcomp_ignores_global_locale_ctype(void) | ||
| 152 | 154 | { | |
| 153 | 155 | regex_t preg; | |
| 156 | + int error = 0; | ||
| 157 | + | ||
| 158 | + const char* oldlocale = setlocale(LC_CTYPE, NULL); | ||
| 154 | 159 | ||
| 155 | - cl_must_pass(p_regcomp(&preg, "[\xc0-\xff][\x80-\xbf]", REG_EXTENDED)); | ||
| 160 | + setlocale(LC_CTYPE, "UTF-8"); | ||
| 161 | + cl_assert_(MB_CUR_MAX > 1, "Expected locale to be switched to multibyte"); | ||
| 162 | + | ||
| 163 | + p_regcomp(&preg, "[\xc0-\xff][\x80-\xbf]", REG_EXTENDED); | ||
| 164 | + setlocale(LC_CTYPE, oldlocale); | ||
| 156 | 165 | ||
| 157 | 166 | regfree(&preg); | |
| 167 | + | ||
| 168 | + cl_must_pass(error); | ||
| 158 | 169 | } | |
| 159 | 170 | ||
| 160 | 171 | void test_core_posix__p_regcomp_compile_userdiff_regexps(void) | |
| 161 | 172 | { | |
| 162 | - regex_t preg; | ||
| 163 | 173 | size_t idx; | |
| 164 | 174 | ||
| 165 | 175 | for (idx = 0; idx < ARRAY_SIZE(builtin_defs); ++idx) { | |
| 166 | 176 | git_diff_driver_definition ddef = builtin_defs[idx]; | |
| 177 | + int error = 0; | ||
| 178 | + regex_t preg; | ||
| 167 | 179 | ||
| 168 | - cl_must_pass(p_regcomp(&preg, ddef.fns, REG_EXTENDED | ddef.flags)); | ||
| 169 | - cl_must_pass(p_regcomp(&preg, ddef.words, REG_EXTENDED)); | ||
| 170 | - } | ||
| 180 | + error = p_regcomp(&preg, ddef.fns, REG_EXTENDED | ddef.flags); | ||
| 181 | + regfree(&preg); | ||
| 182 | + cl_must_pass(error); | ||
| 171 | 183 | ||
| 172 | - regfree(&preg); | ||
| 184 | + error = p_regcomp(&preg, ddef.words, REG_EXTENDED); | ||
| 185 | + regfree(&preg); | ||
| 186 | + cl_must_pass(error); | ||
| 187 | + } | ||
| 173 | 188 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments