hlink: Use an iface instead of a vtbl pointer in HlinkBCImpl.
[wine] / dlls / urlmon / tests / uri.c
1 /*
2  * UrlMon IUri tests
3  *
4  * Copyright 2010 Thomas Mullaly
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include <wine/test.h>
22 #include <stdarg.h>
23 #include <stddef.h>
24
25 #define COBJMACROS
26 #define CONST_VTABLE
27
28 #include "windef.h"
29 #include "winbase.h"
30 #include "urlmon.h"
31 #include "shlwapi.h"
32 #include "wininet.h"
33 #include "strsafe.h"
34
35 #define URI_STR_PROPERTY_COUNT Uri_PROPERTY_STRING_LAST+1
36 #define URI_DWORD_PROPERTY_COUNT (Uri_PROPERTY_DWORD_LAST - Uri_PROPERTY_DWORD_START)+1
37 #define URI_BUILDER_STR_PROPERTY_COUNT 7
38
39 #define DEFINE_EXPECT(func) \
40     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
41
42 #define SET_EXPECT(func) \
43     expect_ ## func = TRUE
44
45 #define CHECK_EXPECT(func) \
46     do { \
47         ok(expect_ ##func, "unexpected call " #func "\n"); \
48         expect_ ## func = FALSE; \
49         called_ ## func = TRUE; \
50     }while(0)
51
52 #define CHECK_EXPECT2(func) \
53     do { \
54         ok(expect_ ##func, "unexpected call " #func "\n"); \
55         called_ ## func = TRUE; \
56     }while(0)
57
58 #define CHECK_CALLED(func) \
59     do { \
60         ok(called_ ## func, "expected " #func "\n"); \
61         expect_ ## func = called_ ## func = FALSE; \
62     }while(0)
63
64 DEFINE_EXPECT(CombineUrl);
65
66 static HRESULT (WINAPI *pCreateUri)(LPCWSTR, DWORD, DWORD_PTR, IUri**);
67 static HRESULT (WINAPI *pCreateUriWithFragment)(LPCWSTR, LPCWSTR, DWORD, DWORD_PTR, IUri**);
68 static HRESULT (WINAPI *pCreateIUriBuilder)(IUri*, DWORD, DWORD_PTR, IUriBuilder**);
69 static HRESULT (WINAPI *pCoInternetCombineIUri)(IUri*,IUri*,DWORD,IUri**,DWORD_PTR);
70 static HRESULT (WINAPI *pCoInternetGetSession)(DWORD,IInternetSession**,DWORD);
71 static HRESULT (WINAPI *pCoInternetCombineUrlEx)(IUri*,LPCWSTR,DWORD,IUri**,DWORD_PTR);
72 static HRESULT (WINAPI *pCoInternetParseIUri)(IUri*,PARSEACTION,DWORD,LPWSTR,DWORD,DWORD*,DWORD_PTR);
73
74 static const WCHAR http_urlW[] = { 'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
75         '.','o','r','g','/',0};
76 static const WCHAR http_url_fragW[] = { 'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
77         '.','o','r','g','/','#','F','r','a','g',0};
78
79 static const WCHAR combine_baseW[] = {'w','i','n','e','t','e','s','t',':','?','t',
80         'e','s','t','i','n','g',0};
81 static const WCHAR combine_relativeW[] = {'?','t','e','s','t',0};
82 static const WCHAR combine_resultW[] = {'z','i','p',':','t','e','s','t',0};
83
84 static const WCHAR winetestW[] = {'w','i','n','e','t','e','s','t',0};
85
86 typedef struct _uri_create_flag_test {
87     DWORD   flags;
88     HRESULT expected;
89 } uri_create_flag_test;
90
91 static const uri_create_flag_test invalid_flag_tests[] = {
92     /* Set of invalid flag combinations to test for. */
93     {Uri_CREATE_DECODE_EXTRA_INFO | Uri_CREATE_NO_DECODE_EXTRA_INFO, E_INVALIDARG},
94     {Uri_CREATE_CANONICALIZE | Uri_CREATE_NO_CANONICALIZE, E_INVALIDARG},
95     {Uri_CREATE_CRACK_UNKNOWN_SCHEMES | Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES, E_INVALIDARG},
96     {Uri_CREATE_PRE_PROCESS_HTML_URI | Uri_CREATE_NO_PRE_PROCESS_HTML_URI, E_INVALIDARG},
97     {Uri_CREATE_IE_SETTINGS | Uri_CREATE_NO_IE_SETTINGS, E_INVALIDARG}
98 };
99
100 typedef struct _uri_str_property {
101     const char* value;
102     HRESULT     expected;
103     BOOL        todo;
104     const char* broken_value;
105 } uri_str_property;
106
107 typedef struct _uri_dword_property {
108     DWORD   value;
109     HRESULT expected;
110     BOOL    todo;
111 } uri_dword_property;
112
113 typedef struct _uri_properties {
114     const char*         uri;
115     DWORD               create_flags;
116     HRESULT             create_expected;
117     BOOL                create_todo;
118
119     uri_str_property    str_props[URI_STR_PROPERTY_COUNT];
120     uri_dword_property  dword_props[URI_DWORD_PROPERTY_COUNT];
121 } uri_properties;
122
123 static const uri_properties uri_tests[] = {
124     {   "http://www.winehq.org/tests/../tests/../..", 0, S_OK, FALSE,
125         {
126             {"http://www.winehq.org/",S_OK,FALSE},                      /* ABSOLUTE_URI */
127             {"www.winehq.org",S_OK,FALSE},                              /* AUTHORITY */
128             {"http://www.winehq.org/",S_OK,FALSE},                      /* DISPLAY_URI */
129             {"winehq.org",S_OK,FALSE},                                  /* DOMAIN */
130             {"",S_FALSE,FALSE},                                         /* EXTENSION */
131             {"",S_FALSE,FALSE},                                         /* FRAGMENT */
132             {"www.winehq.org",S_OK,FALSE},                              /* HOST */
133             {"",S_FALSE,FALSE},                                         /* PASSWORD */
134             {"/",S_OK,FALSE},                                           /* PATH */
135             {"/",S_OK,FALSE},                                           /* PATH_AND_QUERY */
136             {"",S_FALSE,FALSE},                                         /* QUERY */
137             {"http://www.winehq.org/tests/../tests/../..",S_OK,FALSE},  /* RAW_URI */
138             {"http",S_OK,FALSE},                                        /* SCHEME_NAME */
139             {"",S_FALSE,FALSE},                                         /* USER_INFO */
140             {"",S_FALSE,FALSE}                                          /* USER_NAME */
141         },
142         {
143             {Uri_HOST_DNS,S_OK,FALSE},                                  /* HOST_TYPE */
144             {80,S_OK,FALSE},                                            /* PORT */
145             {URL_SCHEME_HTTP,S_OK,FALSE},                               /* SCHEME */
146             {URLZONE_INVALID,E_NOTIMPL,FALSE}                           /* ZONE */
147         }
148     },
149     {   "http://winehq.org/tests/.././tests", 0, S_OK, FALSE,
150         {
151             {"http://winehq.org/tests",S_OK,FALSE},
152             {"winehq.org",S_OK,FALSE},
153             {"http://winehq.org/tests",S_OK,FALSE},
154             {"winehq.org",S_OK,FALSE},
155             {"",S_FALSE,FALSE},
156             {"",S_FALSE,FALSE},
157             {"winehq.org",S_OK,FALSE},
158             {"",S_FALSE,FALSE},
159             {"/tests",S_OK,FALSE},
160             {"/tests",S_OK,FALSE},
161             {"",S_FALSE,FALSE},
162             {"http://winehq.org/tests/.././tests",S_OK,FALSE},
163             {"http",S_OK,FALSE},
164             {"",S_FALSE,FALSE},
165             {"",S_FALSE,FALSE}
166         },
167         {
168             {Uri_HOST_DNS,S_OK,FALSE},
169             {80,S_OK,FALSE},
170             {URL_SCHEME_HTTP,S_OK,FALSE},
171             {URLZONE_INVALID,E_NOTIMPL,FALSE}
172         }
173     },
174     {   "HtTp://www.winehq.org/tests/..?query=x&return=y", 0, S_OK, FALSE,
175         {
176             {"http://www.winehq.org/?query=x&return=y",S_OK,FALSE},
177             {"www.winehq.org",S_OK,FALSE},
178             {"http://www.winehq.org/?query=x&return=y",S_OK,FALSE},
179             {"winehq.org",S_OK,FALSE},
180             {"",S_FALSE,FALSE},
181             {"",S_FALSE,FALSE},
182             {"www.winehq.org",S_OK,FALSE},
183             {"",S_FALSE,FALSE},
184             {"/",S_OK,FALSE},
185             {"/?query=x&return=y",S_OK,FALSE},
186             {"?query=x&return=y",S_OK,FALSE},
187             {"HtTp://www.winehq.org/tests/..?query=x&return=y",S_OK,FALSE},
188             {"http",S_OK,FALSE},
189             {"",S_FALSE,FALSE},
190             {"",S_FALSE,FALSE}
191         },
192         {
193             {Uri_HOST_DNS,S_OK,FALSE},
194             {80,S_OK,FALSE},
195             {URL_SCHEME_HTTP,S_OK,FALSE},
196             {URLZONE_INVALID,E_NOTIMPL,FALSE},
197         }
198     },
199     {   "hTTp://us%45r%3Ainfo@examp%4CE.com:80/path/a/b/./c/../%2E%2E/Forbidden'<|> Characters", 0, S_OK, FALSE,
200         {
201             {"http://usEr%3Ainfo@example.com/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
202             {"usEr%3Ainfo@example.com",S_OK,FALSE},
203             {"http://example.com/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
204             {"example.com",S_OK,FALSE},
205             {"",S_FALSE,FALSE},
206             {"",S_FALSE,FALSE},
207             {"example.com",S_OK,FALSE},
208             {"",S_FALSE,FALSE},
209             {"/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
210             {"/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
211             {"",S_FALSE,FALSE},
212             {"hTTp://us%45r%3Ainfo@examp%4CE.com:80/path/a/b/./c/../%2E%2E/Forbidden'<|> Characters",S_OK,FALSE},
213             {"http",S_OK,FALSE},
214             {"usEr%3Ainfo",S_OK,FALSE},
215             {"usEr%3Ainfo",S_OK,FALSE}
216         },
217         {
218             {Uri_HOST_DNS,S_OK,FALSE},
219             {80,S_OK,FALSE},
220             {URL_SCHEME_HTTP,S_OK,FALSE},
221             {URLZONE_INVALID,E_NOTIMPL,FALSE},
222         }
223     },
224     {   "ftp://winepass:wine@ftp.winehq.org:9999/dir/foo bar.txt", 0, S_OK, FALSE,
225         {
226             {"ftp://winepass:wine@ftp.winehq.org:9999/dir/foo%20bar.txt",S_OK,FALSE},
227             {"winepass:wine@ftp.winehq.org:9999",S_OK,FALSE},
228             {"ftp://ftp.winehq.org:9999/dir/foo%20bar.txt",S_OK,FALSE},
229             {"winehq.org",S_OK,FALSE},
230             {".txt",S_OK,FALSE},
231             {"",S_FALSE,FALSE},
232             {"ftp.winehq.org",S_OK,FALSE},
233             {"wine",S_OK,FALSE},
234             {"/dir/foo%20bar.txt",S_OK,FALSE},
235             {"/dir/foo%20bar.txt",S_OK,FALSE},
236             {"",S_FALSE,FALSE},
237             {"ftp://winepass:wine@ftp.winehq.org:9999/dir/foo bar.txt",S_OK,FALSE},
238             {"ftp",S_OK,FALSE},
239             {"winepass:wine",S_OK,FALSE},
240             {"winepass",S_OK,FALSE}
241         },
242         {
243             {Uri_HOST_DNS,S_OK,FALSE},
244             {9999,S_OK,FALSE},
245             {URL_SCHEME_FTP,S_OK,FALSE},
246             {URLZONE_INVALID,E_NOTIMPL,FALSE}
247         }
248     },
249     {   "file://c:\\tests\\../tests/foo%20bar.mp3", 0, S_OK, FALSE,
250         {
251             {"file:///c:/tests/foo%2520bar.mp3",S_OK,FALSE},
252             {"",S_FALSE,FALSE},
253             {"file:///c:/tests/foo%2520bar.mp3",S_OK,FALSE},
254             {"",S_FALSE,FALSE},
255             {".mp3",S_OK,FALSE},
256             {"",S_FALSE,FALSE},
257             {"",S_FALSE,FALSE},
258             {"",S_FALSE,FALSE},
259             {"/c:/tests/foo%2520bar.mp3",S_OK,FALSE},
260             {"/c:/tests/foo%2520bar.mp3",S_OK,FALSE},
261             {"",S_FALSE,FALSE},
262             {"file://c:\\tests\\../tests/foo%20bar.mp3",S_OK,FALSE},
263             {"file",S_OK,FALSE},
264             {"",S_FALSE,FALSE},
265             {"",S_FALSE,FALSE}
266         },
267         {
268             {Uri_HOST_UNKNOWN,S_OK,FALSE},
269             {0,S_FALSE,FALSE},
270             {URL_SCHEME_FILE,S_OK,FALSE},
271             {URLZONE_INVALID,E_NOTIMPL,FALSE}
272         }
273     },
274     {   "FILE://localhost/test dir\\../tests/test%20file.README.txt", 0, S_OK, FALSE,
275         {
276             {"file:///tests/test%20file.README.txt",S_OK,FALSE},
277             {"",S_FALSE,FALSE},
278             {"file:///tests/test%20file.README.txt",S_OK,FALSE},
279             {"",S_FALSE,FALSE},
280             {".txt",S_OK,FALSE},
281             {"",S_FALSE,FALSE},
282             {"",S_FALSE,FALSE},
283             {"",S_FALSE,FALSE},
284             {"/tests/test%20file.README.txt",S_OK,FALSE},
285             {"/tests/test%20file.README.txt",S_OK,FALSE},
286             {"",S_FALSE,FALSE},
287             {"FILE://localhost/test dir\\../tests/test%20file.README.txt",S_OK,FALSE},
288             {"file",S_OK,FALSE},
289             {"",S_FALSE,FALSE},
290             {"",S_FALSE,FALSE}
291         },
292         {
293             {Uri_HOST_UNKNOWN,S_OK,FALSE},
294             {0,S_FALSE,FALSE},
295             {URL_SCHEME_FILE,S_OK,FALSE},
296             {URLZONE_INVALID,E_NOTIMPL,FALSE}
297         }
298     },
299     {   "urn:nothing:should:happen here", 0, S_OK, FALSE,
300         {
301             {"urn:nothing:should:happen here",S_OK,FALSE},
302             {"",S_FALSE,FALSE},
303             {"urn:nothing:should:happen here",S_OK,FALSE},
304             {"",S_FALSE,FALSE},
305             {"",S_FALSE,FALSE},
306             {"",S_FALSE,FALSE},
307             {"",S_FALSE,FALSE},
308             {"",S_FALSE,FALSE},
309             {"nothing:should:happen here",S_OK,FALSE},
310             {"nothing:should:happen here",S_OK,FALSE},
311             {"",S_FALSE,FALSE},
312             {"urn:nothing:should:happen here",S_OK,FALSE},
313             {"urn",S_OK,FALSE},
314             {"",S_FALSE,FALSE},
315             {"",S_FALSE,FALSE}
316         },
317         {
318             {Uri_HOST_UNKNOWN,S_OK,FALSE},
319             {0,S_FALSE,FALSE},
320             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
321             {URLZONE_INVALID,E_NOTIMPL,FALSE}
322         }
323     },
324     {   "http://127.0.0.1/tests/../test dir/./test.txt", 0, S_OK, FALSE,
325         {
326             {"http://127.0.0.1/test%20dir/test.txt",S_OK,FALSE},
327             {"127.0.0.1",S_OK,FALSE},
328             {"http://127.0.0.1/test%20dir/test.txt",S_OK,FALSE},
329             {"",S_FALSE,FALSE},
330             {".txt",S_OK,FALSE},
331             {"",S_FALSE,FALSE},
332             {"127.0.0.1",S_OK,FALSE},
333             {"",S_FALSE,FALSE},
334             {"/test%20dir/test.txt",S_OK,FALSE},
335             {"/test%20dir/test.txt",S_OK,FALSE},
336             {"",S_FALSE,FALSE},
337             {"http://127.0.0.1/tests/../test dir/./test.txt",S_OK,FALSE},
338             {"http",S_OK,FALSE},
339             {"",S_FALSE,FALSE},
340             {"",S_FALSE,FALSE}
341         },
342         {
343             {Uri_HOST_IPV4,S_OK,FALSE},
344             {80,S_OK,FALSE},
345             {URL_SCHEME_HTTP,S_OK,FALSE},
346             {URLZONE_INVALID,E_NOTIMPL,FALSE}
347         }
348     },
349     {   "http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]", 0, S_OK, FALSE,
350         {
351             {"http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/",S_OK,FALSE},
352             {"[fedc:ba98:7654:3210:fedc:ba98:7654:3210]",S_OK,FALSE},
353             {"http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/",S_OK,FALSE},
354             {"",S_FALSE,FALSE},
355             {"",S_FALSE,FALSE},
356             {"",S_FALSE,FALSE},
357             {"fedc:ba98:7654:3210:fedc:ba98:7654:3210",S_OK,FALSE},
358             {"",S_FALSE,FALSE},
359             {"/",S_OK,FALSE},
360             {"/",S_OK,FALSE},
361             {"",S_FALSE,FALSE},
362             {"http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]",S_OK,FALSE},
363             {"http",S_OK,FALSE},
364             {"",S_FALSE,FALSE},
365             {"",S_FALSE,FALSE}
366         },
367         {
368             {Uri_HOST_IPV6,S_OK,FALSE},
369             {80,S_OK,FALSE},
370             {URL_SCHEME_HTTP,S_OK,FALSE},
371             {URLZONE_INVALID,E_NOTIMPL,FALSE}
372         }
373     },
374     {   "ftp://[::13.1.68.3]", 0, S_OK, FALSE,
375         {
376             {"ftp://[::13.1.68.3]/",S_OK,FALSE},
377             {"[::13.1.68.3]",S_OK,FALSE},
378             {"ftp://[::13.1.68.3]/",S_OK,FALSE},
379             {"",S_FALSE,FALSE},
380             {"",S_FALSE,FALSE},
381             {"",S_FALSE,FALSE},
382             {"::13.1.68.3",S_OK,FALSE},
383             {"",S_FALSE,FALSE},
384             {"/",S_OK,FALSE},
385             {"/",S_OK,FALSE},
386             {"",S_FALSE,FALSE},
387             {"ftp://[::13.1.68.3]",S_OK,FALSE},
388             {"ftp",S_OK,FALSE},
389             {"",S_FALSE,FALSE},
390             {"",S_FALSE,FALSE}
391         },
392         {
393             {Uri_HOST_IPV6,S_OK,FALSE},
394             {21,S_OK,FALSE},
395             {URL_SCHEME_FTP,S_OK,FALSE},
396             {URLZONE_INVALID,E_NOTIMPL,FALSE}
397         }
398     },
399     {   "http://[FEDC:BA98:0:0:0:0:0:3210]", 0, S_OK, FALSE,
400         {
401             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
402             {"[fedc:ba98::3210]",S_OK,FALSE},
403             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
404             {"",S_FALSE,FALSE},
405             {"",S_FALSE,FALSE},
406             {"",S_FALSE,FALSE},
407             {"fedc:ba98::3210",S_OK,FALSE},
408             {"",S_FALSE,FALSE},
409             {"/",S_OK,FALSE},
410             {"/",S_OK,FALSE},
411             {"",S_FALSE,FALSE},
412             {"http://[FEDC:BA98:0:0:0:0:0:3210]",S_OK,FALSE},
413             {"http",S_OK,FALSE},
414             {"",S_FALSE,FALSE},
415             {"",S_FALSE,FALSE},
416         },
417         {
418             {Uri_HOST_IPV6,S_OK,FALSE},
419             {80,S_OK,FALSE},
420             {URL_SCHEME_HTTP,S_OK,FALSE},
421             {URLZONE_INVALID,E_NOTIMPL,FALSE}
422         }
423     },
424     {   "1234://www.winehq.org", 0, S_OK, FALSE,
425         {
426             {"1234://www.winehq.org/",S_OK,FALSE},
427             {"www.winehq.org",S_OK,FALSE},
428             {"1234://www.winehq.org/",S_OK,FALSE},
429             {"winehq.org",S_OK,FALSE},
430             {"",S_FALSE,FALSE},
431             {"",S_FALSE,FALSE},
432             {"www.winehq.org",S_OK,FALSE},
433             {"",S_FALSE,FALSE},
434             {"/",S_OK,FALSE},
435             {"/",S_OK,FALSE},
436             {"",S_FALSE,FALSE},
437             {"1234://www.winehq.org",S_OK,FALSE},
438             {"1234",S_OK,FALSE},
439             {"",S_FALSE,FALSE},
440             {"",S_FALSE,FALSE}
441         },
442         {
443             {Uri_HOST_DNS,S_OK,FALSE},
444             {0,S_FALSE,FALSE},
445             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
446             {URLZONE_INVALID,E_NOTIMPL,FALSE}
447         }
448     },
449     /* Test's to make sure the parser/canonicalizer handles implicit file schemes correctly. */
450     {   "C:/test/test.mp3", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, S_OK, FALSE,
451         {
452             {"file:///C:/test/test.mp3",S_OK,FALSE},
453             {"",S_FALSE,FALSE},
454             {"file:///C:/test/test.mp3",S_OK,FALSE},
455             {"",S_FALSE,FALSE},
456             {".mp3",S_OK,FALSE},
457             {"",S_FALSE,FALSE},
458             {"",S_FALSE,FALSE},
459             {"",S_FALSE,FALSE},
460             {"/C:/test/test.mp3",S_OK,FALSE},
461             {"/C:/test/test.mp3",S_OK,FALSE},
462             {"",S_FALSE,FALSE},
463             {"C:/test/test.mp3",S_OK,FALSE},
464             {"file",S_OK,FALSE},
465             {"",S_FALSE,FALSE},
466             {"",S_FALSE,FALSE}
467         },
468         {
469             {Uri_HOST_UNKNOWN,S_OK,FALSE},
470             {0,S_FALSE,FALSE},
471             {URL_SCHEME_FILE,S_OK,FALSE},
472             {URLZONE_INVALID,E_NOTIMPL,FALSE}
473         }
474     },
475     /* Test's to make sure the parser/canonicalizer handles implicit file schemes correctly. */
476     {   "\\\\Server/test.mp3", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, S_OK, FALSE,
477         {
478             {"file://server/test.mp3",S_OK,FALSE},
479             {"server",S_OK,FALSE},
480             {"file://server/test.mp3",S_OK,FALSE},
481             {"",S_FALSE,FALSE},
482             {".mp3",S_OK,FALSE},
483             {"",S_FALSE,FALSE},
484             {"server",S_OK,FALSE},
485             {"",S_FALSE,FALSE},
486             {"/test.mp3",S_OK,FALSE},
487             {"/test.mp3",S_OK,FALSE},
488             {"",S_FALSE,FALSE},
489             {"\\\\Server/test.mp3",S_OK,FALSE},
490             {"file",S_OK,FALSE},
491             {"",S_FALSE,FALSE},
492             {"",S_FALSE,FALSE}
493         },
494         {
495             {Uri_HOST_DNS,S_OK,FALSE},
496             {0,S_FALSE,FALSE},
497             {URL_SCHEME_FILE,S_OK,FALSE},
498             {URLZONE_INVALID,E_NOTIMPL,FALSE}
499         }
500     },
501     {   "www.winehq.org/test", Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME, S_OK, FALSE,
502         {
503             {"*:www.winehq.org/test",S_OK,FALSE},
504             {"www.winehq.org",S_OK,FALSE},
505             {"*:www.winehq.org/test",S_OK,FALSE},
506             {"winehq.org",S_OK,FALSE},
507             {"",S_FALSE,FALSE},
508             {"",S_FALSE,FALSE},
509             {"www.winehq.org",S_OK,FALSE},
510             {"",S_FALSE,FALSE},
511             {"/test",S_OK,FALSE},
512             {"/test",S_OK,FALSE},
513             {"",S_FALSE,FALSE},
514             {"www.winehq.org/test",S_OK,FALSE},
515             {"*",S_OK,FALSE},
516             {"",S_FALSE,FALSE},
517             {"",S_FALSE,FALSE}
518         },
519         {
520             {Uri_HOST_DNS,S_OK,FALSE},
521             {0,S_FALSE,FALSE},
522             {URL_SCHEME_WILDCARD,S_OK,FALSE},
523             {URLZONE_INVALID,E_NOTIMPL,FALSE}
524         }
525     },
526     /* Valid since the '*' is the only character in the scheme name. */
527     {   "*:www.winehq.org/test", 0, S_OK, FALSE,
528         {
529             {"*:www.winehq.org/test",S_OK,FALSE},
530             {"www.winehq.org",S_OK,FALSE},
531             {"*:www.winehq.org/test",S_OK,FALSE},
532             {"winehq.org",S_OK,FALSE},
533             {"",S_FALSE,FALSE},
534             {"",S_FALSE,FALSE},
535             {"www.winehq.org",S_OK,FALSE},
536             {"",S_FALSE,FALSE},
537             {"/test",S_OK,FALSE},
538             {"/test",S_OK,FALSE},
539             {"",S_FALSE,FALSE},
540             {"*:www.winehq.org/test",S_OK,FALSE},
541             {"*",S_OK,FALSE},
542             {"",S_FALSE,FALSE},
543             {"",S_FALSE,FALSE}
544         },
545         {
546             {Uri_HOST_DNS,S_OK,FALSE},
547             {0,S_FALSE,FALSE},
548             {URL_SCHEME_WILDCARD,S_OK,FALSE},
549             {URLZONE_INVALID,E_NOTIMPL,FALSE}
550         }
551     },
552     {   "/../some dir/test.ext", Uri_CREATE_ALLOW_RELATIVE, S_OK, FALSE,
553         {
554             {"/../some dir/test.ext",S_OK,FALSE},
555             {"",S_FALSE,FALSE},
556             {"/../some dir/test.ext",S_OK,FALSE},
557             {"",S_FALSE,FALSE},
558             {".ext",S_OK,FALSE},
559             {"",S_FALSE,FALSE},
560             {"",S_FALSE,FALSE},
561             {"",S_FALSE,FALSE},
562             {"/../some dir/test.ext",S_OK,FALSE},
563             {"/../some dir/test.ext",S_OK,FALSE},
564             {"",S_FALSE,FALSE},
565             {"/../some dir/test.ext",S_OK,FALSE},
566             {"",S_FALSE,FALSE},
567             {"",S_FALSE,FALSE},
568             {"",S_FALSE,FALSE}
569         },
570         {
571             {Uri_HOST_UNKNOWN,S_OK,FALSE},
572             {0,S_FALSE,FALSE},
573             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
574             {URLZONE_INVALID,E_NOTIMPL,FALSE}
575         }
576     },
577     {   "//implicit/wildcard/uri scheme", Uri_CREATE_ALLOW_RELATIVE|Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME, S_OK, FALSE,
578         {
579             {"*://implicit/wildcard/uri%20scheme",S_OK,FALSE},
580             {"",S_OK,FALSE},
581             {"*://implicit/wildcard/uri%20scheme",S_OK,FALSE},
582             {"",S_FALSE,FALSE},
583             {"",S_FALSE,FALSE},
584             {"",S_FALSE,FALSE},
585             {"",S_OK,FALSE},
586             {"",S_FALSE,FALSE},
587             {"//implicit/wildcard/uri%20scheme",S_OK,FALSE},
588             {"//implicit/wildcard/uri%20scheme",S_OK,FALSE},
589             {"",S_FALSE,FALSE},
590             {"//implicit/wildcard/uri scheme",S_OK,FALSE},
591             {"*",S_OK,FALSE},
592             {"",S_FALSE,FALSE},
593             {"",S_FALSE,FALSE},
594         },
595         {
596             {Uri_HOST_UNKNOWN,S_OK,FALSE},
597             {0,S_FALSE,FALSE},
598             {URL_SCHEME_WILDCARD,S_OK,FALSE},
599             {URLZONE_INVALID,E_NOTIMPL,FALSE}
600         }
601     },
602     /* URI is considered opaque since CREATE_NO_CRACK_UNKNOWN_SCHEMES is set and its an unknown scheme. */
603     {   "zip://google.com", Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES, S_OK, FALSE,
604         {
605             {"zip:/.//google.com",S_OK,FALSE},
606             {"",S_FALSE,FALSE},
607             {"zip:/.//google.com",S_OK,FALSE},
608             {"",S_FALSE,FALSE},
609             {".com",S_OK,FALSE},
610             {"",S_FALSE,FALSE},
611             {"",S_FALSE,FALSE},
612             {"",S_FALSE,FALSE},
613             {"/.//google.com",S_OK,FALSE},
614             {"/.//google.com",S_OK,FALSE},
615             {"",S_FALSE,FALSE},
616             {"zip://google.com",S_OK,FALSE},
617             {"zip",S_OK,FALSE},
618             {"",S_FALSE,FALSE},
619             {"",S_FALSE,FALSE}
620         },
621         {
622             {Uri_HOST_UNKNOWN,S_OK,FALSE},
623             {0,S_FALSE,FALSE},
624             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
625             {URLZONE_INVALID,E_NOTIMPL,FALSE}
626         }
627     },
628     /* Windows uses the first occurrence of ':' to delimit the userinfo. */
629     {   "ftp://user:pass:word@winehq.org/", 0, S_OK, FALSE,
630         {
631             {"ftp://user:pass:word@winehq.org/",S_OK,FALSE},
632             {"user:pass:word@winehq.org",S_OK,FALSE},
633             {"ftp://winehq.org/",S_OK,FALSE},
634             {"winehq.org",S_OK,FALSE},
635             {"",S_FALSE,FALSE},
636             {"",S_FALSE,FALSE},
637             {"winehq.org",S_OK,FALSE},
638             {"pass:word",S_OK,FALSE},
639             {"/",S_OK,FALSE},
640             {"/",S_OK,FALSE},
641             {"",S_FALSE,FALSE},
642             {"ftp://user:pass:word@winehq.org/",S_OK,FALSE},
643             {"ftp",S_OK,FALSE},
644             {"user:pass:word",S_OK,FALSE},
645             {"user",S_OK,FALSE}
646         },
647         {
648             {Uri_HOST_DNS,S_OK,FALSE},
649             {21,S_OK,FALSE},
650             {URL_SCHEME_FTP,S_OK,FALSE},
651             {URLZONE_INVALID,E_NOTIMPL,FALSE}
652         }
653     },
654     /* Make sure % encoded unreserved characters are decoded. */
655     {   "ftp://w%49%4Ee:PA%53%53@ftp.google.com/", 0, S_OK, FALSE,
656         {
657             {"ftp://wINe:PASS@ftp.google.com/",S_OK,FALSE},
658             {"wINe:PASS@ftp.google.com",S_OK,FALSE},
659             {"ftp://ftp.google.com/",S_OK,FALSE},
660             {"google.com",S_OK,FALSE},
661             {"",S_FALSE,FALSE},
662             {"",S_FALSE,FALSE},
663             {"ftp.google.com",S_OK,FALSE},
664             {"PASS",S_OK,FALSE},
665             {"/",S_OK,FALSE},
666             {"/",S_OK,FALSE},
667             {"",S_FALSE,FALSE},
668             {"ftp://w%49%4Ee:PA%53%53@ftp.google.com/",S_OK,FALSE},
669             {"ftp",S_OK,FALSE},
670             {"wINe:PASS",S_OK,FALSE},
671             {"wINe",S_OK,FALSE}
672         },
673         {
674             {Uri_HOST_DNS,S_OK,FALSE},
675             {21,S_OK,FALSE},
676             {URL_SCHEME_FTP,S_OK,FALSE},
677             {URLZONE_INVALID,E_NOTIMPL,FALSE}
678         }
679     },
680     /* Make sure % encoded characters which are NOT unreserved are NOT decoded. */
681     {   "ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/", 0, S_OK, FALSE,
682         {
683             {"ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/",S_OK,FALSE},
684             {"w%5D%5Be:PA%7B%7D@ftp.google.com",S_OK,FALSE},
685             {"ftp://ftp.google.com/",S_OK,FALSE},
686             {"google.com",S_OK,FALSE},
687             {"",S_FALSE,FALSE},
688             {"",S_FALSE,FALSE},
689             {"ftp.google.com",S_OK,FALSE},
690             {"PA%7B%7D",S_OK,FALSE},
691             {"/",S_OK,FALSE},
692             {"/",S_OK,FALSE},
693             {"",S_FALSE,FALSE},
694             {"ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/",S_OK,FALSE},
695             {"ftp",S_OK,FALSE},
696             {"w%5D%5Be:PA%7B%7D",S_OK,FALSE},
697             {"w%5D%5Be",S_OK,FALSE}
698         },
699         {
700             {Uri_HOST_DNS,S_OK,FALSE},
701             {21,S_OK,FALSE},
702             {URL_SCHEME_FTP,S_OK,FALSE},
703             {URLZONE_INVALID,E_NOTIMPL,FALSE}
704         }
705     },
706     /* You're allowed to have an empty password portion in the userinfo section. */
707     {   "ftp://empty:@ftp.google.com/", 0, S_OK, FALSE,
708         {
709             {"ftp://empty:@ftp.google.com/",S_OK,FALSE},
710             {"empty:@ftp.google.com",S_OK,FALSE},
711             {"ftp://ftp.google.com/",S_OK,FALSE},
712             {"google.com",S_OK,FALSE},
713             {"",S_FALSE,FALSE},
714             {"",S_FALSE,FALSE},
715             {"ftp.google.com",S_OK,FALSE},
716             {"",S_OK,FALSE},
717             {"/",S_OK,FALSE},
718             {"/",S_OK,FALSE},
719             {"",S_FALSE,FALSE},
720             {"ftp://empty:@ftp.google.com/",S_OK,FALSE},
721             {"ftp",S_OK,FALSE},
722             {"empty:",S_OK,FALSE},
723             {"empty",S_OK,FALSE}
724         },
725         {
726             {Uri_HOST_DNS,S_OK,FALSE},
727             {21,S_OK,FALSE},
728             {URL_SCHEME_FTP,S_OK,FALSE},
729             {URLZONE_INVALID,E_NOTIMPL,FALSE}
730         }
731     },
732     /* Make sure forbidden characters in "userinfo" get encoded. */
733     {   "ftp://\" \"weird@ftp.google.com/", 0, S_OK, FALSE,
734         {
735             {"ftp://%22%20%22weird@ftp.google.com/",S_OK,FALSE},
736             {"%22%20%22weird@ftp.google.com",S_OK,FALSE},
737             {"ftp://ftp.google.com/",S_OK,FALSE},
738             {"google.com",S_OK,FALSE},
739             {"",S_FALSE,FALSE},
740             {"",S_FALSE,FALSE},
741             {"ftp.google.com",S_OK,FALSE},
742             {"",S_FALSE,FALSE},
743             {"/",S_OK,FALSE},
744             {"/",S_OK,FALSE},
745             {"",S_FALSE,FALSE},
746             {"ftp://\" \"weird@ftp.google.com/",S_OK,FALSE},
747             {"ftp",S_OK,FALSE},
748             {"%22%20%22weird",S_OK,FALSE},
749             {"%22%20%22weird",S_OK,FALSE}
750         },
751         {
752             {Uri_HOST_DNS,S_OK,FALSE},
753             {21,S_OK,FALSE},
754             {URL_SCHEME_FTP,S_OK,FALSE},
755             {URLZONE_INVALID,E_NOTIMPL,FALSE}
756         }
757     },
758     /* Make sure the forbidden characters don't get percent encoded. */
759     {   "ftp://\" \"weird@ftp.google.com/", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
760         {
761             {"ftp://\" \"weird@ftp.google.com/",S_OK,FALSE},
762             {"\" \"weird@ftp.google.com",S_OK,FALSE},
763             {"ftp://ftp.google.com/",S_OK,FALSE},
764             {"google.com",S_OK,FALSE},
765             {"",S_FALSE,FALSE},
766             {"",S_FALSE,FALSE},
767             {"ftp.google.com",S_OK,FALSE},
768             {"",S_FALSE,FALSE},
769             {"/",S_OK,FALSE},
770             {"/",S_OK,FALSE},
771             {"",S_FALSE,FALSE},
772             {"ftp://\" \"weird@ftp.google.com/",S_OK,FALSE},
773             {"ftp",S_OK,FALSE},
774             {"\" \"weird",S_OK,FALSE},
775             {"\" \"weird",S_OK,FALSE}
776         },
777         {
778             {Uri_HOST_DNS,S_OK,FALSE},
779             {21,S_OK,FALSE},
780             {URL_SCHEME_FTP,S_OK,FALSE},
781             {URLZONE_INVALID,E_NOTIMPL,FALSE}
782         }
783     },
784     /* Allowed to have invalid % encoded because its an unknown scheme type. */
785     {   "zip://%xy:word@winehq.org/", 0, S_OK, FALSE,
786         {
787             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
788             {"%xy:word@winehq.org",S_OK,FALSE},
789             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
790             {"winehq.org",S_OK,FALSE},
791             {"",S_FALSE,FALSE},
792             {"",S_FALSE,FALSE},
793             {"winehq.org",S_OK,FALSE},
794             {"word",S_OK,FALSE},
795             {"/",S_OK,FALSE},
796             {"/",S_OK,FALSE},
797             {"",S_FALSE,FALSE},
798             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
799             {"zip",S_OK,FALSE},
800             {"%xy:word",S_OK,FALSE},
801             {"%xy",S_OK,FALSE}
802         },
803         {
804             {Uri_HOST_DNS,S_OK,FALSE},
805             {0,S_FALSE,FALSE},
806             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
807             {URLZONE_INVALID,E_NOTIMPL,FALSE}
808         }
809     },
810     /* Unreserved, percent encoded characters aren't decoded in the userinfo becuase the scheme
811      * isn't known.
812      */
813     {   "zip://%2E:%52%53ord@winehq.org/", 0, S_OK, FALSE,
814         {
815             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
816             {"%2E:%52%53ord@winehq.org",S_OK,FALSE},
817             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
818             {"winehq.org",S_OK,FALSE},
819             {"",S_FALSE,FALSE},
820             {"",S_FALSE,FALSE},
821             {"winehq.org",S_OK,FALSE},
822             {"%52%53ord",S_OK,FALSE},
823             {"/",S_OK,FALSE},
824             {"/",S_OK,FALSE},
825             {"",S_FALSE,FALSE},
826             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
827             {"zip",S_OK,FALSE},
828             {"%2E:%52%53ord",S_OK,FALSE},
829             {"%2E",S_OK,FALSE}
830         },
831         {
832             {Uri_HOST_DNS,S_OK,FALSE},
833             {0,S_FALSE,FALSE},
834             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
835             {URLZONE_INVALID,E_NOTIMPL,FALSE}
836         }
837     },
838     {   "ftp://[](),'test':word@winehq.org/", 0, S_OK, FALSE,
839         {
840             {"ftp://[](),'test':word@winehq.org/",S_OK,FALSE},
841             {"[](),'test':word@winehq.org",S_OK,FALSE},
842             {"ftp://winehq.org/",S_OK,FALSE},
843             {"winehq.org",S_OK,FALSE},
844             {"",S_FALSE,FALSE},
845             {"",S_FALSE,FALSE},
846             {"winehq.org",S_OK,FALSE},
847             {"word",S_OK,FALSE},
848             {"/",S_OK,FALSE},
849             {"/",S_OK,FALSE},
850             {"",S_FALSE,FALSE},
851             {"ftp://[](),'test':word@winehq.org/",S_OK,FALSE},
852             {"ftp",S_OK,FALSE},
853             {"[](),'test':word",S_OK,FALSE},
854             {"[](),'test'",S_OK,FALSE}
855         },
856         {
857             {Uri_HOST_DNS,S_OK,FALSE},
858             {21,S_OK,FALSE},
859             {URL_SCHEME_FTP,S_OK,FALSE},
860             {URLZONE_INVALID,E_NOTIMPL,FALSE}
861         }
862     },
863     {   "ftp://test?:word@winehq.org/", 0, S_OK, FALSE,
864         {
865             {"ftp://test/?:word@winehq.org/",S_OK,FALSE},
866             {"test",S_OK,FALSE},
867             {"ftp://test/?:word@winehq.org/",S_OK,FALSE},
868             {"",S_FALSE,FALSE},
869             {"",S_FALSE,FALSE},
870             {"",S_FALSE,FALSE},
871             {"test",S_OK,FALSE},
872             {"",S_FALSE,FALSE},
873             {"/",S_OK,FALSE},
874             {"/?:word@winehq.org/",S_OK,FALSE},
875             {"?:word@winehq.org/",S_OK,FALSE},
876             {"ftp://test?:word@winehq.org/",S_OK,FALSE},
877             {"ftp",S_OK,FALSE},
878             {"",S_FALSE,FALSE},
879             {"",S_FALSE,FALSE}
880         },
881         {
882             {Uri_HOST_DNS,S_OK,FALSE},
883             {21,S_OK,FALSE},
884             {URL_SCHEME_FTP,S_OK,FALSE},
885             {URLZONE_INVALID,E_NOTIMPL,FALSE}
886         }
887     },
888     {   "ftp://test#:word@winehq.org/", 0, S_OK, FALSE,
889         {
890             {"ftp://test/#:word@winehq.org/",S_OK,FALSE},
891             {"test",S_OK,FALSE},
892             {"ftp://test/#:word@winehq.org/",S_OK,FALSE},
893             {"",S_FALSE,FALSE},
894             {"",S_FALSE,FALSE},
895             {"#:word@winehq.org/",S_OK,FALSE},
896             {"test",S_OK,FALSE},
897             {"",S_FALSE,FALSE},
898             {"/",S_OK,FALSE},
899             {"/",S_OK,FALSE},
900             {"",S_FALSE,FALSE},
901             {"ftp://test#:word@winehq.org/",S_OK,FALSE},
902             {"ftp",S_OK,FALSE},
903             {"",S_FALSE,FALSE},
904             {"",S_FALSE,FALSE}
905         },
906         {
907             {Uri_HOST_DNS,S_OK,FALSE},
908             {21,S_OK,FALSE},
909             {URL_SCHEME_FTP,S_OK,FALSE},
910             {URLZONE_INVALID,E_NOTIMPL,FALSE}
911         }
912     },
913     /* Allowed to have a backslash in the userinfo since it's an unknown scheme. */
914     {   "zip://test\\:word@winehq.org/", 0, S_OK, FALSE,
915         {
916             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
917             {"test\\:word@winehq.org",S_OK,FALSE},
918             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
919             {"winehq.org",S_OK,FALSE},
920             {"",S_FALSE,FALSE},
921             {"",S_FALSE,FALSE},
922             {"winehq.org",S_OK,FALSE},
923             {"word",S_OK,FALSE},
924             {"/",S_OK,FALSE},
925             {"/",S_OK,FALSE},
926             {"",S_FALSE,FALSE},
927             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
928             {"zip",S_OK,FALSE},
929             {"test\\:word",S_OK,FALSE},
930             {"test\\",S_OK,FALSE}
931         },
932         {
933             {Uri_HOST_DNS,S_OK,FALSE},
934             {0,S_FALSE,FALSE},
935             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
936             {URLZONE_INVALID,E_NOTIMPL,FALSE}
937         }
938     },
939     /* It normalizes IPv4 addresses correctly. */
940     {   "http://127.000.000.100/", 0, S_OK, FALSE,
941         {
942             {"http://127.0.0.100/",S_OK,FALSE},
943             {"127.0.0.100",S_OK,FALSE},
944             {"http://127.0.0.100/",S_OK,FALSE},
945             {"",S_FALSE,FALSE},
946             {"",S_FALSE,FALSE},
947             {"",S_FALSE,FALSE},
948             {"127.0.0.100",S_OK,FALSE},
949             {"",S_FALSE,FALSE},
950             {"/",S_OK,FALSE},
951             {"/",S_OK,FALSE},
952             {"",S_FALSE,FALSE},
953             {"http://127.000.000.100/",S_OK,FALSE},
954             {"http",S_OK,FALSE},
955             {"",S_FALSE,FALSE},
956             {"",S_FALSE,FALSE}
957         },
958         {
959             {Uri_HOST_IPV4,S_OK,FALSE},
960             {80,S_OK,FALSE},
961             {URL_SCHEME_HTTP,S_OK,FALSE},
962             {URLZONE_INVALID,E_NOTIMPL,FALSE}
963         }
964     },
965     /* Make sure it normalizes partial IPv4 addresses correctly. */
966     {   "http://127.0/", 0, S_OK, FALSE,
967         {
968             {"http://127.0.0.0/",S_OK,FALSE},
969             {"127.0.0.0",S_OK,FALSE},
970             {"http://127.0.0.0/",S_OK,FALSE},
971             {"",S_FALSE,FALSE},
972             {"",S_FALSE,FALSE},
973             {"",S_FALSE,FALSE},
974             {"127.0.0.0",S_OK,FALSE},
975             {"",S_FALSE,FALSE},
976             {"/",S_OK,FALSE},
977             {"/",S_OK,FALSE},
978             {"",S_FALSE,FALSE},
979             {"http://127.0/",S_OK,FALSE},
980             {"http",S_OK,FALSE},
981             {"",S_FALSE,FALSE},
982             {"",S_FALSE,FALSE}
983         },
984         {
985             {Uri_HOST_IPV4,S_OK,FALSE},
986             {80,S_OK,FALSE},
987             {URL_SCHEME_HTTP,S_OK,FALSE},
988             {URLZONE_INVALID,E_NOTIMPL,FALSE}
989         }
990     },
991     /* Make sure it converts implicit IPv4's correctly. */
992     {   "http://123456/", 0, S_OK, FALSE,
993         {
994             {"http://0.1.226.64/",S_OK,FALSE},
995             {"0.1.226.64",S_OK,FALSE},
996             {"http://0.1.226.64/",S_OK,FALSE},
997             {"",S_FALSE,FALSE},
998             {"",S_FALSE,FALSE},
999             {"",S_FALSE,FALSE},
1000             {"0.1.226.64",S_OK,FALSE},
1001             {"",S_FALSE,FALSE},
1002             {"/",S_OK,FALSE},
1003             {"/",S_OK,FALSE},
1004             {"",S_FALSE,FALSE},
1005             {"http://123456/",S_OK,FALSE},
1006             {"http",S_OK,FALSE},
1007             {"",S_FALSE,FALSE},
1008             {"",S_FALSE,FALSE}
1009         },
1010         {
1011             {Uri_HOST_IPV4,S_OK,FALSE},
1012             {80,S_OK,FALSE},
1013             {URL_SCHEME_HTTP,S_OK,FALSE},
1014             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1015         }
1016     },
1017     /* UINT_MAX */
1018     {   "http://4294967295/", 0, S_OK, FALSE,
1019         {
1020             {"http://255.255.255.255/",S_OK,FALSE},
1021             {"255.255.255.255",S_OK,FALSE},
1022             {"http://255.255.255.255/",S_OK,FALSE},
1023             {"",S_FALSE,FALSE},
1024             {"",S_FALSE,FALSE},
1025             {"",S_FALSE,FALSE},
1026             {"255.255.255.255",S_OK,FALSE},
1027             {"",S_FALSE,FALSE},
1028             {"/",S_OK,FALSE},
1029             {"/",S_OK,FALSE},
1030             {"",S_FALSE,FALSE},
1031             {"http://4294967295/",S_OK,FALSE},
1032             {"http",S_OK,FALSE},
1033             {"",S_FALSE,FALSE},
1034             {"",S_FALSE,FALSE}
1035         },
1036         {
1037             {Uri_HOST_IPV4,S_OK,FALSE},
1038             {80,S_OK,FALSE},
1039             {URL_SCHEME_HTTP,S_OK,FALSE},
1040             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1041         }
1042     },
1043     /* UINT_MAX+1 */
1044     {   "http://4294967296/", 0, S_OK, FALSE,
1045         {
1046             {"http://4294967296/",S_OK,FALSE},
1047             {"4294967296",S_OK,FALSE},
1048             {"http://4294967296/",S_OK,FALSE},
1049             {"",S_FALSE,FALSE},
1050             {"",S_FALSE,FALSE},
1051             {"",S_FALSE,FALSE},
1052             {"4294967296",S_OK,FALSE},
1053             {"",S_FALSE,FALSE},
1054             {"/",S_OK,FALSE},
1055             {"/",S_OK,FALSE},
1056             {"",S_FALSE,FALSE},
1057             {"http://4294967296/",S_OK,FALSE},
1058             {"http",S_OK,FALSE},
1059             {"",S_FALSE,FALSE},
1060             {"",S_FALSE,FALSE}
1061         },
1062         {
1063             {Uri_HOST_DNS,S_OK,FALSE},
1064             {80,S_OK,FALSE},
1065             {URL_SCHEME_HTTP,S_OK,FALSE},
1066             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1067         }
1068     },
1069     /* Window's doesn't normalize IP address for unknown schemes. */
1070     {   "1234://4294967295/", 0, S_OK, FALSE,
1071         {
1072             {"1234://4294967295/",S_OK,FALSE},
1073             {"4294967295",S_OK,FALSE},
1074             {"1234://4294967295/",S_OK,FALSE},
1075             {"",S_FALSE,FALSE},
1076             {"",S_FALSE,FALSE},
1077             {"",S_FALSE,FALSE},
1078             {"4294967295",S_OK,FALSE},
1079             {"",S_FALSE,FALSE},
1080             {"/",S_OK,FALSE},
1081             {"/",S_OK,FALSE},
1082             {"",S_FALSE,FALSE},
1083             {"1234://4294967295/",S_OK,FALSE},
1084             {"1234",S_OK,FALSE},
1085             {"",S_FALSE,FALSE},
1086             {"",S_FALSE,FALSE}
1087         },
1088         {
1089             {Uri_HOST_IPV4,S_OK,FALSE},
1090             {0,S_FALSE,FALSE},
1091             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1092             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1093         }
1094     },
1095     /* Window's doesn't normalize IP address for unknown schemes. */
1096     {   "1234://127.001/", 0, S_OK, FALSE,
1097         {
1098             {"1234://127.001/",S_OK,FALSE},
1099             {"127.001",S_OK,FALSE},
1100             {"1234://127.001/",S_OK,FALSE},
1101             {"",S_FALSE,FALSE},
1102             {"",S_FALSE,FALSE},
1103             {"",S_FALSE,FALSE},
1104             {"127.001",S_OK,FALSE},
1105             {"",S_FALSE,FALSE},
1106             {"/",S_OK,FALSE},
1107             {"/",S_OK,FALSE},
1108             {"",S_FALSE,FALSE},
1109             {"1234://127.001/",S_OK,FALSE},
1110             {"1234",S_OK,FALSE},
1111             {"",S_FALSE,FALSE},
1112             {"",S_FALSE,FALSE}
1113         },
1114         {
1115             {Uri_HOST_IPV4,S_OK,FALSE},
1116             {0,S_FALSE,FALSE},
1117             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1118             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1119         }
1120     },
1121     {   "http://[FEDC:BA98::3210]", 0, S_OK, FALSE,
1122         {
1123             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
1124             {"[fedc:ba98::3210]",S_OK,FALSE},
1125             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
1126             {"",S_FALSE,FALSE},
1127             {"",S_FALSE,FALSE},
1128             {"",S_FALSE,FALSE},
1129             {"fedc:ba98::3210",S_OK,FALSE},
1130             {"",S_FALSE,FALSE},
1131             {"/",S_OK,FALSE},
1132             {"/",S_OK,FALSE},
1133             {"",S_FALSE,FALSE},
1134             {"http://[FEDC:BA98::3210]",S_OK,FALSE},
1135             {"http",S_OK,FALSE},
1136             {"",S_FALSE,FALSE},
1137             {"",S_FALSE,FALSE},
1138         },
1139         {
1140             {Uri_HOST_IPV6,S_OK,FALSE},
1141             {80,S_OK,FALSE},
1142             {URL_SCHEME_HTTP,S_OK,FALSE},
1143             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1144         }
1145     },
1146     {   "http://[::]", 0, S_OK, FALSE,
1147         {
1148             {"http://[::]/",S_OK,FALSE},
1149             {"[::]",S_OK,FALSE},
1150             {"http://[::]/",S_OK,FALSE},
1151             {"",S_FALSE,FALSE},
1152             {"",S_FALSE,FALSE},
1153             {"",S_FALSE,FALSE},
1154             {"::",S_OK,FALSE},
1155             {"",S_FALSE,FALSE},
1156             {"/",S_OK,FALSE},
1157             {"/",S_OK,FALSE},
1158             {"",S_FALSE,FALSE},
1159             {"http://[::]",S_OK,FALSE},
1160             {"http",S_OK,FALSE},
1161             {"",S_FALSE,FALSE},
1162             {"",S_FALSE,FALSE},
1163         },
1164         {
1165             {Uri_HOST_IPV6,S_OK,FALSE},
1166             {80,S_OK,FALSE},
1167             {URL_SCHEME_HTTP,S_OK,FALSE},
1168             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1169         }
1170     },
1171     {   "http://[FEDC:BA98::]", 0, S_OK, FALSE,
1172         {
1173             {"http://[fedc:ba98::]/",S_OK,FALSE},
1174             {"[fedc:ba98::]",S_OK,FALSE},
1175             {"http://[fedc:ba98::]/",S_OK,FALSE},
1176             {"",S_FALSE,FALSE},
1177             {"",S_FALSE,FALSE},
1178             {"",S_FALSE,FALSE},
1179             {"fedc:ba98::",S_OK,FALSE},
1180             {"",S_FALSE,FALSE},
1181             {"/",S_OK,FALSE},
1182             {"/",S_OK,FALSE},
1183             {"",S_FALSE,FALSE},
1184             {"http://[FEDC:BA98::]",S_OK,FALSE},
1185             {"http",S_OK,FALSE},
1186             {"",S_FALSE,FALSE},
1187             {"",S_FALSE,FALSE},
1188         },
1189         {
1190             {Uri_HOST_IPV6,S_OK,FALSE},
1191             {80,S_OK,FALSE},
1192             {URL_SCHEME_HTTP,S_OK,FALSE},
1193             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1194         }
1195     },
1196     /* Valid even with 2 byte elision because it doesn't appear the beginning or end. */
1197     {   "http://[1::3:4:5:6:7:8]", 0, S_OK, FALSE,
1198         {
1199             {"http://[1:0:3:4:5:6:7:8]/",S_OK,FALSE},
1200             {"[1:0:3:4:5:6:7:8]",S_OK,FALSE},
1201             {"http://[1:0:3:4:5:6:7:8]/",S_OK,FALSE},
1202             {"",S_FALSE,FALSE},
1203             {"",S_FALSE,FALSE},
1204             {"",S_FALSE,FALSE},
1205             {"1:0:3:4:5:6:7:8",S_OK,FALSE},
1206             {"",S_FALSE,FALSE},
1207             {"/",S_OK,FALSE},
1208             {"/",S_OK,FALSE},
1209             {"",S_FALSE,FALSE},
1210             {"http://[1::3:4:5:6:7:8]",S_OK,FALSE},
1211             {"http",S_OK,FALSE},
1212             {"",S_FALSE,FALSE},
1213             {"",S_FALSE,FALSE},
1214         },
1215         {
1216             {Uri_HOST_IPV6,S_OK,FALSE},
1217             {80,S_OK,FALSE},
1218             {URL_SCHEME_HTTP,S_OK,FALSE},
1219             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1220         }
1221     },
1222     {   "http://[v2.34]/", 0, S_OK, FALSE,
1223         {
1224             {"http://[v2.34]/",S_OK,FALSE},
1225             {"[v2.34]",S_OK,FALSE},
1226             {"http://[v2.34]/",S_OK,FALSE},
1227             {"",S_FALSE,FALSE},
1228             {"",S_FALSE,FALSE},
1229             {"",S_FALSE,FALSE},
1230             {"[v2.34]",S_OK,FALSE},
1231             {"",S_FALSE,FALSE},
1232             {"/",S_OK,FALSE},
1233             {"/",S_OK,FALSE},
1234             {"",S_FALSE,FALSE},
1235             {"http://[v2.34]/",S_OK,FALSE},
1236             {"http",S_OK,FALSE},
1237             {"",S_FALSE,FALSE},
1238             {"",S_FALSE,FALSE}
1239         },
1240         {
1241             {Uri_HOST_UNKNOWN,S_OK,FALSE},
1242             {80,S_OK,FALSE},
1243             {URL_SCHEME_HTTP,S_OK,FALSE},
1244             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1245         }
1246     },
1247     /* Windows ignores ':' if they appear after a '[' on a non-IPLiteral host. */
1248     {   "http://[xyz:12345.com/test", 0, S_OK, FALSE,
1249         {
1250             {"http://[xyz:12345.com/test",S_OK,FALSE},
1251             {"[xyz:12345.com",S_OK,FALSE},
1252             {"http://[xyz:12345.com/test",S_OK,FALSE},
1253             {"[xyz:12345.com",S_OK,FALSE},
1254             {"",S_FALSE,FALSE},
1255             {"",S_FALSE,FALSE},
1256             {"[xyz:12345.com",S_OK,FALSE},
1257             {"",S_FALSE,FALSE},
1258             {"/test",S_OK,FALSE},
1259             {"/test",S_OK,FALSE},
1260             {"",S_FALSE,FALSE},
1261             {"http://[xyz:12345.com/test",S_OK,FALSE},
1262             {"http",S_OK,FALSE},
1263             {"",S_FALSE,FALSE},
1264             {"",S_FALSE,FALSE}
1265         },
1266         {
1267             {Uri_HOST_DNS,S_OK,FALSE},
1268             {80,S_OK,FALSE},
1269             {URL_SCHEME_HTTP,S_OK,FALSE},
1270             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1271         }
1272     },
1273     /* Valid URI since the '[' and ']' don't appear at the beginning and end
1274      * of the host name (respectively).
1275      */
1276     {   "ftp://www.[works].com/", 0, S_OK, FALSE,
1277         {
1278             {"ftp://www.[works].com/",S_OK,FALSE},
1279             {"www.[works].com",S_OK,FALSE},
1280             {"ftp://www.[works].com/",S_OK,FALSE},
1281             {"[works].com",S_OK,FALSE},
1282             {"",S_FALSE,FALSE},
1283             {"",S_FALSE,FALSE},
1284             {"www.[works].com",S_OK,FALSE},
1285             {"",S_FALSE,FALSE},
1286             {"/",S_OK,FALSE},
1287             {"/",S_OK,FALSE},
1288             {"",S_FALSE,FALSE},
1289             {"ftp://www.[works].com/",S_OK,FALSE},
1290             {"ftp",S_OK,FALSE},
1291             {"",S_FALSE,FALSE},
1292             {"",S_FALSE,FALSE}
1293         },
1294         {
1295             {Uri_HOST_DNS,S_OK,FALSE},
1296             {21,S_OK,FALSE},
1297             {URL_SCHEME_FTP,S_OK,FALSE},
1298             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1299         }
1300     },
1301     /* Considers ':' a delimiter since it appears after the ']'. */
1302     {   "http://www.google.com]:12345/", 0, S_OK, FALSE,
1303         {
1304             {"http://www.google.com]:12345/",S_OK,FALSE},
1305             {"www.google.com]:12345",S_OK,FALSE},
1306             {"http://www.google.com]:12345/",S_OK,FALSE},
1307             {"google.com]",S_OK,FALSE},
1308             {"",S_FALSE,FALSE},
1309             {"",S_FALSE,FALSE},
1310             {"www.google.com]",S_OK,FALSE},
1311             {"",S_FALSE,FALSE},
1312             {"/",S_OK,FALSE},
1313             {"/",S_OK,FALSE},
1314             {"",S_FALSE,FALSE},
1315             {"http://www.google.com]:12345/",S_OK,FALSE},
1316             {"http",S_OK,FALSE},
1317             {"",S_FALSE,FALSE},
1318             {"",S_FALSE,FALSE}
1319         },
1320         {
1321             {Uri_HOST_DNS,S_OK,FALSE},
1322             {12345,S_OK,FALSE},
1323             {URL_SCHEME_HTTP,S_OK,FALSE},
1324             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1325         }
1326     },
1327     /* Unknown scheme types can have invalid % encoded data in the hostname. */
1328     {   "zip://w%XXw%GEw.google.com/", 0, S_OK, FALSE,
1329         {
1330             {"zip://w%XXw%GEw.google.com/",S_OK,FALSE},
1331             {"w%XXw%GEw.google.com",S_OK,FALSE},
1332             {"zip://w%XXw%GEw.google.com/",S_OK,FALSE},
1333             {"google.com",S_OK,FALSE},
1334             {"",S_FALSE,FALSE},
1335             {"",S_FALSE,FALSE},
1336             {"w%XXw%GEw.google.com",S_OK,FALSE},
1337             {"",S_FALSE,FALSE},
1338             {"/",S_OK,FALSE},
1339             {"/",S_OK,FALSE},
1340             {"",S_FALSE,FALSE},
1341             {"zip://w%XXw%GEw.google.com/",S_OK,FALSE},
1342             {"zip",S_OK,FALSE},
1343             {"",S_FALSE,FALSE},
1344             {"",S_FALSE,FALSE}
1345         },
1346         {
1347             {Uri_HOST_DNS,S_OK,FALSE},
1348             {0,S_FALSE,FALSE},
1349             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1350             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1351         }
1352     },
1353     /* Unknown scheme types hostname doesn't get lower cased. */
1354     {   "zip://GOOGLE.com/", 0, S_OK, FALSE,
1355         {
1356             {"zip://GOOGLE.com/",S_OK,FALSE},
1357             {"GOOGLE.com",S_OK,FALSE},
1358             {"zip://GOOGLE.com/",S_OK,FALSE},
1359             {"GOOGLE.com",S_OK,FALSE},
1360             {"",S_FALSE,FALSE},
1361             {"",S_FALSE,FALSE},
1362             {"GOOGLE.com",S_OK,FALSE},
1363             {"",S_FALSE,FALSE},
1364             {"/",S_OK,FALSE},
1365             {"/",S_OK,FALSE},
1366             {"",S_FALSE,FALSE},
1367             {"zip://GOOGLE.com/",S_OK,FALSE},
1368             {"zip",S_OK,FALSE},
1369             {"",S_FALSE,FALSE},
1370             {"",S_FALSE,FALSE}
1371         },
1372         {
1373             {Uri_HOST_DNS,S_OK,FALSE},
1374             {0,S_FALSE,FALSE},
1375             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1376             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1377         }
1378     },
1379     /* Hostname get's lower cased for known scheme types. */
1380     {   "http://WWW.GOOGLE.com/", 0, S_OK, FALSE,
1381         {
1382             {"http://www.google.com/",S_OK,FALSE},
1383             {"www.google.com",S_OK,FALSE},
1384             {"http://www.google.com/",S_OK,FALSE},
1385             {"google.com",S_OK,FALSE},
1386             {"",S_FALSE,FALSE},
1387             {"",S_FALSE,FALSE},
1388             {"www.google.com",S_OK,FALSE},
1389             {"",S_FALSE,FALSE},
1390             {"/",S_OK,FALSE},
1391             {"/",S_OK,FALSE},
1392             {"",S_FALSE,FALSE},
1393             {"http://WWW.GOOGLE.com/",S_OK,FALSE},
1394             {"http",S_OK,FALSE},
1395             {"",S_FALSE,FALSE},
1396             {"",S_FALSE,FALSE}
1397         },
1398         {
1399             {Uri_HOST_DNS,S_OK,FALSE},
1400             {80,S_OK,FALSE},
1401             {URL_SCHEME_HTTP,S_OK,FALSE},
1402             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1403         }
1404     },
1405     /* Characters that get % encoded in the hostname also have their percent
1406      * encoded forms lower cased.
1407      */
1408     {   "http://www.%7Cgoogle|.com/", 0, S_OK, FALSE,
1409         {
1410             {"http://www.%7cgoogle%7c.com/",S_OK,FALSE},
1411             {"www.%7cgoogle%7c.com",S_OK,FALSE},
1412             {"http://www.%7cgoogle%7c.com/",S_OK,FALSE},
1413             {"%7cgoogle%7c.com",S_OK,FALSE},
1414             {"",S_FALSE,FALSE},
1415             {"",S_FALSE,FALSE},
1416             {"www.%7cgoogle%7c.com",S_OK,FALSE},
1417             {"",S_FALSE,FALSE},
1418             {"/",S_OK,FALSE},
1419             {"/",S_OK,FALSE},
1420             {"",S_FALSE,FALSE},
1421             {"http://www.%7Cgoogle|.com/",S_OK,FALSE},
1422             {"http",S_OK,FALSE},
1423             {"",S_FALSE,FALSE},
1424             {"",S_FALSE,FALSE}
1425         },
1426         {
1427             {Uri_HOST_DNS,S_OK,FALSE},
1428             {80,S_OK,FALSE},
1429             {URL_SCHEME_HTTP,S_OK,FALSE},
1430             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1431         }
1432     },
1433     /* IPv4 addresses attached to IPv6 can be included in elisions. */
1434     {   "http://[1:2:3:4:5:6:0.0.0.0]", 0, S_OK, FALSE,
1435         {
1436             {"http://[1:2:3:4:5:6::]/",S_OK,FALSE},
1437             {"[1:2:3:4:5:6::]",S_OK,FALSE},
1438             {"http://[1:2:3:4:5:6::]/",S_OK,FALSE},
1439             {"",S_FALSE,FALSE},
1440             {"",S_FALSE,FALSE},
1441             {"",S_FALSE,FALSE},
1442             {"1:2:3:4:5:6::",S_OK,FALSE},
1443             {"",S_FALSE,FALSE},
1444             {"/",S_OK,FALSE},
1445             {"/",S_OK,FALSE},
1446             {"",S_FALSE,FALSE},
1447             {"http://[1:2:3:4:5:6:0.0.0.0]",S_OK,FALSE},
1448             {"http",S_OK,FALSE},
1449             {"",S_FALSE,FALSE},
1450             {"",S_FALSE,FALSE},
1451         },
1452         {
1453             {Uri_HOST_IPV6,S_OK,FALSE},
1454             {80,S_OK,FALSE},
1455             {URL_SCHEME_HTTP,S_OK,FALSE},
1456             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1457         }
1458     },
1459     /* IPv4 addresses get normalized. */
1460     {   "http://[::001.002.003.000]", 0, S_OK, FALSE,
1461         {
1462             {"http://[::1.2.3.0]/",S_OK,FALSE},
1463             {"[::1.2.3.0]",S_OK,FALSE},
1464             {"http://[::1.2.3.0]/",S_OK,FALSE},
1465             {"",S_FALSE,FALSE},
1466             {"",S_FALSE,FALSE},
1467             {"",S_FALSE,FALSE},
1468             {"::1.2.3.0",S_OK,FALSE},
1469             {"",S_FALSE,FALSE},
1470             {"/",S_OK,FALSE},
1471             {"/",S_OK,FALSE},
1472             {"",S_FALSE,FALSE},
1473             {"http://[::001.002.003.000]",S_OK,FALSE},
1474             {"http",S_OK,FALSE},
1475             {"",S_FALSE,FALSE},
1476             {"",S_FALSE,FALSE},
1477         },
1478         {
1479             {Uri_HOST_IPV6,S_OK,FALSE},
1480             {80,S_OK,FALSE},
1481             {URL_SCHEME_HTTP,S_OK,FALSE},
1482             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1483         }
1484     },
1485     /* Windows doesn't do anything to IPv6's in unknown schemes. */
1486     {   "zip://[0001:0:000:0004:0005:0006:001.002.003.000]", 0, S_OK, FALSE,
1487         {
1488             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]/",S_OK,FALSE},
1489             {"[0001:0:000:0004:0005:0006:001.002.003.000]",S_OK,FALSE},
1490             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]/",S_OK,FALSE},
1491             {"",S_FALSE,FALSE},
1492             {"",S_FALSE,FALSE},
1493             {"",S_FALSE,FALSE},
1494             {"0001:0:000:0004:0005:0006:001.002.003.000",S_OK,FALSE},
1495             {"",S_FALSE,FALSE},
1496             {"/",S_OK,FALSE},
1497             {"/",S_OK,FALSE},
1498             {"",S_FALSE,FALSE},
1499             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]",S_OK,FALSE},
1500             {"zip",S_OK,FALSE},
1501             {"",S_FALSE,FALSE},
1502             {"",S_FALSE,FALSE},
1503         },
1504         {
1505             {Uri_HOST_IPV6,S_OK,FALSE},
1506             {0,S_FALSE,FALSE},
1507             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1508             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1509         }
1510     },
1511     /* IPv4 address is converted into 2 h16 components. */
1512     {   "http://[ffff::192.222.111.32]", 0, S_OK, FALSE,
1513         {
1514             {"http://[ffff::c0de:6f20]/",S_OK,FALSE},
1515             {"[ffff::c0de:6f20]",S_OK,FALSE},
1516             {"http://[ffff::c0de:6f20]/",S_OK,FALSE},
1517             {"",S_FALSE,FALSE},
1518             {"",S_FALSE,FALSE},
1519             {"",S_FALSE,FALSE},
1520             {"ffff::c0de:6f20",S_OK,FALSE},
1521             {"",S_FALSE,FALSE},
1522             {"/",S_OK,FALSE},
1523             {"/",S_OK,FALSE},
1524             {"",S_FALSE,FALSE},
1525             {"http://[ffff::192.222.111.32]",S_OK,FALSE},
1526             {"http",S_OK,FALSE},
1527             {"",S_FALSE,FALSE},
1528             {"",S_FALSE,FALSE},
1529         },
1530         {
1531             {Uri_HOST_IPV6,S_OK,FALSE},
1532             {80,S_OK,FALSE},
1533             {URL_SCHEME_HTTP,S_OK,FALSE},
1534             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1535         }
1536     },
1537     /* Max value for a port. */
1538     {   "http://google.com:65535", 0, S_OK, FALSE,
1539         {
1540             {"http://google.com:65535/",S_OK,FALSE},
1541             {"google.com:65535",S_OK,FALSE},
1542             {"http://google.com:65535/",S_OK,FALSE},
1543             {"google.com",S_OK,FALSE},
1544             {"",S_FALSE,FALSE},
1545             {"",S_FALSE,FALSE},
1546             {"google.com",S_OK,FALSE},
1547             {"",S_FALSE,FALSE},
1548             {"/",S_OK,FALSE},
1549             {"/",S_OK,FALSE},
1550             {"",S_FALSE,FALSE},
1551             {"http://google.com:65535",S_OK,FALSE},
1552             {"http",S_OK,FALSE},
1553             {"",S_FALSE,FALSE},
1554             {"",S_FALSE,FALSE}
1555         },
1556         {
1557             {Uri_HOST_DNS,S_OK,FALSE},
1558             {65535,S_OK,FALSE},
1559             {URL_SCHEME_HTTP,S_OK,FALSE},
1560             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1561         }
1562     },
1563     {   "zip://google.com:65536", 0, S_OK, FALSE,
1564         {
1565             {"zip://google.com:65536/",S_OK,FALSE},
1566             {"google.com:65536",S_OK,FALSE},
1567             {"zip://google.com:65536/",S_OK,FALSE},
1568             {"google.com:65536",S_OK,FALSE},
1569             {"",S_FALSE,FALSE},
1570             {"",S_FALSE,FALSE},
1571             {"google.com:65536",S_OK,FALSE},
1572             {"",S_FALSE,FALSE},
1573             {"/",S_OK,FALSE},
1574             {"/",S_OK,FALSE},
1575             {"",S_FALSE,FALSE},
1576             {"zip://google.com:65536",S_OK,FALSE},
1577             {"zip",S_OK,FALSE},
1578             {"",S_FALSE,FALSE},
1579             {"",S_FALSE,FALSE}
1580         },
1581         {
1582             {Uri_HOST_DNS,S_OK,FALSE},
1583             {0,S_FALSE,FALSE},
1584             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1585             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1586         }
1587     },
1588     {   "zip://google.com:65536:25", 0, S_OK, FALSE,
1589         {
1590             {"zip://google.com:65536:25/",S_OK,FALSE},
1591             {"google.com:65536:25",S_OK,FALSE},
1592             {"zip://google.com:65536:25/",S_OK,FALSE},
1593             {"google.com:65536:25",S_OK,FALSE},
1594             {"",S_FALSE,FALSE},
1595             {"",S_FALSE,FALSE},
1596             {"google.com:65536:25",S_OK,FALSE},
1597             {"",S_FALSE,FALSE},
1598             {"/",S_OK,FALSE},
1599             {"/",S_OK,FALSE},
1600             {"",S_FALSE,FALSE},
1601             {"zip://google.com:65536:25",S_OK,FALSE},
1602             {"zip",S_OK,FALSE},
1603             {"",S_FALSE,FALSE},
1604             {"",S_FALSE,FALSE}
1605         },
1606         {
1607             {Uri_HOST_DNS,S_OK,FALSE},
1608             {0,S_FALSE,FALSE},
1609             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1610             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1611         }
1612     },
1613     {   "zip://[::ffff]:abcd", 0, S_OK, FALSE,
1614         {
1615             {"zip://[::ffff]:abcd/",S_OK,FALSE},
1616             {"[::ffff]:abcd",S_OK,FALSE},
1617             {"zip://[::ffff]:abcd/",S_OK,FALSE},
1618             {"",S_FALSE,FALSE},
1619             {"",S_FALSE,FALSE},
1620             {"",S_FALSE,FALSE},
1621             {"[::ffff]:abcd",S_OK,FALSE},
1622             {"",S_FALSE,FALSE},
1623             {"/",S_OK,FALSE},
1624             {"/",S_OK,FALSE},
1625             {"",S_FALSE,FALSE},
1626             {"zip://[::ffff]:abcd",S_OK,FALSE},
1627             {"zip",S_OK,FALSE},
1628             {"",S_FALSE,FALSE},
1629             {"",S_FALSE,FALSE}
1630         },
1631         {
1632             {Uri_HOST_DNS,S_OK,FALSE},
1633             {0,S_FALSE,FALSE},
1634             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1635             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1636         }
1637     },
1638     {   "zip://127.0.0.1:abcd", 0, S_OK, FALSE,
1639         {
1640             {"zip://127.0.0.1:abcd/",S_OK,FALSE},
1641             {"127.0.0.1:abcd",S_OK,FALSE},
1642             {"zip://127.0.0.1:abcd/",S_OK,FALSE},
1643             {"0.1:abcd",S_OK,FALSE},
1644             {"",S_FALSE,FALSE},
1645             {"",S_FALSE,FALSE},
1646             {"127.0.0.1:abcd",S_OK,FALSE},
1647             {"",S_FALSE,FALSE},
1648             {"/",S_OK,FALSE},
1649             {"/",S_OK,FALSE},
1650             {"",S_FALSE,FALSE},
1651             {"zip://127.0.0.1:abcd",S_OK,FALSE},
1652             {"zip",S_OK,FALSE},
1653             {"",S_FALSE,FALSE},
1654             {"",S_FALSE,FALSE}
1655         },
1656         {
1657             {Uri_HOST_DNS,S_OK,FALSE},
1658             {0,S_FALSE,FALSE},
1659             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1660             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1661         }
1662     },
1663     /* Port is just copied over. */
1664     {   "http://google.com:00035", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
1665         {
1666             {"http://google.com:00035",S_OK,FALSE},
1667             {"google.com:00035",S_OK,FALSE},
1668             {"http://google.com:00035",S_OK,FALSE,"http://google.com:35"},
1669             {"google.com",S_OK,FALSE},
1670             {"",S_FALSE,FALSE},
1671             {"",S_FALSE,FALSE},
1672             {"google.com",S_OK,FALSE},
1673             {"",S_FALSE,FALSE},
1674             {"",S_FALSE,FALSE},
1675             {"",S_FALSE,FALSE},
1676             {"",S_FALSE,FALSE},
1677             {"http://google.com:00035",S_OK,FALSE},
1678             {"http",S_OK,FALSE},
1679             {"",S_FALSE,FALSE},
1680             {"",S_FALSE,FALSE}
1681         },
1682         {
1683             {Uri_HOST_DNS,S_OK,FALSE},
1684             {35,S_OK,FALSE},
1685             {URL_SCHEME_HTTP,S_OK,FALSE},
1686             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1687         }
1688     },
1689     /* Default port is copied over. */
1690     {   "http://google.com:80", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
1691         {
1692             {"http://google.com:80",S_OK,FALSE},
1693             {"google.com:80",S_OK,FALSE},
1694             {"http://google.com:80",S_OK,FALSE},
1695             {"google.com",S_OK,FALSE},
1696             {"",S_FALSE,FALSE},
1697             {"",S_FALSE,FALSE},
1698             {"google.com",S_OK,FALSE},
1699             {"",S_FALSE,FALSE},
1700             {"",S_FALSE,FALSE},
1701             {"",S_FALSE,FALSE},
1702             {"",S_FALSE,FALSE},
1703             {"http://google.com:80",S_OK,FALSE},
1704             {"http",S_OK,FALSE},
1705             {"",S_FALSE,FALSE},
1706             {"",S_FALSE,FALSE}
1707         },
1708         {
1709             {Uri_HOST_DNS,S_OK,FALSE},
1710             {80,S_OK,FALSE},
1711             {URL_SCHEME_HTTP,S_OK,FALSE},
1712             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1713         }
1714     },
1715     {   "http://google.com.uk", 0, S_OK, FALSE,
1716         {
1717             {"http://google.com.uk/",S_OK,FALSE},
1718             {"google.com.uk",S_OK,FALSE},
1719             {"http://google.com.uk/",S_OK,FALSE},
1720             {"google.com.uk",S_OK,FALSE},
1721             {"",S_FALSE,FALSE},
1722             {"",S_FALSE,FALSE},
1723             {"google.com.uk",S_OK,FALSE},
1724             {"",S_FALSE,FALSE},
1725             {"/",S_OK,FALSE},
1726             {"/",S_OK,FALSE},
1727             {"",S_FALSE,FALSE},
1728             {"http://google.com.uk",S_OK,FALSE},
1729             {"http",S_OK,FALSE},
1730             {"",S_FALSE,FALSE},
1731             {"",S_FALSE,FALSE}
1732         },
1733         {
1734             {Uri_HOST_DNS,S_OK,FALSE},
1735             {80,S_OK,FALSE},
1736             {URL_SCHEME_HTTP,S_OK,FALSE},
1737             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1738         }
1739     },
1740     {   "http://google.com.com", 0, S_OK, FALSE,
1741         {
1742             {"http://google.com.com/",S_OK,FALSE},
1743             {"google.com.com",S_OK,FALSE},
1744             {"http://google.com.com/",S_OK,FALSE},
1745             {"com.com",S_OK,FALSE},
1746             {"",S_FALSE,FALSE},
1747             {"",S_FALSE,FALSE},
1748             {"google.com.com",S_OK,FALSE},
1749             {"",S_FALSE,FALSE},
1750             {"/",S_OK,FALSE},
1751             {"/",S_OK,FALSE},
1752             {"",S_FALSE,FALSE},
1753             {"http://google.com.com",S_OK,FALSE},
1754             {"http",S_OK,FALSE},
1755             {"",S_FALSE,FALSE},
1756             {"",S_FALSE,FALSE}
1757         },
1758         {
1759             {Uri_HOST_DNS,S_OK,FALSE},
1760             {80,S_OK,FALSE},
1761             {URL_SCHEME_HTTP,S_OK,FALSE},
1762             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1763         }
1764     },
1765     {   "http://google.uk.1", 0, S_OK, FALSE,
1766         {
1767             {"http://google.uk.1/",S_OK,FALSE},
1768             {"google.uk.1",S_OK,FALSE},
1769             {"http://google.uk.1/",S_OK,FALSE},
1770             {"google.uk.1",S_OK,FALSE},
1771             {"",S_FALSE,FALSE},
1772             {"",S_FALSE,FALSE},
1773             {"google.uk.1",S_OK,FALSE},
1774             {"",S_FALSE,FALSE},
1775             {"/",S_OK,FALSE},
1776             {"/",S_OK,FALSE},
1777             {"",S_FALSE,FALSE},
1778             {"http://google.uk.1",S_OK,FALSE},
1779             {"http",S_OK,FALSE},
1780             {"",S_FALSE,FALSE},
1781             {"",S_FALSE,FALSE}
1782         },
1783         {
1784             {Uri_HOST_DNS,S_OK,FALSE},
1785             {80,S_OK,FALSE},
1786             {URL_SCHEME_HTTP,S_OK,FALSE},
1787             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1788         }
1789     },
1790     /* Since foo isn't a recognized 3 character TLD its considered the domain name. */
1791     {   "http://google.foo.uk", 0, S_OK, FALSE,
1792         {
1793             {"http://google.foo.uk/",S_OK,FALSE},
1794             {"google.foo.uk",S_OK,FALSE},
1795             {"http://google.foo.uk/",S_OK,FALSE},
1796             {"foo.uk",S_OK,FALSE},
1797             {"",S_FALSE,FALSE},
1798             {"",S_FALSE,FALSE},
1799             {"google.foo.uk",S_OK,FALSE},
1800             {"",S_FALSE,FALSE},
1801             {"/",S_OK,FALSE},
1802             {"/",S_OK,FALSE},
1803             {"",S_FALSE,FALSE},
1804             {"http://google.foo.uk",S_OK,FALSE},
1805             {"http",S_OK,FALSE},
1806             {"",S_FALSE,FALSE},
1807             {"",S_FALSE,FALSE}
1808         },
1809         {
1810             {Uri_HOST_DNS,S_OK,FALSE},
1811             {80,S_OK,FALSE},
1812             {URL_SCHEME_HTTP,S_OK,FALSE},
1813             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1814         }
1815     },
1816     {   "http://.com", 0, S_OK, FALSE,
1817         {
1818             {"http://.com/",S_OK,FALSE},
1819             {".com",S_OK,FALSE},
1820             {"http://.com/",S_OK,FALSE},
1821             {".com",S_OK,FALSE},
1822             {"",S_FALSE,FALSE},
1823             {"",S_FALSE,FALSE},
1824             {".com",S_OK,FALSE},
1825             {"",S_FALSE,FALSE},
1826             {"/",S_OK,FALSE},
1827             {"/",S_OK,FALSE},
1828             {"",S_FALSE,FALSE},
1829             {"http://.com",S_OK,FALSE},
1830             {"http",S_OK,FALSE},
1831             {"",S_FALSE,FALSE},
1832             {"",S_FALSE,FALSE}
1833         },
1834         {
1835             {Uri_HOST_DNS,S_OK,FALSE},
1836             {80,S_OK,FALSE},
1837             {URL_SCHEME_HTTP,S_OK,FALSE},
1838             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1839         }
1840     },
1841     {   "http://.uk", 0, S_OK, FALSE,
1842         {
1843             {"http://.uk/",S_OK,FALSE},
1844             {".uk",S_OK,FALSE},
1845             {"http://.uk/",S_OK,FALSE},
1846             {"",S_FALSE,FALSE},
1847             {"",S_FALSE,FALSE},
1848             {"",S_FALSE,FALSE},
1849             {".uk",S_OK,FALSE},
1850             {"",S_FALSE,FALSE},
1851             {"/",S_OK,FALSE},
1852             {"/",S_OK,FALSE},
1853             {"",S_FALSE,FALSE},
1854             {"http://.uk",S_OK,FALSE},
1855             {"http",S_OK,FALSE},
1856             {"",S_FALSE,FALSE},
1857             {"",S_FALSE,FALSE}
1858         },
1859         {
1860             {Uri_HOST_DNS,S_OK,FALSE},
1861             {80,S_OK,FALSE},
1862             {URL_SCHEME_HTTP,S_OK,FALSE},
1863             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1864         }
1865     },
1866     {   "http://www.co.google.com.[]", 0, S_OK, FALSE,
1867         {
1868             {"http://www.co.google.com.[]/",S_OK,FALSE},
1869             {"www.co.google.com.[]",S_OK,FALSE},
1870             {"http://www.co.google.com.[]/",S_OK,FALSE},
1871             {"google.com.[]",S_OK,FALSE},
1872             {"",S_FALSE,FALSE},
1873             {"",S_FALSE,FALSE},
1874             {"www.co.google.com.[]",S_OK,FALSE},
1875             {"",S_FALSE,FALSE},
1876             {"/",S_OK,FALSE},
1877             {"/",S_OK,FALSE},
1878             {"",S_FALSE,FALSE},
1879             {"http://www.co.google.com.[]",S_OK,FALSE},
1880             {"http",S_OK,FALSE},
1881             {"",S_FALSE,FALSE},
1882             {"",S_FALSE,FALSE}
1883         },
1884         {
1885             {Uri_HOST_DNS,S_OK,FALSE},
1886             {80,S_OK,FALSE},
1887             {URL_SCHEME_HTTP,S_OK,FALSE},
1888             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1889         }
1890     },
1891     {   "http://co.uk", 0, S_OK, FALSE,
1892         {
1893             {"http://co.uk/",S_OK,FALSE},
1894             {"co.uk",S_OK,FALSE},
1895             {"http://co.uk/",S_OK,FALSE},
1896             {"",S_FALSE,FALSE},
1897             {"",S_FALSE,FALSE},
1898             {"",S_FALSE,FALSE},
1899             {"co.uk",S_OK,FALSE},
1900             {"",S_FALSE,FALSE},
1901             {"/",S_OK,FALSE},
1902             {"/",S_OK,FALSE},
1903             {"",S_FALSE,FALSE},
1904             {"http://co.uk",S_OK,FALSE},
1905             {"http",S_OK,FALSE},
1906             {"",S_FALSE,FALSE},
1907             {"",S_FALSE,FALSE}
1908         },
1909         {
1910             {Uri_HOST_DNS,S_OK,FALSE},
1911             {80,S_OK,FALSE},
1912             {URL_SCHEME_HTTP,S_OK,FALSE},
1913             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1914         }
1915     },
1916     {   "http://www.co.google.us.test", 0, S_OK, FALSE,
1917         {
1918             {"http://www.co.google.us.test/",S_OK,FALSE},
1919             {"www.co.google.us.test",S_OK,FALSE},
1920             {"http://www.co.google.us.test/",S_OK,FALSE},
1921             {"us.test",S_OK,FALSE},
1922             {"",S_FALSE,FALSE},
1923             {"",S_FALSE,FALSE},
1924             {"www.co.google.us.test",S_OK,FALSE},
1925             {"",S_FALSE,FALSE},
1926             {"/",S_OK,FALSE},
1927             {"/",S_OK,FALSE},
1928             {"",S_FALSE,FALSE},
1929             {"http://www.co.google.us.test",S_OK,FALSE},
1930             {"http",S_OK,FALSE},
1931             {"",S_FALSE,FALSE},
1932             {"",S_FALSE,FALSE}
1933         },
1934         {
1935             {Uri_HOST_DNS,S_OK,FALSE},
1936             {80,S_OK,FALSE},
1937             {URL_SCHEME_HTTP,S_OK,FALSE},
1938             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1939         }
1940     },
1941     {   "http://gov.uk", 0, S_OK, FALSE,
1942         {
1943             {"http://gov.uk/",S_OK,FALSE},
1944             {"gov.uk",S_OK,FALSE},
1945             {"http://gov.uk/",S_OK,FALSE},
1946             {"",S_FALSE,FALSE},
1947             {"",S_FALSE,FALSE},
1948             {"",S_FALSE,FALSE},
1949             {"gov.uk",S_OK,FALSE},
1950             {"",S_FALSE,FALSE},
1951             {"/",S_OK,FALSE},
1952             {"/",S_OK,FALSE},
1953             {"",S_FALSE,FALSE},
1954             {"http://gov.uk",S_OK,FALSE},
1955             {"http",S_OK,FALSE},
1956             {"",S_FALSE,FALSE},
1957             {"",S_FALSE,FALSE}
1958         },
1959         {
1960             {Uri_HOST_DNS,S_OK,FALSE},
1961             {80,S_OK,FALSE},
1962             {URL_SCHEME_HTTP,S_OK,FALSE},
1963             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1964         }
1965     },
1966     {   "zip://www.google.com\\test", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
1967         {
1968             {"zip://www.google.com\\test",S_OK,FALSE},
1969             {"www.google.com\\test",S_OK,FALSE},
1970             {"zip://www.google.com\\test",S_OK,FALSE},
1971             {"google.com\\test",S_OK,FALSE},
1972             {"",S_FALSE,FALSE},
1973             {"",S_FALSE,FALSE},
1974             {"www.google.com\\test",S_OK,FALSE},
1975             {"",S_FALSE,FALSE},
1976             {"",S_FALSE,FALSE},
1977             {"",S_FALSE,FALSE},
1978             {"",S_FALSE,FALSE},
1979             {"zip://www.google.com\\test",S_OK,FALSE},
1980             {"zip",S_OK,FALSE},
1981             {"",S_FALSE,FALSE},
1982             {"",S_FALSE,FALSE}
1983         },
1984         {
1985             {Uri_HOST_DNS,S_OK,FALSE},
1986             {0,S_FALSE,FALSE},
1987             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1988             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1989         }
1990     },
1991     {   "urn:excepts:bad:%XY:encoded", 0, S_OK, FALSE,
1992         {
1993             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
1994             {"",S_FALSE,FALSE},
1995             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
1996             {"",S_FALSE,FALSE},
1997             {"",S_FALSE,FALSE},
1998             {"",S_FALSE,FALSE},
1999             {"",S_FALSE,FALSE},
2000             {"",S_FALSE,FALSE},
2001             {"excepts:bad:%XY:encoded",S_OK,FALSE},
2002             {"excepts:bad:%XY:encoded",S_OK,FALSE},
2003             {"",S_FALSE,FALSE},
2004             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
2005             {"urn",S_OK,FALSE},
2006             {"",S_FALSE,FALSE},
2007             {"",S_FALSE,FALSE}
2008         },
2009         {
2010             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2011             {0,S_FALSE,FALSE},
2012             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2013             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2014         }
2015     },
2016     /* Since the original URI doesn't contain an extra '/' before the path no % encoded values
2017      * are decoded and all '%' are encoded.
2018      */
2019     {   "file://C:/te%3Es%2Et/tes%t.mp3", 0, S_OK, FALSE,
2020         {
2021             {"file:///C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2022             {"",S_FALSE,FALSE},
2023             {"file:///C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2024             {"",S_FALSE,FALSE},
2025             {".mp3",S_OK,FALSE},
2026             {"",S_FALSE,FALSE},
2027             {"",S_FALSE,FALSE},
2028             {"",S_FALSE,FALSE},
2029             {"/C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2030             {"/C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2031             {"",S_FALSE,FALSE},
2032             {"file://C:/te%3Es%2Et/tes%t.mp3",S_OK,FALSE},
2033             {"file",S_OK,FALSE},
2034             {"",S_FALSE,FALSE},
2035             {"",S_FALSE,FALSE}
2036         },
2037         {
2038             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2039             {0,S_FALSE,FALSE},
2040             {URL_SCHEME_FILE,S_OK,FALSE},
2041             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2042         }
2043     },
2044     /* Since there's a '/' in front of the drive letter, any percent encoded, non-forbidden character
2045      * is decoded and only %'s in front of invalid hex digits are encoded.
2046      */
2047     {   "file:///C:/te%3Es%2Et/t%23es%t.mp3", 0, S_OK, FALSE,
2048         {
2049             {"file:///C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2050             {"",S_FALSE,FALSE},
2051             {"file:///C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2052             {"",S_FALSE,FALSE},
2053             {".mp3",S_OK,FALSE},
2054             {"",S_FALSE,FALSE},
2055             {"",S_FALSE,FALSE},
2056             {"",S_FALSE,FALSE},
2057             {"/C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2058             {"/C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2059             {"",S_FALSE,FALSE},
2060             {"file:///C:/te%3Es%2Et/t%23es%t.mp3",S_OK,FALSE},
2061             {"file",S_OK,FALSE},
2062             {"",S_FALSE,FALSE},
2063             {"",S_FALSE,FALSE}
2064         },
2065         {
2066             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2067             {0,S_FALSE,FALSE},
2068             {URL_SCHEME_FILE,S_OK,FALSE},
2069             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2070         }
2071     },
2072     /* Only unreserved percent encoded characters are decoded for known schemes that aren't file. */
2073     {   "http://[::001.002.003.000]/%3F%23%2E%54/test", 0, S_OK, FALSE,
2074         {
2075             {"http://[::1.2.3.0]/%3F%23.T/test",S_OK,FALSE},
2076             {"[::1.2.3.0]",S_OK,FALSE},
2077             {"http://[::1.2.3.0]/%3F%23.T/test",S_OK,FALSE},
2078             {"",S_FALSE,FALSE},
2079             {"",S_FALSE,FALSE},
2080             {"",S_FALSE,FALSE},
2081             {"::1.2.3.0",S_OK,FALSE},
2082             {"",S_FALSE,FALSE},
2083             {"/%3F%23.T/test",S_OK,FALSE},
2084             {"/%3F%23.T/test",S_OK,FALSE},
2085             {"",S_FALSE,FALSE},
2086             {"http://[::001.002.003.000]/%3F%23%2E%54/test",S_OK,FALSE},
2087             {"http",S_OK,FALSE},
2088             {"",S_FALSE,FALSE},
2089             {"",S_FALSE,FALSE},
2090         },
2091         {
2092             {Uri_HOST_IPV6,S_OK,FALSE},
2093             {80,S_OK,FALSE},
2094             {URL_SCHEME_HTTP,S_OK,FALSE},
2095             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2096         }
2097     },
2098     /* Forbidden characters are always encoded for file URIs. */
2099     {   "file:///C:/\"test\"/test.mp3", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2100         {
2101             {"file:///C:/%22test%22/test.mp3",S_OK,FALSE},
2102             {"",S_FALSE,FALSE},
2103             {"file:///C:/%22test%22/test.mp3",S_OK,FALSE},
2104             {"",S_FALSE,FALSE},
2105             {".mp3",S_OK,FALSE},
2106             {"",S_FALSE,FALSE},
2107             {"",S_FALSE,FALSE},
2108             {"",S_FALSE,FALSE},
2109             {"/C:/%22test%22/test.mp3",S_OK,FALSE},
2110             {"/C:/%22test%22/test.mp3",S_OK,FALSE},
2111             {"",S_FALSE,FALSE},
2112             {"file:///C:/\"test\"/test.mp3",S_OK,FALSE},
2113             {"file",S_OK,FALSE},
2114             {"",S_FALSE,FALSE},
2115             {"",S_FALSE,FALSE}
2116         },
2117         {
2118             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2119             {0,S_FALSE,FALSE},
2120             {URL_SCHEME_FILE,S_OK,FALSE},
2121             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2122         }
2123     },
2124     /* Forbidden characters are never encoded for unknown scheme types. */
2125     {   "1234://4294967295/<|>\" test<|>", 0, S_OK, FALSE,
2126         {
2127             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2128             {"4294967295",S_OK,FALSE},
2129             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2130             {"",S_FALSE,FALSE},
2131             {"",S_FALSE,FALSE},
2132             {"",S_FALSE,FALSE},
2133             {"4294967295",S_OK,FALSE},
2134             {"",S_FALSE,FALSE},
2135             {"/<|>\" test<|>",S_OK,FALSE},
2136             {"/<|>\" test<|>",S_OK,FALSE},
2137             {"",S_FALSE,FALSE},
2138             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2139             {"1234",S_OK,FALSE},
2140             {"",S_FALSE,FALSE},
2141             {"",S_FALSE,FALSE}
2142         },
2143         {
2144             {Uri_HOST_IPV4,S_OK,FALSE},
2145             {0,S_FALSE,FALSE},
2146             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2147             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2148         }
2149     },
2150     /* Make sure forbidden characters are percent encoded. */
2151     {   "http://gov.uk/<|> test<|>", 0, S_OK, FALSE,
2152         {
2153             {"http://gov.uk/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2154             {"gov.uk",S_OK,FALSE},
2155             {"http://gov.uk/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2156             {"",S_FALSE,FALSE},
2157             {"",S_FALSE,FALSE},
2158             {"",S_FALSE,FALSE},
2159             {"gov.uk",S_OK,FALSE},
2160             {"",S_FALSE,FALSE},
2161             {"/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2162             {"/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2163             {"",S_FALSE,FALSE},
2164             {"http://gov.uk/<|> test<|>",S_OK,FALSE},
2165             {"http",S_OK,FALSE},
2166             {"",S_FALSE,FALSE},
2167             {"",S_FALSE,FALSE}
2168         },
2169         {
2170             {Uri_HOST_DNS,S_OK,FALSE},
2171             {80,S_OK,FALSE},
2172             {URL_SCHEME_HTTP,S_OK,FALSE},
2173             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2174         }
2175     },
2176     {   "http://gov.uk/test/../test2/././../test3/.././././", 0, S_OK, FALSE,
2177         {
2178             {"http://gov.uk/",S_OK,FALSE},
2179             {"gov.uk",S_OK,FALSE},
2180             {"http://gov.uk/",S_OK,FALSE},
2181             {"",S_FALSE,FALSE},
2182             {"",S_FALSE,FALSE},
2183             {"",S_FALSE,FALSE},
2184             {"gov.uk",S_OK,FALSE},
2185             {"",S_FALSE,FALSE},
2186             {"/",S_OK,FALSE},
2187             {"/",S_OK,FALSE},
2188             {"",S_FALSE,FALSE},
2189             {"http://gov.uk/test/../test2/././../test3/.././././",S_OK,FALSE},
2190             {"http",S_OK,FALSE},
2191             {"",S_FALSE,FALSE},
2192             {"",S_FALSE,FALSE}
2193         },
2194         {
2195             {Uri_HOST_DNS,S_OK,FALSE},
2196             {80,S_OK,FALSE},
2197             {URL_SCHEME_HTTP,S_OK,FALSE},
2198             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2199         }
2200     },
2201     {   "http://gov.uk/test/test2/../../..", 0, S_OK, FALSE,
2202         {
2203             {"http://gov.uk/",S_OK,FALSE},
2204             {"gov.uk",S_OK,FALSE},
2205             {"http://gov.uk/",S_OK,FALSE},
2206             {"",S_FALSE,FALSE},
2207             {"",S_FALSE,FALSE},
2208             {"",S_FALSE,FALSE},
2209             {"gov.uk",S_OK,FALSE},
2210             {"",S_FALSE,FALSE},
2211             {"/",S_OK,FALSE},
2212             {"/",S_OK,FALSE},
2213             {"",S_FALSE,FALSE},
2214             {"http://gov.uk/test/test2/../../..",S_OK,FALSE},
2215             {"http",S_OK,FALSE},
2216             {"",S_FALSE,FALSE},
2217             {"",S_FALSE,FALSE}
2218         },
2219         {
2220             {Uri_HOST_DNS,S_OK,FALSE},
2221             {80,S_OK,FALSE},
2222             {URL_SCHEME_HTTP,S_OK,FALSE},
2223             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2224         }
2225     },
2226     {   "http://gov.uk/test/test2/../../.", 0, S_OK, FALSE,
2227         {
2228             {"http://gov.uk/",S_OK,FALSE},
2229             {"gov.uk",S_OK,FALSE},
2230             {"http://gov.uk/",S_OK,FALSE},
2231             {"",S_FALSE,FALSE},
2232             {"",S_FALSE,FALSE},
2233             {"",S_FALSE,FALSE},
2234             {"gov.uk",S_OK,FALSE},
2235             {"",S_FALSE,FALSE},
2236             {"/",S_OK,FALSE},
2237             {"/",S_OK,FALSE},
2238             {"",S_FALSE,FALSE},
2239             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2240             {"http",S_OK,FALSE},
2241             {"",S_FALSE,FALSE},
2242             {"",S_FALSE,FALSE}
2243         },
2244         {
2245             {Uri_HOST_DNS,S_OK,FALSE},
2246             {80,S_OK,FALSE},
2247             {URL_SCHEME_HTTP,S_OK,FALSE},
2248             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2249         }
2250     },
2251     {   "file://c:\\tests\\../tests\\./.\\..\\foo%20bar.mp3", 0, S_OK, FALSE,
2252         {
2253             {"file:///c:/foo%2520bar.mp3",S_OK,FALSE},
2254             {"",S_FALSE,FALSE},
2255             {"file:///c:/foo%2520bar.mp3",S_OK,FALSE},
2256             {"",S_FALSE,FALSE},
2257             {".mp3",S_OK,FALSE},
2258             {"",S_FALSE,FALSE},
2259             {"",S_FALSE,FALSE},
2260             {"",S_FALSE,FALSE},
2261             {"/c:/foo%2520bar.mp3",S_OK,FALSE},
2262             {"/c:/foo%2520bar.mp3",S_OK,FALSE},
2263             {"",S_FALSE,FALSE},
2264             {"file://c:\\tests\\../tests\\./.\\..\\foo%20bar.mp3",S_OK,FALSE},
2265             {"file",S_OK,FALSE},
2266             {"",S_FALSE,FALSE},
2267             {"",S_FALSE,FALSE}
2268         },
2269         {
2270             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2271             {0,S_FALSE,FALSE},
2272             {URL_SCHEME_FILE,S_OK,FALSE},
2273             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2274         }
2275     },
2276     /* Dot removal happens for unknown scheme types. */
2277     {   "zip://gov.uk/test/test2/../../.", 0, S_OK, FALSE,
2278         {
2279             {"zip://gov.uk/",S_OK,FALSE},
2280             {"gov.uk",S_OK,FALSE},
2281             {"zip://gov.uk/",S_OK,FALSE},
2282             {"",S_FALSE,FALSE},
2283             {"",S_FALSE,FALSE},
2284             {"",S_FALSE,FALSE},
2285             {"gov.uk",S_OK,FALSE},
2286             {"",S_FALSE,FALSE},
2287             {"/",S_OK,FALSE},
2288             {"/",S_OK,FALSE},
2289             {"",S_FALSE,FALSE},
2290             {"zip://gov.uk/test/test2/../../.",S_OK,FALSE},
2291             {"zip",S_OK,FALSE},
2292             {"",S_FALSE,FALSE},
2293             {"",S_FALSE,FALSE}
2294         },
2295         {
2296             {Uri_HOST_DNS,S_OK,FALSE},
2297             {0,S_FALSE,FALSE},
2298             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2299             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2300         }
2301     },
2302     /* Dot removal doesn't happen if NO_CANONICALIZE is set. */
2303     {   "http://gov.uk/test/test2/../../.", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2304         {
2305             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2306             {"gov.uk",S_OK,FALSE},
2307             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2308             {"",S_FALSE,FALSE},
2309             {".",S_OK,FALSE},
2310             {"",S_FALSE,FALSE},
2311             {"gov.uk",S_OK,FALSE},
2312             {"",S_FALSE,FALSE},
2313             {"/test/test2/../../.",S_OK,FALSE},
2314             {"/test/test2/../../.",S_OK,FALSE},
2315             {"",S_FALSE,FALSE},
2316             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2317             {"http",S_OK,FALSE},
2318             {"",S_FALSE,FALSE},
2319             {"",S_FALSE,FALSE}
2320         },
2321         {
2322             {Uri_HOST_DNS,S_OK,FALSE},
2323             {80,S_OK,FALSE},
2324             {URL_SCHEME_HTTP,S_OK,FALSE},
2325             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2326         }
2327     },
2328     /* Dot removal doesn't happen for wildcard scheme types. */
2329     {   "*:gov.uk/test/test2/../../.", 0, S_OK, FALSE,
2330         {
2331             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2332             {"gov.uk",S_OK,FALSE},
2333             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2334             {"",S_FALSE,FALSE},
2335             {".",S_OK,FALSE},
2336             {"",S_FALSE,FALSE},
2337             {"gov.uk",S_OK,FALSE},
2338             {"",S_FALSE,FALSE},
2339             {"/test/test2/../../.",S_OK,FALSE},
2340             {"/test/test2/../../.",S_OK,FALSE},
2341             {"",S_FALSE,FALSE},
2342             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2343             {"*",S_OK,FALSE},
2344             {"",S_FALSE,FALSE},
2345             {"",S_FALSE,FALSE}
2346         },
2347         {
2348             {Uri_HOST_DNS,S_OK,FALSE},
2349             {0,S_FALSE,FALSE},
2350             {URL_SCHEME_WILDCARD,S_OK,FALSE},
2351             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2352         }
2353     },
2354     /* Forbidden characters are encoded for opaque known scheme types. */
2355     {   "mailto:\"acco<|>unt@example.com\"", 0, S_OK, FALSE,
2356         {
2357             {"mailto:%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2358             {"",S_FALSE,FALSE},
2359             {"mailto:%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2360             {"",S_FALSE,FALSE},
2361             {".com%22",S_OK,FALSE},
2362             {"",S_FALSE,FALSE},
2363             {"",S_FALSE,FALSE},
2364             {"",S_FALSE,FALSE},
2365             {"%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2366             {"%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2367             {"",S_FALSE,FALSE},
2368             {"mailto:\"acco<|>unt@example.com\"",S_OK,FALSE},
2369             {"mailto",S_OK,FALSE},
2370             {"",S_FALSE,FALSE},
2371             {"",S_FALSE,FALSE}
2372         },
2373         {
2374             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2375             {0,S_FALSE,FALSE},
2376             {URL_SCHEME_MAILTO,S_OK,FALSE},
2377             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2378         }
2379     },
2380     {   "news:test.tes<|>t.com", 0, S_OK, FALSE,
2381         {
2382             {"news:test.tes%3C%7C%3Et.com",S_OK,FALSE},
2383             {"",S_FALSE,FALSE},
2384             {"news:test.tes%3C%7C%3Et.com",S_OK,FALSE},
2385             {"",S_FALSE,FALSE},
2386             {".com",S_OK,FALSE},
2387             {"",S_FALSE,FALSE},
2388             {"",S_FALSE,FALSE},
2389             {"",S_FALSE,FALSE},
2390             {"test.tes%3C%7C%3Et.com",S_OK,FALSE},
2391             {"test.tes%3C%7C%3Et.com",S_OK,FALSE},
2392             {"",S_FALSE,FALSE},
2393             {"news:test.tes<|>t.com",S_OK,FALSE},
2394             {"news",S_OK,FALSE},
2395             {"",S_FALSE,FALSE},
2396             {"",S_FALSE,FALSE}
2397         },
2398         {
2399             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2400             {0,S_FALSE,FALSE},
2401             {URL_SCHEME_NEWS,S_OK,FALSE},
2402             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2403         }
2404     },
2405     /* Don't encode forbidden characters. */
2406     {   "news:test.tes<|>t.com", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2407         {
2408             {"news:test.tes<|>t.com",S_OK,FALSE},
2409             {"",S_FALSE,FALSE},
2410             {"news:test.tes<|>t.com",S_OK,FALSE},
2411             {"",S_FALSE,FALSE},
2412             {".com",S_OK,FALSE},
2413             {"",S_FALSE,FALSE},
2414             {"",S_FALSE,FALSE},
2415             {"",S_FALSE,FALSE},
2416             {"test.tes<|>t.com",S_OK,FALSE},
2417             {"test.tes<|>t.com",S_OK,FALSE},
2418             {"",S_FALSE,FALSE},
2419             {"news:test.tes<|>t.com",S_OK,FALSE},
2420             {"news",S_OK,FALSE},
2421             {"",S_FALSE,FALSE},
2422             {"",S_FALSE,FALSE}
2423         },
2424         {
2425             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2426             {0,S_FALSE,FALSE},
2427             {URL_SCHEME_NEWS,S_OK,FALSE},
2428             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2429         }
2430     },
2431     /* Forbidden characters aren't encoded for unknown, opaque URIs. */
2432     {   "urn:test.tes<|>t.com", 0, S_OK, FALSE,
2433         {
2434             {"urn:test.tes<|>t.com",S_OK,FALSE},
2435             {"",S_FALSE,FALSE},
2436             {"urn:test.tes<|>t.com",S_OK,FALSE},
2437             {"",S_FALSE,FALSE},
2438             {".com",S_OK,FALSE},
2439             {"",S_FALSE,FALSE},
2440             {"",S_FALSE,FALSE},
2441             {"",S_FALSE,FALSE},
2442             {"test.tes<|>t.com",S_OK,FALSE},
2443             {"test.tes<|>t.com",S_OK,FALSE},
2444             {"",S_FALSE,FALSE},
2445             {"urn:test.tes<|>t.com",S_OK,FALSE},
2446             {"urn",S_OK,FALSE},
2447             {"",S_FALSE,FALSE},
2448             {"",S_FALSE,FALSE}
2449         },
2450         {
2451             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2452             {0,S_FALSE,FALSE},
2453             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2454             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2455         }
2456     },
2457     /* Percent encoded unreserved characters are decoded for known opaque URIs. */
2458     {   "news:test.%74%65%73%74.com", 0, S_OK, FALSE,
2459         {
2460             {"news:test.test.com",S_OK,FALSE},
2461             {"",S_FALSE,FALSE},
2462             {"news:test.test.com",S_OK,FALSE},
2463             {"",S_FALSE,FALSE},
2464             {".com",S_OK,FALSE},
2465             {"",S_FALSE,FALSE},
2466             {"",S_FALSE,FALSE},
2467             {"",S_FALSE,FALSE},
2468             {"test.test.com",S_OK,FALSE},
2469             {"test.test.com",S_OK,FALSE},
2470             {"",S_FALSE,FALSE},
2471             {"news:test.%74%65%73%74.com",S_OK,FALSE},
2472             {"news",S_OK,FALSE},
2473             {"",S_FALSE,FALSE},
2474             {"",S_FALSE,FALSE}
2475         },
2476         {
2477             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2478             {0,S_FALSE,FALSE},
2479             {URL_SCHEME_NEWS,S_OK,FALSE},
2480             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2481         }
2482     },
2483     /* Percent encoded characters are still decoded for known scheme types. */
2484     {   "news:test.%74%65%73%74.com", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2485         {
2486             {"news:test.test.com",S_OK,FALSE},
2487             {"",S_FALSE,FALSE},
2488             {"news:test.test.com",S_OK,FALSE},
2489             {"",S_FALSE,FALSE},
2490             {".com",S_OK,FALSE},
2491             {"",S_FALSE,FALSE},
2492             {"",S_FALSE,FALSE},
2493             {"",S_FALSE,FALSE},
2494             {"test.test.com",S_OK,FALSE},
2495             {"test.test.com",S_OK,FALSE},
2496             {"",S_FALSE,FALSE},
2497             {"news:test.%74%65%73%74.com",S_OK,FALSE},
2498             {"news",S_OK,FALSE},
2499             {"",S_FALSE,FALSE},
2500             {"",S_FALSE,FALSE}
2501         },
2502         {
2503             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2504             {0,S_FALSE,FALSE},
2505             {URL_SCHEME_NEWS,S_OK,FALSE},
2506             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2507         }
2508     },
2509     /* Percent encoded characters aren't decoded for unknown scheme types. */
2510     {   "urn:test.%74%65%73%74.com", 0, S_OK, FALSE,
2511         {
2512             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2513             {"",S_FALSE,FALSE},
2514             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2515             {"",S_FALSE,FALSE},
2516             {".com",S_OK,FALSE},
2517             {"",S_FALSE,FALSE},
2518             {"",S_FALSE,FALSE},
2519             {"",S_FALSE,FALSE},
2520             {"test.%74%65%73%74.com",S_OK,FALSE},
2521             {"test.%74%65%73%74.com",S_OK,FALSE},
2522             {"",S_FALSE,FALSE},
2523             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2524             {"urn",S_OK,FALSE},
2525             {"",S_FALSE,FALSE},
2526             {"",S_FALSE,FALSE}
2527         },
2528         {
2529             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2530             {0,S_FALSE,FALSE},
2531             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2532             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2533         }
2534     },
2535     /* Unknown scheme types can have invalid % encoded data in query string. */
2536     {   "zip://www.winehq.org/tests/..?query=%xx&return=y", 0, S_OK, FALSE,
2537         {
2538             {"zip://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2539             {"www.winehq.org",S_OK,FALSE},
2540             {"zip://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2541             {"winehq.org",S_OK,FALSE},
2542             {"",S_FALSE,FALSE},
2543             {"",S_FALSE,FALSE},
2544             {"www.winehq.org",S_OK,FALSE},
2545             {"",S_FALSE,FALSE},
2546             {"/",S_OK,FALSE},
2547             {"/?query=%xx&return=y",S_OK,FALSE},
2548             {"?query=%xx&return=y",S_OK,FALSE},
2549             {"zip://www.winehq.org/tests/..?query=%xx&return=y",S_OK,FALSE},
2550             {"zip",S_OK,FALSE},
2551             {"",S_FALSE,FALSE},
2552             {"",S_FALSE,FALSE}
2553         },
2554         {
2555             {Uri_HOST_DNS,S_OK,FALSE},
2556             {0,S_FALSE,FALSE},
2557             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2558             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2559         }
2560     },
2561     /* Known scheme types can have invalid % encoded data with the right flags. */
2562     {   "http://www.winehq.org/tests/..?query=%xx&return=y", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2563         {
2564             {"http://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2565             {"www.winehq.org",S_OK,FALSE},
2566             {"http://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2567             {"winehq.org",S_OK,FALSE},
2568             {"",S_FALSE,FALSE},
2569             {"",S_FALSE,FALSE},
2570             {"www.winehq.org",S_OK,FALSE},
2571             {"",S_FALSE,FALSE},
2572             {"/",S_OK,FALSE},
2573             {"/?query=%xx&return=y",S_OK,FALSE},
2574             {"?query=%xx&return=y",S_OK,FALSE},
2575             {"http://www.winehq.org/tests/..?query=%xx&return=y",S_OK,FALSE},
2576             {"http",S_OK,FALSE},
2577             {"",S_FALSE,FALSE},
2578             {"",S_FALSE,FALSE}
2579         },
2580         {
2581             {Uri_HOST_DNS,S_OK,FALSE},
2582             {80,S_OK,FALSE},
2583             {URL_SCHEME_HTTP,S_OK,FALSE},
2584             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2585         }
2586     },
2587     /* Forbidden characters in query aren't percent encoded for known scheme types with this flag. */
2588     {   "http://www.winehq.org/tests/..?query=<|>&return=y", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2589         {
2590             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2591             {"www.winehq.org",S_OK,FALSE},
2592             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2593             {"winehq.org",S_OK,FALSE},
2594             {"",S_FALSE,FALSE},
2595             {"",S_FALSE,FALSE},
2596             {"www.winehq.org",S_OK,FALSE},
2597             {"",S_FALSE,FALSE},
2598             {"/",S_OK,FALSE},
2599             {"/?query=<|>&return=y",S_OK,FALSE},
2600             {"?query=<|>&return=y",S_OK,FALSE},
2601             {"http://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2602             {"http",S_OK,FALSE},
2603             {"",S_FALSE,FALSE},
2604             {"",S_FALSE,FALSE}
2605         },
2606         {
2607             {Uri_HOST_DNS,S_OK,FALSE},
2608             {80,S_OK,FALSE},
2609             {URL_SCHEME_HTTP,S_OK,FALSE},
2610             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2611         }
2612     },
2613     /* Forbidden characters in query aren't percent encoded for known scheme types with this flag. */
2614     {   "http://www.winehq.org/tests/..?query=<|>&return=y", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2615         {
2616             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2617             {"www.winehq.org",S_OK,FALSE},
2618             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2619             {"winehq.org",S_OK,FALSE},
2620             {"",S_FALSE,FALSE},
2621             {"",S_FALSE,FALSE},
2622             {"www.winehq.org",S_OK,FALSE},
2623             {"",S_FALSE,FALSE},
2624             {"/",S_OK,FALSE},
2625             {"/?query=<|>&return=y",S_OK,FALSE},
2626             {"?query=<|>&return=y",S_OK,FALSE},
2627             {"http://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2628             {"http",S_OK,FALSE},
2629             {"",S_FALSE,FALSE},
2630             {"",S_FALSE,FALSE}
2631         },
2632         {
2633             {Uri_HOST_DNS,S_OK,FALSE},
2634             {80,S_OK,FALSE},
2635             {URL_SCHEME_HTTP,S_OK,FALSE},
2636             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2637         }
2638     },
2639     /* Forbidden characters are encoded for known scheme types. */
2640     {   "http://www.winehq.org/tests/..?query=<|>&return=y", 0, S_OK, FALSE,
2641         {
2642             {"http://www.winehq.org/?query=%3C%7C%3E&return=y",S_OK,FALSE},
2643             {"www.winehq.org",S_OK,FALSE},
2644             {"http://www.winehq.org/?query=%3C%7C%3E&return=y",S_OK,FALSE},
2645             {"winehq.org",S_OK,FALSE},
2646             {"",S_FALSE,FALSE},
2647             {"",S_FALSE,FALSE},
2648             {"www.winehq.org",S_OK,FALSE},
2649             {"",S_FALSE,FALSE},
2650             {"/",S_OK,FALSE},
2651             {"/?query=%3C%7C%3E&return=y",S_OK,FALSE},
2652             {"?query=%3C%7C%3E&return=y",S_OK,FALSE},
2653             {"http://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2654             {"http",S_OK,FALSE},
2655             {"",S_FALSE,FALSE},
2656             {"",S_FALSE,FALSE}
2657         },
2658         {
2659             {Uri_HOST_DNS,S_OK,FALSE},
2660             {80,S_OK,FALSE},
2661             {URL_SCHEME_HTTP,S_OK,FALSE},
2662             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2663         }
2664     },
2665     /* Forbidden characters are not encoded for unknown scheme types. */
2666     {   "zip://www.winehq.org/tests/..?query=<|>&return=y", 0, S_OK, FALSE,
2667         {
2668             {"zip://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2669             {"www.winehq.org",S_OK,FALSE},
2670             {"zip://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2671             {"winehq.org",S_OK,FALSE},
2672             {"",S_FALSE,FALSE},
2673             {"",S_FALSE,FALSE},
2674             {"www.winehq.org",S_OK,FALSE},
2675             {"",S_FALSE,FALSE},
2676             {"/",S_OK,FALSE},
2677             {"/?query=<|>&return=y",S_OK,FALSE},
2678             {"?query=<|>&return=y",S_OK,FALSE},
2679             {"zip://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2680             {"zip",S_OK,FALSE},
2681             {"",S_FALSE,FALSE},
2682             {"",S_FALSE,FALSE}
2683         },
2684         {
2685             {Uri_HOST_DNS,S_OK,FALSE},
2686             {0,S_FALSE,FALSE},
2687             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2688             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2689         }
2690     },
2691     /* Percent encoded, unreserved characters are decoded for known scheme types. */
2692     {   "http://www.winehq.org/tests/..?query=%30%31&return=y", 0, S_OK, FALSE,
2693         {
2694             {"http://www.winehq.org/?query=01&return=y",S_OK,FALSE},
2695             {"www.winehq.org",S_OK,FALSE},
2696             {"http://www.winehq.org/?query=01&return=y",S_OK,FALSE},
2697             {"winehq.org",S_OK,FALSE},
2698             {"",S_FALSE,FALSE},
2699             {"",S_FALSE,FALSE},
2700             {"www.winehq.org",S_OK,FALSE},
2701             {"",S_FALSE,FALSE},
2702             {"/",S_OK,FALSE},
2703             {"/?query=01&return=y",S_OK,FALSE},
2704             {"?query=01&return=y",S_OK,FALSE},
2705             {"http://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2706             {"http",S_OK,FALSE},
2707             {"",S_FALSE,FALSE},
2708             {"",S_FALSE,FALSE}
2709         },
2710         {
2711             {Uri_HOST_DNS,S_OK,FALSE},
2712             {80,S_OK,FALSE},
2713             {URL_SCHEME_HTTP,S_OK,FALSE},
2714             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2715         }
2716     },
2717     /* Percent encoded, unreserved characters aren't decoded for unknown scheme types. */
2718     {   "zip://www.winehq.org/tests/..?query=%30%31&return=y", 0, S_OK, FALSE,
2719         {
2720             {"zip://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2721             {"www.winehq.org",S_OK,FALSE},
2722             {"zip://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2723             {"winehq.org",S_OK,FALSE},
2724             {"",S_FALSE,FALSE},
2725             {"",S_FALSE,FALSE},
2726             {"www.winehq.org",S_OK,FALSE},
2727             {"",S_FALSE,FALSE},
2728             {"/",S_OK,FALSE},
2729             {"/?query=%30%31&return=y",S_OK,FALSE},
2730             {"?query=%30%31&return=y",S_OK,FALSE},
2731             {"zip://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2732             {"zip",S_OK,FALSE},
2733             {"",S_FALSE,FALSE},
2734             {"",S_FALSE,FALSE}
2735         },
2736         {
2737             {Uri_HOST_DNS,S_OK,FALSE},
2738             {0,S_FALSE,FALSE},
2739             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2740             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2741         }
2742     },
2743     /* Percent encoded characters aren't decoded when NO_DECODE_EXTRA_INFO is set. */
2744     {   "http://www.winehq.org/tests/..?query=%30%31&return=y", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2745         {
2746             {"http://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2747             {"www.winehq.org",S_OK,FALSE},
2748             {"http://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2749             {"winehq.org",S_OK,FALSE},
2750             {"",S_FALSE,FALSE},
2751             {"",S_FALSE,FALSE},
2752             {"www.winehq.org",S_OK,FALSE},
2753             {"",S_FALSE,FALSE},
2754             {"/",S_OK,FALSE},
2755             {"/?query=%30%31&return=y",S_OK,FALSE},
2756             {"?query=%30%31&return=y",S_OK,FALSE},
2757             {"http://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2758             {"http",S_OK,FALSE},
2759             {"",S_FALSE,FALSE},
2760             {"",S_FALSE,FALSE}
2761         },
2762         {
2763             {Uri_HOST_DNS,S_OK,FALSE},
2764             {80,S_OK,FALSE},
2765             {URL_SCHEME_HTTP,S_OK,FALSE},
2766             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2767         }
2768     },
2769     {   "http://www.winehq.org?query=12&return=y", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2770         {
2771             {"http://www.winehq.org?query=12&return=y",S_OK,FALSE},
2772             {"www.winehq.org",S_OK,FALSE},
2773             {"http://www.winehq.org?query=12&return=y",S_OK,FALSE},
2774             {"winehq.org",S_OK,FALSE},
2775             {"",S_FALSE,FALSE},
2776             {"",S_FALSE,FALSE},
2777             {"www.winehq.org",S_OK,FALSE},
2778             {"",S_FALSE,FALSE},
2779             {"",S_FALSE,FALSE},
2780             {"?query=12&return=y",S_OK,FALSE},
2781             {"?query=12&return=y",S_OK,FALSE},
2782             {"http://www.winehq.org?query=12&return=y",S_OK,FALSE},
2783             {"http",S_OK,FALSE},
2784             {"",S_FALSE,FALSE},
2785             {"",S_FALSE,FALSE}
2786         },
2787         {
2788             {Uri_HOST_DNS,S_OK,FALSE},
2789             {80,S_OK,FALSE},
2790             {URL_SCHEME_HTTP,S_OK,FALSE},
2791             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2792         }
2793     },
2794     /* Unknown scheme types can have invalid % encoded data in fragments. */
2795     {   "zip://www.winehq.org/tests/#Te%xx", 0, S_OK, FALSE,
2796         {
2797             {"zip://www.winehq.org/tests/#Te%xx",S_OK,FALSE},
2798             {"www.winehq.org",S_OK,FALSE},
2799             {"zip://www.winehq.org/tests/#Te%xx",S_OK,FALSE},
2800             {"winehq.org",S_OK,FALSE},
2801             {"",S_FALSE,FALSE},
2802             {"#Te%xx",S_OK,FALSE},
2803             {"www.winehq.org",S_OK,FALSE},
2804             {"",S_FALSE,FALSE},
2805             {"/tests/",S_OK,FALSE},
2806             {"/tests/",S_OK,FALSE},
2807             {"",S_FALSE,FALSE},
2808             {"zip://www.winehq.org/tests/#Te%xx",S_OK,FALSE},
2809             {"zip",S_OK,FALSE},
2810             {"",S_FALSE,FALSE},
2811             {"",S_FALSE,FALSE}
2812         },
2813         {
2814             {Uri_HOST_DNS,S_OK,FALSE},
2815             {0,S_FALSE,FALSE},
2816             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2817             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2818         }
2819     },
2820     /* Forbidden characters in fragment aren't encoded for unknown schemes. */
2821     {   "zip://www.winehq.org/tests/#Te<|>", 0, S_OK, FALSE,
2822         {
2823             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2824             {"www.winehq.org",S_OK,FALSE},
2825             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2826             {"winehq.org",S_OK,FALSE},
2827             {"",S_FALSE,FALSE},
2828             {"#Te<|>",S_OK,FALSE},
2829             {"www.winehq.org",S_OK,FALSE},
2830             {"",S_FALSE,FALSE},
2831             {"/tests/",S_OK,FALSE},
2832             {"/tests/",S_OK,FALSE},
2833             {"",S_FALSE,FALSE},
2834             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2835             {"zip",S_OK,FALSE},
2836             {"",S_FALSE,FALSE},
2837             {"",S_FALSE,FALSE}
2838         },
2839         {
2840             {Uri_HOST_DNS,S_OK,FALSE},
2841             {0,S_FALSE,FALSE},
2842             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2843             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2844         }
2845     },
2846     /* Forbidden characters in the fragment are percent encoded for known schemes. */
2847     {   "http://www.winehq.org/tests/#Te<|>", 0, S_OK, FALSE,
2848         {
2849             {"http://www.winehq.org/tests/#Te%3C%7C%3E",S_OK,FALSE},
2850             {"www.winehq.org",S_OK,FALSE},
2851             {"http://www.winehq.org/tests/#Te%3C%7C%3E",S_OK,FALSE},
2852             {"winehq.org",S_OK,FALSE},
2853             {"",S_FALSE,FALSE},
2854             {"#Te%3C%7C%3E",S_OK,FALSE},
2855             {"www.winehq.org",S_OK,FALSE},
2856             {"",S_FALSE,FALSE},
2857             {"/tests/",S_OK,FALSE},
2858             {"/tests/",S_OK,FALSE},
2859             {"",S_FALSE,FALSE},
2860             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2861             {"http",S_OK,FALSE},
2862             {"",S_FALSE,FALSE},
2863             {"",S_FALSE,FALSE}
2864         },
2865         {
2866             {Uri_HOST_DNS,S_OK,FALSE},
2867             {80,S_OK,FALSE},
2868             {URL_SCHEME_HTTP,S_OK,FALSE},
2869             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2870         }
2871     },
2872     /* Forbidden characters aren't encoded in the fragment with this flag. */
2873     {   "http://www.winehq.org/tests/#Te<|>", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2874         {
2875             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2876             {"www.winehq.org",S_OK,FALSE},
2877             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2878             {"winehq.org",S_OK,FALSE},
2879             {"",S_FALSE,FALSE},
2880             {"#Te<|>",S_OK,FALSE},
2881             {"www.winehq.org",S_OK,FALSE},
2882             {"",S_FALSE,FALSE},
2883             {"/tests/",S_OK,FALSE},
2884             {"/tests/",S_OK,FALSE},
2885             {"",S_FALSE,FALSE},
2886             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2887             {"http",S_OK,FALSE},
2888             {"",S_FALSE,FALSE},
2889             {"",S_FALSE,FALSE}
2890         },
2891         {
2892             {Uri_HOST_DNS,S_OK,FALSE},
2893             {80,S_OK,FALSE},
2894             {URL_SCHEME_HTTP,S_OK,FALSE},
2895             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2896         }
2897     },
2898     /* Forbidden characters aren't encoded in the fragment with this flag. */
2899     {   "http://www.winehq.org/tests/#Te<|>", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2900         {
2901             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2902             {"www.winehq.org",S_OK,FALSE},
2903             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2904             {"winehq.org",S_OK,FALSE},
2905             {"",S_FALSE,FALSE},
2906             {"#Te<|>",S_OK,FALSE},
2907             {"www.winehq.org",S_OK,FALSE},
2908             {"",S_FALSE,FALSE},
2909             {"/tests/",S_OK,FALSE},
2910             {"/tests/",S_OK,FALSE},
2911             {"",S_FALSE,FALSE},
2912             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2913             {"http",S_OK,FALSE},
2914             {"",S_FALSE,FALSE},
2915             {"",S_FALSE,FALSE}
2916         },
2917         {
2918             {Uri_HOST_DNS,S_OK,FALSE},
2919             {80,S_OK,FALSE},
2920             {URL_SCHEME_HTTP,S_OK,FALSE},
2921             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2922         }
2923     },
2924     /* Percent encoded, unreserved characters aren't decoded for known scheme types. */
2925     {   "zip://www.winehq.org/tests/#Te%30%31%32", 0, S_OK, FALSE,
2926         {
2927             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2928             {"www.winehq.org",S_OK,FALSE},
2929             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2930             {"winehq.org",S_OK,FALSE},
2931             {"",S_FALSE,FALSE},
2932             {"#Te%30%31%32",S_OK,FALSE},
2933             {"www.winehq.org",S_OK,FALSE},
2934             {"",S_FALSE,FALSE},
2935             {"/tests/",S_OK,FALSE},
2936             {"/tests/",S_OK,FALSE},
2937             {"",S_FALSE,FALSE},
2938             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2939             {"zip",S_OK,FALSE},
2940             {"",S_FALSE,FALSE},
2941             {"",S_FALSE,FALSE}
2942         },
2943         {
2944             {Uri_HOST_DNS,S_OK,FALSE},
2945             {0,S_FALSE,FALSE},
2946             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2947             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2948         }
2949     },
2950     /* Percent encoded, unreserved characters are decoded for known schemes. */
2951     {   "http://www.winehq.org/tests/#Te%30%31%32", 0, S_OK, FALSE,
2952         {
2953             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
2954             {"www.winehq.org",S_OK,FALSE},
2955             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
2956             {"winehq.org",S_OK,FALSE},
2957             {"",S_FALSE,FALSE},
2958             {"#Te012",S_OK,FALSE},
2959             {"www.winehq.org",S_OK,FALSE},
2960             {"",S_FALSE,FALSE},
2961             {"/tests/",S_OK,FALSE},
2962             {"/tests/",S_OK,FALSE},
2963             {"",S_FALSE,FALSE},
2964             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2965             {"http",S_OK,FALSE},
2966             {"",S_FALSE,FALSE},
2967             {"",S_FALSE,FALSE}
2968         },
2969         {
2970             {Uri_HOST_DNS,S_OK,FALSE},
2971             {80,S_OK,FALSE},
2972             {URL_SCHEME_HTTP,S_OK,FALSE},
2973             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2974         }
2975     },
2976     /* Percent encoded, unreserved characters are decoded even if NO_CANONICALIZE is set. */
2977     {   "http://www.winehq.org/tests/#Te%30%31%32", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2978         {
2979             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
2980             {"www.winehq.org",S_OK,FALSE},
2981             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
2982             {"winehq.org",S_OK,FALSE},
2983             {"",S_FALSE,FALSE},
2984             {"#Te012",S_OK,FALSE},
2985             {"www.winehq.org",S_OK,FALSE},
2986             {"",S_FALSE,FALSE},
2987             {"/tests/",S_OK,FALSE},
2988             {"/tests/",S_OK,FALSE},
2989             {"",S_FALSE,FALSE},
2990             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2991             {"http",S_OK,FALSE},
2992             {"",S_FALSE,FALSE},
2993             {"",S_FALSE,FALSE}
2994         },
2995         {
2996             {Uri_HOST_DNS,S_OK,FALSE},
2997             {80,S_OK,FALSE},
2998             {URL_SCHEME_HTTP,S_OK,FALSE},
2999             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3000         }
3001     },
3002     /* Percent encoded, unreserved characters aren't decoded when NO_DECODE_EXTRA is set. */
3003     {   "http://www.winehq.org/tests/#Te%30%31%32", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
3004         {
3005             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3006             {"www.winehq.org",S_OK,FALSE},
3007             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3008             {"winehq.org",S_OK,FALSE},
3009             {"",S_FALSE,FALSE},
3010             {"#Te%30%31%32",S_OK,FALSE},
3011             {"www.winehq.org",S_OK,FALSE},
3012             {"",S_FALSE,FALSE},
3013             {"/tests/",S_OK,FALSE},
3014             {"/tests/",S_OK,FALSE},
3015             {"",S_FALSE,FALSE},
3016             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3017             {"http",S_OK,FALSE},
3018             {"",S_FALSE,FALSE},
3019             {"",S_FALSE,FALSE}
3020         },
3021         {
3022             {Uri_HOST_DNS,S_OK,FALSE},
3023             {80,S_OK,FALSE},
3024             {URL_SCHEME_HTTP,S_OK,FALSE},
3025             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3026         }
3027     },
3028     /* Leading/Trailing whitespace is removed. */
3029     {   "    http://google.com/     ", 0, S_OK, FALSE,
3030         {
3031             {"http://google.com/",S_OK,FALSE},
3032             {"google.com",S_OK,FALSE},
3033             {"http://google.com/",S_OK,FALSE},
3034             {"google.com",S_OK,FALSE},
3035             {"",S_FALSE,FALSE},
3036             {"",S_FALSE,FALSE},
3037             {"google.com",S_OK,FALSE},
3038             {"",S_FALSE,FALSE},
3039             {"/",S_OK,FALSE},
3040             {"/",S_OK,FALSE},
3041             {"",S_FALSE,FALSE},
3042             {"http://google.com/",S_OK,FALSE},
3043             {"http",S_OK,FALSE},
3044             {"",S_FALSE,FALSE},
3045             {"",S_FALSE,FALSE}
3046         },
3047         {
3048             {Uri_HOST_DNS,S_OK,FALSE},
3049             {80,S_OK,FALSE},
3050             {URL_SCHEME_HTTP,S_OK,FALSE},
3051             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3052         }
3053     },
3054     {   "\t\t\r\nhttp\n://g\noogle.co\rm/\n\n\n", 0, S_OK, FALSE,
3055         {
3056             {"http://google.com/",S_OK,FALSE},
3057             {"google.com",S_OK,FALSE},
3058             {"http://google.com/",S_OK,FALSE},
3059             {"google.com",S_OK,FALSE},
3060             {"",S_FALSE,FALSE},
3061             {"",S_FALSE,FALSE},
3062             {"google.com",S_OK,FALSE},
3063             {"",S_FALSE,FALSE},
3064             {"/",S_OK,FALSE},
3065             {"/",S_OK,FALSE},
3066             {"",S_FALSE,FALSE},
3067             {"http://google.com/",S_OK,FALSE},
3068             {"http",S_OK,FALSE},
3069             {"",S_FALSE,FALSE},
3070             {"",S_FALSE,FALSE}
3071         },
3072         {
3073             {Uri_HOST_DNS,S_OK,FALSE},
3074             {80,S_OK,FALSE},
3075             {URL_SCHEME_HTTP,S_OK,FALSE},
3076             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3077         }
3078     },
3079     {   "http://g\noogle.co\rm/\n\n\n", Uri_CREATE_NO_PRE_PROCESS_HTML_URI, S_OK, FALSE,
3080         {
3081             {"http://g%0aoogle.co%0dm/%0A%0A%0A",S_OK,FALSE},
3082             {"g%0aoogle.co%0dm",S_OK,FALSE},
3083             {"http://g%0aoogle.co%0dm/%0A%0A%0A",S_OK,FALSE},
3084             {"g%0aoogle.co%0dm",S_OK,FALSE},
3085             {"",S_FALSE,FALSE},
3086             {"",S_FALSE,FALSE},
3087             {"g%0aoogle.co%0dm",S_OK,FALSE},
3088             {"",S_FALSE,FALSE},
3089             {"/%0A%0A%0A",S_OK,FALSE},
3090             {"/%0A%0A%0A",S_OK,FALSE},
3091             {"",S_FALSE,FALSE},
3092             {"http://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3093             {"http",S_OK,FALSE},
3094             {"",S_FALSE,FALSE},
3095             {"",S_FALSE,FALSE}
3096         },
3097         {
3098             {Uri_HOST_DNS,S_OK,FALSE},
3099             {80,S_OK,FALSE},
3100             {URL_SCHEME_HTTP,S_OK,FALSE},
3101             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3102         }
3103     },
3104     {   "zip://g\noogle.co\rm/\n\n\n", Uri_CREATE_NO_PRE_PROCESS_HTML_URI, S_OK, FALSE,
3105         {
3106             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3107             {"g\noogle.co\rm",S_OK,FALSE},
3108             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3109             {"g\noogle.co\rm",S_OK,FALSE},
3110             {"",S_FALSE,FALSE},
3111             {"",S_FALSE,FALSE},
3112             {"g\noogle.co\rm",S_OK,FALSE},
3113             {"",S_FALSE,FALSE},
3114             {"/\n\n\n",S_OK,FALSE},
3115             {"/\n\n\n",S_OK,FALSE},
3116             {"",S_FALSE,FALSE},
3117             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3118             {"zip",S_OK,FALSE},
3119             {"",S_FALSE,FALSE},
3120             {"",S_FALSE,FALSE}
3121         },
3122         {
3123             {Uri_HOST_DNS,S_OK,FALSE},
3124             {0,S_FALSE,FALSE},
3125             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3126             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3127         }
3128     },
3129     /* Since file URLs are usually hierarchical, it returns an empty string
3130      * for the absolute URI property since it was declared as an opaque URI.
3131      */
3132     {   "file:index.html", 0, S_OK, FALSE,
3133         {
3134             {"",S_FALSE,FALSE},
3135             {"",S_FALSE,FALSE},
3136             {"file:index.html",S_OK,FALSE},
3137             {"",S_FALSE,FALSE},
3138             {".html",S_OK,FALSE},
3139             {"",S_FALSE,FALSE},
3140             {"",S_FALSE,FALSE},
3141             {"",S_FALSE,FALSE},
3142             {"index.html",S_OK,FALSE},
3143             {"index.html",S_OK,FALSE},
3144             {"",S_FALSE,FALSE},
3145             {"file:index.html",S_OK,FALSE},
3146             {"file",S_OK,FALSE},
3147             {"",S_FALSE,FALSE},
3148             {"",S_FALSE,FALSE}
3149         },
3150         {
3151             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3152             {0,S_FALSE,FALSE},
3153             {URL_SCHEME_FILE,S_OK,FALSE},
3154             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3155         }
3156     },
3157     /* Doesn't have an absolute since it's opaque, but gets it port set. */
3158     {   "http:test.com/index.html", 0, S_OK, FALSE,
3159         {
3160             {"",S_FALSE,FALSE},
3161             {"",S_FALSE,FALSE},
3162             {"http:test.com/index.html",S_OK,FALSE},
3163             {"",S_FALSE,FALSE},
3164             {".html",S_OK,FALSE},
3165             {"",S_FALSE,FALSE},
3166             {"",S_FALSE,FALSE},
3167             {"",S_FALSE,FALSE},
3168             {"test.com/index.html",S_OK,FALSE},
3169             {"test.com/index.html",S_OK,FALSE},
3170             {"",S_FALSE,FALSE},
3171             {"http:test.com/index.html",S_OK,FALSE},
3172             {"http",S_OK,FALSE},
3173             {"",S_FALSE,FALSE},
3174             {"",S_FALSE,FALSE}
3175         },
3176         {
3177             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3178             {80,S_OK,FALSE},
3179             {URL_SCHEME_HTTP,S_OK,FALSE},
3180             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3181         }
3182     },
3183     {   "ftp:test.com/index.html", 0, S_OK, FALSE,
3184         {
3185             {"",S_FALSE,FALSE},
3186             {"",S_FALSE,FALSE},
3187             {"ftp:test.com/index.html",S_OK,FALSE},
3188             {"",S_FALSE,FALSE},
3189             {".html",S_OK,FALSE},
3190             {"",S_FALSE,FALSE},
3191             {"",S_FALSE,FALSE},
3192             {"",S_FALSE,FALSE},
3193             {"test.com/index.html",S_OK,FALSE},
3194             {"test.com/index.html",S_OK,FALSE},
3195             {"",S_FALSE,FALSE},
3196             {"ftp:test.com/index.html",S_OK,FALSE},
3197             {"ftp",S_OK,FALSE},
3198             {"",S_FALSE,FALSE},
3199             {"",S_FALSE,FALSE}
3200         },
3201         {
3202             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3203             {21,S_OK,FALSE},
3204             {URL_SCHEME_FTP,S_OK,FALSE},
3205             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3206         }
3207     },
3208     {   "file://C|/test.mp3", 0, S_OK, FALSE,
3209         {
3210             {"file:///C:/test.mp3",S_OK,FALSE},
3211             {"",S_FALSE,FALSE},
3212             {"file:///C:/test.mp3",S_OK,FALSE},
3213             {"",S_FALSE,FALSE},
3214             {".mp3",S_OK,FALSE},
3215             {"",S_FALSE,FALSE},
3216             {"",S_FALSE,FALSE},
3217             {"",S_FALSE,FALSE},
3218             {"/C:/test.mp3",S_OK,FALSE},
3219             {"/C:/test.mp3",S_OK,FALSE},
3220             {"",S_FALSE,FALSE},
3221             {"file://C|/test.mp3",S_OK,FALSE},
3222             {"file",S_OK,FALSE},
3223             {"",S_FALSE,FALSE},
3224             {"",S_FALSE,FALSE}
3225         },
3226         {
3227             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3228             {0,S_FALSE,FALSE},
3229             {URL_SCHEME_FILE,S_OK,FALSE},
3230             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3231         }
3232     },
3233     {   "file:///C|/test.mp3", 0, S_OK, FALSE,
3234         {
3235             {"file:///C:/test.mp3",S_OK,FALSE},
3236             {"",S_FALSE,FALSE},
3237             {"file:///C:/test.mp3",S_OK,FALSE},
3238             {"",S_FALSE,FALSE},
3239             {".mp3",S_OK,FALSE},
3240             {"",S_FALSE,FALSE},
3241             {"",S_FALSE,FALSE},
3242             {"",S_FALSE,FALSE},
3243             {"/C:/test.mp3",S_OK,FALSE},
3244             {"/C:/test.mp3",S_OK,FALSE},
3245             {"",S_FALSE,FALSE},
3246             {"file:///C|/test.mp3",S_OK,FALSE},
3247             {"file",S_OK,FALSE},
3248             {"",S_FALSE,FALSE},
3249             {"",S_FALSE,FALSE}
3250         },
3251         {
3252             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3253             {0,S_FALSE,FALSE},
3254             {URL_SCHEME_FILE,S_OK,FALSE},
3255             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3256         }
3257     },
3258     /* Extra '/' isn't added before "c:" since USE_DOS_PATH is set and '/' are converted
3259      * to '\\'.
3260      */
3261     {   "file://c:/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3262         {
3263             {"file://c:\\dir\\index.html",S_OK,FALSE},
3264             {"",S_FALSE,FALSE},
3265             {"file://c:\\dir\\index.html",S_OK,FALSE},
3266             {"",S_FALSE,FALSE},
3267             {".html",S_OK,FALSE},
3268             {"",S_FALSE,FALSE},
3269             {"",S_FALSE,FALSE},
3270             {"",S_FALSE,FALSE},
3271             {"c:\\dir\\index.html",S_OK,FALSE},
3272             {"c:\\dir\\index.html",S_OK,FALSE},
3273             {"",S_FALSE,FALSE},
3274             {"file://c:/dir/index.html",S_OK,FALSE},
3275             {"file",S_OK,FALSE},
3276             {"",S_FALSE,FALSE},
3277             {"",S_FALSE,FALSE}
3278         },
3279         {
3280             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3281             {0,S_FALSE,FALSE},
3282             {URL_SCHEME_FILE,S_OK,FALSE},
3283             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3284         }
3285     },
3286     /* Extra '/' after "file://" is removed. */
3287     {   "file:///c:/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3288         {
3289             {"file://c:\\dir\\index.html",S_OK,FALSE},
3290             {"",S_FALSE,FALSE},
3291             {"file://c:\\dir\\index.html",S_OK,FALSE},
3292             {"",S_FALSE,FALSE},
3293             {".html",S_OK,FALSE},
3294             {"",S_FALSE,FALSE},
3295             {"",S_FALSE,FALSE},
3296             {"",S_FALSE,FALSE},
3297             {"c:\\dir\\index.html",S_OK,FALSE},
3298             {"c:\\dir\\index.html",S_OK,FALSE},
3299             {"",S_FALSE,FALSE},
3300             {"file:///c:/dir/index.html",S_OK,FALSE},
3301             {"file",S_OK,FALSE},
3302             {"",S_FALSE,FALSE},
3303             {"",S_FALSE,FALSE}
3304         },
3305         {
3306             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3307             {0,S_FALSE,FALSE},
3308             {URL_SCHEME_FILE,S_OK,FALSE},
3309             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3310         }
3311     },
3312     /* Allow more characters when Uri_CREATE_FILE_USE_DOS_PATH is specified */
3313     {   "file:///c:/dir\\%%61%20%5Fname/file%2A.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3314         {
3315             {"file://c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3316             {"",S_FALSE,FALSE},
3317             {"file://c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3318             {"",S_FALSE,FALSE},
3319             {".html",S_OK,FALSE},
3320             {"",S_FALSE,FALSE},
3321             {"",S_FALSE,FALSE},
3322             {"",S_FALSE,FALSE},
3323             {"c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3324             {"c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3325             {"",S_FALSE,FALSE},
3326             {"file:///c:/dir\\%%61%20%5Fname/file%2A.html",S_OK,FALSE},
3327             {"file",S_OK,FALSE},
3328             {"",S_FALSE,FALSE},
3329             {"",S_FALSE,FALSE}
3330         },
3331         {
3332             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3333             {0,S_FALSE,FALSE},
3334             {URL_SCHEME_FILE,S_OK,FALSE},
3335             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3336         }
3337     },
3338     {   "file://c|/dir\\index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3339         {
3340             {"file://c:\\dir\\index.html",S_OK,FALSE},
3341             {"",S_FALSE,FALSE},
3342             {"file://c:\\dir\\index.html",S_OK,FALSE},
3343             {"",S_FALSE,FALSE},
3344             {".html",S_OK,FALSE},
3345             {"",S_FALSE,FALSE},
3346             {"",S_FALSE,FALSE},
3347             {"",S_FALSE,FALSE},
3348             {"c:\\dir\\index.html",S_OK,FALSE},
3349             {"c:\\dir\\index.html",S_OK,FALSE},
3350             {"",S_FALSE,FALSE},
3351             {"file://c|/dir\\index.html",S_OK,FALSE},
3352             {"file",S_OK,FALSE},
3353             {"",S_FALSE,FALSE},
3354             {"",S_FALSE,FALSE}
3355         },
3356         {
3357             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3358             {0,S_FALSE,FALSE},
3359             {URL_SCHEME_FILE,S_OK,FALSE},
3360             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3361         }
3362     },
3363     /* The backslashes after the scheme name are converted to forward slashes. */
3364     {   "file:\\\\c:\\dir\\index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3365         {
3366             {"file://c:\\dir\\index.html",S_OK,FALSE},
3367             {"",S_FALSE,FALSE},
3368             {"file://c:\\dir\\index.html",S_OK,FALSE},
3369             {"",S_FALSE,FALSE},
3370             {".html",S_OK,FALSE},
3371             {"",S_FALSE,FALSE},
3372             {"",S_FALSE,FALSE},
3373             {"",S_FALSE,FALSE},
3374             {"c:\\dir\\index.html",S_OK,FALSE},
3375             {"c:\\dir\\index.html",S_OK,FALSE},
3376             {"",S_FALSE,FALSE},
3377             {"file:\\\\c:\\dir\\index.html",S_OK,FALSE},
3378             {"file",S_OK,FALSE},
3379             {"",S_FALSE,FALSE},
3380             {"",S_FALSE,FALSE}
3381         },
3382         {
3383             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3384             {0,S_FALSE,FALSE},
3385             {URL_SCHEME_FILE,S_OK,FALSE},
3386             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3387         }
3388     },
3389     {   "file:\\\\c:/dir/index.html", 0, S_OK, FALSE,
3390         {
3391             {"file:///c:/dir/index.html",S_OK,FALSE},
3392             {"",S_FALSE,FALSE},
3393             {"file:///c:/dir/index.html",S_OK,FALSE},
3394             {"",S_FALSE,FALSE},
3395             {".html",S_OK,FALSE},
3396             {"",S_FALSE,FALSE},
3397             {"",S_FALSE,FALSE},
3398             {"",S_FALSE,FALSE},
3399             {"/c:/dir/index.html",S_OK,FALSE},
3400             {"/c:/dir/index.html",S_OK,FALSE},
3401             {"",S_FALSE,FALSE},
3402             {"file:\\\\c:/dir/index.html",S_OK,FALSE},
3403             {"file",S_OK,FALSE},
3404             {"",S_FALSE,FALSE},
3405             {"",S_FALSE,FALSE}
3406         },
3407         {
3408             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3409             {0,S_FALSE,FALSE},
3410             {URL_SCHEME_FILE,S_OK,FALSE},
3411             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3412         }
3413     },
3414     {   "http:\\\\google.com", 0, S_OK, FALSE,
3415         {
3416             {"http://google.com/",S_OK,FALSE},
3417             {"google.com",S_OK,FALSE},
3418             {"http://google.com/",S_OK,FALSE},
3419             {"google.com",S_OK,FALSE},
3420             {"",S_FALSE,FALSE},
3421             {"",S_FALSE,FALSE},
3422             {"google.com",S_OK,FALSE},
3423             {"",S_FALSE,FALSE},
3424             {"/",S_OK,FALSE},
3425             {"/",S_OK,FALSE},
3426             {"",S_FALSE,FALSE},
3427             {"http:\\\\google.com",S_OK,FALSE},
3428             {"http",S_OK,FALSE},
3429             {"",S_FALSE,FALSE},
3430             {"",S_FALSE,FALSE}
3431         },
3432         {
3433             {Uri_HOST_DNS,S_OK,FALSE},
3434             {80,S_OK,FALSE},
3435             {URL_SCHEME_HTTP,S_OK,FALSE},
3436             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3437         }
3438     },
3439     /* the "\\\\" aren't converted to "//" for unknown scheme types and it's considered opaque. */
3440     {   "zip:\\\\google.com", 0, S_OK, FALSE,
3441         {
3442             {"zip:\\\\google.com",S_OK,FALSE},
3443             {"",S_FALSE,FALSE},
3444             {"zip:\\\\google.com",S_OK,FALSE},
3445             {"",S_FALSE,FALSE},
3446             {".com",S_OK,FALSE},
3447             {"",S_FALSE,FALSE},
3448             {"",S_FALSE,FALSE},
3449             {"",S_FALSE,FALSE},
3450             {"\\\\google.com",S_OK,FALSE},
3451             {"\\\\google.com",S_OK,FALSE},
3452             {"",S_FALSE,FALSE},
3453             {"zip:\\\\google.com",S_OK,FALSE},
3454             {"zip",S_OK,FALSE},
3455             {"",S_FALSE,FALSE},
3456             {"",S_FALSE,FALSE}
3457         },
3458         {
3459             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3460             {0,S_FALSE,FALSE},
3461             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3462             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3463         }
3464     },
3465     /* Dot segments aren't removed. */
3466     {   "file://c:\\dir\\../..\\./index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3467         {
3468             {"file://c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3469             {"",S_FALSE,FALSE},
3470             {"file://c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3471             {"",S_FALSE,FALSE},
3472             {".html",S_OK,FALSE},
3473             {"",S_FALSE,FALSE},
3474             {"",S_FALSE,FALSE},
3475             {"",S_FALSE,FALSE},
3476             {"c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3477             {"c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3478             {"",S_FALSE,FALSE},
3479             {"file://c:\\dir\\../..\\./index.html",S_OK,FALSE},
3480             {"file",S_OK,FALSE},
3481             {"",S_FALSE,FALSE},
3482             {"",S_FALSE,FALSE}
3483         },
3484         {
3485             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3486             {0,S_FALSE,FALSE},
3487             {URL_SCHEME_FILE,S_OK,FALSE},
3488             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3489         }
3490     },
3491     /* Forbidden characters aren't percent encoded. */
3492     {   "file://c:\\dir\\i^|ndex.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3493         {
3494             {"file://c:\\dir\\i^|ndex.html",S_OK,FALSE},
3495             {"",S_FALSE,FALSE},
3496             {"file://c:\\dir\\i^|ndex.html",S_OK,FALSE},
3497             {"",S_FALSE,FALSE},
3498             {".html",S_OK,FALSE},
3499             {"",S_FALSE,FALSE},
3500             {"",S_FALSE,FALSE},
3501             {"",S_FALSE,FALSE},
3502             {"c:\\dir\\i^|ndex.html",S_OK,FALSE},
3503             {"c:\\dir\\i^|ndex.html",S_OK,FALSE},
3504             {"",S_FALSE,FALSE},
3505             {"file://c:\\dir\\i^|ndex.html",S_OK,FALSE},
3506             {"file",S_OK,FALSE},
3507             {"",S_FALSE,FALSE},
3508             {"",S_FALSE,FALSE}
3509         },
3510         {
3511             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3512             {0,S_FALSE,FALSE},
3513             {URL_SCHEME_FILE,S_OK,FALSE},
3514             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3515         }
3516     },
3517     /* The '\' are still converted to '/' even though it's an opaque file URI. */
3518     {   "file:c:\\dir\\../..\\index.html", 0, S_OK, FALSE,
3519         {
3520             {"",S_FALSE,FALSE},
3521             {"",S_FALSE,FALSE},
3522             {"file:c:/dir/../../index.html",S_OK,FALSE},
3523             {"",S_FALSE,FALSE},
3524             {".html",S_OK,FALSE},
3525             {"",S_FALSE,FALSE},
3526             {"",S_FALSE,FALSE},
3527             {"",S_FALSE,FALSE},
3528             {"c:/dir/../../index.html",S_OK,FALSE},
3529             {"c:/dir/../../index.html",S_OK,FALSE},
3530             {"",S_FALSE,FALSE},
3531             {"file:c:\\dir\\../..\\index.html",S_OK,FALSE},
3532             {"file",S_OK,FALSE},
3533             {"",S_FALSE,FALSE},
3534             {"",S_FALSE,FALSE}
3535         },
3536         {
3537             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3538             {0,S_FALSE,FALSE},
3539             {URL_SCHEME_FILE,S_OK,FALSE},
3540             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3541         }
3542     },
3543     /* '/' are still converted to '\' even though it's an opaque URI. */
3544     {   "file:c:/dir\\../..\\index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3545         {
3546             {"",S_FALSE,FALSE},
3547             {"",S_FALSE,FALSE},
3548             {"file:c:\\dir\\..\\..\\index.html",S_OK,FALSE},
3549             {"",S_FALSE,FALSE},
3550             {".html",S_OK,FALSE},
3551             {"",S_FALSE,FALSE},
3552             {"",S_FALSE,FALSE},
3553             {"",S_FALSE,FALSE},
3554             {"c:\\dir\\..\\..\\index.html",S_OK,FALSE},
3555             {"c:\\dir\\..\\..\\index.html",S_OK,FALSE},
3556             {"",S_FALSE,FALSE},
3557             {"file:c:/dir\\../..\\index.html",S_OK,FALSE},
3558             {"file",S_OK,FALSE},
3559             {"",S_FALSE,FALSE},
3560             {"",S_FALSE,FALSE}
3561         },
3562         {
3563             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3564             {0,S_FALSE,FALSE},
3565             {URL_SCHEME_FILE,S_OK,FALSE},
3566             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3567         }
3568     },
3569     /* Forbidden characters aren't percent encoded. */
3570     {   "file:c:\\in^|dex.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3571         {
3572             {"",S_FALSE,FALSE},
3573             {"",S_FALSE,FALSE},
3574             {"file:c:\\in^|dex.html",S_OK,FALSE},
3575             {"",S_FALSE,FALSE},
3576             {".html",S_OK,FALSE},
3577             {"",S_FALSE,FALSE},
3578             {"",S_FALSE,FALSE},
3579             {"",S_FALSE,FALSE},
3580             {"c:\\in^|dex.html",S_OK,FALSE},
3581             {"c:\\in^|dex.html",S_OK,FALSE},
3582             {"",S_FALSE,FALSE},
3583             {"file:c:\\in^|dex.html",S_OK,FALSE},
3584             {"file",S_OK,FALSE},
3585             {"",S_FALSE,FALSE},
3586             {"",S_FALSE,FALSE}
3587         },
3588         {
3589             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3590             {0,S_FALSE,FALSE},
3591             {URL_SCHEME_FILE,S_OK,FALSE},
3592             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3593         }
3594     },
3595     /* Doesn't have a UserName since the ':' appears at the beginning of the
3596      * userinfo section.
3597      */
3598     {   "http://:password@gov.uk", 0, S_OK, FALSE,
3599         {
3600             {"http://:password@gov.uk/",S_OK,FALSE},
3601             {":password@gov.uk",S_OK,FALSE},
3602             {"http://gov.uk/",S_OK,FALSE},
3603             {"",S_FALSE,FALSE},
3604             {"",S_FALSE,FALSE},
3605             {"",S_FALSE,FALSE},
3606             {"gov.uk",S_OK,FALSE},
3607             {"password",S_OK,FALSE},
3608             {"/",S_OK,FALSE},
3609             {"/",S_OK,FALSE},
3610             {"",S_FALSE,FALSE},
3611             {"http://:password@gov.uk",S_OK,FALSE},
3612             {"http",S_OK,FALSE},
3613             {":password",S_OK,FALSE},
3614             {"",S_FALSE,FALSE}
3615         },
3616         {
3617             {Uri_HOST_DNS,S_OK,FALSE},
3618             {80,S_OK,FALSE},
3619             {URL_SCHEME_HTTP,S_OK,FALSE},
3620             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3621         }
3622     },
3623     /* Has a UserName since the userinfo section doesn't contain a password. */
3624     {   "http://@gov.uk", 0, S_OK, FALSE,
3625         {
3626             {"http://gov.uk/",S_OK,FALSE,"http://@gov.uk/"},
3627             {"@gov.uk",S_OK,FALSE},
3628             {"http://gov.uk/",S_OK,FALSE},
3629             {"",S_FALSE,FALSE},
3630             {"",S_FALSE,FALSE},
3631             {"",S_FALSE,FALSE},
3632             {"gov.uk",S_OK,FALSE},
3633             {"",S_FALSE,FALSE},
3634             {"/",S_OK,FALSE},
3635             {"/",S_OK,FALSE},
3636             {"",S_FALSE,FALSE},
3637             {"http://@gov.uk",S_OK,FALSE},
3638             {"http",S_OK,FALSE},
3639             {"",S_OK,FALSE},
3640             {"",S_OK,FALSE}
3641         },
3642         {
3643             {Uri_HOST_DNS,S_OK,FALSE},
3644             {80,S_OK,FALSE},
3645             {URL_SCHEME_HTTP,S_OK,FALSE},
3646             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3647         }
3648     },
3649     /* ":@" not included in the absolute URI. */
3650     {   "http://:@gov.uk", 0, S_OK, FALSE,
3651         {
3652             {"http://gov.uk/",S_OK,FALSE,"http://:@gov.uk/"},
3653             {":@gov.uk",S_OK,FALSE},
3654             {"http://gov.uk/",S_OK,FALSE},
3655             {"",S_FALSE,FALSE},
3656             {"",S_FALSE,FALSE},
3657             {"",S_FALSE,FALSE},
3658             {"gov.uk",S_OK,FALSE},
3659             {"",S_OK,FALSE},
3660             {"/",S_OK,FALSE},
3661             {"/",S_OK,FALSE},
3662             {"",S_FALSE,FALSE},
3663             {"http://:@gov.uk",S_OK,FALSE},
3664             {"http",S_OK,FALSE},
3665             {":",S_OK,FALSE},
3666             {"",S_FALSE,FALSE}
3667         },
3668         {
3669             {Uri_HOST_DNS,S_OK,FALSE},
3670             {80,S_OK,FALSE},
3671             {URL_SCHEME_HTTP,S_OK,FALSE},
3672             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3673         }
3674     },
3675     /* '@' is included because it's an unknown scheme type. */
3676     {   "zip://@gov.uk", 0, S_OK, FALSE,
3677         {
3678             {"zip://@gov.uk/",S_OK,FALSE},
3679             {"@gov.uk",S_OK,FALSE},
3680             {"zip://@gov.uk/",S_OK,FALSE},
3681             {"",S_FALSE,FALSE},
3682             {"",S_FALSE,FALSE},
3683             {"",S_FALSE,FALSE},
3684             {"gov.uk",S_OK,FALSE},
3685             {"",S_FALSE,FALSE},
3686             {"/",S_OK,FALSE},
3687             {"/",S_OK,FALSE},
3688             {"",S_FALSE,FALSE},
3689             {"zip://@gov.uk",S_OK,FALSE},
3690             {"zip",S_OK,FALSE},
3691             {"",S_OK,FALSE},
3692             {"",S_OK,FALSE}
3693         },
3694         {
3695             {Uri_HOST_DNS,S_OK,FALSE},
3696             {0,S_FALSE,FALSE},
3697             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3698             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3699         }
3700     },
3701     /* ":@" are included because it's an unknown scheme type. */
3702     {   "zip://:@gov.uk", 0, S_OK, FALSE,
3703         {
3704             {"zip://:@gov.uk/",S_OK,FALSE},
3705             {":@gov.uk",S_OK,FALSE},
3706             {"zip://:@gov.uk/",S_OK,FALSE},
3707             {"",S_FALSE,FALSE},
3708             {"",S_FALSE,FALSE},
3709             {"",S_FALSE,FALSE},
3710             {"gov.uk",S_OK,FALSE},
3711             {"",S_OK,FALSE},
3712             {"/",S_OK,FALSE},
3713             {"/",S_OK,FALSE},
3714             {"",S_FALSE,FALSE},
3715             {"zip://:@gov.uk",S_OK,FALSE},
3716             {"zip",S_OK,FALSE},
3717             {":",S_OK,FALSE},
3718             {"",S_FALSE,FALSE}
3719         },
3720         {
3721             {Uri_HOST_DNS,S_OK,FALSE},
3722             {0,S_FALSE,FALSE},
3723             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3724             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3725         }
3726     },
3727     {   "about:blank", 0, S_OK, FALSE,
3728         {
3729             {"about:blank",S_OK,FALSE},
3730             {"",S_FALSE,FALSE},
3731             {"about:blank",S_OK,FALSE},
3732             {"",S_FALSE,FALSE},
3733             {"",S_FALSE,FALSE},
3734             {"",S_FALSE,FALSE},
3735             {"",S_FALSE,FALSE},
3736             {"",S_FALSE,FALSE},
3737             {"blank",S_OK,FALSE},
3738             {"blank",S_OK,FALSE},
3739             {"",S_FALSE,FALSE},
3740             {"about:blank",S_OK,FALSE},
3741             {"about",S_OK,FALSE},
3742             {"",S_FALSE,FALSE},
3743             {"",S_FALSE,FALSE}
3744         },
3745         {
3746             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3747             {0,S_FALSE,FALSE},
3748             {URL_SCHEME_ABOUT,S_OK,FALSE},
3749             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3750         }
3751     },
3752     {   "mk:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",0,S_OK,FALSE,
3753         {
3754             {"mk:@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3755             {"",S_FALSE,FALSE},
3756             {"mk:@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3757             {"",S_FALSE,FALSE},
3758             {".htm",S_OK,FALSE},
3759             {"",S_FALSE,FALSE},
3760             {"",S_FALSE,FALSE},
3761             {"",S_FALSE,FALSE},
3762             {"@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3763             {"@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3764             {"",S_FALSE,FALSE},
3765             {"mk:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3766             {"mk",S_OK,FALSE},
3767             {"",S_FALSE,FALSE},
3768             {"",S_FALSE,FALSE}
3769         },
3770         {
3771             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3772             {0,S_FALSE,FALSE},
3773             {URL_SCHEME_MK,S_OK,FALSE},
3774             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3775         }
3776     },
3777     {   "mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",0,S_OK,FALSE,
3778         {
3779             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3780             {"",S_FALSE,FALSE},
3781             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3782             {"",S_FALSE,FALSE},
3783             {".htm",S_OK,FALSE},
3784             {"",S_FALSE,FALSE},
3785             {"",S_FALSE,FALSE},
3786             {"",S_FALSE,FALSE},
3787             {"@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3788             {"@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3789             {"",S_FALSE,FALSE},
3790             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3791             {"mk",S_OK,FALSE},
3792             {"",S_FALSE,FALSE},
3793             {"",S_FALSE,FALSE}
3794         },
3795         {
3796             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3797             {0,S_FALSE,FALSE},
3798             {URL_SCHEME_MK,S_OK,FALSE},
3799             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3800         }
3801     },
3802     /* Two '\' are added to the URI when USE_DOS_PATH is set, and it's a UNC path. */
3803     {   "file://server/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3804         {
3805             {"file://\\\\server\\dir\\index.html",S_OK,FALSE},
3806             {"server",S_OK,FALSE},
3807             {"file://\\\\server\\dir\\index.html",S_OK,FALSE},
3808             {"",S_FALSE,FALSE},
3809             {".html",S_OK,FALSE},
3810             {"",S_FALSE,FALSE},
3811             {"server",S_OK,FALSE},
3812             {"",S_FALSE,FALSE},
3813             {"\\dir\\index.html",S_OK,FALSE},
3814             {"\\dir\\index.html",S_OK,FALSE},
3815             {"",S_FALSE,FALSE},
3816             {"file://server/dir/index.html",S_OK,FALSE},
3817             {"file",S_OK,FALSE},
3818             {"",S_FALSE,FALSE},
3819             {"",S_FALSE,FALSE}
3820         },
3821         {
3822             {Uri_HOST_DNS,S_OK,FALSE},
3823             {0,S_FALSE,FALSE},
3824             {URL_SCHEME_FILE,S_OK,FALSE},
3825             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3826         }
3827     },
3828     /* When CreateUri generates an IUri, it still displays the default port in the
3829      * authority.
3830      */
3831     {   "http://google.com:80/", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
3832         {
3833             {"http://google.com:80/",S_OK,FALSE},
3834             {"google.com:80",S_OK,FALSE},
3835             {"http://google.com:80/",S_OK,FALSE},
3836             {"google.com",S_OK,FALSE},
3837             {"",S_FALSE,FALSE},
3838             {"",S_FALSE,FALSE},
3839             {"google.com",S_OK,FALSE},
3840             {"",S_FALSE,FALSE},
3841             {"/",S_OK,FALSE},
3842             {"/",S_OK,FALSE},
3843             {"",S_FALSE,FALSE},
3844             {"http://google.com:80/",S_OK,FALSE},
3845             {"http",S_OK,FALSE},
3846             {"",S_FALSE,FALSE},
3847             {"",S_FALSE,FALSE}
3848         },
3849         {
3850             {Uri_HOST_DNS,S_OK,FALSE},
3851             {80,S_OK,FALSE},
3852             {URL_SCHEME_HTTP,S_OK,FALSE},
3853             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3854         }
3855     },
3856     /* For res URIs the host is everything up until the first '/'. */
3857     {   "res://C:\\dir\\file.exe/DATA/test.html", 0, S_OK, FALSE,
3858         {
3859             {"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
3860             {"C:\\dir\\file.exe",S_OK,FALSE},
3861             {"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
3862             {"",S_FALSE,FALSE},
3863             {".html",S_OK,FALSE},
3864             {"",S_FALSE,FALSE},
3865             {"C:\\dir\\file.exe",S_OK,FALSE},
3866             {"",S_FALSE,FALSE},
3867             {"/DATA/test.html",S_OK,FALSE},
3868             {"/DATA/test.html",S_OK,FALSE},
3869             {"",S_FALSE,FALSE},
3870             {"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
3871             {"res",S_OK,FALSE},
3872             {"",S_FALSE,FALSE},
3873             {"",S_FALSE,FALSE}
3874         },
3875         {
3876             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3877             {0,S_FALSE,FALSE},
3878             {URL_SCHEME_RES,S_OK,FALSE},
3879             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3880         }
3881     },
3882     /* Res URI can contain a '|' in the host name. */
3883     {   "res://c:\\di|r\\file.exe/test", 0, S_OK, FALSE,
3884         {
3885             {"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
3886             {"c:\\di|r\\file.exe",S_OK,FALSE},
3887             {"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
3888             {"",S_FALSE,FALSE},
3889             {"",S_FALSE,FALSE},
3890             {"",S_FALSE,FALSE},
3891             {"c:\\di|r\\file.exe",S_OK,FALSE},
3892             {"",S_FALSE,FALSE},
3893             {"/test",S_OK,FALSE},
3894             {"/test",S_OK,FALSE},
3895             {"",S_FALSE,FALSE},
3896             {"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
3897             {"res",S_OK,FALSE},
3898             {"",S_FALSE,FALSE},
3899             {"",S_FALSE,FALSE}
3900         },
3901         {
3902             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3903             {0,S_FALSE,FALSE},
3904             {URL_SCHEME_RES,S_OK,FALSE},
3905             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3906         }
3907     },
3908     /* Res URIs can have invalid percent encoded values. */
3909     {   "res://c:\\dir%xx\\file.exe/test", 0, S_OK, FALSE,
3910         {
3911             {"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
3912             {"c:\\dir%xx\\file.exe",S_OK,FALSE},
3913             {"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
3914             {"",S_FALSE,FALSE},
3915             {"",S_FALSE,FALSE},
3916             {"",S_FALSE,FALSE},
3917             {"c:\\dir%xx\\file.exe",S_OK,FALSE},
3918             {"",S_FALSE,FALSE},
3919             {"/test",S_OK,FALSE},
3920             {"/test",S_OK,FALSE},
3921             {"",S_FALSE,FALSE},
3922             {"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
3923             {"res",S_OK,FALSE},
3924             {"",S_FALSE,FALSE},
3925             {"",S_FALSE,FALSE}
3926         },
3927         {
3928             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3929             {0,S_FALSE,FALSE},
3930             {URL_SCHEME_RES,S_OK,FALSE},
3931             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3932         }
3933     },
3934     /* Res doesn't get forbidden characters percent encoded in it's path. */
3935     {   "res://c:\\test/tes<|>t", 0, S_OK, FALSE,
3936         {
3937             {"res://c:\\test/tes<|>t",S_OK,FALSE},
3938             {"c:\\test",S_OK,FALSE},
3939             {"res://c:\\test/tes<|>t",S_OK,FALSE},
3940             {"",S_FALSE,FALSE},
3941             {"",S_FALSE,FALSE},
3942             {"",S_FALSE,FALSE},
3943             {"c:\\test",S_OK,FALSE},
3944             {"",S_FALSE,FALSE},
3945             {"/tes<|>t",S_OK,FALSE},
3946             {"/tes<|>t",S_OK,FALSE},
3947             {"",S_FALSE,FALSE},
3948             {"res://c:\\test/tes<|>t",S_OK,FALSE},
3949             {"res",S_OK,FALSE},
3950             {"",S_FALSE,FALSE},
3951             {"",S_FALSE,FALSE}
3952         },
3953         {
3954             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3955             {0,S_FALSE,FALSE},
3956             {URL_SCHEME_RES,S_OK,FALSE},
3957             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3958         }
3959     }
3960 };
3961
3962 typedef struct _invalid_uri {
3963     const char* uri;
3964     DWORD       flags;
3965     BOOL        todo;
3966 } invalid_uri;
3967
3968 static const invalid_uri invalid_uri_tests[] = {
3969     /* Has to have a scheme name. */
3970     {"://www.winehq.org",0,FALSE},
3971     /* Window's doesn't like URI's which are implicitly file paths without the
3972      * ALLOW_IMPLICIT_FILE_SCHEME flag set.
3973      */
3974     {"C:/test/test.mp3",0,FALSE},
3975     {"\\\\Server/test/test.mp3",0,FALSE},
3976     {"C:/test/test.mp3",Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME,FALSE},
3977     {"\\\\Server/test/test.mp3",Uri_CREATE_ALLOW_RELATIVE,FALSE},
3978     /* Invalid schemes. */
3979     {"*abcd://not.valid.com",0,FALSE},
3980     {"*a*b*c*d://not.valid.com",0,FALSE},
3981     /* Not allowed to have invalid % encoded data. */
3982     {"ftp://google.co%XX/",0,FALSE},
3983     /* To many h16 components. */
3984     {"http://[1:2:3:4:5:6:7:8:9]",0,FALSE},
3985     /* Not enough room for IPv4 address. */
3986     {"http://[1:2:3:4:5:6:7:192.0.1.0]",0,FALSE},
3987     /* Not enough h16 components. */
3988     {"http://[1:2:3:4]",0,FALSE},
3989     /* Not enough components including IPv4. */
3990     {"http://[1:192.0.1.0]",0,FALSE},
3991     /* Not allowed to have partial IPv4 in IPv6. */
3992     {"http://[::192.0]",0,FALSE},
3993     /* Can't have elision of 1 h16 at beginning of address. */
3994     {"http://[::2:3:4:5:6:7:8]",0,FALSE},
3995     /* Can't have elision of 1 h16 at end of address. */
3996     {"http://[1:2:3:4:5:6:7::]",0,FALSE},
3997     /* Expects a valid IP Literal. */
3998     {"ftp://[not.valid.uri]/",0,FALSE},
3999     /* Expects valid port for a known scheme type. */
4000     {"ftp://www.winehq.org:123fgh",0,FALSE},
4001     /* Port exceeds USHORT_MAX for known scheme type. */
4002     {"ftp://www.winehq.org:65536",0,FALSE},
4003     /* Invalid port with IPv4 address. */
4004     {"http://www.winehq.org:1abcd",0,FALSE},
4005     /* Invalid port with IPv6 address. */
4006     {"http://[::ffff]:32xy",0,FALSE},
4007     /* Not allowed to have backslashes with NO_CANONICALIZE. */
4008     {"gopher://www.google.com\\test",Uri_CREATE_NO_CANONICALIZE,FALSE},
4009     /* Not allowed to have invalid % encoded data in opaque URI path. */
4010     {"news:test%XX",0,FALSE},
4011     {"mailto:wine@winehq%G8.com",0,FALSE},
4012     /* Known scheme types can't have invalid % encoded data in query string. */
4013     {"http://google.com/?query=te%xx",0,FALSE},
4014     /* Invalid % encoded data in fragment of know scheme type. */
4015     {"ftp://google.com/#Test%xx",0,FALSE},
4016     {"  http://google.com/",Uri_CREATE_NO_PRE_PROCESS_HTML_URI,FALSE},
4017     {"\n\nhttp://google.com/",Uri_CREATE_NO_PRE_PROCESS_HTML_URI,FALSE},
4018     {"file://c:\\test<test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4019     {"file://c:\\test>test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4020     {"file://c:\\test\"test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4021     {"file:c:\\test<test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4022     {"file:c:\\test>test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4023     {"file:c:\\test\"test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4024     /* res URIs aren't allowed to have forbidden dos path characters in the
4025      * hostname.
4026      */
4027     {"res://c:\\te<st\\test/test",0,FALSE},
4028     {"res://c:\\te>st\\test/test",0,FALSE},
4029     {"res://c:\\te\"st\\test/test",0,FALSE},
4030     {"res://c:\\test/te%xxst",0,FALSE}
4031 };
4032
4033 typedef struct _uri_equality {
4034     const char* a;
4035     DWORD       create_flags_a;
4036     BOOL        create_todo_a;
4037     const char* b;
4038     DWORD       create_flags_b;
4039     BOOL        create_todo_b;
4040     BOOL        equal;
4041     BOOL        todo;
4042 } uri_equality;
4043
4044 static const uri_equality equality_tests[] = {
4045     {
4046         "HTTP://www.winehq.org/test dir/./",0,FALSE,
4047         "http://www.winehq.org/test dir/../test dir/",0,FALSE,
4048         TRUE, FALSE
4049     },
4050     {
4051         /* http://www.winehq.org/test%20dir */
4052         "http://%77%77%77%2E%77%69%6E%65%68%71%2E%6F%72%67/%74%65%73%74%20%64%69%72",0,FALSE,
4053         "http://www.winehq.org/test dir",0,FALSE,
4054         TRUE, FALSE
4055     },
4056     {
4057         "c:\\test.mp3",Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME,FALSE,
4058         "file:///c:/test.mp3",0,FALSE,
4059         TRUE, FALSE
4060     },
4061     {
4062         "ftp://ftp.winehq.org/",0,FALSE,
4063         "ftp://ftp.winehq.org",0,FALSE,
4064         TRUE, FALSE
4065     },
4066     {
4067         "ftp://ftp.winehq.org/test/test2/../../testB/",0,FALSE,
4068         "ftp://ftp.winehq.org/t%45stB/",0,FALSE,
4069         FALSE, FALSE
4070     },
4071     {
4072         "http://google.com/TEST",0,FALSE,
4073         "http://google.com/test",0,FALSE,
4074         FALSE, FALSE
4075     },
4076     {
4077         "http://GOOGLE.com/",0,FALSE,
4078         "http://google.com/",0,FALSE,
4079         TRUE, FALSE
4080     },
4081     /* Performs case insensitive compare of host names (for known scheme types). */
4082     {
4083         "ftp://GOOGLE.com/",Uri_CREATE_NO_CANONICALIZE,FALSE,
4084         "ftp://google.com/",0,FALSE,
4085         TRUE, FALSE
4086     },
4087     {
4088         "zip://GOOGLE.com/",0,FALSE,
4089         "zip://google.com/",0,FALSE,
4090         FALSE, FALSE
4091     },
4092     {
4093         "file:///c:/TEST/TeST/",0,FALSE,
4094         "file:///c:/test/test/",0,FALSE,
4095         TRUE, FALSE
4096     },
4097     {
4098         "file:///server/TEST",0,FALSE,
4099         "file:///SERVER/TEST",0,FALSE,
4100         TRUE, FALSE
4101     },
4102     {
4103         "http://google.com",Uri_CREATE_NO_CANONICALIZE,FALSE,
4104         "http://google.com/",0,FALSE,
4105         TRUE, FALSE
4106     },
4107     {
4108         "ftp://google.com:21/",0,FALSE,
4109         "ftp://google.com/",0,FALSE,
4110         TRUE, FALSE
4111     },
4112     {
4113         "http://google.com:80/",Uri_CREATE_NO_CANONICALIZE,FALSE,
4114         "http://google.com/",0,FALSE,
4115         TRUE, FALSE
4116     },
4117     {
4118         "http://google.com:70/",0,FALSE,
4119         "http://google.com:71/",0,FALSE,
4120         FALSE, FALSE
4121     }
4122 };
4123
4124 typedef struct _uri_with_fragment {
4125     const char* uri;
4126     const char* fragment;
4127     DWORD       create_flags;
4128     HRESULT     create_expected;
4129     BOOL        create_todo;
4130
4131     const char* expected_uri;
4132     BOOL        expected_todo;
4133 } uri_with_fragment;
4134
4135 static const uri_with_fragment uri_fragment_tests[] = {
4136     {
4137         "http://google.com/","#fragment",0,S_OK,FALSE,
4138         "http://google.com/#fragment",FALSE
4139     },
4140     {
4141         "http://google.com/","fragment",0,S_OK,FALSE,
4142         "http://google.com/#fragment",FALSE
4143     },
4144     {
4145         "zip://test.com/","?test",0,S_OK,FALSE,
4146         "zip://test.com/#?test",FALSE
4147     },
4148     /* The fragment can be empty. */
4149     {
4150         "ftp://ftp.google.com/","",0,S_OK,FALSE,
4151         "ftp://ftp.google.com/#",FALSE
4152     }
4153 };
4154
4155 typedef struct _uri_builder_property {
4156     BOOL            change;
4157     const char      *value;
4158     const char      *expected_value;
4159     Uri_PROPERTY    property;
4160     HRESULT         expected;
4161     BOOL            todo;
4162 } uri_builder_property;
4163
4164 typedef struct _uri_builder_port {
4165     BOOL    change;
4166     BOOL    set;
4167     DWORD   value;
4168     HRESULT expected;
4169     BOOL    todo;
4170 } uri_builder_port;
4171
4172 typedef struct _uri_builder_str_property {
4173     const char* expected;
4174     HRESULT     result;
4175     BOOL        todo;
4176 } uri_builder_str_property;
4177
4178 typedef struct _uri_builder_dword_property {
4179     DWORD   expected;
4180     HRESULT result;
4181     BOOL    todo;
4182 } uri_builder_dword_property;
4183
4184 typedef struct _uri_builder_test {
4185     const char                  *uri;
4186     DWORD                       create_flags;
4187     HRESULT                     create_builder_expected;
4188     BOOL                        create_builder_todo;
4189
4190     uri_builder_property        properties[URI_BUILDER_STR_PROPERTY_COUNT];
4191
4192     uri_builder_port            port_prop;
4193
4194     DWORD                       uri_flags;
4195     HRESULT                     uri_hres;
4196     BOOL                        uri_todo;
4197
4198     DWORD                       uri_simple_encode_flags;
4199     HRESULT                     uri_simple_hres;
4200     BOOL                        uri_simple_todo;
4201
4202     DWORD                       uri_with_flags;
4203     DWORD                       uri_with_builder_flags;
4204     DWORD                       uri_with_encode_flags;
4205     HRESULT                     uri_with_hres;
4206     BOOL                        uri_with_todo;
4207
4208     uri_builder_str_property    expected_str_props[URI_STR_PROPERTY_COUNT];
4209     uri_builder_dword_property  expected_dword_props[URI_DWORD_PROPERTY_COUNT];
4210 } uri_builder_test;
4211
4212 static const uri_builder_test uri_builder_tests[] = {
4213     {   "http://google.com/",0,S_OK,FALSE,
4214         {
4215             {TRUE,"#fragment",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE},
4216             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE},
4217             {TRUE,"?query=x",NULL,Uri_PROPERTY_QUERY,S_OK,FALSE},
4218             {TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4219         },
4220         {FALSE},
4221         0,S_OK,FALSE,
4222         0,S_OK,FALSE,
4223         0,0,0,S_OK,FALSE,
4224         {
4225             {"http://username:password@google.com/?query=x#fragment",S_OK},
4226             {"username:password@google.com",S_OK},
4227             {"http://google.com/?query=x#fragment",S_OK},
4228             {"google.com",S_OK},
4229             {"",S_FALSE},
4230             {"#fragment",S_OK},
4231             {"google.com",S_OK},
4232             {"password",S_OK},
4233             {"/",S_OK},
4234             {"/?query=x",S_OK},
4235             {"?query=x",S_OK},
4236             {"http://username:password@google.com/?query=x#fragment",S_OK},
4237             {"http",S_OK},
4238             {"username:password",S_OK},
4239             {"username",S_OK}
4240         },
4241         {
4242             {Uri_HOST_DNS,S_OK},
4243             {80,S_OK},
4244             {URL_SCHEME_HTTP,S_OK},
4245             {URLZONE_INVALID,E_NOTIMPL}
4246         }
4247     },
4248     {   "http://google.com/",0,S_OK,FALSE,
4249         {
4250             {TRUE,"test",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE}
4251         },
4252         {TRUE,TRUE,120,S_OK,FALSE},
4253         0,S_OK,FALSE,
4254         0,S_OK,FALSE,
4255         0,0,0,S_OK,FALSE,
4256         {
4257             {"test://google.com:120/",S_OK},
4258             {"google.com:120",S_OK},
4259             {"test://google.com:120/",S_OK},
4260             {"google.com",S_OK},
4261             {"",S_FALSE},
4262             {"",S_FALSE},
4263             {"google.com",S_OK},
4264             {"",S_FALSE},
4265             {"/",S_OK},
4266             {"/",S_OK},
4267             {"",S_FALSE},
4268             {"test://google.com:120/",S_OK},
4269             {"test",S_OK},
4270             {"",S_FALSE},
4271             {"",S_FALSE}
4272         },
4273         {
4274             {Uri_HOST_DNS,S_OK},
4275             {120,S_OK},
4276             {URL_SCHEME_UNKNOWN,S_OK},
4277             {URLZONE_INVALID,E_NOTIMPL}
4278         }
4279     },
4280     {   "/Test/test dir",Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4281         {
4282             {TRUE,"http",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE},
4283             {TRUE,"::192.2.3.4",NULL,Uri_PROPERTY_HOST,S_OK,FALSE},
4284             {TRUE,NULL,NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
4285         },
4286         {FALSE},
4287         0,S_OK,FALSE,
4288         0,S_OK,FALSE,
4289         0,0,0,S_OK,FALSE,
4290         {
4291             {"http://[::192.2.3.4]/",S_OK},
4292             {"[::192.2.3.4]",S_OK},
4293             {"http://[::192.2.3.4]/",S_OK},
4294             {"",S_FALSE},
4295             {"",S_FALSE},
4296             {"",S_FALSE},
4297             {"::192.2.3.4",S_OK},
4298             {"",S_FALSE},
4299             {"/",S_OK},
4300             {"/",S_OK},
4301             {"",S_FALSE},
4302             {"http://[::192.2.3.4]/",S_OK},
4303             {"http",S_OK},
4304             {"",S_FALSE},
4305             {"",S_FALSE}
4306         },
4307         {
4308             {Uri_HOST_IPV6,S_OK},
4309             {80,S_OK},
4310             {URL_SCHEME_HTTP,S_OK},
4311             {URLZONE_INVALID,E_NOTIMPL}
4312         }
4313     },
4314     {   "http://google.com/",0,S_OK,FALSE,
4315         {
4316             {TRUE,"Frag","#Frag",Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
4317         },
4318         {FALSE},
4319         0,S_OK,FALSE,
4320         0,S_OK,FALSE,
4321         0,0,0,S_OK,FALSE,
4322         {
4323             {"http://google.com/#Frag",S_OK},
4324             {"google.com",S_OK},
4325             {"http://google.com/#Frag",S_OK},
4326             {"google.com",S_OK},
4327             {"",S_FALSE},
4328             {"#Frag",S_OK},
4329             {"google.com",S_OK},
4330             {"",S_FALSE},
4331             {"/",S_OK},
4332             {"/",S_OK},
4333             {"",S_FALSE},
4334             {"http://google.com/#Frag",S_OK},
4335             {"http",S_OK},
4336             {"",S_FALSE},
4337             {"",S_FALSE}
4338         },
4339         {
4340             {Uri_HOST_DNS,S_OK},
4341             {80,S_OK},
4342             {URL_SCHEME_HTTP,S_OK},
4343             {URLZONE_INVALID,E_NOTIMPL}
4344         }
4345     },
4346     {   "http://google.com/",0,S_OK,FALSE,
4347         {
4348             {TRUE,"","#",Uri_PROPERTY_FRAGMENT,S_OK,FALSE},
4349         },
4350         {FALSE},
4351         0,S_OK,FALSE,
4352         0,S_OK,FALSE,
4353         0,0,0,S_OK,FALSE,
4354         {
4355             {"http://google.com/#",S_OK},
4356             {"google.com",S_OK},
4357             {"http://google.com/#",S_OK},
4358             {"google.com",S_OK},
4359             {"",S_FALSE},
4360             {"#",S_OK},
4361             {"google.com",S_OK},
4362             {"",S_FALSE},
4363             {"/",S_OK},
4364             {"/",S_OK},
4365             {"",S_FALSE},
4366             {"http://google.com/#",S_OK},
4367             {"http",S_OK},
4368             {"",S_FALSE},
4369             {"",S_FALSE}
4370         },
4371         {
4372             {Uri_HOST_DNS,S_OK},
4373             {80,S_OK},
4374             {URL_SCHEME_HTTP,S_OK},
4375             {URLZONE_INVALID,E_NOTIMPL}
4376         }
4377     },
4378     {   "http://google.com/",0,S_OK,FALSE,
4379         {
4380             {TRUE,":password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4381         },
4382         {FALSE},
4383         0,S_OK,FALSE,
4384         0,S_OK,FALSE,
4385         0,0,0,S_OK,FALSE,
4386         {
4387             {"http://::password@google.com/",S_OK},
4388             {"::password@google.com",S_OK},
4389             {"http://google.com/",S_OK},
4390             {"google.com",S_OK},
4391             {"",S_FALSE},
4392             {"",S_FALSE},
4393             {"google.com",S_OK},
4394             {":password",S_OK},
4395             {"/",S_OK},
4396             {"/",S_OK},
4397             {"",S_FALSE},
4398             {"http://::password@google.com/",S_OK},
4399             {"http",S_OK},
4400             {"::password",S_OK},
4401             {"",S_FALSE}
4402         },
4403         {
4404             {Uri_HOST_DNS,S_OK},
4405             {80,S_OK},
4406             {URL_SCHEME_HTTP,S_OK},
4407             {URLZONE_INVALID,E_NOTIMPL}
4408         }
4409     },
4410     {   "test/test",Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4411         {
4412             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4413         },
4414         {FALSE},
4415         Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4416         0,S_OK,FALSE,
4417         Uri_CREATE_ALLOW_RELATIVE,0,0,S_OK,FALSE,
4418         {
4419             {":password@test/test",S_OK},
4420             {":password@",S_OK},
4421             {":password@test/test",S_OK},
4422             {"",S_FALSE},
4423             {"",S_FALSE},
4424             {"",S_FALSE},
4425             {"",S_FALSE},
4426             {"password",S_OK},
4427             {"test/test",S_OK},
4428             {"test/test",S_OK},
4429             {"",S_FALSE},
4430             {":password@test/test",S_OK},
4431             {"",S_FALSE},
4432             {":password",S_OK},
4433             {"",S_FALSE}
4434         },
4435         {
4436             {Uri_HOST_UNKNOWN,S_OK},
4437             {0,S_FALSE},
4438             {URL_SCHEME_UNKNOWN,S_OK},
4439             {URLZONE_INVALID,E_NOTIMPL}
4440         }
4441     },
4442     {   "http://google.com/",0,S_OK,FALSE,
4443         {
4444             {TRUE,"test/test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
4445         },
4446         {FALSE},
4447         0,S_OK,FALSE,
4448         0,S_OK,FALSE,
4449         0,0,0,S_OK,FALSE,
4450         {
4451             {"http://google.com/test/test",S_OK},
4452             {"google.com",S_OK},
4453             {"http://google.com/test/test",S_OK},
4454             {"google.com",S_OK},
4455             {"",S_FALSE},
4456             {"",S_FALSE},
4457             {"google.com",S_OK},
4458             {"",S_FALSE},
4459             {"/test/test",S_OK},
4460             {"/test/test",S_OK},
4461             {"",S_FALSE},
4462             {"http://google.com/test/test",S_OK},
4463             {"http",S_OK},
4464             {"",S_FALSE},
4465             {"",S_FALSE}
4466         },
4467         {
4468             {Uri_HOST_DNS,S_OK},
4469             {80,S_OK},
4470             {URL_SCHEME_HTTP,S_OK},
4471             {URLZONE_INVALID,E_NOTIMPL}
4472         }
4473     },
4474     {   "zip:testing/test",0,S_OK,FALSE,
4475         {
4476             {TRUE,"test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
4477         },
4478         {FALSE},
4479         0,S_OK,FALSE,
4480         0,S_OK,FALSE,
4481         0,0,0,S_OK,FALSE,
4482         {
4483             {"zip:test",S_OK},
4484             {"",S_FALSE},
4485             {"zip:test",S_OK},
4486             {"",S_FALSE},
4487             {"",S_FALSE},
4488             {"",S_FALSE},
4489             {"",S_FALSE},
4490             {"",S_FALSE},
4491             {"test",S_OK},
4492             {"test",S_OK},
4493             {"",S_FALSE},
4494             {"zip:test",S_OK},
4495             {"zip",S_OK},
4496             {"",S_FALSE},
4497             {"",S_FALSE}
4498         },
4499         {
4500             {Uri_HOST_UNKNOWN,S_OK},
4501             {0,S_FALSE},
4502             {URL_SCHEME_UNKNOWN,S_OK},
4503             {URLZONE_INVALID,E_NOTIMPL}
4504         }
4505     },
4506     {   "http://google.com/",0,S_OK,FALSE,
4507         {
4508             {FALSE},
4509         },
4510         /* 555 will be returned from GetPort even though FALSE was passed as the hasPort parameter. */
4511         {TRUE,FALSE,555,S_OK,FALSE},
4512         0,S_OK,FALSE,
4513         0,S_OK,FALSE,
4514         0,0,0,S_OK,FALSE,
4515         {
4516             {"http://google.com/",S_OK},
4517             {"google.com",S_OK},
4518             {"http://google.com/",S_OK},
4519             {"google.com",S_OK},
4520             {"",S_FALSE},
4521             {"",S_FALSE},
4522             {"google.com",S_OK},
4523             {"",S_FALSE},
4524             {"/",S_OK},
4525             {"/",S_OK},
4526             {"",S_FALSE},
4527             {"http://google.com/",S_OK},
4528             {"http",S_OK},
4529             {"",S_FALSE},
4530             {"",S_FALSE}
4531         },
4532         {
4533             {Uri_HOST_DNS,S_OK},
4534             /* Still returns 80, even though earlier the port was disabled. */
4535             {80,S_OK},
4536             {URL_SCHEME_HTTP,S_OK},
4537             {URLZONE_INVALID,E_NOTIMPL}
4538         }
4539     },
4540     {   "http://google.com/",0,S_OK,FALSE,
4541         {
4542             {FALSE},
4543         },
4544         /* Instead of getting "TRUE" back as the "hasPort" parameter in GetPort,
4545          * you'll get 122345 instead.
4546          */
4547         {TRUE,122345,222,S_OK,FALSE},
4548         0,S_OK,FALSE,
4549         0,S_OK,FALSE,
4550         0,0,0,S_OK,FALSE,
4551         {
4552             {"http://google.com:222/",S_OK},
4553             {"google.com:222",S_OK},
4554             {"http://google.com:222/",S_OK},
4555             {"google.com",S_OK},
4556             {"",S_FALSE},
4557             {"",S_FALSE},
4558             {"google.com",S_OK},
4559             {"",S_FALSE},
4560             {"/",S_OK},
4561             {"/",S_OK},
4562             {"",S_FALSE},
4563             {"http://google.com:222/",S_OK},
4564             {"http",S_OK},
4565             {"",S_FALSE},
4566             {"",S_FALSE}
4567         },
4568         {
4569             {Uri_HOST_DNS,S_OK},
4570             {222,S_OK},
4571             {URL_SCHEME_HTTP,S_OK},
4572             {URLZONE_INVALID,E_NOTIMPL}
4573         }
4574     },
4575     /* IUri's created with the IUriBuilder can have ports that exceed USHORT_MAX. */
4576     {   "http://google.com/",0,S_OK,FALSE,
4577         {
4578             {FALSE},
4579         },
4580         {TRUE,TRUE,999999,S_OK,FALSE},
4581         0,S_OK,FALSE,
4582         0,S_OK,FALSE,
4583         0,0,0,S_OK,FALSE,
4584         {
4585             {"http://google.com:999999/",S_OK},
4586             {"google.com:999999",S_OK},
4587             {"http://google.com:999999/",S_OK},
4588             {"google.com",S_OK},
4589             {"",S_FALSE},
4590             {"",S_FALSE},
4591             {"google.com",S_OK},
4592             {"",S_FALSE},
4593             {"/",S_OK},
4594             {"/",S_OK},
4595             {"",S_FALSE},
4596             {"http://google.com:999999/",S_OK},
4597             {"http",S_OK},
4598             {"",S_FALSE},
4599             {"",S_FALSE}
4600         },
4601         {
4602             {Uri_HOST_DNS,S_OK},
4603             {999999,S_OK},
4604             {URL_SCHEME_HTTP,S_OK},
4605             {URLZONE_INVALID,E_NOTIMPL}
4606         }
4607     },
4608     {   "http://google.com/",0,S_OK,FALSE,
4609         {
4610             {TRUE,"test","?test",Uri_PROPERTY_QUERY,S_OK,FALSE},
4611         },
4612
4613         {FALSE},
4614         0,S_OK,FALSE,
4615         0,S_OK,FALSE,
4616         0,0,0,S_OK,FALSE,
4617         {
4618             {"http://google.com/?test",S_OK},
4619             {"google.com",S_OK},
4620             {"http://google.com/?test",S_OK},
4621             {"google.com",S_OK},
4622             {"",S_FALSE},
4623             {"",S_FALSE},
4624             {"google.com",S_OK},
4625             {"",S_FALSE},
4626             {"/",S_OK},
4627             {"/?test",S_OK},
4628             {"?test",S_OK},
4629             {"http://google.com/?test",S_OK},
4630             {"http",S_OK},
4631             {"",S_FALSE},
4632             {"",S_FALSE}
4633         },
4634         {
4635             {Uri_HOST_DNS,S_OK},
4636             {80,S_OK},
4637             {URL_SCHEME_HTTP,S_OK},
4638             {URLZONE_INVALID,E_NOTIMPL}
4639         }
4640     },
4641     {   "http://:password@google.com/",0,S_OK,FALSE,
4642         {
4643             {FALSE},
4644         },
4645         {FALSE},
4646         0,S_OK,FALSE,
4647         0,S_OK,FALSE,
4648         0,0,0,S_OK,FALSE,
4649         {
4650             {"http://:password@google.com/",S_OK},
4651             {":password@google.com",S_OK},
4652             {"http://google.com/",S_OK},
4653             {"google.com",S_OK},
4654             {"",S_FALSE},
4655             {"",S_FALSE},
4656             {"google.com",S_OK},
4657             {"password",S_OK},
4658             {"/",S_OK},
4659             {"/",S_OK},
4660             {"",S_FALSE},
4661             {"http://:password@google.com/",S_OK},
4662             {"http",S_OK},
4663             {":password",S_OK},
4664             {"",S_FALSE}
4665         },
4666         {
4667             {Uri_HOST_DNS,S_OK},
4668             {80,S_OK},
4669             {URL_SCHEME_HTTP,S_OK},
4670             {URLZONE_INVALID,E_NOTIMPL}
4671         }
4672     },
4673     /* IUriBuilder doesn't need a base IUri to build a IUri. */
4674     {   NULL,0,S_OK,FALSE,
4675         {
4676             {TRUE,"http",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE},
4677             {TRUE,"google.com",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
4678         },
4679         {FALSE},
4680         0,S_OK,FALSE,
4681         0,S_OK,FALSE,
4682         0,0,0,S_OK,FALSE,
4683         {
4684             {"http://google.com/",S_OK},
4685             {"google.com",S_OK},
4686             {"http://google.com/",S_OK},
4687             {"google.com",S_OK},
4688             {"",S_FALSE},
4689             {"",S_FALSE},
4690             {"google.com",S_OK},
4691             {"",S_FALSE},
4692             {"/",S_OK},
4693             {"/",S_OK},
4694             {"",S_FALSE},
4695             {"http://google.com/",S_OK},
4696             {"http",S_OK},
4697             {"",S_FALSE},
4698             {"",S_FALSE}
4699         },
4700         {
4701             {Uri_HOST_DNS,S_OK},
4702             {80,S_OK},
4703             {URL_SCHEME_HTTP,S_OK},
4704             {URLZONE_INVALID,E_NOTIMPL}
4705         }
4706     },
4707     /* Can't set the scheme name to NULL. */
4708     {   "zip://google.com/",0,S_OK,FALSE,
4709         {
4710             {TRUE,NULL,"zip",Uri_PROPERTY_SCHEME_NAME,E_INVALIDARG,FALSE}
4711         },
4712         {FALSE},
4713         0,S_OK,FALSE,
4714         0,S_OK,FALSE,
4715         0,0,0,S_OK,FALSE,
4716         {
4717             {"zip://google.com/",S_OK},
4718             {"google.com",S_OK},
4719             {"zip://google.com/",S_OK},
4720             {"google.com",S_OK},
4721             {"",S_FALSE},
4722             {"",S_FALSE},
4723             {"google.com",S_OK},
4724             {"",S_FALSE},
4725             {"/",S_OK},
4726             {"/",S_OK},
4727             {"",S_FALSE},
4728             {"zip://google.com/",S_OK},
4729             {"zip",S_OK},
4730             {"",S_FALSE},
4731             {"",S_FALSE}
4732         },
4733         {
4734             {Uri_HOST_DNS,S_OK},
4735             {0,S_FALSE},
4736             {URL_SCHEME_UNKNOWN,S_OK},
4737             {URLZONE_INVALID,E_NOTIMPL}
4738         }
4739     },
4740     /* Can't set the scheme name to an empty string. */
4741     {   "zip://google.com/",0,S_OK,FALSE,
4742         {
4743             {TRUE,"","zip",Uri_PROPERTY_SCHEME_NAME,E_INVALIDARG,FALSE}
4744         },
4745         {FALSE},
4746         0,S_OK,FALSE,
4747         0,S_OK,FALSE,
4748         0,0,0,S_OK,FALSE,
4749         {
4750             {"zip://google.com/",S_OK},
4751             {"google.com",S_OK},
4752             {"zip://google.com/",S_OK},
4753             {"google.com",S_OK},
4754             {"",S_FALSE},
4755             {"",S_FALSE},
4756             {"google.com",S_OK},
4757             {"",S_FALSE},
4758             {"/",S_OK},
4759             {"/",S_OK},
4760             {"",S_FALSE},
4761             {"zip://google.com/",S_OK},
4762             {"zip",S_OK},
4763             {"",S_FALSE},
4764             {"",S_FALSE}
4765         },
4766         {
4767             {Uri_HOST_DNS,S_OK},
4768             {0,S_FALSE},
4769             {URL_SCHEME_UNKNOWN,S_OK},
4770             {URLZONE_INVALID,E_NOTIMPL}
4771         }
4772     },
4773     /* -1 to CreateUri makes it use the same flags as the base IUri was created with.
4774      * CreateUriSimple always uses the flags the base IUri was created with (if any).
4775      */
4776     {   "http://google.com/../../",Uri_CREATE_NO_CANONICALIZE,S_OK,FALSE,
4777         {{FALSE}},
4778         {FALSE},
4779         -1,S_OK,FALSE,
4780         0,S_OK,FALSE,
4781         0,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
4782         {
4783             {"http://google.com/../../",S_OK},
4784             {"google.com",S_OK},
4785             {"http://google.com/../../",S_OK},
4786             {"google.com",S_OK},
4787             {"",S_FALSE},
4788             {"",S_FALSE},
4789             {"google.com",S_OK},
4790             {"",S_FALSE},
4791             {"/../../",S_OK},
4792             {"/../../",S_OK},
4793             {"",S_FALSE},
4794             {"http://google.com/../../",S_OK},
4795             {"http",S_OK},
4796             {"",S_FALSE},
4797             {"",S_FALSE}
4798         },
4799         {
4800             {Uri_HOST_DNS,S_OK},
4801             {80,S_OK},
4802             {URL_SCHEME_HTTP,S_OK},
4803             {URLZONE_INVALID,E_NOTIMPL}
4804         }
4805     },
4806     {   "http://google.com/",0,S_OK,FALSE,
4807         {
4808             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
4809         },
4810         {FALSE},
4811         -1,S_OK,FALSE,
4812         0,S_OK,FALSE,
4813         Uri_CREATE_NO_DECODE_EXTRA_INFO,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
4814         {
4815             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
4816             {"google.com",S_OK},
4817             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
4818             {"google.com",S_OK},
4819             {"",S_FALSE},
4820             {"#Fr%3C%7C%3Eg",S_OK},
4821             {"google.com",S_OK},
4822             {"",S_FALSE},
4823             {"/",S_OK},
4824             {"/",S_OK},
4825             {"",S_FALSE},
4826             {"http://google.com/#Fr<|>g",S_OK},
4827             {"http",S_OK},
4828             {"",S_FALSE},
4829             {"",S_FALSE}
4830         },
4831         {
4832             {Uri_HOST_DNS,S_OK},
4833             {80,S_OK},
4834             {URL_SCHEME_HTTP,S_OK},
4835             {URLZONE_INVALID,E_NOTIMPL}
4836         }
4837     },
4838     {   "http://google.com/",0,S_OK,FALSE,
4839         {
4840             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
4841         },
4842         {FALSE},
4843         Uri_CREATE_CANONICALIZE|Uri_CREATE_NO_CANONICALIZE,E_INVALIDARG,FALSE,
4844         0,S_OK,FALSE,
4845         Uri_CREATE_CANONICALIZE|Uri_CREATE_NO_CANONICALIZE,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
4846         {
4847             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
4848             {"google.com",S_OK},
4849             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
4850             {"google.com",S_OK},
4851             {"",S_FALSE},
4852             {"#Fr%3C%7C%3Eg",S_OK},
4853             {"google.com",S_OK},
4854             {"",S_FALSE},
4855             {"/",S_OK},
4856             {"/",S_OK},
4857             {"",S_FALSE},
4858             {"http://google.com/#Fr<|>g",S_OK},
4859             {"http",S_OK},
4860             {"",S_FALSE},
4861             {"",S_FALSE}
4862         },
4863         {
4864             {Uri_HOST_DNS,S_OK},
4865             {80,S_OK},
4866             {URL_SCHEME_HTTP,S_OK},
4867             {URLZONE_INVALID,E_NOTIMPL}
4868         }
4869     },
4870     {   NULL,0,S_OK,FALSE,
4871         {
4872             {TRUE,"/test/test/",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
4873             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
4874         },
4875         {FALSE},
4876         0,INET_E_INVALID_URL,FALSE,
4877         0,INET_E_INVALID_URL,FALSE,
4878         0,0,0,INET_E_INVALID_URL,FALSE
4879     },
4880     {   "http://google.com/",0,S_OK,FALSE,
4881         {
4882             {TRUE,"ht%xxtp",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE}
4883         },
4884         {FALSE},
4885         0,INET_E_INVALID_URL,FALSE,
4886         0,INET_E_INVALID_URL,FALSE,
4887         0,0,0,INET_E_INVALID_URL,FALSE
4888     },
4889     /* File scheme's can't have a username set. */
4890     {   "file://google.com/",0,S_OK,FALSE,
4891         {
4892             {TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4893         },
4894         {FALSE},
4895         0,INET_E_INVALID_URL,FALSE,
4896         0,INET_E_INVALID_URL,FALSE,
4897         0,0,0,INET_E_INVALID_URL,FALSE
4898     },
4899     /* File schemes can't have a password set. */
4900     {   "file://google.com/",0,S_OK,FALSE,
4901         {
4902             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4903         },
4904         {FALSE},
4905         0,INET_E_INVALID_URL,FALSE,
4906         0,INET_E_INVALID_URL,FALSE,
4907         0,0,0,INET_E_INVALID_URL,FALSE
4908     },
4909     /* UserName can't contain any character that is a delimeter for another
4910      * component that appears after it in a normal URI.
4911      */
4912     {   "http://google.com/",0,S_OK,FALSE,
4913         {
4914             {TRUE,"user:pass",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4915         },
4916         {FALSE},
4917         0,INET_E_INVALID_URL,FALSE,
4918         0,INET_E_INVALID_URL,FALSE,
4919         0,0,0,INET_E_INVALID_URL,FALSE
4920     },
4921     {   "http://google.com/",0,S_OK,FALSE,
4922         {
4923             {TRUE,"user@google.com",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4924         },
4925         {FALSE},
4926         0,INET_E_INVALID_URL,FALSE,
4927         0,INET_E_INVALID_URL,FALSE,
4928         0,0,0,INET_E_INVALID_URL,FALSE
4929     },
4930     {   "http://google.com/",0,S_OK,FALSE,
4931         {
4932             {TRUE,"user/path",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4933         },
4934         {FALSE},
4935         0,INET_E_INVALID_URL,FALSE,
4936         0,INET_E_INVALID_URL,FALSE,
4937         0,0,0,INET_E_INVALID_URL,FALSE
4938     },
4939     {   "http://google.com/",0,S_OK,FALSE,
4940         {
4941             {TRUE,"user?Query",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4942         },
4943         {FALSE},
4944         0,INET_E_INVALID_URL,FALSE,
4945         0,INET_E_INVALID_URL,FALSE,
4946         0,0,0,INET_E_INVALID_URL,FALSE
4947     },
4948     {   "http://google.com/",0,S_OK,FALSE,
4949         {
4950             {TRUE,"user#Frag",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4951         },
4952         {FALSE},
4953         0,INET_E_INVALID_URL,FALSE,
4954         0,INET_E_INVALID_URL,FALSE,
4955         0,0,0,INET_E_INVALID_URL,FALSE
4956     },
4957     {   "http://google.com/",0,S_OK,FALSE,
4958         {
4959             {TRUE,"pass@google.com",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4960         },
4961         {FALSE},
4962         0,INET_E_INVALID_URL,FALSE,
4963         0,INET_E_INVALID_URL,FALSE,
4964         0,0,0,INET_E_INVALID_URL,FALSE
4965     },
4966     {   "http://google.com/",0,S_OK,FALSE,
4967         {
4968             {TRUE,"pass/path",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4969         },
4970         {FALSE},
4971         0,INET_E_INVALID_URL,FALSE,
4972         0,INET_E_INVALID_URL,FALSE,
4973         0,0,0,INET_E_INVALID_URL,FALSE
4974     },
4975     {   "http://google.com/",0,S_OK,FALSE,
4976         {
4977             {TRUE,"pass?query",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4978         },
4979         {FALSE},
4980         0,INET_E_INVALID_URL,FALSE,
4981         0,INET_E_INVALID_URL,FALSE,
4982        0,0,0,INET_E_INVALID_URL,FALSE
4983     },
4984     {   "http://google.com/",0,S_OK,FALSE,
4985         {
4986             {TRUE,"pass#frag",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4987         },
4988         {FALSE},
4989         0,INET_E_INVALID_URL,FALSE,
4990         0,INET_E_INVALID_URL,FALSE,
4991         0,0,0,INET_E_INVALID_URL,FALSE
4992     },
4993     {   "http://google.com/",0,S_OK,FALSE,
4994         {
4995             {TRUE,"winehq.org/test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
4996         },
4997         {FALSE},
4998         0,INET_E_INVALID_URL,FALSE,
4999         0,INET_E_INVALID_URL,FALSE,
5000         0,0,0,INET_E_INVALID_URL,FALSE
5001     },
5002     {   "http://google.com/",0,S_OK,FALSE,
5003         {
5004             {TRUE,"winehq.org?test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5005         },
5006         {FALSE},
5007         0,INET_E_INVALID_URL,FALSE,
5008         0,INET_E_INVALID_URL,FALSE,
5009         0,0,0,INET_E_INVALID_URL,FALSE
5010     },
5011     {   "http://google.com/",0,S_OK,FALSE,
5012         {
5013             {TRUE,"winehq.org#test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5014         },
5015         {FALSE},
5016         0,INET_E_INVALID_URL,FALSE,
5017         0,INET_E_INVALID_URL,FALSE,
5018         0,0,0,INET_E_INVALID_URL,FALSE
5019     },
5020     /* Hostname is allowed to contain a ':' (even for known scheme types). */
5021     {   "http://google.com/",0,S_OK,FALSE,
5022         {
5023             {TRUE,"winehq.org:test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE},
5024         },
5025         {FALSE},
5026         0,S_OK,FALSE,
5027         0,S_OK,FALSE,
5028         0,0,0,S_OK,FALSE,
5029         {
5030             {"http://winehq.org:test/",S_OK},
5031             {"winehq.org:test",S_OK},
5032             {"http://winehq.org:test/",S_OK},
5033             {"winehq.org:test",S_OK},
5034             {"",S_FALSE},
5035             {"",S_FALSE},
5036             {"winehq.org:test",S_OK},
5037             {"",S_FALSE},
5038             {"/",S_OK},
5039             {"/",S_OK},
5040             {"",S_FALSE},
5041             {"http://winehq.org:test/",S_OK},
5042             {"http",S_OK},
5043             {"",S_FALSE},
5044             {"",S_FALSE}
5045         },
5046         {
5047             {Uri_HOST_DNS,S_OK},
5048             {80,S_OK},
5049             {URL_SCHEME_HTTP,S_OK},
5050             {URLZONE_INVALID,E_NOTIMPL}
5051         }
5052     },
5053     /* Can't set the host name to NULL. */
5054     {   "http://google.com/",0,S_OK,FALSE,
5055         {
5056             {TRUE,NULL,"google.com",Uri_PROPERTY_HOST,E_INVALIDARG,FALSE}
5057         },
5058         {FALSE},
5059         0,S_OK,FALSE,
5060         0,S_OK,FALSE,
5061         0,0,0,S_OK,FALSE,
5062         {
5063             {"http://google.com/",S_OK},
5064             {"google.com",S_OK},
5065             {"http://google.com/",S_OK},
5066             {"google.com",S_OK},
5067             {"",S_FALSE},
5068             {"",S_FALSE},
5069             {"google.com",S_OK},
5070             {"",S_FALSE},
5071             {"/",S_OK},
5072             {"/",S_OK},
5073             {"",S_FALSE},
5074             {"http://google.com/",S_OK},
5075             {"http",S_OK},
5076             {"",S_FALSE},
5077             {"",S_FALSE}
5078         },
5079         {
5080             {Uri_HOST_DNS,S_OK},
5081             {80,S_OK},
5082             {URL_SCHEME_HTTP,S_OK},
5083             {URLZONE_INVALID,E_NOTIMPL}
5084         }
5085     },
5086     /* Can set the host name to an empty string. */
5087     {   "http://google.com/",0,S_OK,FALSE,
5088         {
5089             {TRUE,"",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5090         },
5091         {FALSE},
5092         0,S_OK,FALSE,
5093         0,S_OK,FALSE,
5094         0,0,0,S_OK,FALSE,
5095         {
5096             {"http:///",S_OK},
5097             {"",S_OK},
5098             {"http:///",S_OK},
5099             {"",S_FALSE},
5100             {"",S_FALSE},
5101             {"",S_FALSE},
5102             {"",S_OK},
5103             {"",S_FALSE},
5104             {"/",S_OK},
5105             {"/",S_OK},
5106             {"",S_FALSE},
5107             {"http:///",S_OK},
5108             {"http",S_OK},
5109             {"",S_FALSE},
5110             {"",S_FALSE}
5111         },
5112         {
5113             {Uri_HOST_UNKNOWN,S_OK},
5114             {80,S_OK},
5115             {URL_SCHEME_HTTP,S_OK},
5116             {URLZONE_INVALID,E_NOTIMPL}
5117         }
5118     },
5119     {   "http://google.com/",0,S_OK,FALSE,
5120         {
5121             {TRUE,"/path?query",NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
5122         },
5123         {FALSE},
5124         0,INET_E_INVALID_URL,FALSE,
5125         0,INET_E_INVALID_URL,FALSE,
5126         0,0,0,INET_E_INVALID_URL,FALSE
5127     },
5128     {   "http://google.com/",0,S_OK,FALSE,
5129         {
5130             {TRUE,"/path#test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
5131         },
5132         {FALSE},
5133         0,INET_E_INVALID_URL,FALSE,
5134         0,INET_E_INVALID_URL,FALSE,
5135         0,0,0,INET_E_INVALID_URL,FALSE
5136     },
5137     {   "http://google.com/",0,S_OK,FALSE,
5138         {
5139             {TRUE,"?path#test",NULL,Uri_PROPERTY_QUERY,S_OK,FALSE}
5140         },
5141         {FALSE},
5142         0,INET_E_INVALID_URL,FALSE,
5143         0,INET_E_INVALID_URL,FALSE,
5144         0,0,0,INET_E_INVALID_URL,FALSE
5145     }
5146 };
5147
5148 typedef struct _uri_builder_remove_test {
5149     const char  *uri;
5150     DWORD       create_flags;
5151     HRESULT     create_builder_expected;
5152     BOOL        create_builder_todo;
5153
5154     DWORD       remove_properties;
5155     HRESULT     remove_expected;
5156     BOOL        remove_todo;
5157
5158     const char  *expected_uri;
5159     DWORD       expected_flags;
5160     HRESULT     expected_hres;
5161     BOOL        expected_todo;
5162 } uri_builder_remove_test;
5163
5164 static const uri_builder_remove_test uri_builder_remove_tests[] = {
5165     {   "http://google.com/test?test=y#Frag",0,S_OK,FALSE,
5166         Uri_HAS_FRAGMENT|Uri_HAS_PATH|Uri_HAS_QUERY,S_OK,FALSE,
5167         "http://google.com/",0,S_OK,FALSE
5168     },
5169     {   "http://user:pass@winehq.org/",0,S_OK,FALSE,
5170         Uri_HAS_USER_NAME|Uri_HAS_PASSWORD,S_OK,FALSE,
5171         "http://winehq.org/",0,S_OK,FALSE
5172     },
5173     {   "zip://google.com?Test=x",0,S_OK,FALSE,
5174         Uri_HAS_HOST,S_OK,FALSE,
5175         "zip:/?Test=x",0,S_OK,FALSE
5176     },
5177     /* Doesn't remove the whole userinfo component. */
5178     {   "http://username:pass@google.com/",0,S_OK,FALSE,
5179         Uri_HAS_USER_INFO,S_OK,FALSE,
5180         "http://username:pass@google.com/",0,S_OK,FALSE
5181     },
5182     /* Doesn't remove the domain. */
5183     {   "http://google.com/",0,S_OK,FALSE,
5184         Uri_HAS_DOMAIN,S_OK,FALSE,
5185         "http://google.com/",0,S_OK,FALSE
5186     },
5187     {   "http://google.com:120/",0,S_OK,FALSE,
5188         Uri_HAS_AUTHORITY,S_OK,FALSE,
5189         "http://google.com:120/",0,S_OK,FALSE
5190     },
5191     {   "http://google.com/test.com/",0,S_OK,FALSE,
5192         Uri_HAS_EXTENSION,S_OK,FALSE,
5193         "http://google.com/test.com/",0,S_OK,FALSE
5194     },
5195     {   "http://google.com/?test=x",0,S_OK,FALSE,
5196         Uri_HAS_PATH_AND_QUERY,S_OK,FALSE,
5197         "http://google.com/?test=x",0,S_OK,FALSE
5198     },
5199     /* Can't remove the scheme name. */
5200     {   "http://google.com/?test=x",0,S_OK,FALSE,
5201         Uri_HAS_SCHEME_NAME|Uri_HAS_QUERY,E_INVALIDARG,FALSE,
5202         "http://google.com/?test=x",0,S_OK,FALSE
5203     }
5204 };
5205
5206 typedef struct _uri_combine_str_property {
5207     const char  *value;
5208     HRESULT     expected;
5209     BOOL        todo;
5210     const char  *broken_value;
5211     const char  *value_ex;
5212 } uri_combine_str_property;
5213
5214 typedef struct _uri_combine_test {
5215     const char  *base_uri;
5216     DWORD       base_create_flags;
5217     const char  *relative_uri;
5218     DWORD       relative_create_flags;
5219     DWORD       combine_flags;
5220     HRESULT     expected;
5221     BOOL        todo;
5222
5223     uri_combine_str_property    str_props[URI_STR_PROPERTY_COUNT];
5224     uri_dword_property          dword_props[URI_DWORD_PROPERTY_COUNT];
5225 } uri_combine_test;
5226
5227 static const uri_combine_test uri_combine_tests[] = {
5228     {   "http://google.com/fun/stuff",0,
5229         "../not/fun/stuff",Uri_CREATE_ALLOW_RELATIVE,
5230         0,S_OK,FALSE,
5231         {
5232             {"http://google.com/not/fun/stuff",S_OK},
5233             {"google.com",S_OK},
5234             {"http://google.com/not/fun/stuff",S_OK},
5235             {"google.com",S_OK},
5236             {"",S_FALSE},
5237             {"",S_FALSE},
5238             {"google.com",S_OK},
5239             {"",S_FALSE},
5240             {"/not/fun/stuff",S_OK},
5241             {"/not/fun/stuff",S_OK},
5242             {"",S_FALSE},
5243             {"http://google.com/not/fun/stuff",S_OK},
5244             {"http",S_OK},
5245             {"",S_FALSE},
5246             {"",S_FALSE}
5247         },
5248         {
5249             {Uri_HOST_DNS,S_OK},
5250             {80,S_OK},
5251             {URL_SCHEME_HTTP,S_OK},
5252             {URLZONE_INVALID,E_NOTIMPL}
5253         }
5254     },
5255     {   "http://google.com/test",0,
5256         "zip://test.com/cool",0,
5257         0,S_OK,FALSE,
5258         {
5259             {"zip://test.com/cool",S_OK},
5260             {"test.com",S_OK},
5261             {"zip://test.com/cool",S_OK},
5262             {"test.com",S_OK},
5263             {"",S_FALSE},
5264             {"",S_FALSE},
5265             {"test.com",S_OK},
5266             {"",S_FALSE},
5267             {"/cool",S_OK},
5268             {"/cool",S_OK},
5269             {"",S_FALSE},
5270             {"zip://test.com/cool",S_OK},
5271             {"zip",S_OK},
5272             {"",S_FALSE},
5273             {"",S_FALSE}
5274         },
5275         {
5276             {Uri_HOST_DNS,S_OK},
5277             {0,S_FALSE},
5278             {URL_SCHEME_UNKNOWN,S_OK},
5279             {URLZONE_INVALID,E_NOTIMPL}
5280         }
5281     },
5282     {   "http://google.com/use/base/path",0,
5283         "?relative",Uri_CREATE_ALLOW_RELATIVE,
5284         0,S_OK,FALSE,
5285         {
5286             {"http://google.com/use/base/path?relative",S_OK},
5287             {"google.com",S_OK},
5288             {"http://google.com/use/base/path?relative",S_OK},
5289             {"google.com",S_OK},
5290             {"",S_FALSE},
5291             {"",S_FALSE},
5292             {"google.com",S_OK},
5293             {"",S_FALSE},
5294             {"/use/base/path",S_OK},
5295             {"/use/base/path?relative",S_OK},
5296             {"?relative",S_OK},
5297             {"http://google.com/use/base/path?relative",S_OK},
5298             {"http",S_OK},
5299             {"",S_FALSE},
5300             {"",S_FALSE}
5301         },
5302         {
5303             {Uri_HOST_DNS,S_OK},
5304             {80,S_OK},
5305             {URL_SCHEME_HTTP,S_OK},
5306             {URLZONE_INVALID,E_NOTIMPL}
5307         }
5308     },
5309     {   "http://google.com/path",0,
5310         "/test/../test/.././testing",Uri_CREATE_ALLOW_RELATIVE,
5311         0,S_OK,FALSE,
5312         {
5313             {"http://google.com/testing",S_OK},
5314             {"google.com",S_OK},
5315             {"http://google.com/testing",S_OK},
5316             {"google.com",S_OK},
5317             {"",S_FALSE},
5318             {"",S_FALSE},
5319             {"google.com",S_OK},
5320             {"",S_FALSE},
5321             {"/testing",S_OK},
5322             {"/testing",S_OK},
5323             {"",S_FALSE},
5324             {"http://google.com/testing",S_OK},
5325             {"http",S_OK},
5326             {"",S_FALSE},
5327             {"",S_FALSE}
5328         },
5329         {
5330             {Uri_HOST_DNS,S_OK},
5331             {80,S_OK},
5332             {URL_SCHEME_HTTP,S_OK},
5333             {URLZONE_INVALID,E_NOTIMPL}
5334         }
5335     },
5336     {   "http://google.com/path",0,
5337         "/test/../test/.././testing",Uri_CREATE_ALLOW_RELATIVE,
5338         URL_DONT_SIMPLIFY,S_OK,FALSE,
5339         {
5340             {"http://google.com:80/test/../test/.././testing",S_OK},
5341             {"google.com",S_OK},
5342             {"http://google.com:80/test/../test/.././testing",S_OK},
5343             {"google.com",S_OK},
5344             {"",S_FALSE},
5345             {"",S_FALSE},
5346             {"google.com",S_OK},
5347             {"",S_FALSE},
5348             {"/test/../test/.././testing",S_OK},
5349             {"/test/../test/.././testing",S_OK},
5350             {"",S_FALSE},
5351             {"http://google.com:80/test/../test/.././testing",S_OK},
5352             {"http",S_OK},
5353             {"",S_FALSE},
5354             {"",S_FALSE}
5355         },
5356         {
5357             {Uri_HOST_DNS,S_OK},
5358             {80,S_OK},
5359             {URL_SCHEME_HTTP,S_OK},
5360             {URLZONE_INVALID,E_NOTIMPL}
5361         }
5362     },
5363     {   "http://winehq.org/test/abc",0,
5364         "testing/abc/../test",Uri_CREATE_ALLOW_RELATIVE,
5365         0,S_OK,FALSE,
5366         {
5367             {"http://winehq.org/test/testing/test",S_OK},
5368             {"winehq.org",S_OK},
5369             {"http://winehq.org/test/testing/test",S_OK},
5370             {"winehq.org",S_OK},
5371             {"",S_FALSE},
5372             {"",S_FALSE},
5373             {"winehq.org",S_OK},
5374             {"",S_FALSE},
5375             {"/test/testing/test",S_OK},
5376             {"/test/testing/test",S_OK},
5377             {"",S_FALSE},
5378             {"http://winehq.org/test/testing/test",S_OK},
5379             {"http",S_OK},
5380             {"",S_FALSE},
5381             {"",S_FALSE}
5382         },
5383         {
5384             {Uri_HOST_DNS,S_OK},
5385             {80,S_OK},
5386             {URL_SCHEME_HTTP,S_OK},
5387             {URLZONE_INVALID,E_NOTIMPL}
5388         }
5389     },
5390     {   "http://winehq.org/test/abc",0,
5391         "testing/abc/../test",Uri_CREATE_ALLOW_RELATIVE,
5392         URL_DONT_SIMPLIFY,S_OK,FALSE,
5393         {
5394             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5395             /* Default port is hidden in the authority. */
5396             {"winehq.org",S_OK},
5397             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5398             {"winehq.org",S_OK},
5399             {"",S_FALSE},
5400             {"",S_FALSE},
5401             {"winehq.org",S_OK},
5402             {"",S_FALSE},
5403             {"/test/testing/abc/../test",S_OK},
5404             {"/test/testing/abc/../test",S_OK},
5405             {"",S_FALSE},
5406             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5407             {"http",S_OK},
5408             {"",S_FALSE},
5409             {"",S_FALSE}
5410         },
5411         {
5412             {Uri_HOST_DNS,S_OK},
5413             {80,S_OK},
5414             {URL_SCHEME_HTTP,S_OK},
5415             {URLZONE_INVALID,E_NOTIMPL}
5416         }
5417     },
5418     {   "http://winehq.org/test?query",0,
5419         "testing",Uri_CREATE_ALLOW_RELATIVE,
5420         0,S_OK,FALSE,
5421         {
5422             {"http://winehq.org/testing",S_OK},
5423             {"winehq.org",S_OK},
5424             {"http://winehq.org/testing",S_OK},
5425             {"winehq.org",S_OK},
5426             {"",S_FALSE},
5427             {"",S_FALSE},
5428             {"winehq.org",S_OK},
5429             {"",S_FALSE},
5430             {"/testing",S_OK},
5431             {"/testing",S_OK},
5432             {"",S_FALSE},
5433             {"http://winehq.org/testing",S_OK},
5434             {"http",S_OK},
5435             {"",S_FALSE},
5436             {"",S_FALSE}
5437         },
5438         {
5439             {Uri_HOST_DNS,S_OK},
5440             {80,S_OK},
5441             {URL_SCHEME_HTTP,S_OK},
5442             {URLZONE_INVALID,E_NOTIMPL}
5443         }
5444     },
5445     {   "http://winehq.org/test#frag",0,
5446         "testing",Uri_CREATE_ALLOW_RELATIVE,
5447         0,S_OK,FALSE,
5448         {
5449             {"http://winehq.org/testing",S_OK},
5450             {"winehq.org",S_OK},
5451             {"http://winehq.org/testing",S_OK},
5452             {"winehq.org",S_OK},
5453             {"",S_FALSE},
5454             {"",S_FALSE},
5455             {"winehq.org",S_OK},
5456             {"",S_FALSE},
5457             {"/testing",S_OK},
5458             {"/testing",S_OK},
5459             {"",S_FALSE},
5460             {"http://winehq.org/testing",S_OK},
5461             {"http",S_OK},
5462             {"",S_FALSE},
5463             {"",S_FALSE}
5464         },
5465         {
5466             {Uri_HOST_DNS,S_OK},
5467             {80,S_OK},
5468             {URL_SCHEME_HTTP,S_OK},
5469             {URLZONE_INVALID,E_NOTIMPL}
5470         }
5471     },
5472     {   "testing?query#frag",Uri_CREATE_ALLOW_RELATIVE,
5473         "test",Uri_CREATE_ALLOW_RELATIVE,
5474         0,S_OK,FALSE,
5475         {
5476             {"test",S_OK},
5477             {"",S_FALSE},
5478             {"test",S_OK},
5479             {"",S_FALSE},
5480             {"",S_FALSE},
5481             {"",S_FALSE},
5482             {"",S_FALSE},
5483             {"",S_FALSE},
5484             {"test",S_OK},
5485             {"test",S_OK},
5486             {"",S_FALSE},
5487             {"test",S_OK},
5488             {"",S_FALSE},
5489             {"",S_FALSE},
5490             {"",S_FALSE}
5491         },
5492         {
5493             {Uri_HOST_UNKNOWN,S_OK},
5494             {0,S_FALSE},
5495             {URL_SCHEME_UNKNOWN,S_OK},
5496             {URLZONE_INVALID,E_NOTIMPL}
5497         }
5498     },
5499     {   "file:///c:/test/test",0,
5500         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
5501         URL_FILE_USE_PATHURL,S_OK,FALSE,
5502         {
5503             {"file://c:\\testing.mp3",S_OK},
5504             {"",S_FALSE},
5505             {"file://c:\\testing.mp3",S_OK},
5506             {"",S_FALSE},
5507             {".mp3",S_OK},
5508             {"",S_FALSE},
5509             {"",S_FALSE},
5510             {"",S_FALSE},
5511             {"c:\\testing.mp3",S_OK},
5512             {"c:\\testing.mp3",S_OK},
5513             {"",S_FALSE},
5514             {"file://c:\\testing.mp3",S_OK},
5515             {"file",S_OK},
5516             {"",S_FALSE},
5517             {"",S_FALSE}
5518         },
5519         {
5520             {Uri_HOST_UNKNOWN,S_OK},
5521             {0,S_FALSE},
5522             {URL_SCHEME_FILE,S_OK},
5523             {URLZONE_INVALID,E_NOTIMPL}
5524         }
5525     },
5526     {   "file:///c:/test/test",0,
5527         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
5528         0,S_OK,FALSE,
5529         {
5530             {"file:///c:/testing.mp3",S_OK},
5531             {"",S_FALSE},
5532             {"file:///c:/testing.mp3",S_OK},
5533             {"",S_FALSE},
5534             {".mp3",S_OK},
5535             {"",S_FALSE},
5536             {"",S_FALSE},
5537             {"",S_FALSE},
5538             {"/c:/testing.mp3",S_OK},
5539             {"/c:/testing.mp3",S_OK},
5540             {"",S_FALSE},
5541             {"file:///c:/testing.mp3",S_OK},
5542             {"file",S_OK},
5543             {"",S_FALSE},
5544             {"",S_FALSE}
5545         },
5546         {
5547             {Uri_HOST_UNKNOWN,S_OK},
5548             {0,S_FALSE},
5549             {URL_SCHEME_FILE,S_OK},
5550             {URLZONE_INVALID,E_NOTIMPL}
5551         }
5552     },
5553     {   "file://test.com/test/test",0,
5554         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
5555         URL_FILE_USE_PATHURL,S_OK,FALSE,
5556         {
5557             {"file://\\\\test.com\\testing.mp3",S_OK},
5558             {"test.com",S_OK},
5559             {"file://\\\\test.com\\testing.mp3",S_OK},
5560             {"test.com",S_OK},
5561             {".mp3",S_OK},
5562             {"",S_FALSE},
5563             {"test.com",S_OK},
5564             {"",S_FALSE},
5565             {"\\testing.mp3",S_OK},
5566             {"\\testing.mp3",S_OK},
5567             {"",S_FALSE},
5568             {"file://\\\\test.com\\testing.mp3",S_OK},
5569             {"file",S_OK},
5570             {"",S_FALSE},
5571             {"",S_FALSE}
5572         },
5573         {
5574             {Uri_HOST_DNS,S_OK},
5575             {0,S_FALSE},
5576             {URL_SCHEME_FILE,S_OK},
5577             {URLZONE_INVALID,E_NOTIMPL}
5578         }
5579     },
5580     /* URL_DONT_SIMPLIFY has no effect. */
5581     {   "http://google.com/test",0,
5582         "zip://test.com/cool/../cool/test",0,
5583         URL_DONT_SIMPLIFY,S_OK,FALSE,
5584         {
5585             {"zip://test.com/cool/test",S_OK,FALSE,NULL,"zip://test.com/cool/../cool/test"},
5586             {"test.com",S_OK},
5587             {"zip://test.com/cool/test",S_OK,FALSE,NULL,"zip://test.com/cool/../cool/test"},
5588             {"test.com",S_OK},
5589             {"",S_FALSE},
5590             {"",S_FALSE},
5591             {"test.com",S_OK},
5592             {"",S_FALSE},
5593             {"/cool/test",S_OK,FALSE,NULL,"/cool/../cool/test"},
5594             {"/cool/test",S_OK,FALSE,NULL,"/cool/../cool/test"},
5595             {"",S_FALSE},
5596             /* The resulting IUri has the same Raw URI as the relative URI (only IE 8).
5597              * On IE 7 it reduces the path in the Raw URI.
5598              */
5599             {"zip://test.com/cool/../cool/test",S_OK,FALSE,"zip://test.com/cool/test"},
5600             {"zip",S_OK},
5601             {"",S_FALSE},
5602             {"",S_FALSE}
5603         },
5604         {
5605             {Uri_HOST_DNS,S_OK},
5606             {0,S_FALSE},
5607             {URL_SCHEME_UNKNOWN,S_OK},
5608             {URLZONE_INVALID,E_NOTIMPL}
5609         }
5610     },
5611     /* FILE_USE_PATHURL has no effect in IE 8, in IE 7 the
5612      * resulting URI is converted into a dos path.
5613      */
5614     {   "http://google.com/test",0,
5615         "file:///c:/test/",0,
5616         URL_FILE_USE_PATHURL,S_OK,FALSE,
5617         {
5618             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
5619             {"",S_FALSE},
5620             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
5621             {"",S_FALSE},
5622             {"",S_FALSE},
5623             {"",S_FALSE},
5624             {"",S_FALSE},
5625             {"",S_FALSE},
5626             {"/c:/test/",S_OK,FALSE,"c:\\test\\"},
5627             {"/c:/test/",S_OK,FALSE,"c:\\test\\"},
5628             {"",S_FALSE},
5629             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
5630             {"file",S_OK},
5631             {"",S_FALSE},
5632             {"",S_FALSE}
5633         },
5634         {
5635             {Uri_HOST_UNKNOWN,S_OK},
5636             {0,S_FALSE},
5637             {URL_SCHEME_FILE,S_OK},
5638             {URLZONE_INVALID,E_NOTIMPL}
5639         }
5640     },
5641     {   "http://google.com/test",0,
5642         "http://test.com/test#%30test",0,
5643         URL_DONT_UNESCAPE_EXTRA_INFO,S_OK,FALSE,
5644         {
5645             {"http://test.com/test#0test",S_OK,FALSE,NULL,"http://test.com/test#%30test"},
5646             {"test.com",S_OK},
5647             {"http://test.com/test#0test",S_OK,FALSE,NULL,"http://test.com/test#%30test"},
5648             {"test.com",S_OK},
5649             {"",S_FALSE},
5650             {"#0test",S_OK,FALSE,NULL,"#%30test"},
5651             {"test.com",S_OK},
5652             {"",S_FALSE},
5653             {"/test",S_OK},
5654             {"/test",S_OK},
5655             {"",S_FALSE},
5656             /* IE 7 decodes the %30 to a 0 in the Raw URI. */
5657             {"http://test.com/test#%30test",S_OK,FALSE,"http://test.com/test#0test"},
5658             {"http",S_OK},
5659             {"",S_FALSE},
5660             {"",S_FALSE}
5661         },
5662         {
5663             {Uri_HOST_DNS,S_OK},
5664             {80,S_OK},
5665             {URL_SCHEME_HTTP,S_OK},
5666             {URLZONE_INVALID,E_NOTIMPL}
5667         }
5668     },
5669     /* Windows validates the path component from the relative Uri. */
5670     {   "http://google.com/test",0,
5671         "/Te%XXst",Uri_CREATE_ALLOW_RELATIVE,
5672         0,E_INVALIDARG,FALSE
5673     },
5674     /* Windows doesn't validate the query from the relative Uri. */
5675     {   "http://google.com/test",0,
5676         "?Tes%XXt",Uri_CREATE_ALLOW_RELATIVE,
5677         0,S_OK,FALSE,
5678         {
5679             {"http://google.com/test?Tes%XXt",S_OK},
5680             {"google.com",S_OK},
5681             {"http://google.com/test?Tes%XXt",S_OK},
5682             {"google.com",S_OK},
5683             {"",S_FALSE},
5684             {"",S_FALSE},
5685             {"google.com",S_OK},
5686             {"",S_FALSE},
5687             {"/test",S_OK},
5688             {"/test?Tes%XXt",S_OK},
5689             {"?Tes%XXt",S_OK},
5690             {"http://google.com/test?Tes%XXt",S_OK},
5691             {"http",S_OK},
5692             {"",S_FALSE},
5693             {"",S_FALSE}
5694         },
5695         {
5696             {Uri_HOST_DNS,S_OK},
5697             {80,S_OK},
5698             {URL_SCHEME_HTTP,S_OK},
5699             {URLZONE_INVALID,E_NOTIMPL}
5700         }
5701     },
5702     /* Windows doesn't validate the fragment from the relative Uri. */
5703     {   "http://google.com/test",0,
5704         "#Tes%XXt",Uri_CREATE_ALLOW_RELATIVE,
5705         0,S_OK,FALSE,
5706         {
5707             {"http://google.com/test#Tes%XXt",S_OK},
5708             {"google.com",S_OK},
5709             {"http://google.com/test#Tes%XXt",S_OK},
5710             {"google.com",S_OK},
5711             {"",S_FALSE},
5712             {"#Tes%XXt",S_OK},
5713             {"google.com",S_OK},
5714             {"",S_FALSE},
5715             {"/test",S_OK},
5716             {"/test",S_OK},
5717             {"",S_FALSE},
5718             {"http://google.com/test#Tes%XXt",S_OK},
5719             {"http",S_OK},
5720             {"",S_FALSE},
5721             {"",S_FALSE}
5722         },
5723         {
5724             {Uri_HOST_DNS,S_OK},
5725             {80,S_OK},
5726             {URL_SCHEME_HTTP,S_OK},
5727             {URLZONE_INVALID,E_NOTIMPL}
5728         }
5729     },
5730     /* Creates an IUri which contains an invalid dos path char. */
5731     {   "file:///c:/test",0,
5732         "/test<ing",Uri_CREATE_ALLOW_RELATIVE,
5733         URL_FILE_USE_PATHURL,S_OK,FALSE,
5734         {
5735             {"file://c:\\test<ing",S_OK},
5736             {"",S_FALSE},
5737             {"file://c:\\test<ing",S_OK},
5738             {"",S_FALSE},
5739             {"",S_FALSE},
5740             {"",S_FALSE},
5741             {"",S_FALSE},
5742             {"",S_FALSE},
5743             {"c:\\test<ing",S_OK},
5744             {"c:\\test<ing",S_OK},
5745             {"",S_FALSE},
5746             {"file://c:\\test<ing",S_OK},
5747             {"file",S_OK},
5748             {"",S_FALSE},
5749             {"",S_FALSE}
5750         },
5751         {
5752             {Uri_HOST_UNKNOWN,S_OK},
5753             {0,S_FALSE},
5754             {URL_SCHEME_FILE,S_OK},
5755             {URLZONE_INVALID,E_NOTIMPL}
5756         }
5757     },
5758     /* Appends the path after the drive letter (if any). */
5759     {   "file:///c:/test",0,
5760         "/c:/testing",Uri_CREATE_ALLOW_RELATIVE,
5761         0,S_OK,FALSE,
5762         {
5763             {"file:///c:/c:/testing",S_OK},
5764             {"",S_FALSE},
5765             {"file:///c:/c:/testing",S_OK},
5766             {"",S_FALSE},
5767             {"",S_FALSE},
5768             {"",S_FALSE},
5769             {"",S_FALSE},
5770             {"",S_FALSE},
5771             {"/c:/c:/testing",S_OK},
5772             {"/c:/c:/testing",S_OK},
5773             {"",S_FALSE},
5774             {"file:///c:/c:/testing",S_OK},
5775             {"file",S_OK},
5776             {"",S_FALSE},
5777             {"",S_FALSE}
5778         },
5779         {
5780             {Uri_HOST_UNKNOWN,S_OK},
5781             {0,S_FALSE},
5782             {URL_SCHEME_FILE,S_OK},
5783             {URLZONE_INVALID,E_NOTIMPL}
5784         }
5785     },
5786     /* A '/' is added if the base URI doesn't have a path and the
5787      * relative URI doesn't contain a path (since the base URI is
5788      * hierarchical.
5789      */
5790     {   "http://google.com",Uri_CREATE_NO_CANONICALIZE,
5791         "?test",Uri_CREATE_ALLOW_RELATIVE,
5792         0,S_OK,FALSE,
5793         {
5794             {"http://google.com/?test",S_OK},
5795             {"google.com",S_OK},
5796             {"http://google.com/?test",S_OK},
5797             {"google.com",S_OK},
5798             {"",S_FALSE},
5799             {"",S_FALSE},
5800             {"google.com",S_OK},
5801             {"",S_FALSE},
5802             {"/",S_OK},
5803             {"/?test",S_OK},
5804             {"?test",S_OK},
5805             {"http://google.com/?test",S_OK},
5806             {"http",S_OK},
5807             {"",S_FALSE},
5808             {"",S_FALSE}
5809         },
5810         {
5811             {Uri_HOST_DNS,S_OK},
5812             {80,S_OK},
5813             {URL_SCHEME_HTTP,S_OK},
5814             {URLZONE_INVALID,E_NOTIMPL}
5815         }
5816     },
5817     {   "zip://google.com",Uri_CREATE_NO_CANONICALIZE,
5818         "?test",Uri_CREATE_ALLOW_RELATIVE,
5819         0,S_OK,FALSE,
5820         {
5821             {"zip://google.com/?test",S_OK},
5822             {"google.com",S_OK},
5823             {"zip://google.com/?test",S_OK},
5824             {"google.com",S_OK},
5825             {"",S_FALSE},
5826             {"",S_FALSE},
5827             {"google.com",S_OK},
5828             {"",S_FALSE},
5829             {"/",S_OK},
5830             {"/?test",S_OK},
5831             {"?test",S_OK},
5832             {"zip://google.com/?test",S_OK},
5833             {"zip",S_OK},
5834             {"",S_FALSE},
5835             {"",S_FALSE}
5836         },
5837         {
5838             {Uri_HOST_DNS,S_OK},
5839             {0,S_FALSE},
5840             {URL_SCHEME_UNKNOWN,S_OK},
5841             {URLZONE_INVALID,E_NOTIMPL}
5842         }
5843     },
5844     /* No path is appended since the base URI is opaque. */
5845     {   "zip:?testing",0,
5846         "?test",Uri_CREATE_ALLOW_RELATIVE,
5847         0,S_OK,FALSE,
5848         {
5849             {"zip:?test",S_OK},
5850             {"",S_FALSE},
5851             {"zip:?test",S_OK},
5852             {"",S_FALSE},
5853             {"",S_FALSE},
5854             {"",S_FALSE},
5855             {"",S_FALSE},
5856             {"",S_FALSE},
5857             {"",S_OK},
5858             {"?test",S_OK},
5859             {"?test",S_OK},
5860             {"zip:?test",S_OK},
5861             {"zip",S_OK},
5862             {"",S_FALSE},
5863             {"",S_FALSE}
5864         },
5865         {
5866             {Uri_HOST_UNKNOWN,S_OK},
5867             {0,S_FALSE},
5868             {URL_SCHEME_UNKNOWN,S_OK},
5869             {URLZONE_INVALID,E_NOTIMPL}
5870         }
5871     },
5872     {   "file:///c:/",0,
5873         "../testing/test",Uri_CREATE_ALLOW_RELATIVE,
5874         0,S_OK,FALSE,
5875         {
5876             {"file:///c:/testing/test",S_OK},
5877             {"",S_FALSE},
5878             {"file:///c:/testing/test",S_OK},
5879             {"",S_FALSE},
5880             {"",S_FALSE},
5881             {"",S_FALSE},
5882             {"",S_FALSE},
5883             {"",S_FALSE},
5884             {"/c:/testing/test",S_OK},
5885             {"/c:/testing/test",S_OK},
5886             {"",S_FALSE},
5887             {"file:///c:/testing/test",S_OK},
5888             {"file",S_OK},
5889             {"",S_FALSE},
5890             {"",S_FALSE}
5891         },
5892         {
5893             {Uri_HOST_UNKNOWN,S_OK},
5894             {0,S_FALSE},
5895             {URL_SCHEME_FILE,S_OK},
5896             {URLZONE_INVALID,E_NOTIMPL}
5897         }
5898     }
5899 };
5900
5901 typedef struct _uri_parse_test {
5902     const char  *uri;
5903     DWORD       uri_flags;
5904     PARSEACTION action;
5905     DWORD       flags;
5906     const char  *property;
5907     HRESULT     expected;
5908     BOOL        todo;
5909 } uri_parse_test;
5910
5911 static const uri_parse_test uri_parse_tests[] = {
5912     /* PARSE_CANONICALIZE tests. */
5913     {"zip://google.com/test<|>",0,PARSE_CANONICALIZE,0,"zip://google.com/test<|>",S_OK,FALSE},
5914     {"http://google.com/test<|>",0,PARSE_CANONICALIZE,0,"http://google.com/test%3C%7C%3E",S_OK,FALSE},
5915     {"http://google.com/%30%23%3F",0,PARSE_CANONICALIZE,URL_UNESCAPE,"http://google.com/0#?",S_OK,FALSE},
5916     {"test <|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_ESCAPE_UNSAFE,"test %3C%7C%3E",S_OK,FALSE},
5917     {"test <|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_ESCAPE_SPACES_ONLY,"test%20<|>",S_OK,FALSE},
5918     {"test%20<|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_UNESCAPE|URL_ESCAPE_UNSAFE,"test%20%3C%7C%3E",S_OK,FALSE},
5919     {"http://google.com/%20",0,PARSE_CANONICALIZE,URL_ESCAPE_PERCENT,"http://google.com/%2520",S_OK,FALSE},
5920     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_DONT_SIMPLIFY,"http://google.com/test/../",S_OK,FALSE},
5921     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_NO_META,"http://google.com/test/../",S_OK,FALSE},
5922     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,0,"http://google.com/",S_OK,FALSE},
5923     {"zip://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,0,"zip://google.com/",S_OK,FALSE},
5924     {"file:///c:/test/../test",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_DONT_SIMPLIFY,"file:///c:/test/../test",S_OK,FALSE},
5925
5926     /* PARSE_FRIENDLY tests. */
5927     {"http://test@google.com/test#test",0,PARSE_FRIENDLY,0,"http://google.com/test#test",S_OK,FALSE},
5928     {"zip://test@google.com/test",0,PARSE_FRIENDLY,0,"zip://test@google.com/test",S_OK,FALSE},
5929
5930     /* PARSE_ROOTDOCUMENT tests. */
5931     {"http://google.com:200/test/test",0,PARSE_ROOTDOCUMENT,0,"http://google.com:200/",S_OK,FALSE},
5932     {"http://google.com",Uri_CREATE_NO_CANONICALIZE,PARSE_ROOTDOCUMENT,0,"http://google.com/",S_OK,FALSE},
5933     {"zip://google.com/",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
5934     {"file:///c:/testing/",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
5935     {"file://server/test",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
5936     {"zip:test/test",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
5937
5938     /* PARSE_DOCUMENT tests. */
5939     {"http://test@google.com/test?query#frag",0,PARSE_DOCUMENT,0,"http://test@google.com/test?query",S_OK,FALSE},
5940     {"http:testing#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
5941     {"file:///c:/test#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
5942     {"zip://google.com/#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
5943     {"zip:test#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
5944     {"testing#frag",Uri_CREATE_ALLOW_RELATIVE,PARSE_DOCUMENT,0,"",S_OK,FALSE},
5945
5946     /* PARSE_PATH_FROM_URL tests. */
5947     {"file:///c:/test.mp3",0,PARSE_PATH_FROM_URL,0,"c:\\test.mp3",S_OK,FALSE},
5948     {"file:///c:/t<|>est.mp3",0,PARSE_PATH_FROM_URL,0,"c:\\t<|>est.mp3",S_OK,FALSE},
5949     {"file:///c:/te%XX t/",0,PARSE_PATH_FROM_URL,0,"c:\\te%XX t\\",S_OK,FALSE},
5950     {"file://server/test",0,PARSE_PATH_FROM_URL,0,"\\\\server\\test",S_OK,FALSE},
5951     {"http://google.com/",0,PARSE_PATH_FROM_URL,0,"",E_INVALIDARG,FALSE},
5952
5953     /* PARSE_URL_FROM_PATH tests. */
5954     /* This function almost seems to useless (just returns the absolute uri). */
5955     {"test.com",Uri_CREATE_ALLOW_RELATIVE,PARSE_URL_FROM_PATH,0,"test.com",S_OK,FALSE},
5956     {"/test/test",Uri_CREATE_ALLOW_RELATIVE,PARSE_URL_FROM_PATH,0,"/test/test",S_OK,FALSE},
5957     {"file://c:\\test\\test",Uri_CREATE_FILE_USE_DOS_PATH,PARSE_URL_FROM_PATH,0,"file://c:\\test\\test",S_OK,FALSE},
5958     {"file:c:/test",0,PARSE_URL_FROM_PATH,0,"",S_OK,FALSE},
5959     {"http:google.com/",0,PARSE_URL_FROM_PATH,0,"",S_OK,FALSE},
5960
5961     /* PARSE_SCHEMA tests. */
5962     {"http://google.com/test",0,PARSE_SCHEMA,0,"http",S_OK,FALSE},
5963     {"test",Uri_CREATE_ALLOW_RELATIVE,PARSE_SCHEMA,0,"",S_OK,FALSE},
5964
5965     /* PARSE_SITE tests. */
5966     {"http://google.uk.com/",0,PARSE_SITE,0,"google.uk.com",S_OK,FALSE},
5967     {"http://google.com.com/",0,PARSE_SITE,0,"google.com.com",S_OK,FALSE},
5968     {"google.com",Uri_CREATE_ALLOW_RELATIVE,PARSE_SITE,0,"",S_OK,FALSE},
5969     {"file://server/test",0,PARSE_SITE,0,"server",S_OK,FALSE},
5970
5971     /* PARSE_DOMAIN tests. */
5972     {"http://google.com.uk/",0,PARSE_DOMAIN,0,"google.com.uk",S_OK,FALSE},
5973     {"http://google.com.com/",0,PARSE_DOMAIN,0,"com.com",S_OK,FALSE},
5974     {"test/test",Uri_CREATE_ALLOW_RELATIVE,PARSE_DOMAIN,0,"",S_OK,FALSE},
5975     {"file://server/test",0,PARSE_DOMAIN,0,"",S_OK,FALSE},
5976
5977     /* PARSE_LOCATION and PARSE_ANCHOR tests. */
5978     {"http://google.com/test#Test",0,PARSE_ANCHOR,0,"#Test",S_OK,FALSE},
5979     {"http://google.com/test#Test",0,PARSE_LOCATION,0,"#Test",S_OK,FALSE},
5980     {"test",Uri_CREATE_ALLOW_RELATIVE,PARSE_ANCHOR,0,"",S_OK,FALSE},
5981     {"test",Uri_CREATE_ALLOW_RELATIVE,PARSE_LOCATION,0,"",S_OK,FALSE}
5982 };
5983
5984 static inline LPWSTR a2w(LPCSTR str) {
5985     LPWSTR ret = NULL;
5986
5987     if(str) {
5988         DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
5989         ret = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
5990         MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
5991     }
5992
5993     return ret;
5994 }
5995
5996 static inline BOOL heap_free(void* mem) {
5997     return HeapFree(GetProcessHeap(), 0, mem);
5998 }
5999
6000 static inline DWORD strcmp_aw(LPCSTR strA, LPCWSTR strB) {
6001     LPWSTR strAW = a2w(strA);
6002     DWORD ret = lstrcmpW(strAW, strB);
6003     heap_free(strAW);
6004     return ret;
6005 }
6006
6007 static inline ULONG get_refcnt(IUri *uri) {
6008     IUri_AddRef(uri);
6009     return IUri_Release(uri);
6010 }
6011
6012 static void change_property(IUriBuilder *builder, const uri_builder_property *prop,
6013                             DWORD test_index) {
6014     HRESULT hr;
6015     LPWSTR valueW;
6016
6017     valueW = a2w(prop->value);
6018     switch(prop->property) {
6019     case Uri_PROPERTY_FRAGMENT:
6020         hr = IUriBuilder_SetFragment(builder, valueW);
6021         if(prop->todo) {
6022             todo_wine {
6023                 ok(hr == prop->expected,
6024                     "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6025                     hr, prop->expected, test_index);
6026             }
6027         } else {
6028             ok(hr == prop->expected,
6029                 "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6030                 hr, prop->expected, test_index);
6031         }
6032         break;
6033     case Uri_PROPERTY_HOST:
6034         hr = IUriBuilder_SetHost(builder, valueW);
6035         if(prop->todo) {
6036             todo_wine {
6037                 ok(hr == prop->expected,
6038                     "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6039                     hr, prop->expected, test_index);
6040             }
6041         } else {
6042             ok(hr == prop->expected,
6043                 "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6044                 hr, prop->expected, test_index);
6045         }
6046         break;
6047     case Uri_PROPERTY_PASSWORD:
6048         hr = IUriBuilder_SetPassword(builder, valueW);
6049         if(prop->todo) {
6050             todo_wine {
6051                 ok(hr == prop->expected,
6052                     "Error: IUriBuilder_SetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6053                     hr, prop->expected, test_index);
6054             }
6055         } else {
6056             ok(hr == prop->expected,
6057                 "Error: IUriBuilder_SetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6058                 hr, prop->expected, test_index);
6059         }
6060         break;
6061     case Uri_PROPERTY_PATH:
6062         hr = IUriBuilder_SetPath(builder, valueW);
6063         if(prop->todo) {
6064             todo_wine {
6065                 ok(hr == prop->expected,
6066                     "Error: IUriBuilder_SetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6067                     hr, prop->expected, test_index);
6068             }
6069         } else {
6070             ok(hr == prop->expected,
6071                 "Error: IUriBuilder_SetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6072                 hr, prop->expected, test_index);
6073         }
6074         break;
6075     case Uri_PROPERTY_QUERY:
6076         hr = IUriBuilder_SetQuery(builder, valueW);
6077         if(prop->todo) {
6078             todo_wine {
6079                 ok(hr == prop->expected,
6080                     "Error: IUriBuilder_SetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6081                     hr, prop->expected, test_index);
6082             }
6083         } else {
6084             ok(hr == prop->expected,
6085                 "Error: IUriBuilder_SetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6086                 hr, prop->expected, test_index);
6087         }
6088         break;
6089     case Uri_PROPERTY_SCHEME_NAME:
6090         hr = IUriBuilder_SetSchemeName(builder, valueW);
6091         if(prop->todo) {
6092             todo_wine {
6093                 ok(hr == prop->expected,
6094                     "Error: IUriBuilder_SetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6095                     hr, prop->expected, test_index);
6096             }
6097         } else {
6098             ok(hr == prop->expected,
6099                 "Error: IUriBuilder_SetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6100                 hr, prop->expected, test_index);
6101         }
6102         break;
6103     case Uri_PROPERTY_USER_NAME:
6104         hr = IUriBuilder_SetUserName(builder, valueW);
6105         if(prop->todo) {
6106             todo_wine {
6107                 ok(hr == prop->expected,
6108                     "Error: IUriBuilder_SetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6109                     hr, prop->expected, test_index);
6110             }
6111         } else {
6112             ok(hr == prop->expected,
6113                 "Error: IUriBuilder_SetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6114                 hr, prop->expected, test_index);
6115         }
6116         break;
6117     default:
6118         trace("Unsupported operation for %d on uri_builder_tests[%d].\n", prop->property, test_index);
6119     }
6120
6121     heap_free(valueW);
6122 }
6123
6124 /*
6125  * Simple tests to make sure the CreateUri function handles invalid flag combinations
6126  * correctly.
6127  */
6128 static void test_CreateUri_InvalidFlags(void) {
6129     DWORD i;
6130
6131     for(i = 0; i < sizeof(invalid_flag_tests)/sizeof(invalid_flag_tests[0]); ++i) {
6132         HRESULT hr;
6133         IUri *uri = (void*) 0xdeadbeef;
6134
6135         hr = pCreateUri(http_urlW, invalid_flag_tests[i].flags, 0, &uri);
6136         ok(hr == invalid_flag_tests[i].expected, "Error: CreateUri returned 0x%08x, expected 0x%08x, flags=0x%08x\n",
6137                 hr, invalid_flag_tests[i].expected, invalid_flag_tests[i].flags);
6138         ok(uri == NULL, "Error: expected the IUri to be NULL, but it was %p instead\n", uri);
6139     }
6140 }
6141
6142 static void test_CreateUri_InvalidArgs(void) {
6143     HRESULT hr;
6144     IUri *uri = (void*) 0xdeadbeef;
6145
6146     const WCHAR invalidW[] = {'i','n','v','a','l','i','d',0};
6147     static const WCHAR emptyW[] = {0};
6148
6149     hr = pCreateUri(http_urlW, 0, 0, NULL);
6150     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG);
6151
6152     hr = pCreateUri(NULL, 0, 0, &uri);
6153     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG);
6154     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6155
6156     uri = (void*) 0xdeadbeef;
6157     hr = pCreateUri(invalidW, 0, 0, &uri);
6158     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6159     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6160
6161     uri = (void*) 0xdeadbeef;
6162     hr = pCreateUri(emptyW, 0, 0, &uri);
6163     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6164     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6165 }
6166
6167 static void test_CreateUri_InvalidUri(void) {
6168     DWORD i;
6169
6170     for(i = 0; i < sizeof(invalid_uri_tests)/sizeof(invalid_uri_tests[0]); ++i) {
6171         invalid_uri test = invalid_uri_tests[i];
6172         IUri *uri = NULL;
6173         LPWSTR uriW;
6174         HRESULT hr;
6175
6176         uriW = a2w(test.uri);
6177         hr = pCreateUri(uriW, test.flags, 0, &uri);
6178         if(test.todo) {
6179             todo_wine {
6180                 ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x on invalid_uri_tests[%d].\n",
6181                     hr, E_INVALIDARG, i);
6182             }
6183         } else {
6184             ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x on invalid_uri_tests[%d].\n",
6185                 hr, E_INVALIDARG, i);
6186         }
6187         if(uri) IUri_Release(uri);
6188
6189         heap_free(uriW);
6190     }
6191 }
6192
6193 static void test_IUri_GetPropertyBSTR(void) {
6194     IUri *uri = NULL;
6195     HRESULT hr;
6196     DWORD i;
6197
6198     /* Make sure GetPropertyBSTR handles invalid args correctly. */
6199     hr = pCreateUri(http_urlW, 0, 0, &uri);
6200     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6201     if(SUCCEEDED(hr)) {
6202         BSTR received = NULL;
6203
6204         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_RAW_URI, NULL, 0);
6205         ok(hr == E_POINTER, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6206
6207         /* Make sure it handles a invalid Uri_PROPERTY's correctly. */
6208         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_PORT, &received, 0);
6209         ok(hr == S_OK, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6210         ok(received != NULL, "Error: Expected the string not to be NULL.\n");
6211         ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
6212         SysFreeString(received);
6213
6214         /* Make sure it handles the ZONE property correctly. */
6215         received = NULL;
6216         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_ZONE, &received, 0);
6217         ok(hr == S_FALSE, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_FALSE);
6218         ok(received != NULL, "Error: Expected the string not to be NULL.\n");
6219         ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
6220         SysFreeString(received);
6221     }
6222     if(uri) IUri_Release(uri);
6223
6224     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6225         uri_properties test = uri_tests[i];
6226         LPWSTR uriW;
6227         uri = NULL;
6228
6229         uriW = a2w(test.uri);
6230         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6231         if(test.create_todo) {
6232             todo_wine {
6233                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6234                         hr, test.create_expected, i);
6235             }
6236         } else {
6237             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6238                     hr, test.create_expected, i);
6239         }
6240
6241         if(SUCCEEDED(hr)) {
6242             DWORD j;
6243
6244             /* Checks all the string properties of the uri. */
6245             for(j = Uri_PROPERTY_STRING_START; j <= Uri_PROPERTY_STRING_LAST; ++j) {
6246                 BSTR received = NULL;
6247                 uri_str_property prop = test.str_props[j];
6248
6249                 hr = IUri_GetPropertyBSTR(uri, j, &received, 0);
6250                 if(prop.todo) {
6251                     todo_wine {
6252                         ok(hr == prop.expected, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
6253                                 hr, prop.expected, i, j);
6254                     }
6255                     todo_wine {
6256                         ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6257                                 "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
6258                                 prop.value, wine_dbgstr_w(received), i, j);
6259                     }
6260                 } else {
6261                     ok(hr == prop.expected, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
6262                             hr, prop.expected, i, j);
6263                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6264                             "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
6265                             prop.value, wine_dbgstr_w(received), i, j);
6266                 }
6267
6268                 SysFreeString(received);
6269             }
6270         }
6271
6272         if(uri) IUri_Release(uri);
6273
6274         heap_free(uriW);
6275     }
6276 }
6277
6278 static void test_IUri_GetPropertyDWORD(void) {
6279     IUri *uri = NULL;
6280     HRESULT hr;
6281     DWORD i;
6282
6283     hr = pCreateUri(http_urlW, 0, 0, &uri);
6284     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6285     if(SUCCEEDED(hr)) {
6286         DWORD received = 0xdeadbeef;
6287
6288         hr = IUri_GetPropertyDWORD(uri, Uri_PROPERTY_DWORD_START, NULL, 0);
6289         ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6290
6291         hr = IUri_GetPropertyDWORD(uri, Uri_PROPERTY_ABSOLUTE_URI, &received, 0);
6292         ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6293         ok(received == 0, "Error: Expected received=%d but instead received=%d.\n", 0, received);
6294     }
6295     if(uri) IUri_Release(uri);
6296
6297     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6298         uri_properties test = uri_tests[i];
6299         LPWSTR uriW;
6300         uri = NULL;
6301
6302         uriW = a2w(test.uri);
6303         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6304         if(test.create_todo) {
6305             todo_wine {
6306                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6307                         hr, test.create_expected, i);
6308             }
6309         } else {
6310             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6311                     hr, test.create_expected, i);
6312         }
6313
6314         if(SUCCEEDED(hr)) {
6315             DWORD j;
6316
6317             /* Checks all the DWORD properties of the uri. */
6318             for(j = 0; j < sizeof(test.dword_props)/sizeof(test.dword_props[0]); ++j) {
6319                 DWORD received;
6320                 uri_dword_property prop = test.dword_props[j];
6321
6322                 hr = IUri_GetPropertyDWORD(uri, j+Uri_PROPERTY_DWORD_START, &received, 0);
6323                 if(prop.todo) {
6324                     todo_wine {
6325                         ok(hr == prop.expected, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
6326                                 hr, prop.expected, i, j);
6327                     }
6328                     todo_wine {
6329                         ok(prop.value == received, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
6330                                 prop.value, received, i, j);
6331                     }
6332                 } else {
6333                     ok(hr == prop.expected, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
6334                             hr, prop.expected, i, j);
6335                     ok(prop.value == received, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
6336                             prop.value, received, i, j);
6337                 }
6338             }
6339         }
6340
6341         if(uri) IUri_Release(uri);
6342
6343         heap_free(uriW);
6344     }
6345 }
6346
6347 /* Tests all the 'Get*' property functions which deal with strings. */
6348 static void test_IUri_GetStrProperties(void) {
6349     IUri *uri = NULL;
6350     HRESULT hr;
6351     DWORD i;
6352
6353     /* Make sure all the 'Get*' string property functions handle invalid args correctly. */
6354     hr = pCreateUri(http_urlW, 0, 0, &uri);
6355     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6356     if(SUCCEEDED(hr)) {
6357         hr = IUri_GetAbsoluteUri(uri, NULL);
6358         ok(hr == E_POINTER, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6359
6360         hr = IUri_GetAuthority(uri, NULL);
6361         ok(hr == E_POINTER, "Error: GetAuthority returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6362
6363         hr = IUri_GetDisplayUri(uri, NULL);
6364         ok(hr == E_POINTER, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6365
6366         hr = IUri_GetDomain(uri, NULL);
6367         ok(hr == E_POINTER, "Error: GetDomain returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6368
6369         hr = IUri_GetExtension(uri, NULL);
6370         ok(hr == E_POINTER, "Error: GetExtension returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6371
6372         hr = IUri_GetFragment(uri, NULL);
6373         ok(hr == E_POINTER, "Error: GetFragment returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6374
6375         hr = IUri_GetHost(uri, NULL);
6376         ok(hr == E_POINTER, "Error: GetHost returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6377
6378         hr = IUri_GetPassword(uri, NULL);
6379         ok(hr == E_POINTER, "Error: GetPassword returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6380
6381         hr = IUri_GetPath(uri, NULL);
6382         ok(hr == E_POINTER, "Error: GetPath returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6383
6384         hr = IUri_GetPathAndQuery(uri, NULL);
6385         ok(hr == E_POINTER, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6386
6387         hr = IUri_GetQuery(uri, NULL);
6388         ok(hr == E_POINTER, "Error: GetQuery returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6389
6390         hr = IUri_GetRawUri(uri, NULL);
6391         ok(hr == E_POINTER, "Error: GetRawUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6392
6393         hr = IUri_GetSchemeName(uri, NULL);
6394         ok(hr == E_POINTER, "Error: GetSchemeName returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6395
6396         hr = IUri_GetUserInfo(uri, NULL);
6397         ok(hr == E_POINTER, "Error: GetUserInfo returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6398
6399         hr = IUri_GetUserName(uri, NULL);
6400         ok(hr == E_POINTER, "Error: GetUserName returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6401     }
6402     if(uri) IUri_Release(uri);
6403
6404     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6405         uri_properties test = uri_tests[i];
6406         LPWSTR uriW;
6407         uri = NULL;
6408
6409         uriW = a2w(test.uri);
6410         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6411         if(test.create_todo) {
6412             todo_wine {
6413                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6414                         hr, test.create_expected, i);
6415             }
6416         } else {
6417             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6418                     hr, test.create_expected, i);
6419         }
6420
6421         if(SUCCEEDED(hr)) {
6422             uri_str_property prop;
6423             BSTR received = NULL;
6424
6425             /* GetAbsoluteUri() tests. */
6426             prop = test.str_props[Uri_PROPERTY_ABSOLUTE_URI];
6427             hr = IUri_GetAbsoluteUri(uri, &received);
6428             if(prop.todo) {
6429                 todo_wine {
6430                     ok(hr == prop.expected, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6431                             hr, prop.expected, i);
6432                 }
6433                 todo_wine {
6434                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6435                             "Error: Expected %s but got %s on uri_tests[%d].\n",
6436                             prop.value, wine_dbgstr_w(received), i);
6437                 }
6438             } else {
6439                 ok(hr == prop.expected, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6440                         hr, prop.expected, i);
6441                 ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6442                         "Error: Expected %s but got %s on uri_tests[%d].\n",
6443                         prop.value, wine_dbgstr_w(received), i);
6444             }
6445             SysFreeString(received);
6446             received = NULL;
6447
6448             /* GetAuthority() tests. */
6449             prop = test.str_props[Uri_PROPERTY_AUTHORITY];
6450             hr = IUri_GetAuthority(uri, &received);
6451             if(prop.todo) {
6452                 todo_wine {
6453                     ok(hr == prop.expected, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6454                             hr, prop.expected, i);
6455                 }
6456                 todo_wine {
6457                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6458                             prop.value, wine_dbgstr_w(received), i);
6459                 }
6460             } else {
6461                 ok(hr == prop.expected, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6462                         hr, prop.expected, i);
6463                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6464                         prop.value, wine_dbgstr_w(received), i);
6465             }
6466             SysFreeString(received);
6467             received = NULL;
6468
6469             /* GetDisplayUri() tests. */
6470             prop = test.str_props[Uri_PROPERTY_DISPLAY_URI];
6471             hr = IUri_GetDisplayUri(uri, &received);
6472             if(prop.todo) {
6473                 todo_wine {
6474                     ok(hr == prop.expected, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6475                             hr, prop.expected, i);
6476                 }
6477                 todo_wine {
6478                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6479                             "Error: Expected %s but got %s on uri_test[%d].\n",
6480                             prop.value, wine_dbgstr_w(received), i);
6481                 }
6482             } else {
6483                 ok(hr == prop.expected, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6484                         hr, prop.expected, i);
6485                 ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6486                         "Error: Expected %s but got %s on uri_tests[%d].\n",
6487                         prop.value, wine_dbgstr_w(received), i);
6488             }
6489             SysFreeString(received);
6490             received = NULL;
6491
6492             /* GetDomain() tests. */
6493             prop = test.str_props[Uri_PROPERTY_DOMAIN];
6494             hr = IUri_GetDomain(uri, &received);
6495             if(prop.todo) {
6496                 todo_wine {
6497                     ok(hr == prop.expected, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6498                             hr, prop.expected, i);
6499                 }
6500                 todo_wine {
6501                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6502                             prop.value, wine_dbgstr_w(received), i);
6503                 }
6504             } else {
6505                 ok(hr == prop.expected, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6506                         hr, prop.expected, i);
6507                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6508                         prop.value, wine_dbgstr_w(received), i);
6509             }
6510             SysFreeString(received);
6511             received = NULL;
6512
6513             /* GetExtension() tests. */
6514             prop = test.str_props[Uri_PROPERTY_EXTENSION];
6515             hr = IUri_GetExtension(uri, &received);
6516             if(prop.todo) {
6517                 todo_wine {
6518                     ok(hr == prop.expected, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6519                             hr, prop.expected, i);
6520                 }
6521                 todo_wine {
6522                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6523                             prop.value, wine_dbgstr_w(received), i);
6524                 }
6525             } else {
6526                 ok(hr == prop.expected, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6527                         hr, prop.expected, i);
6528                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6529                         prop.value, wine_dbgstr_w(received), i);
6530             }
6531             SysFreeString(received);
6532             received = NULL;
6533
6534             /* GetFragment() tests. */
6535             prop = test.str_props[Uri_PROPERTY_FRAGMENT];
6536             hr = IUri_GetFragment(uri, &received);
6537             if(prop.todo) {
6538                 todo_wine {
6539                     ok(hr == prop.expected, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6540                             hr, prop.expected, i);
6541                 }
6542                 todo_wine {
6543                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6544                             prop.value, wine_dbgstr_w(received), i);
6545                 }
6546             } else {
6547                 ok(hr == prop.expected, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6548                         hr, prop.expected, i);
6549                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6550                         prop.value, wine_dbgstr_w(received), i);
6551             }
6552             SysFreeString(received);
6553             received = NULL;
6554
6555             /* GetHost() tests. */
6556             prop = test.str_props[Uri_PROPERTY_HOST];
6557             hr = IUri_GetHost(uri, &received);
6558             if(prop.todo) {
6559                 todo_wine {
6560                     ok(hr == prop.expected, "Error: GetHost returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6561                             hr, prop.expected, i);
6562                 }
6563                 todo_wine {
6564                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6565                             prop.value, wine_dbgstr_w(received), i);
6566                 }
6567             } else {
6568                 ok(hr == prop.expected, "Error: GetHost returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6569                         hr, prop.expected, i);
6570                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6571                         prop.value, wine_dbgstr_w(received), i);
6572             }
6573             SysFreeString(received);
6574             received = NULL;
6575
6576             /* GetPassword() tests. */
6577             prop = test.str_props[Uri_PROPERTY_PASSWORD];
6578             hr = IUri_GetPassword(uri, &received);
6579             if(prop.todo) {
6580                 todo_wine {
6581                     ok(hr == prop.expected, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6582                             hr, prop.expected, i);
6583                 }
6584                 todo_wine {
6585                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6586                             prop.value, wine_dbgstr_w(received), i);
6587                 }
6588             } else {
6589                 ok(hr == prop.expected, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6590                         hr, prop.expected, i);
6591                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6592                         prop.value, wine_dbgstr_w(received), i);
6593             }
6594             SysFreeString(received);
6595             received = NULL;
6596
6597             /* GetPath() tests. */
6598             prop = test.str_props[Uri_PROPERTY_PATH];
6599             hr = IUri_GetPath(uri, &received);
6600             if(prop.todo) {
6601                 todo_wine {
6602                     ok(hr == prop.expected, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6603                             hr, prop.expected, i);
6604                 }
6605                 todo_wine {
6606                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6607                             prop.value, wine_dbgstr_w(received), i);
6608                 }
6609             } else {
6610                 ok(hr == prop.expected, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6611                         hr, prop.expected, i);
6612                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6613                         prop.value, wine_dbgstr_w(received), i);
6614             }
6615             SysFreeString(received);
6616             received = NULL;
6617
6618             /* GetPathAndQuery() tests. */
6619             prop = test.str_props[Uri_PROPERTY_PATH_AND_QUERY];
6620             hr = IUri_GetPathAndQuery(uri, &received);
6621             if(prop.todo) {
6622                 todo_wine {
6623                     ok(hr == prop.expected, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6624                             hr, prop.expected, i);
6625                 }
6626                 todo_wine {
6627                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6628                             prop.value, wine_dbgstr_w(received), i);
6629                 }
6630             } else {
6631                 ok(hr == prop.expected, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6632                         hr, prop.expected, i);
6633                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6634                         prop.value, wine_dbgstr_w(received), i);
6635             }
6636             SysFreeString(received);
6637             received = NULL;
6638
6639             /* GetQuery() tests. */
6640             prop = test.str_props[Uri_PROPERTY_QUERY];
6641             hr = IUri_GetQuery(uri, &received);
6642             if(prop.todo) {
6643                 todo_wine {
6644                     ok(hr == prop.expected, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6645                             hr, prop.expected, i);
6646                 }
6647                 todo_wine {
6648                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6649                             prop.value, wine_dbgstr_w(received), i);
6650                 }
6651             } else {
6652                 ok(hr == prop.expected, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6653                         hr, prop.expected, i);
6654                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6655                         prop.value, wine_dbgstr_w(received), i);
6656             }
6657             SysFreeString(received);
6658             received = NULL;
6659
6660             /* GetRawUri() tests. */
6661             prop = test.str_props[Uri_PROPERTY_RAW_URI];
6662             hr = IUri_GetRawUri(uri, &received);
6663             if(prop.todo) {
6664                 todo_wine {
6665                     ok(hr == prop.expected, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6666                             hr, prop.expected, i);
6667                 }
6668                 todo_wine {
6669                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6670                             prop.value, wine_dbgstr_w(received), i);
6671                 }
6672             } else {
6673                 ok(hr == prop.expected, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6674                         hr, prop.expected, i);
6675                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6676                         prop.value, wine_dbgstr_w(received), i);
6677             }
6678             SysFreeString(received);
6679             received = NULL;
6680
6681             /* GetSchemeName() tests. */
6682             prop = test.str_props[Uri_PROPERTY_SCHEME_NAME];
6683             hr = IUri_GetSchemeName(uri, &received);
6684             if(prop.todo) {
6685                 todo_wine {
6686                     ok(hr == prop.expected, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6687                             hr, prop.expected, i);
6688                 }
6689                 todo_wine {
6690                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6691                             prop.value, wine_dbgstr_w(received), i);
6692                 }
6693             } else {
6694                 ok(hr == prop.expected, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6695                         hr, prop.expected, i);
6696                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6697                         prop.value, wine_dbgstr_w(received), i);
6698             }
6699             SysFreeString(received);
6700             received = NULL;
6701
6702             /* GetUserInfo() tests. */
6703             prop = test.str_props[Uri_PROPERTY_USER_INFO];
6704             hr = IUri_GetUserInfo(uri, &received);
6705             if(prop.todo) {
6706                 todo_wine {
6707                     ok(hr == prop.expected, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6708                             hr, prop.expected, i);
6709                 }
6710                 todo_wine {
6711                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6712                             prop.value, wine_dbgstr_w(received), i);
6713                 }
6714             } else {
6715                 ok(hr == prop.expected, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6716                         hr, prop.expected, i);
6717                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6718                         prop.value, wine_dbgstr_w(received), i);
6719             }
6720             SysFreeString(received);
6721             received = NULL;
6722
6723             /* GetUserName() tests. */
6724             prop = test.str_props[Uri_PROPERTY_USER_NAME];
6725             hr = IUri_GetUserName(uri, &received);
6726             if(prop.todo) {
6727                 todo_wine {
6728                     ok(hr == prop.expected, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6729                             hr, prop.expected, i);
6730                 }
6731                 todo_wine {
6732                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6733                             prop.value, wine_dbgstr_w(received), i);
6734                 }
6735             } else {
6736                 ok(hr == prop.expected, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6737                         hr, prop.expected, i);
6738                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6739                         prop.value, wine_dbgstr_w(received), i);
6740             }
6741             SysFreeString(received);
6742         }
6743
6744         if(uri) IUri_Release(uri);
6745
6746         heap_free(uriW);
6747     }
6748 }
6749
6750 static void test_IUri_GetDwordProperties(void) {
6751     IUri *uri = NULL;
6752     HRESULT hr;
6753     DWORD i;
6754
6755     /* Make sure all the 'Get*' dword property functions handle invalid args correctly. */
6756     hr = pCreateUri(http_urlW, 0, 0, &uri);
6757     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6758     if(SUCCEEDED(hr)) {
6759         hr = IUri_GetHostType(uri, NULL);
6760         ok(hr == E_INVALIDARG, "Error: GetHostType returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6761
6762         hr = IUri_GetPort(uri, NULL);
6763         ok(hr == E_INVALIDARG, "Error: GetPort returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6764
6765         hr = IUri_GetScheme(uri, NULL);
6766         ok(hr == E_INVALIDARG, "Error: GetScheme returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6767
6768         hr = IUri_GetZone(uri, NULL);
6769         ok(hr == E_INVALIDARG, "Error: GetZone returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6770     }
6771     if(uri) IUri_Release(uri);
6772
6773     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6774         uri_properties test = uri_tests[i];
6775         LPWSTR uriW;
6776         uri = NULL;
6777
6778         uriW = a2w(test.uri);
6779         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6780         if(test.create_todo) {
6781             todo_wine {
6782                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6783                         hr, test.create_expected, i);
6784             }
6785         } else {
6786             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6787                     hr, test.create_expected, i);
6788         }
6789
6790         if(SUCCEEDED(hr)) {
6791             uri_dword_property prop;
6792             DWORD received;
6793
6794             /* Assign an insane value so tests don't accidentally pass when
6795              * they shouldn't!
6796              */
6797             received = -9999999;
6798
6799             /* GetHostType() tests. */
6800             prop = test.dword_props[Uri_PROPERTY_HOST_TYPE-Uri_PROPERTY_DWORD_START];
6801             hr = IUri_GetHostType(uri, &received);
6802             if(prop.todo) {
6803                 todo_wine {
6804                     ok(hr == prop.expected, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6805                             hr, prop.expected, i);
6806                 }
6807                 todo_wine {
6808                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6809                 }
6810             } else {
6811                 ok(hr == prop.expected, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6812                         hr, prop.expected, i);
6813                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6814             }
6815             received = -9999999;
6816
6817             /* GetPort() tests. */
6818             prop = test.dword_props[Uri_PROPERTY_PORT-Uri_PROPERTY_DWORD_START];
6819             hr = IUri_GetPort(uri, &received);
6820             if(prop.todo) {
6821                 todo_wine {
6822                     ok(hr == prop.expected, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6823                             hr, prop.expected, i);
6824                 }
6825                 todo_wine {
6826                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6827                 }
6828             } else {
6829                 ok(hr == prop.expected, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6830                         hr, prop.expected, i);
6831                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6832             }
6833             received = -9999999;
6834
6835             /* GetScheme() tests. */
6836             prop = test.dword_props[Uri_PROPERTY_SCHEME-Uri_PROPERTY_DWORD_START];
6837             hr = IUri_GetScheme(uri, &received);
6838             if(prop.todo) {
6839                 todo_wine {
6840                     ok(hr == prop.expected, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6841                             hr, prop.expected, i);
6842                 }
6843                 todo_wine {
6844                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6845                 }
6846             } else {
6847                 ok(hr == prop.expected, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6848                         hr, prop.expected, i);
6849                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6850             }
6851             received = -9999999;
6852
6853             /* GetZone() tests. */
6854             prop = test.dword_props[Uri_PROPERTY_ZONE-Uri_PROPERTY_DWORD_START];
6855             hr = IUri_GetZone(uri, &received);
6856             if(prop.todo) {
6857                 todo_wine {
6858                     ok(hr == prop.expected, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6859                             hr, prop.expected, i);
6860                 }
6861                 todo_wine {
6862                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6863                 }
6864             } else {
6865                 ok(hr == prop.expected, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6866                         hr, prop.expected, i);
6867                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6868             }
6869         }
6870
6871         if(uri) IUri_Release(uri);
6872
6873         heap_free(uriW);
6874     }
6875 }
6876
6877 static void test_IUri_GetPropertyLength(void) {
6878     IUri *uri = NULL;
6879     HRESULT hr;
6880     DWORD i;
6881
6882     /* Make sure it handles invalid args correctly. */
6883     hr = pCreateUri(http_urlW, 0, 0, &uri);
6884     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6885     if(SUCCEEDED(hr)) {
6886         DWORD received = 0xdeadbeef;
6887
6888         hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_STRING_START, NULL, 0);
6889         ok(hr == E_INVALIDARG, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6890
6891         hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_DWORD_START, &received, 0);
6892         ok(hr == E_INVALIDARG, "Error: GetPropertyLength return 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6893         ok(received == 0xdeadbeef, "Error: Expected 0xdeadbeef but got 0x%08x.\n", received);
6894     }
6895     if(uri) IUri_Release(uri);
6896
6897     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6898         uri_properties test = uri_tests[i];
6899         LPWSTR uriW;
6900         uri = NULL;
6901
6902         uriW = a2w(test.uri);
6903         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6904         if(test.create_todo) {
6905             todo_wine {
6906                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6907                         hr, test.create_expected, i);
6908             }
6909         } else {
6910             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_test[%d].\n",
6911                     hr, test.create_expected, i);
6912         }
6913
6914         if(SUCCEEDED(hr)) {
6915             DWORD j;
6916
6917             for(j = Uri_PROPERTY_STRING_START; j <= Uri_PROPERTY_STRING_LAST; ++j) {
6918                 DWORD expectedLen, brokenLen, receivedLen;
6919                 uri_str_property prop = test.str_props[j];
6920
6921                 expectedLen = lstrlen(prop.value);
6922                 brokenLen = lstrlen(prop.broken_value);
6923
6924                 /* This won't be necessary once GetPropertyLength is implemented. */
6925                 receivedLen = -1;
6926
6927                 hr = IUri_GetPropertyLength(uri, j, &receivedLen, 0);
6928                 if(prop.todo) {
6929                     todo_wine {
6930                         ok(hr == prop.expected, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
6931                                 hr, prop.expected, i, j);
6932                     }
6933                     todo_wine {
6934                         ok(receivedLen == expectedLen || broken(receivedLen == brokenLen),
6935                                 "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
6936                                 expectedLen, receivedLen, i, j);
6937                     }
6938                 } else {
6939                     ok(hr == prop.expected, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
6940                             hr, prop.expected, i, j);
6941                     ok(receivedLen == expectedLen || broken(receivedLen == brokenLen),
6942                             "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
6943                             expectedLen, receivedLen, i, j);
6944                 }
6945             }
6946         }
6947
6948         if(uri) IUri_Release(uri);
6949
6950         heap_free(uriW);
6951     }
6952 }
6953
6954 static DWORD compute_expected_props(uri_properties *test)
6955 {
6956     DWORD ret = 0, i;
6957
6958     for(i=Uri_PROPERTY_STRING_START; i <= Uri_PROPERTY_STRING_LAST; i++) {
6959         if(test->str_props[i-Uri_PROPERTY_STRING_START].expected == S_OK)
6960             ret |= 1<<i;
6961     }
6962
6963     for(i=Uri_PROPERTY_DWORD_START; i <= Uri_PROPERTY_DWORD_LAST; i++) {
6964         if(test->dword_props[i-Uri_PROPERTY_DWORD_START].expected == S_OK)
6965             ret |= 1<<i;
6966     }
6967
6968     return ret;
6969 }
6970
6971 static void test_IUri_GetProperties(void) {
6972     IUri *uri = NULL;
6973     HRESULT hr;
6974     DWORD i;
6975
6976     hr = pCreateUri(http_urlW, 0, 0, &uri);
6977     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6978     if(SUCCEEDED(hr)) {
6979         hr = IUri_GetProperties(uri, NULL);
6980         ok(hr == E_INVALIDARG, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6981     }
6982     if(uri) IUri_Release(uri);
6983
6984     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6985         uri_properties test = uri_tests[i];
6986         LPWSTR uriW;
6987         uri = NULL;
6988
6989         uriW = a2w(test.uri);
6990         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6991         if(test.create_todo) {
6992             todo_wine {
6993                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
6994             }
6995         } else {
6996             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
6997         }
6998
6999         if(SUCCEEDED(hr)) {
7000             DWORD received = 0, expected_props;
7001             DWORD j;
7002
7003             hr = IUri_GetProperties(uri, &received);
7004             ok(hr == S_OK, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7005
7006             expected_props = compute_expected_props(&test);
7007
7008             for(j = 0; j <= Uri_PROPERTY_DWORD_LAST; ++j) {
7009                 /* (1 << j) converts a Uri_PROPERTY to its corresponding Uri_HAS_* flag mask. */
7010                 if(expected_props & (1 << j))
7011                     ok(received & (1 << j), "Error: Expected flag for property %d on uri_tests[%d].\n", j, i);
7012                 else
7013                     ok(!(received & (1 << j)), "Error: Received flag for property %d when not expected on uri_tests[%d].\n", j, i);
7014             }
7015         }
7016
7017         if(uri) IUri_Release(uri);
7018
7019         heap_free(uriW);
7020     }
7021 }
7022
7023 static void test_IUri_HasProperty(void) {
7024     IUri *uri = NULL;
7025     HRESULT hr;
7026     DWORD i;
7027
7028     hr = pCreateUri(http_urlW, 0, 0, &uri);
7029     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7030     if(SUCCEEDED(hr)) {
7031         hr = IUri_HasProperty(uri, Uri_PROPERTY_RAW_URI, NULL);
7032         ok(hr == E_INVALIDARG, "Error: HasProperty returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7033     }
7034     if(uri) IUri_Release(uri);
7035
7036     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7037         uri_properties test = uri_tests[i];
7038         LPWSTR uriW;
7039         uri = NULL;
7040
7041         uriW = a2w(test.uri);
7042
7043         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7044         if(test.create_todo) {
7045             todo_wine {
7046                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7047             }
7048         } else {
7049             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7050         }
7051
7052         if(SUCCEEDED(hr)) {
7053             DWORD expected_props, j;
7054
7055             expected_props = compute_expected_props(&test);
7056
7057             for(j = 0; j <= Uri_PROPERTY_DWORD_LAST; ++j) {
7058                 /* Assign -1, then explicitly test for TRUE or FALSE later. */
7059                 BOOL received = -1;
7060
7061                 hr = IUri_HasProperty(uri, j, &received);
7062                 ok(hr == S_OK, "Error: HasProperty returned 0x%08x, expected 0x%08x for property %d on uri_tests[%d].\n",
7063                         hr, S_OK, j, i);
7064
7065                 if(expected_props & (1 << j)) {
7066                     ok(received == TRUE, "Error: Expected to have property %d on uri_tests[%d].\n", j, i);
7067                 } else {
7068                     ok(received == FALSE, "Error: Wasn't expecting to have property %d on uri_tests[%d].\n", j, i);
7069                 }
7070             }
7071         }
7072
7073         if(uri) IUri_Release(uri);
7074
7075         heap_free(uriW);
7076     }
7077 }
7078
7079 static void test_IUri_IsEqual(void) {
7080     IUri *uriA, *uriB;
7081     HRESULT hrA, hrB;
7082     DWORD i;
7083
7084     uriA = uriB = NULL;
7085
7086     /* Make sure IsEqual handles invalid args correctly. */
7087     hrA = pCreateUri(http_urlW, 0, 0, &uriA);
7088     hrB = pCreateUri(http_urlW, 0, 0, &uriB);
7089     ok(hrA == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hrA, S_OK);
7090     ok(hrB == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hrB, S_OK);
7091     if(SUCCEEDED(hrA) && SUCCEEDED(hrB)) {
7092         BOOL equal = -1;
7093         hrA = IUri_IsEqual(uriA, NULL, &equal);
7094         ok(hrA == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x.\n", hrA, S_OK);
7095         ok(equal == FALSE, "Error: Expected equal to be FALSE, but was %d instead.\n", equal);
7096
7097         hrA = IUri_IsEqual(uriA, uriB, NULL);
7098         ok(hrA == E_POINTER, "Error: IsEqual returned 0x%08x, expected 0x%08x.\n", hrA, E_POINTER);
7099     }
7100     if(uriA) IUri_Release(uriA);
7101     if(uriB) IUri_Release(uriB);
7102
7103     for(i = 0; i < sizeof(equality_tests)/sizeof(equality_tests[0]); ++i) {
7104         uri_equality test = equality_tests[i];
7105         LPWSTR uriA_W, uriB_W;
7106
7107         uriA = uriB = NULL;
7108
7109         uriA_W = a2w(test.a);
7110         uriB_W = a2w(test.b);
7111
7112         hrA = pCreateUri(uriA_W, test.create_flags_a, 0, &uriA);
7113         if(test.create_todo_a) {
7114             todo_wine {
7115                 ok(hrA == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].a\n",
7116                         hrA, S_OK, i);
7117             }
7118         } else {
7119             ok(hrA == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].a\n",
7120                     hrA, S_OK, i);
7121         }
7122
7123         hrB = pCreateUri(uriB_W, test.create_flags_b, 0, &uriB);
7124         if(test.create_todo_b) {
7125             todo_wine {
7126                 ok(hrB == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].b\n",
7127                         hrB, S_OK, i);
7128             }
7129         } else {
7130             ok(hrB == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].b\n",
7131                     hrB, S_OK, i);
7132         }
7133
7134         if(SUCCEEDED(hrA) && SUCCEEDED(hrB)) {
7135             BOOL equal = -1;
7136
7137             hrA = IUri_IsEqual(uriA, uriB, &equal);
7138             if(test.todo) {
7139                 todo_wine {
7140                     ok(hrA == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x on equality_tests[%d].\n",
7141                             hrA, S_OK, i);
7142                 }
7143                 todo_wine {
7144                     ok(equal == test.equal, "Error: Expected the comparison to be %d on equality_tests[%d].\n", test.equal, i);
7145                 }
7146             } else {
7147                 ok(hrA == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x on equality_tests[%d].\n", hrA, S_OK, i);
7148                 ok(equal == test.equal, "Error: Expected the comparison to be %d on equality_tests[%d].\n", test.equal, i);
7149             }
7150         }
7151         if(uriA) IUri_Release(uriA);
7152         if(uriB) IUri_Release(uriB);
7153
7154         heap_free(uriA_W);
7155         heap_free(uriB_W);
7156     }
7157 }
7158
7159 static void test_CreateUriWithFragment_InvalidArgs(void) {
7160     HRESULT hr;
7161     IUri *uri = (void*) 0xdeadbeef;
7162     const WCHAR fragmentW[] = {'#','f','r','a','g','m','e','n','t',0};
7163
7164     hr = pCreateUriWithFragment(NULL, fragmentW, 0, 0, &uri);
7165     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7166     ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7167
7168     hr = pCreateUriWithFragment(http_urlW, fragmentW, 0, 0, NULL);
7169     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7170
7171     /* Original URI can't already contain a fragment component. */
7172     uri = (void*) 0xdeadbeef;
7173     hr = pCreateUriWithFragment(http_url_fragW, fragmentW, 0, 0, &uri);
7174     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7175     ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7176 }
7177
7178 /* CreateUriWithFragment has the same invalid flag combinations as CreateUri. */
7179 static void test_CreateUriWithFragment_InvalidFlags(void) {
7180     DWORD i;
7181
7182     for(i = 0; i < sizeof(invalid_flag_tests)/sizeof(invalid_flag_tests[0]); ++i) {
7183         HRESULT hr;
7184         IUri *uri = (void*) 0xdeadbeef;
7185
7186         hr = pCreateUriWithFragment(http_urlW, NULL, invalid_flag_tests[i].flags, 0, &uri);
7187         ok(hr == invalid_flag_tests[i].expected, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x. flags=0x%08x.\n",
7188             hr, invalid_flag_tests[i].expected, invalid_flag_tests[i].flags);
7189         ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7190     }
7191 }
7192
7193 static void test_CreateUriWithFragment(void) {
7194     DWORD i;
7195
7196     for(i = 0; i < sizeof(uri_fragment_tests)/sizeof(uri_fragment_tests[0]); ++i) {
7197         HRESULT hr;
7198         IUri *uri = NULL;
7199         LPWSTR uriW, fragW;
7200         uri_with_fragment test = uri_fragment_tests[i];
7201
7202         uriW = a2w(test.uri);
7203         fragW = a2w(test.fragment);
7204
7205         hr = pCreateUriWithFragment(uriW, fragW, test.create_flags, 0, &uri);
7206         if(test.expected_todo) {
7207             todo_wine {
7208                 ok(hr == test.create_expected,
7209                     "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7210                     hr, test.create_expected, i);
7211             }
7212         } else
7213             ok(hr == test.create_expected,
7214                 "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7215                 hr, test.create_expected, i);
7216
7217         if(SUCCEEDED(hr)) {
7218             BSTR received = NULL;
7219
7220             hr = IUri_GetAbsoluteUri(uri, &received);
7221             if(test.expected_todo) {
7222                 todo_wine {
7223                     ok(hr == S_OK,
7224                         "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7225                         hr, S_OK, i);
7226                 }
7227                 todo_wine {
7228                     ok(!strcmp_aw(test.expected_uri, received),
7229                         "Error: Expected %s but got %s on uri_fragment_tests[%d].\n",
7230                         test.expected_uri, wine_dbgstr_w(received), i);
7231                 }
7232             } else {
7233                 ok(hr == S_OK, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7234                     hr, S_OK, i);
7235                 ok(!strcmp_aw(test.expected_uri, received), "Error: Expected %s but got %s on uri_fragment_tests[%d].\n",
7236                     test.expected_uri, wine_dbgstr_w(received), i);
7237             }
7238
7239             SysFreeString(received);
7240         }
7241
7242         if(uri) IUri_Release(uri);
7243         heap_free(uriW);
7244     }
7245 }
7246
7247 static void test_CreateIUriBuilder(void) {
7248     HRESULT hr;
7249     IUriBuilder *builder = NULL;
7250     IUri *uri;
7251
7252     hr = pCreateIUriBuilder(NULL, 0, 0, NULL);
7253     ok(hr == E_POINTER, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x\n",
7254         hr, E_POINTER);
7255
7256     /* CreateIUriBuilder increases the ref count of the IUri it receives. */
7257     hr = pCreateUri(http_urlW, 0, 0, &uri);
7258     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7259     if(SUCCEEDED(hr)) {
7260         ULONG cur_count, orig_count;
7261
7262         orig_count = get_refcnt(uri);
7263         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
7264         ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7265         ok(builder != NULL, "Error: Expecting builder not to be NULL\n");
7266
7267         cur_count = get_refcnt(uri);
7268         ok(cur_count == orig_count+1, "Error: Expected the ref count to be %u, but was %u instead.\n", orig_count+1, cur_count);
7269
7270         if(builder) IUriBuilder_Release(builder);
7271         cur_count = get_refcnt(uri);
7272         ok(cur_count == orig_count, "Error: Expected the ref count to be %u, but was %u instead.\n", orig_count, cur_count);
7273     }
7274     if(uri) IUri_Release(uri);
7275 }
7276
7277 static void test_IUriBuilder_CreateUri(IUriBuilder *builder, const uri_builder_test *test,
7278                                        DWORD test_index) {
7279     HRESULT hr;
7280     IUri *uri = NULL;
7281
7282     hr = IUriBuilder_CreateUri(builder, test->uri_flags, 0, 0, &uri);
7283     if(test->uri_todo) {
7284         todo_wine {
7285             ok(hr == test->uri_hres,
7286                 "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7287                 hr, test->uri_hres, test_index);
7288         }
7289     } else {
7290         ok(hr == test->uri_hres,
7291             "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7292             hr, test->uri_hres, test_index);
7293     }
7294
7295     if(SUCCEEDED(hr)) {
7296         DWORD i;
7297
7298         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
7299             uri_builder_str_property prop = test->expected_str_props[i];
7300             BSTR received = NULL;
7301
7302             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
7303             if(prop.todo) {
7304                 todo_wine {
7305                     ok(hr == prop.result,
7306                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7307                         hr, prop.result, test_index, i);
7308                 }
7309             } else {
7310                 ok(hr == prop.result,
7311                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7312                     hr, prop.result, test_index, i);
7313             }
7314             if(SUCCEEDED(hr)) {
7315                 if(prop.todo) {
7316                     todo_wine {
7317                         ok(!strcmp_aw(prop.expected, received),
7318                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7319                             prop.expected, wine_dbgstr_w(received), test_index, i);
7320                     }
7321                 } else {
7322                     ok(!strcmp_aw(prop.expected, received),
7323                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7324                         prop.expected, wine_dbgstr_w(received), test_index, i);
7325                 }
7326             }
7327             SysFreeString(received);
7328         }
7329
7330         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
7331             uri_builder_dword_property prop = test->expected_dword_props[i];
7332             DWORD received = -2;
7333
7334             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
7335             if(prop.todo) {
7336                 todo_wine {
7337                     ok(hr == prop.result,
7338                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7339                         hr, prop.result, test_index, i);
7340                 }
7341             } else {
7342                 ok(hr == prop.result,
7343                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7344                     hr, prop.result, test_index, i);
7345             }
7346             if(SUCCEEDED(hr)) {
7347                 if(prop.todo) {
7348                     todo_wine {
7349                         ok(received == prop.expected,
7350                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7351                             prop.expected, received, test_index, i);
7352                     }
7353                 } else {
7354                     ok(received == prop.expected,
7355                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7356                         prop.expected, received, test_index, i);
7357                 }
7358             }
7359         }
7360     }
7361     if(uri) IUri_Release(uri);
7362 }
7363
7364 static void test_IUriBuilder_CreateUriSimple(IUriBuilder *builder, const uri_builder_test *test,
7365                                        DWORD test_index) {
7366     HRESULT hr;
7367     IUri *uri = NULL;
7368
7369     hr = IUriBuilder_CreateUriSimple(builder, test->uri_simple_encode_flags, 0, &uri);
7370     if(test->uri_simple_todo) {
7371         todo_wine {
7372             ok(hr == test->uri_simple_hres,
7373                 "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7374                 hr, test->uri_simple_hres, test_index);
7375         }
7376     } else {
7377         ok(hr == test->uri_simple_hres,
7378             "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7379             hr, test->uri_simple_hres, test_index);
7380     }
7381
7382     if(SUCCEEDED(hr)) {
7383         DWORD i;
7384
7385         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
7386             uri_builder_str_property prop = test->expected_str_props[i];
7387             BSTR received = NULL;
7388
7389             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
7390             if(prop.todo) {
7391                 todo_wine {
7392                     ok(hr == prop.result,
7393                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7394                         hr, prop.result, test_index, i);
7395                 }
7396             } else {
7397                 ok(hr == prop.result,
7398                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7399                     hr, prop.result, test_index, i);
7400             }
7401             if(SUCCEEDED(hr)) {
7402                 if(prop.todo) {
7403                     todo_wine {
7404                         ok(!strcmp_aw(prop.expected, received),
7405                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7406                             prop.expected, wine_dbgstr_w(received), test_index, i);
7407                     }
7408                 } else {
7409                     ok(!strcmp_aw(prop.expected, received),
7410                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7411                         prop.expected, wine_dbgstr_w(received), test_index, i);
7412                 }
7413             }
7414             SysFreeString(received);
7415         }
7416
7417         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
7418             uri_builder_dword_property prop = test->expected_dword_props[i];
7419             DWORD received = -2;
7420
7421             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
7422             if(prop.todo) {
7423                 todo_wine {
7424                     ok(hr == prop.result,
7425                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7426                         hr, prop.result, test_index, i);
7427                 }
7428             } else {
7429                 ok(hr == prop.result,
7430                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7431                     hr, prop.result, test_index, i);
7432             }
7433             if(SUCCEEDED(hr)) {
7434                 if(prop.todo) {
7435                     todo_wine {
7436                         ok(received == prop.expected,
7437                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7438                             prop.expected, received, test_index, i);
7439                     }
7440                 } else {
7441                     ok(received == prop.expected,
7442                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7443                         prop.expected, received, test_index, i);
7444                 }
7445             }
7446         }
7447     }
7448     if(uri) IUri_Release(uri);
7449 }
7450
7451 static void test_IUriBuilder_CreateUriWithFlags(IUriBuilder *builder, const uri_builder_test *test,
7452                                                 DWORD test_index) {
7453     HRESULT hr;
7454     IUri *uri = NULL;
7455
7456     hr = IUriBuilder_CreateUriWithFlags(builder, test->uri_with_flags, test->uri_with_builder_flags,
7457                                         test->uri_with_encode_flags, 0, &uri);
7458     if(test->uri_with_todo) {
7459         todo_wine {
7460             ok(hr == test->uri_with_hres,
7461                 "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7462                 hr, test->uri_with_hres, test_index);
7463         }
7464     } else {
7465         ok(hr == test->uri_with_hres,
7466             "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7467             hr, test->uri_with_hres, test_index);
7468     }
7469
7470     if(SUCCEEDED(hr)) {
7471         DWORD i;
7472
7473         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
7474             uri_builder_str_property prop = test->expected_str_props[i];
7475             BSTR received = NULL;
7476
7477             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
7478             if(prop.todo) {
7479                 todo_wine {
7480                     ok(hr == prop.result,
7481                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7482                         hr, prop.result, test_index, i);
7483                 }
7484             } else {
7485                 ok(hr == prop.result,
7486                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7487                     hr, prop.result, test_index, i);
7488             }
7489             if(SUCCEEDED(hr)) {
7490                 if(prop.todo) {
7491                     todo_wine {
7492                         ok(!strcmp_aw(prop.expected, received),
7493                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7494                             prop.expected, wine_dbgstr_w(received), test_index, i);
7495                     }
7496                 } else {
7497                     ok(!strcmp_aw(prop.expected, received),
7498                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7499                         prop.expected, wine_dbgstr_w(received), test_index, i);
7500                 }
7501             }
7502             SysFreeString(received);
7503         }
7504
7505         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
7506             uri_builder_dword_property prop = test->expected_dword_props[i];
7507             DWORD received = -2;
7508
7509             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
7510             if(prop.todo) {
7511                 todo_wine {
7512                     ok(hr == prop.result,
7513                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7514                         hr, prop.result, test_index, i);
7515                 }
7516             } else {
7517                 ok(hr == prop.result,
7518                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7519                     hr, prop.result, test_index, i);
7520             }
7521             if(SUCCEEDED(hr)) {
7522                 if(prop.todo) {
7523                     todo_wine {
7524                         ok(received == prop.expected,
7525                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7526                             prop.expected, received, test_index, i);
7527                     }
7528                 } else {
7529                     ok(received == prop.expected,
7530                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7531                         prop.expected, received, test_index, i);
7532                 }
7533             }
7534         }
7535     }
7536     if(uri) IUri_Release(uri);
7537 }
7538
7539 static void test_IUriBuilder_CreateInvalidArgs(void) {
7540     IUriBuilder *builder;
7541     HRESULT hr;
7542
7543     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
7544     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7545     if(SUCCEEDED(hr)) {
7546         IUri *test = NULL, *uri = (void*) 0xdeadbeef;
7547
7548         /* Test what happens if the IUriBuilder doesn't have a IUri set. */
7549         hr = IUriBuilder_CreateUri(builder, 0, 0, 0, NULL);
7550         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7551
7552         uri = (void*) 0xdeadbeef;
7553         hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
7554         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_NOTIMPL);
7555         ok(uri == NULL, "Error: expected uri to be NULL, but was %p instead.\n", uri);
7556
7557         hr = IUriBuilder_CreateUriSimple(builder, 0, 0, NULL);
7558         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
7559             hr, E_POINTER);
7560
7561         uri = (void*) 0xdeadbeef;
7562         hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
7563         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
7564             hr, E_NOTIMPL);
7565         ok(!uri, "Error: Expected uri to NULL, but was %p instead.\n", uri);
7566
7567         hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, NULL);
7568         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
7569             hr, E_POINTER);
7570
7571         uri = (void*) 0xdeadbeef;
7572         hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, Uri_HAS_USER_NAME, 0, &uri);
7573         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
7574             hr, E_NOTIMPL);
7575         ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7576
7577         hr = pCreateUri(http_urlW, 0, 0, &test);
7578         ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7579         if(SUCCEEDED(hr)) {
7580             hr = IUriBuilder_SetIUri(builder, test);
7581             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7582
7583             /* No longer returns E_NOTIMPL, since a IUri has been set and hasn't been modified. */
7584             uri = NULL;
7585             hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
7586             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7587             ok(uri != NULL, "Error: The uri was NULL.\n");
7588             if(uri) IUri_Release(uri);
7589
7590             uri = NULL;
7591             hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
7592             ok(hr == S_OK, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
7593                 hr, S_OK);
7594             ok(uri != NULL, "Error: uri was NULL.\n");
7595             if(uri) IUri_Release(uri);
7596
7597             uri = NULL;
7598             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, &uri);
7599             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
7600                 hr, S_OK);
7601             ok(uri != NULL, "Error: uri was NULL.\n");
7602             if(uri) IUri_Release(uri);
7603
7604             hr = IUriBuilder_SetFragment(builder, NULL);
7605             ok(hr == S_OK, "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7606
7607             /* The IUriBuilder is changed, so it returns E_NOTIMPL again. */
7608             uri = (void*) 0xdeadbeef;
7609             hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
7610             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7611             ok(!uri, "Error: Expected uri to be NULL but was %p instead.\n", uri);
7612
7613             uri = (void*) 0xdeadbeef;
7614             hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
7615             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
7616                 hr, S_OK);
7617             ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7618
7619             uri = (void*) 0xdeadbeef;
7620             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, Uri_HAS_USER_NAME, 0, &uri);
7621             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
7622                 hr, E_NOTIMPL);
7623             ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7624         }
7625         if(test) IUri_Release(test);
7626     }
7627     if(builder) IUriBuilder_Release(builder);
7628 }
7629
7630 /* Tests invalid args to the "Get*" functions. */
7631 static void test_IUriBuilder_GetInvalidArgs(void) {
7632     IUriBuilder *builder = NULL;
7633     HRESULT hr;
7634
7635     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
7636     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7637     if(SUCCEEDED(hr)) {
7638         LPCWSTR received = (void*) 0xdeadbeef;
7639         DWORD len = -1, port = -1;
7640         BOOL set = -1;
7641
7642         hr = IUriBuilder_GetFragment(builder, NULL, NULL);
7643         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
7644             hr, E_POINTER);
7645         hr = IUriBuilder_GetFragment(builder, NULL, &received);
7646         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
7647             hr, E_POINTER);
7648         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7649         hr = IUriBuilder_GetFragment(builder, &len, NULL);
7650         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
7651             hr, E_POINTER);
7652         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7653
7654         hr = IUriBuilder_GetHost(builder, NULL, NULL);
7655         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
7656             hr, E_POINTER);
7657         received = (void*) 0xdeadbeef;
7658         hr = IUriBuilder_GetHost(builder, NULL, &received);
7659         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
7660             hr, E_POINTER);
7661         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7662         len = -1;
7663         hr = IUriBuilder_GetHost(builder, &len, NULL);
7664         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
7665             hr, E_POINTER);
7666         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7667
7668         hr = IUriBuilder_GetPassword(builder, NULL, NULL);
7669         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
7670             hr, E_POINTER);
7671         received = (void*) 0xdeadbeef;
7672         hr = IUriBuilder_GetPassword(builder, NULL, &received);
7673         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
7674             hr, E_POINTER);
7675         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7676         len = -1;
7677         hr = IUriBuilder_GetPassword(builder, &len, NULL);
7678         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
7679             hr, E_POINTER);
7680         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7681
7682         hr = IUriBuilder_GetPath(builder, NULL, NULL);
7683         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
7684             hr, E_POINTER);
7685         received = (void*) 0xdeadbeef;
7686         hr = IUriBuilder_GetPath(builder, NULL, &received);
7687         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
7688             hr, E_POINTER);
7689         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7690         len = -1;
7691         hr = IUriBuilder_GetPath(builder, &len, NULL);
7692         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
7693             hr, E_POINTER);
7694         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7695
7696         hr = IUriBuilder_GetPort(builder, NULL, NULL);
7697         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
7698             hr, E_POINTER);
7699         hr = IUriBuilder_GetPort(builder, NULL, &port);
7700         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
7701             hr, E_POINTER);
7702         ok(!port, "Error: Expected port to be 0, but was %d instead.\n", port);
7703         hr = IUriBuilder_GetPort(builder, &set, NULL);
7704         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
7705             hr, E_POINTER);
7706         ok(!set, "Error: Expected set to be FALSE, but was %d instead.\n", set);
7707
7708         hr = IUriBuilder_GetQuery(builder, NULL, NULL);
7709         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
7710             hr, E_POINTER);
7711         received = (void*) 0xdeadbeef;
7712         hr = IUriBuilder_GetQuery(builder, NULL, &received);
7713         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
7714             hr, E_POINTER);
7715         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7716         len = -1;
7717         hr = IUriBuilder_GetQuery(builder, &len, NULL);
7718         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
7719             hr, E_POINTER);
7720         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7721
7722         hr = IUriBuilder_GetSchemeName(builder, NULL, NULL);
7723         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
7724             hr, E_POINTER);
7725         received = (void*) 0xdeadbeef;
7726         hr = IUriBuilder_GetSchemeName(builder, NULL, &received);
7727         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
7728             hr, E_POINTER);
7729         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7730         len = -1;
7731         hr = IUriBuilder_GetSchemeName(builder, &len, NULL);
7732         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
7733             hr, E_POINTER);
7734         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7735
7736         hr = IUriBuilder_GetUserName(builder, NULL, NULL);
7737         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
7738             hr, E_POINTER);
7739         received = (void*) 0xdeadbeef;
7740         hr = IUriBuilder_GetUserName(builder, NULL, &received);
7741         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
7742             hr, E_POINTER);
7743         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7744         len = -1;
7745         hr = IUriBuilder_GetUserName(builder, &len, NULL);
7746         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
7747             hr, E_POINTER);
7748         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7749     }
7750     if(builder) IUriBuilder_Release(builder);
7751 }
7752
7753 static void test_IUriBuilder_GetFragment(IUriBuilder *builder, const uri_builder_test *test,
7754                                          DWORD test_index) {
7755     HRESULT hr;
7756     DWORD i;
7757     LPCWSTR received = NULL;
7758     DWORD len = -1;
7759     const uri_builder_property *prop = NULL;
7760
7761     /* Check if the property was set earlier. */
7762     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
7763         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_FRAGMENT)
7764             prop = &(test->properties[i]);
7765     }
7766
7767     if(prop) {
7768         /* Use expected_value unless it's NULL, then use value. */
7769         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
7770         hr = IUriBuilder_GetFragment(builder, &len, &received);
7771         if(prop->todo) {
7772             todo_wine {
7773                 ok(hr == (expected ? S_OK : S_FALSE),
7774                     "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7775                     hr, (expected ? S_OK : S_FALSE), test_index);
7776             }
7777             if(SUCCEEDED(hr)) {
7778                 todo_wine {
7779                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
7780                         expected, wine_dbgstr_w(received), test_index);
7781                 }
7782                 todo_wine {
7783                     ok(lstrlen(expected) == len,
7784                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
7785                         lstrlen(expected), len, test_index);
7786                 }
7787             }
7788         } else {
7789             ok(hr == (expected ? S_OK : S_FALSE),
7790                 "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7791                 hr, (expected ? S_OK : S_FALSE), test_index);
7792             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
7793                 expected, wine_dbgstr_w(received), test_index);
7794             ok(lstrlen(expected) == len,
7795                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
7796                 lstrlen(expected), len, test_index);
7797         }
7798     } else {
7799         /* The property wasn't set earlier, so it should return whatever
7800          * the base IUri contains (if anything).
7801          */
7802         IUri *uri = NULL;
7803         hr = IUriBuilder_GetIUri(builder, &uri);
7804         ok(hr == S_OK,
7805             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7806             hr, S_OK, test_index);
7807         if(SUCCEEDED(hr)) {
7808             if(!uri) {
7809                 received = (void*) 0xdeadbeef;
7810                 len = -1;
7811
7812                 hr = IUriBuilder_GetFragment(builder, &len, &received);
7813                 ok(hr == S_FALSE,
7814                     "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7815                     hr, S_FALSE, test_index);
7816                 if(SUCCEEDED(hr)) {
7817                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
7818                         len, test_index);
7819                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
7820                         received, test_index);
7821                 }
7822             } else {
7823                 BOOL has_prop = FALSE;
7824                 BSTR expected = NULL;
7825
7826                 hr = IUri_GetFragment(uri, &expected);
7827                 ok(SUCCEEDED(hr),
7828                     "Error: Expected IUri_GetFragment to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
7829                     hr, test_index);
7830                 has_prop = hr == S_OK;
7831
7832                 hr = IUriBuilder_GetFragment(builder, &len, &received);
7833                 if(has_prop) {
7834                     ok(hr == S_OK,
7835                         "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7836                         hr, S_OK, test_index);
7837                     if(SUCCEEDED(hr)) {
7838                         ok(!lstrcmpW(expected, received),
7839                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
7840                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
7841                         ok(lstrlenW(expected) == len,
7842                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
7843                             lstrlenW(expected), len, test_index);
7844                     }
7845                 } else {
7846                     ok(hr == S_FALSE,
7847                         "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7848                         hr, S_FALSE, test_index);
7849                     if(SUCCEEDED(hr)) {
7850                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
7851                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
7852                             len, test_index);
7853                     }
7854                 }
7855                 SysFreeString(expected);
7856             }
7857         }
7858         if(uri) IUri_Release(uri);
7859     }
7860 }
7861
7862 static void test_IUriBuilder_GetHost(IUriBuilder *builder, const uri_builder_test *test,
7863                                      DWORD test_index) {
7864     HRESULT hr;
7865     DWORD i;
7866     LPCWSTR received = NULL;
7867     DWORD len = -1;
7868     const uri_builder_property *prop = NULL;
7869
7870     /* Check if the property was set earlier. */
7871     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
7872         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_HOST)
7873             prop = &(test->properties[i]);
7874     }
7875
7876     if(prop) {
7877         /* Use expected_value unless it's NULL, then use value. */
7878         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
7879         hr = IUriBuilder_GetHost(builder, &len, &received);
7880         if(prop->todo) {
7881             todo_wine {
7882                 ok(hr == (expected ? S_OK : S_FALSE),
7883                     "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7884                     hr, (expected ? S_OK : S_FALSE), test_index);
7885             }
7886             if(SUCCEEDED(hr)) {
7887                 todo_wine {
7888                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
7889                         expected, wine_dbgstr_w(received), test_index);
7890                 }
7891                 todo_wine {
7892                     ok(lstrlen(expected) == len,
7893                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
7894                         lstrlen(expected), len, test_index);
7895                 }
7896             }
7897         } else {
7898             ok(hr == (expected ? S_OK : S_FALSE),
7899                 "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7900                 hr, (expected ? S_OK : S_FALSE), test_index);
7901             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
7902                 expected, wine_dbgstr_w(received), test_index);
7903             ok(lstrlen(expected) == len,
7904                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
7905                 lstrlen(expected), len, test_index);
7906         }
7907     } else {
7908         /* The property wasn't set earlier, so it should return whatever
7909          * the base IUri contains (if anything).
7910          */
7911         IUri *uri = NULL;
7912         hr = IUriBuilder_GetIUri(builder, &uri);
7913         ok(hr == S_OK,
7914             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7915             hr, S_OK, test_index);
7916         if(SUCCEEDED(hr)) {
7917             if(!uri) {
7918                 received = (void*) 0xdeadbeef;
7919                 len = -1;
7920
7921                 hr = IUriBuilder_GetHost(builder, &len, &received);
7922                 ok(hr == S_FALSE,
7923                     "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7924                     hr, S_FALSE, test_index);
7925                 if(SUCCEEDED(hr)) {
7926                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
7927                         len, test_index);
7928                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
7929                         received, test_index);
7930                 }
7931             } else {
7932                 BOOL has_prop = FALSE;
7933                 BSTR expected = NULL;
7934
7935                 hr = IUri_GetHost(uri, &expected);
7936                 ok(SUCCEEDED(hr),
7937                     "Error: Expected IUri_GetHost to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
7938                     hr, test_index);
7939                 has_prop = hr == S_OK;
7940
7941                 hr = IUriBuilder_GetHost(builder, &len, &received);
7942                 if(has_prop) {
7943                     ok(hr == S_OK,
7944                         "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7945                         hr, S_OK, test_index);
7946                     if(SUCCEEDED(hr)) {
7947                         ok(!lstrcmpW(expected, received),
7948                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
7949                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
7950                         ok(lstrlenW(expected) == len,
7951                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
7952                             lstrlenW(expected), len, test_index);
7953                     }
7954                 } else {
7955                     ok(hr == S_FALSE,
7956                         "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7957                         hr, S_FALSE, test_index);
7958                     if(SUCCEEDED(hr)) {
7959                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
7960                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
7961                             len, test_index);
7962                     }
7963                 }
7964                 SysFreeString(expected);
7965             }
7966         }
7967         if(uri) IUri_Release(uri);
7968     }
7969 }
7970
7971 static void test_IUriBuilder_GetPassword(IUriBuilder *builder, const uri_builder_test *test,
7972                                          DWORD test_index) {
7973     HRESULT hr;
7974     DWORD i;
7975     LPCWSTR received = NULL;
7976     DWORD len = -1;
7977     const uri_builder_property *prop = NULL;
7978
7979     /* Check if the property was set earlier. */
7980     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
7981         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_PASSWORD)
7982             prop = &(test->properties[i]);
7983     }
7984
7985     if(prop) {
7986         /* Use expected_value unless it's NULL, then use value. */
7987         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
7988         hr = IUriBuilder_GetPassword(builder, &len, &received);
7989         if(prop->todo) {
7990             todo_wine {
7991                 ok(hr == (expected ? S_OK : S_FALSE),
7992                     "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7993                     hr, (expected ? S_OK : S_FALSE), test_index);
7994             }
7995             if(SUCCEEDED(hr)) {
7996                 todo_wine {
7997                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
7998                         expected, wine_dbgstr_w(received), test_index);
7999                 }
8000                 todo_wine {
8001                     ok(lstrlen(expected) == len,
8002                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8003                         lstrlen(expected), len, test_index);
8004                 }
8005             }
8006         } else {
8007             ok(hr == (expected ? S_OK : S_FALSE),
8008                 "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8009                 hr, (expected ? S_OK : S_FALSE), test_index);
8010             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8011                 expected, wine_dbgstr_w(received), test_index);
8012             ok(lstrlen(expected) == len,
8013                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8014                 lstrlen(expected), len, test_index);
8015         }
8016     } else {
8017         /* The property wasn't set earlier, so it should return whatever
8018          * the base IUri contains (if anything).
8019          */
8020         IUri *uri = NULL;
8021         hr = IUriBuilder_GetIUri(builder, &uri);
8022         ok(hr == S_OK,
8023             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8024             hr, S_OK, test_index);
8025         if(SUCCEEDED(hr)) {
8026             if(!uri) {
8027                 received = (void*) 0xdeadbeef;
8028                 len = -1;
8029
8030                 hr = IUriBuilder_GetPassword(builder, &len, &received);
8031                 ok(hr == S_FALSE,
8032                     "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8033                     hr, S_FALSE, test_index);
8034                 if(SUCCEEDED(hr)) {
8035                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8036                         len, test_index);
8037                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8038                         received, test_index);
8039                 }
8040             } else {
8041                 BOOL has_prop = FALSE;
8042                 BSTR expected = NULL;
8043
8044                 hr = IUri_GetPassword(uri, &expected);
8045                 ok(SUCCEEDED(hr),
8046                     "Error: Expected IUri_GetPassword to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8047                     hr, test_index);
8048                 has_prop = hr == S_OK;
8049
8050                 hr = IUriBuilder_GetPassword(builder, &len, &received);
8051                 if(has_prop) {
8052                     ok(hr == S_OK,
8053                         "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8054                         hr, S_OK, test_index);
8055                     if(SUCCEEDED(hr)) {
8056                         ok(!lstrcmpW(expected, received),
8057                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8058                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8059                         ok(lstrlenW(expected) == len,
8060                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8061                             lstrlenW(expected), len, test_index);
8062                     }
8063                 } else {
8064                     ok(hr == S_FALSE,
8065                         "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8066                         hr, S_FALSE, test_index);
8067                     if(SUCCEEDED(hr)) {
8068                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8069                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8070                             len, test_index);
8071                     }
8072                 }
8073                 SysFreeString(expected);
8074             }
8075         }
8076         if(uri) IUri_Release(uri);
8077     }
8078 }
8079
8080 static void test_IUriBuilder_GetPath(IUriBuilder *builder, const uri_builder_test *test,
8081                                      DWORD test_index) {
8082     HRESULT hr;
8083     DWORD i;
8084     LPCWSTR received = NULL;
8085     DWORD len = -1;
8086     const uri_builder_property *prop = NULL;
8087
8088     /* Check if the property was set earlier. */
8089     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8090         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_PATH)
8091             prop = &(test->properties[i]);
8092     }
8093
8094     if(prop) {
8095         /* Use expected_value unless it's NULL, then use value. */
8096         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8097         hr = IUriBuilder_GetPath(builder, &len, &received);
8098         if(prop->todo) {
8099             todo_wine {
8100                 ok(hr == (expected ? S_OK : S_FALSE),
8101                     "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8102                     hr, (expected ? S_OK : S_FALSE), test_index);
8103             }
8104             if(SUCCEEDED(hr)) {
8105                 todo_wine {
8106                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8107                         expected, wine_dbgstr_w(received), test_index);
8108                 }
8109                 todo_wine {
8110                     ok(lstrlen(expected) == len,
8111                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8112                         lstrlen(expected), len, test_index);
8113                 }
8114             }
8115         } else {
8116             ok(hr == (expected ? S_OK : S_FALSE),
8117                 "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8118                 hr, (expected ? S_OK : S_FALSE), test_index);
8119             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8120                 expected, wine_dbgstr_w(received), test_index);
8121             ok(lstrlen(expected) == len,
8122                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8123                 lstrlen(expected), len, test_index);
8124         }
8125     } else {
8126         /* The property wasn't set earlier, so it should return whatever
8127          * the base IUri contains (if anything).
8128          */
8129         IUri *uri = NULL;
8130         hr = IUriBuilder_GetIUri(builder, &uri);
8131         ok(hr == S_OK,
8132             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8133             hr, S_OK, test_index);
8134         if(SUCCEEDED(hr)) {
8135             if(!uri) {
8136                 received = (void*) 0xdeadbeef;
8137                 len = -1;
8138
8139                 hr = IUriBuilder_GetPath(builder, &len, &received);
8140                 ok(hr == S_FALSE,
8141                     "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8142                     hr, S_FALSE, test_index);
8143                 if(SUCCEEDED(hr)) {
8144                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8145                         len, test_index);
8146                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8147                         received, test_index);
8148                 }
8149             } else {
8150                 BOOL has_prop = FALSE;
8151                 BSTR expected = NULL;
8152
8153                 hr = IUri_GetPath(uri, &expected);
8154                 ok(SUCCEEDED(hr),
8155                     "Error: Expected IUri_GetPath to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8156                     hr, test_index);
8157                 has_prop = hr == S_OK;
8158
8159                 hr = IUriBuilder_GetPath(builder, &len, &received);
8160                 if(has_prop) {
8161                     ok(hr == S_OK,
8162                         "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8163                         hr, S_OK, test_index);
8164                     if(SUCCEEDED(hr)) {
8165                         ok(!lstrcmpW(expected, received),
8166                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8167                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8168                         ok(lstrlenW(expected) == len,
8169                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8170                             lstrlenW(expected), len, test_index);
8171                     }
8172                 } else {
8173                     ok(hr == S_FALSE,
8174                         "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8175                         hr, S_FALSE, test_index);
8176                     if(SUCCEEDED(hr)) {
8177                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8178                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8179                             len, test_index);
8180                     }
8181                 }
8182                 SysFreeString(expected);
8183             }
8184         }
8185         if(uri) IUri_Release(uri);
8186     }
8187 }
8188
8189 static void test_IUriBuilder_GetPort(IUriBuilder *builder, const uri_builder_test *test,
8190                                      DWORD test_index) {
8191     HRESULT hr;
8192     BOOL has_port = FALSE;
8193     DWORD received = -1;
8194
8195     if(test->port_prop.change) {
8196         DWORD expected = test->port_prop.value;
8197
8198         hr = IUriBuilder_GetPort(builder, &has_port, &received);
8199         if(test->port_prop.todo) {
8200             todo_wine {
8201                 ok(hr == S_OK,
8202                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8203                     hr, S_OK, test_index);
8204             }
8205             if(SUCCEEDED(hr)) {
8206                 todo_wine {
8207                     ok(has_port == test->port_prop.set,
8208                         "Error: Expected has_port to be %d but was %d instead on uri_builder_tests[%d].\n",
8209                         test->port_prop.set, has_port, test_index);
8210                 }
8211                 todo_wine {
8212                     ok(received == expected,
8213                         "Error: Expected received to be %d, but was %d instead on uri_builder_tests[%d].\n",
8214                         expected, received, test_index);
8215                 }
8216             }
8217         } else {
8218             ok(hr == S_OK,
8219                 "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8220                 hr, S_OK, test_index);
8221             ok(has_port == test->port_prop.set,
8222                 "Error: Expected has_port to be %d, but was %d instead on uri_builder_tests[%d].\n",
8223                 test->port_prop.set, has_port, test_index);
8224             ok(received == test->port_prop.value,
8225                 "Error: Expected port to be %d, but was %d instead on uri_builder_tests[%d].\n",
8226                 test->port_prop.value, received, test_index);
8227         }
8228     } else {
8229         IUri *uri = NULL;
8230
8231         hr = IUriBuilder_GetIUri(builder, &uri);
8232         ok(hr == S_OK,
8233             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8234             hr, S_OK, test_index);
8235         if(SUCCEEDED(hr)) {
8236             if(!uri) {
8237                 hr = IUriBuilder_GetPort(builder, &has_port, &received);
8238                 ok(hr == S_OK,
8239                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8240                     hr, S_OK, test_index);
8241                 if(SUCCEEDED(hr)) {
8242                     ok(has_port == FALSE,
8243                         "Error: Expected has_port to be FALSE, but was %d instead on uri_builder_tests[%d].\n",
8244                         has_port, test_index);
8245                     ok(!received, "Error: Expected received to be 0, but was %d instead on uri_builder_tests[%d].\n",
8246                         received, test_index);
8247                 }
8248             } else {
8249                 DWORD expected;
8250
8251                 hr = IUri_GetPort(uri, &expected);
8252                 ok(SUCCEEDED(hr),
8253                     "Error: Expected IUri_Port to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8254                     hr, test_index);
8255
8256                 hr = IUriBuilder_GetPort(builder, &has_port, &received);
8257                 ok(hr == S_OK,
8258                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8259                     hr, S_OK, test_index);
8260                 if(SUCCEEDED(hr)) {
8261                     ok(!has_port,
8262                         "Error: Expected has_port to be FALSE but was TRUE instead on uri_builder_tests[%d].\n",
8263                         test_index);
8264                     ok(received == expected,
8265                         "Error: Expected received to be %d, but was %d instead on uri_builder_tests[%d].\n",
8266                         expected, received, test_index);
8267                 }
8268             }
8269         }
8270         if(uri) IUri_Release(uri);
8271     }
8272 }
8273
8274 static void test_IUriBuilder_GetQuery(IUriBuilder *builder, const uri_builder_test *test,
8275                                       DWORD test_index) {
8276     HRESULT hr;
8277     DWORD i;
8278     LPCWSTR received = NULL;
8279     DWORD len = -1;
8280     const uri_builder_property *prop = NULL;
8281
8282     /* Check if the property was set earlier. */
8283     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8284         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_QUERY)
8285             prop = &(test->properties[i]);
8286     }
8287
8288     if(prop) {
8289         /* Use expected_value unless it's NULL, then use value. */
8290         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8291         hr = IUriBuilder_GetQuery(builder, &len, &received);
8292         if(prop->todo) {
8293             todo_wine {
8294                 ok(hr == (expected ? S_OK : S_FALSE),
8295                     "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8296                     hr, (expected ? S_OK : S_FALSE), test_index);
8297             }
8298             if(SUCCEEDED(hr)) {
8299                 todo_wine {
8300                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8301                         expected, wine_dbgstr_w(received), test_index);
8302                 }
8303                 todo_wine {
8304                     ok(lstrlen(expected) == len,
8305                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8306                         lstrlen(expected), len, test_index);
8307                 }
8308             }
8309         } else {
8310             ok(hr == (expected ? S_OK : S_FALSE),
8311                 "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8312                 hr, (expected ? S_OK : S_FALSE), test_index);
8313             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8314                 expected, wine_dbgstr_w(received), test_index);
8315             ok(lstrlen(expected) == len,
8316                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8317                 lstrlen(expected), len, test_index);
8318         }
8319     } else {
8320         /* The property wasn't set earlier, so it should return whatever
8321          * the base IUri contains (if anything).
8322          */
8323         IUri *uri = NULL;
8324         hr = IUriBuilder_GetIUri(builder, &uri);
8325         ok(hr == S_OK,
8326             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8327             hr, S_OK, test_index);
8328         if(SUCCEEDED(hr)) {
8329             if(!uri) {
8330                 received = (void*) 0xdeadbeef;
8331                 len = -1;
8332
8333                 hr = IUriBuilder_GetQuery(builder, &len, &received);
8334                 ok(hr == S_FALSE,
8335                     "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8336                     hr, S_FALSE, test_index);
8337                 if(SUCCEEDED(hr)) {
8338                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8339                         len, test_index);
8340                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8341                         received, test_index);
8342                 }
8343             } else {
8344                 BOOL has_prop = FALSE;
8345                 BSTR expected = NULL;
8346
8347                 hr = IUri_GetQuery(uri, &expected);
8348                 ok(SUCCEEDED(hr),
8349                     "Error: Expected IUri_GetQuery to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8350                     hr, test_index);
8351                 has_prop = hr == S_OK;
8352
8353                 hr = IUriBuilder_GetQuery(builder, &len, &received);
8354                 if(has_prop) {
8355                     ok(hr == S_OK,
8356                         "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8357                         hr, S_OK, test_index);
8358                     if(SUCCEEDED(hr)) {
8359                         ok(!lstrcmpW(expected, received),
8360                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8361                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8362                         ok(lstrlenW(expected) == len,
8363                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8364                             lstrlenW(expected), len, test_index);
8365                     }
8366                 } else {
8367                     ok(hr == S_FALSE,
8368                         "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8369                         hr, S_FALSE, test_index);
8370                     if(SUCCEEDED(hr)) {
8371                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8372                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8373                             len, test_index);
8374                     }
8375                 }
8376                 SysFreeString(expected);
8377             }
8378         }
8379         if(uri) IUri_Release(uri);
8380     }
8381 }
8382
8383 static void test_IUriBuilder_GetSchemeName(IUriBuilder *builder, const uri_builder_test *test,
8384                                            DWORD test_index) {
8385     HRESULT hr;
8386     DWORD i;
8387     LPCWSTR received = NULL;
8388     DWORD len = -1;
8389     const uri_builder_property *prop = NULL;
8390
8391     /* Check if the property was set earlier. */
8392     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8393         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_SCHEME_NAME)
8394             prop = &(test->properties[i]);
8395     }
8396
8397     if(prop) {
8398         /* Use expected_value unless it's NULL, then use value. */
8399         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8400         hr = IUriBuilder_GetSchemeName(builder, &len, &received);
8401         if(prop->todo) {
8402             todo_wine {
8403                 ok(hr == (expected ? S_OK : S_FALSE),
8404                     "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8405                     hr, (expected ? S_OK : S_FALSE), test_index);
8406             }
8407             if(SUCCEEDED(hr)) {
8408                 todo_wine {
8409                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8410                         expected, wine_dbgstr_w(received), test_index);
8411                 }
8412                 todo_wine {
8413                     ok(lstrlen(expected) == len,
8414                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8415                         lstrlen(expected), len, test_index);
8416                 }
8417             }
8418         } else {
8419             ok(hr == (expected ? S_OK : S_FALSE),
8420                 "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8421                 hr, (expected ? S_OK : S_FALSE), test_index);
8422             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8423                 expected, wine_dbgstr_w(received), test_index);
8424             ok(lstrlen(expected) == len,
8425                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8426                 lstrlen(expected), len, test_index);
8427         }
8428     } else {
8429         /* The property wasn't set earlier, so it should return whatever
8430          * the base IUri contains (if anything).
8431          */
8432         IUri *uri = NULL;
8433         hr = IUriBuilder_GetIUri(builder, &uri);
8434         ok(hr == S_OK,
8435             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8436             hr, S_OK, test_index);
8437         if(SUCCEEDED(hr)) {
8438             if(!uri) {
8439                 received = (void*) 0xdeadbeef;
8440                 len = -1;
8441
8442                 hr = IUriBuilder_GetSchemeName(builder, &len, &received);
8443                 ok(hr == S_FALSE,
8444                     "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8445                     hr, S_FALSE, test_index);
8446                 if(SUCCEEDED(hr)) {
8447                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8448                         len, test_index);
8449                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8450                         received, test_index);
8451                 }
8452             } else {
8453                 BOOL has_prop = FALSE;
8454                 BSTR expected = NULL;
8455
8456                 hr = IUri_GetSchemeName(uri, &expected);
8457                 ok(SUCCEEDED(hr),
8458                     "Error: Expected IUri_GetSchemeName to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8459                     hr, test_index);
8460                 has_prop = hr == S_OK;
8461
8462                 hr = IUriBuilder_GetSchemeName(builder, &len, &received);
8463                 if(has_prop) {
8464                     ok(hr == S_OK,
8465                         "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8466                         hr, S_OK, test_index);
8467                     if(SUCCEEDED(hr)) {
8468                         ok(!lstrcmpW(expected, received),
8469                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8470                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8471                         ok(lstrlenW(expected) == len,
8472                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8473                             lstrlenW(expected), len, test_index);
8474                     }
8475                 } else {
8476                     ok(hr == S_FALSE,
8477                         "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8478                         hr, S_FALSE, test_index);
8479                     if(SUCCEEDED(hr)) {
8480                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8481                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8482                             len, test_index);
8483                     }
8484                 }
8485                 SysFreeString(expected);
8486             }
8487         }
8488         if(uri) IUri_Release(uri);
8489     }
8490 }
8491
8492 static void test_IUriBuilder_GetUserName(IUriBuilder *builder, const uri_builder_test *test,
8493                                          DWORD test_index) {
8494     HRESULT hr;
8495     DWORD i;
8496     LPCWSTR received = NULL;
8497     DWORD len = -1;
8498     const uri_builder_property *prop = NULL;
8499
8500     /* Check if the property was set earlier. */
8501     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8502         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_USER_NAME)
8503             prop = &(test->properties[i]);
8504     }
8505
8506     if(prop && prop->value && *prop->value) {
8507         /* Use expected_value unless it's NULL, then use value. */
8508         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8509         hr = IUriBuilder_GetUserName(builder, &len, &received);
8510         if(prop->todo) {
8511             todo_wine {
8512                 ok(hr == (expected ? S_OK : S_FALSE),
8513                     "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8514                     hr, (expected ? S_OK : S_FALSE), test_index);
8515             }
8516             if(SUCCEEDED(hr)) {
8517                 todo_wine {
8518                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8519                         expected, wine_dbgstr_w(received), test_index);
8520                 }
8521                 todo_wine {
8522                     ok(lstrlen(expected) == len,
8523                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8524                         lstrlen(expected), len, test_index);
8525                 }
8526             }
8527         } else {
8528             ok(hr == (expected ? S_OK : S_FALSE),
8529                 "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8530                 hr, (expected ? S_OK : S_FALSE), test_index);
8531             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8532                 expected, wine_dbgstr_w(received), test_index);
8533             ok(lstrlen(expected) == len,
8534                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8535                 lstrlen(expected), len, test_index);
8536         }
8537     } else {
8538         /* The property wasn't set earlier, so it should return whatever
8539          * the base IUri contains (if anything).
8540          */
8541         IUri *uri = NULL;
8542         hr = IUriBuilder_GetIUri(builder, &uri);
8543         ok(hr == S_OK,
8544             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8545             hr, S_OK, test_index);
8546         if(SUCCEEDED(hr)) {
8547             if(!uri) {
8548                 received = (void*) 0xdeadbeef;
8549                 len = -1;
8550
8551                 hr = IUriBuilder_GetUserName(builder, &len, &received);
8552                 ok(hr == S_FALSE,
8553                     "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8554                     hr, S_FALSE, test_index);
8555                 if(SUCCEEDED(hr)) {
8556                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8557                         len, test_index);
8558                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8559                         received, test_index);
8560                 }
8561             } else {
8562                 BSTR expected = NULL;
8563                 BOOL has_prop = FALSE;
8564
8565                 hr = IUri_GetUserName(uri, &expected);
8566                 ok(SUCCEEDED(hr),
8567                     "Error: Expected IUri_GetUserName to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8568                     hr, test_index);
8569                 has_prop = hr == S_OK;
8570
8571                 hr = IUriBuilder_GetUserName(builder, &len, &received);
8572                 if(has_prop) {
8573                     ok(hr == S_OK,
8574                         "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8575                         hr, S_OK, test_index);
8576                     if(SUCCEEDED(hr)) {
8577                         ok(!lstrcmpW(expected, received),
8578                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8579                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8580                         ok(lstrlenW(expected) == len,
8581                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8582                             lstrlenW(expected), len, test_index);
8583                     }
8584                 } else {
8585                     ok(hr == S_FALSE,
8586                         "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8587                         hr, S_FALSE, test_index);
8588                     if(SUCCEEDED(hr)) {
8589                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8590                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8591                             len, test_index);
8592                     }
8593                 }
8594                 SysFreeString(expected);
8595             }
8596         }
8597         if(uri) IUri_Release(uri);
8598     }
8599 }
8600
8601 /* Tests IUriBuilder functions. */
8602 static void test_IUriBuilder(void) {
8603     HRESULT hr;
8604     IUriBuilder *builder;
8605     DWORD i;
8606
8607     for(i = 0; i < sizeof(uri_builder_tests)/sizeof(uri_builder_tests[0]); ++i) {
8608         IUri *uri = NULL;
8609         uri_builder_test test = uri_builder_tests[i];
8610         LPWSTR uriW = NULL;
8611
8612         if(test.uri) {
8613             uriW = a2w(test.uri);
8614             hr = pCreateUri(uriW, test.create_flags, 0, &uri);
8615             ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8616                 hr, S_OK, i);
8617             if(FAILED(hr)) continue;
8618         }
8619         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
8620         if(test.create_builder_todo) {
8621             todo_wine {
8622                 ok(hr == test.create_builder_expected,
8623                     "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8624                     hr, test.create_builder_expected, i);
8625             }
8626         } else {
8627             ok(hr == test.create_builder_expected,
8628                 "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8629                 hr, test.create_builder_expected, i);
8630         }
8631         if(SUCCEEDED(hr)) {
8632             DWORD j;
8633             BOOL modified = FALSE, received = FALSE;
8634
8635             /* Perform all the string property changes. */
8636             for(j = 0; j < URI_BUILDER_STR_PROPERTY_COUNT; ++j) {
8637                 uri_builder_property prop = test.properties[j];
8638                 if(prop.change) {
8639                     change_property(builder, &prop, i);
8640                     if(prop.property != Uri_PROPERTY_SCHEME_NAME &&
8641                        prop.property != Uri_PROPERTY_HOST)
8642                         modified = TRUE;
8643                     else if(prop.value && *prop.value)
8644                         modified = TRUE;
8645                     else if(prop.value && !*prop.value && prop.property == Uri_PROPERTY_HOST)
8646                         /* Host name property can't be NULL, but it can be empty. */
8647                         modified = TRUE;
8648                 }
8649             }
8650
8651             if(test.port_prop.change) {
8652                 hr = IUriBuilder_SetPort(builder, test.port_prop.set, test.port_prop.value);
8653                 modified = TRUE;
8654                 if(test.port_prop.todo) {
8655                     todo_wine {
8656                         ok(hr == test.port_prop.expected,
8657                             "Error: IUriBuilder_SetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8658                             hr, test.port_prop.expected, i);
8659                     }
8660                 } else {
8661                     ok(hr == test.port_prop.expected,
8662                         "Error: IUriBuilder_SetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8663                         hr, test.port_prop.expected, i);
8664                 }
8665             }
8666
8667             hr = IUriBuilder_HasBeenModified(builder, &received);
8668             ok(hr == S_OK,
8669                 "Error IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8670                 hr, S_OK, i);
8671             if(SUCCEEDED(hr))
8672                 ok(received == modified,
8673                     "Error: Expected received to be %d but was %d instead on uri_builder_tests[%d].\n",
8674                     modified, received, i);
8675
8676             /* Test the "Get*" functions. */
8677             test_IUriBuilder_GetFragment(builder, &test, i);
8678             test_IUriBuilder_GetHost(builder, &test, i);
8679             test_IUriBuilder_GetPassword(builder, &test, i);
8680             test_IUriBuilder_GetPath(builder, &test, i);
8681             test_IUriBuilder_GetPort(builder, &test, i);
8682             test_IUriBuilder_GetQuery(builder, &test, i);
8683             test_IUriBuilder_GetSchemeName(builder, &test, i);
8684             test_IUriBuilder_GetUserName(builder, &test, i);
8685
8686             test_IUriBuilder_CreateUri(builder, &test, i);
8687             test_IUriBuilder_CreateUriSimple(builder, &test, i);
8688             test_IUriBuilder_CreateUriWithFlags(builder, &test, i);
8689         }
8690         if(builder) IUriBuilder_Release(builder);
8691         if(uri) IUri_Release(uri);
8692         heap_free(uriW);
8693     }
8694 }
8695
8696 static void test_IUriBuilder_HasBeenModified(void) {
8697     HRESULT hr;
8698     IUriBuilder *builder = NULL;
8699
8700     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
8701     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8702     if(SUCCEEDED(hr)) {
8703         static const WCHAR hostW[] = {'g','o','o','g','l','e','.','c','o','m',0};
8704         IUri *uri = NULL;
8705         BOOL received;
8706
8707         hr = IUriBuilder_HasBeenModified(builder, NULL);
8708         ok(hr == E_POINTER, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
8709             hr, E_POINTER);
8710
8711         hr = IUriBuilder_SetHost(builder, hostW);
8712         ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n",
8713             hr, S_OK);
8714
8715         hr = IUriBuilder_HasBeenModified(builder, &received);
8716         ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
8717             hr, S_OK);
8718         if(SUCCEEDED(hr))
8719             ok(received == TRUE, "Error: Expected received to be TRUE.\n");
8720
8721         hr = pCreateUri(http_urlW, 0, 0, &uri);
8722         ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8723         if(SUCCEEDED(hr)) {
8724             LPCWSTR prop;
8725             DWORD len = -1;
8726
8727             hr = IUriBuilder_SetIUri(builder, uri);
8728             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n",
8729                 hr, S_OK);
8730
8731             hr = IUriBuilder_HasBeenModified(builder, &received);
8732             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
8733                 hr, S_OK);
8734             if(SUCCEEDED(hr))
8735                 ok(received == FALSE, "Error: Expected received to be FALSE.\n");
8736
8737             /* Test what happens with you call SetIUri with the same IUri again. */
8738             hr = IUriBuilder_SetHost(builder, hostW);
8739             ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8740
8741             hr = IUriBuilder_HasBeenModified(builder, &received);
8742             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
8743                 hr, S_OK);
8744             if(SUCCEEDED(hr))
8745                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
8746
8747             hr = IUriBuilder_SetIUri(builder, uri);
8748             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8749
8750             /* IUriBuilder already had 'uri' as it's IUri property and so Windows doesn't
8751              * reset any of the changes that were made to the IUriBuilder.
8752              */
8753             hr = IUriBuilder_HasBeenModified(builder, &received);
8754             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8755             if(SUCCEEDED(hr))
8756                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
8757
8758             hr = IUriBuilder_GetHost(builder, &len, &prop);
8759             ok(hr == S_OK, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8760             if(SUCCEEDED(hr)) {
8761                 ok(!lstrcmpW(prop, hostW), "Error: Expected %s but got %s instead.\n",
8762                     wine_dbgstr_w(hostW), wine_dbgstr_w(prop));
8763                 ok(len == lstrlenW(hostW), "Error: Expected len to be %d, but was %d instead.\n",
8764                     lstrlenW(hostW), len);
8765             }
8766
8767             hr = IUriBuilder_SetIUri(builder, NULL);
8768             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8769
8770             hr = IUriBuilder_SetHost(builder, hostW);
8771             ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8772             hr = IUriBuilder_HasBeenModified(builder, &received);
8773             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
8774                 hr, S_OK);
8775             if(SUCCEEDED(hr))
8776                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
8777
8778             hr = IUriBuilder_SetIUri(builder, NULL);
8779             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%09x.\n", hr, S_OK);
8780
8781             hr = IUriBuilder_HasBeenModified(builder, &received);
8782             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
8783                 hr, S_OK);
8784             if(SUCCEEDED(hr))
8785                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
8786
8787             hr = IUriBuilder_GetHost(builder, &len, &prop);
8788             ok(hr == S_OK, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8789             if(SUCCEEDED(hr)) {
8790                 ok(!lstrcmpW(prop, hostW), "Error: Expected %s but got %s instead.\n",
8791                     wine_dbgstr_w(hostW), wine_dbgstr_w(prop));
8792                 ok(len == lstrlenW(hostW), "Error: Expected len to %d, but was %d instead.\n",
8793                     lstrlenW(hostW), len);
8794             }
8795         }
8796         if(uri) IUri_Release(uri);
8797     }
8798     if(builder) IUriBuilder_Release(builder);
8799 }
8800
8801 /* Test IUriBuilder {Get,Set}IUri functions. */
8802 static void test_IUriBuilder_IUriProperty(void) {
8803     IUriBuilder *builder = NULL;
8804     HRESULT hr;
8805
8806     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
8807     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8808     if(SUCCEEDED(hr)) {
8809         IUri *uri = NULL;
8810
8811         hr = IUriBuilder_GetIUri(builder, NULL);
8812         ok(hr == E_POINTER, "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x.\n",
8813             hr, E_POINTER);
8814
8815         hr = pCreateUri(http_urlW, 0, 0, &uri);
8816         if(SUCCEEDED(hr)) {
8817             IUri *test = NULL;
8818             ULONG cur_count, orig_count;
8819
8820             /* IUriBuilder doesn't clone the IUri, it use the same IUri. */
8821             orig_count = get_refcnt(uri);
8822             hr = IUriBuilder_SetIUri(builder, uri);
8823             cur_count = get_refcnt(uri);
8824             if(SUCCEEDED(hr))
8825                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
8826                     orig_count+1, cur_count);
8827
8828             hr = IUriBuilder_SetIUri(builder, NULL);
8829             cur_count = get_refcnt(uri);
8830             if(SUCCEEDED(hr))
8831                 ok(cur_count == orig_count, "Error: Expected uri ref count to be %d, but was %d instead.\n",
8832                     orig_count, cur_count);
8833
8834             /* CreateUri* functions will return back the same IUri if nothing has changed. */
8835             hr = IUriBuilder_SetIUri(builder, uri);
8836             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8837             orig_count = get_refcnt(uri);
8838
8839             hr = IUriBuilder_CreateUri(builder, 0, 0, 0, &test);
8840             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8841             if(SUCCEEDED(hr)) {
8842                 cur_count = get_refcnt(uri);
8843                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
8844                     orig_count+1, cur_count);
8845                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n",
8846                     uri, test);
8847             }
8848             if(test) IUri_Release(test);
8849
8850             test = NULL;
8851             hr = IUriBuilder_CreateUri(builder, -1, 0, 0, &test);
8852             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8853             if(SUCCEEDED(hr)) {
8854                 cur_count = get_refcnt(uri);
8855                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
8856                     orig_count+1, cur_count);
8857                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
8858             }
8859             if(test) IUri_Release(test);
8860
8861             /* Doesn't return the same IUri, if the flag combination is different then the one that created
8862              * the base IUri.
8863              */
8864             test = NULL;
8865             hr = IUriBuilder_CreateUri(builder, Uri_CREATE_ALLOW_RELATIVE, 0, 0, &test);
8866             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8867             if(SUCCEEDED(hr))
8868                 ok(test != uri, "Error: Wasn't expecting 'test' to be 'uri'\n");
8869
8870             if(test) IUri_Release(test);
8871
8872             /* Still returns the same IUri, even though the base one wasn't created with CREATE_CANONICALIZE
8873              * explicitly set (because it's a default flags).
8874              */
8875             test = NULL;
8876             hr = IUriBuilder_CreateUri(builder, Uri_CREATE_CANONICALIZE, 0, 0, &test);
8877             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8878             if(SUCCEEDED(hr)) {
8879                 cur_count = get_refcnt(uri);
8880                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
8881                     orig_count+1, cur_count);
8882                 ok(test == uri, "Error: Expected 'test' to be %p, but was %p instead.\n", uri, test);
8883             }
8884             if(test) IUri_Release(test);
8885
8886             test = NULL;
8887             hr = IUriBuilder_CreateUriSimple(builder, 0, 0, &test);
8888             ok(hr == S_OK, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8889             if(SUCCEEDED(hr)) {
8890                 cur_count = get_refcnt(uri);
8891                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
8892                     orig_count+1, cur_count);
8893                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
8894             }
8895             if(test) IUri_Release(test);
8896
8897             test = NULL;
8898             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, &test);
8899             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
8900                 hr, S_OK);
8901             if(SUCCEEDED(hr)) {
8902                 cur_count = get_refcnt(uri);
8903                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
8904                     orig_count+1, cur_count);
8905                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
8906             }
8907             if(test) IUri_Release(test);
8908
8909             /* Doesn't return the same IUri, if the flag combination is different then the one that created
8910              * the base IUri.
8911              */
8912             test = NULL;
8913             hr = IUriBuilder_CreateUriWithFlags(builder, Uri_CREATE_ALLOW_RELATIVE, 0, 0, 0, &test);
8914             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8915             if(SUCCEEDED(hr))
8916                 ok(test != uri, "Error: Wasn't expecting 'test' to be 'uri'\n");
8917
8918             if(test) IUri_Release(test);
8919
8920             /* Still returns the same IUri, even though the base one wasn't created with CREATE_CANONICALIZE
8921              * explicitly set (because it's a default flags).
8922              */
8923             test = NULL;
8924             hr = IUriBuilder_CreateUriWithFlags(builder, Uri_CREATE_CANONICALIZE, 0, 0, 0, &test);
8925             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8926             if(SUCCEEDED(hr)) {
8927                 cur_count = get_refcnt(uri);
8928                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
8929                     orig_count+1, cur_count);
8930                 ok(test == uri, "Error: Expected 'test' to be %p, but was %p instead.\n", uri, test);
8931             }
8932             if(test) IUri_Release(test);
8933         }
8934         if(uri) IUri_Release(uri);
8935     }
8936     if(builder) IUriBuilder_Release(builder);
8937 }
8938
8939 static void test_IUriBuilder_RemoveProperties(void) {
8940     IUriBuilder *builder = NULL;
8941     HRESULT hr;
8942     DWORD i;
8943
8944     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
8945     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8946     if(SUCCEEDED(hr)) {
8947         /* Properties that can't be removed. */
8948         const DWORD invalid = Uri_HAS_ABSOLUTE_URI|Uri_HAS_DISPLAY_URI|Uri_HAS_RAW_URI|Uri_HAS_HOST_TYPE|
8949                               Uri_HAS_SCHEME|Uri_HAS_ZONE;
8950
8951         for(i = Uri_PROPERTY_STRING_START; i <= Uri_PROPERTY_DWORD_LAST; ++i) {
8952             hr = IUriBuilder_RemoveProperties(builder, i << 1);
8953             if((i << 1) & invalid) {
8954                 ok(hr == E_INVALIDARG,
8955                     "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x with prop=%d.\n",
8956                     hr, E_INVALIDARG, i);
8957             } else {
8958                 ok(hr == S_OK,
8959                     "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x with prop=%d.\n",
8960                     hr, S_OK, i);
8961             }
8962         }
8963
8964         /* Also doesn't accept anything that's outside the range of the
8965          * Uri_HAS flags.
8966          */
8967         hr = IUriBuilder_RemoveProperties(builder, (Uri_PROPERTY_DWORD_LAST+1) << 1);
8968         ok(hr == E_INVALIDARG, "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x.\n",
8969             hr, E_INVALIDARG);
8970     }
8971     if(builder) IUriBuilder_Release(builder);
8972
8973     for(i = 0; i < sizeof(uri_builder_remove_tests)/sizeof(uri_builder_remove_tests[0]); ++i) {
8974         uri_builder_remove_test test = uri_builder_remove_tests[i];
8975         IUri *uri = NULL;
8976         LPWSTR uriW;
8977
8978         uriW = a2w(test.uri);
8979         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
8980         if(SUCCEEDED(hr)) {
8981             builder = NULL;
8982
8983             hr = pCreateIUriBuilder(uri, 0, 0, &builder);
8984             if(test.create_builder_todo) {
8985                 todo_wine {
8986                     ok(hr == test.create_builder_expected,
8987                         "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
8988                         hr, test.create_builder_expected, i);
8989                 }
8990             } else {
8991                 ok(hr == test.create_builder_expected,
8992                     "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
8993                     hr, test.create_builder_expected, i);
8994             }
8995             if(SUCCEEDED(hr)) {
8996                 hr = IUriBuilder_RemoveProperties(builder, test.remove_properties);
8997                 if(test.remove_todo) {
8998                     todo_wine {
8999                         ok(hr == test.remove_expected,
9000                             "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x on test %d.\n",
9001                             hr, test.remove_expected, i);
9002                     }
9003                 } else {
9004                     ok(hr == test.remove_expected,
9005                         "Error: IUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
9006                         hr, test.remove_expected, i);
9007                 }
9008                 if(SUCCEEDED(hr)) {
9009                     IUri *result = NULL;
9010
9011                     hr = IUriBuilder_CreateUri(builder, test.expected_flags, 0, 0, &result);
9012                     if(test.expected_todo) {
9013                         todo_wine {
9014                             ok(hr == test.expected_hres,
9015                                 "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on test %d.\n",
9016                                 hr, test.expected_hres, i);
9017                         }
9018                     } else {
9019                         ok(hr == test.expected_hres,
9020                             "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on test %d.\n",
9021                             hr, test.expected_hres, i);
9022                     }
9023                     if(SUCCEEDED(hr)) {
9024                         BSTR received = NULL;
9025
9026                         hr = IUri_GetAbsoluteUri(result, &received);
9027                         ok(!strcmp_aw(test.expected_uri, received),
9028                             "Error: Expected %s but got %s instead on test %d.\n",
9029                             test.expected_uri, wine_dbgstr_w(received), i);
9030                         SysFreeString(received);
9031                     }
9032                     if(result) IUri_Release(result);
9033                 }
9034             }
9035             if(builder) IUriBuilder_Release(builder);
9036         }
9037         if(uri) IUri_Release(uri);
9038         heap_free(uriW);
9039     }
9040 }
9041
9042 static void test_IUriBuilder_Misc(void) {
9043     HRESULT hr;
9044     IUri *uri;
9045
9046     hr = pCreateUri(http_urlW, 0, 0, &uri);
9047     if(SUCCEEDED(hr)) {
9048         IUriBuilder *builder;
9049
9050         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
9051         ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9052         if(SUCCEEDED(hr)) {
9053             BOOL has = -1;
9054             DWORD port = -1;
9055
9056             hr = IUriBuilder_GetPort(builder, &has, &port);
9057             ok(hr == S_OK, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9058             if(SUCCEEDED(hr)) {
9059                 /* 'has' will be set to FALSE, even though uri had a port. */
9060                 ok(has == FALSE, "Error: Expected 'has' to be FALSE, was %d instead.\n", has);
9061                 /* Still sets 'port' to 80. */
9062                 ok(port == 80, "Error: Expected the port to be 80, but, was %d instead.\n", port);
9063             }
9064         }
9065         if(builder) IUriBuilder_Release(builder);
9066     }
9067     if(uri) IUri_Release(uri);
9068 }
9069
9070 static void test_CoInternetCombineIUri(void) {
9071     HRESULT hr;
9072     IUri *base, *relative, *result;
9073     DWORD i;
9074
9075     base = NULL;
9076     hr = pCreateUri(http_urlW, 0, 0, &base);
9077     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x.\n", hr);
9078     if(SUCCEEDED(hr)) {
9079         result = (void*) 0xdeadbeef;
9080         hr = pCoInternetCombineIUri(base, NULL, 0, &result, 0);
9081         ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9082         ok(!result, "Error: Expected 'result' to be NULL, was %p.\n", result);
9083     }
9084
9085     relative = NULL;
9086     hr = pCreateUri(http_urlW, 0, 0, &relative);
9087     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x.\n", hr);
9088     if(SUCCEEDED(hr)) {
9089         result = (void*) 0xdeadbeef;
9090         hr = pCoInternetCombineIUri(NULL, relative, 0, &result, 0);
9091         ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9092         ok(!result, "Error: Expected 'result' to be NULL, was %p.\n", result);
9093     }
9094
9095     hr = pCoInternetCombineIUri(base, relative, 0, NULL, 0);
9096     ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9097
9098     if(base) IUri_Release(base);
9099     if(relative) IUri_Release(relative);
9100
9101     for(i = 0; i < sizeof(uri_combine_tests)/sizeof(uri_combine_tests[0]); ++i) {
9102         LPWSTR baseW = a2w(uri_combine_tests[i].base_uri);
9103
9104         hr = pCreateUri(baseW, uri_combine_tests[i].base_create_flags, 0, &base);
9105         ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x on uri_combine_tests[%d].\n", hr, i);
9106         if(SUCCEEDED(hr)) {
9107             LPWSTR relativeW = a2w(uri_combine_tests[i].relative_uri);
9108
9109             hr = pCreateUri(relativeW, uri_combine_tests[i].relative_create_flags, 0, &relative);
9110             ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x on uri_combine_tests[%d].\n", hr, i);
9111             if(SUCCEEDED(hr)) {
9112                 result = NULL;
9113
9114                 hr = pCoInternetCombineIUri(base, relative, uri_combine_tests[i].combine_flags, &result, 0);
9115                 if(uri_combine_tests[i].todo) {
9116                     todo_wine {
9117                         ok(hr == uri_combine_tests[i].expected,
9118                             "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9119                             hr, uri_combine_tests[i].expected, i);
9120                     }
9121                 } else {
9122                     ok(hr == uri_combine_tests[i].expected,
9123                         "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9124                         hr, uri_combine_tests[i]. expected, i);
9125                 }
9126                 if(SUCCEEDED(hr)) {
9127                     DWORD j;
9128
9129                     for(j = 0; j < sizeof(uri_combine_tests[i].str_props)/sizeof(uri_combine_tests[i].str_props[0]); ++j) {
9130                         uri_combine_str_property prop = uri_combine_tests[i].str_props[j];
9131                         BSTR received;
9132
9133                         hr = IUri_GetPropertyBSTR(result, j, &received, 0);
9134                         if(prop.todo) {
9135                             todo_wine {
9136                                 ok(hr == prop.expected,
9137                                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9138                                     hr, prop.expected, i, j);
9139                             }
9140                             todo_wine {
9141                                 ok(!strcmp_aw(prop.value, received) ||
9142                                    broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9143                                     "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9144                                     prop.value, wine_dbgstr_w(received), i, j);
9145                             }
9146                         } else {
9147                             ok(hr == prop.expected,
9148                                 "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9149                                 hr, prop.expected, i, j);
9150                             ok(!strcmp_aw(prop.value, received) ||
9151                                broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9152                                 "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9153                                 prop.value, wine_dbgstr_w(received), i, j);
9154                         }
9155                         SysFreeString(received);
9156                     }
9157
9158                     for(j = 0; j < sizeof(uri_combine_tests[i].dword_props)/sizeof(uri_combine_tests[i].dword_props[0]); ++j) {
9159                         uri_dword_property prop = uri_combine_tests[i].dword_props[j];
9160                         DWORD received;
9161
9162                         hr = IUri_GetPropertyDWORD(result, j+Uri_PROPERTY_DWORD_START, &received, 0);
9163                         if(prop.todo) {
9164                             todo_wine {
9165                                 ok(hr == prop.expected,
9166                                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9167                                     hr, prop.expected, i, j);
9168                             }
9169                             todo_wine {
9170                                 ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9171                                     prop.value, received, i, j);
9172                             }
9173                         } else {
9174                             ok(hr == prop.expected,
9175                                 "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9176                                 hr, prop.expected, i, j);
9177                             ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9178                                 prop.value, received, i, j);
9179                         }
9180                     }
9181                 }
9182                 if(result) IUri_Release(result);
9183             }
9184             if(relative) IUri_Release(relative);
9185             heap_free(relativeW);
9186         }
9187         if(base) IUri_Release(base);
9188         heap_free(baseW);
9189     }
9190 }
9191
9192 static HRESULT WINAPI InternetProtocolInfo_QueryInterface(IInternetProtocolInfo *iface,
9193                                                           REFIID riid, void **ppv)
9194 {
9195     ok(0, "unexpected call\n");
9196     return E_NOINTERFACE;
9197 }
9198
9199 static ULONG WINAPI InternetProtocolInfo_AddRef(IInternetProtocolInfo *iface)
9200 {
9201     return 2;
9202 }
9203
9204 static ULONG WINAPI InternetProtocolInfo_Release(IInternetProtocolInfo *iface)
9205 {
9206     return 1;
9207 }
9208
9209 static HRESULT WINAPI InternetProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
9210         PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
9211         DWORD *pcchResult, DWORD dwReserved)
9212 {
9213     ok(0, "unexpected call %d\n", ParseAction);
9214     return E_NOTIMPL;
9215 }
9216
9217 static HRESULT WINAPI InternetProtocolInfo_CombineUrl(IInternetProtocolInfo *iface,
9218         LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags,
9219         LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
9220 {
9221     CHECK_EXPECT(CombineUrl);
9222     ok(!lstrcmpW(pwzBaseUrl, combine_baseW), "Error: Expected %s, but got %s instead.\n",
9223         wine_dbgstr_w(combine_baseW), wine_dbgstr_w(pwzBaseUrl));
9224     ok(!lstrcmpW(pwzRelativeUrl, combine_relativeW), "Error: Expected %s, but got %s instead.\n",
9225         wine_dbgstr_w(combine_relativeW), wine_dbgstr_w(pwzRelativeUrl));
9226     ok(dwCombineFlags == (URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO),
9227         "Error: Expected 0, but got 0x%08x.\n", dwCombineFlags);
9228     ok(cchResult == INTERNET_MAX_URL_LENGTH+1, "Error: Got %d.\n", cchResult);
9229
9230     memcpy(pwzResult, combine_resultW, sizeof(combine_resultW));
9231     *pcchResult = lstrlenW(combine_resultW);
9232
9233     return S_OK;
9234 }
9235
9236 static HRESULT WINAPI InternetProtocolInfo_CompareUrl(IInternetProtocolInfo *iface,
9237         LPCWSTR pwzUrl1, LPCWSTR pwzUrl2, DWORD dwCompareFlags)
9238 {
9239     ok(0, "unexpected call\n");
9240     return E_NOTIMPL;
9241 }
9242
9243 static HRESULT WINAPI InternetProtocolInfo_QueryInfo(IInternetProtocolInfo *iface,
9244         LPCWSTR pwzUrl, QUERYOPTION OueryOption, DWORD dwQueryFlags, LPVOID pBuffer,
9245         DWORD cbBuffer, DWORD *pcbBuf, DWORD dwReserved)
9246 {
9247     ok(0, "unexpected call\n");
9248     return E_NOTIMPL;
9249 }
9250
9251 static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl = {
9252     InternetProtocolInfo_QueryInterface,
9253     InternetProtocolInfo_AddRef,
9254     InternetProtocolInfo_Release,
9255     InternetProtocolInfo_ParseUrl,
9256     InternetProtocolInfo_CombineUrl,
9257     InternetProtocolInfo_CompareUrl,
9258     InternetProtocolInfo_QueryInfo
9259 };
9260
9261 static IInternetProtocolInfo protocol_info = { &InternetProtocolInfoVtbl };
9262
9263 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
9264 {
9265     if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) {
9266         *ppv = &protocol_info;
9267         return S_OK;
9268     }
9269
9270     ok(0, "unexpected call\n");
9271     return E_NOINTERFACE;
9272 }
9273
9274 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
9275 {
9276     return 2;
9277 }
9278
9279 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
9280 {
9281     return 1;
9282 }
9283
9284 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
9285                                         REFIID riid, void **ppv)
9286 {
9287     ok(0, "unexpected call\n");
9288     return E_NOTIMPL;
9289 }
9290
9291 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
9292 {
9293     ok(0, "unexpected call\n");
9294     return S_OK;
9295 }
9296
9297 static const IClassFactoryVtbl ClassFactoryVtbl = {
9298     ClassFactory_QueryInterface,
9299     ClassFactory_AddRef,
9300     ClassFactory_Release,
9301     ClassFactory_CreateInstance,
9302     ClassFactory_LockServer
9303 };
9304
9305 static IClassFactory protocol_cf = { &ClassFactoryVtbl };
9306
9307 static void register_protocols(void)
9308 {
9309     IInternetSession *session;
9310     HRESULT hres;
9311
9312     hres = pCoInternetGetSession(0, &session, 0);
9313     ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
9314     if(FAILED(hres))
9315         return;
9316
9317     hres = IInternetSession_RegisterNameSpace(session, &protocol_cf, &IID_NULL,
9318             winetestW, 0, NULL, 0);
9319     ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
9320
9321     IInternetSession_Release(session);
9322 }
9323
9324 static void unregister_protocols(void) {
9325     IInternetSession *session;
9326     HRESULT hr;
9327
9328     hr = pCoInternetGetSession(0, &session, 0);
9329     ok(hr == S_OK, "CoInternetGetSession failed: 0x%08x\n", hr);
9330     if(FAILED(hr))
9331         return;
9332
9333     hr = IInternetSession_UnregisterNameSpace(session, &protocol_cf, winetestW);
9334     ok(hr == S_OK, "UnregisterNameSpace failed: 0x%08x\n", hr);
9335
9336     IInternetSession_Release(session);
9337 }
9338
9339 static void test_CoInternetCombineIUri_Pluggable(void) {
9340     HRESULT hr;
9341     IUri *base = NULL;
9342
9343     hr = pCreateUri(combine_baseW, 0, 0, &base);
9344     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9345     if(SUCCEEDED(hr)) {
9346         IUri *relative = NULL;
9347
9348         hr = pCreateUri(combine_relativeW, Uri_CREATE_ALLOW_RELATIVE, 0, &relative);
9349         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9350         if(SUCCEEDED(hr)) {
9351             IUri *result = NULL;
9352
9353             SET_EXPECT(CombineUrl);
9354
9355             hr = pCoInternetCombineIUri(base, relative, URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO,
9356                                         &result, 0);
9357             ok(hr == S_OK, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9358
9359             CHECK_CALLED(CombineUrl);
9360
9361             if(SUCCEEDED(hr)) {
9362                 BSTR received = NULL;
9363                 hr = IUri_GetAbsoluteUri(result, &received);
9364                 ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x instead.\n", hr);
9365                 if(SUCCEEDED(hr)) {
9366                     ok(!lstrcmpW(combine_resultW, received), "Error: Expected %s, but got %s.\n",
9367                         wine_dbgstr_w(combine_resultW), wine_dbgstr_w(received));
9368                 }
9369                 SysFreeString(received);
9370             }
9371             if(result) IUri_Release(result);
9372         }
9373         if(relative) IUri_Release(relative);
9374     }
9375     if(base) IUri_Release(base);
9376 }
9377
9378 static void test_CoInternetCombineUrlEx(void) {
9379     HRESULT hr;
9380     IUri *base, *result;
9381     DWORD i;
9382
9383     base = NULL;
9384     hr = pCreateUri(http_urlW, 0, 0, &base);
9385     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9386     if(SUCCEEDED(hr)) {
9387         result = (void*) 0xdeadbeef;
9388         hr = pCoInternetCombineUrlEx(base, NULL, 0, &result, 0);
9389         ok(hr == E_UNEXPECTED, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
9390             hr, E_UNEXPECTED);
9391         ok(!result, "Error: Expected 'result' to be NULL was %p instead.\n", result);
9392     }
9393
9394     result = (void*) 0xdeadbeef;
9395     hr = pCoInternetCombineUrlEx(NULL, http_urlW, 0, &result, 0);
9396     ok(hr == E_INVALIDARG, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
9397         hr, E_INVALIDARG);
9398     ok(!result, "Error: Expected 'result' to be NULL, but was %p instead.\n", result);
9399
9400     result = (void*) 0xdeadbeef;
9401     hr = pCoInternetCombineUrlEx(NULL, NULL, 0, &result, 0);
9402     ok(hr == E_UNEXPECTED, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
9403         hr, E_UNEXPECTED);
9404     ok(!result, "Error: Expected 'result' to be NULL, but was %p instead.\n", result);
9405
9406     hr = pCoInternetCombineUrlEx(base, http_urlW, 0, NULL, 0);
9407     ok(hr == E_POINTER, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
9408         hr, E_POINTER);
9409     if(base) IUri_Release(base);
9410
9411     for(i = 0; i < sizeof(uri_combine_tests)/sizeof(uri_combine_tests[0]); ++i) {
9412         LPWSTR baseW = a2w(uri_combine_tests[i].base_uri);
9413
9414         hr = pCreateUri(baseW, uri_combine_tests[i].base_create_flags, 0, &base);
9415         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x on uri_combine_tests[%d].\n", hr, i);
9416         if(SUCCEEDED(hr)) {
9417             LPWSTR relativeW = a2w(uri_combine_tests[i].relative_uri);
9418
9419             hr = pCoInternetCombineUrlEx(base, relativeW, uri_combine_tests[i].combine_flags,
9420                                          &result, 0);
9421             if(uri_combine_tests[i].todo) {
9422                 todo_wine {
9423                     ok(hr == uri_combine_tests[i].expected,
9424                         "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9425                         hr, uri_combine_tests[i].expected, i);
9426                 }
9427             } else {
9428                 ok(hr == uri_combine_tests[i].expected,
9429                     "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9430                     hr, uri_combine_tests[i]. expected, i);
9431             }
9432             if(SUCCEEDED(hr)) {
9433                 DWORD j;
9434
9435                 for(j = 0; j < sizeof(uri_combine_tests[i].str_props)/sizeof(uri_combine_tests[i].str_props[0]); ++j) {
9436                     uri_combine_str_property prop = uri_combine_tests[i].str_props[j];
9437                     BSTR received;
9438                     LPCSTR value = (prop.value_ex) ? prop.value_ex : prop.value;
9439
9440                     hr = IUri_GetPropertyBSTR(result, j, &received, 0);
9441                     if(prop.todo) {
9442                         todo_wine {
9443                             ok(hr == prop.expected,
9444                                 "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9445                                 hr, prop.expected, i, j);
9446                         }
9447                         todo_wine {
9448                             ok(!strcmp_aw(value, received) ||
9449                                broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9450                                 "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9451                                 value, wine_dbgstr_w(received), i, j);
9452                         }
9453                     } else {
9454                         ok(hr == prop.expected,
9455                             "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9456                             hr, prop.expected, i, j);
9457                         ok(!strcmp_aw(value, received) ||
9458                            broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9459                             "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9460                             value, wine_dbgstr_w(received), i, j);
9461                     }
9462                     SysFreeString(received);
9463                 }
9464
9465                 for(j = 0; j < sizeof(uri_combine_tests[i].dword_props)/sizeof(uri_combine_tests[i].dword_props[0]); ++j) {
9466                     uri_dword_property prop = uri_combine_tests[i].dword_props[j];
9467                     DWORD received;
9468
9469                     hr = IUri_GetPropertyDWORD(result, j+Uri_PROPERTY_DWORD_START, &received, 0);
9470                     if(prop.todo) {
9471                         todo_wine {
9472                             ok(hr == prop.expected,
9473                                 "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9474                                 hr, prop.expected, i, j);
9475                         }
9476                         todo_wine {
9477                             ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9478                                 prop.value, received, i, j);
9479                         }
9480                     } else {
9481                         ok(hr == prop.expected,
9482                             "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9483                             hr, prop.expected, i, j);
9484                         ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9485                             prop.value, received, i, j);
9486                     }
9487                 }
9488             }
9489             if(result) IUri_Release(result);
9490             heap_free(relativeW);
9491         }
9492         if(base) IUri_Release(base);
9493         heap_free(baseW);
9494     }
9495 }
9496
9497 static void test_CoInternetCombineUrlEx_Pluggable(void) {
9498     HRESULT hr;
9499     IUri *base = NULL;
9500
9501     hr = pCreateUri(combine_baseW, 0, 0, &base);
9502     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9503     if(SUCCEEDED(hr)) {
9504         IUri *result = NULL;
9505
9506         SET_EXPECT(CombineUrl);
9507
9508         hr = pCoInternetCombineUrlEx(base, combine_relativeW, URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO,
9509                                      &result, 0);
9510         ok(hr == S_OK, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9511
9512         CHECK_CALLED(CombineUrl);
9513
9514         if(SUCCEEDED(hr)) {
9515             BSTR received = NULL;
9516             hr = IUri_GetAbsoluteUri(result, &received);
9517             ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x instead.\n", hr);
9518             if(SUCCEEDED(hr)) {
9519                 ok(!lstrcmpW(combine_resultW, received), "Error: Expected %s, but got %s.\n",
9520                     wine_dbgstr_w(combine_resultW), wine_dbgstr_w(received));
9521             }
9522             SysFreeString(received);
9523         }
9524         if(result) IUri_Release(result);
9525     }
9526     if(base) IUri_Release(base);
9527 }
9528
9529 static void test_CoInternetParseIUri_InvalidArgs(void) {
9530     HRESULT hr;
9531     IUri *uri = NULL;
9532     WCHAR tmp[3];
9533     DWORD result = -1;
9534
9535     hr = pCoInternetParseIUri(NULL, PARSE_CANONICALIZE, 0, tmp, 3, &result, 0);
9536     ok(hr == E_INVALIDARG, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
9537         hr, E_INVALIDARG);
9538     ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
9539
9540     hr = pCreateUri(http_urlW, 0, 0, &uri);
9541     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9542     if(SUCCEEDED(hr)) {
9543         DWORD expected_len;
9544
9545         result = -1;
9546         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, NULL, 0, &result, 0);
9547         ok(hr == E_INVALIDARG, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
9548             hr, E_INVALIDARG);
9549         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
9550
9551         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, tmp, 3, NULL, 0);
9552         ok(hr == E_POINTER, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
9553             hr, E_POINTER);
9554
9555         result = -1;
9556         hr = pCoInternetParseIUri(uri, PARSE_SECURITY_URL, 0, tmp, 3, &result, 0);
9557         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x expected 0x%08x.\n",
9558             hr, E_FAIL);
9559         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
9560
9561         result = -1;
9562         hr = pCoInternetParseIUri(uri, PARSE_MIME, 0, tmp, 3, &result, 0);
9563         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
9564             hr, E_FAIL);
9565         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
9566
9567         result = -1;
9568         hr = pCoInternetParseIUri(uri, PARSE_SERVER, 0, tmp, 3, &result, 0);
9569         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
9570             hr, E_FAIL);
9571         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
9572
9573         result = -1;
9574         hr = pCoInternetParseIUri(uri, PARSE_SECURITY_DOMAIN, 0, tmp, 3, &result, 0);
9575         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
9576             hr, E_FAIL);
9577         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
9578
9579         expected_len = lstrlenW(http_urlW);
9580         result = -1;
9581         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, tmp, 3, &result, 0);
9582         ok(hr == STRSAFE_E_INSUFFICIENT_BUFFER,
9583             "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
9584             hr, STRSAFE_E_INSUFFICIENT_BUFFER);
9585         ok(result == expected_len, "Error: Expected 'result' to be %d, but was %d instead.\n",
9586             expected_len, result);
9587     }
9588     if(uri) IUri_Release(uri);
9589 }
9590
9591 static void test_CoInternetParseIUri(void) {
9592     DWORD i;
9593
9594     for(i = 0; i < sizeof(uri_parse_tests)/sizeof(uri_parse_tests[0]); ++i) {
9595         HRESULT hr;
9596         IUri *uri;
9597         LPWSTR uriW;
9598         uri_parse_test test = uri_parse_tests[i];
9599
9600         uriW = a2w(test.uri);
9601         hr = pCreateUri(uriW, test.uri_flags, 0, &uri);
9602         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x on uri_parse_tests[%d].\n", hr, i);
9603         if(SUCCEEDED(hr)) {
9604             WCHAR result[INTERNET_MAX_URL_LENGTH+1];
9605             DWORD result_len = -1;
9606
9607             hr = pCoInternetParseIUri(uri, test.action, test.flags, result, INTERNET_MAX_URL_LENGTH+1, &result_len, 0);
9608             if(test.todo) {
9609                 todo_wine {
9610                     ok(hr == test.expected,
9611                         "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x on uri_parse_tests[%d].\n",
9612                         hr, test.expected, i);
9613                 }
9614             } else {
9615                 ok(hr == test.expected,
9616                     "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x on uri_parse_tests[%d].\n",
9617                     hr, test.expected, i);
9618             }
9619             if(SUCCEEDED(hr)) {
9620                 DWORD len = lstrlenA(test.property);
9621                 ok(!strcmp_aw(test.property, result),
9622                     "Error: Expected %s but got %s instead on uri_parse_tests[%d].\n",
9623                     test.property, wine_dbgstr_w(result), i);
9624                 ok(len == result_len,
9625                     "Error: Expected %d, but got %d instead on uri_parse_tests[%d].\n",
9626                     len, result_len, i);
9627             } else {
9628                 ok(!result_len,
9629                     "Error: Expected 'result_len' to be 0, but was %d on uri_parse_tests[%d].\n",
9630                     result_len, i);
9631             }
9632         }
9633         if(uri) IUri_Release(uri);
9634         heap_free(uriW);
9635     }
9636 }
9637
9638 START_TEST(uri) {
9639     HMODULE hurlmon;
9640
9641     hurlmon = GetModuleHandle("urlmon.dll");
9642     pCoInternetGetSession = (void*) GetProcAddress(hurlmon, "CoInternetGetSession");
9643     pCreateUri = (void*) GetProcAddress(hurlmon, "CreateUri");
9644     pCreateUriWithFragment = (void*) GetProcAddress(hurlmon, "CreateUriWithFragment");
9645     pCreateIUriBuilder = (void*) GetProcAddress(hurlmon, "CreateIUriBuilder");
9646     pCoInternetCombineIUri = (void*) GetProcAddress(hurlmon, "CoInternetCombineIUri");
9647     pCoInternetCombineUrlEx = (void*) GetProcAddress(hurlmon, "CoInternetCombineUrlEx");
9648     pCoInternetParseIUri = (void*) GetProcAddress(hurlmon, "CoInternetParseIUri");
9649
9650     if(!pCreateUri) {
9651         win_skip("CreateUri is not present, skipping tests.\n");
9652         return;
9653     }
9654
9655     trace("test CreateUri invalid flags...\n");
9656     test_CreateUri_InvalidFlags();
9657
9658     trace("test CreateUri invalid args...\n");
9659     test_CreateUri_InvalidArgs();
9660
9661     trace("test CreateUri invalid URIs...\n");
9662     test_CreateUri_InvalidUri();
9663
9664     trace("test IUri_GetPropertyBSTR...\n");
9665     test_IUri_GetPropertyBSTR();
9666
9667     trace("test IUri_GetPropertyDWORD...\n");
9668     test_IUri_GetPropertyDWORD();
9669
9670     trace("test IUri_GetStrProperties...\n");
9671     test_IUri_GetStrProperties();
9672
9673     trace("test IUri_GetDwordProperties...\n");
9674     test_IUri_GetDwordProperties();
9675
9676     trace("test IUri_GetPropertyLength...\n");
9677     test_IUri_GetPropertyLength();
9678
9679     trace("test IUri_GetProperties...\n");
9680     test_IUri_GetProperties();
9681
9682     trace("test IUri_HasProperty...\n");
9683     test_IUri_HasProperty();
9684
9685     trace("test IUri_IsEqual...\n");
9686     test_IUri_IsEqual();
9687
9688     trace("test CreateUriWithFragment invalid args...\n");
9689     test_CreateUriWithFragment_InvalidArgs();
9690
9691     trace("test CreateUriWithFragment invalid flags...\n");
9692     test_CreateUriWithFragment_InvalidFlags();
9693
9694     trace("test CreateUriWithFragment...\n");
9695     test_CreateUriWithFragment();
9696
9697     trace("test CreateIUriBuilder...\n");
9698     test_CreateIUriBuilder();
9699
9700     trace("test IUriBuilder_CreateInvalidArgs...\n");
9701     test_IUriBuilder_CreateInvalidArgs();
9702
9703     trace("test IUriBuilder...\n");
9704     test_IUriBuilder();
9705
9706     trace("test IUriBuilder_GetInvalidArgs...\n");
9707     test_IUriBuilder_GetInvalidArgs();
9708
9709     trace("test IUriBuilder_HasBeenModified...\n");
9710     test_IUriBuilder_HasBeenModified();
9711
9712     trace("test IUriBuilder_IUriProperty...\n");
9713     test_IUriBuilder_IUriProperty();
9714
9715     trace("test IUriBuilder_RemoveProperties...\n");
9716     test_IUriBuilder_RemoveProperties();
9717
9718     trace("test IUriBuilder miscellaneous...\n");
9719     test_IUriBuilder_Misc();
9720
9721     trace("test CoInternetCombineIUri...\n");
9722     test_CoInternetCombineIUri();
9723
9724     trace("test CoInternetCombineUrlEx...\n");
9725     test_CoInternetCombineUrlEx();
9726
9727     trace("test CoInternetParseIUri Invalid Args...\n");
9728     test_CoInternetParseIUri_InvalidArgs();
9729
9730     trace("test CoInternetParseIUri...\n");
9731     test_CoInternetParseIUri();
9732
9733     register_protocols();
9734
9735     trace("test CoInternetCombineIUri pluggable...\n");
9736     test_CoInternetCombineIUri_Pluggable();
9737
9738     trace("test CoInternetCombineUrlEx Pluggable...\n");
9739     test_CoInternetCombineUrlEx_Pluggable();
9740
9741     unregister_protocols();
9742 }