kernel32/tests: Add GetVolumePathNameW tests.

oldstable
Sebastian Lackner 2015-06-17 22:36:39 -06:00 committed by Alexandre Julliard
parent d01c135aed
commit b80bbd5986
1 changed files with 49 additions and 0 deletions

View File

@ -54,6 +54,7 @@ static UINT (WINAPI *pGetLogicalDriveStringsA)(UINT,LPSTR);
static UINT (WINAPI *pGetLogicalDriveStringsW)(UINT,LPWSTR);
static BOOL (WINAPI *pGetVolumeInformationA)(LPCSTR, LPSTR, DWORD, LPDWORD, LPDWORD, LPDWORD, LPSTR, DWORD);
static BOOL (WINAPI *pGetVolumePathNameA)(LPCSTR, LPSTR, DWORD);
static BOOL (WINAPI *pGetVolumePathNameW)(LPWSTR, LPWSTR, DWORD);
static BOOL (WINAPI *pGetVolumePathNamesForVolumeNameA)(LPCSTR, LPSTR, DWORD, LPDWORD);
static BOOL (WINAPI *pGetVolumePathNamesForVolumeNameW)(LPCWSTR, LPWSTR, DWORD, LPDWORD);
@ -832,6 +833,52 @@ static void test_GetVolumePathNameA(void)
}
}
static void test_GetVolumePathNameW(void)
{
static WCHAR drive_c1[] = {'C',':',0};
static WCHAR drive_c2[] = {'C',':','\\',0};
WCHAR volume_path[MAX_PATH];
BOOL ret;
if (!pGetVolumePathNameW)
{
win_skip("required functions not found\n");
return;
}
volume_path[0] = 0;
volume_path[1] = 0x11;
ret = pGetVolumePathNameW( drive_c1, volume_path, 1 );
ok(!ret, "GetVolumePathNameW test succeeded unexpectedly.\n");
ok(GetLastError() == ERROR_FILENAME_EXCED_RANGE, "GetVolumePathNameW unexpectedly returned error 0x%x (expected 0x%x).\n",
GetLastError(), ERROR_FILENAME_EXCED_RANGE);
ok(volume_path[1] == 0x11, "GetVolumePathW corrupted byte after end of buffer.\n");
volume_path[0] = 0;
volume_path[2] = 0x11;
ret = pGetVolumePathNameW( drive_c1, volume_path, 2 );
ok(!ret, "GetVolumePathNameW test succeeded unexpectedly.\n");
ok(GetLastError() == ERROR_FILENAME_EXCED_RANGE, "GetVolumePathNameW unexpectedly returned error 0x%x (expected 0x%x).\n",
GetLastError(), ERROR_FILENAME_EXCED_RANGE);
ok(volume_path[2] == 0x11, "GetVolumePathW corrupted byte after end of buffer.\n");
volume_path[0] = 0;
volume_path[3] = 0x11;
ret = pGetVolumePathNameW( drive_c1, volume_path, 3 );
ok(ret || broken(!ret) /* win2k */, "GetVolumePathNameW test failed unexpectedly.\n");
ok(memcmp(volume_path, drive_c1, sizeof(drive_c1)) == 0
|| broken(volume_path[0] == 0) /* win2k */,
"GetVolumePathNameW unexpectedly returned wrong path.\n");
ok(volume_path[3] == 0x11, "GetVolumePathW corrupted byte after end of buffer.\n");
volume_path[0] = 0;
volume_path[4] = 0x11;
ret = pGetVolumePathNameW( drive_c1, volume_path, 4 );
ok(ret, "GetVolumePathNameW test failed unexpectedly.\n");
ok(memcmp(volume_path, drive_c2, sizeof(drive_c2)) == 0, "GetVolumePathNameW unexpectedly returned wrong path.\n");
ok(volume_path[4] == 0x11, "GetVolumePathW corrupted byte after end of buffer.\n");
}
static void test_GetVolumePathNamesForVolumeNameA(void)
{
BOOL ret;
@ -1171,6 +1218,7 @@ START_TEST(volume)
pGetLogicalDriveStringsW = (void *) GetProcAddress(hdll, "GetLogicalDriveStringsW");
pGetVolumeInformationA = (void *) GetProcAddress(hdll, "GetVolumeInformationA");
pGetVolumePathNameA = (void *) GetProcAddress(hdll, "GetVolumePathNameA");
pGetVolumePathNameW = (void *) GetProcAddress(hdll, "GetVolumePathNameW");
pGetVolumePathNamesForVolumeNameA = (void *) GetProcAddress(hdll, "GetVolumePathNamesForVolumeNameA");
pGetVolumePathNamesForVolumeNameW = (void *) GetProcAddress(hdll, "GetVolumePathNamesForVolumeNameW");
@ -1178,6 +1226,7 @@ START_TEST(volume)
test_define_dos_deviceA();
test_FindFirstVolume();
test_GetVolumePathNameA();
test_GetVolumePathNameW();
test_GetVolumeNameForVolumeMountPointA();
test_GetVolumeNameForVolumeMountPointW();
test_GetLogicalDriveStringsA();