Merge my current work done on the kd++ branch:
[reactos.git] / rostests / apitests / kernel32 / GetDriveType.c
1 #include <wine/test.h>
2
3 #define IS_DRIVE_TYPE_VALID(type) ((type) != DRIVE_UNKNOWN && (type) != DRIVE_NO_ROOT_DIR)
4
5 START_TEST(GetDriveType)
6 {
7 UINT Type, Type2, i;
8 WCHAR Path[MAX_PATH];
9
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);
12
13 Type = GetDriveTypeW(L"");
14 ok(Type == DRIVE_NO_ROOT_DIR, "Expected DRIVE_NO_ROOT_DIR, got %u\n", Type);
15
16 Type = GetDriveTypeW(L"\nC:\\");
17 ok(Type == DRIVE_NO_ROOT_DIR, "Expected DRIVE_NO_ROOT_DIR, got %u\n", Type);
18
19 Type = GetDriveTypeW(L"Z:\\");
20 ok(Type == DRIVE_NO_ROOT_DIR, "Expected DRIVE_NO_ROOT_DIR, got %u\n", Type);
21
22 ok(GetLastError() == 0xdeadbeaf, "Expected no errors, got %lu\n", GetLastError());
23
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);
27
28 Type = GetDriveTypeW(L"C:\\");
29 ok(IS_DRIVE_TYPE_VALID(Type), "Expected valid drive type, got %u\n", Type);
30
31 Type = GetDriveTypeW(NULL);
32 ok(IS_DRIVE_TYPE_VALID(Type), "Expected valid drive type, got %u\n", Type);
33
34 i = GetCurrentDirectoryW(sizeof(Path)/sizeof(Path[0]), Path);
35 if (i)
36 {
37 /* Note: there is no backslash at the end of Path */
38 SetLastError(0xdeadbeaf);
39 Type2 = GetDriveTypeW(Path);
40 ok(Type2 == DRIVE_NO_ROOT_DIR, "Expected DRIVE_NO_ROOT_DIR, got %u\n", Type2);
41 ok(GetLastError() == 0xdeadbeaf, "Expected ERROR_NOT_A_REPARSE_POINT, got %lu\n", GetLastError());
42
43 wcscpy(Path+i, L"\\");
44 Type2 = GetDriveTypeW(Path);
45 ok(Type == Type2, "Types are not equal: %u != %u\n", Type, Type2);
46 }
47
48 i = GetSystemDirectoryW(Path, sizeof(Path)/sizeof(Path[0]));
49 if (i)
50 {
51 /* Note: there is no backslash at the end of Path */
52 SetLastError(0xdeadbeaf);
53 Type = GetDriveTypeW(Path);
54 ok(Type == DRIVE_NO_ROOT_DIR, "Expected DRIVE_NO_ROOT_DIR, got %u\n", Type);
55 ok(GetLastError() == 0xdeadbeaf, "Expected no errors, got %lu\n", GetLastError());
56
57 wcscpy(Path+i, L"\\");
58 Type = GetDriveTypeW(Path);
59 ok(IS_DRIVE_TYPE_VALID(Type), "Expected valid drive type, got %u\n", Type);
60
61 wcscpy(Path+i, L"/");
62 Type = GetDriveTypeW(Path);
63 ok(IS_DRIVE_TYPE_VALID(Type), "Expected valid drive type, got %u\n", Type);
64
65 wcscpy(Path+i, L"\\\\");
66 Type = GetDriveTypeW(Path);
67 ok(IS_DRIVE_TYPE_VALID(Type), "Expected valid drive type, got %u\n", Type);
68 }
69 }