1 /* Unit test suite for Path functions
3 * Copyright 2002 Matthew Mastracci
4 * Copyright 2007 Detlef Riekenberg
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/test.h"
31 /* ################ */
32 static HMODULE hShlwapi;
33 static HRESULT (WINAPI *pUrlCanonicalizeW)(LPCWSTR, LPWSTR, LPDWORD, DWORD);
35 static const char* TEST_URL_1 = "http://www.winehq.org/tests?date=10/10/1923";
36 static const char* TEST_URL_2 = "http://localhost:8080/tests%2e.html?date=Mon%2010/10/1923";
37 static const char* TEST_URL_3 = "http://foo:bar@localhost:21/internal.php?query=x&return=y";
38 static const WCHAR winehqW[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/',0};
39 static const CHAR winehqA[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/',0};
41 /* ################ */
43 typedef struct _TEST_URL_CANONICALIZE {
47 const char *expecturl;
48 } TEST_URL_CANONICALIZE;
50 static const TEST_URL_CANONICALIZE TEST_CANONICALIZE[] = {
51 /*FIXME {"http://www.winehq.org/tests/../tests/../..", 0, S_OK, "http://www.winehq.org/"},*/
52 {"http://www.winehq.org/tests/../tests", 0, S_OK, "http://www.winehq.org/tests"},
53 {"http://www.winehq.org/tests\n", URL_WININET_COMPATIBILITY|URL_ESCAPE_SPACES_ONLY|URL_ESCAPE_UNSAFE, S_OK, "http://www.winehq.org/tests"},
54 {"http://www.winehq.org/tests\r", URL_WININET_COMPATIBILITY|URL_ESCAPE_SPACES_ONLY|URL_ESCAPE_UNSAFE, S_OK, "http://www.winehq.org/tests"},
55 {"http://www.winehq.org/tests\r", 0, S_OK, "http://www.winehq.org/tests"},
56 {"http://www.winehq.org/tests\r", URL_DONT_SIMPLIFY, S_OK, "http://www.winehq.org/tests"},
57 {"http://www.winehq.org/tests/../tests/", 0, S_OK, "http://www.winehq.org/tests/"},
58 {"http://www.winehq.org/tests/../tests/..", 0, S_OK, "http://www.winehq.org/"},
59 {"http://www.winehq.org/tests/../tests/../", 0, S_OK, "http://www.winehq.org/"},
60 {"http://www.winehq.org/tests/..", 0, S_OK, "http://www.winehq.org/"},
61 {"http://www.winehq.org/tests/../", 0, S_OK, "http://www.winehq.org/"},
62 {"http://www.winehq.org/tests/..?query=x&return=y", 0, S_OK, "http://www.winehq.org/?query=x&return=y"},
63 {"http://www.winehq.org/tests/../?query=x&return=y", 0, S_OK, "http://www.winehq.org/?query=x&return=y"},
64 {"http://www.winehq.org/tests/..#example", 0, S_OK, "http://www.winehq.org/#example"},
65 {"http://www.winehq.org/tests/../#example", 0, S_OK, "http://www.winehq.org/#example"},
66 {"http://www.winehq.org/tests\\../#example", 0, S_OK, "http://www.winehq.org/#example"},
67 {"http://www.winehq.org/tests/..\\#example", 0, S_OK, "http://www.winehq.org/#example"},
68 {"http://www.winehq.org\\tests/../#example", 0, S_OK, "http://www.winehq.org/#example"},
69 {"http://www.winehq.org/tests/../#example", URL_DONT_SIMPLIFY, S_OK, "http://www.winehq.org/tests/../#example"},
70 {"http://www.winehq.org/tests/foo bar", URL_ESCAPE_SPACES_ONLY| URL_DONT_ESCAPE_EXTRA_INFO , S_OK, "http://www.winehq.org/tests/foo%20bar"},
71 {"http://www.winehq.org/tests/foo%20bar", URL_UNESCAPE , S_OK, "http://www.winehq.org/tests/foo bar"},
72 {"file:///c:/tests/foo%20bar", URL_UNESCAPE , S_OK, "file:///c:/tests/foo bar"},
73 {"file:///c:/tests\\foo%20bar", URL_UNESCAPE , S_OK, "file:///c:/tests/foo bar"},
74 {"file:///c:/tests/foo%20bar", 0, S_OK, "file:///c:/tests/foo%20bar"},
75 {"file:///c:/tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar"},
76 {"file://c:/tests/../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar"},
77 {"file://c:/tests\\../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar"},
78 {"file://c:/tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar"},
79 {"file:///c://tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\\\tests\\foo bar"},
80 {"file:///c:\\tests\\foo bar", 0, S_OK, "file:///c:/tests/foo bar"},
81 {"file:///c:\\tests\\foo bar", URL_DONT_SIMPLIFY, S_OK, "file:///c:/tests/foo bar"},
82 {"http://www.winehq.org/site/about", URL_FILE_USE_PATHURL, S_OK, "http://www.winehq.org/site/about"},
83 {"file_://www.winehq.org/site/about", URL_FILE_USE_PATHURL, S_OK, "file_://www.winehq.org/site/about"},
84 {"c:\\dir\\file", 0, S_OK, "file:///c:/dir/file"},
85 {"file:///c:\\dir\\file", 0, S_OK, "file:///c:/dir/file"},
86 {"c:dir\\file", 0, S_OK, "file:///c:dir/file"},
87 {"c:\\tests\\foo bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar"},
88 {"c:\\tests\\foo bar", 0, S_OK, "file:///c:/tests/foo%20bar"},
93 /* ################ */
95 typedef struct _TEST_URL_ESCAPE {
100 const char *expecturl;
103 static const TEST_URL_ESCAPE TEST_ESCAPE[] = {
104 {"http://www.winehq.org/tests0", 0, 0, S_OK, "http://www.winehq.org/tests0"},
105 {"http://www.winehq.org/tests1\n", 0, 0, S_OK, "http://www.winehq.org/tests1%0A"},
106 {"http://www.winehq.org/tests2\r", 0, 0, S_OK, "http://www.winehq.org/tests2%0D"},
107 {"http://www.winehq.org/tests3\r", URL_ESCAPE_SPACES_ONLY|URL_ESCAPE_UNSAFE, 0, S_OK, "http://www.winehq.org/tests3\r"},
108 {"http://www.winehq.org/tests4\r", URL_ESCAPE_SPACES_ONLY, 0, S_OK, "http://www.winehq.org/tests4\r"},
109 {"http://www.winehq.org/tests5\r", URL_WININET_COMPATIBILITY|URL_ESCAPE_SPACES_ONLY, 0, S_OK, "http://www.winehq.org/tests5\r"},
110 {"/direct/swhelp/series6/6.2i_latestservicepack.dat\r", URL_ESCAPE_SPACES_ONLY, 0, S_OK, "/direct/swhelp/series6/6.2i_latestservicepack.dat\r"},
112 {"file://////foo/bar\\baz", 0, 0, S_OK, "file://foo/bar/baz"},
113 {"file://///foo/bar\\baz", 0, 0, S_OK, "file://foo/bar/baz"},
114 {"file:////foo/bar\\baz", 0, 0, S_OK, "file://foo/bar/baz"},
115 {"file:///localhost/foo/bar\\baz", 0, 0, S_OK, "file:///localhost/foo/bar/baz"},
116 {"file:///foo/bar\\baz", 0, 0, S_OK, "file:///foo/bar/baz"},
117 {"file://loCalHost/foo/bar\\baz", 0, 0, S_OK, "file:///foo/bar/baz"},
118 {"file://foo/bar\\baz", 0, 0, S_OK, "file://foo/bar/baz"},
119 {"file:/localhost/foo/bar\\baz", 0, 0, S_OK, "file:///localhost/foo/bar/baz"},
120 {"file:/foo/bar\\baz", 0, 0, S_OK, "file:///foo/bar/baz"},
121 {"file:foo/bar\\baz", 0, 0, S_OK, "file:foo/bar/baz"},
122 {"file:\\foo/bar\\baz", 0, 0, S_OK, "file:///foo/bar/baz"},
123 {"file:\\\\foo/bar\\baz", 0, 0, S_OK, "file://foo/bar/baz"},
124 {"file:\\\\\\foo/bar\\baz", 0, 0, S_OK, "file:///foo/bar/baz"},
125 {"file:\\\\localhost\\foo/bar\\baz", 0, 0, S_OK, "file:///foo/bar/baz"},
126 {"file:///f oo/b?a r\\baz", 0, 0, S_OK, "file:///f%20oo/b?a r\\baz"},
127 {"file:///foo/b#a r\\baz", 0, 0, S_OK, "file:///foo/b%23a%20r/baz"},
128 {"file:///f o^&`{}|][\"<>\\%o/b#a r\\baz", 0, 0, S_OK, "file:///f%20o%5E%26%60%7B%7D%7C%5D%5B%22%3C%3E/%o/b%23a%20r/baz"},
129 {"file:///f o%o/b?a r\\b%az", URL_ESCAPE_PERCENT, 0, S_OK, "file:///f%20o%25o/b?a r\\b%az"},
130 {"file:/foo/bar\\baz", URL_ESCAPE_SEGMENT_ONLY, 0, S_OK, "file:%2Ffoo%2Fbar%5Cbaz"},
132 {"foo/b%ar\\ba?z\\", URL_ESCAPE_SEGMENT_ONLY, 0, S_OK, "foo%2Fb%ar%5Cba%3Fz%5C"},
133 {"foo/b%ar\\ba?z\\", URL_ESCAPE_PERCENT | URL_ESCAPE_SEGMENT_ONLY, 0, S_OK, "foo%2Fb%25ar%5Cba%3Fz%5C"},
134 {"foo/bar\\ba?z\\", 0, 0, S_OK, "foo/bar%5Cba?z\\"},
135 {"/foo/bar\\ba?z\\", 0, 0, S_OK, "/foo/bar%5Cba?z\\"},
136 {"/foo/bar\\ba#z\\", 0, 0, S_OK, "/foo/bar%5Cba#z\\"},
137 {"/foo/%5C", 0, 0, S_OK, "/foo/%5C"},
138 {"/foo/%5C", URL_ESCAPE_PERCENT, 0, S_OK, "/foo/%255C"},
140 {"http://////foo/bar\\baz", 0, 0, S_OK, "http://////foo/bar/baz"},
141 {"http://///foo/bar\\baz", 0, 0, S_OK, "http://///foo/bar/baz"},
142 {"http:////foo/bar\\baz", 0, 0, S_OK, "http:////foo/bar/baz"},
143 {"http:///foo/bar\\baz", 0, 0, S_OK, "http:///foo/bar/baz"},
144 {"http://localhost/foo/bar\\baz", 0, 0, S_OK, "http://localhost/foo/bar/baz"},
145 {"http://foo/bar\\baz", 0, 0, S_OK, "http://foo/bar/baz"},
146 {"http:/foo/bar\\baz", 0, 0, S_OK, "http:/foo/bar/baz"},
147 {"http:foo/bar\\ba?z\\", 0, 0, S_OK, "http:foo%2Fbar%2Fba?z\\"},
148 {"http:foo/bar\\ba#z\\", 0, 0, S_OK, "http:foo%2Fbar%2Fba#z\\"},
149 {"http:\\foo/bar\\baz", 0, 0, S_OK, "http:/foo/bar/baz"},
150 {"http:\\\\foo/bar\\baz", 0, 0, S_OK, "http://foo/bar/baz"},
151 {"http:\\\\\\foo/bar\\baz", 0, 0, S_OK, "http:///foo/bar/baz"},
152 {"http:\\\\\\\\foo/bar\\baz", 0, 0, S_OK, "http:////foo/bar/baz"},
153 {"http:/fo ?o/b ar\\baz", 0, 0, S_OK, "http:/fo%20?o/b ar\\baz"},
154 {"http:fo ?o/b ar\\baz", 0, 0, S_OK, "http:fo%20?o/b ar\\baz"},
155 {"http:/foo/bar\\baz", URL_ESCAPE_SEGMENT_ONLY, 0, S_OK, "http:%2Ffoo%2Fbar%5Cbaz"},
157 {"https://foo/bar\\baz", 0, 0, S_OK, "https://foo/bar/baz"},
158 {"https:/foo/bar\\baz", 0, 0, S_OK, "https:/foo/bar/baz"},
159 {"https:\\foo/bar\\baz", 0, 0, S_OK, "https:/foo/bar/baz"},
161 {"foo:////foo/bar\\baz", 0, 0, S_OK, "foo:////foo/bar%5Cbaz"},
162 {"foo:///foo/bar\\baz", 0, 0, S_OK, "foo:///foo/bar%5Cbaz"},
163 {"foo://localhost/foo/bar\\baz", 0, 0, S_OK, "foo://localhost/foo/bar%5Cbaz"},
164 {"foo://foo/bar\\baz", 0, 0, S_OK, "foo://foo/bar%5Cbaz"},
165 {"foo:/foo/bar\\baz", 0, 0, S_OK, "foo:/foo/bar%5Cbaz"},
166 {"foo:foo/bar\\baz", 0, 0, S_OK, "foo:foo%2Fbar%5Cbaz"},
167 {"foo:\\foo/bar\\baz", 0, 0, S_OK, "foo:%5Cfoo%2Fbar%5Cbaz"},
168 {"foo:/foo/bar\\ba?\\z", 0, 0, S_OK, "foo:/foo/bar%5Cba?\\z"},
169 {"foo:/foo/bar\\ba#\\z", 0, 0, S_OK, "foo:/foo/bar%5Cba#\\z"},
171 {"mailto:/fo/o@b\\%a?\\r.b#\\az", 0, 0, S_OK, "mailto:%2Ffo%2Fo@b%5C%a%3F%5Cr.b%23%5Caz"},
172 {"mailto:fo/o@b\\%a?\\r.b#\\az", 0, 0, S_OK, "mailto:fo%2Fo@b%5C%a%3F%5Cr.b%23%5Caz"},
173 {"mailto:fo/o@b\\%a?\\r.b#\\az", URL_ESCAPE_PERCENT, 0, S_OK, "mailto:fo%2Fo@b%5C%25a%3F%5Cr.b%23%5Caz"},
175 {"ftp:fo/o@bar.baz/foo/bar", 0, 0, S_OK, "ftp:fo%2Fo@bar.baz%2Ffoo%2Fbar"},
176 {"ftp:/fo/o@bar.baz/foo/bar", 0, 0, S_OK, "ftp:/fo/o@bar.baz/foo/bar"},
177 {"ftp://fo/o@bar.baz/fo?o\\bar", 0, 0, S_OK, "ftp://fo/o@bar.baz/fo?o\\bar"},
178 {"ftp://fo/o@bar.baz/fo#o\\bar", 0, 0, S_OK, "ftp://fo/o@bar.baz/fo#o\\bar"},
179 {"ftp://localhost/o@bar.baz/fo#o\\bar", 0, 0, S_OK, "ftp://localhost/o@bar.baz/fo#o\\bar"},
180 {"ftp:///fo/o@bar.baz/foo/bar", 0, 0, S_OK, "ftp:///fo/o@bar.baz/foo/bar"},
181 {"ftp:////fo/o@bar.baz/foo/bar", 0, 0, S_OK, "ftp:////fo/o@bar.baz/foo/bar"}
184 /* ################ */
186 typedef struct _TEST_URL_COMBINE {
191 const char *expecturl;
194 static const TEST_URL_COMBINE TEST_COMBINE[] = {
195 {"http://www.winehq.org/tests", "tests1", 0, S_OK, "http://www.winehq.org/tests1"},
196 {"http://www.%77inehq.org/tests", "tests1", 0, S_OK, "http://www.%77inehq.org/tests1"},
197 /*FIXME {"http://www.winehq.org/tests", "../tests2", 0, S_OK, "http://www.winehq.org/tests2"},*/
198 {"http://www.winehq.org/tests/", "../tests3", 0, S_OK, "http://www.winehq.org/tests3"},
199 {"http://www.winehq.org/tests/test1", "test2", 0, S_OK, "http://www.winehq.org/tests/test2"},
200 {"http://www.winehq.org/tests/../tests", "tests4", 0, S_OK, "http://www.winehq.org/tests4"},
201 {"http://www.winehq.org/tests/../tests/", "tests5", 0, S_OK, "http://www.winehq.org/tests/tests5"},
202 {"http://www.winehq.org/tests/../tests/", "/tests6/..", 0, S_OK, "http://www.winehq.org/"},
203 {"http://www.winehq.org/tests/../tests/..", "tests7/..", 0, S_OK, "http://www.winehq.org/"},
204 {"http://www.winehq.org/tests/?query=x&return=y", "tests8", 0, S_OK, "http://www.winehq.org/tests/tests8"},
205 {"http://www.winehq.org/tests/#example", "tests9", 0, S_OK, "http://www.winehq.org/tests/tests9"},
206 {"http://www.winehq.org/tests/../tests/", "/tests10/..", URL_DONT_SIMPLIFY, S_OK, "http://www.winehq.org/tests10/.."},
207 {"http://www.winehq.org/tests/../", "tests11", URL_DONT_SIMPLIFY, S_OK, "http://www.winehq.org/tests/../tests11"},
208 {"file:///C:\\dir\\file.txt", "test.txt", 0, S_OK, "file:///C:/dir/test.txt"},
209 {"C:\\winehq\\winehq.txt", "C:\\Test\\test.txt", 0, S_OK, "file:///C:/Test/test.txt"},
210 {"http://www.winehq.org/test/", "test%20file.txt", 0, S_OK, "http://www.winehq.org/test/test%20file.txt"},
211 {"http://www.winehq.org/test/", "test%20file.txt", URL_FILE_USE_PATHURL, S_OK, "http://www.winehq.org/test/test%20file.txt"},
212 {"http://www.winehq.org%2ftest/", "test%20file.txt", URL_FILE_USE_PATHURL, S_OK, "http://www.winehq.org%2ftest/test%20file.txt"},
213 {"xxx:@MSITStore:file.chm/file.html", "dir/file", 0, S_OK, "xxx:dir/file"},
214 {"mk:@MSITStore:file.chm::/file.html", "/dir/file", 0, S_OK, "mk:@MSITStore:file.chm::/dir/file"},
215 {"mk:@MSITStore:file.chm::/file.html", "mk:@MSITStore:file.chm::/dir/file", 0, S_OK, "mk:@MSITStore:file.chm::/dir/file"},
216 {"foo:today", "foo:calendar", 0, S_OK, "foo:calendar"},
217 {"foo:today", "bar:calendar", 0, S_OK, "bar:calendar"},
218 {"foo:/today", "foo:calendar", 0, S_OK, "foo:/calendar"},
219 {"foo:/today/", "foo:calendar", 0, S_OK, "foo:/today/calendar"},
222 /* ################ */
224 static const struct {
228 } TEST_URLFROMPATH [] = {
229 {"foo", "file:foo", S_OK},
230 {"foo\\bar", "file:foo/bar", S_OK},
231 {"\\foo\\bar", "file:///foo/bar", S_OK},
232 {"c:\\foo\\bar", "file:///c:/foo/bar", S_OK},
233 {"c:foo\\bar", "file:///c:foo/bar", S_OK},
234 {"c:\\foo/b a%r", "file:///c:/foo/b%20a%25r", S_OK},
235 {"c:\\foo\\foo bar", "file:///c:/foo/foo%20bar", S_OK},
237 /* The following test fails on native shlwapi as distributed with Win95/98.
238 * Wine matches the behaviour of later versions.
240 {"xx:c:\\foo\\bar", "xx:c:\\foo\\bar", S_FALSE}
244 /* ################ */
249 } TEST_URL_UNESCAPE[] = {
250 {"file://foo/bar", "file://foo/bar"},
251 {"file://fo%20o%5Ca/bar", "file://fo o\\a/bar"}
254 /* ################ */
256 static const struct {
259 } TEST_PATH_IS_URL[] = {
260 {"http://foo/bar", TRUE},
261 {"c:\\foo\\bar", FALSE},
262 {"foo://foo/bar", TRUE},
265 {"bogusscheme:", TRUE},
266 {"http:partial", TRUE}
269 /* ################ */
271 static const struct {
275 } TEST_URLIS_ATTRIBS[] = {
276 { "ftp:", FALSE, FALSE },
277 { "http:", FALSE, FALSE },
278 { "gopher:", FALSE, FALSE },
279 { "mailto:", TRUE, FALSE },
280 { "news:", FALSE, FALSE },
281 { "nntp:", FALSE, FALSE },
282 { "telnet:", FALSE, FALSE },
283 { "wais:", FALSE, FALSE },
284 { "file:", FALSE, TRUE },
285 { "mk:", FALSE, FALSE },
286 { "https:", FALSE, FALSE },
287 { "shell:", TRUE, FALSE },
288 { "https:", FALSE, FALSE },
289 { "snews:", FALSE, FALSE },
290 { "local:", FALSE, FALSE },
291 { "javascript:", TRUE, FALSE },
292 { "vbscript:", TRUE, FALSE },
293 { "about:", TRUE, FALSE },
294 { "res:", FALSE, FALSE },
295 { "bogusscheme:", FALSE, FALSE },
296 { "file:\\\\e:\\b\\c", FALSE, TRUE },
297 { "file://e:/b/c", FALSE, TRUE },
298 { "http:partial", FALSE, FALSE },
299 { "mailto://www.winehq.org/test.html", TRUE, FALSE },
300 { "file:partial", FALSE, TRUE }
303 /* ########################### */
305 static LPWSTR GetWideString(const char* szString)
307 LPWSTR wszString = HeapAlloc(GetProcessHeap(), 0, (2*INTERNET_MAX_URL_LENGTH) * sizeof(WCHAR));
309 MultiByteToWideChar(0, 0, szString, -1, wszString, INTERNET_MAX_URL_LENGTH);
315 static void FreeWideString(LPWSTR wszString)
317 HeapFree(GetProcessHeap(), 0, wszString);
320 /* ########################### */
322 static void hash_url(const char* szUrl)
324 LPCSTR szTestUrl = szUrl;
325 LPWSTR wszTestUrl = GetWideString(szTestUrl);
327 DWORD cbSize = sizeof(DWORD);
328 DWORD dwHash1, dwHash2;
329 ok(UrlHashA(szTestUrl, (LPBYTE)&dwHash1, cbSize) == S_OK, "UrlHashA didn't return S_OK\n");
330 ok(UrlHashW(wszTestUrl, (LPBYTE)&dwHash2, cbSize) == S_OK, "UrlHashW didn't return S_OK\n");
332 FreeWideString(wszTestUrl);
334 ok(dwHash1 == dwHash2, "Hashes didn't compare\n");
337 static void test_UrlHash(void)
339 hash_url(TEST_URL_1);
340 hash_url(TEST_URL_2);
341 hash_url(TEST_URL_3);
344 /* ########################### */
346 static void test_url_part(const char* szUrl, DWORD dwPart, DWORD dwFlags, const char* szExpected)
348 CHAR szPart[INTERNET_MAX_URL_LENGTH];
349 WCHAR wszPart[INTERNET_MAX_URL_LENGTH];
350 LPWSTR wszUrl = GetWideString(szUrl);
351 LPWSTR wszConvertedPart;
355 dwSize = INTERNET_MAX_URL_LENGTH;
356 ok( UrlGetPartA(szUrl, szPart, &dwSize, dwPart, dwFlags) == S_OK, "UrlGetPartA for \"%s\" part 0x%08x didn't return S_OK but \"%s\"\n", szUrl, dwPart, szPart);
357 dwSize = INTERNET_MAX_URL_LENGTH;
358 ok( UrlGetPartW(wszUrl, wszPart, &dwSize, dwPart, dwFlags) == S_OK, "UrlGetPartW didn't return S_OK\n" );
360 wszConvertedPart = GetWideString(szPart);
362 ok(lstrcmpW(wszPart,wszConvertedPart)==0, "Strings didn't match between ascii and unicode UrlGetPart!\n");
364 FreeWideString(wszUrl);
365 FreeWideString(wszConvertedPart);
367 /* Note that v6.0 and later don't return '?' with the query */
368 ok(strcmp(szPart,szExpected)==0 ||
369 (*szExpected=='?' && !strcmp(szPart,szExpected+1)),
370 "Expected %s, but got %s\n", szExpected, szPart);
373 /* ########################### */
375 static void test_UrlGetPart(void)
377 CHAR szPart[INTERNET_MAX_URL_LENGTH];
381 dwSize = sizeof szPart;
382 szPart[0]='x'; szPart[1]=0;
383 res = UrlGetPartA("hi", szPart, &dwSize, URL_PART_SCHEME, 0);
385 ok (res==S_FALSE, "UrlGetPartA(\"hi\") returned %08X\n", res);
386 ok(szPart[0]==0, "UrlGetPartA(\"hi\") return \"%s\" instead of \"\"\n", szPart);
388 dwSize = sizeof szPart;
389 szPart[0]='x'; szPart[1]=0;
390 res = UrlGetPartA("hi", szPart, &dwSize, URL_PART_QUERY, 0);
392 ok (res==S_FALSE, "UrlGetPartA(\"hi\") returned %08X\n", res);
393 ok(szPart[0]==0, "UrlGetPartA(\"hi\") return \"%s\" instead of \"\"\n", szPart);
396 test_url_part(TEST_URL_3, URL_PART_HOSTNAME, 0, "localhost");
397 test_url_part(TEST_URL_3, URL_PART_PORT, 0, "21");
398 test_url_part(TEST_URL_3, URL_PART_USERNAME, 0, "foo");
399 test_url_part(TEST_URL_3, URL_PART_PASSWORD, 0, "bar");
400 test_url_part(TEST_URL_3, URL_PART_SCHEME, 0, "http");
401 test_url_part(TEST_URL_3, URL_PART_QUERY, 0, "?query=x&return=y");
404 /* ########################### */
406 static void test_url_escape(const char *szUrl, DWORD dwFlags, HRESULT dwExpectReturn, const char *szExpectUrl)
408 CHAR szReturnUrl[INTERNET_MAX_URL_LENGTH];
410 WCHAR ret_urlW[INTERNET_MAX_URL_LENGTH];
411 WCHAR *urlW, *expected_urlW;
412 dwEscaped=INTERNET_MAX_URL_LENGTH;
414 ok(UrlEscapeA(szUrl, szReturnUrl, &dwEscaped, dwFlags) == dwExpectReturn, "UrlEscapeA didn't return 0x%08x from \"%s\"\n", dwExpectReturn, szUrl);
415 ok(strcmp(szReturnUrl,szExpectUrl)==0, "Expected \"%s\", but got \"%s\" from \"%s\"\n", szExpectUrl, szReturnUrl, szUrl);
417 dwEscaped = INTERNET_MAX_URL_LENGTH;
418 urlW = GetWideString(szUrl);
419 expected_urlW = GetWideString(szExpectUrl);
420 ok(UrlEscapeW(urlW, ret_urlW, &dwEscaped, dwFlags) == dwExpectReturn, "UrlEscapeW didn't return 0x%08x from \"%s\"\n", dwExpectReturn, szUrl);
421 WideCharToMultiByte(CP_ACP,0,ret_urlW,-1,szReturnUrl,INTERNET_MAX_URL_LENGTH,0,0);
422 ok(lstrcmpW(ret_urlW, expected_urlW)==0, "Expected \"%s\", but got \"%s\" from \"%s\" flags %08x\n", szExpectUrl, szReturnUrl, szUrl, dwFlags);
423 FreeWideString(urlW);
424 FreeWideString(expected_urlW);
428 static void test_url_canonicalize(const char *szUrl, DWORD dwFlags, HRESULT dwExpectReturn, const char *szExpectUrl)
430 CHAR szReturnUrl[INTERNET_MAX_URL_LENGTH];
431 WCHAR wszReturnUrl[INTERNET_MAX_URL_LENGTH];
432 LPWSTR wszUrl = GetWideString(szUrl);
433 LPWSTR wszExpectUrl = GetWideString(szExpectUrl);
434 LPWSTR wszConvertedUrl;
438 dwSize = INTERNET_MAX_URL_LENGTH;
439 ok(UrlCanonicalizeA(szUrl, NULL, &dwSize, dwFlags) != dwExpectReturn, "Unexpected return for NULL buffer\n");
440 ok(UrlCanonicalizeA(szUrl, szReturnUrl, &dwSize, dwFlags) == dwExpectReturn, "UrlCanonicalizeA didn't return 0x%08x\n", dwExpectReturn);
441 ok(strcmp(szReturnUrl,szExpectUrl)==0, "UrlCanonicalizeA dwFlags 0x%08x Expected \"%s\", but got \"%s\"\n", dwFlags, szExpectUrl, szReturnUrl);
443 dwSize = INTERNET_MAX_URL_LENGTH;
444 ok(UrlCanonicalizeW(wszUrl, NULL, &dwSize, dwFlags) != dwExpectReturn, "Unexpected return for NULL buffer\n");
445 ok(UrlCanonicalizeW(wszUrl, wszReturnUrl, &dwSize, dwFlags) == dwExpectReturn, "UrlCanonicalizeW didn't return 0x%08x\n", dwExpectReturn);
446 wszConvertedUrl = GetWideString(szReturnUrl);
447 ok(lstrcmpW(wszReturnUrl, wszConvertedUrl)==0, "Strings didn't match between ascii and unicode UrlCanonicalize!\n");
448 FreeWideString(wszConvertedUrl);
451 FreeWideString(wszUrl);
452 FreeWideString(wszExpectUrl);
456 static void test_UrlEscape(void)
461 char empty_string[] = "";
463 ret = UrlEscapeA("/woningplan/woonkamer basis.swf", NULL, &size, URL_ESCAPE_SPACES_ONLY);
464 ok(ret == E_INVALIDARG, "got %x, expected %x\n", ret, E_INVALIDARG);
465 ok(size == 0, "got %d, expected %d\n", size, 0);
468 ret = UrlEscapeA("/woningplan/woonkamer basis.swf", empty_string, &size, URL_ESCAPE_SPACES_ONLY);
469 ok(ret == E_INVALIDARG, "got %x, expected %x\n", ret, E_INVALIDARG);
470 ok(size == 0, "got %d, expected %d\n", size, 0);
473 ret = UrlEscapeA("/woningplan/woonkamer basis.swf", NULL, &size, URL_ESCAPE_SPACES_ONLY);
474 ok(ret == E_INVALIDARG, "got %x, expected %x\n", ret, E_INVALIDARG);
475 ok(size == 1, "got %d, expected %d\n", size, 1);
478 ret = UrlEscapeA("/woningplan/woonkamer basis.swf", empty_string, NULL, URL_ESCAPE_SPACES_ONLY);
479 ok(ret == E_INVALIDARG, "got %x, expected %x\n", ret, E_INVALIDARG);
480 ok(size == 1, "got %d, expected %d\n", size, 1);
483 ret = UrlEscapeA("/woningplan/woonkamer basis.swf", empty_string, &size, URL_ESCAPE_SPACES_ONLY);
484 ok(ret == E_POINTER, "got %x, expected %x\n", ret, E_POINTER);
485 ok(size == 34, "got %d, expected %d\n", size, 34);
487 for(i=0; i<sizeof(TEST_ESCAPE)/sizeof(TEST_ESCAPE[0]); i++) {
488 test_url_escape(TEST_ESCAPE[i].url, TEST_ESCAPE[i].flags,
489 TEST_ESCAPE[i].expectret, TEST_ESCAPE[i].expecturl);
493 /* ########################### */
495 static void test_UrlCanonicalizeA(void)
498 CHAR szReturnUrl[INTERNET_MAX_URL_LENGTH];
503 urllen = lstrlenA(winehqA);
505 /* buffer has no space for the result */
507 memset(szReturnUrl, '#', urllen+4);
508 szReturnUrl[urllen+4] = '\0';
509 SetLastError(0xdeadbeef);
510 hr = UrlCanonicalizeA(winehqA, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE);
511 ok( (hr == E_POINTER) && (dwSize == (urllen + 1)),
512 "got 0x%x with %u and size %u for '%s' and %u (expected 'E_POINTER' and size %u)\n",
513 hr, GetLastError(), dwSize, szReturnUrl, lstrlenA(szReturnUrl), urllen+1);
515 /* buffer has no space for the terminating '\0' */
517 memset(szReturnUrl, '#', urllen+4);
518 szReturnUrl[urllen+4] = '\0';
519 SetLastError(0xdeadbeef);
520 hr = UrlCanonicalizeA(winehqA, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE);
521 ok( (hr == E_POINTER) && (dwSize == (urllen + 1)),
522 "got 0x%x with %u and size %u for '%s' and %u (expected 'E_POINTER' and size %u)\n",
523 hr, GetLastError(), dwSize, szReturnUrl, lstrlenA(szReturnUrl), urllen+1);
525 /* buffer has the required size */
527 memset(szReturnUrl, '#', urllen+4);
528 szReturnUrl[urllen+4] = '\0';
529 SetLastError(0xdeadbeef);
530 hr = UrlCanonicalizeA(winehqA, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE);
531 ok( (hr == S_OK) && (dwSize == urllen),
532 "got 0x%x with %u and size %u for '%s' and %u (expected 'S_OK' and size %u)\n",
533 hr, GetLastError(), dwSize, szReturnUrl, lstrlenA(szReturnUrl), urllen);
535 /* buffer is larger as the required size */
537 memset(szReturnUrl, '#', urllen+4);
538 szReturnUrl[urllen+4] = '\0';
539 SetLastError(0xdeadbeef);
540 hr = UrlCanonicalizeA(winehqA, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE);
541 ok( (hr == S_OK) && (dwSize == urllen),
542 "got 0x%x with %u and size %u for '%s' and %u (expected 'S_OK' and size %u)\n",
543 hr, GetLastError(), dwSize, szReturnUrl, lstrlenA(szReturnUrl), urllen);
546 /* test url-modification */
547 for(i=0; i<sizeof(TEST_CANONICALIZE)/sizeof(TEST_CANONICALIZE[0]); i++) {
548 test_url_canonicalize(TEST_CANONICALIZE[i].url, TEST_CANONICALIZE[i].flags,
549 TEST_CANONICALIZE[i].expectret, TEST_CANONICALIZE[i].expecturl);
552 /* move to TEST_CANONICALIZE when fixed */
553 dwSize = sizeof szReturnUrl;
554 /*LimeWire online installer calls this*/
555 hr = UrlCanonicalizeA("/uri-res/N2R?urn:sha1:B3K", szReturnUrl, &dwSize,URL_DONT_ESCAPE_EXTRA_INFO | URL_WININET_COMPATIBILITY /*0x82000000*/);
556 ok(hr==S_OK,"UrlCanonicalizeA returned 0x%08x instead of S_OK\n", hr);
558 ok(strcmp(szReturnUrl,"/uri-res/N2R?urn:sha1:B3K")==0, "UrlCanonicalizeA got \"%s\" instead of \"/uri-res/N2R?urn:sha1:B3K\"\n", szReturnUrl);
563 /* ########################### */
565 static void test_UrlCanonicalizeW(void)
567 WCHAR szReturnUrl[INTERNET_MAX_URL_LENGTH];
573 if (!pUrlCanonicalizeW) {
574 skip("UrlCanonicalizeW\n");
577 urllen = lstrlenW(winehqW);
579 /* buffer has no space for the result */
581 memset(szReturnUrl, '#', (urllen+4) * sizeof(WCHAR));
582 szReturnUrl[urllen+4] = '\0';
583 SetLastError(0xdeadbeef);
584 hr = pUrlCanonicalizeW(winehqW, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE);
585 ok( (hr == E_POINTER) && (dwSize == (urllen + 1)),
586 "got 0x%x with %u and size %u for %u (expected 'E_POINTER' and size %u)\n",
587 hr, GetLastError(), dwSize, lstrlenW(szReturnUrl), urllen+1);
590 /* buffer has no space for the terminating '\0' */
592 memset(szReturnUrl, '#', (urllen+4) * sizeof(WCHAR));
593 szReturnUrl[urllen+4] = '\0';
594 SetLastError(0xdeadbeef);
595 hr = pUrlCanonicalizeW(winehqW, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE);
596 ok( (hr == E_POINTER) && (dwSize == (urllen + 1)),
597 "got 0x%x with %u and size %u for %u (expected 'E_POINTER' and size %u)\n",
598 hr, GetLastError(), dwSize, lstrlenW(szReturnUrl), urllen+1);
600 /* buffer has the required size */
602 memset(szReturnUrl, '#', (urllen+4) * sizeof(WCHAR));
603 szReturnUrl[urllen+4] = '\0';
604 SetLastError(0xdeadbeef);
605 hr = pUrlCanonicalizeW(winehqW, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE);
606 ok( (hr == S_OK) && (dwSize == urllen),
607 "got 0x%x with %u and size %u for %u (expected 'S_OK' and size %u)\n",
608 hr, GetLastError(), dwSize, lstrlenW(szReturnUrl), urllen);
610 /* buffer is larger as the required size */
612 memset(szReturnUrl, '#', (urllen+4) * sizeof(WCHAR));
613 szReturnUrl[urllen+4] = '\0';
614 SetLastError(0xdeadbeef);
615 hr = pUrlCanonicalizeW(winehqW, szReturnUrl, &dwSize, URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE);
616 ok( (hr == S_OK) && (dwSize == urllen),
617 "got 0x%x with %u and size %u for %u (expected 'S_OK' and size %u)\n",
618 hr, GetLastError(), dwSize, lstrlenW(szReturnUrl), urllen);
622 /* ########################### */
624 static void test_url_combine(const char *szUrl1, const char *szUrl2, DWORD dwFlags, HRESULT dwExpectReturn, const char *szExpectUrl)
627 CHAR szReturnUrl[INTERNET_MAX_URL_LENGTH];
628 WCHAR wszReturnUrl[INTERNET_MAX_URL_LENGTH];
629 LPWSTR wszUrl1 = GetWideString(szUrl1);
630 LPWSTR wszUrl2 = GetWideString(szUrl2);
631 LPWSTR wszExpectUrl = GetWideString(szExpectUrl);
632 LPWSTR wszConvertedUrl;
635 DWORD dwExpectLen = lstrlen(szExpectUrl);
637 hr = UrlCombineA(szUrl1, szUrl2, NULL, NULL, dwFlags);
638 ok(hr == E_INVALIDARG, "UrlCombineA returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG);
641 hr = UrlCombineA(szUrl1, szUrl2, NULL, &dwSize, dwFlags);
642 ok(hr == E_POINTER, "Checking length of string, return was 0x%08x, expected 0x%08x\n", hr, E_POINTER);
643 ok(dwSize == dwExpectLen+1, "Got length %d, expected %d\n", dwSize, dwExpectLen+1);
646 hr = UrlCombineA(szUrl1, szUrl2, szReturnUrl, &dwSize, dwFlags);
647 ok(hr == E_POINTER, "UrlCombineA returned 0x%08x, expected 0x%08x\n", hr, E_POINTER);
648 ok(dwSize == dwExpectLen+1, "Got length %d, expected %d\n", dwSize, dwExpectLen+1);
650 hr = UrlCombineA(szUrl1, szUrl2, szReturnUrl, &dwSize, dwFlags);
651 ok(hr == dwExpectReturn, "UrlCombineA returned 0x%08x, expected 0x%08x\n", hr, dwExpectReturn);
652 ok(dwSize == dwExpectLen, "Got length %d, expected %d\n", dwSize, dwExpectLen);
654 ok(strcmp(szReturnUrl,szExpectUrl)==0, "Expected %s, but got %s\n", szExpectUrl, szReturnUrl);
658 hr = UrlCombineW(wszUrl1, wszUrl2, NULL, &dwSize, dwFlags);
659 ok(hr == E_POINTER, "Checking length of string, return was 0x%08x, expected 0x%08x\n", hr, E_POINTER);
660 ok(dwSize == dwExpectLen+1, "Got length %d, expected %d\n", dwSize, dwExpectLen+1);
663 hr = UrlCombineW(wszUrl1, wszUrl2, wszReturnUrl, &dwSize, dwFlags);
664 ok(hr == E_POINTER, "UrlCombineA returned 0x%08x, expected 0x%08x\n", hr, E_POINTER);
665 ok(dwSize == dwExpectLen+1, "Got length %d, expected %d\n", dwSize, dwExpectLen+1);
667 hr = UrlCombineW(wszUrl1, wszUrl2, wszReturnUrl, &dwSize, dwFlags);
668 ok(hr == dwExpectReturn, "UrlCombineW returned 0x%08x, expected 0x%08x\n", hr, dwExpectReturn);
669 ok(dwSize == dwExpectLen, "Got length %d, expected %d\n", dwSize, dwExpectLen);
671 wszConvertedUrl = GetWideString(szReturnUrl);
672 ok(lstrcmpW(wszReturnUrl, wszConvertedUrl)==0, "Strings didn't match between ascii and unicode UrlCombine!\n");
673 FreeWideString(wszConvertedUrl);
676 FreeWideString(wszUrl1);
677 FreeWideString(wszUrl2);
678 FreeWideString(wszExpectUrl);
681 /* ########################### */
683 static void test_UrlCombine(void)
686 for(i=0; i<sizeof(TEST_COMBINE)/sizeof(TEST_COMBINE[0]); i++) {
687 test_url_combine(TEST_COMBINE[i].url1, TEST_COMBINE[i].url2, TEST_COMBINE[i].flags,
688 TEST_COMBINE[i].expectret, TEST_COMBINE[i].expecturl);
692 /* ########################### */
694 static void test_UrlCreateFromPath(void)
697 char ret_url[INTERNET_MAX_URL_LENGTH];
699 WCHAR ret_urlW[INTERNET_MAX_URL_LENGTH];
702 for(i = 0; i < sizeof(TEST_URLFROMPATH) / sizeof(TEST_URLFROMPATH[0]); i++) {
703 len = INTERNET_MAX_URL_LENGTH;
704 ret = UrlCreateFromPathA(TEST_URLFROMPATH[i].path, ret_url, &len, 0);
705 ok(ret == TEST_URLFROMPATH[i].ret, "ret %08x from path %s\n", ret, TEST_URLFROMPATH[i].path);
706 ok(!lstrcmpi(ret_url, TEST_URLFROMPATH[i].url), "url %s from path %s\n", ret_url, TEST_URLFROMPATH[i].path);
707 ok(len == strlen(ret_url), "ret len %d from path %s\n", len, TEST_URLFROMPATH[i].path);
709 len = INTERNET_MAX_URL_LENGTH;
710 pathW = GetWideString(TEST_URLFROMPATH[i].path);
711 urlW = GetWideString(TEST_URLFROMPATH[i].url);
712 ret = UrlCreateFromPathW(pathW, ret_urlW, &len, 0);
713 WideCharToMultiByte(CP_ACP, 0, ret_urlW, -1, ret_url, sizeof(ret_url),0,0);
714 ok(ret == TEST_URLFROMPATH[i].ret, "ret %08x from path L\"%s\", expected %08x\n",
715 ret, TEST_URLFROMPATH[i].path, TEST_URLFROMPATH[i].ret);
716 ok(!lstrcmpiW(ret_urlW, urlW), "got %s expected %s from path L\"%s\"\n", ret_url, TEST_URLFROMPATH[i].url, TEST_URLFROMPATH[i].path);
717 ok(len == lstrlenW(ret_urlW), "ret len %d from path L\"%s\"\n", len, TEST_URLFROMPATH[i].path);
718 FreeWideString(urlW);
719 FreeWideString(pathW);
723 /* ########################### */
725 static void test_UrlIs(void)
731 for(i = 0; i < sizeof(TEST_PATH_IS_URL) / sizeof(TEST_PATH_IS_URL[0]); i++) {
732 MultiByteToWideChar(CP_ACP, 0, TEST_PATH_IS_URL[i].path, -1, wurl, 80);
734 ret = UrlIsA( TEST_PATH_IS_URL[i].path, URLIS_URL );
735 ok( ret == TEST_PATH_IS_URL[i].expect,
736 "returned %d from path %s, expected %d\n", ret, TEST_PATH_IS_URL[i].path,
737 TEST_PATH_IS_URL[i].expect );
739 ret = UrlIsW( wurl, URLIS_URL );
740 ok( ret == TEST_PATH_IS_URL[i].expect,
741 "returned %d from path (UrlIsW) %s, expected %d\n", ret, TEST_PATH_IS_URL[i].path,
742 TEST_PATH_IS_URL[i].expect );
744 for(i = 0; i < sizeof(TEST_URLIS_ATTRIBS) / sizeof(TEST_URLIS_ATTRIBS[0]); i++) {
745 MultiByteToWideChar(CP_ACP, 0, TEST_URLIS_ATTRIBS[i].url, -1, wurl, 80);
747 ret = UrlIsA( TEST_URLIS_ATTRIBS[i].url, URLIS_OPAQUE);
748 ok( ret == TEST_URLIS_ATTRIBS[i].expectOpaque,
749 "returned %d for URLIS_OPAQUE, url \"%s\", expected %d\n", ret, TEST_URLIS_ATTRIBS[i].url,
750 TEST_URLIS_ATTRIBS[i].expectOpaque );
751 ret = UrlIsA( TEST_URLIS_ATTRIBS[i].url, URLIS_FILEURL);
752 ok( ret == TEST_URLIS_ATTRIBS[i].expectFile,
753 "returned %d for URLIS_FILEURL, url \"%s\", expected %d\n", ret, TEST_URLIS_ATTRIBS[i].url,
754 TEST_URLIS_ATTRIBS[i].expectFile );
756 ret = UrlIsW( wurl, URLIS_OPAQUE);
757 ok( ret == TEST_URLIS_ATTRIBS[i].expectOpaque,
758 "returned %d for URLIS_OPAQUE (UrlIsW), url \"%s\", expected %d\n", ret, TEST_URLIS_ATTRIBS[i].url,
759 TEST_URLIS_ATTRIBS[i].expectOpaque );
760 ret = UrlIsW( wurl, URLIS_FILEURL);
761 ok( ret == TEST_URLIS_ATTRIBS[i].expectFile,
762 "returned %d for URLIS_FILEURL (UrlIsW), url \"%s\", expected %d\n", ret, TEST_URLIS_ATTRIBS[i].url,
763 TEST_URLIS_ATTRIBS[i].expectFile );
767 /* ########################### */
769 static void test_UrlUnescape(void)
771 CHAR szReturnUrl[INTERNET_MAX_URL_LENGTH];
772 WCHAR ret_urlW[INTERNET_MAX_URL_LENGTH];
773 WCHAR *urlW, *expected_urlW;
776 static char inplace[] = "file:///C:/Program%20Files";
777 static WCHAR inplaceW[] = {'f','i','l','e',':','/','/','/','C',':','/',
778 'P','r','o','g','r','a','m','%','2','0','F','i','l','e','s',0};
780 for(i=0; i<sizeof(TEST_URL_UNESCAPE)/sizeof(TEST_URL_UNESCAPE[0]); i++) {
781 dwEscaped=INTERNET_MAX_URL_LENGTH;
782 ok(UrlUnescapeA(TEST_URL_UNESCAPE[i].url, szReturnUrl, &dwEscaped, 0) == S_OK, "UrlUnescapeA didn't return 0x%08x from \"%s\"\n", S_OK, TEST_URL_UNESCAPE[i].url);
783 ok(strcmp(szReturnUrl,TEST_URL_UNESCAPE[i].expect)==0, "Expected \"%s\", but got \"%s\" from \"%s\"\n", TEST_URL_UNESCAPE[i].expect, szReturnUrl, TEST_URL_UNESCAPE[i].url);
785 dwEscaped = INTERNET_MAX_URL_LENGTH;
786 urlW = GetWideString(TEST_URL_UNESCAPE[i].url);
787 expected_urlW = GetWideString(TEST_URL_UNESCAPE[i].expect);
788 ok(UrlUnescapeW(urlW, ret_urlW, &dwEscaped, 0) == S_OK, "UrlUnescapeW didn't return 0x%08x from \"%s\"\n", S_OK, TEST_URL_UNESCAPE[i].url);
789 WideCharToMultiByte(CP_ACP,0,ret_urlW,-1,szReturnUrl,INTERNET_MAX_URL_LENGTH,0,0);
790 ok(lstrcmpW(ret_urlW, expected_urlW)==0, "Expected \"%s\", but got \"%s\" from \"%s\" flags %08lx\n", TEST_URL_UNESCAPE[i].expect, szReturnUrl, TEST_URL_UNESCAPE[i].url, 0L);
791 FreeWideString(urlW);
792 FreeWideString(expected_urlW);
795 dwEscaped = sizeof(inplace);
796 ok(UrlUnescapeA(inplace, NULL, &dwEscaped, URL_UNESCAPE_INPLACE) == S_OK, "UrlUnescapeA failed unexpectedly\n");
798 dwEscaped = sizeof(inplaceW);
799 ok(UrlUnescapeW(inplaceW, NULL, &dwEscaped, URL_UNESCAPE_INPLACE) == S_OK, "UrlUnescapeW failed unexpectedly\n");
802 /* ########################### */
807 hShlwapi = GetModuleHandleA("shlwapi.dll");
808 pUrlCanonicalizeW = (void *) GetProcAddress(hShlwapi, "UrlCanonicalizeW");
812 test_UrlCanonicalizeA();
813 test_UrlCanonicalizeW();
816 test_UrlCreateFromPath();