summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2018-03-02 15:12:14 +0000
committerEdward Thomson <ethomson@edwardthomson.com>2019-05-19 11:12:13 +0100
commitaea9a7129bbe98efcda767619e47c140152e4156 (patch)
tree6b66f2d23eae4c5d7907ce0f69705631e32443d1
parente207b2a2ff021d297bfce8d0ad20ec32359a7daa (diff)
downloadlibgit2-aea9a7129bbe98efcda767619e47c140152e4156.tar.gz
tests: regcomp: assert character groups do match normal alphabet
In order to avoid us being unable to match characters which are part of the normal US alphabet in certain weird languages, add two tests to catch this behavior.
-rw-r--r--tests/core/posix.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/core/posix.c b/tests/core/posix.c
index 8155538c5..374373651 100644
--- a/tests/core/posix.c
+++ b/tests/core/posix.c
@@ -197,6 +197,48 @@ void test_core_posix__p_regcomp_ignores_global_locale_collate(void)
p_regfree(&preg);
}
+void test_core_posix__p_regcomp_matches_digits_with_locale(void)
+{
+ p_regex_t preg;
+ char c, str[2];
+
+ try_set_locale(LC_COLLATE);
+ try_set_locale(LC_CTYPE);
+
+ cl_must_pass(p_regcomp(&preg, "[:digit:]", P_REG_EXTENDED));
+
+ str[1] = '\0';
+ for (c = '0'; c <= '9'; c++) {
+ str[0] = c;
+ cl_must_pass(p_regexec(&preg, str, 0, NULL, 0));
+ }
+
+ p_regfree(&preg);
+}
+
+void test_core_posix__p_regcomp_matches_alphabet_with_locale(void)
+{
+ p_regex_t preg;
+ char c, str[2];
+
+ try_set_locale(LC_COLLATE);
+ try_set_locale(LC_CTYPE);
+
+ cl_must_pass(p_regcomp(&preg, "[:alpha:]", REG_EXTENDED));
+
+ str[1] = '\0';
+ for (c = 'a'; c <= 'z'; c++) {
+ str[0] = c;
+ cl_must_pass(p_regexec(&preg, str, 0, NULL, 0));
+ }
+ for (c = 'A'; c <= 'Z'; c++) {
+ str[0] = c;
+ cl_must_pass(p_regexec(&preg, str, 0, NULL, 0));
+ }
+
+ p_regfree(&preg);
+}
+
void test_core_posix__p_regcomp_compile_userdiff_regexps(void)
{
size_t idx;