3 #define IS_DRIVE_TYPE_VALID(type) ((type) != DRIVE_UNKNOWN && (type) != DRIVE_NO_ROOT_DIR)
5 START_TEST(GetDriveType
)
10 /* Note: Successful calls can set last error to at least ERROR_NOT_A_REPARSE_POINT, we don't test it here */
11 SetLastError(0xdeadbeaf);
13 Type
= GetDriveTypeW(L
"");
14 ok(Type
== DRIVE_NO_ROOT_DIR
, "Expected DRIVE_NO_ROOT_DIR, got %u\n", Type
);
16 Type
= GetDriveTypeW(L
"\nC:\\");
17 ok(Type
== DRIVE_NO_ROOT_DIR
, "Expected DRIVE_NO_ROOT_DIR, got %u\n", Type
);
19 Type
= GetDriveTypeW(L
"Z:\\");
20 ok(Type
== DRIVE_NO_ROOT_DIR
, "Expected DRIVE_NO_ROOT_DIR, got %u\n", Type
);
22 ok(GetLastError() == 0xdeadbeaf, "Expected no errors, got %lu\n", GetLastError());
24 /* Drive root is accepted without ending slash */
25 Type
= GetDriveTypeW(L
"C:");
26 ok(IS_DRIVE_TYPE_VALID(Type
), "Expected valid drive type, got %u\n", Type
);
28 Type
= GetDriveTypeW(L
"C:\\");
29 ok(IS_DRIVE_TYPE_VALID(Type
), "Expected valid drive type, got %u\n", Type
);
31 Type
= GetDriveTypeW(NULL
);
32 ok(IS_DRIVE_TYPE_VALID(Type
), "Expected valid drive type, got %u\n", Type
);
34 i
= GetCurrentDirectoryW(sizeof(Path
)/sizeof(Path
[0]), Path
);
37 /* No trailing backslash returned unless we're at the drive root */
38 if (Path
[i
- 1] != L
'\\')
40 SetLastError(0xdeadbeaf);
41 Type2
= GetDriveTypeW(Path
);
42 ok(Type2
== DRIVE_NO_ROOT_DIR
, "Expected DRIVE_NO_ROOT_DIR, got %u\n", Type2
);
43 ok(GetLastError() == 0xdeadbeaf, "Expected no errors, got %lu\n", GetLastError());
45 StringCchCopyW(Path
+ i
, MAX_PATH
- i
, L
"\\");
47 Type2
= GetDriveTypeW(Path
);
48 ok(Type
== Type2
, "Types are not equal: %u != %u\n", Type
, Type2
);
51 i
= GetSystemDirectoryW(Path
, sizeof(Path
)/sizeof(Path
[0]));
54 /* Note: there is no backslash at the end of Path */
55 SetLastError(0xdeadbeaf);
56 Type
= GetDriveTypeW(Path
);
57 ok(Type
== DRIVE_NO_ROOT_DIR
, "Expected DRIVE_NO_ROOT_DIR, got %u\n", Type
);
58 ok(GetLastError() == 0xdeadbeaf, "Expected no errors, got %lu\n", GetLastError());
60 StringCchCopyW(Path
+ i
, MAX_PATH
- i
, L
"\\");
61 Type
= GetDriveTypeW(Path
);
62 ok(IS_DRIVE_TYPE_VALID(Type
), "Expected valid drive type, got %u\n", Type
);
64 StringCchCopyW(Path
+ i
, MAX_PATH
- i
, L
"/");
65 Type
= GetDriveTypeW(Path
);
66 ok(IS_DRIVE_TYPE_VALID(Type
), "Expected valid drive type, got %u\n", Type
);
68 StringCchCopyW(Path
+ i
, MAX_PATH
- i
, L
"\\\\");
69 Type
= GetDriveTypeW(Path
);
70 ok(IS_DRIVE_TYPE_VALID(Type
), "Expected valid drive type, got %u\n", Type
);