Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46465 Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/msvcp140/msvcp140.spec | 2 +- dlls/msvcp140/tests/msvcp140.c | 69 ++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-)
diff --git a/dlls/msvcp140/msvcp140.spec b/dlls/msvcp140/msvcp140.spec index 245389e61e..6a4eb14c04 100644 --- a/dlls/msvcp140/msvcp140.spec +++ b/dlls/msvcp140/msvcp140.spec @@ -3638,7 +3638,7 @@ @ cdecl _Current_set(wstr) tr2_sys__Current_set_wchar @ extern _Denorm _Denorm @ cdecl _Dtest(ptr) _Dtest -@ stub _Equivalent +@ cdecl _Equivalent(wstr wstr) tr2_sys__Equivalent_wchar @ cdecl _Exp(ptr double long) _Exp @ stub _FCosh @ extern _FDenorm _FDenorm diff --git a/dlls/msvcp140/tests/msvcp140.c b/dlls/msvcp140/tests/msvcp140.c index ac7154bec2..229741a52d 100644 --- a/dlls/msvcp140/tests/msvcp140.c +++ b/dlls/msvcp140/tests/msvcp140.c @@ -176,6 +176,7 @@ static void (__cdecl *p__Release_chore)(_Threadpool_chore*); static void (__cdecl *p_Close_dir)(void*); static MSVCP_bool (__cdecl *p_Current_get)(WCHAR *); static MSVCP_bool (__cdecl *p_Current_set)(WCHAR const *); +static int (__cdecl *p_Equivalent)(WCHAR const*, WCHAR const*); static ULONGLONG (__cdecl *p_File_size)(WCHAR const *); static __int64 (__cdecl *p_Last_write_time)(WCHAR const*); static void (__cdecl *p_Set_last_write_time)(WCHAR const*, __int64); @@ -267,6 +268,7 @@ static BOOL init(void) SET(p_Close_dir, "_Close_dir"); SET(p_Current_get, "_Current_get"); SET(p_Current_set, "_Current_set"); + SET(p_Equivalent, "_Equivalent"); SET(p_File_size, "_File_size"); SET(p_Last_write_time, "_Last_write_time"); SET(p_Set_last_write_time, "_Set_last_write_time"); @@ -1360,6 +1362,72 @@ static void test__Winerror_map(void) } }
+static void test_Equivalent(void) +{ + int val, i; + HANDLE file; + WCHAR temp_path[MAX_PATH], current_path[MAX_PATH]; + static const WCHAR wine_test_dirW[] = + {'w','i','n','e','_','t','e','s','t','_','d','i','r',0}; + static const WCHAR f1W[] = + {'w','i','n','e','_','t','e','s','t','_','d','i','r','/','f','1',0}; + static const WCHAR f1W_backslash[] = + {'w','i','n','e','_','t','e','s','t','_','d','i','r','\','f','1',0}; + static const WCHAR f1W_subdir[] = + {'w','i','n','e','_','t','e','s','t','_','d','i','r','/','.','/','f','1',0}; + static const WCHAR f1W_long[] = + {'w','i','n','e','_','t','e','s','t','_','d','i','r','/','.','.','/','w','i','n','e','_','t','e','s','t','_','d','i','r','/','f','1',0}; + static const WCHAR f2W[] = + {'w','i','n','e','_','t','e','s','t','_','d','i','r','/','f','2',0}; + static const WCHAR not_existW[] = + {'n','o','t','_','e','x','i','s','t','s','_','f','i','l','e',0}; + static const struct { + const WCHAR *path1; + const WCHAR *path2; + int equivalent; + } tests[] = { + { NULL, NULL, -1 }, + { NULL, f1W, 0 }, + { f1W, NULL, 0 }, + { f1W, wine_test_dirW, 0 }, + { wine_test_dirW, f1W, 0 }, + { wine_test_dirW, wine_test_dirW, -1 }, + { f1W_subdir, f2W, 0 }, + { f1W, f1W, 1 }, + { not_existW, f1W, 0 }, + { f1W_backslash, f1W_subdir, 1 }, + { not_existW, not_existW, -1 }, + { f1W, not_existW, 0 }, + { f1W_long, f1W, 1 } + }; + + memset(current_path, 0, MAX_PATH); + GetCurrentDirectoryW(MAX_PATH, current_path); + memset(temp_path, 0, MAX_PATH); + GetTempPathW(MAX_PATH, temp_path); + ok(SetCurrentDirectoryW(temp_path), "SetCurrentDirectoryW to temp_path failed\n"); + CreateDirectoryW(wine_test_dirW, NULL); + + file = CreateFileW(f1W, 0, 0, NULL, CREATE_ALWAYS, 0, NULL); + ok(file != INVALID_HANDLE_VALUE, "create file failed: INVALID_HANDLE_VALUE\n"); + CloseHandle(file); + file = CreateFileW(f2W, 0, 0, NULL, CREATE_ALWAYS, 0, NULL); + ok(file != INVALID_HANDLE_VALUE, "create file failed: INVALID_HANDLE_VALUE\n"); + CloseHandle(file); + + for(i=0; i<ARRAY_SIZE(tests); i++) { + errno = 0xdeadbeef; + val = p_Equivalent(tests[i].path1, tests[i].path2); + ok(tests[i].equivalent == val, "_Equivalent(): test %d expect: %d, got %d\n", i+1, tests[i].equivalent, val); + ok(errno == 0xdeadbeef, "errno = %d\n", errno); + } + + ok(DeleteFileW(f1W), "expect wine_test_dir/f1 to exist\n"); + ok(DeleteFileW(f2W), "expect wine_test_dir/f2 to exist\n"); + ok(p_Remove_dir(wine_test_dirW), "expect wine_test_dir to exist\n"); + ok(SetCurrentDirectoryW(current_path), "SetCurrentDirectoryW failed\n"); +} + START_TEST(msvcp140) { if(!init()) return; @@ -1383,5 +1451,6 @@ START_TEST(msvcp140) test_Last_write_time(); test__Winerror_message(); test__Winerror_map(); + test_Equivalent(); FreeLibrary(msvcp); }