2 * Unit test suite for drive functions.
4 * Copyright 2002 Dmitry Timoshkov
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "wine/test.h"
25 void test_GetDriveTypeA(void)
27 char drive[] = "?:\\";
31 logical_drives = GetLogicalDrives();
32 ok(logical_drives != 0, "GetLogicalDrives error %ld", GetLastError());
34 for (drive[0] = 'A'; drive[0] <= 'Z'; drive[0]++)
36 type = GetDriveTypeA(drive);
37 ok(type > 0 && type <= 6, "not a valid drive %c: type %u", drive[0], type);
39 if (!(logical_drives & 1))
40 ok(type == DRIVE_NO_ROOT_DIR,
41 "GetDriveTypeA should return DRIVE_NO_ROOT_DIR for a not existing drive %c: but not %u",
48 void test_GetDriveTypeW(void)
50 WCHAR drive[] = {'?',':','\\',0};
54 logical_drives = GetLogicalDrives();
55 ok(logical_drives != 0, "GetLogicalDrives error %ld", GetLastError());
57 for (drive[0] = 'A'; drive[0] <= 'Z'; drive[0]++)
59 type = GetDriveTypeW(drive);
60 ok(type > 0 && type <= 6, "not a valid drive %c: type %u", drive[0], type);
62 if (!(logical_drives & 1))
63 ok(type == DRIVE_NO_ROOT_DIR,
64 "GetDriveTypeW should return DRIVE_NO_ROOT_DIR for a not existing drive %c: but not %u",
71 void test_GetDiskFreeSpaceA(void)
74 DWORD sectors_per_cluster, bytes_per_sector, free_clusters, total_clusters;
75 char drive[] = "?:\\";
78 ret = GetDiskFreeSpaceA(NULL, NULL, NULL, NULL, NULL);
79 ok(ret, "GetDiskFreeSpaceA error %ld", GetLastError());
81 ret = GetDiskFreeSpaceA(NULL, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
82 ok(ret, "GetDiskFreeSpaceA error %ld", GetLastError());
84 ret = GetDiskFreeSpaceA("", §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
85 ok(!ret && GetLastError() == ERROR_PATH_NOT_FOUND, "GetDiskFreeSpaceA should return ERROR_PATH_NOT_FOUND for \"\"");
87 ret = GetDiskFreeSpaceA("\\", §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
88 ok(ret, "GetDiskFreeSpaceA error %ld", GetLastError());
90 ret = GetDiskFreeSpaceA("/", §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
91 ok(ret, "GetDiskFreeSpaceA error %ld", GetLastError());
93 ret = GetDiskFreeSpaceA(".", §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
94 ok(!ret && GetLastError() == ERROR_INVALID_NAME, "GetDiskFreeSpaceA should return ERROR_INVALID_NAME for \".\"");
96 ret = GetDiskFreeSpaceA("..", §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
97 ok(!ret && GetLastError() == ERROR_INVALID_NAME, "GetDiskFreeSpaceA should return ERROR_INVALID_NAME for \"..\"");
99 logical_drives = GetLogicalDrives();
100 ok(logical_drives != 0, "GetLogicalDrives error %ld", GetLastError());
102 for (drive[0] = 'A'; drive[0] <= 'Z'; drive[0]++)
104 ret = GetDiskFreeSpaceA(drive, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
105 if (!(logical_drives & 1))
106 ok(!ret && GetLastError() == ERROR_PATH_NOT_FOUND,
107 "GetDiskFreeSpaceA should return ERROR_PATH_NOT_FOUND for a not existing drive %c",
110 ok(ret, "GetDiskFreeSpaceA error %ld", GetLastError());
112 logical_drives >>= 1;
116 void test_GetDiskFreeSpaceW(void)
119 DWORD sectors_per_cluster, bytes_per_sector, free_clusters, total_clusters;
120 WCHAR drive[] = {'?',':','\\',0};
121 DWORD logical_drives;
122 static const WCHAR empty_pathW[] = { 0 };
123 static const WCHAR root_pathW[] = { '\\', 0 };
124 static const WCHAR unix_style_root_pathW[] = { '/', 0 };
125 static const WCHAR cur_dirW[] = { '.', 0 };
126 static const WCHAR upper_dirW[] = { '.','.', 0 };
128 ret = GetDiskFreeSpaceW(NULL, NULL, NULL, NULL, NULL);
129 ok(ret, "GetDiskFreeSpaceW error %ld", GetLastError());
131 ret = GetDiskFreeSpaceW(NULL, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
132 ok(ret, "GetDiskFreeSpaceW error %ld", GetLastError());
134 ret = GetDiskFreeSpaceW(empty_pathW, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
135 ok(!ret && GetLastError() == ERROR_PATH_NOT_FOUND, "GetDiskFreeSpaceW should return ERROR_PATH_NOT_FOUND for \"\"");
137 ret = GetDiskFreeSpaceW(root_pathW, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
138 ok(ret, "GetDiskFreeSpaceW error %ld", GetLastError());
140 ret = GetDiskFreeSpaceW(unix_style_root_pathW, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
141 ok(ret, "GetDiskFreeSpaceW error %ld", GetLastError());
143 ret = GetDiskFreeSpaceW(cur_dirW, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
144 ok(!ret && GetLastError() == ERROR_INVALID_NAME, "GetDiskFreeSpaceW should return ERROR_INVALID_NAME for \".\"");
146 ret = GetDiskFreeSpaceW(upper_dirW, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
147 ok(!ret && GetLastError() == ERROR_INVALID_NAME, "GetDiskFreeSpaceW should return ERROR_INVALID_NAME for \"..\"");
149 logical_drives = GetLogicalDrives();
150 ok(logical_drives != 0, "GetLogicalDrives error %ld", GetLastError());
152 for (drive[0] = 'A'; drive[0] <= 'Z'; drive[0]++)
154 ret = GetDiskFreeSpaceW(drive, §ors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
155 if (!(logical_drives & 1))
156 ok(!ret && GetLastError() == ERROR_PATH_NOT_FOUND,
157 "GetDiskFreeSpaceW should return ERROR_PATH_NOT_FOUND for a not existing drive %c",
160 ok(ret, "GetDiskFreeSpaceW error %ld", GetLastError());
162 logical_drives >>= 1;
168 test_GetDriveTypeA();
169 test_GetDriveTypeW();
171 test_GetDiskFreeSpaceA();
172 test_GetDiskFreeSpaceW();