Module: wine Branch: master Commit: 1029167232fa7b5492f3cc0537120a911cbf4080 URL: http://source.winehq.org/git/wine.git/?a=commit;h=1029167232fa7b5492f3cc0537...
Author: Andrew Nguyen anguyen@codeweavers.com Date: Wed Jun 16 23:40:26 2010 -0500
kernel32/tests: Add tests to examine output file part pointer behavior for GetFullPathNameW.
---
dlls/kernel32/tests/path.c | 60 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 60 insertions(+), 0 deletions(-)
diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c index 6fa4d93..e6d7e56 100644 --- a/dlls/kernel32/tests/path.c +++ b/dlls/kernel32/tests/path.c @@ -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(); }