msvcp140: Export _Equivalent and port tests.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46465
Signed-off-by: Gijs Vermeulen <gijsvrm@gmail.com>
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
(cherry picked from commit 7e2816d2f1)
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
oldstable
Gijs Vermeulen 2019-01-23 03:22:55 +01:00 committed by Michael Stefaniuc
parent 4843534b28
commit c9a2aa88e9
2 changed files with 70 additions and 1 deletions

View File

@ -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

View File

@ -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);
}