FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Actually test that the global locale is ignored. · libgit2/libgit2@994252c · GitHub

Repository navigation

Commit 994252c

Browse files
Actually test that the global locale is ignored.
1 parent 3567d13 commit 994252c

1 file changed

Lines changed: 22 additions & 7 deletions

File tree

‎tests/core/posix.c‎

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
# endif
1010
#endif
1111

12+
#include <locale.h>
13+
1214
#include "clar_libgit2.h"
1315
#include "posix.h"
1416
#include "userdiff.h"
@@ -148,26 +150,39 @@ void test_core_posix__utimes(void)
148150
p_unlink("foo");
149151
}
150152

151-
void test_core_posix__p_regcomp_compile_single_byte_regexps(void)
153+
void test_core_posix__p_regcomp_ignores_global_locale_ctype(void)
152154
{
153155
regex_t preg;
156+
int error = 0;
157+
158+
const char* oldlocale = setlocale(LC_CTYPE, NULL);
154159

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);
156165

157166
regfree(&preg);
167+
168+
cl_must_pass(error);
158169
}
159170

160171
void test_core_posix__p_regcomp_compile_userdiff_regexps(void)
161172
{
162-
regex_t preg;
163173
size_t idx;
164174

165175
for (idx = 0; idx < ARRAY_SIZE(builtin_defs); ++idx) {
166176
git_diff_driver_definition ddef = builtin_defs[idx];
177+
int error = 0;
178+
regex_t preg;
167179

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);
171183

172-
regfree(&preg);
184+
error = p_regcomp(&preg, ddef.words, REG_EXTENDED);
185+
regfree(&preg);
186+
cl_must_pass(error);
187+
}
173188
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL