Joachim Priesner : kernel32/tests: Add tests for GetDriveType with invalid drive spec.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Nov 27 08:20:49 CST 2015


Module: wine
Branch: master
Commit: ceb57b781748807900d88ac06832fe750b7c44d2
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ceb57b781748807900d88ac06832fe750b7c44d2

Author: Joachim Priesner <joachim.priesner at web.de>
Date:   Thu Nov 26 23:49:39 2015 +0100

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

Signed-off-by: Joachim Priesner <joachim.priesner at web.de>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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)




More information about the wine-cvs mailing list