kernel32/tests: Add tests to examine output file part pointer behavior for GetFullPathNameW.

This commit is contained in:
Andrew Nguyen 2010-06-16 23:40:26 -05:00 committed by Alexandre Julliard
parent 70099e8971
commit 1029167232
1 changed files with 60 additions and 0 deletions

View File

@ -1624,6 +1624,65 @@ static void test_GetFullPathNameA(void)
}
}
static void test_GetFullPathNameW(void)
{
static const WCHAR emptyW[] = {0};
static const WCHAR deadbeefW[] = {'d','e','a','d','b','e','e','f',0};
WCHAR output[MAX_PATH], *filepart;
DWORD ret;
int i;
const struct
{
LPCWSTR name;
DWORD len;
LPWSTR buffer;
LPWSTR *lastpart;
int win7_expect;
} invalid_parameters[] =
{
{NULL, 0, NULL, NULL},
{NULL, 0, NULL, &filepart, 1},
{NULL, MAX_PATH, NULL, NULL},
{NULL, MAX_PATH, output, NULL},
{NULL, MAX_PATH, output, &filepart, 1},
{emptyW, 0, NULL, NULL},
{emptyW, 0, NULL, &filepart, 1},
{emptyW, MAX_PATH, NULL, NULL},
{emptyW, MAX_PATH, output, NULL},
{emptyW, MAX_PATH, output, &filepart, 1},
};
SetLastError(0xdeadbeef);
ret = GetFullPathNameW(NULL, 0, NULL, NULL);
if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{
win_skip("GetFullPathNameW is not available\n");
return;
}
for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++)
{
SetLastError(0xdeadbeef);
lstrcpyW(output, deadbeefW);
filepart = (WCHAR *)0xdeadbeef;
ret = GetFullPathNameW(invalid_parameters[i].name,
invalid_parameters[i].len,
invalid_parameters[i].buffer,
invalid_parameters[i].lastpart);
ok(!ret, "[%d] Expected GetFullPathNameW to return 0, got %u\n", i, ret);
ok(!lstrcmpW(output, deadbeefW), "[%d] Expected the output buffer to be unchanged, got %s\n", i, wine_dbgstr_w(output));
ok(filepart == (WCHAR *)0xdeadbeef ||
(invalid_parameters[i].win7_expect && filepart == NULL),
"[%d] Expected output file part pointer to be untouched, got %p\n", i, filepart);
ok(GetLastError() == 0xdeadbeef ||
GetLastError() == ERROR_INVALID_NAME, /* Win7 */
"[%d] Expected GetLastError() to return 0xdeadbeef, got %u\n",
i, GetLastError());
}
}
static void init_pointers(void)
{
HMODULE hKernel32 = GetModuleHandleA("kernel32.dll");
@ -1666,4 +1725,5 @@ START_TEST(path)
test_SearchPathA();
test_SearchPathW();
test_GetFullPathNameA();
test_GetFullPathNameW();
}