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

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

View File

@ -1569,6 +1569,61 @@ if (0)
"Expected ERROR_INVALID_PARAMETER, got %x\n", GetLastError());
}
static void test_GetFullPathNameA(void)
{
char output[MAX_PATH], *filepart;
DWORD ret;
int is_win9x, i;
const struct
{
LPCSTR name;
DWORD len;
LPSTR buffer;
LPSTR *lastpart;
int win9x_crash;
} invalid_parameters[] =
{
{NULL, 0, NULL, NULL, 1},
{NULL, MAX_PATH, NULL, NULL, 1},
{NULL, MAX_PATH, output, NULL, 1},
{NULL, MAX_PATH, output, &filepart, 1},
{"", 0, NULL, NULL},
{"", MAX_PATH, NULL, NULL},
{"", MAX_PATH, output, NULL},
{"", MAX_PATH, output, &filepart},
};
SetLastError(0xdeadbeef);
ret = GetFullPathNameW(NULL, 0, NULL, NULL);
is_win9x = !ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED;
if (is_win9x)
win_skip("Skipping some tests that cause GetFullPathNameA to crash on Win9x\n");
for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++)
{
if (is_win9x && invalid_parameters[i].win9x_crash)
continue;
SetLastError(0xdeadbeef);
strcpy(output, "deadbeef");
filepart = (char *)0xdeadbeef;
ret = GetFullPathNameA(invalid_parameters[i].name,
invalid_parameters[i].len,
invalid_parameters[i].buffer,
invalid_parameters[i].lastpart);
ok(!ret, "[%d] Expected GetFullPathNameA to return 0, got %u\n", i, ret);
ok(!strcmp(output, "deadbeef"), "[%d] Expected the output buffer to be unchanged, got \"%s\"\n", i, output);
ok(filepart == (char *)0xdeadbeef, "[%d] Expected output file part pointer to be untouched, got %p\n", i, filepart);
ok(GetLastError() == 0xdeadbeef ||
GetLastError() == ERROR_BAD_PATHNAME || /* Win9x */
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");
@ -1610,4 +1665,5 @@ START_TEST(path)
test_drive_letter_case();
test_SearchPathA();
test_SearchPathW();
test_GetFullPathNameA();
}