diff options
Diffstat (limited to 'tests/core/posix.c')
-rw-r--r-- | tests/core/posix.c | 120 |
1 files changed, 0 insertions, 120 deletions
diff --git a/tests/core/posix.c b/tests/core/posix.c index dcc619f22..77ac65ad6 100644 --- a/tests/core/posix.c +++ b/tests/core/posix.c @@ -9,23 +9,12 @@ # endif #endif -#include <locale.h> - #include "clar_libgit2.h" #include "futils.h" #include "posix.h" -#include "userdiff.h" - -#if LC_ALL > 0 -static const char *old_locales[LC_ALL]; -#endif void test_core_posix__initialize(void) { -#if LC_ALL > 0 - memset(&old_locales, 0, sizeof(old_locales)); -#endif - #ifdef GIT_WIN32 /* on win32, the WSA context needs to be initialized * before any socket calls can be performed */ @@ -156,115 +145,6 @@ void test_core_posix__utimes(void) cl_must_pass(p_unlink("foo")); } -static void try_set_locale(int category) -{ -#if LC_ALL > 0 - old_locales[category] = setlocale(category, NULL); -#endif - - if (!setlocale(category, "UTF-8") && - !setlocale(category, "c.utf8") && - !setlocale(category, "en_US.UTF-8")) - cl_skip(); - - if (MB_CUR_MAX == 1) - cl_fail("Expected locale to be switched to multibyte"); -} - -void test_core_posix__p_regcomp_ignores_global_locale_ctype(void) -{ - p_regex_t preg; - - try_set_locale(LC_CTYPE); - - cl_assert(!p_regcomp(&preg, "[\xc0-\xff][\x80-\xbf]", P_REG_EXTENDED)); - - p_regfree(&preg); -} - -void test_core_posix__p_regcomp_ignores_global_locale_collate(void) -{ - p_regex_t preg; - -#ifdef GIT_WIN32 - cl_skip(); -#endif - - try_set_locale(LC_COLLATE); - cl_assert(!p_regcomp(&preg, "[\xc0-\xff][\x80-\xbf]", P_REG_EXTENDED)); - - p_regfree(&preg); -} - -void test_core_posix__p_regcomp_matches_digits_with_locale(void) -{ - p_regex_t preg; - char c, str[2]; - -#ifdef GIT_WIN32 - cl_skip(); -#endif - - try_set_locale(LC_COLLATE); - try_set_locale(LC_CTYPE); - - cl_assert(!p_regcomp(&preg, "[[:digit:]]", P_REG_EXTENDED)); - - str[1] = '\0'; - for (c = '0'; c <= '9'; c++) { - str[0] = c; - cl_assert(!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]; - -#ifdef GIT_WIN32 - cl_skip(); -#endif - - try_set_locale(LC_COLLATE); - try_set_locale(LC_CTYPE); - - cl_assert(!p_regcomp(&preg, "[[:alpha:]]", P_REG_EXTENDED)); - - str[1] = '\0'; - for (c = 'a'; c <= 'z'; c++) { - str[0] = c; - cl_assert(!p_regexec(&preg, str, 0, NULL, 0)); - } - for (c = 'A'; c <= 'Z'; c++) { - str[0] = c; - cl_assert(!p_regexec(&preg, str, 0, NULL, 0)); - } - - p_regfree(&preg); -} - -void test_core_posix__p_regcomp_compile_userdiff_regexps(void) -{ - size_t idx; - - for (idx = 0; idx < ARRAY_SIZE(builtin_defs); ++idx) { - git_diff_driver_definition ddef = builtin_defs[idx]; - int error = 0; - p_regex_t preg; - - error = p_regcomp(&preg, ddef.fns, P_REG_EXTENDED | ddef.flags); - p_regfree(&preg); - cl_assert(!error); - - error = p_regcomp(&preg, ddef.words, P_REG_EXTENDED); - p_regfree(&preg); - cl_assert(!error); - } -} - void test_core_posix__unlink_removes_symlink(void) { if (!git_path_supports_symlinks(clar_sandbox_path())) |