Signed-off-by: Kirill Erofeev erofeev.info@gmail.com --- dlls/msvcrt/tests/dir.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+)
diff --git a/dlls/msvcrt/tests/dir.c b/dlls/msvcrt/tests/dir.c index 0750b34..d3e7d4c 100644 --- a/dlls/msvcrt/tests/dir.c +++ b/dlls/msvcrt/tests/dir.c @@ -438,6 +438,9 @@ static void test_search_environment(void) const char** file_name = files; const char** dir_name = dirs; char result[MAX_PATH]; + WCHAR result_w[MAX_PATH]; + WCHAR filename_w[MAX_PATH]; + const WCHAR env_w[] = {'T', 'E', 'S', 'T', '_', 'P', 'A', 'T', 'H', '\0'};
const char eraser[] = "TEST_PATH=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; while (*dir_name){ @@ -484,6 +487,42 @@ static void test_search_environment(void)
putenv(eraser); + MultiByteToWideChar( CP_ACP, 0, "1.dat", -1, filename_w, MAX_PATH); + _wsearchenv(filename_w, env_w, result_w); + putenv("TEST_PATH=c:\search_env_test\dir1;c:\search_env_test\dir2;c:\search_env_test\dir3longer"); + _wsearchenv(filename_w, env_w, result_w); + WideCharToMultiByte(CP_ACP, 0, result_w, -1, result, MAX_PATH, NULL, NULL); + ok(!strcmp(result, "c:\search_env_test\dir1\1.dat"), "Failed to found %s in %s got in %s\n", "1.dat", "c:\search_env_test\dir1", result); + + putenv(eraser); + MultiByteToWideChar( CP_ACP, 0, "3.dat", -1, filename_w, MAX_PATH); + _wsearchenv(filename_w, env_w, result_w); + putenv("TEST_PATH=c:\search_env_test\dir1;c:\search_env_test\dir2;c:\search_env_test\dir3longer"); + _wsearchenv(filename_w, env_w, result_w); + WideCharToMultiByte(CP_ACP, 0, result_w, -1, result, MAX_PATH, NULL, NULL); + ok(!strcmp(result, "c:\search_env_test\dir2\3.dat"), "Failed to found %s in %s got in %s\n", "3.dat", "c:\search_env_test\dir2", result); + + putenv(eraser); + MultiByteToWideChar( CP_ACP, 0, "1.dat", -1, filename_w, MAX_PATH); + _wsearchenv(filename_w, env_w, result_w); + putenv("TEST_PATH=;c:\search_env_test\dir1;c:\search_env_test\dir2;c:\search_env_test\dir3longer"); + _wsearchenv(filename_w, env_w, result_w); + WideCharToMultiByte(CP_ACP, 0, result_w, -1, result, MAX_PATH, NULL, NULL); + ok(!strcmp(result, "c:\search_env_test\dir1\1.dat"), "Failed to found %s in %s got in %s\n", "1.dat", "c:\search_env_test\dir1", result); + + putenv(eraser); + MultiByteToWideChar( CP_ACP, 0, "3.dat", -1, filename_w, MAX_PATH); + _wsearchenv(filename_w, env_w, result_w); + putenv("TEST_PATH=c:\search_env_test\dir1;;c:\search_env_test\dir2;c:\search_env_test\dir3longer"); + _wsearchenv(filename_w, env_w, result_w); + WideCharToMultiByte(CP_ACP, 0, result_w, -1, result, MAX_PATH, NULL, NULL); + ok(!strcmp(result, "c:\search_env_test\dir2\3.dat"), "Failed to found %s in %s got in %s\n", "3.dat", "c:\search_env_test\dir2", result); + + + + + + putenv(eraser); _searchenv_s("1.dat", "TEST_PATH", result, MAX_PATH); putenv("TEST_PATH=c:\search_env_test\dir1;c:\search_env_test\dir2;c:\search_env_test\dir3longer"); _searchenv_s("1.dat", "TEST_PATH", result, MAX_PATH); @@ -510,6 +549,42 @@ static void test_search_environment(void)
+ putenv(eraser); + MultiByteToWideChar( CP_ACP, 0, "1.dat", -1, filename_w, MAX_PATH); + _wsearchenv_s(filename_w, env_w, result_w, MAX_PATH); + putenv("TEST_PATH=c:\search_env_test\dir1;c:\search_env_test\dir2;c:\search_env_test\dir3longer"); + _wsearchenv_s(filename_w, env_w, result_w); + WideCharToMultiByte(CP_ACP, 0, result_w, -1, result, MAX_PATH, NULL, NULL); + ok(!strcmp(result, "c:\search_env_test\dir1\1.dat"), "Failed to found %s in %s got in %s\n", "1.dat", "c:\search_env_test\dir1", result); + + putenv(eraser); + MultiByteToWideChar( CP_ACP, 0, "3.dat", -1, filename_w, MAX_PATH); + _wsearchenv_s(filename_w, env_w, result_w, MAX_PATH); + putenv("TEST_PATH=c:\search_env_test\dir1;c:\search_env_test\dir2;c:\search_env_test\dir3longer"); + _wsearchenv_s(filename_w, env_w, result_w, MAX_PATH); + WideCharToMultiByte(CP_ACP, 0, result_w, -1, result, MAX_PATH, NULL, NULL); + ok(!strcmp(result, "c:\search_env_test\dir2\3.dat"), "Failed to found %s in %s got in %s\n", "3.dat", "c:\search_env_test\dir2", result); + + putenv(eraser); + MultiByteToWideChar( CP_ACP, 0, "1.dat", -1, filename_w, MAX_PATH); + _wsearchenv_s(filename_w, env_w, result_w, MAX_PATH); + putenv("TEST_PATH=;c:\search_env_test\dir1;c:\search_env_test\dir2;c:\search_env_test\dir3longer"); + _wsearchenv_s(filename_w, env_w, result_w, MAX_PATH); + WideCharToMultiByte(CP_ACP, 0, result_w, -1, result, MAX_PATH, NULL, NULL); + ok(!strcmp(result, "c:\search_env_test\dir1\1.dat"), "Failed to found %s in %s got in %s\n", "1.dat", "c:\search_env_test\dir1", result); + + putenv(eraser); + MultiByteToWideChar( CP_ACP, 0, "3.dat", -1, filename_w, MAX_PATH); + _wsearchenv_s(filename_w, env_w, result_w, MAX_PATH); + putenv("TEST_PATH=c:\search_env_test\dir1;;c:\search_env_test\dir2;c:\search_env_test\dir3longer"); + _wsearchenv_s(filename_w, env_w, result_w, MAX_PATH); + WideCharToMultiByte(CP_ACP, 0, result_w, -1, result, MAX_PATH, NULL, NULL); + ok(!strcmp(result, "c:\search_env_test\dir2\3.dat"), "Failed to found %s in %s got in %s\n", "3.dat", "c:\search_env_test\dir2", result); + + + + + putenv("TEST_PATH=");
do {