kernel32/tests: Add tests for GetDriveType with invalid drive spec

Joachim Priesner joachim.priesner at web.de
Thu Nov 26 16:49:39 CST 2015


Signed-off-by: Joachim Priesner <joachim.priesner at web.de>
---
 dlls/kernel32/tests/drive.c | 59 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/dlls/kernel32/tests/drive.c b/dlls/kernel32/tests/drive.c
index 4acd3e8..98dc454 100644
--- a/dlls/kernel32/tests/drive.c
+++ b/dlls/kernel32/tests/drive.c
@@ -30,6 +30,7 @@ static DWORD (WINAPI *pGetDiskFreeSpaceExA)(LPCSTR, PULARGE_INTEGER, PULARGE_INT
 static void test_GetDriveTypeA(void)
 {
     char drive[] = "?:\\";
+    char existing_drive_letter = 0;
     DWORD logical_drives;
     UINT type;
 
@@ -46,14 +47,43 @@ static void test_GetDriveTypeA(void)
             ok(type == DRIVE_NO_ROOT_DIR,
                "GetDriveTypeA should return DRIVE_NO_ROOT_DIR for inexistent drive %c: but not %u\n",
                drive[0], type);
+        else if (type != DRIVE_NO_ROOT_DIR)
+            existing_drive_letter = drive[0];
 
         logical_drives >>= 1;
     }
+
+    if (!existing_drive_letter) {
+        skip("No drives found, skipping drive spec format tests.\n");
+        return;
+    }
+
+    drive[0] = existing_drive_letter;
+    drive[2] = 0; /* C: */
+    type = GetDriveTypeA(drive);
+    ok(type > DRIVE_NO_ROOT_DIR && type <= DRIVE_RAMDISK, "got %u for drive spec '%s'\n", type, drive);
+
+    drive[1] = '?'; /* C? */
+    type = GetDriveTypeA(drive);
+    ok(type == DRIVE_NO_ROOT_DIR, "got %u for drive spec '%s'\n", type, drive);
+
+    drive[1] = 0; /* C */
+    type = GetDriveTypeA(drive);
+    ok(type == DRIVE_NO_ROOT_DIR, "got %u for drive spec '%s'\n", type, drive);
+
+    drive[0] = '?'; /* the string "?" */
+    type = GetDriveTypeA(drive);
+    ok(type == DRIVE_NO_ROOT_DIR, "got %u for drive spec '%s'\n", type, drive);
+
+    drive[0] = 0; /* the empty string */
+    type = GetDriveTypeA(drive);
+    ok(type == DRIVE_NO_ROOT_DIR, "got %u for drive spec '%s'\n", type, drive);
 }
 
 static void test_GetDriveTypeW(void)
 {
     WCHAR drive[] = {'?',':','\\',0};
+    WCHAR existing_drive_letter = 0;
     DWORD logical_drives;
     UINT type;
 
@@ -70,9 +100,38 @@ static void test_GetDriveTypeW(void)
             ok(type == DRIVE_NO_ROOT_DIR,
                "GetDriveTypeW should return DRIVE_NO_ROOT_DIR for inexistent drive %c: but not %u\n",
                drive[0], type);
+        else if (type != DRIVE_NO_ROOT_DIR)
+            existing_drive_letter = drive[0];
 
         logical_drives >>= 1;
     }
+
+    if (!existing_drive_letter) {
+        skip("No drives found, skipping drive spec format tests.\n");
+        return;
+    }
+
+    drive[0] = existing_drive_letter;
+    drive[2] = 0; /* C: */
+    type = GetDriveTypeW(drive);
+    ok(type > DRIVE_NO_ROOT_DIR && type <= DRIVE_RAMDISK, "got %u for drive spec '%s'\n",
+       type, wine_dbgstr_w(drive));
+
+    drive[1] = '?'; /* C? */
+    type = GetDriveTypeW(drive);
+    ok(type == DRIVE_NO_ROOT_DIR, "got %u for drive spec '%s'\n", type, wine_dbgstr_w(drive));
+
+    drive[1] = 0; /* C */
+    type = GetDriveTypeW(drive);
+    ok(type == DRIVE_NO_ROOT_DIR, "got %u for drive spec '%s'\n", type, wine_dbgstr_w(drive));
+
+    drive[0] = '?'; /* the string "?" */
+    type = GetDriveTypeW(drive);
+    ok(type == DRIVE_NO_ROOT_DIR, "got %u for drive spec '%s'\n", type, wine_dbgstr_w(drive));
+
+    drive[0] = 0; /* the empty string */
+    type = GetDriveTypeW(drive);
+    ok(type == DRIVE_NO_ROOT_DIR, "got %u for drive spec '%s'\n", type, wine_dbgstr_w(drive));
 }
 
 static void test_GetDiskFreeSpaceA(void)
-- 
2.1.4



More information about the wine-patches mailing list