2 * Unit test suite for ntdll path functions
4 * Copyright 2002 Alexandre Julliard
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 static NTSTATUS (WINAPI *pRtlMultiByteToUnicodeN)( LPWSTR dst, DWORD dstlen, LPDWORD reslen,
26 LPCSTR src, DWORD srclen );
27 static UINT (WINAPI *pRtlDetermineDosPathNameType_U)( PCWSTR path );
28 static ULONG (WINAPI *pRtlIsDosDeviceName_U)( PCWSTR dos_name );
29 static NTSTATUS (WINAPI *pRtlOemStringToUnicodeString)(UNICODE_STRING *, const STRING *, BOOLEAN );
30 static BOOLEAN (WINAPI *pRtlIsNameLegalDOS8Dot3)(const UNICODE_STRING*,POEM_STRING,PBOOLEAN);
32 static void test_RtlDetermineDosPathNameType(void)
40 static const struct test tests[] =
73 const struct test *test;
74 WCHAR buffer[MAX_PATH];
77 for (test = tests; test->path; test++)
79 pRtlMultiByteToUnicodeN( buffer, sizeof(buffer), NULL, test->path, strlen(test->path)+1 );
80 ret = pRtlDetermineDosPathNameType_U( buffer );
81 ok( ret == test->ret, "Wrong result %d/%d for %s", ret, test->ret, test->path );
86 static void test_RtlIsDosDeviceName(void)
95 static const struct test tests[] =
97 { "\\\\.\\CON", 8, 6 },
98 { "\\\\.\\con", 8, 6 },
99 { "\\\\.\\CON2", 0, 0 },
101 { "\\\\foo\\nul", 0, 0 },
102 { "c:\\nul:", 6, 6 },
103 { "c:\\nul::", 0, 0 },
105 { "c:prn.......", 4, 6 },
106 { "c:prn... ...", 4, 6 },
107 { "c:NUL .... ", 0, 0 },
108 { "c: . . .", 0, 0 },
110 { " . . . :", 0, 0 },
112 { "c:nul. . . :", 4, 6 },
113 { "c:nul . . :", 0, 0 },
115 { "c:prn:aaa", 0, 0 },
116 { "c:PRN:.txt", 4, 6 },
117 { "c:aux:.txt...", 4, 6 },
118 { "c:prn:.txt:", 4, 6 },
119 { "c:nul:aaa", 0, 0 },
125 { "c:\\lpt0.txt", 0, 0 },
126 { "c:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
127 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
128 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
129 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
130 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
131 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
132 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\nul.txt", 1000, 6 },
136 const struct test *test;
140 for (test = tests; test->path; test++)
142 pRtlMultiByteToUnicodeN( buffer, sizeof(buffer), NULL, test->path, strlen(test->path)+1 );
143 ret = pRtlIsDosDeviceName_U( buffer );
144 ok( ret == MAKELONG( test->len, test->pos ),
145 "Wrong result (%d,%d)/(%d,%d) for %s",
146 HIWORD(ret), LOWORD(ret), test->pos, test->len, test->path );
150 static void test_RtlIsNameLegalDOS8Dot3(void)
159 static const struct test tests[] =
161 { "12345678", TRUE, FALSE },
162 { "123 5678", TRUE, TRUE },
163 { "12345678.", FALSE, 2 /*not set*/ },
164 { "1234 678.", FALSE, 2 /*not set*/ },
165 { "12345678.a", TRUE, FALSE },
166 { "12345678.a ", FALSE, 2 /*not set*/ },
167 { "12345678.a c", TRUE, TRUE },
168 { " 2345678.a ", FALSE, 2 /*not set*/ },
169 { "1 345678.abc", TRUE, TRUE },
170 { "1 8.a c", TRUE, TRUE },
171 { "1 3 5 7 .abc", FALSE, 2 /*not set*/ },
172 { "12345678. c", TRUE, TRUE },
173 { "123456789.a", FALSE, 2 /*not set*/ },
174 { "12345.abcd", FALSE, 2 /*not set*/ },
175 { "12345.ab d", FALSE, 2 /*not set*/ },
176 { ".abc", FALSE, 2 /*not set*/ },
177 { "12.abc.d", FALSE, 2 /*not set*/ },
178 { ".", TRUE, FALSE },
179 { "..", TRUE, FALSE },
180 { "...", FALSE, 2 /*not set*/ },
181 { "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", FALSE, 2 /*not set*/ },
185 const struct test *test;
187 OEM_STRING oem, oem_ret;
192 ustr.MaximumLength = sizeof(buffer);
193 ustr.Buffer = buffer;
194 for (test = tests; test->path; test++)
196 oem.Buffer = test->path;
197 oem.Length = strlen(test->path);
198 oem.MaximumLength = oem.Length + 1;
199 pRtlOemStringToUnicodeString( &ustr, &oem, FALSE );
201 oem_ret.Length = oem_ret.MaximumLength = sizeof(buff2);
202 oem_ret.Buffer = buff2;
203 ret = pRtlIsNameLegalDOS8Dot3( &ustr, &oem_ret, &spaces );
204 ok( ret == test->result, "Wrong result %d/%d for '%s'", ret, test->result, test->path );
205 ok( spaces == test->spaces, "Wrong spaces value %d/%d for '%s'", spaces, test->spaces, test->path );
206 if (strlen(test->path) <= 12)
210 strcpy( str, test->path );
211 for (i = 0; str[i]; i++) str[i] = toupper(str[i]);
212 ok( oem_ret.Length == strlen(test->path), "Wrong length %d/%d for '%s'",
213 oem_ret.Length, strlen(test->path), test->path );
214 ok( !memcmp( oem_ret.Buffer, str, oem_ret.Length ),
215 "Wrong string '%.*s'/'%s'", oem_ret.Length, oem_ret.Buffer, str );
223 HMODULE mod = GetModuleHandleA("ntdll.dll");
224 pRtlMultiByteToUnicodeN = (void *)GetProcAddress(mod,"RtlMultiByteToUnicodeN");
225 pRtlDetermineDosPathNameType_U = (void *)GetProcAddress(mod,"RtlDetermineDosPathNameType_U");
226 pRtlIsDosDeviceName_U = (void *)GetProcAddress(mod,"RtlIsDosDeviceName_U");
227 pRtlOemStringToUnicodeString = (void *)GetProcAddress(mod,"RtlOemStringToUnicodeString");
228 pRtlIsNameLegalDOS8Dot3 = (void *)GetProcAddress(mod,"RtlIsNameLegalDOS8Dot3");
229 test_RtlDetermineDosPathNameType();
230 test_RtlIsDosDeviceName();
231 test_RtlIsNameLegalDOS8Dot3();