[SHLWAPI][WINESYNC] Import PathUndecorate wine fix + adaptation for ReactOS (#7636)

shlwapi: Fix PathUndecorate[AW] implementation.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id f3c1d663a4a4a99b5c07000cb0ad9cc55d1e1c88 by Jacek Caban <jacek@codeweavers.com>

Co-authored-by: Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
This commit is contained in:
Jacek Caban
2019-11-12 21:48:23 +01:00
committed by Hermès Bélusca-Maïto
parent 9d1c0efb1f
commit f189d8c454
2 changed files with 71 additions and 46 deletions

View File

@@ -1672,6 +1672,46 @@ static void test_PathStripPathA(void)
PathStripPathA((char*)const_path);
}
static void test_PathUndecorate(void)
{
static const struct {
const WCHAR *path;
const WCHAR *expect;
} tests[] = {
{ L"c:\\test\\a[123]", L"c:\\test\\a" },
{ L"c:\\test\\a[123].txt", L"c:\\test\\a.txt" },
{ L"c:\\test\\a.txt[123]", L"c:\\test\\a.txt[123]" },
{ L"c:\\test\\a[123a].txt", L"c:\\test\\a[123a].txt" },
{ L"c:\\test\\a[a123].txt", L"c:\\test\\a[a123].txt" },
{ L"c:\\test\\a[12\x0660].txt", L"c:\\test\\a[12\x0660].txt" },
{ L"c:\\test\\a[12]file", L"c:\\test\\a[12]file" },
{ L"c:\\test[123]\\a", L"c:\\test[123]\\a" },
{ L"c:\\test\\[123]", L"c:\\test\\[123]" },
{ L"a[123]", L"a" },
{ L"a[]", L"a" },
{ L"[123]", L"[123]" }
};
char bufa[MAX_PATH], expect[MAX_PATH];
WCHAR buf[MAX_PATH];
unsigned i;
for (i = 0; i < ARRAY_SIZE(tests); i++)
{
wcscpy(buf, tests[i].path);
PathUndecorateW(buf);
ok(!wcscmp(buf, tests[i].expect), "PathUndecorateW returned %s, expected %s\n",
wine_dbgstr_w(buf), wine_dbgstr_w(tests[i].expect));
WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, tests[i].path, -1, bufa, ARRAY_SIZE(bufa), "?", NULL);
WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, tests[i].expect, -1, expect, ARRAY_SIZE(expect), "?", NULL);
PathUndecorateA(bufa);
ok(!strcmp(bufa, expect), "PathUndecorateA returned %s, expected %s\n", bufa, expect);
}
PathUndecorateA(NULL);
PathUndecorateW(NULL);
}
START_TEST(path)
{
HMODULE hShlwapi = GetModuleHandleA("shlwapi.dll");
@@ -1718,4 +1758,5 @@ START_TEST(path)
test_PathIsRelativeA();
test_PathIsRelativeW();
test_PathStripPathA();
test_PathUndecorate();
}