4 #define IS_DRIVE_TYPE_VALID(type) ((type) != DRIVE_UNKNOWN && (type) != DRIVE_NO_ROOT_DIR)
6 START_TEST(GetDriveType
)
11 /* Note: Successful calls can set last error to at least ERROR_NOT_A_REPARSE_POINT, we don't test it here */
12 SetLastError(0xdeadbeaf);
14 Type
= GetDriveTypeW(L
"");
15 ok(Type
== DRIVE_NO_ROOT_DIR
, "Expected DRIVE_NO_ROOT_DIR, got %u\n", Type
);
17 Type
= GetDriveTypeW(L
"\nC:\\");
18 ok(Type
== DRIVE_NO_ROOT_DIR
, "Expected DRIVE_NO_ROOT_DIR, got %u\n", Type
);
20 Type
= GetDriveTypeW(L
"Z:\\");
21 ok(Type
== DRIVE_NO_ROOT_DIR
, "Expected DRIVE_NO_ROOT_DIR, got %u\n", Type
);
23 ok(GetLastError() == 0xdeadbeaf, "Expected no errors, got %lu\n", GetLastError());
25 /* Drive root is accepted without ending slash */
26 Type
= GetDriveTypeW(L
"C:");
27 ok(IS_DRIVE_TYPE_VALID(Type
), "Expected valid drive type, got %u\n", Type
);
29 Type
= GetDriveTypeW(L
"C:\\");
30 ok(IS_DRIVE_TYPE_VALID(Type
), "Expected valid drive type, got %u\n", Type
);
32 Type
= GetDriveTypeW(NULL
);
33 ok(IS_DRIVE_TYPE_VALID(Type
), "Expected valid drive type, got %u\n", Type
);
35 i
= GetCurrentDirectoryW(sizeof(Path
)/sizeof(Path
[0]), Path
);
38 /* No trailing backslash returned unless we're at the drive root */
39 if (Path
[i
- 1] != L
'\\')
41 SetLastError(0xdeadbeaf);
42 Type2
= GetDriveTypeW(Path
);
43 ok(Type2
== DRIVE_NO_ROOT_DIR
, "Expected DRIVE_NO_ROOT_DIR, got %u\n", Type2
);
44 ok(GetLastError() == 0xdeadbeaf, "Expected no errors, got %lu\n", GetLastError());
46 StringCchCopyW(Path
+ i
, MAX_PATH
- i
, L
"\\");
48 Type2
= GetDriveTypeW(Path
);
49 ok(Type
== Type2
, "Types are not equal: %u != %u\n", Type
, Type2
);
52 i
= GetSystemDirectoryW(Path
, sizeof(Path
)/sizeof(Path
[0]));
55 /* Note: there is no backslash at the end of Path */
56 SetLastError(0xdeadbeaf);
57 Type
= GetDriveTypeW(Path
);
58 ok(Type
== DRIVE_NO_ROOT_DIR
, "Expected DRIVE_NO_ROOT_DIR, got %u\n", Type
);
59 ok(GetLastError() == 0xdeadbeaf, "Expected no errors, got %lu\n", GetLastError());
61 StringCchCopyW(Path
+ i
, MAX_PATH
- i
, L
"\\");
62 Type
= GetDriveTypeW(Path
);
63 ok(IS_DRIVE_TYPE_VALID(Type
), "Expected valid drive type, got %u\n", Type
);
65 StringCchCopyW(Path
+ i
, MAX_PATH
- i
, L
"/");
66 Type
= GetDriveTypeW(Path
);
67 ok(IS_DRIVE_TYPE_VALID(Type
), "Expected valid drive type, got %u\n", Type
);
69 StringCchCopyW(Path
+ i
, MAX_PATH
- i
, L
"\\\\");
70 Type
= GetDriveTypeW(Path
);
71 ok(IS_DRIVE_TYPE_VALID(Type
), "Expected valid drive type, got %u\n", Type
);