urlmon: Implemented CoInternetCombineUrlEx.
[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
34 #define URI_STR_PROPERTY_COUNT Uri_PROPERTY_STRING_LAST+1
35 #define URI_DWORD_PROPERTY_COUNT (Uri_PROPERTY_DWORD_LAST - Uri_PROPERTY_DWORD_START)+1
36 #define URI_BUILDER_STR_PROPERTY_COUNT 7
37
38 #define DEFINE_EXPECT(func) \
39     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
40
41 #define SET_EXPECT(func) \
42     expect_ ## func = TRUE
43
44 #define CHECK_EXPECT(func) \
45     do { \
46         ok(expect_ ##func, "unexpected call " #func "\n"); \
47         expect_ ## func = FALSE; \
48         called_ ## func = TRUE; \
49     }while(0)
50
51 #define CHECK_EXPECT2(func) \
52     do { \
53         ok(expect_ ##func, "unexpected call " #func "\n"); \
54         called_ ## func = TRUE; \
55     }while(0)
56
57 #define CHECK_CALLED(func) \
58     do { \
59         ok(called_ ## func, "expected " #func "\n"); \
60         expect_ ## func = called_ ## func = FALSE; \
61     }while(0)
62
63 DEFINE_EXPECT(CombineUrl);
64
65 static HRESULT (WINAPI *pCreateUri)(LPCWSTR, DWORD, DWORD_PTR, IUri**);
66 static HRESULT (WINAPI *pCreateUriWithFragment)(LPCWSTR, LPCWSTR, DWORD, DWORD_PTR, IUri**);
67 static HRESULT (WINAPI *pCreateIUriBuilder)(IUri*, DWORD, DWORD_PTR, IUriBuilder**);
68 static HRESULT (WINAPI *pCoInternetCombineIUri)(IUri*,IUri*,DWORD,IUri**,DWORD_PTR);
69 static HRESULT (WINAPI *pCoInternetGetSession)(DWORD,IInternetSession**,DWORD);
70 static HRESULT (WINAPI *pCoInternetCombineUrlEx)(IUri*,LPCWSTR,DWORD,IUri**,DWORD_PTR);
71
72 static const WCHAR http_urlW[] = { 'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
73         '.','o','r','g','/',0};
74 static const WCHAR http_url_fragW[] = { 'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
75         '.','o','r','g','/','#','F','r','a','g',0};
76
77 static const WCHAR combine_baseW[] = {'w','i','n','e','t','e','s','t',':','?','t',
78         'e','s','t','i','n','g',0};
79 static const WCHAR combine_relativeW[] = {'?','t','e','s','t',0};
80 static const WCHAR combine_resultW[] = {'z','i','p',':','t','e','s','t',0};
81
82 static const WCHAR winetestW[] = {'w','i','n','e','t','e','s','t',0};
83
84 typedef struct _uri_create_flag_test {
85     DWORD   flags;
86     HRESULT expected;
87 } uri_create_flag_test;
88
89 static const uri_create_flag_test invalid_flag_tests[] = {
90     /* Set of invalid flag combinations to test for. */
91     {Uri_CREATE_DECODE_EXTRA_INFO | Uri_CREATE_NO_DECODE_EXTRA_INFO, E_INVALIDARG},
92     {Uri_CREATE_CANONICALIZE | Uri_CREATE_NO_CANONICALIZE, E_INVALIDARG},
93     {Uri_CREATE_CRACK_UNKNOWN_SCHEMES | Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES, E_INVALIDARG},
94     {Uri_CREATE_PRE_PROCESS_HTML_URI | Uri_CREATE_NO_PRE_PROCESS_HTML_URI, E_INVALIDARG},
95     {Uri_CREATE_IE_SETTINGS | Uri_CREATE_NO_IE_SETTINGS, E_INVALIDARG}
96 };
97
98 typedef struct _uri_str_property {
99     const char* value;
100     HRESULT     expected;
101     BOOL        todo;
102     const char* broken_value;
103 } uri_str_property;
104
105 typedef struct _uri_dword_property {
106     DWORD   value;
107     HRESULT expected;
108     BOOL    todo;
109 } uri_dword_property;
110
111 typedef struct _uri_properties {
112     const char*         uri;
113     DWORD               create_flags;
114     HRESULT             create_expected;
115     BOOL                create_todo;
116
117     uri_str_property    str_props[URI_STR_PROPERTY_COUNT];
118     uri_dword_property  dword_props[URI_DWORD_PROPERTY_COUNT];
119 } uri_properties;
120
121 static const uri_properties uri_tests[] = {
122     {   "http://www.winehq.org/tests/../tests/../..", 0, S_OK, FALSE,
123         {
124             {"http://www.winehq.org/",S_OK,FALSE},                      /* ABSOLUTE_URI */
125             {"www.winehq.org",S_OK,FALSE},                              /* AUTHORITY */
126             {"http://www.winehq.org/",S_OK,FALSE},                      /* DISPLAY_URI */
127             {"winehq.org",S_OK,FALSE},                                  /* DOMAIN */
128             {"",S_FALSE,FALSE},                                         /* EXTENSION */
129             {"",S_FALSE,FALSE},                                         /* FRAGMENT */
130             {"www.winehq.org",S_OK,FALSE},                              /* HOST */
131             {"",S_FALSE,FALSE},                                         /* PASSWORD */
132             {"/",S_OK,FALSE},                                           /* PATH */
133             {"/",S_OK,FALSE},                                           /* PATH_AND_QUERY */
134             {"",S_FALSE,FALSE},                                         /* QUERY */
135             {"http://www.winehq.org/tests/../tests/../..",S_OK,FALSE},  /* RAW_URI */
136             {"http",S_OK,FALSE},                                        /* SCHEME_NAME */
137             {"",S_FALSE,FALSE},                                         /* USER_INFO */
138             {"",S_FALSE,FALSE}                                          /* USER_NAME */
139         },
140         {
141             {Uri_HOST_DNS,S_OK,FALSE},                                  /* HOST_TYPE */
142             {80,S_OK,FALSE},                                            /* PORT */
143             {URL_SCHEME_HTTP,S_OK,FALSE},                               /* SCHEME */
144             {URLZONE_INVALID,E_NOTIMPL,FALSE}                           /* ZONE */
145         }
146     },
147     {   "http://winehq.org/tests/.././tests", 0, S_OK, FALSE,
148         {
149             {"http://winehq.org/tests",S_OK,FALSE},
150             {"winehq.org",S_OK,FALSE},
151             {"http://winehq.org/tests",S_OK,FALSE},
152             {"winehq.org",S_OK,FALSE},
153             {"",S_FALSE,FALSE},
154             {"",S_FALSE,FALSE},
155             {"winehq.org",S_OK,FALSE},
156             {"",S_FALSE,FALSE},
157             {"/tests",S_OK,FALSE},
158             {"/tests",S_OK,FALSE},
159             {"",S_FALSE,FALSE},
160             {"http://winehq.org/tests/.././tests",S_OK,FALSE},
161             {"http",S_OK,FALSE},
162             {"",S_FALSE,FALSE},
163             {"",S_FALSE,FALSE}
164         },
165         {
166             {Uri_HOST_DNS,S_OK,FALSE},
167             {80,S_OK,FALSE},
168             {URL_SCHEME_HTTP,S_OK,FALSE},
169             {URLZONE_INVALID,E_NOTIMPL,FALSE}
170         }
171     },
172     {   "HtTp://www.winehq.org/tests/..?query=x&return=y", 0, S_OK, FALSE,
173         {
174             {"http://www.winehq.org/?query=x&return=y",S_OK,FALSE},
175             {"www.winehq.org",S_OK,FALSE},
176             {"http://www.winehq.org/?query=x&return=y",S_OK,FALSE},
177             {"winehq.org",S_OK,FALSE},
178             {"",S_FALSE,FALSE},
179             {"",S_FALSE,FALSE},
180             {"www.winehq.org",S_OK,FALSE},
181             {"",S_FALSE,FALSE},
182             {"/",S_OK,FALSE},
183             {"/?query=x&return=y",S_OK,FALSE},
184             {"?query=x&return=y",S_OK,FALSE},
185             {"HtTp://www.winehq.org/tests/..?query=x&return=y",S_OK,FALSE},
186             {"http",S_OK,FALSE},
187             {"",S_FALSE,FALSE},
188             {"",S_FALSE,FALSE}
189         },
190         {
191             {Uri_HOST_DNS,S_OK,FALSE},
192             {80,S_OK,FALSE},
193             {URL_SCHEME_HTTP,S_OK,FALSE},
194             {URLZONE_INVALID,E_NOTIMPL,FALSE},
195         }
196     },
197     {   "hTTp://us%45r%3Ainfo@examp%4CE.com:80/path/a/b/./c/../%2E%2E/Forbidden'<|> Characters", 0, S_OK, FALSE,
198         {
199             {"http://usEr%3Ainfo@example.com/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
200             {"usEr%3Ainfo@example.com",S_OK,FALSE},
201             {"http://example.com/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
202             {"example.com",S_OK,FALSE},
203             {"",S_FALSE,FALSE},
204             {"",S_FALSE,FALSE},
205             {"example.com",S_OK,FALSE},
206             {"",S_FALSE,FALSE},
207             {"/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
208             {"/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
209             {"",S_FALSE,FALSE},
210             {"hTTp://us%45r%3Ainfo@examp%4CE.com:80/path/a/b/./c/../%2E%2E/Forbidden'<|> Characters",S_OK,FALSE},
211             {"http",S_OK,FALSE},
212             {"usEr%3Ainfo",S_OK,FALSE},
213             {"usEr%3Ainfo",S_OK,FALSE}
214         },
215         {
216             {Uri_HOST_DNS,S_OK,FALSE},
217             {80,S_OK,FALSE},
218             {URL_SCHEME_HTTP,S_OK,FALSE},
219             {URLZONE_INVALID,E_NOTIMPL,FALSE},
220         }
221     },
222     {   "ftp://winepass:wine@ftp.winehq.org:9999/dir/foo bar.txt", 0, S_OK, FALSE,
223         {
224             {"ftp://winepass:wine@ftp.winehq.org:9999/dir/foo%20bar.txt",S_OK,FALSE},
225             {"winepass:wine@ftp.winehq.org:9999",S_OK,FALSE},
226             {"ftp://ftp.winehq.org:9999/dir/foo%20bar.txt",S_OK,FALSE},
227             {"winehq.org",S_OK,FALSE},
228             {".txt",S_OK,FALSE},
229             {"",S_FALSE,FALSE},
230             {"ftp.winehq.org",S_OK,FALSE},
231             {"wine",S_OK,FALSE},
232             {"/dir/foo%20bar.txt",S_OK,FALSE},
233             {"/dir/foo%20bar.txt",S_OK,FALSE},
234             {"",S_FALSE,FALSE},
235             {"ftp://winepass:wine@ftp.winehq.org:9999/dir/foo bar.txt",S_OK,FALSE},
236             {"ftp",S_OK,FALSE},
237             {"winepass:wine",S_OK,FALSE},
238             {"winepass",S_OK,FALSE}
239         },
240         {
241             {Uri_HOST_DNS,S_OK,FALSE},
242             {9999,S_OK,FALSE},
243             {URL_SCHEME_FTP,S_OK,FALSE},
244             {URLZONE_INVALID,E_NOTIMPL,FALSE}
245         }
246     },
247     {   "file://c:\\tests\\../tests/foo%20bar.mp3", 0, S_OK, FALSE,
248         {
249             {"file:///c:/tests/foo%2520bar.mp3",S_OK,FALSE},
250             {"",S_FALSE,FALSE},
251             {"file:///c:/tests/foo%2520bar.mp3",S_OK,FALSE},
252             {"",S_FALSE,FALSE},
253             {".mp3",S_OK,FALSE},
254             {"",S_FALSE,FALSE},
255             {"",S_FALSE,FALSE},
256             {"",S_FALSE,FALSE},
257             {"/c:/tests/foo%2520bar.mp3",S_OK,FALSE},
258             {"/c:/tests/foo%2520bar.mp3",S_OK,FALSE},
259             {"",S_FALSE,FALSE},
260             {"file://c:\\tests\\../tests/foo%20bar.mp3",S_OK,FALSE},
261             {"file",S_OK,FALSE},
262             {"",S_FALSE,FALSE},
263             {"",S_FALSE,FALSE}
264         },
265         {
266             {Uri_HOST_UNKNOWN,S_OK,FALSE},
267             {0,S_FALSE,FALSE},
268             {URL_SCHEME_FILE,S_OK,FALSE},
269             {URLZONE_INVALID,E_NOTIMPL,FALSE}
270         }
271     },
272     {   "FILE://localhost/test dir\\../tests/test%20file.README.txt", 0, S_OK, FALSE,
273         {
274             {"file:///tests/test%20file.README.txt",S_OK,FALSE},
275             {"",S_FALSE,FALSE},
276             {"file:///tests/test%20file.README.txt",S_OK,FALSE},
277             {"",S_FALSE,FALSE},
278             {".txt",S_OK,FALSE},
279             {"",S_FALSE,FALSE},
280             {"",S_FALSE,FALSE},
281             {"",S_FALSE,FALSE},
282             {"/tests/test%20file.README.txt",S_OK,FALSE},
283             {"/tests/test%20file.README.txt",S_OK,FALSE},
284             {"",S_FALSE,FALSE},
285             {"FILE://localhost/test dir\\../tests/test%20file.README.txt",S_OK,FALSE},
286             {"file",S_OK,FALSE},
287             {"",S_FALSE,FALSE},
288             {"",S_FALSE,FALSE}
289         },
290         {
291             {Uri_HOST_UNKNOWN,S_OK,FALSE},
292             {0,S_FALSE,FALSE},
293             {URL_SCHEME_FILE,S_OK,FALSE},
294             {URLZONE_INVALID,E_NOTIMPL,FALSE}
295         }
296     },
297     {   "urn:nothing:should:happen here", 0, S_OK, FALSE,
298         {
299             {"urn:nothing:should:happen here",S_OK,FALSE},
300             {"",S_FALSE,FALSE},
301             {"urn:nothing:should:happen here",S_OK,FALSE},
302             {"",S_FALSE,FALSE},
303             {"",S_FALSE,FALSE},
304             {"",S_FALSE,FALSE},
305             {"",S_FALSE,FALSE},
306             {"",S_FALSE,FALSE},
307             {"nothing:should:happen here",S_OK,FALSE},
308             {"nothing:should:happen here",S_OK,FALSE},
309             {"",S_FALSE,FALSE},
310             {"urn:nothing:should:happen here",S_OK,FALSE},
311             {"urn",S_OK,FALSE},
312             {"",S_FALSE,FALSE},
313             {"",S_FALSE,FALSE}
314         },
315         {
316             {Uri_HOST_UNKNOWN,S_OK,FALSE},
317             {0,S_FALSE,FALSE},
318             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
319             {URLZONE_INVALID,E_NOTIMPL,FALSE}
320         }
321     },
322     {   "http://127.0.0.1/tests/../test dir/./test.txt", 0, S_OK, FALSE,
323         {
324             {"http://127.0.0.1/test%20dir/test.txt",S_OK,FALSE},
325             {"127.0.0.1",S_OK,FALSE},
326             {"http://127.0.0.1/test%20dir/test.txt",S_OK,FALSE},
327             {"",S_FALSE,FALSE},
328             {".txt",S_OK,FALSE},
329             {"",S_FALSE,FALSE},
330             {"127.0.0.1",S_OK,FALSE},
331             {"",S_FALSE,FALSE},
332             {"/test%20dir/test.txt",S_OK,FALSE},
333             {"/test%20dir/test.txt",S_OK,FALSE},
334             {"",S_FALSE,FALSE},
335             {"http://127.0.0.1/tests/../test dir/./test.txt",S_OK,FALSE},
336             {"http",S_OK,FALSE},
337             {"",S_FALSE,FALSE},
338             {"",S_FALSE,FALSE}
339         },
340         {
341             {Uri_HOST_IPV4,S_OK,FALSE},
342             {80,S_OK,FALSE},
343             {URL_SCHEME_HTTP,S_OK,FALSE},
344             {URLZONE_INVALID,E_NOTIMPL,FALSE}
345         }
346     },
347     {   "http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]", 0, S_OK, FALSE,
348         {
349             {"http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/",S_OK,FALSE},
350             {"[fedc:ba98:7654:3210:fedc:ba98:7654:3210]",S_OK,FALSE},
351             {"http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/",S_OK,FALSE},
352             {"",S_FALSE,FALSE},
353             {"",S_FALSE,FALSE},
354             {"",S_FALSE,FALSE},
355             {"fedc:ba98:7654:3210:fedc:ba98:7654:3210",S_OK,FALSE},
356             {"",S_FALSE,FALSE},
357             {"/",S_OK,FALSE},
358             {"/",S_OK,FALSE},
359             {"",S_FALSE,FALSE},
360             {"http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]",S_OK,FALSE},
361             {"http",S_OK,FALSE},
362             {"",S_FALSE,FALSE},
363             {"",S_FALSE,FALSE}
364         },
365         {
366             {Uri_HOST_IPV6,S_OK,FALSE},
367             {80,S_OK,FALSE},
368             {URL_SCHEME_HTTP,S_OK,FALSE},
369             {URLZONE_INVALID,E_NOTIMPL,FALSE}
370         }
371     },
372     {   "ftp://[::13.1.68.3]", 0, S_OK, FALSE,
373         {
374             {"ftp://[::13.1.68.3]/",S_OK,FALSE},
375             {"[::13.1.68.3]",S_OK,FALSE},
376             {"ftp://[::13.1.68.3]/",S_OK,FALSE},
377             {"",S_FALSE,FALSE},
378             {"",S_FALSE,FALSE},
379             {"",S_FALSE,FALSE},
380             {"::13.1.68.3",S_OK,FALSE},
381             {"",S_FALSE,FALSE},
382             {"/",S_OK,FALSE},
383             {"/",S_OK,FALSE},
384             {"",S_FALSE,FALSE},
385             {"ftp://[::13.1.68.3]",S_OK,FALSE},
386             {"ftp",S_OK,FALSE},
387             {"",S_FALSE,FALSE},
388             {"",S_FALSE,FALSE}
389         },
390         {
391             {Uri_HOST_IPV6,S_OK,FALSE},
392             {21,S_OK,FALSE},
393             {URL_SCHEME_FTP,S_OK,FALSE},
394             {URLZONE_INVALID,E_NOTIMPL,FALSE}
395         }
396     },
397     {   "http://[FEDC:BA98:0:0:0:0:0:3210]", 0, S_OK, FALSE,
398         {
399             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
400             {"[fedc:ba98::3210]",S_OK,FALSE},
401             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
402             {"",S_FALSE,FALSE},
403             {"",S_FALSE,FALSE},
404             {"",S_FALSE,FALSE},
405             {"fedc:ba98::3210",S_OK,FALSE},
406             {"",S_FALSE,FALSE},
407             {"/",S_OK,FALSE},
408             {"/",S_OK,FALSE},
409             {"",S_FALSE,FALSE},
410             {"http://[FEDC:BA98:0:0:0:0:0:3210]",S_OK,FALSE},
411             {"http",S_OK,FALSE},
412             {"",S_FALSE,FALSE},
413             {"",S_FALSE,FALSE},
414         },
415         {
416             {Uri_HOST_IPV6,S_OK,FALSE},
417             {80,S_OK,FALSE},
418             {URL_SCHEME_HTTP,S_OK,FALSE},
419             {URLZONE_INVALID,E_NOTIMPL,FALSE}
420         }
421     },
422     {   "1234://www.winehq.org", 0, S_OK, FALSE,
423         {
424             {"1234://www.winehq.org/",S_OK,FALSE},
425             {"www.winehq.org",S_OK,FALSE},
426             {"1234://www.winehq.org/",S_OK,FALSE},
427             {"winehq.org",S_OK,FALSE},
428             {"",S_FALSE,FALSE},
429             {"",S_FALSE,FALSE},
430             {"www.winehq.org",S_OK,FALSE},
431             {"",S_FALSE,FALSE},
432             {"/",S_OK,FALSE},
433             {"/",S_OK,FALSE},
434             {"",S_FALSE,FALSE},
435             {"1234://www.winehq.org",S_OK,FALSE},
436             {"1234",S_OK,FALSE},
437             {"",S_FALSE,FALSE},
438             {"",S_FALSE,FALSE}
439         },
440         {
441             {Uri_HOST_DNS,S_OK,FALSE},
442             {0,S_FALSE,FALSE},
443             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
444             {URLZONE_INVALID,E_NOTIMPL,FALSE}
445         }
446     },
447     /* Test's to make sure the parser/canonicalizer handles implicit file schemes correctly. */
448     {   "C:/test/test.mp3", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, S_OK, FALSE,
449         {
450             {"file:///C:/test/test.mp3",S_OK,FALSE},
451             {"",S_FALSE,FALSE},
452             {"file:///C:/test/test.mp3",S_OK,FALSE},
453             {"",S_FALSE,FALSE},
454             {".mp3",S_OK,FALSE},
455             {"",S_FALSE,FALSE},
456             {"",S_FALSE,FALSE},
457             {"",S_FALSE,FALSE},
458             {"/C:/test/test.mp3",S_OK,FALSE},
459             {"/C:/test/test.mp3",S_OK,FALSE},
460             {"",S_FALSE,FALSE},
461             {"C:/test/test.mp3",S_OK,FALSE},
462             {"file",S_OK,FALSE},
463             {"",S_FALSE,FALSE},
464             {"",S_FALSE,FALSE}
465         },
466         {
467             {Uri_HOST_UNKNOWN,S_OK,FALSE},
468             {0,S_FALSE,FALSE},
469             {URL_SCHEME_FILE,S_OK,FALSE},
470             {URLZONE_INVALID,E_NOTIMPL,FALSE}
471         }
472     },
473     /* Test's to make sure the parser/canonicalizer handles implicit file schemes correctly. */
474     {   "\\\\Server/test.mp3", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, S_OK, FALSE,
475         {
476             {"file://server/test.mp3",S_OK,FALSE},
477             {"server",S_OK,FALSE},
478             {"file://server/test.mp3",S_OK,FALSE},
479             {"",S_FALSE,FALSE},
480             {".mp3",S_OK,FALSE},
481             {"",S_FALSE,FALSE},
482             {"server",S_OK,FALSE},
483             {"",S_FALSE,FALSE},
484             {"/test.mp3",S_OK,FALSE},
485             {"/test.mp3",S_OK,FALSE},
486             {"",S_FALSE,FALSE},
487             {"\\\\Server/test.mp3",S_OK,FALSE},
488             {"file",S_OK,FALSE},
489             {"",S_FALSE,FALSE},
490             {"",S_FALSE,FALSE}
491         },
492         {
493             {Uri_HOST_DNS,S_OK,FALSE},
494             {0,S_FALSE,FALSE},
495             {URL_SCHEME_FILE,S_OK,FALSE},
496             {URLZONE_INVALID,E_NOTIMPL,FALSE}
497         }
498     },
499     {   "www.winehq.org/test", Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME, S_OK, FALSE,
500         {
501             {"*:www.winehq.org/test",S_OK,FALSE},
502             {"www.winehq.org",S_OK,FALSE},
503             {"*:www.winehq.org/test",S_OK,FALSE},
504             {"winehq.org",S_OK,FALSE},
505             {"",S_FALSE,FALSE},
506             {"",S_FALSE,FALSE},
507             {"www.winehq.org",S_OK,FALSE},
508             {"",S_FALSE,FALSE},
509             {"/test",S_OK,FALSE},
510             {"/test",S_OK,FALSE},
511             {"",S_FALSE,FALSE},
512             {"www.winehq.org/test",S_OK,FALSE},
513             {"*",S_OK,FALSE},
514             {"",S_FALSE,FALSE},
515             {"",S_FALSE,FALSE}
516         },
517         {
518             {Uri_HOST_DNS,S_OK,FALSE},
519             {0,S_FALSE,FALSE},
520             {URL_SCHEME_WILDCARD,S_OK,FALSE},
521             {URLZONE_INVALID,E_NOTIMPL,FALSE}
522         }
523     },
524     /* Valid since the '*' is the only character in the scheme name. */
525     {   "*:www.winehq.org/test", 0, S_OK, FALSE,
526         {
527             {"*:www.winehq.org/test",S_OK,FALSE},
528             {"www.winehq.org",S_OK,FALSE},
529             {"*:www.winehq.org/test",S_OK,FALSE},
530             {"winehq.org",S_OK,FALSE},
531             {"",S_FALSE,FALSE},
532             {"",S_FALSE,FALSE},
533             {"www.winehq.org",S_OK,FALSE},
534             {"",S_FALSE,FALSE},
535             {"/test",S_OK,FALSE},
536             {"/test",S_OK,FALSE},
537             {"",S_FALSE,FALSE},
538             {"*:www.winehq.org/test",S_OK,FALSE},
539             {"*",S_OK,FALSE},
540             {"",S_FALSE,FALSE},
541             {"",S_FALSE,FALSE}
542         },
543         {
544             {Uri_HOST_DNS,S_OK,FALSE},
545             {0,S_FALSE,FALSE},
546             {URL_SCHEME_WILDCARD,S_OK,FALSE},
547             {URLZONE_INVALID,E_NOTIMPL,FALSE}
548         }
549     },
550     {   "/../some dir/test.ext", Uri_CREATE_ALLOW_RELATIVE, S_OK, FALSE,
551         {
552             {"/../some dir/test.ext",S_OK,FALSE},
553             {"",S_FALSE,FALSE},
554             {"/../some dir/test.ext",S_OK,FALSE},
555             {"",S_FALSE,FALSE},
556             {".ext",S_OK,FALSE},
557             {"",S_FALSE,FALSE},
558             {"",S_FALSE,FALSE},
559             {"",S_FALSE,FALSE},
560             {"/../some dir/test.ext",S_OK,FALSE},
561             {"/../some dir/test.ext",S_OK,FALSE},
562             {"",S_FALSE,FALSE},
563             {"/../some dir/test.ext",S_OK,FALSE},
564             {"",S_FALSE,FALSE},
565             {"",S_FALSE,FALSE},
566             {"",S_FALSE,FALSE}
567         },
568         {
569             {Uri_HOST_UNKNOWN,S_OK,FALSE},
570             {0,S_FALSE,FALSE},
571             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
572             {URLZONE_INVALID,E_NOTIMPL,FALSE}
573         }
574     },
575     {   "//implicit/wildcard/uri scheme", Uri_CREATE_ALLOW_RELATIVE|Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME, S_OK, FALSE,
576         {
577             {"*://implicit/wildcard/uri%20scheme",S_OK,FALSE},
578             {"",S_OK,FALSE},
579             {"*://implicit/wildcard/uri%20scheme",S_OK,FALSE},
580             {"",S_FALSE,FALSE},
581             {"",S_FALSE,FALSE},
582             {"",S_FALSE,FALSE},
583             {"",S_OK,FALSE},
584             {"",S_FALSE,FALSE},
585             {"//implicit/wildcard/uri%20scheme",S_OK,FALSE},
586             {"//implicit/wildcard/uri%20scheme",S_OK,FALSE},
587             {"",S_FALSE,FALSE},
588             {"//implicit/wildcard/uri scheme",S_OK,FALSE},
589             {"*",S_OK,FALSE},
590             {"",S_FALSE,FALSE},
591             {"",S_FALSE,FALSE},
592         },
593         {
594             {Uri_HOST_UNKNOWN,S_OK,FALSE},
595             {0,S_FALSE,FALSE},
596             {URL_SCHEME_WILDCARD,S_OK,FALSE},
597             {URLZONE_INVALID,E_NOTIMPL,FALSE}
598         }
599     },
600     /* URI is considered opaque since CREATE_NO_CRACK_UNKNOWN_SCHEMES is set and its an unknown scheme. */
601     {   "zip://google.com", Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES, S_OK, FALSE,
602         {
603             {"zip:/.//google.com",S_OK,FALSE},
604             {"",S_FALSE,FALSE},
605             {"zip:/.//google.com",S_OK,FALSE},
606             {"",S_FALSE,FALSE},
607             {".com",S_OK,FALSE},
608             {"",S_FALSE,FALSE},
609             {"",S_FALSE,FALSE},
610             {"",S_FALSE,FALSE},
611             {"/.//google.com",S_OK,FALSE},
612             {"/.//google.com",S_OK,FALSE},
613             {"",S_FALSE,FALSE},
614             {"zip://google.com",S_OK,FALSE},
615             {"zip",S_OK,FALSE},
616             {"",S_FALSE,FALSE},
617             {"",S_FALSE,FALSE}
618         },
619         {
620             {Uri_HOST_UNKNOWN,S_OK,FALSE},
621             {0,S_FALSE,FALSE},
622             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
623             {URLZONE_INVALID,E_NOTIMPL,FALSE}
624         }
625     },
626     /* Windows uses the first occurrence of ':' to delimit the userinfo. */
627     {   "ftp://user:pass:word@winehq.org/", 0, S_OK, FALSE,
628         {
629             {"ftp://user:pass:word@winehq.org/",S_OK,FALSE},
630             {"user:pass:word@winehq.org",S_OK,FALSE},
631             {"ftp://winehq.org/",S_OK,FALSE},
632             {"winehq.org",S_OK,FALSE},
633             {"",S_FALSE,FALSE},
634             {"",S_FALSE,FALSE},
635             {"winehq.org",S_OK,FALSE},
636             {"pass:word",S_OK,FALSE},
637             {"/",S_OK,FALSE},
638             {"/",S_OK,FALSE},
639             {"",S_FALSE,FALSE},
640             {"ftp://user:pass:word@winehq.org/",S_OK,FALSE},
641             {"ftp",S_OK,FALSE},
642             {"user:pass:word",S_OK,FALSE},
643             {"user",S_OK,FALSE}
644         },
645         {
646             {Uri_HOST_DNS,S_OK,FALSE},
647             {21,S_OK,FALSE},
648             {URL_SCHEME_FTP,S_OK,FALSE},
649             {URLZONE_INVALID,E_NOTIMPL,FALSE}
650         }
651     },
652     /* Make sure % encoded unreserved characters are decoded. */
653     {   "ftp://w%49%4Ee:PA%53%53@ftp.google.com/", 0, S_OK, FALSE,
654         {
655             {"ftp://wINe:PASS@ftp.google.com/",S_OK,FALSE},
656             {"wINe:PASS@ftp.google.com",S_OK,FALSE},
657             {"ftp://ftp.google.com/",S_OK,FALSE},
658             {"google.com",S_OK,FALSE},
659             {"",S_FALSE,FALSE},
660             {"",S_FALSE,FALSE},
661             {"ftp.google.com",S_OK,FALSE},
662             {"PASS",S_OK,FALSE},
663             {"/",S_OK,FALSE},
664             {"/",S_OK,FALSE},
665             {"",S_FALSE,FALSE},
666             {"ftp://w%49%4Ee:PA%53%53@ftp.google.com/",S_OK,FALSE},
667             {"ftp",S_OK,FALSE},
668             {"wINe:PASS",S_OK,FALSE},
669             {"wINe",S_OK,FALSE}
670         },
671         {
672             {Uri_HOST_DNS,S_OK,FALSE},
673             {21,S_OK,FALSE},
674             {URL_SCHEME_FTP,S_OK,FALSE},
675             {URLZONE_INVALID,E_NOTIMPL,FALSE}
676         }
677     },
678     /* Make sure % encoded characters which are NOT unreserved are NOT decoded. */
679     {   "ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/", 0, S_OK, FALSE,
680         {
681             {"ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/",S_OK,FALSE},
682             {"w%5D%5Be:PA%7B%7D@ftp.google.com",S_OK,FALSE},
683             {"ftp://ftp.google.com/",S_OK,FALSE},
684             {"google.com",S_OK,FALSE},
685             {"",S_FALSE,FALSE},
686             {"",S_FALSE,FALSE},
687             {"ftp.google.com",S_OK,FALSE},
688             {"PA%7B%7D",S_OK,FALSE},
689             {"/",S_OK,FALSE},
690             {"/",S_OK,FALSE},
691             {"",S_FALSE,FALSE},
692             {"ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/",S_OK,FALSE},
693             {"ftp",S_OK,FALSE},
694             {"w%5D%5Be:PA%7B%7D",S_OK,FALSE},
695             {"w%5D%5Be",S_OK,FALSE}
696         },
697         {
698             {Uri_HOST_DNS,S_OK,FALSE},
699             {21,S_OK,FALSE},
700             {URL_SCHEME_FTP,S_OK,FALSE},
701             {URLZONE_INVALID,E_NOTIMPL,FALSE}
702         }
703     },
704     /* You're allowed to have an empty password portion in the userinfo section. */
705     {   "ftp://empty:@ftp.google.com/", 0, S_OK, FALSE,
706         {
707             {"ftp://empty:@ftp.google.com/",S_OK,FALSE},
708             {"empty:@ftp.google.com",S_OK,FALSE},
709             {"ftp://ftp.google.com/",S_OK,FALSE},
710             {"google.com",S_OK,FALSE},
711             {"",S_FALSE,FALSE},
712             {"",S_FALSE,FALSE},
713             {"ftp.google.com",S_OK,FALSE},
714             {"",S_OK,FALSE},
715             {"/",S_OK,FALSE},
716             {"/",S_OK,FALSE},
717             {"",S_FALSE,FALSE},
718             {"ftp://empty:@ftp.google.com/",S_OK,FALSE},
719             {"ftp",S_OK,FALSE},
720             {"empty:",S_OK,FALSE},
721             {"empty",S_OK,FALSE}
722         },
723         {
724             {Uri_HOST_DNS,S_OK,FALSE},
725             {21,S_OK,FALSE},
726             {URL_SCHEME_FTP,S_OK,FALSE},
727             {URLZONE_INVALID,E_NOTIMPL,FALSE}
728         }
729     },
730     /* Make sure forbidden characters in "userinfo" get encoded. */
731     {   "ftp://\" \"weird@ftp.google.com/", 0, S_OK, FALSE,
732         {
733             {"ftp://%22%20%22weird@ftp.google.com/",S_OK,FALSE},
734             {"%22%20%22weird@ftp.google.com",S_OK,FALSE},
735             {"ftp://ftp.google.com/",S_OK,FALSE},
736             {"google.com",S_OK,FALSE},
737             {"",S_FALSE,FALSE},
738             {"",S_FALSE,FALSE},
739             {"ftp.google.com",S_OK,FALSE},
740             {"",S_FALSE,FALSE},
741             {"/",S_OK,FALSE},
742             {"/",S_OK,FALSE},
743             {"",S_FALSE,FALSE},
744             {"ftp://\" \"weird@ftp.google.com/",S_OK,FALSE},
745             {"ftp",S_OK,FALSE},
746             {"%22%20%22weird",S_OK,FALSE},
747             {"%22%20%22weird",S_OK,FALSE}
748         },
749         {
750             {Uri_HOST_DNS,S_OK,FALSE},
751             {21,S_OK,FALSE},
752             {URL_SCHEME_FTP,S_OK,FALSE},
753             {URLZONE_INVALID,E_NOTIMPL,FALSE}
754         }
755     },
756     /* Make sure the forbidden characters don't get percent encoded. */
757     {   "ftp://\" \"weird@ftp.google.com/", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
758         {
759             {"ftp://\" \"weird@ftp.google.com/",S_OK,FALSE},
760             {"\" \"weird@ftp.google.com",S_OK,FALSE},
761             {"ftp://ftp.google.com/",S_OK,FALSE},
762             {"google.com",S_OK,FALSE},
763             {"",S_FALSE,FALSE},
764             {"",S_FALSE,FALSE},
765             {"ftp.google.com",S_OK,FALSE},
766             {"",S_FALSE,FALSE},
767             {"/",S_OK,FALSE},
768             {"/",S_OK,FALSE},
769             {"",S_FALSE,FALSE},
770             {"ftp://\" \"weird@ftp.google.com/",S_OK,FALSE},
771             {"ftp",S_OK,FALSE},
772             {"\" \"weird",S_OK,FALSE},
773             {"\" \"weird",S_OK,FALSE}
774         },
775         {
776             {Uri_HOST_DNS,S_OK,FALSE},
777             {21,S_OK,FALSE},
778             {URL_SCHEME_FTP,S_OK,FALSE},
779             {URLZONE_INVALID,E_NOTIMPL,FALSE}
780         }
781     },
782     /* Allowed to have invalid % encoded because its an unknown scheme type. */
783     {   "zip://%xy:word@winehq.org/", 0, S_OK, FALSE,
784         {
785             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
786             {"%xy:word@winehq.org",S_OK,FALSE},
787             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
788             {"winehq.org",S_OK,FALSE},
789             {"",S_FALSE,FALSE},
790             {"",S_FALSE,FALSE},
791             {"winehq.org",S_OK,FALSE},
792             {"word",S_OK,FALSE},
793             {"/",S_OK,FALSE},
794             {"/",S_OK,FALSE},
795             {"",S_FALSE,FALSE},
796             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
797             {"zip",S_OK,FALSE},
798             {"%xy:word",S_OK,FALSE},
799             {"%xy",S_OK,FALSE}
800         },
801         {
802             {Uri_HOST_DNS,S_OK,FALSE},
803             {0,S_FALSE,FALSE},
804             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
805             {URLZONE_INVALID,E_NOTIMPL,FALSE}
806         }
807     },
808     /* Unreserved, percent encoded characters aren't decoded in the userinfo becuase the scheme
809      * isn't known.
810      */
811     {   "zip://%2E:%52%53ord@winehq.org/", 0, S_OK, FALSE,
812         {
813             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
814             {"%2E:%52%53ord@winehq.org",S_OK,FALSE},
815             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
816             {"winehq.org",S_OK,FALSE},
817             {"",S_FALSE,FALSE},
818             {"",S_FALSE,FALSE},
819             {"winehq.org",S_OK,FALSE},
820             {"%52%53ord",S_OK,FALSE},
821             {"/",S_OK,FALSE},
822             {"/",S_OK,FALSE},
823             {"",S_FALSE,FALSE},
824             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
825             {"zip",S_OK,FALSE},
826             {"%2E:%52%53ord",S_OK,FALSE},
827             {"%2E",S_OK,FALSE}
828         },
829         {
830             {Uri_HOST_DNS,S_OK,FALSE},
831             {0,S_FALSE,FALSE},
832             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
833             {URLZONE_INVALID,E_NOTIMPL,FALSE}
834         }
835     },
836     {   "ftp://[](),'test':word@winehq.org/", 0, S_OK, FALSE,
837         {
838             {"ftp://[](),'test':word@winehq.org/",S_OK,FALSE},
839             {"[](),'test':word@winehq.org",S_OK,FALSE},
840             {"ftp://winehq.org/",S_OK,FALSE},
841             {"winehq.org",S_OK,FALSE},
842             {"",S_FALSE,FALSE},
843             {"",S_FALSE,FALSE},
844             {"winehq.org",S_OK,FALSE},
845             {"word",S_OK,FALSE},
846             {"/",S_OK,FALSE},
847             {"/",S_OK,FALSE},
848             {"",S_FALSE,FALSE},
849             {"ftp://[](),'test':word@winehq.org/",S_OK,FALSE},
850             {"ftp",S_OK,FALSE},
851             {"[](),'test':word",S_OK,FALSE},
852             {"[](),'test'",S_OK,FALSE}
853         },
854         {
855             {Uri_HOST_DNS,S_OK,FALSE},
856             {21,S_OK,FALSE},
857             {URL_SCHEME_FTP,S_OK,FALSE},
858             {URLZONE_INVALID,E_NOTIMPL,FALSE}
859         }
860     },
861     {   "ftp://test?:word@winehq.org/", 0, S_OK, FALSE,
862         {
863             {"ftp://test/?:word@winehq.org/",S_OK,FALSE},
864             {"test",S_OK,FALSE},
865             {"ftp://test/?:word@winehq.org/",S_OK,FALSE},
866             {"",S_FALSE,FALSE},
867             {"",S_FALSE,FALSE},
868             {"",S_FALSE,FALSE},
869             {"test",S_OK,FALSE},
870             {"",S_FALSE,FALSE},
871             {"/",S_OK,FALSE},
872             {"/?:word@winehq.org/",S_OK,FALSE},
873             {"?:word@winehq.org/",S_OK,FALSE},
874             {"ftp://test?:word@winehq.org/",S_OK,FALSE},
875             {"ftp",S_OK,FALSE},
876             {"",S_FALSE,FALSE},
877             {"",S_FALSE,FALSE}
878         },
879         {
880             {Uri_HOST_DNS,S_OK,FALSE},
881             {21,S_OK,FALSE},
882             {URL_SCHEME_FTP,S_OK,FALSE},
883             {URLZONE_INVALID,E_NOTIMPL,FALSE}
884         }
885     },
886     {   "ftp://test#:word@winehq.org/", 0, S_OK, FALSE,
887         {
888             {"ftp://test/#:word@winehq.org/",S_OK,FALSE},
889             {"test",S_OK,FALSE},
890             {"ftp://test/#:word@winehq.org/",S_OK,FALSE},
891             {"",S_FALSE,FALSE},
892             {"",S_FALSE,FALSE},
893             {"#:word@winehq.org/",S_OK,FALSE},
894             {"test",S_OK,FALSE},
895             {"",S_FALSE,FALSE},
896             {"/",S_OK,FALSE},
897             {"/",S_OK,FALSE},
898             {"",S_FALSE,FALSE},
899             {"ftp://test#:word@winehq.org/",S_OK,FALSE},
900             {"ftp",S_OK,FALSE},
901             {"",S_FALSE,FALSE},
902             {"",S_FALSE,FALSE}
903         },
904         {
905             {Uri_HOST_DNS,S_OK,FALSE},
906             {21,S_OK,FALSE},
907             {URL_SCHEME_FTP,S_OK,FALSE},
908             {URLZONE_INVALID,E_NOTIMPL,FALSE}
909         }
910     },
911     /* Allowed to have a backslash in the userinfo since it's an unknown scheme. */
912     {   "zip://test\\:word@winehq.org/", 0, S_OK, FALSE,
913         {
914             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
915             {"test\\:word@winehq.org",S_OK,FALSE},
916             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
917             {"winehq.org",S_OK,FALSE},
918             {"",S_FALSE,FALSE},
919             {"",S_FALSE,FALSE},
920             {"winehq.org",S_OK,FALSE},
921             {"word",S_OK,FALSE},
922             {"/",S_OK,FALSE},
923             {"/",S_OK,FALSE},
924             {"",S_FALSE,FALSE},
925             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
926             {"zip",S_OK,FALSE},
927             {"test\\:word",S_OK,FALSE},
928             {"test\\",S_OK,FALSE}
929         },
930         {
931             {Uri_HOST_DNS,S_OK,FALSE},
932             {0,S_FALSE,FALSE},
933             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
934             {URLZONE_INVALID,E_NOTIMPL,FALSE}
935         }
936     },
937     /* It normalizes IPv4 addresses correctly. */
938     {   "http://127.000.000.100/", 0, S_OK, FALSE,
939         {
940             {"http://127.0.0.100/",S_OK,FALSE},
941             {"127.0.0.100",S_OK,FALSE},
942             {"http://127.0.0.100/",S_OK,FALSE},
943             {"",S_FALSE,FALSE},
944             {"",S_FALSE,FALSE},
945             {"",S_FALSE,FALSE},
946             {"127.0.0.100",S_OK,FALSE},
947             {"",S_FALSE,FALSE},
948             {"/",S_OK,FALSE},
949             {"/",S_OK,FALSE},
950             {"",S_FALSE,FALSE},
951             {"http://127.000.000.100/",S_OK,FALSE},
952             {"http",S_OK,FALSE},
953             {"",S_FALSE,FALSE},
954             {"",S_FALSE,FALSE}
955         },
956         {
957             {Uri_HOST_IPV4,S_OK,FALSE},
958             {80,S_OK,FALSE},
959             {URL_SCHEME_HTTP,S_OK,FALSE},
960             {URLZONE_INVALID,E_NOTIMPL,FALSE}
961         }
962     },
963     /* Make sure it normalizes partial IPv4 addresses correctly. */
964     {   "http://127.0/", 0, S_OK, FALSE,
965         {
966             {"http://127.0.0.0/",S_OK,FALSE},
967             {"127.0.0.0",S_OK,FALSE},
968             {"http://127.0.0.0/",S_OK,FALSE},
969             {"",S_FALSE,FALSE},
970             {"",S_FALSE,FALSE},
971             {"",S_FALSE,FALSE},
972             {"127.0.0.0",S_OK,FALSE},
973             {"",S_FALSE,FALSE},
974             {"/",S_OK,FALSE},
975             {"/",S_OK,FALSE},
976             {"",S_FALSE,FALSE},
977             {"http://127.0/",S_OK,FALSE},
978             {"http",S_OK,FALSE},
979             {"",S_FALSE,FALSE},
980             {"",S_FALSE,FALSE}
981         },
982         {
983             {Uri_HOST_IPV4,S_OK,FALSE},
984             {80,S_OK,FALSE},
985             {URL_SCHEME_HTTP,S_OK,FALSE},
986             {URLZONE_INVALID,E_NOTIMPL,FALSE}
987         }
988     },
989     /* Make sure it converts implicit IPv4's correctly. */
990     {   "http://123456/", 0, S_OK, FALSE,
991         {
992             {"http://0.1.226.64/",S_OK,FALSE},
993             {"0.1.226.64",S_OK,FALSE},
994             {"http://0.1.226.64/",S_OK,FALSE},
995             {"",S_FALSE,FALSE},
996             {"",S_FALSE,FALSE},
997             {"",S_FALSE,FALSE},
998             {"0.1.226.64",S_OK,FALSE},
999             {"",S_FALSE,FALSE},
1000             {"/",S_OK,FALSE},
1001             {"/",S_OK,FALSE},
1002             {"",S_FALSE,FALSE},
1003             {"http://123456/",S_OK,FALSE},
1004             {"http",S_OK,FALSE},
1005             {"",S_FALSE,FALSE},
1006             {"",S_FALSE,FALSE}
1007         },
1008         {
1009             {Uri_HOST_IPV4,S_OK,FALSE},
1010             {80,S_OK,FALSE},
1011             {URL_SCHEME_HTTP,S_OK,FALSE},
1012             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1013         }
1014     },
1015     /* UINT_MAX */
1016     {   "http://4294967295/", 0, S_OK, FALSE,
1017         {
1018             {"http://255.255.255.255/",S_OK,FALSE},
1019             {"255.255.255.255",S_OK,FALSE},
1020             {"http://255.255.255.255/",S_OK,FALSE},
1021             {"",S_FALSE,FALSE},
1022             {"",S_FALSE,FALSE},
1023             {"",S_FALSE,FALSE},
1024             {"255.255.255.255",S_OK,FALSE},
1025             {"",S_FALSE,FALSE},
1026             {"/",S_OK,FALSE},
1027             {"/",S_OK,FALSE},
1028             {"",S_FALSE,FALSE},
1029             {"http://4294967295/",S_OK,FALSE},
1030             {"http",S_OK,FALSE},
1031             {"",S_FALSE,FALSE},
1032             {"",S_FALSE,FALSE}
1033         },
1034         {
1035             {Uri_HOST_IPV4,S_OK,FALSE},
1036             {80,S_OK,FALSE},
1037             {URL_SCHEME_HTTP,S_OK,FALSE},
1038             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1039         }
1040     },
1041     /* UINT_MAX+1 */
1042     {   "http://4294967296/", 0, S_OK, FALSE,
1043         {
1044             {"http://4294967296/",S_OK,FALSE},
1045             {"4294967296",S_OK,FALSE},
1046             {"http://4294967296/",S_OK,FALSE},
1047             {"",S_FALSE,FALSE},
1048             {"",S_FALSE,FALSE},
1049             {"",S_FALSE,FALSE},
1050             {"4294967296",S_OK,FALSE},
1051             {"",S_FALSE,FALSE},
1052             {"/",S_OK,FALSE},
1053             {"/",S_OK,FALSE},
1054             {"",S_FALSE,FALSE},
1055             {"http://4294967296/",S_OK,FALSE},
1056             {"http",S_OK,FALSE},
1057             {"",S_FALSE,FALSE},
1058             {"",S_FALSE,FALSE}
1059         },
1060         {
1061             {Uri_HOST_DNS,S_OK,FALSE},
1062             {80,S_OK,FALSE},
1063             {URL_SCHEME_HTTP,S_OK,FALSE},
1064             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1065         }
1066     },
1067     /* Window's doesn't normalize IP address for unknown schemes. */
1068     {   "1234://4294967295/", 0, S_OK, FALSE,
1069         {
1070             {"1234://4294967295/",S_OK,FALSE},
1071             {"4294967295",S_OK,FALSE},
1072             {"1234://4294967295/",S_OK,FALSE},
1073             {"",S_FALSE,FALSE},
1074             {"",S_FALSE,FALSE},
1075             {"",S_FALSE,FALSE},
1076             {"4294967295",S_OK,FALSE},
1077             {"",S_FALSE,FALSE},
1078             {"/",S_OK,FALSE},
1079             {"/",S_OK,FALSE},
1080             {"",S_FALSE,FALSE},
1081             {"1234://4294967295/",S_OK,FALSE},
1082             {"1234",S_OK,FALSE},
1083             {"",S_FALSE,FALSE},
1084             {"",S_FALSE,FALSE}
1085         },
1086         {
1087             {Uri_HOST_IPV4,S_OK,FALSE},
1088             {0,S_FALSE,FALSE},
1089             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1090             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1091         }
1092     },
1093     /* Window's doesn't normalize IP address for unknown schemes. */
1094     {   "1234://127.001/", 0, S_OK, FALSE,
1095         {
1096             {"1234://127.001/",S_OK,FALSE},
1097             {"127.001",S_OK,FALSE},
1098             {"1234://127.001/",S_OK,FALSE},
1099             {"",S_FALSE,FALSE},
1100             {"",S_FALSE,FALSE},
1101             {"",S_FALSE,FALSE},
1102             {"127.001",S_OK,FALSE},
1103             {"",S_FALSE,FALSE},
1104             {"/",S_OK,FALSE},
1105             {"/",S_OK,FALSE},
1106             {"",S_FALSE,FALSE},
1107             {"1234://127.001/",S_OK,FALSE},
1108             {"1234",S_OK,FALSE},
1109             {"",S_FALSE,FALSE},
1110             {"",S_FALSE,FALSE}
1111         },
1112         {
1113             {Uri_HOST_IPV4,S_OK,FALSE},
1114             {0,S_FALSE,FALSE},
1115             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1116             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1117         }
1118     },
1119     {   "http://[FEDC:BA98::3210]", 0, S_OK, FALSE,
1120         {
1121             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
1122             {"[fedc:ba98::3210]",S_OK,FALSE},
1123             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
1124             {"",S_FALSE,FALSE},
1125             {"",S_FALSE,FALSE},
1126             {"",S_FALSE,FALSE},
1127             {"fedc:ba98::3210",S_OK,FALSE},
1128             {"",S_FALSE,FALSE},
1129             {"/",S_OK,FALSE},
1130             {"/",S_OK,FALSE},
1131             {"",S_FALSE,FALSE},
1132             {"http://[FEDC:BA98::3210]",S_OK,FALSE},
1133             {"http",S_OK,FALSE},
1134             {"",S_FALSE,FALSE},
1135             {"",S_FALSE,FALSE},
1136         },
1137         {
1138             {Uri_HOST_IPV6,S_OK,FALSE},
1139             {80,S_OK,FALSE},
1140             {URL_SCHEME_HTTP,S_OK,FALSE},
1141             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1142         }
1143     },
1144     {   "http://[::]", 0, S_OK, FALSE,
1145         {
1146             {"http://[::]/",S_OK,FALSE},
1147             {"[::]",S_OK,FALSE},
1148             {"http://[::]/",S_OK,FALSE},
1149             {"",S_FALSE,FALSE},
1150             {"",S_FALSE,FALSE},
1151             {"",S_FALSE,FALSE},
1152             {"::",S_OK,FALSE},
1153             {"",S_FALSE,FALSE},
1154             {"/",S_OK,FALSE},
1155             {"/",S_OK,FALSE},
1156             {"",S_FALSE,FALSE},
1157             {"http://[::]",S_OK,FALSE},
1158             {"http",S_OK,FALSE},
1159             {"",S_FALSE,FALSE},
1160             {"",S_FALSE,FALSE},
1161         },
1162         {
1163             {Uri_HOST_IPV6,S_OK,FALSE},
1164             {80,S_OK,FALSE},
1165             {URL_SCHEME_HTTP,S_OK,FALSE},
1166             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1167         }
1168     },
1169     {   "http://[FEDC:BA98::]", 0, S_OK, FALSE,
1170         {
1171             {"http://[fedc:ba98::]/",S_OK,FALSE},
1172             {"[fedc:ba98::]",S_OK,FALSE},
1173             {"http://[fedc:ba98::]/",S_OK,FALSE},
1174             {"",S_FALSE,FALSE},
1175             {"",S_FALSE,FALSE},
1176             {"",S_FALSE,FALSE},
1177             {"fedc:ba98::",S_OK,FALSE},
1178             {"",S_FALSE,FALSE},
1179             {"/",S_OK,FALSE},
1180             {"/",S_OK,FALSE},
1181             {"",S_FALSE,FALSE},
1182             {"http://[FEDC:BA98::]",S_OK,FALSE},
1183             {"http",S_OK,FALSE},
1184             {"",S_FALSE,FALSE},
1185             {"",S_FALSE,FALSE},
1186         },
1187         {
1188             {Uri_HOST_IPV6,S_OK,FALSE},
1189             {80,S_OK,FALSE},
1190             {URL_SCHEME_HTTP,S_OK,FALSE},
1191             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1192         }
1193     },
1194     /* Valid even with 2 byte elision because it doesn't appear the beginning or end. */
1195     {   "http://[1::3:4:5:6:7:8]", 0, S_OK, FALSE,
1196         {
1197             {"http://[1:0:3:4:5:6:7:8]/",S_OK,FALSE},
1198             {"[1:0:3:4:5:6:7:8]",S_OK,FALSE},
1199             {"http://[1:0:3:4:5:6:7:8]/",S_OK,FALSE},
1200             {"",S_FALSE,FALSE},
1201             {"",S_FALSE,FALSE},
1202             {"",S_FALSE,FALSE},
1203             {"1:0:3:4:5:6:7:8",S_OK,FALSE},
1204             {"",S_FALSE,FALSE},
1205             {"/",S_OK,FALSE},
1206             {"/",S_OK,FALSE},
1207             {"",S_FALSE,FALSE},
1208             {"http://[1::3:4:5:6:7:8]",S_OK,FALSE},
1209             {"http",S_OK,FALSE},
1210             {"",S_FALSE,FALSE},
1211             {"",S_FALSE,FALSE},
1212         },
1213         {
1214             {Uri_HOST_IPV6,S_OK,FALSE},
1215             {80,S_OK,FALSE},
1216             {URL_SCHEME_HTTP,S_OK,FALSE},
1217             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1218         }
1219     },
1220     {   "http://[v2.34]/", 0, S_OK, FALSE,
1221         {
1222             {"http://[v2.34]/",S_OK,FALSE},
1223             {"[v2.34]",S_OK,FALSE},
1224             {"http://[v2.34]/",S_OK,FALSE},
1225             {"",S_FALSE,FALSE},
1226             {"",S_FALSE,FALSE},
1227             {"",S_FALSE,FALSE},
1228             {"[v2.34]",S_OK,FALSE},
1229             {"",S_FALSE,FALSE},
1230             {"/",S_OK,FALSE},
1231             {"/",S_OK,FALSE},
1232             {"",S_FALSE,FALSE},
1233             {"http://[v2.34]/",S_OK,FALSE},
1234             {"http",S_OK,FALSE},
1235             {"",S_FALSE,FALSE},
1236             {"",S_FALSE,FALSE}
1237         },
1238         {
1239             {Uri_HOST_UNKNOWN,S_OK,FALSE},
1240             {80,S_OK,FALSE},
1241             {URL_SCHEME_HTTP,S_OK,FALSE},
1242             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1243         }
1244     },
1245     /* Windows ignores ':' if they appear after a '[' on a non-IPLiteral host. */
1246     {   "http://[xyz:12345.com/test", 0, S_OK, FALSE,
1247         {
1248             {"http://[xyz:12345.com/test",S_OK,FALSE},
1249             {"[xyz:12345.com",S_OK,FALSE},
1250             {"http://[xyz:12345.com/test",S_OK,FALSE},
1251             {"[xyz:12345.com",S_OK,FALSE},
1252             {"",S_FALSE,FALSE},
1253             {"",S_FALSE,FALSE},
1254             {"[xyz:12345.com",S_OK,FALSE},
1255             {"",S_FALSE,FALSE},
1256             {"/test",S_OK,FALSE},
1257             {"/test",S_OK,FALSE},
1258             {"",S_FALSE,FALSE},
1259             {"http://[xyz:12345.com/test",S_OK,FALSE},
1260             {"http",S_OK,FALSE},
1261             {"",S_FALSE,FALSE},
1262             {"",S_FALSE,FALSE}
1263         },
1264         {
1265             {Uri_HOST_DNS,S_OK,FALSE},
1266             {80,S_OK,FALSE},
1267             {URL_SCHEME_HTTP,S_OK,FALSE},
1268             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1269         }
1270     },
1271     /* Valid URI since the '[' and ']' don't appear at the beginning and end
1272      * of the host name (respectively).
1273      */
1274     {   "ftp://www.[works].com/", 0, S_OK, FALSE,
1275         {
1276             {"ftp://www.[works].com/",S_OK,FALSE},
1277             {"www.[works].com",S_OK,FALSE},
1278             {"ftp://www.[works].com/",S_OK,FALSE},
1279             {"[works].com",S_OK,FALSE},
1280             {"",S_FALSE,FALSE},
1281             {"",S_FALSE,FALSE},
1282             {"www.[works].com",S_OK,FALSE},
1283             {"",S_FALSE,FALSE},
1284             {"/",S_OK,FALSE},
1285             {"/",S_OK,FALSE},
1286             {"",S_FALSE,FALSE},
1287             {"ftp://www.[works].com/",S_OK,FALSE},
1288             {"ftp",S_OK,FALSE},
1289             {"",S_FALSE,FALSE},
1290             {"",S_FALSE,FALSE}
1291         },
1292         {
1293             {Uri_HOST_DNS,S_OK,FALSE},
1294             {21,S_OK,FALSE},
1295             {URL_SCHEME_FTP,S_OK,FALSE},
1296             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1297         }
1298     },
1299     /* Considers ':' a delimiter since it appears after the ']'. */
1300     {   "http://www.google.com]:12345/", 0, S_OK, FALSE,
1301         {
1302             {"http://www.google.com]:12345/",S_OK,FALSE},
1303             {"www.google.com]:12345",S_OK,FALSE},
1304             {"http://www.google.com]:12345/",S_OK,FALSE},
1305             {"google.com]",S_OK,FALSE},
1306             {"",S_FALSE,FALSE},
1307             {"",S_FALSE,FALSE},
1308             {"www.google.com]",S_OK,FALSE},
1309             {"",S_FALSE,FALSE},
1310             {"/",S_OK,FALSE},
1311             {"/",S_OK,FALSE},
1312             {"",S_FALSE,FALSE},
1313             {"http://www.google.com]:12345/",S_OK,FALSE},
1314             {"http",S_OK,FALSE},
1315             {"",S_FALSE,FALSE},
1316             {"",S_FALSE,FALSE}
1317         },
1318         {
1319             {Uri_HOST_DNS,S_OK,FALSE},
1320             {12345,S_OK,FALSE},
1321             {URL_SCHEME_HTTP,S_OK,FALSE},
1322             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1323         }
1324     },
1325     /* Unknown scheme types can have invalid % encoded data in the hostname. */
1326     {   "zip://w%XXw%GEw.google.com/", 0, S_OK, FALSE,
1327         {
1328             {"zip://w%XXw%GEw.google.com/",S_OK,FALSE},
1329             {"w%XXw%GEw.google.com",S_OK,FALSE},
1330             {"zip://w%XXw%GEw.google.com/",S_OK,FALSE},
1331             {"google.com",S_OK,FALSE},
1332             {"",S_FALSE,FALSE},
1333             {"",S_FALSE,FALSE},
1334             {"w%XXw%GEw.google.com",S_OK,FALSE},
1335             {"",S_FALSE,FALSE},
1336             {"/",S_OK,FALSE},
1337             {"/",S_OK,FALSE},
1338             {"",S_FALSE,FALSE},
1339             {"zip://w%XXw%GEw.google.com/",S_OK,FALSE},
1340             {"zip",S_OK,FALSE},
1341             {"",S_FALSE,FALSE},
1342             {"",S_FALSE,FALSE}
1343         },
1344         {
1345             {Uri_HOST_DNS,S_OK,FALSE},
1346             {0,S_FALSE,FALSE},
1347             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1348             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1349         }
1350     },
1351     /* Unknown scheme types hostname doesn't get lower cased. */
1352     {   "zip://GOOGLE.com/", 0, S_OK, FALSE,
1353         {
1354             {"zip://GOOGLE.com/",S_OK,FALSE},
1355             {"GOOGLE.com",S_OK,FALSE},
1356             {"zip://GOOGLE.com/",S_OK,FALSE},
1357             {"GOOGLE.com",S_OK,FALSE},
1358             {"",S_FALSE,FALSE},
1359             {"",S_FALSE,FALSE},
1360             {"GOOGLE.com",S_OK,FALSE},
1361             {"",S_FALSE,FALSE},
1362             {"/",S_OK,FALSE},
1363             {"/",S_OK,FALSE},
1364             {"",S_FALSE,FALSE},
1365             {"zip://GOOGLE.com/",S_OK,FALSE},
1366             {"zip",S_OK,FALSE},
1367             {"",S_FALSE,FALSE},
1368             {"",S_FALSE,FALSE}
1369         },
1370         {
1371             {Uri_HOST_DNS,S_OK,FALSE},
1372             {0,S_FALSE,FALSE},
1373             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1374             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1375         }
1376     },
1377     /* Hostname get's lower cased for known scheme types. */
1378     {   "http://WWW.GOOGLE.com/", 0, S_OK, FALSE,
1379         {
1380             {"http://www.google.com/",S_OK,FALSE},
1381             {"www.google.com",S_OK,FALSE},
1382             {"http://www.google.com/",S_OK,FALSE},
1383             {"google.com",S_OK,FALSE},
1384             {"",S_FALSE,FALSE},
1385             {"",S_FALSE,FALSE},
1386             {"www.google.com",S_OK,FALSE},
1387             {"",S_FALSE,FALSE},
1388             {"/",S_OK,FALSE},
1389             {"/",S_OK,FALSE},
1390             {"",S_FALSE,FALSE},
1391             {"http://WWW.GOOGLE.com/",S_OK,FALSE},
1392             {"http",S_OK,FALSE},
1393             {"",S_FALSE,FALSE},
1394             {"",S_FALSE,FALSE}
1395         },
1396         {
1397             {Uri_HOST_DNS,S_OK,FALSE},
1398             {80,S_OK,FALSE},
1399             {URL_SCHEME_HTTP,S_OK,FALSE},
1400             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1401         }
1402     },
1403     /* Characters that get % encoded in the hostname also have their percent
1404      * encoded forms lower cased.
1405      */
1406     {   "http://www.%7Cgoogle|.com/", 0, S_OK, FALSE,
1407         {
1408             {"http://www.%7cgoogle%7c.com/",S_OK,FALSE},
1409             {"www.%7cgoogle%7c.com",S_OK,FALSE},
1410             {"http://www.%7cgoogle%7c.com/",S_OK,FALSE},
1411             {"%7cgoogle%7c.com",S_OK,FALSE},
1412             {"",S_FALSE,FALSE},
1413             {"",S_FALSE,FALSE},
1414             {"www.%7cgoogle%7c.com",S_OK,FALSE},
1415             {"",S_FALSE,FALSE},
1416             {"/",S_OK,FALSE},
1417             {"/",S_OK,FALSE},
1418             {"",S_FALSE,FALSE},
1419             {"http://www.%7Cgoogle|.com/",S_OK,FALSE},
1420             {"http",S_OK,FALSE},
1421             {"",S_FALSE,FALSE},
1422             {"",S_FALSE,FALSE}
1423         },
1424         {
1425             {Uri_HOST_DNS,S_OK,FALSE},
1426             {80,S_OK,FALSE},
1427             {URL_SCHEME_HTTP,S_OK,FALSE},
1428             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1429         }
1430     },
1431     /* IPv4 addresses attached to IPv6 can be included in elisions. */
1432     {   "http://[1:2:3:4:5:6:0.0.0.0]", 0, S_OK, FALSE,
1433         {
1434             {"http://[1:2:3:4:5:6::]/",S_OK,FALSE},
1435             {"[1:2:3:4:5:6::]",S_OK,FALSE},
1436             {"http://[1:2:3:4:5:6::]/",S_OK,FALSE},
1437             {"",S_FALSE,FALSE},
1438             {"",S_FALSE,FALSE},
1439             {"",S_FALSE,FALSE},
1440             {"1:2:3:4:5:6::",S_OK,FALSE},
1441             {"",S_FALSE,FALSE},
1442             {"/",S_OK,FALSE},
1443             {"/",S_OK,FALSE},
1444             {"",S_FALSE,FALSE},
1445             {"http://[1:2:3:4:5:6:0.0.0.0]",S_OK,FALSE},
1446             {"http",S_OK,FALSE},
1447             {"",S_FALSE,FALSE},
1448             {"",S_FALSE,FALSE},
1449         },
1450         {
1451             {Uri_HOST_IPV6,S_OK,FALSE},
1452             {80,S_OK,FALSE},
1453             {URL_SCHEME_HTTP,S_OK,FALSE},
1454             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1455         }
1456     },
1457     /* IPv4 addresses get normalized. */
1458     {   "http://[::001.002.003.000]", 0, S_OK, FALSE,
1459         {
1460             {"http://[::1.2.3.0]/",S_OK,FALSE},
1461             {"[::1.2.3.0]",S_OK,FALSE},
1462             {"http://[::1.2.3.0]/",S_OK,FALSE},
1463             {"",S_FALSE,FALSE},
1464             {"",S_FALSE,FALSE},
1465             {"",S_FALSE,FALSE},
1466             {"::1.2.3.0",S_OK,FALSE},
1467             {"",S_FALSE,FALSE},
1468             {"/",S_OK,FALSE},
1469             {"/",S_OK,FALSE},
1470             {"",S_FALSE,FALSE},
1471             {"http://[::001.002.003.000]",S_OK,FALSE},
1472             {"http",S_OK,FALSE},
1473             {"",S_FALSE,FALSE},
1474             {"",S_FALSE,FALSE},
1475         },
1476         {
1477             {Uri_HOST_IPV6,S_OK,FALSE},
1478             {80,S_OK,FALSE},
1479             {URL_SCHEME_HTTP,S_OK,FALSE},
1480             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1481         }
1482     },
1483     /* Windows doesn't do anything to IPv6's in unknown schemes. */
1484     {   "zip://[0001:0:000:0004:0005:0006:001.002.003.000]", 0, S_OK, FALSE,
1485         {
1486             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]/",S_OK,FALSE},
1487             {"[0001:0:000:0004:0005:0006:001.002.003.000]",S_OK,FALSE},
1488             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]/",S_OK,FALSE},
1489             {"",S_FALSE,FALSE},
1490             {"",S_FALSE,FALSE},
1491             {"",S_FALSE,FALSE},
1492             {"0001:0:000:0004:0005:0006:001.002.003.000",S_OK,FALSE},
1493             {"",S_FALSE,FALSE},
1494             {"/",S_OK,FALSE},
1495             {"/",S_OK,FALSE},
1496             {"",S_FALSE,FALSE},
1497             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]",S_OK,FALSE},
1498             {"zip",S_OK,FALSE},
1499             {"",S_FALSE,FALSE},
1500             {"",S_FALSE,FALSE},
1501         },
1502         {
1503             {Uri_HOST_IPV6,S_OK,FALSE},
1504             {0,S_FALSE,FALSE},
1505             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1506             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1507         }
1508     },
1509     /* IPv4 address is converted into 2 h16 components. */
1510     {   "http://[ffff::192.222.111.32]", 0, S_OK, FALSE,
1511         {
1512             {"http://[ffff::c0de:6f20]/",S_OK,FALSE},
1513             {"[ffff::c0de:6f20]",S_OK,FALSE},
1514             {"http://[ffff::c0de:6f20]/",S_OK,FALSE},
1515             {"",S_FALSE,FALSE},
1516             {"",S_FALSE,FALSE},
1517             {"",S_FALSE,FALSE},
1518             {"ffff::c0de:6f20",S_OK,FALSE},
1519             {"",S_FALSE,FALSE},
1520             {"/",S_OK,FALSE},
1521             {"/",S_OK,FALSE},
1522             {"",S_FALSE,FALSE},
1523             {"http://[ffff::192.222.111.32]",S_OK,FALSE},
1524             {"http",S_OK,FALSE},
1525             {"",S_FALSE,FALSE},
1526             {"",S_FALSE,FALSE},
1527         },
1528         {
1529             {Uri_HOST_IPV6,S_OK,FALSE},
1530             {80,S_OK,FALSE},
1531             {URL_SCHEME_HTTP,S_OK,FALSE},
1532             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1533         }
1534     },
1535     /* Max value for a port. */
1536     {   "http://google.com:65535", 0, S_OK, FALSE,
1537         {
1538             {"http://google.com:65535/",S_OK,FALSE},
1539             {"google.com:65535",S_OK,FALSE},
1540             {"http://google.com:65535/",S_OK,FALSE},
1541             {"google.com",S_OK,FALSE},
1542             {"",S_FALSE,FALSE},
1543             {"",S_FALSE,FALSE},
1544             {"google.com",S_OK,FALSE},
1545             {"",S_FALSE,FALSE},
1546             {"/",S_OK,FALSE},
1547             {"/",S_OK,FALSE},
1548             {"",S_FALSE,FALSE},
1549             {"http://google.com:65535",S_OK,FALSE},
1550             {"http",S_OK,FALSE},
1551             {"",S_FALSE,FALSE},
1552             {"",S_FALSE,FALSE}
1553         },
1554         {
1555             {Uri_HOST_DNS,S_OK,FALSE},
1556             {65535,S_OK,FALSE},
1557             {URL_SCHEME_HTTP,S_OK,FALSE},
1558             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1559         }
1560     },
1561     {   "zip://google.com:65536", 0, S_OK, FALSE,
1562         {
1563             {"zip://google.com:65536/",S_OK,FALSE},
1564             {"google.com:65536",S_OK,FALSE},
1565             {"zip://google.com:65536/",S_OK,FALSE},
1566             {"google.com:65536",S_OK,FALSE},
1567             {"",S_FALSE,FALSE},
1568             {"",S_FALSE,FALSE},
1569             {"google.com:65536",S_OK,FALSE},
1570             {"",S_FALSE,FALSE},
1571             {"/",S_OK,FALSE},
1572             {"/",S_OK,FALSE},
1573             {"",S_FALSE,FALSE},
1574             {"zip://google.com:65536",S_OK,FALSE},
1575             {"zip",S_OK,FALSE},
1576             {"",S_FALSE,FALSE},
1577             {"",S_FALSE,FALSE}
1578         },
1579         {
1580             {Uri_HOST_DNS,S_OK,FALSE},
1581             {0,S_FALSE,FALSE},
1582             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1583             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1584         }
1585     },
1586     {   "zip://google.com:65536:25", 0, S_OK, FALSE,
1587         {
1588             {"zip://google.com:65536:25/",S_OK,FALSE},
1589             {"google.com:65536:25",S_OK,FALSE},
1590             {"zip://google.com:65536:25/",S_OK,FALSE},
1591             {"google.com:65536:25",S_OK,FALSE},
1592             {"",S_FALSE,FALSE},
1593             {"",S_FALSE,FALSE},
1594             {"google.com:65536:25",S_OK,FALSE},
1595             {"",S_FALSE,FALSE},
1596             {"/",S_OK,FALSE},
1597             {"/",S_OK,FALSE},
1598             {"",S_FALSE,FALSE},
1599             {"zip://google.com:65536:25",S_OK,FALSE},
1600             {"zip",S_OK,FALSE},
1601             {"",S_FALSE,FALSE},
1602             {"",S_FALSE,FALSE}
1603         },
1604         {
1605             {Uri_HOST_DNS,S_OK,FALSE},
1606             {0,S_FALSE,FALSE},
1607             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1608             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1609         }
1610     },
1611     {   "zip://[::ffff]:abcd", 0, S_OK, FALSE,
1612         {
1613             {"zip://[::ffff]:abcd/",S_OK,FALSE},
1614             {"[::ffff]:abcd",S_OK,FALSE},
1615             {"zip://[::ffff]:abcd/",S_OK,FALSE},
1616             {"",S_FALSE,FALSE},
1617             {"",S_FALSE,FALSE},
1618             {"",S_FALSE,FALSE},
1619             {"[::ffff]:abcd",S_OK,FALSE},
1620             {"",S_FALSE,FALSE},
1621             {"/",S_OK,FALSE},
1622             {"/",S_OK,FALSE},
1623             {"",S_FALSE,FALSE},
1624             {"zip://[::ffff]:abcd",S_OK,FALSE},
1625             {"zip",S_OK,FALSE},
1626             {"",S_FALSE,FALSE},
1627             {"",S_FALSE,FALSE}
1628         },
1629         {
1630             {Uri_HOST_DNS,S_OK,FALSE},
1631             {0,S_FALSE,FALSE},
1632             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1633             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1634         }
1635     },
1636     {   "zip://127.0.0.1:abcd", 0, S_OK, FALSE,
1637         {
1638             {"zip://127.0.0.1:abcd/",S_OK,FALSE},
1639             {"127.0.0.1:abcd",S_OK,FALSE},
1640             {"zip://127.0.0.1:abcd/",S_OK,FALSE},
1641             {"0.1:abcd",S_OK,FALSE},
1642             {"",S_FALSE,FALSE},
1643             {"",S_FALSE,FALSE},
1644             {"127.0.0.1:abcd",S_OK,FALSE},
1645             {"",S_FALSE,FALSE},
1646             {"/",S_OK,FALSE},
1647             {"/",S_OK,FALSE},
1648             {"",S_FALSE,FALSE},
1649             {"zip://127.0.0.1:abcd",S_OK,FALSE},
1650             {"zip",S_OK,FALSE},
1651             {"",S_FALSE,FALSE},
1652             {"",S_FALSE,FALSE}
1653         },
1654         {
1655             {Uri_HOST_DNS,S_OK,FALSE},
1656             {0,S_FALSE,FALSE},
1657             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1658             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1659         }
1660     },
1661     /* Port is just copied over. */
1662     {   "http://google.com:00035", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
1663         {
1664             {"http://google.com:00035",S_OK,FALSE},
1665             {"google.com:00035",S_OK,FALSE},
1666             {"http://google.com:00035",S_OK,FALSE,"http://google.com:35"},
1667             {"google.com",S_OK,FALSE},
1668             {"",S_FALSE,FALSE},
1669             {"",S_FALSE,FALSE},
1670             {"google.com",S_OK,FALSE},
1671             {"",S_FALSE,FALSE},
1672             {"",S_FALSE,FALSE},
1673             {"",S_FALSE,FALSE},
1674             {"",S_FALSE,FALSE},
1675             {"http://google.com:00035",S_OK,FALSE},
1676             {"http",S_OK,FALSE},
1677             {"",S_FALSE,FALSE},
1678             {"",S_FALSE,FALSE}
1679         },
1680         {
1681             {Uri_HOST_DNS,S_OK,FALSE},
1682             {35,S_OK,FALSE},
1683             {URL_SCHEME_HTTP,S_OK,FALSE},
1684             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1685         }
1686     },
1687     /* Default port is copied over. */
1688     {   "http://google.com:80", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
1689         {
1690             {"http://google.com:80",S_OK,FALSE},
1691             {"google.com:80",S_OK,FALSE},
1692             {"http://google.com:80",S_OK,FALSE},
1693             {"google.com",S_OK,FALSE},
1694             {"",S_FALSE,FALSE},
1695             {"",S_FALSE,FALSE},
1696             {"google.com",S_OK,FALSE},
1697             {"",S_FALSE,FALSE},
1698             {"",S_FALSE,FALSE},
1699             {"",S_FALSE,FALSE},
1700             {"",S_FALSE,FALSE},
1701             {"http://google.com:80",S_OK,FALSE},
1702             {"http",S_OK,FALSE},
1703             {"",S_FALSE,FALSE},
1704             {"",S_FALSE,FALSE}
1705         },
1706         {
1707             {Uri_HOST_DNS,S_OK,FALSE},
1708             {80,S_OK,FALSE},
1709             {URL_SCHEME_HTTP,S_OK,FALSE},
1710             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1711         }
1712     },
1713     {   "http://google.com.uk", 0, S_OK, FALSE,
1714         {
1715             {"http://google.com.uk/",S_OK,FALSE},
1716             {"google.com.uk",S_OK,FALSE},
1717             {"http://google.com.uk/",S_OK,FALSE},
1718             {"google.com.uk",S_OK,FALSE},
1719             {"",S_FALSE,FALSE},
1720             {"",S_FALSE,FALSE},
1721             {"google.com.uk",S_OK,FALSE},
1722             {"",S_FALSE,FALSE},
1723             {"/",S_OK,FALSE},
1724             {"/",S_OK,FALSE},
1725             {"",S_FALSE,FALSE},
1726             {"http://google.com.uk",S_OK,FALSE},
1727             {"http",S_OK,FALSE},
1728             {"",S_FALSE,FALSE},
1729             {"",S_FALSE,FALSE}
1730         },
1731         {
1732             {Uri_HOST_DNS,S_OK,FALSE},
1733             {80,S_OK,FALSE},
1734             {URL_SCHEME_HTTP,S_OK,FALSE},
1735             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1736         }
1737     },
1738     {   "http://google.com.com", 0, S_OK, FALSE,
1739         {
1740             {"http://google.com.com/",S_OK,FALSE},
1741             {"google.com.com",S_OK,FALSE},
1742             {"http://google.com.com/",S_OK,FALSE},
1743             {"com.com",S_OK,FALSE},
1744             {"",S_FALSE,FALSE},
1745             {"",S_FALSE,FALSE},
1746             {"google.com.com",S_OK,FALSE},
1747             {"",S_FALSE,FALSE},
1748             {"/",S_OK,FALSE},
1749             {"/",S_OK,FALSE},
1750             {"",S_FALSE,FALSE},
1751             {"http://google.com.com",S_OK,FALSE},
1752             {"http",S_OK,FALSE},
1753             {"",S_FALSE,FALSE},
1754             {"",S_FALSE,FALSE}
1755         },
1756         {
1757             {Uri_HOST_DNS,S_OK,FALSE},
1758             {80,S_OK,FALSE},
1759             {URL_SCHEME_HTTP,S_OK,FALSE},
1760             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1761         }
1762     },
1763     {   "http://google.uk.1", 0, S_OK, FALSE,
1764         {
1765             {"http://google.uk.1/",S_OK,FALSE},
1766             {"google.uk.1",S_OK,FALSE},
1767             {"http://google.uk.1/",S_OK,FALSE},
1768             {"google.uk.1",S_OK,FALSE},
1769             {"",S_FALSE,FALSE},
1770             {"",S_FALSE,FALSE},
1771             {"google.uk.1",S_OK,FALSE},
1772             {"",S_FALSE,FALSE},
1773             {"/",S_OK,FALSE},
1774             {"/",S_OK,FALSE},
1775             {"",S_FALSE,FALSE},
1776             {"http://google.uk.1",S_OK,FALSE},
1777             {"http",S_OK,FALSE},
1778             {"",S_FALSE,FALSE},
1779             {"",S_FALSE,FALSE}
1780         },
1781         {
1782             {Uri_HOST_DNS,S_OK,FALSE},
1783             {80,S_OK,FALSE},
1784             {URL_SCHEME_HTTP,S_OK,FALSE},
1785             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1786         }
1787     },
1788     /* Since foo isn't a recognized 3 character TLD its considered the domain name. */
1789     {   "http://google.foo.uk", 0, S_OK, FALSE,
1790         {
1791             {"http://google.foo.uk/",S_OK,FALSE},
1792             {"google.foo.uk",S_OK,FALSE},
1793             {"http://google.foo.uk/",S_OK,FALSE},
1794             {"foo.uk",S_OK,FALSE},
1795             {"",S_FALSE,FALSE},
1796             {"",S_FALSE,FALSE},
1797             {"google.foo.uk",S_OK,FALSE},
1798             {"",S_FALSE,FALSE},
1799             {"/",S_OK,FALSE},
1800             {"/",S_OK,FALSE},
1801             {"",S_FALSE,FALSE},
1802             {"http://google.foo.uk",S_OK,FALSE},
1803             {"http",S_OK,FALSE},
1804             {"",S_FALSE,FALSE},
1805             {"",S_FALSE,FALSE}
1806         },
1807         {
1808             {Uri_HOST_DNS,S_OK,FALSE},
1809             {80,S_OK,FALSE},
1810             {URL_SCHEME_HTTP,S_OK,FALSE},
1811             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1812         }
1813     },
1814     {   "http://.com", 0, S_OK, FALSE,
1815         {
1816             {"http://.com/",S_OK,FALSE},
1817             {".com",S_OK,FALSE},
1818             {"http://.com/",S_OK,FALSE},
1819             {".com",S_OK,FALSE},
1820             {"",S_FALSE,FALSE},
1821             {"",S_FALSE,FALSE},
1822             {".com",S_OK,FALSE},
1823             {"",S_FALSE,FALSE},
1824             {"/",S_OK,FALSE},
1825             {"/",S_OK,FALSE},
1826             {"",S_FALSE,FALSE},
1827             {"http://.com",S_OK,FALSE},
1828             {"http",S_OK,FALSE},
1829             {"",S_FALSE,FALSE},
1830             {"",S_FALSE,FALSE}
1831         },
1832         {
1833             {Uri_HOST_DNS,S_OK,FALSE},
1834             {80,S_OK,FALSE},
1835             {URL_SCHEME_HTTP,S_OK,FALSE},
1836             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1837         }
1838     },
1839     {   "http://.uk", 0, S_OK, FALSE,
1840         {
1841             {"http://.uk/",S_OK,FALSE},
1842             {".uk",S_OK,FALSE},
1843             {"http://.uk/",S_OK,FALSE},
1844             {"",S_FALSE,FALSE},
1845             {"",S_FALSE,FALSE},
1846             {"",S_FALSE,FALSE},
1847             {".uk",S_OK,FALSE},
1848             {"",S_FALSE,FALSE},
1849             {"/",S_OK,FALSE},
1850             {"/",S_OK,FALSE},
1851             {"",S_FALSE,FALSE},
1852             {"http://.uk",S_OK,FALSE},
1853             {"http",S_OK,FALSE},
1854             {"",S_FALSE,FALSE},
1855             {"",S_FALSE,FALSE}
1856         },
1857         {
1858             {Uri_HOST_DNS,S_OK,FALSE},
1859             {80,S_OK,FALSE},
1860             {URL_SCHEME_HTTP,S_OK,FALSE},
1861             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1862         }
1863     },
1864     {   "http://www.co.google.com.[]", 0, S_OK, FALSE,
1865         {
1866             {"http://www.co.google.com.[]/",S_OK,FALSE},
1867             {"www.co.google.com.[]",S_OK,FALSE},
1868             {"http://www.co.google.com.[]/",S_OK,FALSE},
1869             {"google.com.[]",S_OK,FALSE},
1870             {"",S_FALSE,FALSE},
1871             {"",S_FALSE,FALSE},
1872             {"www.co.google.com.[]",S_OK,FALSE},
1873             {"",S_FALSE,FALSE},
1874             {"/",S_OK,FALSE},
1875             {"/",S_OK,FALSE},
1876             {"",S_FALSE,FALSE},
1877             {"http://www.co.google.com.[]",S_OK,FALSE},
1878             {"http",S_OK,FALSE},
1879             {"",S_FALSE,FALSE},
1880             {"",S_FALSE,FALSE}
1881         },
1882         {
1883             {Uri_HOST_DNS,S_OK,FALSE},
1884             {80,S_OK,FALSE},
1885             {URL_SCHEME_HTTP,S_OK,FALSE},
1886             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1887         }
1888     },
1889     {   "http://co.uk", 0, S_OK, FALSE,
1890         {
1891             {"http://co.uk/",S_OK,FALSE},
1892             {"co.uk",S_OK,FALSE},
1893             {"http://co.uk/",S_OK,FALSE},
1894             {"",S_FALSE,FALSE},
1895             {"",S_FALSE,FALSE},
1896             {"",S_FALSE,FALSE},
1897             {"co.uk",S_OK,FALSE},
1898             {"",S_FALSE,FALSE},
1899             {"/",S_OK,FALSE},
1900             {"/",S_OK,FALSE},
1901             {"",S_FALSE,FALSE},
1902             {"http://co.uk",S_OK,FALSE},
1903             {"http",S_OK,FALSE},
1904             {"",S_FALSE,FALSE},
1905             {"",S_FALSE,FALSE}
1906         },
1907         {
1908             {Uri_HOST_DNS,S_OK,FALSE},
1909             {80,S_OK,FALSE},
1910             {URL_SCHEME_HTTP,S_OK,FALSE},
1911             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1912         }
1913     },
1914     {   "http://www.co.google.us.test", 0, S_OK, FALSE,
1915         {
1916             {"http://www.co.google.us.test/",S_OK,FALSE},
1917             {"www.co.google.us.test",S_OK,FALSE},
1918             {"http://www.co.google.us.test/",S_OK,FALSE},
1919             {"us.test",S_OK,FALSE},
1920             {"",S_FALSE,FALSE},
1921             {"",S_FALSE,FALSE},
1922             {"www.co.google.us.test",S_OK,FALSE},
1923             {"",S_FALSE,FALSE},
1924             {"/",S_OK,FALSE},
1925             {"/",S_OK,FALSE},
1926             {"",S_FALSE,FALSE},
1927             {"http://www.co.google.us.test",S_OK,FALSE},
1928             {"http",S_OK,FALSE},
1929             {"",S_FALSE,FALSE},
1930             {"",S_FALSE,FALSE}
1931         },
1932         {
1933             {Uri_HOST_DNS,S_OK,FALSE},
1934             {80,S_OK,FALSE},
1935             {URL_SCHEME_HTTP,S_OK,FALSE},
1936             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1937         }
1938     },
1939     {   "http://gov.uk", 0, S_OK, FALSE,
1940         {
1941             {"http://gov.uk/",S_OK,FALSE},
1942             {"gov.uk",S_OK,FALSE},
1943             {"http://gov.uk/",S_OK,FALSE},
1944             {"",S_FALSE,FALSE},
1945             {"",S_FALSE,FALSE},
1946             {"",S_FALSE,FALSE},
1947             {"gov.uk",S_OK,FALSE},
1948             {"",S_FALSE,FALSE},
1949             {"/",S_OK,FALSE},
1950             {"/",S_OK,FALSE},
1951             {"",S_FALSE,FALSE},
1952             {"http://gov.uk",S_OK,FALSE},
1953             {"http",S_OK,FALSE},
1954             {"",S_FALSE,FALSE},
1955             {"",S_FALSE,FALSE}
1956         },
1957         {
1958             {Uri_HOST_DNS,S_OK,FALSE},
1959             {80,S_OK,FALSE},
1960             {URL_SCHEME_HTTP,S_OK,FALSE},
1961             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1962         }
1963     },
1964     {   "zip://www.google.com\\test", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
1965         {
1966             {"zip://www.google.com\\test",S_OK,FALSE},
1967             {"www.google.com\\test",S_OK,FALSE},
1968             {"zip://www.google.com\\test",S_OK,FALSE},
1969             {"google.com\\test",S_OK,FALSE},
1970             {"",S_FALSE,FALSE},
1971             {"",S_FALSE,FALSE},
1972             {"www.google.com\\test",S_OK,FALSE},
1973             {"",S_FALSE,FALSE},
1974             {"",S_FALSE,FALSE},
1975             {"",S_FALSE,FALSE},
1976             {"",S_FALSE,FALSE},
1977             {"zip://www.google.com\\test",S_OK,FALSE},
1978             {"zip",S_OK,FALSE},
1979             {"",S_FALSE,FALSE},
1980             {"",S_FALSE,FALSE}
1981         },
1982         {
1983             {Uri_HOST_DNS,S_OK,FALSE},
1984             {0,S_FALSE,FALSE},
1985             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1986             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1987         }
1988     },
1989     {   "urn:excepts:bad:%XY:encoded", 0, S_OK, FALSE,
1990         {
1991             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
1992             {"",S_FALSE,FALSE},
1993             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
1994             {"",S_FALSE,FALSE},
1995             {"",S_FALSE,FALSE},
1996             {"",S_FALSE,FALSE},
1997             {"",S_FALSE,FALSE},
1998             {"",S_FALSE,FALSE},
1999             {"excepts:bad:%XY:encoded",S_OK,FALSE},
2000             {"excepts:bad:%XY:encoded",S_OK,FALSE},
2001             {"",S_FALSE,FALSE},
2002             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
2003             {"urn",S_OK,FALSE},
2004             {"",S_FALSE,FALSE},
2005             {"",S_FALSE,FALSE}
2006         },
2007         {
2008             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2009             {0,S_FALSE,FALSE},
2010             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2011             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2012         }
2013     },
2014     /* Since the original URI doesn't contain an extra '/' before the path no % encoded values
2015      * are decoded and all '%' are encoded.
2016      */
2017     {   "file://C:/te%3Es%2Et/tes%t.mp3", 0, S_OK, FALSE,
2018         {
2019             {"file:///C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2020             {"",S_FALSE,FALSE},
2021             {"file:///C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2022             {"",S_FALSE,FALSE},
2023             {".mp3",S_OK,FALSE},
2024             {"",S_FALSE,FALSE},
2025             {"",S_FALSE,FALSE},
2026             {"",S_FALSE,FALSE},
2027             {"/C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2028             {"/C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2029             {"",S_FALSE,FALSE},
2030             {"file://C:/te%3Es%2Et/tes%t.mp3",S_OK,FALSE},
2031             {"file",S_OK,FALSE},
2032             {"",S_FALSE,FALSE},
2033             {"",S_FALSE,FALSE}
2034         },
2035         {
2036             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2037             {0,S_FALSE,FALSE},
2038             {URL_SCHEME_FILE,S_OK,FALSE},
2039             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2040         }
2041     },
2042     /* Since there's a '/' in front of the drive letter, any percent encoded, non-forbidden character
2043      * is decoded and only %'s in front of invalid hex digits are encoded.
2044      */
2045     {   "file:///C:/te%3Es%2Et/t%23es%t.mp3", 0, S_OK, FALSE,
2046         {
2047             {"file:///C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2048             {"",S_FALSE,FALSE},
2049             {"file:///C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2050             {"",S_FALSE,FALSE},
2051             {".mp3",S_OK,FALSE},
2052             {"",S_FALSE,FALSE},
2053             {"",S_FALSE,FALSE},
2054             {"",S_FALSE,FALSE},
2055             {"/C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2056             {"/C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2057             {"",S_FALSE,FALSE},
2058             {"file:///C:/te%3Es%2Et/t%23es%t.mp3",S_OK,FALSE},
2059             {"file",S_OK,FALSE},
2060             {"",S_FALSE,FALSE},
2061             {"",S_FALSE,FALSE}
2062         },
2063         {
2064             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2065             {0,S_FALSE,FALSE},
2066             {URL_SCHEME_FILE,S_OK,FALSE},
2067             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2068         }
2069     },
2070     /* Only unreserved percent encoded characters are decoded for known schemes that aren't file. */
2071     {   "http://[::001.002.003.000]/%3F%23%2E%54/test", 0, S_OK, FALSE,
2072         {
2073             {"http://[::1.2.3.0]/%3F%23.T/test",S_OK,FALSE},
2074             {"[::1.2.3.0]",S_OK,FALSE},
2075             {"http://[::1.2.3.0]/%3F%23.T/test",S_OK,FALSE},
2076             {"",S_FALSE,FALSE},
2077             {"",S_FALSE,FALSE},
2078             {"",S_FALSE,FALSE},
2079             {"::1.2.3.0",S_OK,FALSE},
2080             {"",S_FALSE,FALSE},
2081             {"/%3F%23.T/test",S_OK,FALSE},
2082             {"/%3F%23.T/test",S_OK,FALSE},
2083             {"",S_FALSE,FALSE},
2084             {"http://[::001.002.003.000]/%3F%23%2E%54/test",S_OK,FALSE},
2085             {"http",S_OK,FALSE},
2086             {"",S_FALSE,FALSE},
2087             {"",S_FALSE,FALSE},
2088         },
2089         {
2090             {Uri_HOST_IPV6,S_OK,FALSE},
2091             {80,S_OK,FALSE},
2092             {URL_SCHEME_HTTP,S_OK,FALSE},
2093             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2094         }
2095     },
2096     /* Forbidden characters are always encoded for file URIs. */
2097     {   "file:///C:/\"test\"/test.mp3", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2098         {
2099             {"file:///C:/%22test%22/test.mp3",S_OK,FALSE},
2100             {"",S_FALSE,FALSE},
2101             {"file:///C:/%22test%22/test.mp3",S_OK,FALSE},
2102             {"",S_FALSE,FALSE},
2103             {".mp3",S_OK,FALSE},
2104             {"",S_FALSE,FALSE},
2105             {"",S_FALSE,FALSE},
2106             {"",S_FALSE,FALSE},
2107             {"/C:/%22test%22/test.mp3",S_OK,FALSE},
2108             {"/C:/%22test%22/test.mp3",S_OK,FALSE},
2109             {"",S_FALSE,FALSE},
2110             {"file:///C:/\"test\"/test.mp3",S_OK,FALSE},
2111             {"file",S_OK,FALSE},
2112             {"",S_FALSE,FALSE},
2113             {"",S_FALSE,FALSE}
2114         },
2115         {
2116             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2117             {0,S_FALSE,FALSE},
2118             {URL_SCHEME_FILE,S_OK,FALSE},
2119             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2120         }
2121     },
2122     /* Forbidden characters are never encoded for unknown scheme types. */
2123     {   "1234://4294967295/<|>\" test<|>", 0, S_OK, FALSE,
2124         {
2125             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2126             {"4294967295",S_OK,FALSE},
2127             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2128             {"",S_FALSE,FALSE},
2129             {"",S_FALSE,FALSE},
2130             {"",S_FALSE,FALSE},
2131             {"4294967295",S_OK,FALSE},
2132             {"",S_FALSE,FALSE},
2133             {"/<|>\" test<|>",S_OK,FALSE},
2134             {"/<|>\" test<|>",S_OK,FALSE},
2135             {"",S_FALSE,FALSE},
2136             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2137             {"1234",S_OK,FALSE},
2138             {"",S_FALSE,FALSE},
2139             {"",S_FALSE,FALSE}
2140         },
2141         {
2142             {Uri_HOST_IPV4,S_OK,FALSE},
2143             {0,S_FALSE,FALSE},
2144             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2145             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2146         }
2147     },
2148     /* Make sure forbidden characters are percent encoded. */
2149     {   "http://gov.uk/<|> test<|>", 0, S_OK, FALSE,
2150         {
2151             {"http://gov.uk/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2152             {"gov.uk",S_OK,FALSE},
2153             {"http://gov.uk/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2154             {"",S_FALSE,FALSE},
2155             {"",S_FALSE,FALSE},
2156             {"",S_FALSE,FALSE},
2157             {"gov.uk",S_OK,FALSE},
2158             {"",S_FALSE,FALSE},
2159             {"/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2160             {"/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2161             {"",S_FALSE,FALSE},
2162             {"http://gov.uk/<|> test<|>",S_OK,FALSE},
2163             {"http",S_OK,FALSE},
2164             {"",S_FALSE,FALSE},
2165             {"",S_FALSE,FALSE}
2166         },
2167         {
2168             {Uri_HOST_DNS,S_OK,FALSE},
2169             {80,S_OK,FALSE},
2170             {URL_SCHEME_HTTP,S_OK,FALSE},
2171             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2172         }
2173     },
2174     {   "http://gov.uk/test/../test2/././../test3/.././././", 0, S_OK, FALSE,
2175         {
2176             {"http://gov.uk/",S_OK,FALSE},
2177             {"gov.uk",S_OK,FALSE},
2178             {"http://gov.uk/",S_OK,FALSE},
2179             {"",S_FALSE,FALSE},
2180             {"",S_FALSE,FALSE},
2181             {"",S_FALSE,FALSE},
2182             {"gov.uk",S_OK,FALSE},
2183             {"",S_FALSE,FALSE},
2184             {"/",S_OK,FALSE},
2185             {"/",S_OK,FALSE},
2186             {"",S_FALSE,FALSE},
2187             {"http://gov.uk/test/../test2/././../test3/.././././",S_OK,FALSE},
2188             {"http",S_OK,FALSE},
2189             {"",S_FALSE,FALSE},
2190             {"",S_FALSE,FALSE}
2191         },
2192         {
2193             {Uri_HOST_DNS,S_OK,FALSE},
2194             {80,S_OK,FALSE},
2195             {URL_SCHEME_HTTP,S_OK,FALSE},
2196             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2197         }
2198     },
2199     {   "http://gov.uk/test/test2/../../..", 0, S_OK, FALSE,
2200         {
2201             {"http://gov.uk/",S_OK,FALSE},
2202             {"gov.uk",S_OK,FALSE},
2203             {"http://gov.uk/",S_OK,FALSE},
2204             {"",S_FALSE,FALSE},
2205             {"",S_FALSE,FALSE},
2206             {"",S_FALSE,FALSE},
2207             {"gov.uk",S_OK,FALSE},
2208             {"",S_FALSE,FALSE},
2209             {"/",S_OK,FALSE},
2210             {"/",S_OK,FALSE},
2211             {"",S_FALSE,FALSE},
2212             {"http://gov.uk/test/test2/../../..",S_OK,FALSE},
2213             {"http",S_OK,FALSE},
2214             {"",S_FALSE,FALSE},
2215             {"",S_FALSE,FALSE}
2216         },
2217         {
2218             {Uri_HOST_DNS,S_OK,FALSE},
2219             {80,S_OK,FALSE},
2220             {URL_SCHEME_HTTP,S_OK,FALSE},
2221             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2222         }
2223     },
2224     {   "http://gov.uk/test/test2/../../.", 0, S_OK, FALSE,
2225         {
2226             {"http://gov.uk/",S_OK,FALSE},
2227             {"gov.uk",S_OK,FALSE},
2228             {"http://gov.uk/",S_OK,FALSE},
2229             {"",S_FALSE,FALSE},
2230             {"",S_FALSE,FALSE},
2231             {"",S_FALSE,FALSE},
2232             {"gov.uk",S_OK,FALSE},
2233             {"",S_FALSE,FALSE},
2234             {"/",S_OK,FALSE},
2235             {"/",S_OK,FALSE},
2236             {"",S_FALSE,FALSE},
2237             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2238             {"http",S_OK,FALSE},
2239             {"",S_FALSE,FALSE},
2240             {"",S_FALSE,FALSE}
2241         },
2242         {
2243             {Uri_HOST_DNS,S_OK,FALSE},
2244             {80,S_OK,FALSE},
2245             {URL_SCHEME_HTTP,S_OK,FALSE},
2246             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2247         }
2248     },
2249     {   "file://c:\\tests\\../tests\\./.\\..\\foo%20bar.mp3", 0, S_OK, FALSE,
2250         {
2251             {"file:///c:/foo%2520bar.mp3",S_OK,FALSE},
2252             {"",S_FALSE,FALSE},
2253             {"file:///c:/foo%2520bar.mp3",S_OK,FALSE},
2254             {"",S_FALSE,FALSE},
2255             {".mp3",S_OK,FALSE},
2256             {"",S_FALSE,FALSE},
2257             {"",S_FALSE,FALSE},
2258             {"",S_FALSE,FALSE},
2259             {"/c:/foo%2520bar.mp3",S_OK,FALSE},
2260             {"/c:/foo%2520bar.mp3",S_OK,FALSE},
2261             {"",S_FALSE,FALSE},
2262             {"file://c:\\tests\\../tests\\./.\\..\\foo%20bar.mp3",S_OK,FALSE},
2263             {"file",S_OK,FALSE},
2264             {"",S_FALSE,FALSE},
2265             {"",S_FALSE,FALSE}
2266         },
2267         {
2268             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2269             {0,S_FALSE,FALSE},
2270             {URL_SCHEME_FILE,S_OK,FALSE},
2271             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2272         }
2273     },
2274     /* Dot removal happens for unknown scheme types. */
2275     {   "zip://gov.uk/test/test2/../../.", 0, S_OK, FALSE,
2276         {
2277             {"zip://gov.uk/",S_OK,FALSE},
2278             {"gov.uk",S_OK,FALSE},
2279             {"zip://gov.uk/",S_OK,FALSE},
2280             {"",S_FALSE,FALSE},
2281             {"",S_FALSE,FALSE},
2282             {"",S_FALSE,FALSE},
2283             {"gov.uk",S_OK,FALSE},
2284             {"",S_FALSE,FALSE},
2285             {"/",S_OK,FALSE},
2286             {"/",S_OK,FALSE},
2287             {"",S_FALSE,FALSE},
2288             {"zip://gov.uk/test/test2/../../.",S_OK,FALSE},
2289             {"zip",S_OK,FALSE},
2290             {"",S_FALSE,FALSE},
2291             {"",S_FALSE,FALSE}
2292         },
2293         {
2294             {Uri_HOST_DNS,S_OK,FALSE},
2295             {0,S_FALSE,FALSE},
2296             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2297             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2298         }
2299     },
2300     /* Dot removal doesn't happen if NO_CANONICALIZE is set. */
2301     {   "http://gov.uk/test/test2/../../.", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2302         {
2303             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2304             {"gov.uk",S_OK,FALSE},
2305             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2306             {"",S_FALSE,FALSE},
2307             {".",S_OK,FALSE},
2308             {"",S_FALSE,FALSE},
2309             {"gov.uk",S_OK,FALSE},
2310             {"",S_FALSE,FALSE},
2311             {"/test/test2/../../.",S_OK,FALSE},
2312             {"/test/test2/../../.",S_OK,FALSE},
2313             {"",S_FALSE,FALSE},
2314             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2315             {"http",S_OK,FALSE},
2316             {"",S_FALSE,FALSE},
2317             {"",S_FALSE,FALSE}
2318         },
2319         {
2320             {Uri_HOST_DNS,S_OK,FALSE},
2321             {80,S_OK,FALSE},
2322             {URL_SCHEME_HTTP,S_OK,FALSE},
2323             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2324         }
2325     },
2326     /* Dot removal doesn't happen for wildcard scheme types. */
2327     {   "*:gov.uk/test/test2/../../.", 0, S_OK, FALSE,
2328         {
2329             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2330             {"gov.uk",S_OK,FALSE},
2331             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2332             {"",S_FALSE,FALSE},
2333             {".",S_OK,FALSE},
2334             {"",S_FALSE,FALSE},
2335             {"gov.uk",S_OK,FALSE},
2336             {"",S_FALSE,FALSE},
2337             {"/test/test2/../../.",S_OK,FALSE},
2338             {"/test/test2/../../.",S_OK,FALSE},
2339             {"",S_FALSE,FALSE},
2340             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2341             {"*",S_OK,FALSE},
2342             {"",S_FALSE,FALSE},
2343             {"",S_FALSE,FALSE}
2344         },
2345         {
2346             {Uri_HOST_DNS,S_OK,FALSE},
2347             {0,S_FALSE,FALSE},
2348             {URL_SCHEME_WILDCARD,S_OK,FALSE},
2349             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2350         }
2351     },
2352     /* Forbidden characters are encoded for opaque known scheme types. */
2353     {   "mailto:\"acco<|>unt@example.com\"", 0, S_OK, FALSE,
2354         {
2355             {"mailto:%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2356             {"",S_FALSE,FALSE},
2357             {"mailto:%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2358             {"",S_FALSE,FALSE},
2359             {".com%22",S_OK,FALSE},
2360             {"",S_FALSE,FALSE},
2361             {"",S_FALSE,FALSE},
2362             {"",S_FALSE,FALSE},
2363             {"%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2364             {"%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2365             {"",S_FALSE,FALSE},
2366             {"mailto:\"acco<|>unt@example.com\"",S_OK,FALSE},
2367             {"mailto",S_OK,FALSE},
2368             {"",S_FALSE,FALSE},
2369             {"",S_FALSE,FALSE}
2370         },
2371         {
2372             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2373             {0,S_FALSE,FALSE},
2374             {URL_SCHEME_MAILTO,S_OK,FALSE},
2375             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2376         }
2377     },
2378     {   "news:test.tes<|>t.com", 0, S_OK, FALSE,
2379         {
2380             {"news:test.tes%3C%7C%3Et.com",S_OK,FALSE},
2381             {"",S_FALSE,FALSE},
2382             {"news:test.tes%3C%7C%3Et.com",S_OK,FALSE},
2383             {"",S_FALSE,FALSE},
2384             {".com",S_OK,FALSE},
2385             {"",S_FALSE,FALSE},
2386             {"",S_FALSE,FALSE},
2387             {"",S_FALSE,FALSE},
2388             {"test.tes%3C%7C%3Et.com",S_OK,FALSE},
2389             {"test.tes%3C%7C%3Et.com",S_OK,FALSE},
2390             {"",S_FALSE,FALSE},
2391             {"news:test.tes<|>t.com",S_OK,FALSE},
2392             {"news",S_OK,FALSE},
2393             {"",S_FALSE,FALSE},
2394             {"",S_FALSE,FALSE}
2395         },
2396         {
2397             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2398             {0,S_FALSE,FALSE},
2399             {URL_SCHEME_NEWS,S_OK,FALSE},
2400             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2401         }
2402     },
2403     /* Don't encode forbidden characters. */
2404     {   "news:test.tes<|>t.com", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2405         {
2406             {"news:test.tes<|>t.com",S_OK,FALSE},
2407             {"",S_FALSE,FALSE},
2408             {"news:test.tes<|>t.com",S_OK,FALSE},
2409             {"",S_FALSE,FALSE},
2410             {".com",S_OK,FALSE},
2411             {"",S_FALSE,FALSE},
2412             {"",S_FALSE,FALSE},
2413             {"",S_FALSE,FALSE},
2414             {"test.tes<|>t.com",S_OK,FALSE},
2415             {"test.tes<|>t.com",S_OK,FALSE},
2416             {"",S_FALSE,FALSE},
2417             {"news:test.tes<|>t.com",S_OK,FALSE},
2418             {"news",S_OK,FALSE},
2419             {"",S_FALSE,FALSE},
2420             {"",S_FALSE,FALSE}
2421         },
2422         {
2423             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2424             {0,S_FALSE,FALSE},
2425             {URL_SCHEME_NEWS,S_OK,FALSE},
2426             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2427         }
2428     },
2429     /* Forbidden characters aren't encoded for unknown, opaque URIs. */
2430     {   "urn:test.tes<|>t.com", 0, S_OK, FALSE,
2431         {
2432             {"urn:test.tes<|>t.com",S_OK,FALSE},
2433             {"",S_FALSE,FALSE},
2434             {"urn:test.tes<|>t.com",S_OK,FALSE},
2435             {"",S_FALSE,FALSE},
2436             {".com",S_OK,FALSE},
2437             {"",S_FALSE,FALSE},
2438             {"",S_FALSE,FALSE},
2439             {"",S_FALSE,FALSE},
2440             {"test.tes<|>t.com",S_OK,FALSE},
2441             {"test.tes<|>t.com",S_OK,FALSE},
2442             {"",S_FALSE,FALSE},
2443             {"urn:test.tes<|>t.com",S_OK,FALSE},
2444             {"urn",S_OK,FALSE},
2445             {"",S_FALSE,FALSE},
2446             {"",S_FALSE,FALSE}
2447         },
2448         {
2449             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2450             {0,S_FALSE,FALSE},
2451             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2452             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2453         }
2454     },
2455     /* Percent encoded unreserved characters are decoded for known opaque URIs. */
2456     {   "news:test.%74%65%73%74.com", 0, S_OK, FALSE,
2457         {
2458             {"news:test.test.com",S_OK,FALSE},
2459             {"",S_FALSE,FALSE},
2460             {"news:test.test.com",S_OK,FALSE},
2461             {"",S_FALSE,FALSE},
2462             {".com",S_OK,FALSE},
2463             {"",S_FALSE,FALSE},
2464             {"",S_FALSE,FALSE},
2465             {"",S_FALSE,FALSE},
2466             {"test.test.com",S_OK,FALSE},
2467             {"test.test.com",S_OK,FALSE},
2468             {"",S_FALSE,FALSE},
2469             {"news:test.%74%65%73%74.com",S_OK,FALSE},
2470             {"news",S_OK,FALSE},
2471             {"",S_FALSE,FALSE},
2472             {"",S_FALSE,FALSE}
2473         },
2474         {
2475             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2476             {0,S_FALSE,FALSE},
2477             {URL_SCHEME_NEWS,S_OK,FALSE},
2478             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2479         }
2480     },
2481     /* Percent encoded characters are still decoded for known scheme types. */
2482     {   "news:test.%74%65%73%74.com", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2483         {
2484             {"news:test.test.com",S_OK,FALSE},
2485             {"",S_FALSE,FALSE},
2486             {"news:test.test.com",S_OK,FALSE},
2487             {"",S_FALSE,FALSE},
2488             {".com",S_OK,FALSE},
2489             {"",S_FALSE,FALSE},
2490             {"",S_FALSE,FALSE},
2491             {"",S_FALSE,FALSE},
2492             {"test.test.com",S_OK,FALSE},
2493             {"test.test.com",S_OK,FALSE},
2494             {"",S_FALSE,FALSE},
2495             {"news:test.%74%65%73%74.com",S_OK,FALSE},
2496             {"news",S_OK,FALSE},
2497             {"",S_FALSE,FALSE},
2498             {"",S_FALSE,FALSE}
2499         },
2500         {
2501             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2502             {0,S_FALSE,FALSE},
2503             {URL_SCHEME_NEWS,S_OK,FALSE},
2504             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2505         }
2506     },
2507     /* Percent encoded characters aren't decoded for unknown scheme types. */
2508     {   "urn:test.%74%65%73%74.com", 0, S_OK, FALSE,
2509         {
2510             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2511             {"",S_FALSE,FALSE},
2512             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2513             {"",S_FALSE,FALSE},
2514             {".com",S_OK,FALSE},
2515             {"",S_FALSE,FALSE},
2516             {"",S_FALSE,FALSE},
2517             {"",S_FALSE,FALSE},
2518             {"test.%74%65%73%74.com",S_OK,FALSE},
2519             {"test.%74%65%73%74.com",S_OK,FALSE},
2520             {"",S_FALSE,FALSE},
2521             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2522             {"urn",S_OK,FALSE},
2523             {"",S_FALSE,FALSE},
2524             {"",S_FALSE,FALSE}
2525         },
2526         {
2527             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2528             {0,S_FALSE,FALSE},
2529             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2530             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2531         }
2532     },
2533     /* Unknown scheme types can have invalid % encoded data in query string. */
2534     {   "zip://www.winehq.org/tests/..?query=%xx&return=y", 0, S_OK, FALSE,
2535         {
2536             {"zip://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2537             {"www.winehq.org",S_OK,FALSE},
2538             {"zip://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2539             {"winehq.org",S_OK,FALSE},
2540             {"",S_FALSE,FALSE},
2541             {"",S_FALSE,FALSE},
2542             {"www.winehq.org",S_OK,FALSE},
2543             {"",S_FALSE,FALSE},
2544             {"/",S_OK,FALSE},
2545             {"/?query=%xx&return=y",S_OK,FALSE},
2546             {"?query=%xx&return=y",S_OK,FALSE},
2547             {"zip://www.winehq.org/tests/..?query=%xx&return=y",S_OK,FALSE},
2548             {"zip",S_OK,FALSE},
2549             {"",S_FALSE,FALSE},
2550             {"",S_FALSE,FALSE}
2551         },
2552         {
2553             {Uri_HOST_DNS,S_OK,FALSE},
2554             {0,S_FALSE,FALSE},
2555             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2556             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2557         }
2558     },
2559     /* Known scheme types can have invalid % encoded data with the right flags. */
2560     {   "http://www.winehq.org/tests/..?query=%xx&return=y", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2561         {
2562             {"http://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2563             {"www.winehq.org",S_OK,FALSE},
2564             {"http://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2565             {"winehq.org",S_OK,FALSE},
2566             {"",S_FALSE,FALSE},
2567             {"",S_FALSE,FALSE},
2568             {"www.winehq.org",S_OK,FALSE},
2569             {"",S_FALSE,FALSE},
2570             {"/",S_OK,FALSE},
2571             {"/?query=%xx&return=y",S_OK,FALSE},
2572             {"?query=%xx&return=y",S_OK,FALSE},
2573             {"http://www.winehq.org/tests/..?query=%xx&return=y",S_OK,FALSE},
2574             {"http",S_OK,FALSE},
2575             {"",S_FALSE,FALSE},
2576             {"",S_FALSE,FALSE}
2577         },
2578         {
2579             {Uri_HOST_DNS,S_OK,FALSE},
2580             {80,S_OK,FALSE},
2581             {URL_SCHEME_HTTP,S_OK,FALSE},
2582             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2583         }
2584     },
2585     /* Forbidden characters in query aren't percent encoded for known scheme types with this flag. */
2586     {   "http://www.winehq.org/tests/..?query=<|>&return=y", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2587         {
2588             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2589             {"www.winehq.org",S_OK,FALSE},
2590             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2591             {"winehq.org",S_OK,FALSE},
2592             {"",S_FALSE,FALSE},
2593             {"",S_FALSE,FALSE},
2594             {"www.winehq.org",S_OK,FALSE},
2595             {"",S_FALSE,FALSE},
2596             {"/",S_OK,FALSE},
2597             {"/?query=<|>&return=y",S_OK,FALSE},
2598             {"?query=<|>&return=y",S_OK,FALSE},
2599             {"http://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2600             {"http",S_OK,FALSE},
2601             {"",S_FALSE,FALSE},
2602             {"",S_FALSE,FALSE}
2603         },
2604         {
2605             {Uri_HOST_DNS,S_OK,FALSE},
2606             {80,S_OK,FALSE},
2607             {URL_SCHEME_HTTP,S_OK,FALSE},
2608             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2609         }
2610     },
2611     /* Forbidden characters in query aren't percent encoded for known scheme types with this flag. */
2612     {   "http://www.winehq.org/tests/..?query=<|>&return=y", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2613         {
2614             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2615             {"www.winehq.org",S_OK,FALSE},
2616             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2617             {"winehq.org",S_OK,FALSE},
2618             {"",S_FALSE,FALSE},
2619             {"",S_FALSE,FALSE},
2620             {"www.winehq.org",S_OK,FALSE},
2621             {"",S_FALSE,FALSE},
2622             {"/",S_OK,FALSE},
2623             {"/?query=<|>&return=y",S_OK,FALSE},
2624             {"?query=<|>&return=y",S_OK,FALSE},
2625             {"http://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2626             {"http",S_OK,FALSE},
2627             {"",S_FALSE,FALSE},
2628             {"",S_FALSE,FALSE}
2629         },
2630         {
2631             {Uri_HOST_DNS,S_OK,FALSE},
2632             {80,S_OK,FALSE},
2633             {URL_SCHEME_HTTP,S_OK,FALSE},
2634             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2635         }
2636     },
2637     /* Forbidden characters are encoded for known scheme types. */
2638     {   "http://www.winehq.org/tests/..?query=<|>&return=y", 0, S_OK, FALSE,
2639         {
2640             {"http://www.winehq.org/?query=%3C%7C%3E&return=y",S_OK,FALSE},
2641             {"www.winehq.org",S_OK,FALSE},
2642             {"http://www.winehq.org/?query=%3C%7C%3E&return=y",S_OK,FALSE},
2643             {"winehq.org",S_OK,FALSE},
2644             {"",S_FALSE,FALSE},
2645             {"",S_FALSE,FALSE},
2646             {"www.winehq.org",S_OK,FALSE},
2647             {"",S_FALSE,FALSE},
2648             {"/",S_OK,FALSE},
2649             {"/?query=%3C%7C%3E&return=y",S_OK,FALSE},
2650             {"?query=%3C%7C%3E&return=y",S_OK,FALSE},
2651             {"http://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2652             {"http",S_OK,FALSE},
2653             {"",S_FALSE,FALSE},
2654             {"",S_FALSE,FALSE}
2655         },
2656         {
2657             {Uri_HOST_DNS,S_OK,FALSE},
2658             {80,S_OK,FALSE},
2659             {URL_SCHEME_HTTP,S_OK,FALSE},
2660             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2661         }
2662     },
2663     /* Forbidden characters are not encoded for unknown scheme types. */
2664     {   "zip://www.winehq.org/tests/..?query=<|>&return=y", 0, S_OK, FALSE,
2665         {
2666             {"zip://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2667             {"www.winehq.org",S_OK,FALSE},
2668             {"zip://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2669             {"winehq.org",S_OK,FALSE},
2670             {"",S_FALSE,FALSE},
2671             {"",S_FALSE,FALSE},
2672             {"www.winehq.org",S_OK,FALSE},
2673             {"",S_FALSE,FALSE},
2674             {"/",S_OK,FALSE},
2675             {"/?query=<|>&return=y",S_OK,FALSE},
2676             {"?query=<|>&return=y",S_OK,FALSE},
2677             {"zip://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2678             {"zip",S_OK,FALSE},
2679             {"",S_FALSE,FALSE},
2680             {"",S_FALSE,FALSE}
2681         },
2682         {
2683             {Uri_HOST_DNS,S_OK,FALSE},
2684             {0,S_FALSE,FALSE},
2685             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2686             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2687         }
2688     },
2689     /* Percent encoded, unreserved characters are decoded for known scheme types. */
2690     {   "http://www.winehq.org/tests/..?query=%30%31&return=y", 0, S_OK, FALSE,
2691         {
2692             {"http://www.winehq.org/?query=01&return=y",S_OK,FALSE},
2693             {"www.winehq.org",S_OK,FALSE},
2694             {"http://www.winehq.org/?query=01&return=y",S_OK,FALSE},
2695             {"winehq.org",S_OK,FALSE},
2696             {"",S_FALSE,FALSE},
2697             {"",S_FALSE,FALSE},
2698             {"www.winehq.org",S_OK,FALSE},
2699             {"",S_FALSE,FALSE},
2700             {"/",S_OK,FALSE},
2701             {"/?query=01&return=y",S_OK,FALSE},
2702             {"?query=01&return=y",S_OK,FALSE},
2703             {"http://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2704             {"http",S_OK,FALSE},
2705             {"",S_FALSE,FALSE},
2706             {"",S_FALSE,FALSE}
2707         },
2708         {
2709             {Uri_HOST_DNS,S_OK,FALSE},
2710             {80,S_OK,FALSE},
2711             {URL_SCHEME_HTTP,S_OK,FALSE},
2712             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2713         }
2714     },
2715     /* Percent encoded, unreserved characters aren't decoded for unknown scheme types. */
2716     {   "zip://www.winehq.org/tests/..?query=%30%31&return=y", 0, S_OK, FALSE,
2717         {
2718             {"zip://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2719             {"www.winehq.org",S_OK,FALSE},
2720             {"zip://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2721             {"winehq.org",S_OK,FALSE},
2722             {"",S_FALSE,FALSE},
2723             {"",S_FALSE,FALSE},
2724             {"www.winehq.org",S_OK,FALSE},
2725             {"",S_FALSE,FALSE},
2726             {"/",S_OK,FALSE},
2727             {"/?query=%30%31&return=y",S_OK,FALSE},
2728             {"?query=%30%31&return=y",S_OK,FALSE},
2729             {"zip://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2730             {"zip",S_OK,FALSE},
2731             {"",S_FALSE,FALSE},
2732             {"",S_FALSE,FALSE}
2733         },
2734         {
2735             {Uri_HOST_DNS,S_OK,FALSE},
2736             {0,S_FALSE,FALSE},
2737             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2738             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2739         }
2740     },
2741     /* Percent encoded characters aren't decoded when NO_DECODE_EXTRA_INFO is set. */
2742     {   "http://www.winehq.org/tests/..?query=%30%31&return=y", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2743         {
2744             {"http://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2745             {"www.winehq.org",S_OK,FALSE},
2746             {"http://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2747             {"winehq.org",S_OK,FALSE},
2748             {"",S_FALSE,FALSE},
2749             {"",S_FALSE,FALSE},
2750             {"www.winehq.org",S_OK,FALSE},
2751             {"",S_FALSE,FALSE},
2752             {"/",S_OK,FALSE},
2753             {"/?query=%30%31&return=y",S_OK,FALSE},
2754             {"?query=%30%31&return=y",S_OK,FALSE},
2755             {"http://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2756             {"http",S_OK,FALSE},
2757             {"",S_FALSE,FALSE},
2758             {"",S_FALSE,FALSE}
2759         },
2760         {
2761             {Uri_HOST_DNS,S_OK,FALSE},
2762             {80,S_OK,FALSE},
2763             {URL_SCHEME_HTTP,S_OK,FALSE},
2764             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2765         }
2766     },
2767     {   "http://www.winehq.org?query=12&return=y", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2768         {
2769             {"http://www.winehq.org?query=12&return=y",S_OK,FALSE},
2770             {"www.winehq.org",S_OK,FALSE},
2771             {"http://www.winehq.org?query=12&return=y",S_OK,FALSE},
2772             {"winehq.org",S_OK,FALSE},
2773             {"",S_FALSE,FALSE},
2774             {"",S_FALSE,FALSE},
2775             {"www.winehq.org",S_OK,FALSE},
2776             {"",S_FALSE,FALSE},
2777             {"",S_FALSE,FALSE},
2778             {"?query=12&return=y",S_OK,FALSE},
2779             {"?query=12&return=y",S_OK,FALSE},
2780             {"http://www.winehq.org?query=12&return=y",S_OK,FALSE},
2781             {"http",S_OK,FALSE},
2782             {"",S_FALSE,FALSE},
2783             {"",S_FALSE,FALSE}
2784         },
2785         {
2786             {Uri_HOST_DNS,S_OK,FALSE},
2787             {80,S_OK,FALSE},
2788             {URL_SCHEME_HTTP,S_OK,FALSE},
2789             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2790         }
2791     },
2792     /* Unknown scheme types can have invalid % encoded data in fragments. */
2793     {   "zip://www.winehq.org/tests/#Te%xx", 0, S_OK, FALSE,
2794         {
2795             {"zip://www.winehq.org/tests/#Te%xx",S_OK,FALSE},
2796             {"www.winehq.org",S_OK,FALSE},
2797             {"zip://www.winehq.org/tests/#Te%xx",S_OK,FALSE},
2798             {"winehq.org",S_OK,FALSE},
2799             {"",S_FALSE,FALSE},
2800             {"#Te%xx",S_OK,FALSE},
2801             {"www.winehq.org",S_OK,FALSE},
2802             {"",S_FALSE,FALSE},
2803             {"/tests/",S_OK,FALSE},
2804             {"/tests/",S_OK,FALSE},
2805             {"",S_FALSE,FALSE},
2806             {"zip://www.winehq.org/tests/#Te%xx",S_OK,FALSE},
2807             {"zip",S_OK,FALSE},
2808             {"",S_FALSE,FALSE},
2809             {"",S_FALSE,FALSE}
2810         },
2811         {
2812             {Uri_HOST_DNS,S_OK,FALSE},
2813             {0,S_FALSE,FALSE},
2814             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2815             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2816         }
2817     },
2818     /* Forbidden characters in fragment aren't encoded for unknown schemes. */
2819     {   "zip://www.winehq.org/tests/#Te<|>", 0, S_OK, FALSE,
2820         {
2821             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2822             {"www.winehq.org",S_OK,FALSE},
2823             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2824             {"winehq.org",S_OK,FALSE},
2825             {"",S_FALSE,FALSE},
2826             {"#Te<|>",S_OK,FALSE},
2827             {"www.winehq.org",S_OK,FALSE},
2828             {"",S_FALSE,FALSE},
2829             {"/tests/",S_OK,FALSE},
2830             {"/tests/",S_OK,FALSE},
2831             {"",S_FALSE,FALSE},
2832             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2833             {"zip",S_OK,FALSE},
2834             {"",S_FALSE,FALSE},
2835             {"",S_FALSE,FALSE}
2836         },
2837         {
2838             {Uri_HOST_DNS,S_OK,FALSE},
2839             {0,S_FALSE,FALSE},
2840             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2841             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2842         }
2843     },
2844     /* Forbidden characters in the fragment are percent encoded for known schemes. */
2845     {   "http://www.winehq.org/tests/#Te<|>", 0, S_OK, FALSE,
2846         {
2847             {"http://www.winehq.org/tests/#Te%3C%7C%3E",S_OK,FALSE},
2848             {"www.winehq.org",S_OK,FALSE},
2849             {"http://www.winehq.org/tests/#Te%3C%7C%3E",S_OK,FALSE},
2850             {"winehq.org",S_OK,FALSE},
2851             {"",S_FALSE,FALSE},
2852             {"#Te%3C%7C%3E",S_OK,FALSE},
2853             {"www.winehq.org",S_OK,FALSE},
2854             {"",S_FALSE,FALSE},
2855             {"/tests/",S_OK,FALSE},
2856             {"/tests/",S_OK,FALSE},
2857             {"",S_FALSE,FALSE},
2858             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2859             {"http",S_OK,FALSE},
2860             {"",S_FALSE,FALSE},
2861             {"",S_FALSE,FALSE}
2862         },
2863         {
2864             {Uri_HOST_DNS,S_OK,FALSE},
2865             {80,S_OK,FALSE},
2866             {URL_SCHEME_HTTP,S_OK,FALSE},
2867             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2868         }
2869     },
2870     /* Forbidden characters aren't encoded in the fragment with this flag. */
2871     {   "http://www.winehq.org/tests/#Te<|>", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2872         {
2873             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2874             {"www.winehq.org",S_OK,FALSE},
2875             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2876             {"winehq.org",S_OK,FALSE},
2877             {"",S_FALSE,FALSE},
2878             {"#Te<|>",S_OK,FALSE},
2879             {"www.winehq.org",S_OK,FALSE},
2880             {"",S_FALSE,FALSE},
2881             {"/tests/",S_OK,FALSE},
2882             {"/tests/",S_OK,FALSE},
2883             {"",S_FALSE,FALSE},
2884             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2885             {"http",S_OK,FALSE},
2886             {"",S_FALSE,FALSE},
2887             {"",S_FALSE,FALSE}
2888         },
2889         {
2890             {Uri_HOST_DNS,S_OK,FALSE},
2891             {80,S_OK,FALSE},
2892             {URL_SCHEME_HTTP,S_OK,FALSE},
2893             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2894         }
2895     },
2896     /* Forbidden characters aren't encoded in the fragment with this flag. */
2897     {   "http://www.winehq.org/tests/#Te<|>", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2898         {
2899             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2900             {"www.winehq.org",S_OK,FALSE},
2901             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2902             {"winehq.org",S_OK,FALSE},
2903             {"",S_FALSE,FALSE},
2904             {"#Te<|>",S_OK,FALSE},
2905             {"www.winehq.org",S_OK,FALSE},
2906             {"",S_FALSE,FALSE},
2907             {"/tests/",S_OK,FALSE},
2908             {"/tests/",S_OK,FALSE},
2909             {"",S_FALSE,FALSE},
2910             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2911             {"http",S_OK,FALSE},
2912             {"",S_FALSE,FALSE},
2913             {"",S_FALSE,FALSE}
2914         },
2915         {
2916             {Uri_HOST_DNS,S_OK,FALSE},
2917             {80,S_OK,FALSE},
2918             {URL_SCHEME_HTTP,S_OK,FALSE},
2919             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2920         }
2921     },
2922     /* Percent encoded, unreserved characters aren't decoded for known scheme types. */
2923     {   "zip://www.winehq.org/tests/#Te%30%31%32", 0, S_OK, FALSE,
2924         {
2925             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2926             {"www.winehq.org",S_OK,FALSE},
2927             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2928             {"winehq.org",S_OK,FALSE},
2929             {"",S_FALSE,FALSE},
2930             {"#Te%30%31%32",S_OK,FALSE},
2931             {"www.winehq.org",S_OK,FALSE},
2932             {"",S_FALSE,FALSE},
2933             {"/tests/",S_OK,FALSE},
2934             {"/tests/",S_OK,FALSE},
2935             {"",S_FALSE,FALSE},
2936             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2937             {"zip",S_OK,FALSE},
2938             {"",S_FALSE,FALSE},
2939             {"",S_FALSE,FALSE}
2940         },
2941         {
2942             {Uri_HOST_DNS,S_OK,FALSE},
2943             {0,S_FALSE,FALSE},
2944             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2945             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2946         }
2947     },
2948     /* Percent encoded, unreserved characters are decoded for known schemes. */
2949     {   "http://www.winehq.org/tests/#Te%30%31%32", 0, S_OK, FALSE,
2950         {
2951             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
2952             {"www.winehq.org",S_OK,FALSE},
2953             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
2954             {"winehq.org",S_OK,FALSE},
2955             {"",S_FALSE,FALSE},
2956             {"#Te012",S_OK,FALSE},
2957             {"www.winehq.org",S_OK,FALSE},
2958             {"",S_FALSE,FALSE},
2959             {"/tests/",S_OK,FALSE},
2960             {"/tests/",S_OK,FALSE},
2961             {"",S_FALSE,FALSE},
2962             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2963             {"http",S_OK,FALSE},
2964             {"",S_FALSE,FALSE},
2965             {"",S_FALSE,FALSE}
2966         },
2967         {
2968             {Uri_HOST_DNS,S_OK,FALSE},
2969             {80,S_OK,FALSE},
2970             {URL_SCHEME_HTTP,S_OK,FALSE},
2971             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2972         }
2973     },
2974     /* Percent encoded, unreserved characters are decoded even if NO_CANONICALIZE is set. */
2975     {   "http://www.winehq.org/tests/#Te%30%31%32", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2976         {
2977             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
2978             {"www.winehq.org",S_OK,FALSE},
2979             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
2980             {"winehq.org",S_OK,FALSE},
2981             {"",S_FALSE,FALSE},
2982             {"#Te012",S_OK,FALSE},
2983             {"www.winehq.org",S_OK,FALSE},
2984             {"",S_FALSE,FALSE},
2985             {"/tests/",S_OK,FALSE},
2986             {"/tests/",S_OK,FALSE},
2987             {"",S_FALSE,FALSE},
2988             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2989             {"http",S_OK,FALSE},
2990             {"",S_FALSE,FALSE},
2991             {"",S_FALSE,FALSE}
2992         },
2993         {
2994             {Uri_HOST_DNS,S_OK,FALSE},
2995             {80,S_OK,FALSE},
2996             {URL_SCHEME_HTTP,S_OK,FALSE},
2997             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2998         }
2999     },
3000     /* Percent encoded, unreserved characters aren't decoded when NO_DECODE_EXTRA is set. */
3001     {   "http://www.winehq.org/tests/#Te%30%31%32", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
3002         {
3003             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3004             {"www.winehq.org",S_OK,FALSE},
3005             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3006             {"winehq.org",S_OK,FALSE},
3007             {"",S_FALSE,FALSE},
3008             {"#Te%30%31%32",S_OK,FALSE},
3009             {"www.winehq.org",S_OK,FALSE},
3010             {"",S_FALSE,FALSE},
3011             {"/tests/",S_OK,FALSE},
3012             {"/tests/",S_OK,FALSE},
3013             {"",S_FALSE,FALSE},
3014             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3015             {"http",S_OK,FALSE},
3016             {"",S_FALSE,FALSE},
3017             {"",S_FALSE,FALSE}
3018         },
3019         {
3020             {Uri_HOST_DNS,S_OK,FALSE},
3021             {80,S_OK,FALSE},
3022             {URL_SCHEME_HTTP,S_OK,FALSE},
3023             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3024         }
3025     },
3026     /* Leading/Trailing whitespace is removed. */
3027     {   "    http://google.com/     ", 0, S_OK, FALSE,
3028         {
3029             {"http://google.com/",S_OK,FALSE},
3030             {"google.com",S_OK,FALSE},
3031             {"http://google.com/",S_OK,FALSE},
3032             {"google.com",S_OK,FALSE},
3033             {"",S_FALSE,FALSE},
3034             {"",S_FALSE,FALSE},
3035             {"google.com",S_OK,FALSE},
3036             {"",S_FALSE,FALSE},
3037             {"/",S_OK,FALSE},
3038             {"/",S_OK,FALSE},
3039             {"",S_FALSE,FALSE},
3040             {"http://google.com/",S_OK,FALSE},
3041             {"http",S_OK,FALSE},
3042             {"",S_FALSE,FALSE},
3043             {"",S_FALSE,FALSE}
3044         },
3045         {
3046             {Uri_HOST_DNS,S_OK,FALSE},
3047             {80,S_OK,FALSE},
3048             {URL_SCHEME_HTTP,S_OK,FALSE},
3049             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3050         }
3051     },
3052     {   "\t\t\r\nhttp\n://g\noogle.co\rm/\n\n\n", 0, S_OK, FALSE,
3053         {
3054             {"http://google.com/",S_OK,FALSE},
3055             {"google.com",S_OK,FALSE},
3056             {"http://google.com/",S_OK,FALSE},
3057             {"google.com",S_OK,FALSE},
3058             {"",S_FALSE,FALSE},
3059             {"",S_FALSE,FALSE},
3060             {"google.com",S_OK,FALSE},
3061             {"",S_FALSE,FALSE},
3062             {"/",S_OK,FALSE},
3063             {"/",S_OK,FALSE},
3064             {"",S_FALSE,FALSE},
3065             {"http://google.com/",S_OK,FALSE},
3066             {"http",S_OK,FALSE},
3067             {"",S_FALSE,FALSE},
3068             {"",S_FALSE,FALSE}
3069         },
3070         {
3071             {Uri_HOST_DNS,S_OK,FALSE},
3072             {80,S_OK,FALSE},
3073             {URL_SCHEME_HTTP,S_OK,FALSE},
3074             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3075         }
3076     },
3077     {   "http://g\noogle.co\rm/\n\n\n", Uri_CREATE_NO_PRE_PROCESS_HTML_URI, S_OK, FALSE,
3078         {
3079             {"http://g%0aoogle.co%0dm/%0A%0A%0A",S_OK,FALSE},
3080             {"g%0aoogle.co%0dm",S_OK,FALSE},
3081             {"http://g%0aoogle.co%0dm/%0A%0A%0A",S_OK,FALSE},
3082             {"g%0aoogle.co%0dm",S_OK,FALSE},
3083             {"",S_FALSE,FALSE},
3084             {"",S_FALSE,FALSE},
3085             {"g%0aoogle.co%0dm",S_OK,FALSE},
3086             {"",S_FALSE,FALSE},
3087             {"/%0A%0A%0A",S_OK,FALSE},
3088             {"/%0A%0A%0A",S_OK,FALSE},
3089             {"",S_FALSE,FALSE},
3090             {"http://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3091             {"http",S_OK,FALSE},
3092             {"",S_FALSE,FALSE},
3093             {"",S_FALSE,FALSE}
3094         },
3095         {
3096             {Uri_HOST_DNS,S_OK,FALSE},
3097             {80,S_OK,FALSE},
3098             {URL_SCHEME_HTTP,S_OK,FALSE},
3099             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3100         }
3101     },
3102     {   "zip://g\noogle.co\rm/\n\n\n", Uri_CREATE_NO_PRE_PROCESS_HTML_URI, S_OK, FALSE,
3103         {
3104             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3105             {"g\noogle.co\rm",S_OK,FALSE},
3106             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3107             {"g\noogle.co\rm",S_OK,FALSE},
3108             {"",S_FALSE,FALSE},
3109             {"",S_FALSE,FALSE},
3110             {"g\noogle.co\rm",S_OK,FALSE},
3111             {"",S_FALSE,FALSE},
3112             {"/\n\n\n",S_OK,FALSE},
3113             {"/\n\n\n",S_OK,FALSE},
3114             {"",S_FALSE,FALSE},
3115             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3116             {"zip",S_OK,FALSE},
3117             {"",S_FALSE,FALSE},
3118             {"",S_FALSE,FALSE}
3119         },
3120         {
3121             {Uri_HOST_DNS,S_OK,FALSE},
3122             {0,S_FALSE,FALSE},
3123             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3124             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3125         }
3126     },
3127     /* Since file URLs are usually hierarchical, it returns an empty string
3128      * for the absolute URI property since it was declared as an opaque URI.
3129      */
3130     {   "file:index.html", 0, S_OK, FALSE,
3131         {
3132             {"",S_FALSE,FALSE},
3133             {"",S_FALSE,FALSE},
3134             {"file:index.html",S_OK,FALSE},
3135             {"",S_FALSE,FALSE},
3136             {".html",S_OK,FALSE},
3137             {"",S_FALSE,FALSE},
3138             {"",S_FALSE,FALSE},
3139             {"",S_FALSE,FALSE},
3140             {"index.html",S_OK,FALSE},
3141             {"index.html",S_OK,FALSE},
3142             {"",S_FALSE,FALSE},
3143             {"file:index.html",S_OK,FALSE},
3144             {"file",S_OK,FALSE},
3145             {"",S_FALSE,FALSE},
3146             {"",S_FALSE,FALSE}
3147         },
3148         {
3149             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3150             {0,S_FALSE,FALSE},
3151             {URL_SCHEME_FILE,S_OK,FALSE},
3152             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3153         }
3154     },
3155     /* Doesn't have an absolute since it's opaque, but gets it port set. */
3156     {   "http:test.com/index.html", 0, S_OK, FALSE,
3157         {
3158             {"",S_FALSE,FALSE},
3159             {"",S_FALSE,FALSE},
3160             {"http:test.com/index.html",S_OK,FALSE},
3161             {"",S_FALSE,FALSE},
3162             {".html",S_OK,FALSE},
3163             {"",S_FALSE,FALSE},
3164             {"",S_FALSE,FALSE},
3165             {"",S_FALSE,FALSE},
3166             {"test.com/index.html",S_OK,FALSE},
3167             {"test.com/index.html",S_OK,FALSE},
3168             {"",S_FALSE,FALSE},
3169             {"http:test.com/index.html",S_OK,FALSE},
3170             {"http",S_OK,FALSE},
3171             {"",S_FALSE,FALSE},
3172             {"",S_FALSE,FALSE}
3173         },
3174         {
3175             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3176             {80,S_OK,FALSE},
3177             {URL_SCHEME_HTTP,S_OK,FALSE},
3178             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3179         }
3180     },
3181     {   "ftp:test.com/index.html", 0, S_OK, FALSE,
3182         {
3183             {"",S_FALSE,FALSE},
3184             {"",S_FALSE,FALSE},
3185             {"ftp:test.com/index.html",S_OK,FALSE},
3186             {"",S_FALSE,FALSE},
3187             {".html",S_OK,FALSE},
3188             {"",S_FALSE,FALSE},
3189             {"",S_FALSE,FALSE},
3190             {"",S_FALSE,FALSE},
3191             {"test.com/index.html",S_OK,FALSE},
3192             {"test.com/index.html",S_OK,FALSE},
3193             {"",S_FALSE,FALSE},
3194             {"ftp:test.com/index.html",S_OK,FALSE},
3195             {"ftp",S_OK,FALSE},
3196             {"",S_FALSE,FALSE},
3197             {"",S_FALSE,FALSE}
3198         },
3199         {
3200             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3201             {21,S_OK,FALSE},
3202             {URL_SCHEME_FTP,S_OK,FALSE},
3203             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3204         }
3205     },
3206     {   "file://C|/test.mp3", 0, S_OK, FALSE,
3207         {
3208             {"file:///C:/test.mp3",S_OK,FALSE},
3209             {"",S_FALSE,FALSE},
3210             {"file:///C:/test.mp3",S_OK,FALSE},
3211             {"",S_FALSE,FALSE},
3212             {".mp3",S_OK,FALSE},
3213             {"",S_FALSE,FALSE},
3214             {"",S_FALSE,FALSE},
3215             {"",S_FALSE,FALSE},
3216             {"/C:/test.mp3",S_OK,FALSE},
3217             {"/C:/test.mp3",S_OK,FALSE},
3218             {"",S_FALSE,FALSE},
3219             {"file://C|/test.mp3",S_OK,FALSE},
3220             {"file",S_OK,FALSE},
3221             {"",S_FALSE,FALSE},
3222             {"",S_FALSE,FALSE}
3223         },
3224         {
3225             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3226             {0,S_FALSE,FALSE},
3227             {URL_SCHEME_FILE,S_OK,FALSE},
3228             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3229         }
3230     },
3231     {   "file:///C|/test.mp3", 0, S_OK, FALSE,
3232         {
3233             {"file:///C:/test.mp3",S_OK,FALSE},
3234             {"",S_FALSE,FALSE},
3235             {"file:///C:/test.mp3",S_OK,FALSE},
3236             {"",S_FALSE,FALSE},
3237             {".mp3",S_OK,FALSE},
3238             {"",S_FALSE,FALSE},
3239             {"",S_FALSE,FALSE},
3240             {"",S_FALSE,FALSE},
3241             {"/C:/test.mp3",S_OK,FALSE},
3242             {"/C:/test.mp3",S_OK,FALSE},
3243             {"",S_FALSE,FALSE},
3244             {"file:///C|/test.mp3",S_OK,FALSE},
3245             {"file",S_OK,FALSE},
3246             {"",S_FALSE,FALSE},
3247             {"",S_FALSE,FALSE}
3248         },
3249         {
3250             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3251             {0,S_FALSE,FALSE},
3252             {URL_SCHEME_FILE,S_OK,FALSE},
3253             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3254         }
3255     },
3256     /* Extra '/' isn't added before "c:" since USE_DOS_PATH is set and '/' are converted
3257      * to '\\'.
3258      */
3259     {   "file://c:/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3260         {
3261             {"file://c:\\dir\\index.html",S_OK,FALSE},
3262             {"",S_FALSE,FALSE},
3263             {"file://c:\\dir\\index.html",S_OK,FALSE},
3264             {"",S_FALSE,FALSE},
3265             {".html",S_OK,FALSE},
3266             {"",S_FALSE,FALSE},
3267             {"",S_FALSE,FALSE},
3268             {"",S_FALSE,FALSE},
3269             {"c:\\dir\\index.html",S_OK,FALSE},
3270             {"c:\\dir\\index.html",S_OK,FALSE},
3271             {"",S_FALSE,FALSE},
3272             {"file://c:/dir/index.html",S_OK,FALSE},
3273             {"file",S_OK,FALSE},
3274             {"",S_FALSE,FALSE},
3275             {"",S_FALSE,FALSE}
3276         },
3277         {
3278             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3279             {0,S_FALSE,FALSE},
3280             {URL_SCHEME_FILE,S_OK,FALSE},
3281             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3282         }
3283     },
3284     /* Extra '/' after "file://" is removed. */
3285     {   "file:///c:/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3286         {
3287             {"file://c:\\dir\\index.html",S_OK,FALSE},
3288             {"",S_FALSE,FALSE},
3289             {"file://c:\\dir\\index.html",S_OK,FALSE},
3290             {"",S_FALSE,FALSE},
3291             {".html",S_OK,FALSE},
3292             {"",S_FALSE,FALSE},
3293             {"",S_FALSE,FALSE},
3294             {"",S_FALSE,FALSE},
3295             {"c:\\dir\\index.html",S_OK,FALSE},
3296             {"c:\\dir\\index.html",S_OK,FALSE},
3297             {"",S_FALSE,FALSE},
3298             {"file:///c:/dir/index.html",S_OK,FALSE},
3299             {"file",S_OK,FALSE},
3300             {"",S_FALSE,FALSE},
3301             {"",S_FALSE,FALSE}
3302         },
3303         {
3304             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3305             {0,S_FALSE,FALSE},
3306             {URL_SCHEME_FILE,S_OK,FALSE},
3307             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3308         }
3309     },
3310     /* Allow more characters when Uri_CREATE_FILE_USE_DOS_PATH is specified */
3311     {   "file:///c:/dir\\%%61%20%5Fname/file%2A.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3312         {
3313             {"file://c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3314             {"",S_FALSE,FALSE},
3315             {"file://c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3316             {"",S_FALSE,FALSE},
3317             {".html",S_OK,FALSE},
3318             {"",S_FALSE,FALSE},
3319             {"",S_FALSE,FALSE},
3320             {"",S_FALSE,FALSE},
3321             {"c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3322             {"c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3323             {"",S_FALSE,FALSE},
3324             {"file:///c:/dir\\%%61%20%5Fname/file%2A.html",S_OK,FALSE},
3325             {"file",S_OK,FALSE},
3326             {"",S_FALSE,FALSE},
3327             {"",S_FALSE,FALSE}
3328         },
3329         {
3330             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3331             {0,S_FALSE,FALSE},
3332             {URL_SCHEME_FILE,S_OK,FALSE},
3333             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3334         }
3335     },
3336     {   "file://c|/dir\\index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3337         {
3338             {"file://c:\\dir\\index.html",S_OK,FALSE},
3339             {"",S_FALSE,FALSE},
3340             {"file://c:\\dir\\index.html",S_OK,FALSE},
3341             {"",S_FALSE,FALSE},
3342             {".html",S_OK,FALSE},
3343             {"",S_FALSE,FALSE},
3344             {"",S_FALSE,FALSE},
3345             {"",S_FALSE,FALSE},
3346             {"c:\\dir\\index.html",S_OK,FALSE},
3347             {"c:\\dir\\index.html",S_OK,FALSE},
3348             {"",S_FALSE,FALSE},
3349             {"file://c|/dir\\index.html",S_OK,FALSE},
3350             {"file",S_OK,FALSE},
3351             {"",S_FALSE,FALSE},
3352             {"",S_FALSE,FALSE}
3353         },
3354         {
3355             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3356             {0,S_FALSE,FALSE},
3357             {URL_SCHEME_FILE,S_OK,FALSE},
3358             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3359         }
3360     },
3361     /* The backslashes after the scheme name are converted to forward slashes. */
3362     {   "file:\\\\c:\\dir\\index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3363         {
3364             {"file://c:\\dir\\index.html",S_OK,FALSE},
3365             {"",S_FALSE,FALSE},
3366             {"file://c:\\dir\\index.html",S_OK,FALSE},
3367             {"",S_FALSE,FALSE},
3368             {".html",S_OK,FALSE},
3369             {"",S_FALSE,FALSE},
3370             {"",S_FALSE,FALSE},
3371             {"",S_FALSE,FALSE},
3372             {"c:\\dir\\index.html",S_OK,FALSE},
3373             {"c:\\dir\\index.html",S_OK,FALSE},
3374             {"",S_FALSE,FALSE},
3375             {"file:\\\\c:\\dir\\index.html",S_OK,FALSE},
3376             {"file",S_OK,FALSE},
3377             {"",S_FALSE,FALSE},
3378             {"",S_FALSE,FALSE}
3379         },
3380         {
3381             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3382             {0,S_FALSE,FALSE},
3383             {URL_SCHEME_FILE,S_OK,FALSE},
3384             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3385         }
3386     },
3387     {   "file:\\\\c:/dir/index.html", 0, S_OK, FALSE,
3388         {
3389             {"file:///c:/dir/index.html",S_OK,FALSE},
3390             {"",S_FALSE,FALSE},
3391             {"file:///c:/dir/index.html",S_OK,FALSE},
3392             {"",S_FALSE,FALSE},
3393             {".html",S_OK,FALSE},
3394             {"",S_FALSE,FALSE},
3395             {"",S_FALSE,FALSE},
3396             {"",S_FALSE,FALSE},
3397             {"/c:/dir/index.html",S_OK,FALSE},
3398             {"/c:/dir/index.html",S_OK,FALSE},
3399             {"",S_FALSE,FALSE},
3400             {"file:\\\\c:/dir/index.html",S_OK,FALSE},
3401             {"file",S_OK,FALSE},
3402             {"",S_FALSE,FALSE},
3403             {"",S_FALSE,FALSE}
3404         },
3405         {
3406             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3407             {0,S_FALSE,FALSE},
3408             {URL_SCHEME_FILE,S_OK,FALSE},
3409             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3410         }
3411     },
3412     {   "http:\\\\google.com", 0, S_OK, FALSE,
3413         {
3414             {"http://google.com/",S_OK,FALSE},
3415             {"google.com",S_OK,FALSE},
3416             {"http://google.com/",S_OK,FALSE},
3417             {"google.com",S_OK,FALSE},
3418             {"",S_FALSE,FALSE},
3419             {"",S_FALSE,FALSE},
3420             {"google.com",S_OK,FALSE},
3421             {"",S_FALSE,FALSE},
3422             {"/",S_OK,FALSE},
3423             {"/",S_OK,FALSE},
3424             {"",S_FALSE,FALSE},
3425             {"http:\\\\google.com",S_OK,FALSE},
3426             {"http",S_OK,FALSE},
3427             {"",S_FALSE,FALSE},
3428             {"",S_FALSE,FALSE}
3429         },
3430         {
3431             {Uri_HOST_DNS,S_OK,FALSE},
3432             {80,S_OK,FALSE},
3433             {URL_SCHEME_HTTP,S_OK,FALSE},
3434             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3435         }
3436     },
3437     /* the "\\\\" aren't converted to "//" for unknown scheme types and it's considered opaque. */
3438     {   "zip:\\\\google.com", 0, S_OK, FALSE,
3439         {
3440             {"zip:\\\\google.com",S_OK,FALSE},
3441             {"",S_FALSE,FALSE},
3442             {"zip:\\\\google.com",S_OK,FALSE},
3443             {"",S_FALSE,FALSE},
3444             {".com",S_OK,FALSE},
3445             {"",S_FALSE,FALSE},
3446             {"",S_FALSE,FALSE},
3447             {"",S_FALSE,FALSE},
3448             {"\\\\google.com",S_OK,FALSE},
3449             {"\\\\google.com",S_OK,FALSE},
3450             {"",S_FALSE,FALSE},
3451             {"zip:\\\\google.com",S_OK,FALSE},
3452             {"zip",S_OK,FALSE},
3453             {"",S_FALSE,FALSE},
3454             {"",S_FALSE,FALSE}
3455         },
3456         {
3457             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3458             {0,S_FALSE,FALSE},
3459             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3460             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3461         }
3462     },
3463     /* Dot segments aren't removed. */
3464     {   "file://c:\\dir\\../..\\./index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3465         {
3466             {"file://c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3467             {"",S_FALSE,FALSE},
3468             {"file://c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3469             {"",S_FALSE,FALSE},
3470             {".html",S_OK,FALSE},
3471             {"",S_FALSE,FALSE},
3472             {"",S_FALSE,FALSE},
3473             {"",S_FALSE,FALSE},
3474             {"c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3475             {"c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3476             {"",S_FALSE,FALSE},
3477             {"file://c:\\dir\\../..\\./index.html",S_OK,FALSE},
3478             {"file",S_OK,FALSE},
3479             {"",S_FALSE,FALSE},
3480             {"",S_FALSE,FALSE}
3481         },
3482         {
3483             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3484             {0,S_FALSE,FALSE},
3485             {URL_SCHEME_FILE,S_OK,FALSE},
3486             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3487         }
3488     },
3489     /* Forbidden characters aren't percent encoded. */
3490     {   "file://c:\\dir\\i^|ndex.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3491         {
3492             {"file://c:\\dir\\i^|ndex.html",S_OK,FALSE},
3493             {"",S_FALSE,FALSE},
3494             {"file://c:\\dir\\i^|ndex.html",S_OK,FALSE},
3495             {"",S_FALSE,FALSE},
3496             {".html",S_OK,FALSE},
3497             {"",S_FALSE,FALSE},
3498             {"",S_FALSE,FALSE},
3499             {"",S_FALSE,FALSE},
3500             {"c:\\dir\\i^|ndex.html",S_OK,FALSE},
3501             {"c:\\dir\\i^|ndex.html",S_OK,FALSE},
3502             {"",S_FALSE,FALSE},
3503             {"file://c:\\dir\\i^|ndex.html",S_OK,FALSE},
3504             {"file",S_OK,FALSE},
3505             {"",S_FALSE,FALSE},
3506             {"",S_FALSE,FALSE}
3507         },
3508         {
3509             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3510             {0,S_FALSE,FALSE},
3511             {URL_SCHEME_FILE,S_OK,FALSE},
3512             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3513         }
3514     },
3515     /* The '\' are still converted to '/' even though it's an opaque file URI. */
3516     {   "file:c:\\dir\\../..\\index.html", 0, S_OK, FALSE,
3517         {
3518             {"",S_FALSE,FALSE},
3519             {"",S_FALSE,FALSE},
3520             {"file:c:/dir/../../index.html",S_OK,FALSE},
3521             {"",S_FALSE,FALSE},
3522             {".html",S_OK,FALSE},
3523             {"",S_FALSE,FALSE},
3524             {"",S_FALSE,FALSE},
3525             {"",S_FALSE,FALSE},
3526             {"c:/dir/../../index.html",S_OK,FALSE},
3527             {"c:/dir/../../index.html",S_OK,FALSE},
3528             {"",S_FALSE,FALSE},
3529             {"file:c:\\dir\\../..\\index.html",S_OK,FALSE},
3530             {"file",S_OK,FALSE},
3531             {"",S_FALSE,FALSE},
3532             {"",S_FALSE,FALSE}
3533         },
3534         {
3535             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3536             {0,S_FALSE,FALSE},
3537             {URL_SCHEME_FILE,S_OK,FALSE},
3538             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3539         }
3540     },
3541     /* '/' are still converted to '\' even though it's an opaque URI. */
3542     {   "file:c:/dir\\../..\\index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3543         {
3544             {"",S_FALSE,FALSE},
3545             {"",S_FALSE,FALSE},
3546             {"file:c:\\dir\\..\\..\\index.html",S_OK,FALSE},
3547             {"",S_FALSE,FALSE},
3548             {".html",S_OK,FALSE},
3549             {"",S_FALSE,FALSE},
3550             {"",S_FALSE,FALSE},
3551             {"",S_FALSE,FALSE},
3552             {"c:\\dir\\..\\..\\index.html",S_OK,FALSE},
3553             {"c:\\dir\\..\\..\\index.html",S_OK,FALSE},
3554             {"",S_FALSE,FALSE},
3555             {"file:c:/dir\\../..\\index.html",S_OK,FALSE},
3556             {"file",S_OK,FALSE},
3557             {"",S_FALSE,FALSE},
3558             {"",S_FALSE,FALSE}
3559         },
3560         {
3561             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3562             {0,S_FALSE,FALSE},
3563             {URL_SCHEME_FILE,S_OK,FALSE},
3564             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3565         }
3566     },
3567     /* Forbidden characters aren't percent encoded. */
3568     {   "file:c:\\in^|dex.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3569         {
3570             {"",S_FALSE,FALSE},
3571             {"",S_FALSE,FALSE},
3572             {"file:c:\\in^|dex.html",S_OK,FALSE},
3573             {"",S_FALSE,FALSE},
3574             {".html",S_OK,FALSE},
3575             {"",S_FALSE,FALSE},
3576             {"",S_FALSE,FALSE},
3577             {"",S_FALSE,FALSE},
3578             {"c:\\in^|dex.html",S_OK,FALSE},
3579             {"c:\\in^|dex.html",S_OK,FALSE},
3580             {"",S_FALSE,FALSE},
3581             {"file:c:\\in^|dex.html",S_OK,FALSE},
3582             {"file",S_OK,FALSE},
3583             {"",S_FALSE,FALSE},
3584             {"",S_FALSE,FALSE}
3585         },
3586         {
3587             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3588             {0,S_FALSE,FALSE},
3589             {URL_SCHEME_FILE,S_OK,FALSE},
3590             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3591         }
3592     },
3593     /* Doesn't have a UserName since the ':' appears at the beginning of the
3594      * userinfo section.
3595      */
3596     {   "http://:password@gov.uk", 0, S_OK, FALSE,
3597         {
3598             {"http://:password@gov.uk/",S_OK,FALSE},
3599             {":password@gov.uk",S_OK,FALSE},
3600             {"http://gov.uk/",S_OK,FALSE},
3601             {"",S_FALSE,FALSE},
3602             {"",S_FALSE,FALSE},
3603             {"",S_FALSE,FALSE},
3604             {"gov.uk",S_OK,FALSE},
3605             {"password",S_OK,FALSE},
3606             {"/",S_OK,FALSE},
3607             {"/",S_OK,FALSE},
3608             {"",S_FALSE,FALSE},
3609             {"http://:password@gov.uk",S_OK,FALSE},
3610             {"http",S_OK,FALSE},
3611             {":password",S_OK,FALSE},
3612             {"",S_FALSE,FALSE}
3613         },
3614         {
3615             {Uri_HOST_DNS,S_OK,FALSE},
3616             {80,S_OK,FALSE},
3617             {URL_SCHEME_HTTP,S_OK,FALSE},
3618             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3619         }
3620     },
3621     /* Has a UserName since the userinfo section doesn't contain a password. */
3622     {   "http://@gov.uk", 0, S_OK, FALSE,
3623         {
3624             {"http://gov.uk/",S_OK,FALSE,"http://@gov.uk/"},
3625             {"@gov.uk",S_OK,FALSE},
3626             {"http://gov.uk/",S_OK,FALSE},
3627             {"",S_FALSE,FALSE},
3628             {"",S_FALSE,FALSE},
3629             {"",S_FALSE,FALSE},
3630             {"gov.uk",S_OK,FALSE},
3631             {"",S_FALSE,FALSE},
3632             {"/",S_OK,FALSE},
3633             {"/",S_OK,FALSE},
3634             {"",S_FALSE,FALSE},
3635             {"http://@gov.uk",S_OK,FALSE},
3636             {"http",S_OK,FALSE},
3637             {"",S_OK,FALSE},
3638             {"",S_OK,FALSE}
3639         },
3640         {
3641             {Uri_HOST_DNS,S_OK,FALSE},
3642             {80,S_OK,FALSE},
3643             {URL_SCHEME_HTTP,S_OK,FALSE},
3644             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3645         }
3646     },
3647     /* ":@" not included in the absolute URI. */
3648     {   "http://:@gov.uk", 0, S_OK, FALSE,
3649         {
3650             {"http://gov.uk/",S_OK,FALSE,"http://:@gov.uk/"},
3651             {":@gov.uk",S_OK,FALSE},
3652             {"http://gov.uk/",S_OK,FALSE},
3653             {"",S_FALSE,FALSE},
3654             {"",S_FALSE,FALSE},
3655             {"",S_FALSE,FALSE},
3656             {"gov.uk",S_OK,FALSE},
3657             {"",S_OK,FALSE},
3658             {"/",S_OK,FALSE},
3659             {"/",S_OK,FALSE},
3660             {"",S_FALSE,FALSE},
3661             {"http://:@gov.uk",S_OK,FALSE},
3662             {"http",S_OK,FALSE},
3663             {":",S_OK,FALSE},
3664             {"",S_FALSE,FALSE}
3665         },
3666         {
3667             {Uri_HOST_DNS,S_OK,FALSE},
3668             {80,S_OK,FALSE},
3669             {URL_SCHEME_HTTP,S_OK,FALSE},
3670             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3671         }
3672     },
3673     /* '@' is included because it's an unknown scheme type. */
3674     {   "zip://@gov.uk", 0, S_OK, FALSE,
3675         {
3676             {"zip://@gov.uk/",S_OK,FALSE},
3677             {"@gov.uk",S_OK,FALSE},
3678             {"zip://@gov.uk/",S_OK,FALSE},
3679             {"",S_FALSE,FALSE},
3680             {"",S_FALSE,FALSE},
3681             {"",S_FALSE,FALSE},
3682             {"gov.uk",S_OK,FALSE},
3683             {"",S_FALSE,FALSE},
3684             {"/",S_OK,FALSE},
3685             {"/",S_OK,FALSE},
3686             {"",S_FALSE,FALSE},
3687             {"zip://@gov.uk",S_OK,FALSE},
3688             {"zip",S_OK,FALSE},
3689             {"",S_OK,FALSE},
3690             {"",S_OK,FALSE}
3691         },
3692         {
3693             {Uri_HOST_DNS,S_OK,FALSE},
3694             {0,S_FALSE,FALSE},
3695             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3696             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3697         }
3698     },
3699     /* ":@" are included because it's an unknown scheme type. */
3700     {   "zip://:@gov.uk", 0, S_OK, FALSE,
3701         {
3702             {"zip://:@gov.uk/",S_OK,FALSE},
3703             {":@gov.uk",S_OK,FALSE},
3704             {"zip://:@gov.uk/",S_OK,FALSE},
3705             {"",S_FALSE,FALSE},
3706             {"",S_FALSE,FALSE},
3707             {"",S_FALSE,FALSE},
3708             {"gov.uk",S_OK,FALSE},
3709             {"",S_OK,FALSE},
3710             {"/",S_OK,FALSE},
3711             {"/",S_OK,FALSE},
3712             {"",S_FALSE,FALSE},
3713             {"zip://:@gov.uk",S_OK,FALSE},
3714             {"zip",S_OK,FALSE},
3715             {":",S_OK,FALSE},
3716             {"",S_FALSE,FALSE}
3717         },
3718         {
3719             {Uri_HOST_DNS,S_OK,FALSE},
3720             {0,S_FALSE,FALSE},
3721             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3722             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3723         }
3724     },
3725     {   "about:blank", 0, S_OK, FALSE,
3726         {
3727             {"about:blank",S_OK,FALSE},
3728             {"",S_FALSE,FALSE},
3729             {"about:blank",S_OK,FALSE},
3730             {"",S_FALSE,FALSE},
3731             {"",S_FALSE,FALSE},
3732             {"",S_FALSE,FALSE},
3733             {"",S_FALSE,FALSE},
3734             {"",S_FALSE,FALSE},
3735             {"blank",S_OK,FALSE},
3736             {"blank",S_OK,FALSE},
3737             {"",S_FALSE,FALSE},
3738             {"about:blank",S_OK,FALSE},
3739             {"about",S_OK,FALSE},
3740             {"",S_FALSE,FALSE},
3741             {"",S_FALSE,FALSE}
3742         },
3743         {
3744             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3745             {0,S_FALSE,FALSE},
3746             {URL_SCHEME_ABOUT,S_OK,FALSE},
3747             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3748         }
3749     },
3750     {   "mk:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",0,S_OK,FALSE,
3751         {
3752             {"mk:@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3753             {"",S_FALSE,FALSE},
3754             {"mk:@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3755             {"",S_FALSE,FALSE},
3756             {".htm",S_OK,FALSE},
3757             {"",S_FALSE,FALSE},
3758             {"",S_FALSE,FALSE},
3759             {"",S_FALSE,FALSE},
3760             {"@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3761             {"@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3762             {"",S_FALSE,FALSE},
3763             {"mk:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3764             {"mk",S_OK,FALSE},
3765             {"",S_FALSE,FALSE},
3766             {"",S_FALSE,FALSE}
3767         },
3768         {
3769             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3770             {0,S_FALSE,FALSE},
3771             {URL_SCHEME_MK,S_OK,FALSE},
3772             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3773         }
3774     },
3775     {   "mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",0,S_OK,FALSE,
3776         {
3777             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3778             {"",S_FALSE,FALSE},
3779             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3780             {"",S_FALSE,FALSE},
3781             {".htm",S_OK,FALSE},
3782             {"",S_FALSE,FALSE},
3783             {"",S_FALSE,FALSE},
3784             {"",S_FALSE,FALSE},
3785             {"@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3786             {"@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3787             {"",S_FALSE,FALSE},
3788             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3789             {"mk",S_OK,FALSE},
3790             {"",S_FALSE,FALSE},
3791             {"",S_FALSE,FALSE}
3792         },
3793         {
3794             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3795             {0,S_FALSE,FALSE},
3796             {URL_SCHEME_MK,S_OK,FALSE},
3797             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3798         }
3799     },
3800     /* Two '\' are added to the URI when USE_DOS_PATH is set, and it's a UNC path. */
3801     {   "file://server/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3802         {
3803             {"file://\\\\server\\dir\\index.html",S_OK,FALSE},
3804             {"server",S_OK,FALSE},
3805             {"file://\\\\server\\dir\\index.html",S_OK,FALSE},
3806             {"",S_FALSE,FALSE},
3807             {".html",S_OK,FALSE},
3808             {"",S_FALSE,FALSE},
3809             {"server",S_OK,FALSE},
3810             {"",S_FALSE,FALSE},
3811             {"\\dir\\index.html",S_OK,FALSE},
3812             {"\\dir\\index.html",S_OK,FALSE},
3813             {"",S_FALSE,FALSE},
3814             {"file://server/dir/index.html",S_OK,FALSE},
3815             {"file",S_OK,FALSE},
3816             {"",S_FALSE,FALSE},
3817             {"",S_FALSE,FALSE}
3818         },
3819         {
3820             {Uri_HOST_DNS,S_OK,FALSE},
3821             {0,S_FALSE,FALSE},
3822             {URL_SCHEME_FILE,S_OK,FALSE},
3823             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3824         }
3825     },
3826     /* When CreateUri generates an IUri, it still displays the default port in the
3827      * authority.
3828      */
3829     {   "http://google.com:80/", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
3830         {
3831             {"http://google.com:80/",S_OK,FALSE},
3832             {"google.com:80",S_OK,FALSE},
3833             {"http://google.com:80/",S_OK,FALSE},
3834             {"google.com",S_OK,FALSE},
3835             {"",S_FALSE,FALSE},
3836             {"",S_FALSE,FALSE},
3837             {"google.com",S_OK,FALSE},
3838             {"",S_FALSE,FALSE},
3839             {"/",S_OK,FALSE},
3840             {"/",S_OK,FALSE},
3841             {"",S_FALSE,FALSE},
3842             {"http://google.com:80/",S_OK,FALSE},
3843             {"http",S_OK,FALSE},
3844             {"",S_FALSE,FALSE},
3845             {"",S_FALSE,FALSE}
3846         },
3847         {
3848             {Uri_HOST_DNS,S_OK,FALSE},
3849             {80,S_OK,FALSE},
3850             {URL_SCHEME_HTTP,S_OK,FALSE},
3851             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3852         }
3853     },
3854     /* For res URIs the host is everything up until the first '/'. */
3855     {   "res://C:\\dir\\file.exe/DATA/test.html", 0, S_OK, FALSE,
3856         {
3857             {"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
3858             {"C:\\dir\\file.exe",S_OK,FALSE},
3859             {"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
3860             {"",S_FALSE,FALSE},
3861             {".html",S_OK,FALSE},
3862             {"",S_FALSE,FALSE},
3863             {"C:\\dir\\file.exe",S_OK,FALSE},
3864             {"",S_FALSE,FALSE},
3865             {"/DATA/test.html",S_OK,FALSE},
3866             {"/DATA/test.html",S_OK,FALSE},
3867             {"",S_FALSE,FALSE},
3868             {"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
3869             {"res",S_OK,FALSE},
3870             {"",S_FALSE,FALSE},
3871             {"",S_FALSE,FALSE}
3872         },
3873         {
3874             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3875             {0,S_FALSE,FALSE},
3876             {URL_SCHEME_RES,S_OK,FALSE},
3877             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3878         }
3879     },
3880     /* Res URI can contain a '|' in the host name. */
3881     {   "res://c:\\di|r\\file.exe/test", 0, S_OK, FALSE,
3882         {
3883             {"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
3884             {"c:\\di|r\\file.exe",S_OK,FALSE},
3885             {"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
3886             {"",S_FALSE,FALSE},
3887             {"",S_FALSE,FALSE},
3888             {"",S_FALSE,FALSE},
3889             {"c:\\di|r\\file.exe",S_OK,FALSE},
3890             {"",S_FALSE,FALSE},
3891             {"/test",S_OK,FALSE},
3892             {"/test",S_OK,FALSE},
3893             {"",S_FALSE,FALSE},
3894             {"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
3895             {"res",S_OK,FALSE},
3896             {"",S_FALSE,FALSE},
3897             {"",S_FALSE,FALSE}
3898         },
3899         {
3900             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3901             {0,S_FALSE,FALSE},
3902             {URL_SCHEME_RES,S_OK,FALSE},
3903             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3904         }
3905     },
3906     /* Res URIs can have invalid percent encoded values. */
3907     {   "res://c:\\dir%xx\\file.exe/test", 0, S_OK, FALSE,
3908         {
3909             {"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
3910             {"c:\\dir%xx\\file.exe",S_OK,FALSE},
3911             {"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
3912             {"",S_FALSE,FALSE},
3913             {"",S_FALSE,FALSE},
3914             {"",S_FALSE,FALSE},
3915             {"c:\\dir%xx\\file.exe",S_OK,FALSE},
3916             {"",S_FALSE,FALSE},
3917             {"/test",S_OK,FALSE},
3918             {"/test",S_OK,FALSE},
3919             {"",S_FALSE,FALSE},
3920             {"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
3921             {"res",S_OK,FALSE},
3922             {"",S_FALSE,FALSE},
3923             {"",S_FALSE,FALSE}
3924         },
3925         {
3926             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3927             {0,S_FALSE,FALSE},
3928             {URL_SCHEME_RES,S_OK,FALSE},
3929             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3930         }
3931     },
3932     /* Res doesn't get forbidden characters percent encoded in it's path. */
3933     {   "res://c:\\test/tes<|>t", 0, S_OK, FALSE,
3934         {
3935             {"res://c:\\test/tes<|>t",S_OK,FALSE},
3936             {"c:\\test",S_OK,FALSE},
3937             {"res://c:\\test/tes<|>t",S_OK,FALSE},
3938             {"",S_FALSE,FALSE},
3939             {"",S_FALSE,FALSE},
3940             {"",S_FALSE,FALSE},
3941             {"c:\\test",S_OK,FALSE},
3942             {"",S_FALSE,FALSE},
3943             {"/tes<|>t",S_OK,FALSE},
3944             {"/tes<|>t",S_OK,FALSE},
3945             {"",S_FALSE,FALSE},
3946             {"res://c:\\test/tes<|>t",S_OK,FALSE},
3947             {"res",S_OK,FALSE},
3948             {"",S_FALSE,FALSE},
3949             {"",S_FALSE,FALSE}
3950         },
3951         {
3952             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3953             {0,S_FALSE,FALSE},
3954             {URL_SCHEME_RES,S_OK,FALSE},
3955             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3956         }
3957     }
3958 };
3959
3960 typedef struct _invalid_uri {
3961     const char* uri;
3962     DWORD       flags;
3963     BOOL        todo;
3964 } invalid_uri;
3965
3966 static const invalid_uri invalid_uri_tests[] = {
3967     /* Has to have a scheme name. */
3968     {"://www.winehq.org",0,FALSE},
3969     /* Window's doesn't like URI's which are implicitly file paths without the
3970      * ALLOW_IMPLICIT_FILE_SCHEME flag set.
3971      */
3972     {"C:/test/test.mp3",0,FALSE},
3973     {"\\\\Server/test/test.mp3",0,FALSE},
3974     {"C:/test/test.mp3",Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME,FALSE},
3975     {"\\\\Server/test/test.mp3",Uri_CREATE_ALLOW_RELATIVE,FALSE},
3976     /* Invalid schemes. */
3977     {"*abcd://not.valid.com",0,FALSE},
3978     {"*a*b*c*d://not.valid.com",0,FALSE},
3979     /* Not allowed to have invalid % encoded data. */
3980     {"ftp://google.co%XX/",0,FALSE},
3981     /* To many h16 components. */
3982     {"http://[1:2:3:4:5:6:7:8:9]",0,FALSE},
3983     /* Not enough room for IPv4 address. */
3984     {"http://[1:2:3:4:5:6:7:192.0.1.0]",0,FALSE},
3985     /* Not enough h16 components. */
3986     {"http://[1:2:3:4]",0,FALSE},
3987     /* Not enough components including IPv4. */
3988     {"http://[1:192.0.1.0]",0,FALSE},
3989     /* Not allowed to have partial IPv4 in IPv6. */
3990     {"http://[::192.0]",0,FALSE},
3991     /* Can't have elision of 1 h16 at beginning of address. */
3992     {"http://[::2:3:4:5:6:7:8]",0,FALSE},
3993     /* Can't have elision of 1 h16 at end of address. */
3994     {"http://[1:2:3:4:5:6:7::]",0,FALSE},
3995     /* Expects a valid IP Literal. */
3996     {"ftp://[not.valid.uri]/",0,FALSE},
3997     /* Expects valid port for a known scheme type. */
3998     {"ftp://www.winehq.org:123fgh",0,FALSE},
3999     /* Port exceeds USHORT_MAX for known scheme type. */
4000     {"ftp://www.winehq.org:65536",0,FALSE},
4001     /* Invalid port with IPv4 address. */
4002     {"http://www.winehq.org:1abcd",0,FALSE},
4003     /* Invalid port with IPv6 address. */
4004     {"http://[::ffff]:32xy",0,FALSE},
4005     /* Not allowed to have backslashes with NO_CANONICALIZE. */
4006     {"gopher://www.google.com\\test",Uri_CREATE_NO_CANONICALIZE,FALSE},
4007     /* Not allowed to have invalid % encoded data in opaque URI path. */
4008     {"news:test%XX",0,FALSE},
4009     {"mailto:wine@winehq%G8.com",0,FALSE},
4010     /* Known scheme types can't have invalid % encoded data in query string. */
4011     {"http://google.com/?query=te%xx",0,FALSE},
4012     /* Invalid % encoded data in fragment of know scheme type. */
4013     {"ftp://google.com/#Test%xx",0,FALSE},
4014     {"  http://google.com/",Uri_CREATE_NO_PRE_PROCESS_HTML_URI,FALSE},
4015     {"\n\nhttp://google.com/",Uri_CREATE_NO_PRE_PROCESS_HTML_URI,FALSE},
4016     {"file://c:\\test<test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4017     {"file://c:\\test>test",Uri_CREATE_FILE_USE_DOS_PATH,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     /* res URIs aren't allowed to have forbidden dos path characters in the
4023      * hostname.
4024      */
4025     {"res://c:\\te<st\\test/test",0,FALSE},
4026     {"res://c:\\te>st\\test/test",0,FALSE},
4027     {"res://c:\\te\"st\\test/test",0,FALSE},
4028     {"res://c:\\test/te%xxst",0,FALSE}
4029 };
4030
4031 typedef struct _uri_equality {
4032     const char* a;
4033     DWORD       create_flags_a;
4034     BOOL        create_todo_a;
4035     const char* b;
4036     DWORD       create_flags_b;
4037     BOOL        create_todo_b;
4038     BOOL        equal;
4039     BOOL        todo;
4040 } uri_equality;
4041
4042 static const uri_equality equality_tests[] = {
4043     {
4044         "HTTP://www.winehq.org/test dir/./",0,FALSE,
4045         "http://www.winehq.org/test dir/../test dir/",0,FALSE,
4046         TRUE, FALSE
4047     },
4048     {
4049         /* http://www.winehq.org/test%20dir */
4050         "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,
4051         "http://www.winehq.org/test dir",0,FALSE,
4052         TRUE, FALSE
4053     },
4054     {
4055         "c:\\test.mp3",Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME,FALSE,
4056         "file:///c:/test.mp3",0,FALSE,
4057         TRUE, FALSE
4058     },
4059     {
4060         "ftp://ftp.winehq.org/",0,FALSE,
4061         "ftp://ftp.winehq.org",0,FALSE,
4062         TRUE, FALSE
4063     },
4064     {
4065         "ftp://ftp.winehq.org/test/test2/../../testB/",0,FALSE,
4066         "ftp://ftp.winehq.org/t%45stB/",0,FALSE,
4067         FALSE, FALSE
4068     },
4069     {
4070         "http://google.com/TEST",0,FALSE,
4071         "http://google.com/test",0,FALSE,
4072         FALSE, FALSE
4073     },
4074     {
4075         "http://GOOGLE.com/",0,FALSE,
4076         "http://google.com/",0,FALSE,
4077         TRUE, FALSE
4078     },
4079     /* Performs case insensitive compare of host names (for known scheme types). */
4080     {
4081         "ftp://GOOGLE.com/",Uri_CREATE_NO_CANONICALIZE,FALSE,
4082         "ftp://google.com/",0,FALSE,
4083         TRUE, FALSE
4084     },
4085     {
4086         "zip://GOOGLE.com/",0,FALSE,
4087         "zip://google.com/",0,FALSE,
4088         FALSE, FALSE
4089     },
4090     {
4091         "file:///c:/TEST/TeST/",0,FALSE,
4092         "file:///c:/test/test/",0,FALSE,
4093         TRUE, FALSE
4094     },
4095     {
4096         "file:///server/TEST",0,FALSE,
4097         "file:///SERVER/TEST",0,FALSE,
4098         TRUE, FALSE
4099     },
4100     {
4101         "http://google.com",Uri_CREATE_NO_CANONICALIZE,FALSE,
4102         "http://google.com/",0,FALSE,
4103         TRUE, FALSE
4104     },
4105     {
4106         "ftp://google.com:21/",0,FALSE,
4107         "ftp://google.com/",0,FALSE,
4108         TRUE, FALSE
4109     },
4110     {
4111         "http://google.com:80/",Uri_CREATE_NO_CANONICALIZE,FALSE,
4112         "http://google.com/",0,FALSE,
4113         TRUE, FALSE
4114     },
4115     {
4116         "http://google.com:70/",0,FALSE,
4117         "http://google.com:71/",0,FALSE,
4118         FALSE, FALSE
4119     }
4120 };
4121
4122 typedef struct _uri_with_fragment {
4123     const char* uri;
4124     const char* fragment;
4125     DWORD       create_flags;
4126     HRESULT     create_expected;
4127     BOOL        create_todo;
4128
4129     const char* expected_uri;
4130     BOOL        expected_todo;
4131 } uri_with_fragment;
4132
4133 static const uri_with_fragment uri_fragment_tests[] = {
4134     {
4135         "http://google.com/","#fragment",0,S_OK,FALSE,
4136         "http://google.com/#fragment",FALSE
4137     },
4138     {
4139         "http://google.com/","fragment",0,S_OK,FALSE,
4140         "http://google.com/#fragment",FALSE
4141     },
4142     {
4143         "zip://test.com/","?test",0,S_OK,FALSE,
4144         "zip://test.com/#?test",FALSE
4145     },
4146     /* The fragment can be empty. */
4147     {
4148         "ftp://ftp.google.com/","",0,S_OK,FALSE,
4149         "ftp://ftp.google.com/#",FALSE
4150     }
4151 };
4152
4153 typedef struct _uri_builder_property {
4154     BOOL            change;
4155     const char      *value;
4156     const char      *expected_value;
4157     Uri_PROPERTY    property;
4158     HRESULT         expected;
4159     BOOL            todo;
4160 } uri_builder_property;
4161
4162 typedef struct _uri_builder_port {
4163     BOOL    change;
4164     BOOL    set;
4165     DWORD   value;
4166     HRESULT expected;
4167     BOOL    todo;
4168 } uri_builder_port;
4169
4170 typedef struct _uri_builder_str_property {
4171     const char* expected;
4172     HRESULT     result;
4173     BOOL        todo;
4174 } uri_builder_str_property;
4175
4176 typedef struct _uri_builder_dword_property {
4177     DWORD   expected;
4178     HRESULT result;
4179     BOOL    todo;
4180 } uri_builder_dword_property;
4181
4182 typedef struct _uri_builder_test {
4183     const char                  *uri;
4184     DWORD                       create_flags;
4185     HRESULT                     create_builder_expected;
4186     BOOL                        create_builder_todo;
4187
4188     uri_builder_property        properties[URI_BUILDER_STR_PROPERTY_COUNT];
4189
4190     uri_builder_port            port_prop;
4191
4192     DWORD                       uri_flags;
4193     HRESULT                     uri_hres;
4194     BOOL                        uri_todo;
4195
4196     DWORD                       uri_simple_encode_flags;
4197     HRESULT                     uri_simple_hres;
4198     BOOL                        uri_simple_todo;
4199
4200     DWORD                       uri_with_flags;
4201     DWORD                       uri_with_builder_flags;
4202     DWORD                       uri_with_encode_flags;
4203     HRESULT                     uri_with_hres;
4204     BOOL                        uri_with_todo;
4205
4206     uri_builder_str_property    expected_str_props[URI_STR_PROPERTY_COUNT];
4207     uri_builder_dword_property  expected_dword_props[URI_DWORD_PROPERTY_COUNT];
4208 } uri_builder_test;
4209
4210 static const uri_builder_test uri_builder_tests[] = {
4211     {   "http://google.com/",0,S_OK,FALSE,
4212         {
4213             {TRUE,"#fragment",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE},
4214             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE},
4215             {TRUE,"?query=x",NULL,Uri_PROPERTY_QUERY,S_OK,FALSE},
4216             {TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4217         },
4218         {FALSE},
4219         0,S_OK,FALSE,
4220         0,S_OK,FALSE,
4221         0,0,0,S_OK,FALSE,
4222         {
4223             {"http://username:password@google.com/?query=x#fragment",S_OK},
4224             {"username:password@google.com",S_OK},
4225             {"http://google.com/?query=x#fragment",S_OK},
4226             {"google.com",S_OK},
4227             {"",S_FALSE},
4228             {"#fragment",S_OK},
4229             {"google.com",S_OK},
4230             {"password",S_OK},
4231             {"/",S_OK},
4232             {"/?query=x",S_OK},
4233             {"?query=x",S_OK},
4234             {"http://username:password@google.com/?query=x#fragment",S_OK},
4235             {"http",S_OK},
4236             {"username:password",S_OK},
4237             {"username",S_OK}
4238         },
4239         {
4240             {Uri_HOST_DNS,S_OK},
4241             {80,S_OK},
4242             {URL_SCHEME_HTTP,S_OK},
4243             {URLZONE_INVALID,E_NOTIMPL}
4244         }
4245     },
4246     {   "http://google.com/",0,S_OK,FALSE,
4247         {
4248             {TRUE,"test",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE}
4249         },
4250         {TRUE,TRUE,120,S_OK,FALSE},
4251         0,S_OK,FALSE,
4252         0,S_OK,FALSE,
4253         0,0,0,S_OK,FALSE,
4254         {
4255             {"test://google.com:120/",S_OK},
4256             {"google.com:120",S_OK},
4257             {"test://google.com:120/",S_OK},
4258             {"google.com",S_OK},
4259             {"",S_FALSE},
4260             {"",S_FALSE},
4261             {"google.com",S_OK},
4262             {"",S_FALSE},
4263             {"/",S_OK},
4264             {"/",S_OK},
4265             {"",S_FALSE},
4266             {"test://google.com:120/",S_OK},
4267             {"test",S_OK},
4268             {"",S_FALSE},
4269             {"",S_FALSE}
4270         },
4271         {
4272             {Uri_HOST_DNS,S_OK},
4273             {120,S_OK},
4274             {URL_SCHEME_UNKNOWN,S_OK},
4275             {URLZONE_INVALID,E_NOTIMPL}
4276         }
4277     },
4278     {   "/Test/test dir",Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4279         {
4280             {TRUE,"http",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE},
4281             {TRUE,"::192.2.3.4",NULL,Uri_PROPERTY_HOST,S_OK,FALSE},
4282             {TRUE,NULL,NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
4283         },
4284         {FALSE},
4285         0,S_OK,FALSE,
4286         0,S_OK,FALSE,
4287         0,0,0,S_OK,FALSE,
4288         {
4289             {"http://[::192.2.3.4]/",S_OK},
4290             {"[::192.2.3.4]",S_OK},
4291             {"http://[::192.2.3.4]/",S_OK},
4292             {"",S_FALSE},
4293             {"",S_FALSE},
4294             {"",S_FALSE},
4295             {"::192.2.3.4",S_OK},
4296             {"",S_FALSE},
4297             {"/",S_OK},
4298             {"/",S_OK},
4299             {"",S_FALSE},
4300             {"http://[::192.2.3.4]/",S_OK},
4301             {"http",S_OK},
4302             {"",S_FALSE},
4303             {"",S_FALSE}
4304         },
4305         {
4306             {Uri_HOST_IPV6,S_OK},
4307             {80,S_OK},
4308             {URL_SCHEME_HTTP,S_OK},
4309             {URLZONE_INVALID,E_NOTIMPL}
4310         }
4311     },
4312     {   "http://google.com/",0,S_OK,FALSE,
4313         {
4314             {TRUE,"Frag","#Frag",Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
4315         },
4316         {FALSE},
4317         0,S_OK,FALSE,
4318         0,S_OK,FALSE,
4319         0,0,0,S_OK,FALSE,
4320         {
4321             {"http://google.com/#Frag",S_OK},
4322             {"google.com",S_OK},
4323             {"http://google.com/#Frag",S_OK},
4324             {"google.com",S_OK},
4325             {"",S_FALSE},
4326             {"#Frag",S_OK},
4327             {"google.com",S_OK},
4328             {"",S_FALSE},
4329             {"/",S_OK},
4330             {"/",S_OK},
4331             {"",S_FALSE},
4332             {"http://google.com/#Frag",S_OK},
4333             {"http",S_OK},
4334             {"",S_FALSE},
4335             {"",S_FALSE}
4336         },
4337         {
4338             {Uri_HOST_DNS,S_OK},
4339             {80,S_OK},
4340             {URL_SCHEME_HTTP,S_OK},
4341             {URLZONE_INVALID,E_NOTIMPL}
4342         }
4343     },
4344     {   "http://google.com/",0,S_OK,FALSE,
4345         {
4346             {TRUE,"","#",Uri_PROPERTY_FRAGMENT,S_OK,FALSE},
4347         },
4348         {FALSE},
4349         0,S_OK,FALSE,
4350         0,S_OK,FALSE,
4351         0,0,0,S_OK,FALSE,
4352         {
4353             {"http://google.com/#",S_OK},
4354             {"google.com",S_OK},
4355             {"http://google.com/#",S_OK},
4356             {"google.com",S_OK},
4357             {"",S_FALSE},
4358             {"#",S_OK},
4359             {"google.com",S_OK},
4360             {"",S_FALSE},
4361             {"/",S_OK},
4362             {"/",S_OK},
4363             {"",S_FALSE},
4364             {"http://google.com/#",S_OK},
4365             {"http",S_OK},
4366             {"",S_FALSE},
4367             {"",S_FALSE}
4368         },
4369         {
4370             {Uri_HOST_DNS,S_OK},
4371             {80,S_OK},
4372             {URL_SCHEME_HTTP,S_OK},
4373             {URLZONE_INVALID,E_NOTIMPL}
4374         }
4375     },
4376     {   "http://google.com/",0,S_OK,FALSE,
4377         {
4378             {TRUE,":password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4379         },
4380         {FALSE},
4381         0,S_OK,FALSE,
4382         0,S_OK,FALSE,
4383         0,0,0,S_OK,FALSE,
4384         {
4385             {"http://::password@google.com/",S_OK},
4386             {"::password@google.com",S_OK},
4387             {"http://google.com/",S_OK},
4388             {"google.com",S_OK},
4389             {"",S_FALSE},
4390             {"",S_FALSE},
4391             {"google.com",S_OK},
4392             {":password",S_OK},
4393             {"/",S_OK},
4394             {"/",S_OK},
4395             {"",S_FALSE},
4396             {"http://::password@google.com/",S_OK},
4397             {"http",S_OK},
4398             {"::password",S_OK},
4399             {"",S_FALSE}
4400         },
4401         {
4402             {Uri_HOST_DNS,S_OK},
4403             {80,S_OK},
4404             {URL_SCHEME_HTTP,S_OK},
4405             {URLZONE_INVALID,E_NOTIMPL}
4406         }
4407     },
4408     {   "test/test",Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4409         {
4410             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4411         },
4412         {FALSE},
4413         Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4414         0,S_OK,FALSE,
4415         Uri_CREATE_ALLOW_RELATIVE,0,0,S_OK,FALSE,
4416         {
4417             {":password@test/test",S_OK},
4418             {":password@",S_OK},
4419             {":password@test/test",S_OK},
4420             {"",S_FALSE},
4421             {"",S_FALSE},
4422             {"",S_FALSE},
4423             {"",S_FALSE},
4424             {"password",S_OK},
4425             {"test/test",S_OK},
4426             {"test/test",S_OK},
4427             {"",S_FALSE},
4428             {":password@test/test",S_OK},
4429             {"",S_FALSE},
4430             {":password",S_OK},
4431             {"",S_FALSE}
4432         },
4433         {
4434             {Uri_HOST_UNKNOWN,S_OK},
4435             {0,S_FALSE},
4436             {URL_SCHEME_UNKNOWN,S_OK},
4437             {URLZONE_INVALID,E_NOTIMPL}
4438         }
4439     },
4440     {   "http://google.com/",0,S_OK,FALSE,
4441         {
4442             {TRUE,"test/test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
4443         },
4444         {FALSE},
4445         0,S_OK,FALSE,
4446         0,S_OK,FALSE,
4447         0,0,0,S_OK,FALSE,
4448         {
4449             {"http://google.com/test/test",S_OK},
4450             {"google.com",S_OK},
4451             {"http://google.com/test/test",S_OK},
4452             {"google.com",S_OK},
4453             {"",S_FALSE},
4454             {"",S_FALSE},
4455             {"google.com",S_OK},
4456             {"",S_FALSE},
4457             {"/test/test",S_OK},
4458             {"/test/test",S_OK},
4459             {"",S_FALSE},
4460             {"http://google.com/test/test",S_OK},
4461             {"http",S_OK},
4462             {"",S_FALSE},
4463             {"",S_FALSE}
4464         },
4465         {
4466             {Uri_HOST_DNS,S_OK},
4467             {80,S_OK},
4468             {URL_SCHEME_HTTP,S_OK},
4469             {URLZONE_INVALID,E_NOTIMPL}
4470         }
4471     },
4472     {   "zip:testing/test",0,S_OK,FALSE,
4473         {
4474             {TRUE,"test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
4475         },
4476         {FALSE},
4477         0,S_OK,FALSE,
4478         0,S_OK,FALSE,
4479         0,0,0,S_OK,FALSE,
4480         {
4481             {"zip:test",S_OK},
4482             {"",S_FALSE},
4483             {"zip:test",S_OK},
4484             {"",S_FALSE},
4485             {"",S_FALSE},
4486             {"",S_FALSE},
4487             {"",S_FALSE},
4488             {"",S_FALSE},
4489             {"test",S_OK},
4490             {"test",S_OK},
4491             {"",S_FALSE},
4492             {"zip:test",S_OK},
4493             {"zip",S_OK},
4494             {"",S_FALSE},
4495             {"",S_FALSE}
4496         },
4497         {
4498             {Uri_HOST_UNKNOWN,S_OK},
4499             {0,S_FALSE},
4500             {URL_SCHEME_UNKNOWN,S_OK},
4501             {URLZONE_INVALID,E_NOTIMPL}
4502         }
4503     },
4504     {   "http://google.com/",0,S_OK,FALSE,
4505         {
4506             {FALSE},
4507         },
4508         /* 555 will be returned from GetPort even though FALSE was passed as the hasPort parameter. */
4509         {TRUE,FALSE,555,S_OK,FALSE},
4510         0,S_OK,FALSE,
4511         0,S_OK,FALSE,
4512         0,0,0,S_OK,FALSE,
4513         {
4514             {"http://google.com/",S_OK},
4515             {"google.com",S_OK},
4516             {"http://google.com/",S_OK},
4517             {"google.com",S_OK},
4518             {"",S_FALSE},
4519             {"",S_FALSE},
4520             {"google.com",S_OK},
4521             {"",S_FALSE},
4522             {"/",S_OK},
4523             {"/",S_OK},
4524             {"",S_FALSE},
4525             {"http://google.com/",S_OK},
4526             {"http",S_OK},
4527             {"",S_FALSE},
4528             {"",S_FALSE}
4529         },
4530         {
4531             {Uri_HOST_DNS,S_OK},
4532             /* Still returns 80, even though earlier the port was disabled. */
4533             {80,S_OK},
4534             {URL_SCHEME_HTTP,S_OK},
4535             {URLZONE_INVALID,E_NOTIMPL}
4536         }
4537     },
4538     {   "http://google.com/",0,S_OK,FALSE,
4539         {
4540             {FALSE},
4541         },
4542         /* Instead of getting "TRUE" back as the "hasPort" parameter in GetPort,
4543          * you'll get 122345 instead.
4544          */
4545         {TRUE,122345,222,S_OK,FALSE},
4546         0,S_OK,FALSE,
4547         0,S_OK,FALSE,
4548         0,0,0,S_OK,FALSE,
4549         {
4550             {"http://google.com:222/",S_OK},
4551             {"google.com:222",S_OK},
4552             {"http://google.com:222/",S_OK},
4553             {"google.com",S_OK},
4554             {"",S_FALSE},
4555             {"",S_FALSE},
4556             {"google.com",S_OK},
4557             {"",S_FALSE},
4558             {"/",S_OK},
4559             {"/",S_OK},
4560             {"",S_FALSE},
4561             {"http://google.com:222/",S_OK},
4562             {"http",S_OK},
4563             {"",S_FALSE},
4564             {"",S_FALSE}
4565         },
4566         {
4567             {Uri_HOST_DNS,S_OK},
4568             {222,S_OK},
4569             {URL_SCHEME_HTTP,S_OK},
4570             {URLZONE_INVALID,E_NOTIMPL}
4571         }
4572     },
4573     /* IUri's created with the IUriBuilder can have ports that exceed USHORT_MAX. */
4574     {   "http://google.com/",0,S_OK,FALSE,
4575         {
4576             {FALSE},
4577         },
4578         {TRUE,TRUE,999999,S_OK,FALSE},
4579         0,S_OK,FALSE,
4580         0,S_OK,FALSE,
4581         0,0,0,S_OK,FALSE,
4582         {
4583             {"http://google.com:999999/",S_OK},
4584             {"google.com:999999",S_OK},
4585             {"http://google.com:999999/",S_OK},
4586             {"google.com",S_OK},
4587             {"",S_FALSE},
4588             {"",S_FALSE},
4589             {"google.com",S_OK},
4590             {"",S_FALSE},
4591             {"/",S_OK},
4592             {"/",S_OK},
4593             {"",S_FALSE},
4594             {"http://google.com:999999/",S_OK},
4595             {"http",S_OK},
4596             {"",S_FALSE},
4597             {"",S_FALSE}
4598         },
4599         {
4600             {Uri_HOST_DNS,S_OK},
4601             {999999,S_OK},
4602             {URL_SCHEME_HTTP,S_OK},
4603             {URLZONE_INVALID,E_NOTIMPL}
4604         }
4605     },
4606     {   "http://google.com/",0,S_OK,FALSE,
4607         {
4608             {TRUE,"test","?test",Uri_PROPERTY_QUERY,S_OK,FALSE},
4609         },
4610
4611         {FALSE},
4612         0,S_OK,FALSE,
4613         0,S_OK,FALSE,
4614         0,0,0,S_OK,FALSE,
4615         {
4616             {"http://google.com/?test",S_OK},
4617             {"google.com",S_OK},
4618             {"http://google.com/?test",S_OK},
4619             {"google.com",S_OK},
4620             {"",S_FALSE},
4621             {"",S_FALSE},
4622             {"google.com",S_OK},
4623             {"",S_FALSE},
4624             {"/",S_OK},
4625             {"/?test",S_OK},
4626             {"?test",S_OK},
4627             {"http://google.com/?test",S_OK},
4628             {"http",S_OK},
4629             {"",S_FALSE},
4630             {"",S_FALSE}
4631         },
4632         {
4633             {Uri_HOST_DNS,S_OK},
4634             {80,S_OK},
4635             {URL_SCHEME_HTTP,S_OK},
4636             {URLZONE_INVALID,E_NOTIMPL}
4637         }
4638     },
4639     {   "http://:password@google.com/",0,S_OK,FALSE,
4640         {
4641             {FALSE},
4642         },
4643         {FALSE},
4644         0,S_OK,FALSE,
4645         0,S_OK,FALSE,
4646         0,0,0,S_OK,FALSE,
4647         {
4648             {"http://:password@google.com/",S_OK},
4649             {":password@google.com",S_OK},
4650             {"http://google.com/",S_OK},
4651             {"google.com",S_OK},
4652             {"",S_FALSE},
4653             {"",S_FALSE},
4654             {"google.com",S_OK},
4655             {"password",S_OK},
4656             {"/",S_OK},
4657             {"/",S_OK},
4658             {"",S_FALSE},
4659             {"http://:password@google.com/",S_OK},
4660             {"http",S_OK},
4661             {":password",S_OK},
4662             {"",S_FALSE}
4663         },
4664         {
4665             {Uri_HOST_DNS,S_OK},
4666             {80,S_OK},
4667             {URL_SCHEME_HTTP,S_OK},
4668             {URLZONE_INVALID,E_NOTIMPL}
4669         }
4670     },
4671     /* IUriBuilder doesn't need a base IUri to build a IUri. */
4672     {   NULL,0,S_OK,FALSE,
4673         {
4674             {TRUE,"http",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE},
4675             {TRUE,"google.com",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
4676         },
4677         {FALSE},
4678         0,S_OK,FALSE,
4679         0,S_OK,FALSE,
4680         0,0,0,S_OK,FALSE,
4681         {
4682             {"http://google.com/",S_OK},
4683             {"google.com",S_OK},
4684             {"http://google.com/",S_OK},
4685             {"google.com",S_OK},
4686             {"",S_FALSE},
4687             {"",S_FALSE},
4688             {"google.com",S_OK},
4689             {"",S_FALSE},
4690             {"/",S_OK},
4691             {"/",S_OK},
4692             {"",S_FALSE},
4693             {"http://google.com/",S_OK},
4694             {"http",S_OK},
4695             {"",S_FALSE},
4696             {"",S_FALSE}
4697         },
4698         {
4699             {Uri_HOST_DNS,S_OK},
4700             {80,S_OK},
4701             {URL_SCHEME_HTTP,S_OK},
4702             {URLZONE_INVALID,E_NOTIMPL}
4703         }
4704     },
4705     /* Can't set the scheme name to NULL. */
4706     {   "zip://google.com/",0,S_OK,FALSE,
4707         {
4708             {TRUE,NULL,"zip",Uri_PROPERTY_SCHEME_NAME,E_INVALIDARG,FALSE}
4709         },
4710         {FALSE},
4711         0,S_OK,FALSE,
4712         0,S_OK,FALSE,
4713         0,0,0,S_OK,FALSE,
4714         {
4715             {"zip://google.com/",S_OK},
4716             {"google.com",S_OK},
4717             {"zip://google.com/",S_OK},
4718             {"google.com",S_OK},
4719             {"",S_FALSE},
4720             {"",S_FALSE},
4721             {"google.com",S_OK},
4722             {"",S_FALSE},
4723             {"/",S_OK},
4724             {"/",S_OK},
4725             {"",S_FALSE},
4726             {"zip://google.com/",S_OK},
4727             {"zip",S_OK},
4728             {"",S_FALSE},
4729             {"",S_FALSE}
4730         },
4731         {
4732             {Uri_HOST_DNS,S_OK},
4733             {0,S_FALSE},
4734             {URL_SCHEME_UNKNOWN,S_OK},
4735             {URLZONE_INVALID,E_NOTIMPL}
4736         }
4737     },
4738     /* Can't set the scheme name to an empty string. */
4739     {   "zip://google.com/",0,S_OK,FALSE,
4740         {
4741             {TRUE,"","zip",Uri_PROPERTY_SCHEME_NAME,E_INVALIDARG,FALSE}
4742         },
4743         {FALSE},
4744         0,S_OK,FALSE,
4745         0,S_OK,FALSE,
4746         0,0,0,S_OK,FALSE,
4747         {
4748             {"zip://google.com/",S_OK},
4749             {"google.com",S_OK},
4750             {"zip://google.com/",S_OK},
4751             {"google.com",S_OK},
4752             {"",S_FALSE},
4753             {"",S_FALSE},
4754             {"google.com",S_OK},
4755             {"",S_FALSE},
4756             {"/",S_OK},
4757             {"/",S_OK},
4758             {"",S_FALSE},
4759             {"zip://google.com/",S_OK},
4760             {"zip",S_OK},
4761             {"",S_FALSE},
4762             {"",S_FALSE}
4763         },
4764         {
4765             {Uri_HOST_DNS,S_OK},
4766             {0,S_FALSE},
4767             {URL_SCHEME_UNKNOWN,S_OK},
4768             {URLZONE_INVALID,E_NOTIMPL}
4769         }
4770     },
4771     /* -1 to CreateUri makes it use the same flags as the base IUri was created with.
4772      * CreateUriSimple always uses the flags the base IUri was created with (if any).
4773      */
4774     {   "http://google.com/../../",Uri_CREATE_NO_CANONICALIZE,S_OK,FALSE,
4775         {{FALSE}},
4776         {FALSE},
4777         -1,S_OK,FALSE,
4778         0,S_OK,FALSE,
4779         0,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
4780         {
4781             {"http://google.com/../../",S_OK},
4782             {"google.com",S_OK},
4783             {"http://google.com/../../",S_OK},
4784             {"google.com",S_OK},
4785             {"",S_FALSE},
4786             {"",S_FALSE},
4787             {"google.com",S_OK},
4788             {"",S_FALSE},
4789             {"/../../",S_OK},
4790             {"/../../",S_OK},
4791             {"",S_FALSE},
4792             {"http://google.com/../../",S_OK},
4793             {"http",S_OK},
4794             {"",S_FALSE},
4795             {"",S_FALSE}
4796         },
4797         {
4798             {Uri_HOST_DNS,S_OK},
4799             {80,S_OK},
4800             {URL_SCHEME_HTTP,S_OK},
4801             {URLZONE_INVALID,E_NOTIMPL}
4802         }
4803     },
4804     {   "http://google.com/",0,S_OK,FALSE,
4805         {
4806             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
4807         },
4808         {FALSE},
4809         -1,S_OK,FALSE,
4810         0,S_OK,FALSE,
4811         Uri_CREATE_NO_DECODE_EXTRA_INFO,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
4812         {
4813             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
4814             {"google.com",S_OK},
4815             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
4816             {"google.com",S_OK},
4817             {"",S_FALSE},
4818             {"#Fr%3C%7C%3Eg",S_OK},
4819             {"google.com",S_OK},
4820             {"",S_FALSE},
4821             {"/",S_OK},
4822             {"/",S_OK},
4823             {"",S_FALSE},
4824             {"http://google.com/#Fr<|>g",S_OK},
4825             {"http",S_OK},
4826             {"",S_FALSE},
4827             {"",S_FALSE}
4828         },
4829         {
4830             {Uri_HOST_DNS,S_OK},
4831             {80,S_OK},
4832             {URL_SCHEME_HTTP,S_OK},
4833             {URLZONE_INVALID,E_NOTIMPL}
4834         }
4835     },
4836     {   "http://google.com/",0,S_OK,FALSE,
4837         {
4838             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
4839         },
4840         {FALSE},
4841         Uri_CREATE_CANONICALIZE|Uri_CREATE_NO_CANONICALIZE,E_INVALIDARG,FALSE,
4842         0,S_OK,FALSE,
4843         Uri_CREATE_CANONICALIZE|Uri_CREATE_NO_CANONICALIZE,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
4844         {
4845             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
4846             {"google.com",S_OK},
4847             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
4848             {"google.com",S_OK},
4849             {"",S_FALSE},
4850             {"#Fr%3C%7C%3Eg",S_OK},
4851             {"google.com",S_OK},
4852             {"",S_FALSE},
4853             {"/",S_OK},
4854             {"/",S_OK},
4855             {"",S_FALSE},
4856             {"http://google.com/#Fr<|>g",S_OK},
4857             {"http",S_OK},
4858             {"",S_FALSE},
4859             {"",S_FALSE}
4860         },
4861         {
4862             {Uri_HOST_DNS,S_OK},
4863             {80,S_OK},
4864             {URL_SCHEME_HTTP,S_OK},
4865             {URLZONE_INVALID,E_NOTIMPL}
4866         }
4867     },
4868     {   NULL,0,S_OK,FALSE,
4869         {
4870             {TRUE,"/test/test/",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
4871             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
4872         },
4873         {FALSE},
4874         0,INET_E_INVALID_URL,FALSE,
4875         0,INET_E_INVALID_URL,FALSE,
4876         0,0,0,INET_E_INVALID_URL,FALSE
4877     },
4878     {   "http://google.com/",0,S_OK,FALSE,
4879         {
4880             {TRUE,"ht%xxtp",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE}
4881         },
4882         {FALSE},
4883         0,INET_E_INVALID_URL,FALSE,
4884         0,INET_E_INVALID_URL,FALSE,
4885         0,0,0,INET_E_INVALID_URL,FALSE
4886     },
4887     /* File scheme's can't have a username set. */
4888     {   "file://google.com/",0,S_OK,FALSE,
4889         {
4890             {TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4891         },
4892         {FALSE},
4893         0,INET_E_INVALID_URL,FALSE,
4894         0,INET_E_INVALID_URL,FALSE,
4895         0,0,0,INET_E_INVALID_URL,FALSE
4896     },
4897     /* File schemes can't have a password set. */
4898     {   "file://google.com/",0,S_OK,FALSE,
4899         {
4900             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4901         },
4902         {FALSE},
4903         0,INET_E_INVALID_URL,FALSE,
4904         0,INET_E_INVALID_URL,FALSE,
4905         0,0,0,INET_E_INVALID_URL,FALSE
4906     },
4907     /* UserName can't contain any character that is a delimeter for another
4908      * component that appears after it in a normal URI.
4909      */
4910     {   "http://google.com/",0,S_OK,FALSE,
4911         {
4912             {TRUE,"user:pass",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4913         },
4914         {FALSE},
4915         0,INET_E_INVALID_URL,FALSE,
4916         0,INET_E_INVALID_URL,FALSE,
4917         0,0,0,INET_E_INVALID_URL,FALSE
4918     },
4919     {   "http://google.com/",0,S_OK,FALSE,
4920         {
4921             {TRUE,"user@google.com",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4922         },
4923         {FALSE},
4924         0,INET_E_INVALID_URL,FALSE,
4925         0,INET_E_INVALID_URL,FALSE,
4926         0,0,0,INET_E_INVALID_URL,FALSE
4927     },
4928     {   "http://google.com/",0,S_OK,FALSE,
4929         {
4930             {TRUE,"user/path",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4931         },
4932         {FALSE},
4933         0,INET_E_INVALID_URL,FALSE,
4934         0,INET_E_INVALID_URL,FALSE,
4935         0,0,0,INET_E_INVALID_URL,FALSE
4936     },
4937     {   "http://google.com/",0,S_OK,FALSE,
4938         {
4939             {TRUE,"user?Query",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4940         },
4941         {FALSE},
4942         0,INET_E_INVALID_URL,FALSE,
4943         0,INET_E_INVALID_URL,FALSE,
4944         0,0,0,INET_E_INVALID_URL,FALSE
4945     },
4946     {   "http://google.com/",0,S_OK,FALSE,
4947         {
4948             {TRUE,"user#Frag",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4949         },
4950         {FALSE},
4951         0,INET_E_INVALID_URL,FALSE,
4952         0,INET_E_INVALID_URL,FALSE,
4953         0,0,0,INET_E_INVALID_URL,FALSE
4954     },
4955     {   "http://google.com/",0,S_OK,FALSE,
4956         {
4957             {TRUE,"pass@google.com",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4958         },
4959         {FALSE},
4960         0,INET_E_INVALID_URL,FALSE,
4961         0,INET_E_INVALID_URL,FALSE,
4962         0,0,0,INET_E_INVALID_URL,FALSE
4963     },
4964     {   "http://google.com/",0,S_OK,FALSE,
4965         {
4966             {TRUE,"pass/path",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4967         },
4968         {FALSE},
4969         0,INET_E_INVALID_URL,FALSE,
4970         0,INET_E_INVALID_URL,FALSE,
4971         0,0,0,INET_E_INVALID_URL,FALSE
4972     },
4973     {   "http://google.com/",0,S_OK,FALSE,
4974         {
4975             {TRUE,"pass?query",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4976         },
4977         {FALSE},
4978         0,INET_E_INVALID_URL,FALSE,
4979         0,INET_E_INVALID_URL,FALSE,
4980        0,0,0,INET_E_INVALID_URL,FALSE
4981     },
4982     {   "http://google.com/",0,S_OK,FALSE,
4983         {
4984             {TRUE,"pass#frag",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4985         },
4986         {FALSE},
4987         0,INET_E_INVALID_URL,FALSE,
4988         0,INET_E_INVALID_URL,FALSE,
4989         0,0,0,INET_E_INVALID_URL,FALSE
4990     },
4991     {   "http://google.com/",0,S_OK,FALSE,
4992         {
4993             {TRUE,"winehq.org/test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
4994         },
4995         {FALSE},
4996         0,INET_E_INVALID_URL,FALSE,
4997         0,INET_E_INVALID_URL,FALSE,
4998         0,0,0,INET_E_INVALID_URL,FALSE
4999     },
5000     {   "http://google.com/",0,S_OK,FALSE,
5001         {
5002             {TRUE,"winehq.org?test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5003         },
5004         {FALSE},
5005         0,INET_E_INVALID_URL,FALSE,
5006         0,INET_E_INVALID_URL,FALSE,
5007         0,0,0,INET_E_INVALID_URL,FALSE
5008     },
5009     {   "http://google.com/",0,S_OK,FALSE,
5010         {
5011             {TRUE,"winehq.org#test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5012         },
5013         {FALSE},
5014         0,INET_E_INVALID_URL,FALSE,
5015         0,INET_E_INVALID_URL,FALSE,
5016         0,0,0,INET_E_INVALID_URL,FALSE
5017     },
5018     /* Hostname is allowed to contain a ':' (even for known scheme types). */
5019     {   "http://google.com/",0,S_OK,FALSE,
5020         {
5021             {TRUE,"winehq.org:test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE},
5022         },
5023         {FALSE},
5024         0,S_OK,FALSE,
5025         0,S_OK,FALSE,
5026         0,0,0,S_OK,FALSE,
5027         {
5028             {"http://winehq.org:test/",S_OK},
5029             {"winehq.org:test",S_OK},
5030             {"http://winehq.org:test/",S_OK},
5031             {"winehq.org:test",S_OK},
5032             {"",S_FALSE},
5033             {"",S_FALSE},
5034             {"winehq.org:test",S_OK},
5035             {"",S_FALSE},
5036             {"/",S_OK},
5037             {"/",S_OK},
5038             {"",S_FALSE},
5039             {"http://winehq.org:test/",S_OK},
5040             {"http",S_OK},
5041             {"",S_FALSE},
5042             {"",S_FALSE}
5043         },
5044         {
5045             {Uri_HOST_DNS,S_OK},
5046             {80,S_OK},
5047             {URL_SCHEME_HTTP,S_OK},
5048             {URLZONE_INVALID,E_NOTIMPL}
5049         }
5050     },
5051     /* Can't set the host name to NULL. */
5052     {   "http://google.com/",0,S_OK,FALSE,
5053         {
5054             {TRUE,NULL,"google.com",Uri_PROPERTY_HOST,E_INVALIDARG,FALSE}
5055         },
5056         {FALSE},
5057         0,S_OK,FALSE,
5058         0,S_OK,FALSE,
5059         0,0,0,S_OK,FALSE,
5060         {
5061             {"http://google.com/",S_OK},
5062             {"google.com",S_OK},
5063             {"http://google.com/",S_OK},
5064             {"google.com",S_OK},
5065             {"",S_FALSE},
5066             {"",S_FALSE},
5067             {"google.com",S_OK},
5068             {"",S_FALSE},
5069             {"/",S_OK},
5070             {"/",S_OK},
5071             {"",S_FALSE},
5072             {"http://google.com/",S_OK},
5073             {"http",S_OK},
5074             {"",S_FALSE},
5075             {"",S_FALSE}
5076         },
5077         {
5078             {Uri_HOST_DNS,S_OK},
5079             {80,S_OK},
5080             {URL_SCHEME_HTTP,S_OK},
5081             {URLZONE_INVALID,E_NOTIMPL}
5082         }
5083     },
5084     /* Can set the host name to an empty string. */
5085     {   "http://google.com/",0,S_OK,FALSE,
5086         {
5087             {TRUE,"",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5088         },
5089         {FALSE},
5090         0,S_OK,FALSE,
5091         0,S_OK,FALSE,
5092         0,0,0,S_OK,FALSE,
5093         {
5094             {"http:///",S_OK},
5095             {"",S_OK},
5096             {"http:///",S_OK},
5097             {"",S_FALSE},
5098             {"",S_FALSE},
5099             {"",S_FALSE},
5100             {"",S_OK},
5101             {"",S_FALSE},
5102             {"/",S_OK},
5103             {"/",S_OK},
5104             {"",S_FALSE},
5105             {"http:///",S_OK},
5106             {"http",S_OK},
5107             {"",S_FALSE},
5108             {"",S_FALSE}
5109         },
5110         {
5111             {Uri_HOST_UNKNOWN,S_OK},
5112             {80,S_OK},
5113             {URL_SCHEME_HTTP,S_OK},
5114             {URLZONE_INVALID,E_NOTIMPL}
5115         }
5116     },
5117     {   "http://google.com/",0,S_OK,FALSE,
5118         {
5119             {TRUE,"/path?query",NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
5120         },
5121         {FALSE},
5122         0,INET_E_INVALID_URL,FALSE,
5123         0,INET_E_INVALID_URL,FALSE,
5124         0,0,0,INET_E_INVALID_URL,FALSE
5125     },
5126     {   "http://google.com/",0,S_OK,FALSE,
5127         {
5128             {TRUE,"/path#test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
5129         },
5130         {FALSE},
5131         0,INET_E_INVALID_URL,FALSE,
5132         0,INET_E_INVALID_URL,FALSE,
5133         0,0,0,INET_E_INVALID_URL,FALSE
5134     },
5135     {   "http://google.com/",0,S_OK,FALSE,
5136         {
5137             {TRUE,"?path#test",NULL,Uri_PROPERTY_QUERY,S_OK,FALSE}
5138         },
5139         {FALSE},
5140         0,INET_E_INVALID_URL,FALSE,
5141         0,INET_E_INVALID_URL,FALSE,
5142         0,0,0,INET_E_INVALID_URL,FALSE
5143     }
5144 };
5145
5146 typedef struct _uri_builder_remove_test {
5147     const char  *uri;
5148     DWORD       create_flags;
5149     HRESULT     create_builder_expected;
5150     BOOL        create_builder_todo;
5151
5152     DWORD       remove_properties;
5153     HRESULT     remove_expected;
5154     BOOL        remove_todo;
5155
5156     const char  *expected_uri;
5157     DWORD       expected_flags;
5158     HRESULT     expected_hres;
5159     BOOL        expected_todo;
5160 } uri_builder_remove_test;
5161
5162 static const uri_builder_remove_test uri_builder_remove_tests[] = {
5163     {   "http://google.com/test?test=y#Frag",0,S_OK,FALSE,
5164         Uri_HAS_FRAGMENT|Uri_HAS_PATH|Uri_HAS_QUERY,S_OK,FALSE,
5165         "http://google.com/",0,S_OK,FALSE
5166     },
5167     {   "http://user:pass@winehq.org/",0,S_OK,FALSE,
5168         Uri_HAS_USER_NAME|Uri_HAS_PASSWORD,S_OK,FALSE,
5169         "http://winehq.org/",0,S_OK,FALSE
5170     },
5171     {   "zip://google.com?Test=x",0,S_OK,FALSE,
5172         Uri_HAS_HOST,S_OK,FALSE,
5173         "zip:/?Test=x",0,S_OK,FALSE
5174     },
5175     /* Doesn't remove the whole userinfo component. */
5176     {   "http://username:pass@google.com/",0,S_OK,FALSE,
5177         Uri_HAS_USER_INFO,S_OK,FALSE,
5178         "http://username:pass@google.com/",0,S_OK,FALSE
5179     },
5180     /* Doesn't remove the domain. */
5181     {   "http://google.com/",0,S_OK,FALSE,
5182         Uri_HAS_DOMAIN,S_OK,FALSE,
5183         "http://google.com/",0,S_OK,FALSE
5184     },
5185     {   "http://google.com:120/",0,S_OK,FALSE,
5186         Uri_HAS_AUTHORITY,S_OK,FALSE,
5187         "http://google.com:120/",0,S_OK,FALSE
5188     },
5189     {   "http://google.com/test.com/",0,S_OK,FALSE,
5190         Uri_HAS_EXTENSION,S_OK,FALSE,
5191         "http://google.com/test.com/",0,S_OK,FALSE
5192     },
5193     {   "http://google.com/?test=x",0,S_OK,FALSE,
5194         Uri_HAS_PATH_AND_QUERY,S_OK,FALSE,
5195         "http://google.com/?test=x",0,S_OK,FALSE
5196     },
5197     /* Can't remove the scheme name. */
5198     {   "http://google.com/?test=x",0,S_OK,FALSE,
5199         Uri_HAS_SCHEME_NAME|Uri_HAS_QUERY,E_INVALIDARG,FALSE,
5200         "http://google.com/?test=x",0,S_OK,FALSE
5201     }
5202 };
5203
5204 typedef struct _uri_combine_str_property {
5205     const char  *value;
5206     HRESULT     expected;
5207     BOOL        todo;
5208     const char  *broken_value;
5209     const char  *value_ex;
5210 } uri_combine_str_property;
5211
5212 typedef struct _uri_combine_test {
5213     const char  *base_uri;
5214     DWORD       base_create_flags;
5215     const char  *relative_uri;
5216     DWORD       relative_create_flags;
5217     DWORD       combine_flags;
5218     HRESULT     expected;
5219     BOOL        todo;
5220
5221     uri_combine_str_property    str_props[URI_STR_PROPERTY_COUNT];
5222     uri_dword_property          dword_props[URI_DWORD_PROPERTY_COUNT];
5223 } uri_combine_test;
5224
5225 static const uri_combine_test uri_combine_tests[] = {
5226     {   "http://google.com/fun/stuff",0,
5227         "../not/fun/stuff",Uri_CREATE_ALLOW_RELATIVE,
5228         0,S_OK,FALSE,
5229         {
5230             {"http://google.com/not/fun/stuff",S_OK},
5231             {"google.com",S_OK},
5232             {"http://google.com/not/fun/stuff",S_OK},
5233             {"google.com",S_OK},
5234             {"",S_FALSE},
5235             {"",S_FALSE},
5236             {"google.com",S_OK},
5237             {"",S_FALSE},
5238             {"/not/fun/stuff",S_OK},
5239             {"/not/fun/stuff",S_OK},
5240             {"",S_FALSE},
5241             {"http://google.com/not/fun/stuff",S_OK},
5242             {"http",S_OK},
5243             {"",S_FALSE},
5244             {"",S_FALSE}
5245         },
5246         {
5247             {Uri_HOST_DNS,S_OK},
5248             {80,S_OK},
5249             {URL_SCHEME_HTTP,S_OK},
5250             {URLZONE_INVALID,E_NOTIMPL}
5251         }
5252     },
5253     {   "http://google.com/test",0,
5254         "zip://test.com/cool",0,
5255         0,S_OK,FALSE,
5256         {
5257             {"zip://test.com/cool",S_OK},
5258             {"test.com",S_OK},
5259             {"zip://test.com/cool",S_OK},
5260             {"test.com",S_OK},
5261             {"",S_FALSE},
5262             {"",S_FALSE},
5263             {"test.com",S_OK},
5264             {"",S_FALSE},
5265             {"/cool",S_OK},
5266             {"/cool",S_OK},
5267             {"",S_FALSE},
5268             {"zip://test.com/cool",S_OK},
5269             {"zip",S_OK},
5270             {"",S_FALSE},
5271             {"",S_FALSE}
5272         },
5273         {
5274             {Uri_HOST_DNS,S_OK},
5275             {0,S_FALSE},
5276             {URL_SCHEME_UNKNOWN,S_OK},
5277             {URLZONE_INVALID,E_NOTIMPL}
5278         }
5279     },
5280     {   "http://google.com/use/base/path",0,
5281         "?relative",Uri_CREATE_ALLOW_RELATIVE,
5282         0,S_OK,FALSE,
5283         {
5284             {"http://google.com/use/base/path?relative",S_OK},
5285             {"google.com",S_OK},
5286             {"http://google.com/use/base/path?relative",S_OK},
5287             {"google.com",S_OK},
5288             {"",S_FALSE},
5289             {"",S_FALSE},
5290             {"google.com",S_OK},
5291             {"",S_FALSE},
5292             {"/use/base/path",S_OK},
5293             {"/use/base/path?relative",S_OK},
5294             {"?relative",S_OK},
5295             {"http://google.com/use/base/path?relative",S_OK},
5296             {"http",S_OK},
5297             {"",S_FALSE},
5298             {"",S_FALSE}
5299         },
5300         {
5301             {Uri_HOST_DNS,S_OK},
5302             {80,S_OK},
5303             {URL_SCHEME_HTTP,S_OK},
5304             {URLZONE_INVALID,E_NOTIMPL}
5305         }
5306     },
5307     {   "http://google.com/path",0,
5308         "/test/../test/.././testing",Uri_CREATE_ALLOW_RELATIVE,
5309         0,S_OK,FALSE,
5310         {
5311             {"http://google.com/testing",S_OK},
5312             {"google.com",S_OK},
5313             {"http://google.com/testing",S_OK},
5314             {"google.com",S_OK},
5315             {"",S_FALSE},
5316             {"",S_FALSE},
5317             {"google.com",S_OK},
5318             {"",S_FALSE},
5319             {"/testing",S_OK},
5320             {"/testing",S_OK},
5321             {"",S_FALSE},
5322             {"http://google.com/testing",S_OK},
5323             {"http",S_OK},
5324             {"",S_FALSE},
5325             {"",S_FALSE}
5326         },
5327         {
5328             {Uri_HOST_DNS,S_OK},
5329             {80,S_OK},
5330             {URL_SCHEME_HTTP,S_OK},
5331             {URLZONE_INVALID,E_NOTIMPL}
5332         }
5333     },
5334     {   "http://google.com/path",0,
5335         "/test/../test/.././testing",Uri_CREATE_ALLOW_RELATIVE,
5336         URL_DONT_SIMPLIFY,S_OK,FALSE,
5337         {
5338             {"http://google.com:80/test/../test/.././testing",S_OK},
5339             {"google.com",S_OK},
5340             {"http://google.com:80/test/../test/.././testing",S_OK},
5341             {"google.com",S_OK},
5342             {"",S_FALSE},
5343             {"",S_FALSE},
5344             {"google.com",S_OK},
5345             {"",S_FALSE},
5346             {"/test/../test/.././testing",S_OK},
5347             {"/test/../test/.././testing",S_OK},
5348             {"",S_FALSE},
5349             {"http://google.com:80/test/../test/.././testing",S_OK},
5350             {"http",S_OK},
5351             {"",S_FALSE},
5352             {"",S_FALSE}
5353         },
5354         {
5355             {Uri_HOST_DNS,S_OK},
5356             {80,S_OK},
5357             {URL_SCHEME_HTTP,S_OK},
5358             {URLZONE_INVALID,E_NOTIMPL}
5359         }
5360     },
5361     {   "http://winehq.org/test/abc",0,
5362         "testing/abc/../test",Uri_CREATE_ALLOW_RELATIVE,
5363         0,S_OK,FALSE,
5364         {
5365             {"http://winehq.org/test/testing/test",S_OK},
5366             {"winehq.org",S_OK},
5367             {"http://winehq.org/test/testing/test",S_OK},
5368             {"winehq.org",S_OK},
5369             {"",S_FALSE},
5370             {"",S_FALSE},
5371             {"winehq.org",S_OK},
5372             {"",S_FALSE},
5373             {"/test/testing/test",S_OK},
5374             {"/test/testing/test",S_OK},
5375             {"",S_FALSE},
5376             {"http://winehq.org/test/testing/test",S_OK},
5377             {"http",S_OK},
5378             {"",S_FALSE},
5379             {"",S_FALSE}
5380         },
5381         {
5382             {Uri_HOST_DNS,S_OK},
5383             {80,S_OK},
5384             {URL_SCHEME_HTTP,S_OK},
5385             {URLZONE_INVALID,E_NOTIMPL}
5386         }
5387     },
5388     {   "http://winehq.org/test/abc",0,
5389         "testing/abc/../test",Uri_CREATE_ALLOW_RELATIVE,
5390         URL_DONT_SIMPLIFY,S_OK,FALSE,
5391         {
5392             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5393             /* Default port is hidden in the authority. */
5394             {"winehq.org",S_OK},
5395             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5396             {"winehq.org",S_OK},
5397             {"",S_FALSE},
5398             {"",S_FALSE},
5399             {"winehq.org",S_OK},
5400             {"",S_FALSE},
5401             {"/test/testing/abc/../test",S_OK},
5402             {"/test/testing/abc/../test",S_OK},
5403             {"",S_FALSE},
5404             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5405             {"http",S_OK},
5406             {"",S_FALSE},
5407             {"",S_FALSE}
5408         },
5409         {
5410             {Uri_HOST_DNS,S_OK},
5411             {80,S_OK},
5412             {URL_SCHEME_HTTP,S_OK},
5413             {URLZONE_INVALID,E_NOTIMPL}
5414         }
5415     },
5416     {   "http://winehq.org/test?query",0,
5417         "testing",Uri_CREATE_ALLOW_RELATIVE,
5418         0,S_OK,FALSE,
5419         {
5420             {"http://winehq.org/testing",S_OK},
5421             {"winehq.org",S_OK},
5422             {"http://winehq.org/testing",S_OK},
5423             {"winehq.org",S_OK},
5424             {"",S_FALSE},
5425             {"",S_FALSE},
5426             {"winehq.org",S_OK},
5427             {"",S_FALSE},
5428             {"/testing",S_OK},
5429             {"/testing",S_OK},
5430             {"",S_FALSE},
5431             {"http://winehq.org/testing",S_OK},
5432             {"http",S_OK},
5433             {"",S_FALSE},
5434             {"",S_FALSE}
5435         },
5436         {
5437             {Uri_HOST_DNS,S_OK},
5438             {80,S_OK},
5439             {URL_SCHEME_HTTP,S_OK},
5440             {URLZONE_INVALID,E_NOTIMPL}
5441         }
5442     },
5443     {   "http://winehq.org/test#frag",0,
5444         "testing",Uri_CREATE_ALLOW_RELATIVE,
5445         0,S_OK,FALSE,
5446         {
5447             {"http://winehq.org/testing",S_OK},
5448             {"winehq.org",S_OK},
5449             {"http://winehq.org/testing",S_OK},
5450             {"winehq.org",S_OK},
5451             {"",S_FALSE},
5452             {"",S_FALSE},
5453             {"winehq.org",S_OK},
5454             {"",S_FALSE},
5455             {"/testing",S_OK},
5456             {"/testing",S_OK},
5457             {"",S_FALSE},
5458             {"http://winehq.org/testing",S_OK},
5459             {"http",S_OK},
5460             {"",S_FALSE},
5461             {"",S_FALSE}
5462         },
5463         {
5464             {Uri_HOST_DNS,S_OK},
5465             {80,S_OK},
5466             {URL_SCHEME_HTTP,S_OK},
5467             {URLZONE_INVALID,E_NOTIMPL}
5468         }
5469     },
5470     {   "testing?query#frag",Uri_CREATE_ALLOW_RELATIVE,
5471         "test",Uri_CREATE_ALLOW_RELATIVE,
5472         0,S_OK,FALSE,
5473         {
5474             {"test",S_OK},
5475             {"",S_FALSE},
5476             {"test",S_OK},
5477             {"",S_FALSE},
5478             {"",S_FALSE},
5479             {"",S_FALSE},
5480             {"",S_FALSE},
5481             {"",S_FALSE},
5482             {"test",S_OK},
5483             {"test",S_OK},
5484             {"",S_FALSE},
5485             {"test",S_OK},
5486             {"",S_FALSE},
5487             {"",S_FALSE},
5488             {"",S_FALSE}
5489         },
5490         {
5491             {Uri_HOST_UNKNOWN,S_OK},
5492             {0,S_FALSE},
5493             {URL_SCHEME_UNKNOWN,S_OK},
5494             {URLZONE_INVALID,E_NOTIMPL}
5495         }
5496     },
5497     {   "file:///c:/test/test",0,
5498         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
5499         URL_FILE_USE_PATHURL,S_OK,FALSE,
5500         {
5501             {"file://c:\\testing.mp3",S_OK},
5502             {"",S_FALSE},
5503             {"file://c:\\testing.mp3",S_OK},
5504             {"",S_FALSE},
5505             {".mp3",S_OK},
5506             {"",S_FALSE},
5507             {"",S_FALSE},
5508             {"",S_FALSE},
5509             {"c:\\testing.mp3",S_OK},
5510             {"c:\\testing.mp3",S_OK},
5511             {"",S_FALSE},
5512             {"file://c:\\testing.mp3",S_OK},
5513             {"file",S_OK},
5514             {"",S_FALSE},
5515             {"",S_FALSE}
5516         },
5517         {
5518             {Uri_HOST_UNKNOWN,S_OK},
5519             {0,S_FALSE},
5520             {URL_SCHEME_FILE,S_OK},
5521             {URLZONE_INVALID,E_NOTIMPL}
5522         }
5523     },
5524     {   "file:///c:/test/test",0,
5525         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
5526         0,S_OK,FALSE,
5527         {
5528             {"file:///c:/testing.mp3",S_OK},
5529             {"",S_FALSE},
5530             {"file:///c:/testing.mp3",S_OK},
5531             {"",S_FALSE},
5532             {".mp3",S_OK},
5533             {"",S_FALSE},
5534             {"",S_FALSE},
5535             {"",S_FALSE},
5536             {"/c:/testing.mp3",S_OK},
5537             {"/c:/testing.mp3",S_OK},
5538             {"",S_FALSE},
5539             {"file:///c:/testing.mp3",S_OK},
5540             {"file",S_OK},
5541             {"",S_FALSE},
5542             {"",S_FALSE}
5543         },
5544         {
5545             {Uri_HOST_UNKNOWN,S_OK},
5546             {0,S_FALSE},
5547             {URL_SCHEME_FILE,S_OK},
5548             {URLZONE_INVALID,E_NOTIMPL}
5549         }
5550     },
5551     {   "file://test.com/test/test",0,
5552         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
5553         URL_FILE_USE_PATHURL,S_OK,FALSE,
5554         {
5555             {"file://\\\\test.com\\testing.mp3",S_OK},
5556             {"test.com",S_OK},
5557             {"file://\\\\test.com\\testing.mp3",S_OK},
5558             {"test.com",S_OK},
5559             {".mp3",S_OK},
5560             {"",S_FALSE},
5561             {"test.com",S_OK},
5562             {"",S_FALSE},
5563             {"\\testing.mp3",S_OK},
5564             {"\\testing.mp3",S_OK},
5565             {"",S_FALSE},
5566             {"file://\\\\test.com\\testing.mp3",S_OK},
5567             {"file",S_OK},
5568             {"",S_FALSE},
5569             {"",S_FALSE}
5570         },
5571         {
5572             {Uri_HOST_DNS,S_OK},
5573             {0,S_FALSE},
5574             {URL_SCHEME_FILE,S_OK},
5575             {URLZONE_INVALID,E_NOTIMPL}
5576         }
5577     },
5578     /* URL_DONT_SIMPLIFY has no effect. */
5579     {   "http://google.com/test",0,
5580         "zip://test.com/cool/../cool/test",0,
5581         URL_DONT_SIMPLIFY,S_OK,FALSE,
5582         {
5583             {"zip://test.com/cool/test",S_OK,FALSE,NULL,"zip://test.com/cool/../cool/test"},
5584             {"test.com",S_OK},
5585             {"zip://test.com/cool/test",S_OK,FALSE,NULL,"zip://test.com/cool/../cool/test"},
5586             {"test.com",S_OK},
5587             {"",S_FALSE},
5588             {"",S_FALSE},
5589             {"test.com",S_OK},
5590             {"",S_FALSE},
5591             {"/cool/test",S_OK,FALSE,NULL,"/cool/../cool/test"},
5592             {"/cool/test",S_OK,FALSE,NULL,"/cool/../cool/test"},
5593             {"",S_FALSE},
5594             /* The resulting IUri has the same Raw URI as the relative URI (only IE 8).
5595              * On IE 7 it reduces the path in the Raw URI.
5596              */
5597             {"zip://test.com/cool/../cool/test",S_OK,FALSE,"zip://test.com/cool/test"},
5598             {"zip",S_OK},
5599             {"",S_FALSE},
5600             {"",S_FALSE}
5601         },
5602         {
5603             {Uri_HOST_DNS,S_OK},
5604             {0,S_FALSE},
5605             {URL_SCHEME_UNKNOWN,S_OK},
5606             {URLZONE_INVALID,E_NOTIMPL}
5607         }
5608     },
5609     /* FILE_USE_PATHURL has no effect in IE 8, in IE 7 the
5610      * resulting URI is converted into a dos path.
5611      */
5612     {   "http://google.com/test",0,
5613         "file:///c:/test/",0,
5614         URL_FILE_USE_PATHURL,S_OK,FALSE,
5615         {
5616             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
5617             {"",S_FALSE},
5618             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
5619             {"",S_FALSE},
5620             {"",S_FALSE},
5621             {"",S_FALSE},
5622             {"",S_FALSE},
5623             {"",S_FALSE},
5624             {"/c:/test/",S_OK,FALSE,"c:\\test\\"},
5625             {"/c:/test/",S_OK,FALSE,"c:\\test\\"},
5626             {"",S_FALSE},
5627             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
5628             {"file",S_OK},
5629             {"",S_FALSE},
5630             {"",S_FALSE}
5631         },
5632         {
5633             {Uri_HOST_UNKNOWN,S_OK},
5634             {0,S_FALSE},
5635             {URL_SCHEME_FILE,S_OK},
5636             {URLZONE_INVALID,E_NOTIMPL}
5637         }
5638     },
5639     {   "http://google.com/test",0,
5640         "http://test.com/test#%30test",0,
5641         URL_DONT_UNESCAPE_EXTRA_INFO,S_OK,FALSE,
5642         {
5643             {"http://test.com/test#0test",S_OK,FALSE,NULL,"http://test.com/test#%30test"},
5644             {"test.com",S_OK},
5645             {"http://test.com/test#0test",S_OK,FALSE,NULL,"http://test.com/test#%30test"},
5646             {"test.com",S_OK},
5647             {"",S_FALSE},
5648             {"#0test",S_OK,FALSE,NULL,"#%30test"},
5649             {"test.com",S_OK},
5650             {"",S_FALSE},
5651             {"/test",S_OK},
5652             {"/test",S_OK},
5653             {"",S_FALSE},
5654             /* IE 7 decodes the %30 to a 0 in the Raw URI. */
5655             {"http://test.com/test#%30test",S_OK,FALSE,"http://test.com/test#0test"},
5656             {"http",S_OK},
5657             {"",S_FALSE},
5658             {"",S_FALSE}
5659         },
5660         {
5661             {Uri_HOST_DNS,S_OK},
5662             {80,S_OK},
5663             {URL_SCHEME_HTTP,S_OK},
5664             {URLZONE_INVALID,E_NOTIMPL}
5665         }
5666     },
5667     /* Windows validates the path component from the relative Uri. */
5668     {   "http://google.com/test",0,
5669         "/Te%XXst",Uri_CREATE_ALLOW_RELATIVE,
5670         0,E_INVALIDARG,FALSE
5671     },
5672     /* Windows doesn't validate the query from the relative Uri. */
5673     {   "http://google.com/test",0,
5674         "?Tes%XXt",Uri_CREATE_ALLOW_RELATIVE,
5675         0,S_OK,FALSE,
5676         {
5677             {"http://google.com/test?Tes%XXt",S_OK},
5678             {"google.com",S_OK},
5679             {"http://google.com/test?Tes%XXt",S_OK},
5680             {"google.com",S_OK},
5681             {"",S_FALSE},
5682             {"",S_FALSE},
5683             {"google.com",S_OK},
5684             {"",S_FALSE},
5685             {"/test",S_OK},
5686             {"/test?Tes%XXt",S_OK},
5687             {"?Tes%XXt",S_OK},
5688             {"http://google.com/test?Tes%XXt",S_OK},
5689             {"http",S_OK},
5690             {"",S_FALSE},
5691             {"",S_FALSE}
5692         },
5693         {
5694             {Uri_HOST_DNS,S_OK},
5695             {80,S_OK},
5696             {URL_SCHEME_HTTP,S_OK},
5697             {URLZONE_INVALID,E_NOTIMPL}
5698         }
5699     },
5700     /* Windows doesn't validate the fragment from the relative Uri. */
5701     {   "http://google.com/test",0,
5702         "#Tes%XXt",Uri_CREATE_ALLOW_RELATIVE,
5703         0,S_OK,FALSE,
5704         {
5705             {"http://google.com/test#Tes%XXt",S_OK},
5706             {"google.com",S_OK},
5707             {"http://google.com/test#Tes%XXt",S_OK},
5708             {"google.com",S_OK},
5709             {"",S_FALSE},
5710             {"#Tes%XXt",S_OK},
5711             {"google.com",S_OK},
5712             {"",S_FALSE},
5713             {"/test",S_OK},
5714             {"/test",S_OK},
5715             {"",S_FALSE},
5716             {"http://google.com/test#Tes%XXt",S_OK},
5717             {"http",S_OK},
5718             {"",S_FALSE},
5719             {"",S_FALSE}
5720         },
5721         {
5722             {Uri_HOST_DNS,S_OK},
5723             {80,S_OK},
5724             {URL_SCHEME_HTTP,S_OK},
5725             {URLZONE_INVALID,E_NOTIMPL}
5726         }
5727     },
5728     /* Creates an IUri which contains an invalid dos path char. */
5729     {   "file:///c:/test",0,
5730         "/test<ing",Uri_CREATE_ALLOW_RELATIVE,
5731         URL_FILE_USE_PATHURL,S_OK,FALSE,
5732         {
5733             {"file://c:\\test<ing",S_OK},
5734             {"",S_FALSE},
5735             {"file://c:\\test<ing",S_OK},
5736             {"",S_FALSE},
5737             {"",S_FALSE},
5738             {"",S_FALSE},
5739             {"",S_FALSE},
5740             {"",S_FALSE},
5741             {"c:\\test<ing",S_OK},
5742             {"c:\\test<ing",S_OK},
5743             {"",S_FALSE},
5744             {"file://c:\\test<ing",S_OK},
5745             {"file",S_OK},
5746             {"",S_FALSE},
5747             {"",S_FALSE}
5748         },
5749         {
5750             {Uri_HOST_UNKNOWN,S_OK},
5751             {0,S_FALSE},
5752             {URL_SCHEME_FILE,S_OK},
5753             {URLZONE_INVALID,E_NOTIMPL}
5754         }
5755     },
5756     /* Appends the path after the drive letter (if any). */
5757     {   "file:///c:/test",0,
5758         "/c:/testing",Uri_CREATE_ALLOW_RELATIVE,
5759         0,S_OK,FALSE,
5760         {
5761             {"file:///c:/c:/testing",S_OK},
5762             {"",S_FALSE},
5763             {"file:///c:/c:/testing",S_OK},
5764             {"",S_FALSE},
5765             {"",S_FALSE},
5766             {"",S_FALSE},
5767             {"",S_FALSE},
5768             {"",S_FALSE},
5769             {"/c:/c:/testing",S_OK},
5770             {"/c:/c:/testing",S_OK},
5771             {"",S_FALSE},
5772             {"file:///c:/c:/testing",S_OK},
5773             {"file",S_OK},
5774             {"",S_FALSE},
5775             {"",S_FALSE}
5776         },
5777         {
5778             {Uri_HOST_UNKNOWN,S_OK},
5779             {0,S_FALSE},
5780             {URL_SCHEME_FILE,S_OK},
5781             {URLZONE_INVALID,E_NOTIMPL}
5782         }
5783     },
5784     /* A '/' is added if the base URI doesn't have a path and the
5785      * relative URI doesn't contain a path (since the base URI is
5786      * hierarchical.
5787      */
5788     {   "http://google.com",Uri_CREATE_NO_CANONICALIZE,
5789         "?test",Uri_CREATE_ALLOW_RELATIVE,
5790         0,S_OK,FALSE,
5791         {
5792             {"http://google.com/?test",S_OK},
5793             {"google.com",S_OK},
5794             {"http://google.com/?test",S_OK},
5795             {"google.com",S_OK},
5796             {"",S_FALSE},
5797             {"",S_FALSE},
5798             {"google.com",S_OK},
5799             {"",S_FALSE},
5800             {"/",S_OK},
5801             {"/?test",S_OK},
5802             {"?test",S_OK},
5803             {"http://google.com/?test",S_OK},
5804             {"http",S_OK},
5805             {"",S_FALSE},
5806             {"",S_FALSE}
5807         },
5808         {
5809             {Uri_HOST_DNS,S_OK},
5810             {80,S_OK},
5811             {URL_SCHEME_HTTP,S_OK},
5812             {URLZONE_INVALID,E_NOTIMPL}
5813         }
5814     },
5815     {   "zip://google.com",Uri_CREATE_NO_CANONICALIZE,
5816         "?test",Uri_CREATE_ALLOW_RELATIVE,
5817         0,S_OK,FALSE,
5818         {
5819             {"zip://google.com/?test",S_OK},
5820             {"google.com",S_OK},
5821             {"zip://google.com/?test",S_OK},
5822             {"google.com",S_OK},
5823             {"",S_FALSE},
5824             {"",S_FALSE},
5825             {"google.com",S_OK},
5826             {"",S_FALSE},
5827             {"/",S_OK},
5828             {"/?test",S_OK},
5829             {"?test",S_OK},
5830             {"zip://google.com/?test",S_OK},
5831             {"zip",S_OK},
5832             {"",S_FALSE},
5833             {"",S_FALSE}
5834         },
5835         {
5836             {Uri_HOST_DNS,S_OK},
5837             {0,S_FALSE},
5838             {URL_SCHEME_UNKNOWN,S_OK},
5839             {URLZONE_INVALID,E_NOTIMPL}
5840         }
5841     },
5842     /* No path is appended since the base URI is opaque. */
5843     {   "zip:?testing",0,
5844         "?test",Uri_CREATE_ALLOW_RELATIVE,
5845         0,S_OK,FALSE,
5846         {
5847             {"zip:?test",S_OK},
5848             {"",S_FALSE},
5849             {"zip:?test",S_OK},
5850             {"",S_FALSE},
5851             {"",S_FALSE},
5852             {"",S_FALSE},
5853             {"",S_FALSE},
5854             {"",S_FALSE},
5855             {"",S_OK},
5856             {"?test",S_OK},
5857             {"?test",S_OK},
5858             {"zip:?test",S_OK},
5859             {"zip",S_OK},
5860             {"",S_FALSE},
5861             {"",S_FALSE}
5862         },
5863         {
5864             {Uri_HOST_UNKNOWN,S_OK},
5865             {0,S_FALSE},
5866             {URL_SCHEME_UNKNOWN,S_OK},
5867             {URLZONE_INVALID,E_NOTIMPL}
5868         }
5869     },
5870     {   "file:///c:/",0,
5871         "../testing/test",Uri_CREATE_ALLOW_RELATIVE,
5872         0,S_OK,FALSE,
5873         {
5874             {"file:///c:/testing/test",S_OK},
5875             {"",S_FALSE},
5876             {"file:///c:/testing/test",S_OK},
5877             {"",S_FALSE},
5878             {"",S_FALSE},
5879             {"",S_FALSE},
5880             {"",S_FALSE},
5881             {"",S_FALSE},
5882             {"/c:/testing/test",S_OK},
5883             {"/c:/testing/test",S_OK},
5884             {"",S_FALSE},
5885             {"file:///c:/testing/test",S_OK},
5886             {"file",S_OK},
5887             {"",S_FALSE},
5888             {"",S_FALSE}
5889         },
5890         {
5891             {Uri_HOST_UNKNOWN,S_OK},
5892             {0,S_FALSE},
5893             {URL_SCHEME_FILE,S_OK},
5894             {URLZONE_INVALID,E_NOTIMPL}
5895         }
5896     }
5897 };
5898
5899 static inline LPWSTR a2w(LPCSTR str) {
5900     LPWSTR ret = NULL;
5901
5902     if(str) {
5903         DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
5904         ret = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
5905         MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
5906     }
5907
5908     return ret;
5909 }
5910
5911 static inline BOOL heap_free(void* mem) {
5912     return HeapFree(GetProcessHeap(), 0, mem);
5913 }
5914
5915 static inline DWORD strcmp_aw(LPCSTR strA, LPCWSTR strB) {
5916     LPWSTR strAW = a2w(strA);
5917     DWORD ret = lstrcmpW(strAW, strB);
5918     heap_free(strAW);
5919     return ret;
5920 }
5921
5922 static inline ULONG get_refcnt(IUri *uri) {
5923     IUri_AddRef(uri);
5924     return IUri_Release(uri);
5925 }
5926
5927 static void change_property(IUriBuilder *builder, const uri_builder_property *prop,
5928                             DWORD test_index) {
5929     HRESULT hr;
5930     LPWSTR valueW;
5931
5932     valueW = a2w(prop->value);
5933     switch(prop->property) {
5934     case Uri_PROPERTY_FRAGMENT:
5935         hr = IUriBuilder_SetFragment(builder, valueW);
5936         if(prop->todo) {
5937             todo_wine {
5938                 ok(hr == prop->expected,
5939                     "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
5940                     hr, prop->expected, test_index);
5941             }
5942         } else {
5943             ok(hr == prop->expected,
5944                 "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
5945                 hr, prop->expected, test_index);
5946         }
5947         break;
5948     case Uri_PROPERTY_HOST:
5949         hr = IUriBuilder_SetHost(builder, valueW);
5950         if(prop->todo) {
5951             todo_wine {
5952                 ok(hr == prop->expected,
5953                     "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
5954                     hr, prop->expected, test_index);
5955             }
5956         } else {
5957             ok(hr == prop->expected,
5958                 "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
5959                 hr, prop->expected, test_index);
5960         }
5961         break;
5962     case Uri_PROPERTY_PASSWORD:
5963         hr = IUriBuilder_SetPassword(builder, valueW);
5964         if(prop->todo) {
5965             todo_wine {
5966                 ok(hr == prop->expected,
5967                     "Error: IUriBuilder_SetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
5968                     hr, prop->expected, test_index);
5969             }
5970         } else {
5971             ok(hr == prop->expected,
5972                 "Error: IUriBuilder_SetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
5973                 hr, prop->expected, test_index);
5974         }
5975         break;
5976     case Uri_PROPERTY_PATH:
5977         hr = IUriBuilder_SetPath(builder, valueW);
5978         if(prop->todo) {
5979             todo_wine {
5980                 ok(hr == prop->expected,
5981                     "Error: IUriBuilder_SetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
5982                     hr, prop->expected, test_index);
5983             }
5984         } else {
5985             ok(hr == prop->expected,
5986                 "Error: IUriBuilder_SetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
5987                 hr, prop->expected, test_index);
5988         }
5989         break;
5990     case Uri_PROPERTY_QUERY:
5991         hr = IUriBuilder_SetQuery(builder, valueW);
5992         if(prop->todo) {
5993             todo_wine {
5994                 ok(hr == prop->expected,
5995                     "Error: IUriBuilder_SetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
5996                     hr, prop->expected, test_index);
5997             }
5998         } else {
5999             ok(hr == prop->expected,
6000                 "Error: IUriBuilder_SetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6001                 hr, prop->expected, test_index);
6002         }
6003         break;
6004     case Uri_PROPERTY_SCHEME_NAME:
6005         hr = IUriBuilder_SetSchemeName(builder, valueW);
6006         if(prop->todo) {
6007             todo_wine {
6008                 ok(hr == prop->expected,
6009                     "Error: IUriBuilder_SetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6010                     hr, prop->expected, test_index);
6011             }
6012         } else {
6013             ok(hr == prop->expected,
6014                 "Error: IUriBuilder_SetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6015                 hr, prop->expected, test_index);
6016         }
6017         break;
6018     case Uri_PROPERTY_USER_NAME:
6019         hr = IUriBuilder_SetUserName(builder, valueW);
6020         if(prop->todo) {
6021             todo_wine {
6022                 ok(hr == prop->expected,
6023                     "Error: IUriBuilder_SetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6024                     hr, prop->expected, test_index);
6025             }
6026         } else {
6027             ok(hr == prop->expected,
6028                 "Error: IUriBuilder_SetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6029                 hr, prop->expected, test_index);
6030         }
6031         break;
6032     default:
6033         trace("Unsupported operation for %d on uri_builder_tests[%d].\n", prop->property, test_index);
6034     }
6035
6036     heap_free(valueW);
6037 }
6038
6039 /*
6040  * Simple tests to make sure the CreateUri function handles invalid flag combinations
6041  * correctly.
6042  */
6043 static void test_CreateUri_InvalidFlags(void) {
6044     DWORD i;
6045
6046     for(i = 0; i < sizeof(invalid_flag_tests)/sizeof(invalid_flag_tests[0]); ++i) {
6047         HRESULT hr;
6048         IUri *uri = (void*) 0xdeadbeef;
6049
6050         hr = pCreateUri(http_urlW, invalid_flag_tests[i].flags, 0, &uri);
6051         ok(hr == invalid_flag_tests[i].expected, "Error: CreateUri returned 0x%08x, expected 0x%08x, flags=0x%08x\n",
6052                 hr, invalid_flag_tests[i].expected, invalid_flag_tests[i].flags);
6053         ok(uri == NULL, "Error: expected the IUri to be NULL, but it was %p instead\n", uri);
6054     }
6055 }
6056
6057 static void test_CreateUri_InvalidArgs(void) {
6058     HRESULT hr;
6059     IUri *uri = (void*) 0xdeadbeef;
6060
6061     const WCHAR invalidW[] = {'i','n','v','a','l','i','d',0};
6062     static const WCHAR emptyW[] = {0};
6063
6064     hr = pCreateUri(http_urlW, 0, 0, NULL);
6065     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG);
6066
6067     hr = pCreateUri(NULL, 0, 0, &uri);
6068     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG);
6069     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6070
6071     uri = (void*) 0xdeadbeef;
6072     hr = pCreateUri(invalidW, 0, 0, &uri);
6073     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6074     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6075
6076     uri = (void*) 0xdeadbeef;
6077     hr = pCreateUri(emptyW, 0, 0, &uri);
6078     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6079     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6080 }
6081
6082 static void test_CreateUri_InvalidUri(void) {
6083     DWORD i;
6084
6085     for(i = 0; i < sizeof(invalid_uri_tests)/sizeof(invalid_uri_tests[0]); ++i) {
6086         invalid_uri test = invalid_uri_tests[i];
6087         IUri *uri = NULL;
6088         LPWSTR uriW;
6089         HRESULT hr;
6090
6091         uriW = a2w(test.uri);
6092         hr = pCreateUri(uriW, test.flags, 0, &uri);
6093         if(test.todo) {
6094             todo_wine {
6095                 ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x on invalid_uri_tests[%d].\n",
6096                     hr, E_INVALIDARG, i);
6097             }
6098         } else {
6099             ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x on invalid_uri_tests[%d].\n",
6100                 hr, E_INVALIDARG, i);
6101         }
6102         if(uri) IUri_Release(uri);
6103
6104         heap_free(uriW);
6105     }
6106 }
6107
6108 static void test_IUri_GetPropertyBSTR(void) {
6109     IUri *uri = NULL;
6110     HRESULT hr;
6111     DWORD i;
6112
6113     /* Make sure GetPropertyBSTR handles invalid args correctly. */
6114     hr = pCreateUri(http_urlW, 0, 0, &uri);
6115     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6116     if(SUCCEEDED(hr)) {
6117         BSTR received = NULL;
6118
6119         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_RAW_URI, NULL, 0);
6120         ok(hr == E_POINTER, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6121
6122         /* Make sure it handles a invalid Uri_PROPERTY's correctly. */
6123         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_PORT, &received, 0);
6124         ok(hr == S_OK, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6125         ok(received != NULL, "Error: Expected the string not to be NULL.\n");
6126         ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
6127         SysFreeString(received);
6128
6129         /* Make sure it handles the ZONE property correctly. */
6130         received = NULL;
6131         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_ZONE, &received, 0);
6132         ok(hr == S_FALSE, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_FALSE);
6133         ok(received != NULL, "Error: Expected the string not to be NULL.\n");
6134         ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
6135         SysFreeString(received);
6136     }
6137     if(uri) IUri_Release(uri);
6138
6139     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6140         uri_properties test = uri_tests[i];
6141         LPWSTR uriW;
6142         uri = NULL;
6143
6144         uriW = a2w(test.uri);
6145         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6146         if(test.create_todo) {
6147             todo_wine {
6148                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6149                         hr, test.create_expected, i);
6150             }
6151         } else {
6152             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6153                     hr, test.create_expected, i);
6154         }
6155
6156         if(SUCCEEDED(hr)) {
6157             DWORD j;
6158
6159             /* Checks all the string properties of the uri. */
6160             for(j = Uri_PROPERTY_STRING_START; j <= Uri_PROPERTY_STRING_LAST; ++j) {
6161                 BSTR received = NULL;
6162                 uri_str_property prop = test.str_props[j];
6163
6164                 hr = IUri_GetPropertyBSTR(uri, j, &received, 0);
6165                 if(prop.todo) {
6166                     todo_wine {
6167                         ok(hr == prop.expected, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
6168                                 hr, prop.expected, i, j);
6169                     }
6170                     todo_wine {
6171                         ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6172                                 "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
6173                                 prop.value, wine_dbgstr_w(received), i, j);
6174                     }
6175                 } else {
6176                     ok(hr == prop.expected, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
6177                             hr, prop.expected, i, j);
6178                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6179                             "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
6180                             prop.value, wine_dbgstr_w(received), i, j);
6181                 }
6182
6183                 SysFreeString(received);
6184             }
6185         }
6186
6187         if(uri) IUri_Release(uri);
6188
6189         heap_free(uriW);
6190     }
6191 }
6192
6193 static void test_IUri_GetPropertyDWORD(void) {
6194     IUri *uri = NULL;
6195     HRESULT hr;
6196     DWORD i;
6197
6198     hr = pCreateUri(http_urlW, 0, 0, &uri);
6199     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6200     if(SUCCEEDED(hr)) {
6201         DWORD received = 0xdeadbeef;
6202
6203         hr = IUri_GetPropertyDWORD(uri, Uri_PROPERTY_DWORD_START, NULL, 0);
6204         ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6205
6206         hr = IUri_GetPropertyDWORD(uri, Uri_PROPERTY_ABSOLUTE_URI, &received, 0);
6207         ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6208         ok(received == 0, "Error: Expected received=%d but instead received=%d.\n", 0, received);
6209     }
6210     if(uri) IUri_Release(uri);
6211
6212     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6213         uri_properties test = uri_tests[i];
6214         LPWSTR uriW;
6215         uri = NULL;
6216
6217         uriW = a2w(test.uri);
6218         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6219         if(test.create_todo) {
6220             todo_wine {
6221                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6222                         hr, test.create_expected, i);
6223             }
6224         } else {
6225             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6226                     hr, test.create_expected, i);
6227         }
6228
6229         if(SUCCEEDED(hr)) {
6230             DWORD j;
6231
6232             /* Checks all the DWORD properties of the uri. */
6233             for(j = 0; j < sizeof(test.dword_props)/sizeof(test.dword_props[0]); ++j) {
6234                 DWORD received;
6235                 uri_dword_property prop = test.dword_props[j];
6236
6237                 hr = IUri_GetPropertyDWORD(uri, j+Uri_PROPERTY_DWORD_START, &received, 0);
6238                 if(prop.todo) {
6239                     todo_wine {
6240                         ok(hr == prop.expected, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
6241                                 hr, prop.expected, i, j);
6242                     }
6243                     todo_wine {
6244                         ok(prop.value == received, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
6245                                 prop.value, received, i, j);
6246                     }
6247                 } else {
6248                     ok(hr == prop.expected, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
6249                             hr, prop.expected, i, j);
6250                     ok(prop.value == received, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
6251                             prop.value, received, i, j);
6252                 }
6253             }
6254         }
6255
6256         if(uri) IUri_Release(uri);
6257
6258         heap_free(uriW);
6259     }
6260 }
6261
6262 /* Tests all the 'Get*' property functions which deal with strings. */
6263 static void test_IUri_GetStrProperties(void) {
6264     IUri *uri = NULL;
6265     HRESULT hr;
6266     DWORD i;
6267
6268     /* Make sure all the 'Get*' string property functions handle invalid args correctly. */
6269     hr = pCreateUri(http_urlW, 0, 0, &uri);
6270     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6271     if(SUCCEEDED(hr)) {
6272         hr = IUri_GetAbsoluteUri(uri, NULL);
6273         ok(hr == E_POINTER, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6274
6275         hr = IUri_GetAuthority(uri, NULL);
6276         ok(hr == E_POINTER, "Error: GetAuthority returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6277
6278         hr = IUri_GetDisplayUri(uri, NULL);
6279         ok(hr == E_POINTER, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6280
6281         hr = IUri_GetDomain(uri, NULL);
6282         ok(hr == E_POINTER, "Error: GetDomain returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6283
6284         hr = IUri_GetExtension(uri, NULL);
6285         ok(hr == E_POINTER, "Error: GetExtension returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6286
6287         hr = IUri_GetFragment(uri, NULL);
6288         ok(hr == E_POINTER, "Error: GetFragment returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6289
6290         hr = IUri_GetHost(uri, NULL);
6291         ok(hr == E_POINTER, "Error: GetHost returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6292
6293         hr = IUri_GetPassword(uri, NULL);
6294         ok(hr == E_POINTER, "Error: GetPassword returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6295
6296         hr = IUri_GetPath(uri, NULL);
6297         ok(hr == E_POINTER, "Error: GetPath returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6298
6299         hr = IUri_GetPathAndQuery(uri, NULL);
6300         ok(hr == E_POINTER, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6301
6302         hr = IUri_GetQuery(uri, NULL);
6303         ok(hr == E_POINTER, "Error: GetQuery returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6304
6305         hr = IUri_GetRawUri(uri, NULL);
6306         ok(hr == E_POINTER, "Error: GetRawUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6307
6308         hr = IUri_GetSchemeName(uri, NULL);
6309         ok(hr == E_POINTER, "Error: GetSchemeName returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6310
6311         hr = IUri_GetUserInfo(uri, NULL);
6312         ok(hr == E_POINTER, "Error: GetUserInfo returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6313
6314         hr = IUri_GetUserName(uri, NULL);
6315         ok(hr == E_POINTER, "Error: GetUserName returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6316     }
6317     if(uri) IUri_Release(uri);
6318
6319     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6320         uri_properties test = uri_tests[i];
6321         LPWSTR uriW;
6322         uri = NULL;
6323
6324         uriW = a2w(test.uri);
6325         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6326         if(test.create_todo) {
6327             todo_wine {
6328                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6329                         hr, test.create_expected, i);
6330             }
6331         } else {
6332             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6333                     hr, test.create_expected, i);
6334         }
6335
6336         if(SUCCEEDED(hr)) {
6337             uri_str_property prop;
6338             BSTR received = NULL;
6339
6340             /* GetAbsoluteUri() tests. */
6341             prop = test.str_props[Uri_PROPERTY_ABSOLUTE_URI];
6342             hr = IUri_GetAbsoluteUri(uri, &received);
6343             if(prop.todo) {
6344                 todo_wine {
6345                     ok(hr == prop.expected, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6346                             hr, prop.expected, i);
6347                 }
6348                 todo_wine {
6349                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6350                             "Error: Expected %s but got %s on uri_tests[%d].\n",
6351                             prop.value, wine_dbgstr_w(received), i);
6352                 }
6353             } else {
6354                 ok(hr == prop.expected, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6355                         hr, prop.expected, i);
6356                 ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6357                         "Error: Expected %s but got %s on uri_tests[%d].\n",
6358                         prop.value, wine_dbgstr_w(received), i);
6359             }
6360             SysFreeString(received);
6361             received = NULL;
6362
6363             /* GetAuthority() tests. */
6364             prop = test.str_props[Uri_PROPERTY_AUTHORITY];
6365             hr = IUri_GetAuthority(uri, &received);
6366             if(prop.todo) {
6367                 todo_wine {
6368                     ok(hr == prop.expected, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6369                             hr, prop.expected, i);
6370                 }
6371                 todo_wine {
6372                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6373                             prop.value, wine_dbgstr_w(received), i);
6374                 }
6375             } else {
6376                 ok(hr == prop.expected, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6377                         hr, prop.expected, i);
6378                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6379                         prop.value, wine_dbgstr_w(received), i);
6380             }
6381             SysFreeString(received);
6382             received = NULL;
6383
6384             /* GetDisplayUri() tests. */
6385             prop = test.str_props[Uri_PROPERTY_DISPLAY_URI];
6386             hr = IUri_GetDisplayUri(uri, &received);
6387             if(prop.todo) {
6388                 todo_wine {
6389                     ok(hr == prop.expected, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6390                             hr, prop.expected, i);
6391                 }
6392                 todo_wine {
6393                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6394                             "Error: Expected %s but got %s on uri_test[%d].\n",
6395                             prop.value, wine_dbgstr_w(received), i);
6396                 }
6397             } else {
6398                 ok(hr == prop.expected, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6399                         hr, prop.expected, i);
6400                 ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6401                         "Error: Expected %s but got %s on uri_tests[%d].\n",
6402                         prop.value, wine_dbgstr_w(received), i);
6403             }
6404             SysFreeString(received);
6405             received = NULL;
6406
6407             /* GetDomain() tests. */
6408             prop = test.str_props[Uri_PROPERTY_DOMAIN];
6409             hr = IUri_GetDomain(uri, &received);
6410             if(prop.todo) {
6411                 todo_wine {
6412                     ok(hr == prop.expected, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6413                             hr, prop.expected, i);
6414                 }
6415                 todo_wine {
6416                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6417                             prop.value, wine_dbgstr_w(received), i);
6418                 }
6419             } else {
6420                 ok(hr == prop.expected, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6421                         hr, prop.expected, i);
6422                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6423                         prop.value, wine_dbgstr_w(received), i);
6424             }
6425             SysFreeString(received);
6426             received = NULL;
6427
6428             /* GetExtension() tests. */
6429             prop = test.str_props[Uri_PROPERTY_EXTENSION];
6430             hr = IUri_GetExtension(uri, &received);
6431             if(prop.todo) {
6432                 todo_wine {
6433                     ok(hr == prop.expected, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6434                             hr, prop.expected, i);
6435                 }
6436                 todo_wine {
6437                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6438                             prop.value, wine_dbgstr_w(received), i);
6439                 }
6440             } else {
6441                 ok(hr == prop.expected, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6442                         hr, prop.expected, i);
6443                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6444                         prop.value, wine_dbgstr_w(received), i);
6445             }
6446             SysFreeString(received);
6447             received = NULL;
6448
6449             /* GetFragment() tests. */
6450             prop = test.str_props[Uri_PROPERTY_FRAGMENT];
6451             hr = IUri_GetFragment(uri, &received);
6452             if(prop.todo) {
6453                 todo_wine {
6454                     ok(hr == prop.expected, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6455                             hr, prop.expected, i);
6456                 }
6457                 todo_wine {
6458                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6459                             prop.value, wine_dbgstr_w(received), i);
6460                 }
6461             } else {
6462                 ok(hr == prop.expected, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6463                         hr, prop.expected, i);
6464                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6465                         prop.value, wine_dbgstr_w(received), i);
6466             }
6467             SysFreeString(received);
6468             received = NULL;
6469
6470             /* GetHost() tests. */
6471             prop = test.str_props[Uri_PROPERTY_HOST];
6472             hr = IUri_GetHost(uri, &received);
6473             if(prop.todo) {
6474                 todo_wine {
6475                     ok(hr == prop.expected, "Error: GetHost returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6476                             hr, prop.expected, i);
6477                 }
6478                 todo_wine {
6479                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6480                             prop.value, wine_dbgstr_w(received), i);
6481                 }
6482             } else {
6483                 ok(hr == prop.expected, "Error: GetHost returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6484                         hr, prop.expected, i);
6485                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6486                         prop.value, wine_dbgstr_w(received), i);
6487             }
6488             SysFreeString(received);
6489             received = NULL;
6490
6491             /* GetPassword() tests. */
6492             prop = test.str_props[Uri_PROPERTY_PASSWORD];
6493             hr = IUri_GetPassword(uri, &received);
6494             if(prop.todo) {
6495                 todo_wine {
6496                     ok(hr == prop.expected, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6497                             hr, prop.expected, i);
6498                 }
6499                 todo_wine {
6500                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6501                             prop.value, wine_dbgstr_w(received), i);
6502                 }
6503             } else {
6504                 ok(hr == prop.expected, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6505                         hr, prop.expected, i);
6506                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6507                         prop.value, wine_dbgstr_w(received), i);
6508             }
6509             SysFreeString(received);
6510             received = NULL;
6511
6512             /* GetPath() tests. */
6513             prop = test.str_props[Uri_PROPERTY_PATH];
6514             hr = IUri_GetPath(uri, &received);
6515             if(prop.todo) {
6516                 todo_wine {
6517                     ok(hr == prop.expected, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6518                             hr, prop.expected, i);
6519                 }
6520                 todo_wine {
6521                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6522                             prop.value, wine_dbgstr_w(received), i);
6523                 }
6524             } else {
6525                 ok(hr == prop.expected, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6526                         hr, prop.expected, i);
6527                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6528                         prop.value, wine_dbgstr_w(received), i);
6529             }
6530             SysFreeString(received);
6531             received = NULL;
6532
6533             /* GetPathAndQuery() tests. */
6534             prop = test.str_props[Uri_PROPERTY_PATH_AND_QUERY];
6535             hr = IUri_GetPathAndQuery(uri, &received);
6536             if(prop.todo) {
6537                 todo_wine {
6538                     ok(hr == prop.expected, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6539                             hr, prop.expected, i);
6540                 }
6541                 todo_wine {
6542                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6543                             prop.value, wine_dbgstr_w(received), i);
6544                 }
6545             } else {
6546                 ok(hr == prop.expected, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6547                         hr, prop.expected, i);
6548                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6549                         prop.value, wine_dbgstr_w(received), i);
6550             }
6551             SysFreeString(received);
6552             received = NULL;
6553
6554             /* GetQuery() tests. */
6555             prop = test.str_props[Uri_PROPERTY_QUERY];
6556             hr = IUri_GetQuery(uri, &received);
6557             if(prop.todo) {
6558                 todo_wine {
6559                     ok(hr == prop.expected, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6560                             hr, prop.expected, i);
6561                 }
6562                 todo_wine {
6563                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6564                             prop.value, wine_dbgstr_w(received), i);
6565                 }
6566             } else {
6567                 ok(hr == prop.expected, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6568                         hr, prop.expected, i);
6569                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6570                         prop.value, wine_dbgstr_w(received), i);
6571             }
6572             SysFreeString(received);
6573             received = NULL;
6574
6575             /* GetRawUri() tests. */
6576             prop = test.str_props[Uri_PROPERTY_RAW_URI];
6577             hr = IUri_GetRawUri(uri, &received);
6578             if(prop.todo) {
6579                 todo_wine {
6580                     ok(hr == prop.expected, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6581                             hr, prop.expected, i);
6582                 }
6583                 todo_wine {
6584                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6585                             prop.value, wine_dbgstr_w(received), i);
6586                 }
6587             } else {
6588                 ok(hr == prop.expected, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6589                         hr, prop.expected, i);
6590                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6591                         prop.value, wine_dbgstr_w(received), i);
6592             }
6593             SysFreeString(received);
6594             received = NULL;
6595
6596             /* GetSchemeName() tests. */
6597             prop = test.str_props[Uri_PROPERTY_SCHEME_NAME];
6598             hr = IUri_GetSchemeName(uri, &received);
6599             if(prop.todo) {
6600                 todo_wine {
6601                     ok(hr == prop.expected, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6602                             hr, prop.expected, i);
6603                 }
6604                 todo_wine {
6605                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6606                             prop.value, wine_dbgstr_w(received), i);
6607                 }
6608             } else {
6609                 ok(hr == prop.expected, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6610                         hr, prop.expected, i);
6611                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6612                         prop.value, wine_dbgstr_w(received), i);
6613             }
6614             SysFreeString(received);
6615             received = NULL;
6616
6617             /* GetUserInfo() tests. */
6618             prop = test.str_props[Uri_PROPERTY_USER_INFO];
6619             hr = IUri_GetUserInfo(uri, &received);
6620             if(prop.todo) {
6621                 todo_wine {
6622                     ok(hr == prop.expected, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6623                             hr, prop.expected, i);
6624                 }
6625                 todo_wine {
6626                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6627                             prop.value, wine_dbgstr_w(received), i);
6628                 }
6629             } else {
6630                 ok(hr == prop.expected, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6631                         hr, prop.expected, i);
6632                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6633                         prop.value, wine_dbgstr_w(received), i);
6634             }
6635             SysFreeString(received);
6636             received = NULL;
6637
6638             /* GetUserName() tests. */
6639             prop = test.str_props[Uri_PROPERTY_USER_NAME];
6640             hr = IUri_GetUserName(uri, &received);
6641             if(prop.todo) {
6642                 todo_wine {
6643                     ok(hr == prop.expected, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6644                             hr, prop.expected, i);
6645                 }
6646                 todo_wine {
6647                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6648                             prop.value, wine_dbgstr_w(received), i);
6649                 }
6650             } else {
6651                 ok(hr == prop.expected, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6652                         hr, prop.expected, i);
6653                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6654                         prop.value, wine_dbgstr_w(received), i);
6655             }
6656             SysFreeString(received);
6657         }
6658
6659         if(uri) IUri_Release(uri);
6660
6661         heap_free(uriW);
6662     }
6663 }
6664
6665 static void test_IUri_GetDwordProperties(void) {
6666     IUri *uri = NULL;
6667     HRESULT hr;
6668     DWORD i;
6669
6670     /* Make sure all the 'Get*' dword property functions handle invalid args correctly. */
6671     hr = pCreateUri(http_urlW, 0, 0, &uri);
6672     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6673     if(SUCCEEDED(hr)) {
6674         hr = IUri_GetHostType(uri, NULL);
6675         ok(hr == E_INVALIDARG, "Error: GetHostType returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6676
6677         hr = IUri_GetPort(uri, NULL);
6678         ok(hr == E_INVALIDARG, "Error: GetPort returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6679
6680         hr = IUri_GetScheme(uri, NULL);
6681         ok(hr == E_INVALIDARG, "Error: GetScheme returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6682
6683         hr = IUri_GetZone(uri, NULL);
6684         ok(hr == E_INVALIDARG, "Error: GetZone returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6685     }
6686     if(uri) IUri_Release(uri);
6687
6688     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6689         uri_properties test = uri_tests[i];
6690         LPWSTR uriW;
6691         uri = NULL;
6692
6693         uriW = a2w(test.uri);
6694         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6695         if(test.create_todo) {
6696             todo_wine {
6697                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6698                         hr, test.create_expected, i);
6699             }
6700         } else {
6701             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6702                     hr, test.create_expected, i);
6703         }
6704
6705         if(SUCCEEDED(hr)) {
6706             uri_dword_property prop;
6707             DWORD received;
6708
6709             /* Assign an insane value so tests don't accidentally pass when
6710              * they shouldn't!
6711              */
6712             received = -9999999;
6713
6714             /* GetHostType() tests. */
6715             prop = test.dword_props[Uri_PROPERTY_HOST_TYPE-Uri_PROPERTY_DWORD_START];
6716             hr = IUri_GetHostType(uri, &received);
6717             if(prop.todo) {
6718                 todo_wine {
6719                     ok(hr == prop.expected, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6720                             hr, prop.expected, i);
6721                 }
6722                 todo_wine {
6723                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6724                 }
6725             } else {
6726                 ok(hr == prop.expected, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6727                         hr, prop.expected, i);
6728                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6729             }
6730             received = -9999999;
6731
6732             /* GetPort() tests. */
6733             prop = test.dword_props[Uri_PROPERTY_PORT-Uri_PROPERTY_DWORD_START];
6734             hr = IUri_GetPort(uri, &received);
6735             if(prop.todo) {
6736                 todo_wine {
6737                     ok(hr == prop.expected, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6738                             hr, prop.expected, i);
6739                 }
6740                 todo_wine {
6741                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6742                 }
6743             } else {
6744                 ok(hr == prop.expected, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6745                         hr, prop.expected, i);
6746                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6747             }
6748             received = -9999999;
6749
6750             /* GetScheme() tests. */
6751             prop = test.dword_props[Uri_PROPERTY_SCHEME-Uri_PROPERTY_DWORD_START];
6752             hr = IUri_GetScheme(uri, &received);
6753             if(prop.todo) {
6754                 todo_wine {
6755                     ok(hr == prop.expected, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6756                             hr, prop.expected, i);
6757                 }
6758                 todo_wine {
6759                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6760                 }
6761             } else {
6762                 ok(hr == prop.expected, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6763                         hr, prop.expected, i);
6764                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6765             }
6766             received = -9999999;
6767
6768             /* GetZone() tests. */
6769             prop = test.dword_props[Uri_PROPERTY_ZONE-Uri_PROPERTY_DWORD_START];
6770             hr = IUri_GetZone(uri, &received);
6771             if(prop.todo) {
6772                 todo_wine {
6773                     ok(hr == prop.expected, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6774                             hr, prop.expected, i);
6775                 }
6776                 todo_wine {
6777                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6778                 }
6779             } else {
6780                 ok(hr == prop.expected, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6781                         hr, prop.expected, i);
6782                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
6783             }
6784         }
6785
6786         if(uri) IUri_Release(uri);
6787
6788         heap_free(uriW);
6789     }
6790 }
6791
6792 static void test_IUri_GetPropertyLength(void) {
6793     IUri *uri = NULL;
6794     HRESULT hr;
6795     DWORD i;
6796
6797     /* Make sure it handles invalid args correctly. */
6798     hr = pCreateUri(http_urlW, 0, 0, &uri);
6799     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6800     if(SUCCEEDED(hr)) {
6801         DWORD received = 0xdeadbeef;
6802
6803         hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_STRING_START, NULL, 0);
6804         ok(hr == E_INVALIDARG, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6805
6806         hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_DWORD_START, &received, 0);
6807         ok(hr == E_INVALIDARG, "Error: GetPropertyLength return 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6808         ok(received == 0xdeadbeef, "Error: Expected 0xdeadbeef but got 0x%08x.\n", received);
6809     }
6810     if(uri) IUri_Release(uri);
6811
6812     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6813         uri_properties test = uri_tests[i];
6814         LPWSTR uriW;
6815         uri = NULL;
6816
6817         uriW = a2w(test.uri);
6818         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6819         if(test.create_todo) {
6820             todo_wine {
6821                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6822                         hr, test.create_expected, i);
6823             }
6824         } else {
6825             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_test[%d].\n",
6826                     hr, test.create_expected, i);
6827         }
6828
6829         if(SUCCEEDED(hr)) {
6830             DWORD j;
6831
6832             for(j = Uri_PROPERTY_STRING_START; j <= Uri_PROPERTY_STRING_LAST; ++j) {
6833                 DWORD expectedLen, brokenLen, receivedLen;
6834                 uri_str_property prop = test.str_props[j];
6835
6836                 expectedLen = lstrlen(prop.value);
6837                 brokenLen = lstrlen(prop.broken_value);
6838
6839                 /* This won't be necessary once GetPropertyLength is implemented. */
6840                 receivedLen = -1;
6841
6842                 hr = IUri_GetPropertyLength(uri, j, &receivedLen, 0);
6843                 if(prop.todo) {
6844                     todo_wine {
6845                         ok(hr == prop.expected, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
6846                                 hr, prop.expected, i, j);
6847                     }
6848                     todo_wine {
6849                         ok(receivedLen == expectedLen || broken(receivedLen == brokenLen),
6850                                 "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
6851                                 expectedLen, receivedLen, i, j);
6852                     }
6853                 } else {
6854                     ok(hr == prop.expected, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
6855                             hr, prop.expected, i, j);
6856                     ok(receivedLen == expectedLen || broken(receivedLen == brokenLen),
6857                             "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
6858                             expectedLen, receivedLen, i, j);
6859                 }
6860             }
6861         }
6862
6863         if(uri) IUri_Release(uri);
6864
6865         heap_free(uriW);
6866     }
6867 }
6868
6869 static DWORD compute_expected_props(uri_properties *test)
6870 {
6871     DWORD ret = 0, i;
6872
6873     for(i=Uri_PROPERTY_STRING_START; i <= Uri_PROPERTY_STRING_LAST; i++) {
6874         if(test->str_props[i-Uri_PROPERTY_STRING_START].expected == S_OK)
6875             ret |= 1<<i;
6876     }
6877
6878     for(i=Uri_PROPERTY_DWORD_START; i <= Uri_PROPERTY_DWORD_LAST; i++) {
6879         if(test->dword_props[i-Uri_PROPERTY_DWORD_START].expected == S_OK)
6880             ret |= 1<<i;
6881     }
6882
6883     return ret;
6884 }
6885
6886 static void test_IUri_GetProperties(void) {
6887     IUri *uri = NULL;
6888     HRESULT hr;
6889     DWORD i;
6890
6891     hr = pCreateUri(http_urlW, 0, 0, &uri);
6892     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6893     if(SUCCEEDED(hr)) {
6894         hr = IUri_GetProperties(uri, NULL);
6895         ok(hr == E_INVALIDARG, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6896     }
6897     if(uri) IUri_Release(uri);
6898
6899     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6900         uri_properties test = uri_tests[i];
6901         LPWSTR uriW;
6902         uri = NULL;
6903
6904         uriW = a2w(test.uri);
6905         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6906         if(test.create_todo) {
6907             todo_wine {
6908                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
6909             }
6910         } else {
6911             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
6912         }
6913
6914         if(SUCCEEDED(hr)) {
6915             DWORD received = 0, expected_props;
6916             DWORD j;
6917
6918             hr = IUri_GetProperties(uri, &received);
6919             ok(hr == S_OK, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6920
6921             expected_props = compute_expected_props(&test);
6922
6923             for(j = 0; j <= Uri_PROPERTY_DWORD_LAST; ++j) {
6924                 /* (1 << j) converts a Uri_PROPERTY to its corresponding Uri_HAS_* flag mask. */
6925                 if(expected_props & (1 << j))
6926                     ok(received & (1 << j), "Error: Expected flag for property %d on uri_tests[%d].\n", j, i);
6927                 else
6928                     ok(!(received & (1 << j)), "Error: Received flag for property %d when not expected on uri_tests[%d].\n", j, i);
6929             }
6930         }
6931
6932         if(uri) IUri_Release(uri);
6933
6934         heap_free(uriW);
6935     }
6936 }
6937
6938 static void test_IUri_HasProperty(void) {
6939     IUri *uri = NULL;
6940     HRESULT hr;
6941     DWORD i;
6942
6943     hr = pCreateUri(http_urlW, 0, 0, &uri);
6944     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6945     if(SUCCEEDED(hr)) {
6946         hr = IUri_HasProperty(uri, Uri_PROPERTY_RAW_URI, NULL);
6947         ok(hr == E_INVALIDARG, "Error: HasProperty returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6948     }
6949     if(uri) IUri_Release(uri);
6950
6951     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6952         uri_properties test = uri_tests[i];
6953         LPWSTR uriW;
6954         uri = NULL;
6955
6956         uriW = a2w(test.uri);
6957
6958         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6959         if(test.create_todo) {
6960             todo_wine {
6961                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
6962             }
6963         } else {
6964             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
6965         }
6966
6967         if(SUCCEEDED(hr)) {
6968             DWORD expected_props, j;
6969
6970             expected_props = compute_expected_props(&test);
6971
6972             for(j = 0; j <= Uri_PROPERTY_DWORD_LAST; ++j) {
6973                 /* Assign -1, then explicitly test for TRUE or FALSE later. */
6974                 BOOL received = -1;
6975
6976                 hr = IUri_HasProperty(uri, j, &received);
6977                 ok(hr == S_OK, "Error: HasProperty returned 0x%08x, expected 0x%08x for property %d on uri_tests[%d].\n",
6978                         hr, S_OK, j, i);
6979
6980                 if(expected_props & (1 << j)) {
6981                     ok(received == TRUE, "Error: Expected to have property %d on uri_tests[%d].\n", j, i);
6982                 } else {
6983                     ok(received == FALSE, "Error: Wasn't expecting to have property %d on uri_tests[%d].\n", j, i);
6984                 }
6985             }
6986         }
6987
6988         if(uri) IUri_Release(uri);
6989
6990         heap_free(uriW);
6991     }
6992 }
6993
6994 static void test_IUri_IsEqual(void) {
6995     IUri *uriA, *uriB;
6996     HRESULT hrA, hrB;
6997     DWORD i;
6998
6999     uriA = uriB = NULL;
7000
7001     /* Make sure IsEqual handles invalid args correctly. */
7002     hrA = pCreateUri(http_urlW, 0, 0, &uriA);
7003     hrB = pCreateUri(http_urlW, 0, 0, &uriB);
7004     ok(hrA == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hrA, S_OK);
7005     ok(hrB == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hrB, S_OK);
7006     if(SUCCEEDED(hrA) && SUCCEEDED(hrB)) {
7007         BOOL equal = -1;
7008         hrA = IUri_IsEqual(uriA, NULL, &equal);
7009         ok(hrA == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x.\n", hrA, S_OK);
7010         ok(equal == FALSE, "Error: Expected equal to be FALSE, but was %d instead.\n", equal);
7011
7012         hrA = IUri_IsEqual(uriA, uriB, NULL);
7013         ok(hrA == E_POINTER, "Error: IsEqual returned 0x%08x, expected 0x%08x.\n", hrA, E_POINTER);
7014     }
7015     if(uriA) IUri_Release(uriA);
7016     if(uriB) IUri_Release(uriB);
7017
7018     for(i = 0; i < sizeof(equality_tests)/sizeof(equality_tests[0]); ++i) {
7019         uri_equality test = equality_tests[i];
7020         LPWSTR uriA_W, uriB_W;
7021
7022         uriA = uriB = NULL;
7023
7024         uriA_W = a2w(test.a);
7025         uriB_W = a2w(test.b);
7026
7027         hrA = pCreateUri(uriA_W, test.create_flags_a, 0, &uriA);
7028         if(test.create_todo_a) {
7029             todo_wine {
7030                 ok(hrA == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].a\n",
7031                         hrA, S_OK, i);
7032             }
7033         } else {
7034             ok(hrA == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].a\n",
7035                     hrA, S_OK, i);
7036         }
7037
7038         hrB = pCreateUri(uriB_W, test.create_flags_b, 0, &uriB);
7039         if(test.create_todo_b) {
7040             todo_wine {
7041                 ok(hrB == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].b\n",
7042                         hrB, S_OK, i);
7043             }
7044         } else {
7045             ok(hrB == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].b\n",
7046                     hrB, S_OK, i);
7047         }
7048
7049         if(SUCCEEDED(hrA) && SUCCEEDED(hrB)) {
7050             BOOL equal = -1;
7051
7052             hrA = IUri_IsEqual(uriA, uriB, &equal);
7053             if(test.todo) {
7054                 todo_wine {
7055                     ok(hrA == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x on equality_tests[%d].\n",
7056                             hrA, S_OK, i);
7057                 }
7058                 todo_wine {
7059                     ok(equal == test.equal, "Error: Expected the comparison to be %d on equality_tests[%d].\n", test.equal, i);
7060                 }
7061             } else {
7062                 ok(hrA == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x on equality_tests[%d].\n", hrA, S_OK, i);
7063                 ok(equal == test.equal, "Error: Expected the comparison to be %d on equality_tests[%d].\n", test.equal, i);
7064             }
7065         }
7066         if(uriA) IUri_Release(uriA);
7067         if(uriB) IUri_Release(uriB);
7068
7069         heap_free(uriA_W);
7070         heap_free(uriB_W);
7071     }
7072 }
7073
7074 static void test_CreateUriWithFragment_InvalidArgs(void) {
7075     HRESULT hr;
7076     IUri *uri = (void*) 0xdeadbeef;
7077     const WCHAR fragmentW[] = {'#','f','r','a','g','m','e','n','t',0};
7078
7079     hr = pCreateUriWithFragment(NULL, fragmentW, 0, 0, &uri);
7080     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7081     ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7082
7083     hr = pCreateUriWithFragment(http_urlW, fragmentW, 0, 0, NULL);
7084     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7085
7086     /* Original URI can't already contain a fragment component. */
7087     uri = (void*) 0xdeadbeef;
7088     hr = pCreateUriWithFragment(http_url_fragW, fragmentW, 0, 0, &uri);
7089     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7090     ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7091 }
7092
7093 /* CreateUriWithFragment has the same invalid flag combinations as CreateUri. */
7094 static void test_CreateUriWithFragment_InvalidFlags(void) {
7095     DWORD i;
7096
7097     for(i = 0; i < sizeof(invalid_flag_tests)/sizeof(invalid_flag_tests[0]); ++i) {
7098         HRESULT hr;
7099         IUri *uri = (void*) 0xdeadbeef;
7100
7101         hr = pCreateUriWithFragment(http_urlW, NULL, invalid_flag_tests[i].flags, 0, &uri);
7102         ok(hr == invalid_flag_tests[i].expected, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x. flags=0x%08x.\n",
7103             hr, invalid_flag_tests[i].expected, invalid_flag_tests[i].flags);
7104         ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7105     }
7106 }
7107
7108 static void test_CreateUriWithFragment(void) {
7109     DWORD i;
7110
7111     for(i = 0; i < sizeof(uri_fragment_tests)/sizeof(uri_fragment_tests[0]); ++i) {
7112         HRESULT hr;
7113         IUri *uri = NULL;
7114         LPWSTR uriW, fragW;
7115         uri_with_fragment test = uri_fragment_tests[i];
7116
7117         uriW = a2w(test.uri);
7118         fragW = a2w(test.fragment);
7119
7120         hr = pCreateUriWithFragment(uriW, fragW, test.create_flags, 0, &uri);
7121         if(test.expected_todo) {
7122             todo_wine {
7123                 ok(hr == test.create_expected,
7124                     "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7125                     hr, test.create_expected, i);
7126             }
7127         } else
7128             ok(hr == test.create_expected,
7129                 "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7130                 hr, test.create_expected, i);
7131
7132         if(SUCCEEDED(hr)) {
7133             BSTR received = NULL;
7134
7135             hr = IUri_GetAbsoluteUri(uri, &received);
7136             if(test.expected_todo) {
7137                 todo_wine {
7138                     ok(hr == S_OK,
7139                         "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7140                         hr, S_OK, i);
7141                 }
7142                 todo_wine {
7143                     ok(!strcmp_aw(test.expected_uri, received),
7144                         "Error: Expected %s but got %s on uri_fragment_tests[%d].\n",
7145                         test.expected_uri, wine_dbgstr_w(received), i);
7146                 }
7147             } else {
7148                 ok(hr == S_OK, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7149                     hr, S_OK, i);
7150                 ok(!strcmp_aw(test.expected_uri, received), "Error: Expected %s but got %s on uri_fragment_tests[%d].\n",
7151                     test.expected_uri, wine_dbgstr_w(received), i);
7152             }
7153
7154             SysFreeString(received);
7155         }
7156
7157         if(uri) IUri_Release(uri);
7158         heap_free(uriW);
7159     }
7160 }
7161
7162 static void test_CreateIUriBuilder(void) {
7163     HRESULT hr;
7164     IUriBuilder *builder = NULL;
7165     IUri *uri;
7166
7167     hr = pCreateIUriBuilder(NULL, 0, 0, NULL);
7168     ok(hr == E_POINTER, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x\n",
7169         hr, E_POINTER);
7170
7171     /* CreateIUriBuilder increases the ref count of the IUri it receives. */
7172     hr = pCreateUri(http_urlW, 0, 0, &uri);
7173     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7174     if(SUCCEEDED(hr)) {
7175         ULONG cur_count, orig_count;
7176
7177         orig_count = get_refcnt(uri);
7178         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
7179         ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7180         ok(builder != NULL, "Error: Expecting builder not to be NULL\n");
7181
7182         cur_count = get_refcnt(uri);
7183         ok(cur_count == orig_count+1, "Error: Expected the ref count to be %u, but was %u instead.\n", orig_count+1, cur_count);
7184
7185         if(builder) IUriBuilder_Release(builder);
7186         cur_count = get_refcnt(uri);
7187         ok(cur_count == orig_count, "Error: Expected the ref count to be %u, but was %u instead.\n", orig_count, cur_count);
7188     }
7189     if(uri) IUri_Release(uri);
7190 }
7191
7192 static void test_IUriBuilder_CreateUri(IUriBuilder *builder, const uri_builder_test *test,
7193                                        DWORD test_index) {
7194     HRESULT hr;
7195     IUri *uri = NULL;
7196
7197     hr = IUriBuilder_CreateUri(builder, test->uri_flags, 0, 0, &uri);
7198     if(test->uri_todo) {
7199         todo_wine {
7200             ok(hr == test->uri_hres,
7201                 "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7202                 hr, test->uri_hres, test_index);
7203         }
7204     } else {
7205         ok(hr == test->uri_hres,
7206             "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7207             hr, test->uri_hres, test_index);
7208     }
7209
7210     if(SUCCEEDED(hr)) {
7211         DWORD i;
7212
7213         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
7214             uri_builder_str_property prop = test->expected_str_props[i];
7215             BSTR received = NULL;
7216
7217             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
7218             if(prop.todo) {
7219                 todo_wine {
7220                     ok(hr == prop.result,
7221                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7222                         hr, prop.result, test_index, i);
7223                 }
7224             } else {
7225                 ok(hr == prop.result,
7226                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7227                     hr, prop.result, test_index, i);
7228             }
7229             if(SUCCEEDED(hr)) {
7230                 if(prop.todo) {
7231                     todo_wine {
7232                         ok(!strcmp_aw(prop.expected, received),
7233                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7234                             prop.expected, wine_dbgstr_w(received), test_index, i);
7235                     }
7236                 } else {
7237                     ok(!strcmp_aw(prop.expected, received),
7238                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7239                         prop.expected, wine_dbgstr_w(received), test_index, i);
7240                 }
7241             }
7242             SysFreeString(received);
7243         }
7244
7245         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
7246             uri_builder_dword_property prop = test->expected_dword_props[i];
7247             DWORD received = -2;
7248
7249             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
7250             if(prop.todo) {
7251                 todo_wine {
7252                     ok(hr == prop.result,
7253                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7254                         hr, prop.result, test_index, i);
7255                 }
7256             } else {
7257                 ok(hr == prop.result,
7258                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7259                     hr, prop.result, test_index, i);
7260             }
7261             if(SUCCEEDED(hr)) {
7262                 if(prop.todo) {
7263                     todo_wine {
7264                         ok(received == prop.expected,
7265                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7266                             prop.expected, received, test_index, i);
7267                     }
7268                 } else {
7269                     ok(received == prop.expected,
7270                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7271                         prop.expected, received, test_index, i);
7272                 }
7273             }
7274         }
7275     }
7276     if(uri) IUri_Release(uri);
7277 }
7278
7279 static void test_IUriBuilder_CreateUriSimple(IUriBuilder *builder, const uri_builder_test *test,
7280                                        DWORD test_index) {
7281     HRESULT hr;
7282     IUri *uri = NULL;
7283
7284     hr = IUriBuilder_CreateUriSimple(builder, test->uri_simple_encode_flags, 0, &uri);
7285     if(test->uri_simple_todo) {
7286         todo_wine {
7287             ok(hr == test->uri_simple_hres,
7288                 "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7289                 hr, test->uri_simple_hres, test_index);
7290         }
7291     } else {
7292         ok(hr == test->uri_simple_hres,
7293             "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7294             hr, test->uri_simple_hres, test_index);
7295     }
7296
7297     if(SUCCEEDED(hr)) {
7298         DWORD i;
7299
7300         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
7301             uri_builder_str_property prop = test->expected_str_props[i];
7302             BSTR received = NULL;
7303
7304             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
7305             if(prop.todo) {
7306                 todo_wine {
7307                     ok(hr == prop.result,
7308                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7309                         hr, prop.result, test_index, i);
7310                 }
7311             } else {
7312                 ok(hr == prop.result,
7313                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7314                     hr, prop.result, test_index, i);
7315             }
7316             if(SUCCEEDED(hr)) {
7317                 if(prop.todo) {
7318                     todo_wine {
7319                         ok(!strcmp_aw(prop.expected, received),
7320                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7321                             prop.expected, wine_dbgstr_w(received), test_index, i);
7322                     }
7323                 } else {
7324                     ok(!strcmp_aw(prop.expected, received),
7325                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7326                         prop.expected, wine_dbgstr_w(received), test_index, i);
7327                 }
7328             }
7329             SysFreeString(received);
7330         }
7331
7332         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
7333             uri_builder_dword_property prop = test->expected_dword_props[i];
7334             DWORD received = -2;
7335
7336             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
7337             if(prop.todo) {
7338                 todo_wine {
7339                     ok(hr == prop.result,
7340                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7341                         hr, prop.result, test_index, i);
7342                 }
7343             } else {
7344                 ok(hr == prop.result,
7345                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7346                     hr, prop.result, test_index, i);
7347             }
7348             if(SUCCEEDED(hr)) {
7349                 if(prop.todo) {
7350                     todo_wine {
7351                         ok(received == prop.expected,
7352                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7353                             prop.expected, received, test_index, i);
7354                     }
7355                 } else {
7356                     ok(received == prop.expected,
7357                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7358                         prop.expected, received, test_index, i);
7359                 }
7360             }
7361         }
7362     }
7363     if(uri) IUri_Release(uri);
7364 }
7365
7366 static void test_IUriBuilder_CreateUriWithFlags(IUriBuilder *builder, const uri_builder_test *test,
7367                                                 DWORD test_index) {
7368     HRESULT hr;
7369     IUri *uri = NULL;
7370
7371     hr = IUriBuilder_CreateUriWithFlags(builder, test->uri_with_flags, test->uri_with_builder_flags,
7372                                         test->uri_with_encode_flags, 0, &uri);
7373     if(test->uri_with_todo) {
7374         todo_wine {
7375             ok(hr == test->uri_with_hres,
7376                 "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7377                 hr, test->uri_with_hres, test_index);
7378         }
7379     } else {
7380         ok(hr == test->uri_with_hres,
7381             "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7382             hr, test->uri_with_hres, test_index);
7383     }
7384
7385     if(SUCCEEDED(hr)) {
7386         DWORD i;
7387
7388         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
7389             uri_builder_str_property prop = test->expected_str_props[i];
7390             BSTR received = NULL;
7391
7392             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
7393             if(prop.todo) {
7394                 todo_wine {
7395                     ok(hr == prop.result,
7396                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7397                         hr, prop.result, test_index, i);
7398                 }
7399             } else {
7400                 ok(hr == prop.result,
7401                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7402                     hr, prop.result, test_index, i);
7403             }
7404             if(SUCCEEDED(hr)) {
7405                 if(prop.todo) {
7406                     todo_wine {
7407                         ok(!strcmp_aw(prop.expected, received),
7408                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7409                             prop.expected, wine_dbgstr_w(received), test_index, i);
7410                     }
7411                 } else {
7412                     ok(!strcmp_aw(prop.expected, received),
7413                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7414                         prop.expected, wine_dbgstr_w(received), test_index, i);
7415                 }
7416             }
7417             SysFreeString(received);
7418         }
7419
7420         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
7421             uri_builder_dword_property prop = test->expected_dword_props[i];
7422             DWORD received = -2;
7423
7424             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
7425             if(prop.todo) {
7426                 todo_wine {
7427                     ok(hr == prop.result,
7428                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7429                         hr, prop.result, test_index, i);
7430                 }
7431             } else {
7432                 ok(hr == prop.result,
7433                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7434                     hr, prop.result, test_index, i);
7435             }
7436             if(SUCCEEDED(hr)) {
7437                 if(prop.todo) {
7438                     todo_wine {
7439                         ok(received == prop.expected,
7440                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7441                             prop.expected, received, test_index, i);
7442                     }
7443                 } else {
7444                     ok(received == prop.expected,
7445                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7446                         prop.expected, received, test_index, i);
7447                 }
7448             }
7449         }
7450     }
7451     if(uri) IUri_Release(uri);
7452 }
7453
7454 static void test_IUriBuilder_CreateInvalidArgs(void) {
7455     IUriBuilder *builder;
7456     HRESULT hr;
7457
7458     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
7459     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7460     if(SUCCEEDED(hr)) {
7461         IUri *test = NULL, *uri = (void*) 0xdeadbeef;
7462
7463         /* Test what happens if the IUriBuilder doesn't have a IUri set. */
7464         hr = IUriBuilder_CreateUri(builder, 0, 0, 0, NULL);
7465         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7466
7467         uri = (void*) 0xdeadbeef;
7468         hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
7469         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_NOTIMPL);
7470         ok(uri == NULL, "Error: expected uri to be NULL, but was %p instead.\n", uri);
7471
7472         hr = IUriBuilder_CreateUriSimple(builder, 0, 0, NULL);
7473         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
7474             hr, E_POINTER);
7475
7476         uri = (void*) 0xdeadbeef;
7477         hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
7478         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
7479             hr, E_NOTIMPL);
7480         ok(!uri, "Error: Expected uri to NULL, but was %p instead.\n", uri);
7481
7482         hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, NULL);
7483         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
7484             hr, E_POINTER);
7485
7486         uri = (void*) 0xdeadbeef;
7487         hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, Uri_HAS_USER_NAME, 0, &uri);
7488         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
7489             hr, E_NOTIMPL);
7490         ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7491
7492         hr = pCreateUri(http_urlW, 0, 0, &test);
7493         ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7494         if(SUCCEEDED(hr)) {
7495             hr = IUriBuilder_SetIUri(builder, test);
7496             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7497
7498             /* No longer returns E_NOTIMPL, since a IUri has been set and hasn't been modified. */
7499             uri = NULL;
7500             hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
7501             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7502             ok(uri != NULL, "Error: The uri was NULL.\n");
7503             if(uri) IUri_Release(uri);
7504
7505             uri = NULL;
7506             hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
7507             ok(hr == S_OK, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
7508                 hr, S_OK);
7509             ok(uri != NULL, "Error: uri was NULL.\n");
7510             if(uri) IUri_Release(uri);
7511
7512             uri = NULL;
7513             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, &uri);
7514             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
7515                 hr, S_OK);
7516             ok(uri != NULL, "Error: uri was NULL.\n");
7517             if(uri) IUri_Release(uri);
7518
7519             hr = IUriBuilder_SetFragment(builder, NULL);
7520             ok(hr == S_OK, "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7521
7522             /* The IUriBuilder is changed, so it returns E_NOTIMPL again. */
7523             uri = (void*) 0xdeadbeef;
7524             hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
7525             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7526             ok(!uri, "Error: Expected uri to be NULL but was %p instead.\n", uri);
7527
7528             uri = (void*) 0xdeadbeef;
7529             hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
7530             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
7531                 hr, S_OK);
7532             ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7533
7534             uri = (void*) 0xdeadbeef;
7535             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, Uri_HAS_USER_NAME, 0, &uri);
7536             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
7537                 hr, E_NOTIMPL);
7538             ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7539         }
7540         if(test) IUri_Release(test);
7541     }
7542     if(builder) IUriBuilder_Release(builder);
7543 }
7544
7545 /* Tests invalid args to the "Get*" functions. */
7546 static void test_IUriBuilder_GetInvalidArgs(void) {
7547     IUriBuilder *builder = NULL;
7548     HRESULT hr;
7549
7550     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
7551     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7552     if(SUCCEEDED(hr)) {
7553         LPCWSTR received = (void*) 0xdeadbeef;
7554         DWORD len = -1, port = -1;
7555         BOOL set = -1;
7556
7557         hr = IUriBuilder_GetFragment(builder, NULL, NULL);
7558         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
7559             hr, E_POINTER);
7560         hr = IUriBuilder_GetFragment(builder, NULL, &received);
7561         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
7562             hr, E_POINTER);
7563         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7564         hr = IUriBuilder_GetFragment(builder, &len, NULL);
7565         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
7566             hr, E_POINTER);
7567         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7568
7569         hr = IUriBuilder_GetHost(builder, NULL, NULL);
7570         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
7571             hr, E_POINTER);
7572         received = (void*) 0xdeadbeef;
7573         hr = IUriBuilder_GetHost(builder, NULL, &received);
7574         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
7575             hr, E_POINTER);
7576         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7577         len = -1;
7578         hr = IUriBuilder_GetHost(builder, &len, NULL);
7579         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
7580             hr, E_POINTER);
7581         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7582
7583         hr = IUriBuilder_GetPassword(builder, NULL, NULL);
7584         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
7585             hr, E_POINTER);
7586         received = (void*) 0xdeadbeef;
7587         hr = IUriBuilder_GetPassword(builder, NULL, &received);
7588         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
7589             hr, E_POINTER);
7590         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7591         len = -1;
7592         hr = IUriBuilder_GetPassword(builder, &len, NULL);
7593         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
7594             hr, E_POINTER);
7595         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7596
7597         hr = IUriBuilder_GetPath(builder, NULL, NULL);
7598         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
7599             hr, E_POINTER);
7600         received = (void*) 0xdeadbeef;
7601         hr = IUriBuilder_GetPath(builder, NULL, &received);
7602         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
7603             hr, E_POINTER);
7604         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7605         len = -1;
7606         hr = IUriBuilder_GetPath(builder, &len, NULL);
7607         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
7608             hr, E_POINTER);
7609         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7610
7611         hr = IUriBuilder_GetPort(builder, NULL, NULL);
7612         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
7613             hr, E_POINTER);
7614         hr = IUriBuilder_GetPort(builder, NULL, &port);
7615         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
7616             hr, E_POINTER);
7617         ok(!port, "Error: Expected port to be 0, but was %d instead.\n", port);
7618         hr = IUriBuilder_GetPort(builder, &set, NULL);
7619         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
7620             hr, E_POINTER);
7621         ok(!set, "Error: Expected set to be FALSE, but was %d instead.\n", set);
7622
7623         hr = IUriBuilder_GetQuery(builder, NULL, NULL);
7624         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
7625             hr, E_POINTER);
7626         received = (void*) 0xdeadbeef;
7627         hr = IUriBuilder_GetQuery(builder, NULL, &received);
7628         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
7629             hr, E_POINTER);
7630         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7631         len = -1;
7632         hr = IUriBuilder_GetQuery(builder, &len, NULL);
7633         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
7634             hr, E_POINTER);
7635         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7636
7637         hr = IUriBuilder_GetSchemeName(builder, NULL, NULL);
7638         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
7639             hr, E_POINTER);
7640         received = (void*) 0xdeadbeef;
7641         hr = IUriBuilder_GetSchemeName(builder, NULL, &received);
7642         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
7643             hr, E_POINTER);
7644         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7645         len = -1;
7646         hr = IUriBuilder_GetSchemeName(builder, &len, NULL);
7647         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
7648             hr, E_POINTER);
7649         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7650
7651         hr = IUriBuilder_GetUserName(builder, NULL, NULL);
7652         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
7653             hr, E_POINTER);
7654         received = (void*) 0xdeadbeef;
7655         hr = IUriBuilder_GetUserName(builder, NULL, &received);
7656         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
7657             hr, E_POINTER);
7658         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
7659         len = -1;
7660         hr = IUriBuilder_GetUserName(builder, &len, NULL);
7661         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
7662             hr, E_POINTER);
7663         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
7664     }
7665     if(builder) IUriBuilder_Release(builder);
7666 }
7667
7668 static void test_IUriBuilder_GetFragment(IUriBuilder *builder, const uri_builder_test *test,
7669                                          DWORD test_index) {
7670     HRESULT hr;
7671     DWORD i;
7672     LPCWSTR received = NULL;
7673     DWORD len = -1;
7674     const uri_builder_property *prop = NULL;
7675
7676     /* Check if the property was set earlier. */
7677     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
7678         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_FRAGMENT)
7679             prop = &(test->properties[i]);
7680     }
7681
7682     if(prop) {
7683         /* Use expected_value unless it's NULL, then use value. */
7684         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
7685         hr = IUriBuilder_GetFragment(builder, &len, &received);
7686         if(prop->todo) {
7687             todo_wine {
7688                 ok(hr == (expected ? S_OK : S_FALSE),
7689                     "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7690                     hr, (expected ? S_OK : S_FALSE), test_index);
7691             }
7692             if(SUCCEEDED(hr)) {
7693                 todo_wine {
7694                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
7695                         expected, wine_dbgstr_w(received), test_index);
7696                 }
7697                 todo_wine {
7698                     ok(lstrlen(expected) == len,
7699                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
7700                         lstrlen(expected), len, test_index);
7701                 }
7702             }
7703         } else {
7704             ok(hr == (expected ? S_OK : S_FALSE),
7705                 "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7706                 hr, (expected ? S_OK : S_FALSE), test_index);
7707             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
7708                 expected, wine_dbgstr_w(received), test_index);
7709             ok(lstrlen(expected) == len,
7710                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
7711                 lstrlen(expected), len, test_index);
7712         }
7713     } else {
7714         /* The property wasn't set earlier, so it should return whatever
7715          * the base IUri contains (if anything).
7716          */
7717         IUri *uri = NULL;
7718         hr = IUriBuilder_GetIUri(builder, &uri);
7719         ok(hr == S_OK,
7720             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7721             hr, S_OK, test_index);
7722         if(SUCCEEDED(hr)) {
7723             if(!uri) {
7724                 received = (void*) 0xdeadbeef;
7725                 len = -1;
7726
7727                 hr = IUriBuilder_GetFragment(builder, &len, &received);
7728                 ok(hr == S_FALSE,
7729                     "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7730                     hr, S_FALSE, test_index);
7731                 if(SUCCEEDED(hr)) {
7732                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
7733                         len, test_index);
7734                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
7735                         received, test_index);
7736                 }
7737             } else {
7738                 BOOL has_prop = FALSE;
7739                 BSTR expected = NULL;
7740
7741                 hr = IUri_GetFragment(uri, &expected);
7742                 ok(SUCCEEDED(hr),
7743                     "Error: Expected IUri_GetFragment to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
7744                     hr, test_index);
7745                 has_prop = hr == S_OK;
7746
7747                 hr = IUriBuilder_GetFragment(builder, &len, &received);
7748                 if(has_prop) {
7749                     ok(hr == S_OK,
7750                         "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7751                         hr, S_OK, test_index);
7752                     if(SUCCEEDED(hr)) {
7753                         ok(!lstrcmpW(expected, received),
7754                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
7755                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
7756                         ok(lstrlenW(expected) == len,
7757                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
7758                             lstrlenW(expected), len, test_index);
7759                     }
7760                 } else {
7761                     ok(hr == S_FALSE,
7762                         "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7763                         hr, S_FALSE, test_index);
7764                     if(SUCCEEDED(hr)) {
7765                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
7766                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
7767                             len, test_index);
7768                     }
7769                 }
7770                 SysFreeString(expected);
7771             }
7772         }
7773         if(uri) IUri_Release(uri);
7774     }
7775 }
7776
7777 static void test_IUriBuilder_GetHost(IUriBuilder *builder, const uri_builder_test *test,
7778                                      DWORD test_index) {
7779     HRESULT hr;
7780     DWORD i;
7781     LPCWSTR received = NULL;
7782     DWORD len = -1;
7783     const uri_builder_property *prop = NULL;
7784
7785     /* Check if the property was set earlier. */
7786     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
7787         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_HOST)
7788             prop = &(test->properties[i]);
7789     }
7790
7791     if(prop) {
7792         /* Use expected_value unless it's NULL, then use value. */
7793         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
7794         hr = IUriBuilder_GetHost(builder, &len, &received);
7795         if(prop->todo) {
7796             todo_wine {
7797                 ok(hr == (expected ? S_OK : S_FALSE),
7798                     "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7799                     hr, (expected ? S_OK : S_FALSE), test_index);
7800             }
7801             if(SUCCEEDED(hr)) {
7802                 todo_wine {
7803                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
7804                         expected, wine_dbgstr_w(received), test_index);
7805                 }
7806                 todo_wine {
7807                     ok(lstrlen(expected) == len,
7808                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
7809                         lstrlen(expected), len, test_index);
7810                 }
7811             }
7812         } else {
7813             ok(hr == (expected ? S_OK : S_FALSE),
7814                 "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7815                 hr, (expected ? S_OK : S_FALSE), test_index);
7816             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
7817                 expected, wine_dbgstr_w(received), test_index);
7818             ok(lstrlen(expected) == len,
7819                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
7820                 lstrlen(expected), len, test_index);
7821         }
7822     } else {
7823         /* The property wasn't set earlier, so it should return whatever
7824          * the base IUri contains (if anything).
7825          */
7826         IUri *uri = NULL;
7827         hr = IUriBuilder_GetIUri(builder, &uri);
7828         ok(hr == S_OK,
7829             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7830             hr, S_OK, test_index);
7831         if(SUCCEEDED(hr)) {
7832             if(!uri) {
7833                 received = (void*) 0xdeadbeef;
7834                 len = -1;
7835
7836                 hr = IUriBuilder_GetHost(builder, &len, &received);
7837                 ok(hr == S_FALSE,
7838                     "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7839                     hr, S_FALSE, test_index);
7840                 if(SUCCEEDED(hr)) {
7841                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
7842                         len, test_index);
7843                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
7844                         received, test_index);
7845                 }
7846             } else {
7847                 BOOL has_prop = FALSE;
7848                 BSTR expected = NULL;
7849
7850                 hr = IUri_GetHost(uri, &expected);
7851                 ok(SUCCEEDED(hr),
7852                     "Error: Expected IUri_GetHost to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
7853                     hr, test_index);
7854                 has_prop = hr == S_OK;
7855
7856                 hr = IUriBuilder_GetHost(builder, &len, &received);
7857                 if(has_prop) {
7858                     ok(hr == S_OK,
7859                         "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7860                         hr, S_OK, test_index);
7861                     if(SUCCEEDED(hr)) {
7862                         ok(!lstrcmpW(expected, received),
7863                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
7864                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
7865                         ok(lstrlenW(expected) == len,
7866                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
7867                             lstrlenW(expected), len, test_index);
7868                     }
7869                 } else {
7870                     ok(hr == S_FALSE,
7871                         "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7872                         hr, S_FALSE, test_index);
7873                     if(SUCCEEDED(hr)) {
7874                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
7875                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
7876                             len, test_index);
7877                     }
7878                 }
7879                 SysFreeString(expected);
7880             }
7881         }
7882         if(uri) IUri_Release(uri);
7883     }
7884 }
7885
7886 static void test_IUriBuilder_GetPassword(IUriBuilder *builder, const uri_builder_test *test,
7887                                          DWORD test_index) {
7888     HRESULT hr;
7889     DWORD i;
7890     LPCWSTR received = NULL;
7891     DWORD len = -1;
7892     const uri_builder_property *prop = NULL;
7893
7894     /* Check if the property was set earlier. */
7895     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
7896         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_PASSWORD)
7897             prop = &(test->properties[i]);
7898     }
7899
7900     if(prop) {
7901         /* Use expected_value unless it's NULL, then use value. */
7902         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
7903         hr = IUriBuilder_GetPassword(builder, &len, &received);
7904         if(prop->todo) {
7905             todo_wine {
7906                 ok(hr == (expected ? S_OK : S_FALSE),
7907                     "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7908                     hr, (expected ? S_OK : S_FALSE), test_index);
7909             }
7910             if(SUCCEEDED(hr)) {
7911                 todo_wine {
7912                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
7913                         expected, wine_dbgstr_w(received), test_index);
7914                 }
7915                 todo_wine {
7916                     ok(lstrlen(expected) == len,
7917                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
7918                         lstrlen(expected), len, test_index);
7919                 }
7920             }
7921         } else {
7922             ok(hr == (expected ? S_OK : S_FALSE),
7923                 "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7924                 hr, (expected ? S_OK : S_FALSE), test_index);
7925             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
7926                 expected, wine_dbgstr_w(received), test_index);
7927             ok(lstrlen(expected) == len,
7928                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
7929                 lstrlen(expected), len, test_index);
7930         }
7931     } else {
7932         /* The property wasn't set earlier, so it should return whatever
7933          * the base IUri contains (if anything).
7934          */
7935         IUri *uri = NULL;
7936         hr = IUriBuilder_GetIUri(builder, &uri);
7937         ok(hr == S_OK,
7938             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7939             hr, S_OK, test_index);
7940         if(SUCCEEDED(hr)) {
7941             if(!uri) {
7942                 received = (void*) 0xdeadbeef;
7943                 len = -1;
7944
7945                 hr = IUriBuilder_GetPassword(builder, &len, &received);
7946                 ok(hr == S_FALSE,
7947                     "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7948                     hr, S_FALSE, test_index);
7949                 if(SUCCEEDED(hr)) {
7950                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
7951                         len, test_index);
7952                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
7953                         received, test_index);
7954                 }
7955             } else {
7956                 BOOL has_prop = FALSE;
7957                 BSTR expected = NULL;
7958
7959                 hr = IUri_GetPassword(uri, &expected);
7960                 ok(SUCCEEDED(hr),
7961                     "Error: Expected IUri_GetPassword to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
7962                     hr, test_index);
7963                 has_prop = hr == S_OK;
7964
7965                 hr = IUriBuilder_GetPassword(builder, &len, &received);
7966                 if(has_prop) {
7967                     ok(hr == S_OK,
7968                         "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7969                         hr, S_OK, test_index);
7970                     if(SUCCEEDED(hr)) {
7971                         ok(!lstrcmpW(expected, received),
7972                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
7973                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
7974                         ok(lstrlenW(expected) == len,
7975                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
7976                             lstrlenW(expected), len, test_index);
7977                     }
7978                 } else {
7979                     ok(hr == S_FALSE,
7980                         "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7981                         hr, S_FALSE, test_index);
7982                     if(SUCCEEDED(hr)) {
7983                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
7984                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
7985                             len, test_index);
7986                     }
7987                 }
7988                 SysFreeString(expected);
7989             }
7990         }
7991         if(uri) IUri_Release(uri);
7992     }
7993 }
7994
7995 static void test_IUriBuilder_GetPath(IUriBuilder *builder, const uri_builder_test *test,
7996                                      DWORD test_index) {
7997     HRESULT hr;
7998     DWORD i;
7999     LPCWSTR received = NULL;
8000     DWORD len = -1;
8001     const uri_builder_property *prop = NULL;
8002
8003     /* Check if the property was set earlier. */
8004     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8005         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_PATH)
8006             prop = &(test->properties[i]);
8007     }
8008
8009     if(prop) {
8010         /* Use expected_value unless it's NULL, then use value. */
8011         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8012         hr = IUriBuilder_GetPath(builder, &len, &received);
8013         if(prop->todo) {
8014             todo_wine {
8015                 ok(hr == (expected ? S_OK : S_FALSE),
8016                     "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8017                     hr, (expected ? S_OK : S_FALSE), test_index);
8018             }
8019             if(SUCCEEDED(hr)) {
8020                 todo_wine {
8021                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8022                         expected, wine_dbgstr_w(received), test_index);
8023                 }
8024                 todo_wine {
8025                     ok(lstrlen(expected) == len,
8026                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8027                         lstrlen(expected), len, test_index);
8028                 }
8029             }
8030         } else {
8031             ok(hr == (expected ? S_OK : S_FALSE),
8032                 "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8033                 hr, (expected ? S_OK : S_FALSE), test_index);
8034             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8035                 expected, wine_dbgstr_w(received), test_index);
8036             ok(lstrlen(expected) == len,
8037                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8038                 lstrlen(expected), len, test_index);
8039         }
8040     } else {
8041         /* The property wasn't set earlier, so it should return whatever
8042          * the base IUri contains (if anything).
8043          */
8044         IUri *uri = NULL;
8045         hr = IUriBuilder_GetIUri(builder, &uri);
8046         ok(hr == S_OK,
8047             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8048             hr, S_OK, test_index);
8049         if(SUCCEEDED(hr)) {
8050             if(!uri) {
8051                 received = (void*) 0xdeadbeef;
8052                 len = -1;
8053
8054                 hr = IUriBuilder_GetPath(builder, &len, &received);
8055                 ok(hr == S_FALSE,
8056                     "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8057                     hr, S_FALSE, test_index);
8058                 if(SUCCEEDED(hr)) {
8059                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8060                         len, test_index);
8061                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8062                         received, test_index);
8063                 }
8064             } else {
8065                 BOOL has_prop = FALSE;
8066                 BSTR expected = NULL;
8067
8068                 hr = IUri_GetPath(uri, &expected);
8069                 ok(SUCCEEDED(hr),
8070                     "Error: Expected IUri_GetPath to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8071                     hr, test_index);
8072                 has_prop = hr == S_OK;
8073
8074                 hr = IUriBuilder_GetPath(builder, &len, &received);
8075                 if(has_prop) {
8076                     ok(hr == S_OK,
8077                         "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8078                         hr, S_OK, test_index);
8079                     if(SUCCEEDED(hr)) {
8080                         ok(!lstrcmpW(expected, received),
8081                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8082                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8083                         ok(lstrlenW(expected) == len,
8084                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8085                             lstrlenW(expected), len, test_index);
8086                     }
8087                 } else {
8088                     ok(hr == S_FALSE,
8089                         "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8090                         hr, S_FALSE, test_index);
8091                     if(SUCCEEDED(hr)) {
8092                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8093                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8094                             len, test_index);
8095                     }
8096                 }
8097                 SysFreeString(expected);
8098             }
8099         }
8100         if(uri) IUri_Release(uri);
8101     }
8102 }
8103
8104 static void test_IUriBuilder_GetPort(IUriBuilder *builder, const uri_builder_test *test,
8105                                      DWORD test_index) {
8106     HRESULT hr;
8107     BOOL has_port = FALSE;
8108     DWORD received = -1;
8109
8110     if(test->port_prop.change) {
8111         DWORD expected = test->port_prop.value;
8112
8113         hr = IUriBuilder_GetPort(builder, &has_port, &received);
8114         if(test->port_prop.todo) {
8115             todo_wine {
8116                 ok(hr == S_OK,
8117                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8118                     hr, S_OK, test_index);
8119             }
8120             if(SUCCEEDED(hr)) {
8121                 todo_wine {
8122                     ok(has_port == test->port_prop.set,
8123                         "Error: Expected has_port to be %d but was %d instead on uri_builder_tests[%d].\n",
8124                         test->port_prop.set, has_port, test_index);
8125                 }
8126                 todo_wine {
8127                     ok(received == expected,
8128                         "Error: Expected received to be %d, but was %d instead on uri_builder_tests[%d].\n",
8129                         expected, received, test_index);
8130                 }
8131             }
8132         } else {
8133             ok(hr == S_OK,
8134                 "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8135                 hr, S_OK, test_index);
8136             ok(has_port == test->port_prop.set,
8137                 "Error: Expected has_port to be %d, but was %d instead on uri_builder_tests[%d].\n",
8138                 test->port_prop.set, has_port, test_index);
8139             ok(received == test->port_prop.value,
8140                 "Error: Expected port to be %d, but was %d instead on uri_builder_tests[%d].\n",
8141                 test->port_prop.value, received, test_index);
8142         }
8143     } else {
8144         IUri *uri = NULL;
8145
8146         hr = IUriBuilder_GetIUri(builder, &uri);
8147         ok(hr == S_OK,
8148             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8149             hr, S_OK, test_index);
8150         if(SUCCEEDED(hr)) {
8151             if(!uri) {
8152                 hr = IUriBuilder_GetPort(builder, &has_port, &received);
8153                 ok(hr == S_OK,
8154                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8155                     hr, S_OK, test_index);
8156                 if(SUCCEEDED(hr)) {
8157                     ok(has_port == FALSE,
8158                         "Error: Expected has_port to be FALSE, but was %d instead on uri_builder_tests[%d].\n",
8159                         has_port, test_index);
8160                     ok(!received, "Error: Expected received to be 0, but was %d instead on uri_builder_tests[%d].\n",
8161                         received, test_index);
8162                 }
8163             } else {
8164                 DWORD expected;
8165
8166                 hr = IUri_GetPort(uri, &expected);
8167                 ok(SUCCEEDED(hr),
8168                     "Error: Expected IUri_Port to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8169                     hr, test_index);
8170
8171                 hr = IUriBuilder_GetPort(builder, &has_port, &received);
8172                 ok(hr == S_OK,
8173                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8174                     hr, S_OK, test_index);
8175                 if(SUCCEEDED(hr)) {
8176                     ok(!has_port,
8177                         "Error: Expected has_port to be FALSE but was TRUE instead on uri_builder_tests[%d].\n",
8178                         test_index);
8179                     ok(received == expected,
8180                         "Error: Expected received to be %d, but was %d instead on uri_builder_tests[%d].\n",
8181                         expected, received, test_index);
8182                 }
8183             }
8184         }
8185         if(uri) IUri_Release(uri);
8186     }
8187 }
8188
8189 static void test_IUriBuilder_GetQuery(IUriBuilder *builder, const uri_builder_test *test,
8190                                       DWORD test_index) {
8191     HRESULT hr;
8192     DWORD i;
8193     LPCWSTR received = NULL;
8194     DWORD len = -1;
8195     const uri_builder_property *prop = NULL;
8196
8197     /* Check if the property was set earlier. */
8198     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8199         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_QUERY)
8200             prop = &(test->properties[i]);
8201     }
8202
8203     if(prop) {
8204         /* Use expected_value unless it's NULL, then use value. */
8205         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8206         hr = IUriBuilder_GetQuery(builder, &len, &received);
8207         if(prop->todo) {
8208             todo_wine {
8209                 ok(hr == (expected ? S_OK : S_FALSE),
8210                     "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8211                     hr, (expected ? S_OK : S_FALSE), test_index);
8212             }
8213             if(SUCCEEDED(hr)) {
8214                 todo_wine {
8215                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8216                         expected, wine_dbgstr_w(received), test_index);
8217                 }
8218                 todo_wine {
8219                     ok(lstrlen(expected) == len,
8220                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8221                         lstrlen(expected), len, test_index);
8222                 }
8223             }
8224         } else {
8225             ok(hr == (expected ? S_OK : S_FALSE),
8226                 "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8227                 hr, (expected ? S_OK : S_FALSE), test_index);
8228             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8229                 expected, wine_dbgstr_w(received), test_index);
8230             ok(lstrlen(expected) == len,
8231                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8232                 lstrlen(expected), len, test_index);
8233         }
8234     } else {
8235         /* The property wasn't set earlier, so it should return whatever
8236          * the base IUri contains (if anything).
8237          */
8238         IUri *uri = NULL;
8239         hr = IUriBuilder_GetIUri(builder, &uri);
8240         ok(hr == S_OK,
8241             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8242             hr, S_OK, test_index);
8243         if(SUCCEEDED(hr)) {
8244             if(!uri) {
8245                 received = (void*) 0xdeadbeef;
8246                 len = -1;
8247
8248                 hr = IUriBuilder_GetQuery(builder, &len, &received);
8249                 ok(hr == S_FALSE,
8250                     "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8251                     hr, S_FALSE, test_index);
8252                 if(SUCCEEDED(hr)) {
8253                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8254                         len, test_index);
8255                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8256                         received, test_index);
8257                 }
8258             } else {
8259                 BOOL has_prop = FALSE;
8260                 BSTR expected = NULL;
8261
8262                 hr = IUri_GetQuery(uri, &expected);
8263                 ok(SUCCEEDED(hr),
8264                     "Error: Expected IUri_GetQuery to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8265                     hr, test_index);
8266                 has_prop = hr == S_OK;
8267
8268                 hr = IUriBuilder_GetQuery(builder, &len, &received);
8269                 if(has_prop) {
8270                     ok(hr == S_OK,
8271                         "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8272                         hr, S_OK, test_index);
8273                     if(SUCCEEDED(hr)) {
8274                         ok(!lstrcmpW(expected, received),
8275                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8276                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8277                         ok(lstrlenW(expected) == len,
8278                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8279                             lstrlenW(expected), len, test_index);
8280                     }
8281                 } else {
8282                     ok(hr == S_FALSE,
8283                         "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8284                         hr, S_FALSE, test_index);
8285                     if(SUCCEEDED(hr)) {
8286                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8287                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8288                             len, test_index);
8289                     }
8290                 }
8291                 SysFreeString(expected);
8292             }
8293         }
8294         if(uri) IUri_Release(uri);
8295     }
8296 }
8297
8298 static void test_IUriBuilder_GetSchemeName(IUriBuilder *builder, const uri_builder_test *test,
8299                                            DWORD test_index) {
8300     HRESULT hr;
8301     DWORD i;
8302     LPCWSTR received = NULL;
8303     DWORD len = -1;
8304     const uri_builder_property *prop = NULL;
8305
8306     /* Check if the property was set earlier. */
8307     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8308         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_SCHEME_NAME)
8309             prop = &(test->properties[i]);
8310     }
8311
8312     if(prop) {
8313         /* Use expected_value unless it's NULL, then use value. */
8314         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8315         hr = IUriBuilder_GetSchemeName(builder, &len, &received);
8316         if(prop->todo) {
8317             todo_wine {
8318                 ok(hr == (expected ? S_OK : S_FALSE),
8319                     "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8320                     hr, (expected ? S_OK : S_FALSE), test_index);
8321             }
8322             if(SUCCEEDED(hr)) {
8323                 todo_wine {
8324                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8325                         expected, wine_dbgstr_w(received), test_index);
8326                 }
8327                 todo_wine {
8328                     ok(lstrlen(expected) == len,
8329                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8330                         lstrlen(expected), len, test_index);
8331                 }
8332             }
8333         } else {
8334             ok(hr == (expected ? S_OK : S_FALSE),
8335                 "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8336                 hr, (expected ? S_OK : S_FALSE), test_index);
8337             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8338                 expected, wine_dbgstr_w(received), test_index);
8339             ok(lstrlen(expected) == len,
8340                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8341                 lstrlen(expected), len, test_index);
8342         }
8343     } else {
8344         /* The property wasn't set earlier, so it should return whatever
8345          * the base IUri contains (if anything).
8346          */
8347         IUri *uri = NULL;
8348         hr = IUriBuilder_GetIUri(builder, &uri);
8349         ok(hr == S_OK,
8350             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8351             hr, S_OK, test_index);
8352         if(SUCCEEDED(hr)) {
8353             if(!uri) {
8354                 received = (void*) 0xdeadbeef;
8355                 len = -1;
8356
8357                 hr = IUriBuilder_GetSchemeName(builder, &len, &received);
8358                 ok(hr == S_FALSE,
8359                     "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8360                     hr, S_FALSE, test_index);
8361                 if(SUCCEEDED(hr)) {
8362                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8363                         len, test_index);
8364                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8365                         received, test_index);
8366                 }
8367             } else {
8368                 BOOL has_prop = FALSE;
8369                 BSTR expected = NULL;
8370
8371                 hr = IUri_GetSchemeName(uri, &expected);
8372                 ok(SUCCEEDED(hr),
8373                     "Error: Expected IUri_GetSchemeName to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8374                     hr, test_index);
8375                 has_prop = hr == S_OK;
8376
8377                 hr = IUriBuilder_GetSchemeName(builder, &len, &received);
8378                 if(has_prop) {
8379                     ok(hr == S_OK,
8380                         "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8381                         hr, S_OK, test_index);
8382                     if(SUCCEEDED(hr)) {
8383                         ok(!lstrcmpW(expected, received),
8384                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8385                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8386                         ok(lstrlenW(expected) == len,
8387                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8388                             lstrlenW(expected), len, test_index);
8389                     }
8390                 } else {
8391                     ok(hr == S_FALSE,
8392                         "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8393                         hr, S_FALSE, test_index);
8394                     if(SUCCEEDED(hr)) {
8395                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8396                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8397                             len, test_index);
8398                     }
8399                 }
8400                 SysFreeString(expected);
8401             }
8402         }
8403         if(uri) IUri_Release(uri);
8404     }
8405 }
8406
8407 static void test_IUriBuilder_GetUserName(IUriBuilder *builder, const uri_builder_test *test,
8408                                          DWORD test_index) {
8409     HRESULT hr;
8410     DWORD i;
8411     LPCWSTR received = NULL;
8412     DWORD len = -1;
8413     const uri_builder_property *prop = NULL;
8414
8415     /* Check if the property was set earlier. */
8416     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8417         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_USER_NAME)
8418             prop = &(test->properties[i]);
8419     }
8420
8421     if(prop && prop->value && *prop->value) {
8422         /* Use expected_value unless it's NULL, then use value. */
8423         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8424         hr = IUriBuilder_GetUserName(builder, &len, &received);
8425         if(prop->todo) {
8426             todo_wine {
8427                 ok(hr == (expected ? S_OK : S_FALSE),
8428                     "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8429                     hr, (expected ? S_OK : S_FALSE), test_index);
8430             }
8431             if(SUCCEEDED(hr)) {
8432                 todo_wine {
8433                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8434                         expected, wine_dbgstr_w(received), test_index);
8435                 }
8436                 todo_wine {
8437                     ok(lstrlen(expected) == len,
8438                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8439                         lstrlen(expected), len, test_index);
8440                 }
8441             }
8442         } else {
8443             ok(hr == (expected ? S_OK : S_FALSE),
8444                 "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8445                 hr, (expected ? S_OK : S_FALSE), test_index);
8446             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8447                 expected, wine_dbgstr_w(received), test_index);
8448             ok(lstrlen(expected) == len,
8449                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8450                 lstrlen(expected), len, test_index);
8451         }
8452     } else {
8453         /* The property wasn't set earlier, so it should return whatever
8454          * the base IUri contains (if anything).
8455          */
8456         IUri *uri = NULL;
8457         hr = IUriBuilder_GetIUri(builder, &uri);
8458         ok(hr == S_OK,
8459             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8460             hr, S_OK, test_index);
8461         if(SUCCEEDED(hr)) {
8462             if(!uri) {
8463                 received = (void*) 0xdeadbeef;
8464                 len = -1;
8465
8466                 hr = IUriBuilder_GetUserName(builder, &len, &received);
8467                 ok(hr == S_FALSE,
8468                     "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8469                     hr, S_FALSE, test_index);
8470                 if(SUCCEEDED(hr)) {
8471                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8472                         len, test_index);
8473                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8474                         received, test_index);
8475                 }
8476             } else {
8477                 BSTR expected = NULL;
8478                 BOOL has_prop = FALSE;
8479
8480                 hr = IUri_GetUserName(uri, &expected);
8481                 ok(SUCCEEDED(hr),
8482                     "Error: Expected IUri_GetUserName to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8483                     hr, test_index);
8484                 has_prop = hr == S_OK;
8485
8486                 hr = IUriBuilder_GetUserName(builder, &len, &received);
8487                 if(has_prop) {
8488                     ok(hr == S_OK,
8489                         "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8490                         hr, S_OK, test_index);
8491                     if(SUCCEEDED(hr)) {
8492                         ok(!lstrcmpW(expected, received),
8493                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8494                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8495                         ok(lstrlenW(expected) == len,
8496                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8497                             lstrlenW(expected), len, test_index);
8498                     }
8499                 } else {
8500                     ok(hr == S_FALSE,
8501                         "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8502                         hr, S_FALSE, test_index);
8503                     if(SUCCEEDED(hr)) {
8504                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8505                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8506                             len, test_index);
8507                     }
8508                 }
8509                 SysFreeString(expected);
8510             }
8511         }
8512         if(uri) IUri_Release(uri);
8513     }
8514 }
8515
8516 /* Tests IUriBuilder functions. */
8517 static void test_IUriBuilder(void) {
8518     HRESULT hr;
8519     IUriBuilder *builder;
8520     DWORD i;
8521
8522     for(i = 0; i < sizeof(uri_builder_tests)/sizeof(uri_builder_tests[0]); ++i) {
8523         IUri *uri = NULL;
8524         uri_builder_test test = uri_builder_tests[i];
8525         LPWSTR uriW = NULL;
8526
8527         if(test.uri) {
8528             uriW = a2w(test.uri);
8529             hr = pCreateUri(uriW, test.create_flags, 0, &uri);
8530             ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8531                 hr, S_OK, i);
8532             if(FAILED(hr)) continue;
8533         }
8534         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
8535         if(test.create_builder_todo) {
8536             todo_wine {
8537                 ok(hr == test.create_builder_expected,
8538                     "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8539                     hr, test.create_builder_expected, i);
8540             }
8541         } else {
8542             ok(hr == test.create_builder_expected,
8543                 "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8544                 hr, test.create_builder_expected, i);
8545         }
8546         if(SUCCEEDED(hr)) {
8547             DWORD j;
8548             BOOL modified = FALSE, received = FALSE;
8549
8550             /* Perform all the string property changes. */
8551             for(j = 0; j < URI_BUILDER_STR_PROPERTY_COUNT; ++j) {
8552                 uri_builder_property prop = test.properties[j];
8553                 if(prop.change) {
8554                     change_property(builder, &prop, i);
8555                     if(prop.property != Uri_PROPERTY_SCHEME_NAME &&
8556                        prop.property != Uri_PROPERTY_HOST)
8557                         modified = TRUE;
8558                     else if(prop.value && *prop.value)
8559                         modified = TRUE;
8560                     else if(prop.value && !*prop.value && prop.property == Uri_PROPERTY_HOST)
8561                         /* Host name property can't be NULL, but it can be empty. */
8562                         modified = TRUE;
8563                 }
8564             }
8565
8566             if(test.port_prop.change) {
8567                 hr = IUriBuilder_SetPort(builder, test.port_prop.set, test.port_prop.value);
8568                 modified = TRUE;
8569                 if(test.port_prop.todo) {
8570                     todo_wine {
8571                         ok(hr == test.port_prop.expected,
8572                             "Error: IUriBuilder_SetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8573                             hr, test.port_prop.expected, i);
8574                     }
8575                 } else {
8576                     ok(hr == test.port_prop.expected,
8577                         "Error: IUriBuilder_SetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8578                         hr, test.port_prop.expected, i);
8579                 }
8580             }
8581
8582             hr = IUriBuilder_HasBeenModified(builder, &received);
8583             ok(hr == S_OK,
8584                 "Error IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8585                 hr, S_OK, i);
8586             if(SUCCEEDED(hr))
8587                 ok(received == modified,
8588                     "Error: Expected received to be %d but was %d instead on uri_builder_tests[%d].\n",
8589                     modified, received, i);
8590
8591             /* Test the "Get*" functions. */
8592             test_IUriBuilder_GetFragment(builder, &test, i);
8593             test_IUriBuilder_GetHost(builder, &test, i);
8594             test_IUriBuilder_GetPassword(builder, &test, i);
8595             test_IUriBuilder_GetPath(builder, &test, i);
8596             test_IUriBuilder_GetPort(builder, &test, i);
8597             test_IUriBuilder_GetQuery(builder, &test, i);
8598             test_IUriBuilder_GetSchemeName(builder, &test, i);
8599             test_IUriBuilder_GetUserName(builder, &test, i);
8600
8601             test_IUriBuilder_CreateUri(builder, &test, i);
8602             test_IUriBuilder_CreateUriSimple(builder, &test, i);
8603             test_IUriBuilder_CreateUriWithFlags(builder, &test, i);
8604         }
8605         if(builder) IUriBuilder_Release(builder);
8606         if(uri) IUri_Release(uri);
8607         heap_free(uriW);
8608     }
8609 }
8610
8611 static void test_IUriBuilder_HasBeenModified(void) {
8612     HRESULT hr;
8613     IUriBuilder *builder = NULL;
8614
8615     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
8616     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8617     if(SUCCEEDED(hr)) {
8618         static const WCHAR hostW[] = {'g','o','o','g','l','e','.','c','o','m',0};
8619         IUri *uri = NULL;
8620         BOOL received;
8621
8622         hr = IUriBuilder_HasBeenModified(builder, NULL);
8623         ok(hr == E_POINTER, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
8624             hr, E_POINTER);
8625
8626         hr = IUriBuilder_SetHost(builder, hostW);
8627         ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n",
8628             hr, S_OK);
8629
8630         hr = IUriBuilder_HasBeenModified(builder, &received);
8631         ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
8632             hr, S_OK);
8633         if(SUCCEEDED(hr))
8634             ok(received == TRUE, "Error: Expected received to be TRUE.\n");
8635
8636         hr = pCreateUri(http_urlW, 0, 0, &uri);
8637         ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8638         if(SUCCEEDED(hr)) {
8639             LPCWSTR prop;
8640             DWORD len = -1;
8641
8642             hr = IUriBuilder_SetIUri(builder, uri);
8643             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n",
8644                 hr, S_OK);
8645
8646             hr = IUriBuilder_HasBeenModified(builder, &received);
8647             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
8648                 hr, S_OK);
8649             if(SUCCEEDED(hr))
8650                 ok(received == FALSE, "Error: Expected received to be FALSE.\n");
8651
8652             /* Test what happens with you call SetIUri with the same IUri again. */
8653             hr = IUriBuilder_SetHost(builder, hostW);
8654             ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8655
8656             hr = IUriBuilder_HasBeenModified(builder, &received);
8657             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
8658                 hr, S_OK);
8659             if(SUCCEEDED(hr))
8660                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
8661
8662             hr = IUriBuilder_SetIUri(builder, uri);
8663             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8664
8665             /* IUriBuilder already had 'uri' as it's IUri property and so Windows doesn't
8666              * reset any of the changes that were made to the IUriBuilder.
8667              */
8668             hr = IUriBuilder_HasBeenModified(builder, &received);
8669             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8670             if(SUCCEEDED(hr))
8671                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
8672
8673             hr = IUriBuilder_GetHost(builder, &len, &prop);
8674             ok(hr == S_OK, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8675             if(SUCCEEDED(hr)) {
8676                 ok(!lstrcmpW(prop, hostW), "Error: Expected %s but got %s instead.\n",
8677                     wine_dbgstr_w(hostW), wine_dbgstr_w(prop));
8678                 ok(len == lstrlenW(hostW), "Error: Expected len to be %d, but was %d instead.\n",
8679                     lstrlenW(hostW), len);
8680             }
8681
8682             hr = IUriBuilder_SetIUri(builder, NULL);
8683             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8684
8685             hr = IUriBuilder_SetHost(builder, hostW);
8686             ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8687             hr = IUriBuilder_HasBeenModified(builder, &received);
8688             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
8689                 hr, S_OK);
8690             if(SUCCEEDED(hr))
8691                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
8692
8693             hr = IUriBuilder_SetIUri(builder, NULL);
8694             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%09x.\n", hr, S_OK);
8695
8696             hr = IUriBuilder_HasBeenModified(builder, &received);
8697             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
8698                 hr, S_OK);
8699             if(SUCCEEDED(hr))
8700                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
8701
8702             hr = IUriBuilder_GetHost(builder, &len, &prop);
8703             ok(hr == S_OK, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8704             if(SUCCEEDED(hr)) {
8705                 ok(!lstrcmpW(prop, hostW), "Error: Expected %s but got %s instead.\n",
8706                     wine_dbgstr_w(hostW), wine_dbgstr_w(prop));
8707                 ok(len == lstrlenW(hostW), "Error: Expected len to %d, but was %d instead.\n",
8708                     lstrlenW(hostW), len);
8709             }
8710         }
8711         if(uri) IUri_Release(uri);
8712     }
8713     if(builder) IUriBuilder_Release(builder);
8714 }
8715
8716 /* Test IUriBuilder {Get,Set}IUri functions. */
8717 static void test_IUriBuilder_IUriProperty(void) {
8718     IUriBuilder *builder = NULL;
8719     HRESULT hr;
8720
8721     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
8722     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8723     if(SUCCEEDED(hr)) {
8724         IUri *uri = NULL;
8725
8726         hr = IUriBuilder_GetIUri(builder, NULL);
8727         ok(hr == E_POINTER, "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x.\n",
8728             hr, E_POINTER);
8729
8730         hr = pCreateUri(http_urlW, 0, 0, &uri);
8731         if(SUCCEEDED(hr)) {
8732             IUri *test = NULL;
8733             ULONG cur_count, orig_count;
8734
8735             /* IUriBuilder doesn't clone the IUri, it use the same IUri. */
8736             orig_count = get_refcnt(uri);
8737             hr = IUriBuilder_SetIUri(builder, uri);
8738             cur_count = get_refcnt(uri);
8739             if(SUCCEEDED(hr))
8740                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
8741                     orig_count+1, cur_count);
8742
8743             hr = IUriBuilder_SetIUri(builder, NULL);
8744             cur_count = get_refcnt(uri);
8745             if(SUCCEEDED(hr))
8746                 ok(cur_count == orig_count, "Error: Expected uri ref count to be %d, but was %d instead.\n",
8747                     orig_count, cur_count);
8748
8749             /* CreateUri* functions will return back the same IUri if nothing has changed. */
8750             hr = IUriBuilder_SetIUri(builder, uri);
8751             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8752             orig_count = get_refcnt(uri);
8753
8754             hr = IUriBuilder_CreateUri(builder, 0, 0, 0, &test);
8755             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8756             if(SUCCEEDED(hr)) {
8757                 cur_count = get_refcnt(uri);
8758                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
8759                     orig_count+1, cur_count);
8760                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n",
8761                     uri, test);
8762             }
8763             if(test) IUri_Release(test);
8764
8765             test = NULL;
8766             hr = IUriBuilder_CreateUri(builder, -1, 0, 0, &test);
8767             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8768             if(SUCCEEDED(hr)) {
8769                 cur_count = get_refcnt(uri);
8770                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
8771                     orig_count+1, cur_count);
8772                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
8773             }
8774             if(test) IUri_Release(test);
8775
8776             /* Doesn't return the same IUri, if the flag combination is different then the one that created
8777              * the base IUri.
8778              */
8779             test = NULL;
8780             hr = IUriBuilder_CreateUri(builder, Uri_CREATE_ALLOW_RELATIVE, 0, 0, &test);
8781             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8782             if(SUCCEEDED(hr))
8783                 ok(test != uri, "Error: Wasn't expecting 'test' to be 'uri'\n");
8784
8785             if(test) IUri_Release(test);
8786
8787             /* Still returns the same IUri, even though the base one wasn't created with CREATE_CANONICALIZE
8788              * explicitly set (because it's a default flags).
8789              */
8790             test = NULL;
8791             hr = IUriBuilder_CreateUri(builder, Uri_CREATE_CANONICALIZE, 0, 0, &test);
8792             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8793             if(SUCCEEDED(hr)) {
8794                 cur_count = get_refcnt(uri);
8795                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
8796                     orig_count+1, cur_count);
8797                 ok(test == uri, "Error: Expected 'test' to be %p, but was %p instead.\n", uri, test);
8798             }
8799             if(test) IUri_Release(test);
8800
8801             test = NULL;
8802             hr = IUriBuilder_CreateUriSimple(builder, 0, 0, &test);
8803             ok(hr == S_OK, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8804             if(SUCCEEDED(hr)) {
8805                 cur_count = get_refcnt(uri);
8806                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
8807                     orig_count+1, cur_count);
8808                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
8809             }
8810             if(test) IUri_Release(test);
8811
8812             test = NULL;
8813             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, &test);
8814             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
8815                 hr, S_OK);
8816             if(SUCCEEDED(hr)) {
8817                 cur_count = get_refcnt(uri);
8818                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
8819                     orig_count+1, cur_count);
8820                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
8821             }
8822             if(test) IUri_Release(test);
8823
8824             /* Doesn't return the same IUri, if the flag combination is different then the one that created
8825              * the base IUri.
8826              */
8827             test = NULL;
8828             hr = IUriBuilder_CreateUriWithFlags(builder, Uri_CREATE_ALLOW_RELATIVE, 0, 0, 0, &test);
8829             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8830             if(SUCCEEDED(hr))
8831                 ok(test != uri, "Error: Wasn't expecting 'test' to be 'uri'\n");
8832
8833             if(test) IUri_Release(test);
8834
8835             /* Still returns the same IUri, even though the base one wasn't created with CREATE_CANONICALIZE
8836              * explicitly set (because it's a default flags).
8837              */
8838             test = NULL;
8839             hr = IUriBuilder_CreateUriWithFlags(builder, Uri_CREATE_CANONICALIZE, 0, 0, 0, &test);
8840             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags 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", uri, test);
8846             }
8847             if(test) IUri_Release(test);
8848         }
8849         if(uri) IUri_Release(uri);
8850     }
8851     if(builder) IUriBuilder_Release(builder);
8852 }
8853
8854 static void test_IUriBuilder_RemoveProperties(void) {
8855     IUriBuilder *builder = NULL;
8856     HRESULT hr;
8857     DWORD i;
8858
8859     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
8860     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8861     if(SUCCEEDED(hr)) {
8862         /* Properties that can't be removed. */
8863         const DWORD invalid = Uri_HAS_ABSOLUTE_URI|Uri_HAS_DISPLAY_URI|Uri_HAS_RAW_URI|Uri_HAS_HOST_TYPE|
8864                               Uri_HAS_SCHEME|Uri_HAS_ZONE;
8865
8866         for(i = Uri_PROPERTY_STRING_START; i <= Uri_PROPERTY_DWORD_LAST; ++i) {
8867             hr = IUriBuilder_RemoveProperties(builder, i << 1);
8868             if((i << 1) & invalid) {
8869                 ok(hr == E_INVALIDARG,
8870                     "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x with prop=%d.\n",
8871                     hr, E_INVALIDARG, i);
8872             } else {
8873                 ok(hr == S_OK,
8874                     "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x with prop=%d.\n",
8875                     hr, S_OK, i);
8876             }
8877         }
8878
8879         /* Also doesn't accept anything that's outside the range of the
8880          * Uri_HAS flags.
8881          */
8882         hr = IUriBuilder_RemoveProperties(builder, (Uri_PROPERTY_DWORD_LAST+1) << 1);
8883         ok(hr == E_INVALIDARG, "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x.\n",
8884             hr, E_INVALIDARG);
8885     }
8886     if(builder) IUriBuilder_Release(builder);
8887
8888     for(i = 0; i < sizeof(uri_builder_remove_tests)/sizeof(uri_builder_remove_tests[0]); ++i) {
8889         uri_builder_remove_test test = uri_builder_remove_tests[i];
8890         IUri *uri = NULL;
8891         LPWSTR uriW;
8892
8893         uriW = a2w(test.uri);
8894         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
8895         if(SUCCEEDED(hr)) {
8896             builder = NULL;
8897
8898             hr = pCreateIUriBuilder(uri, 0, 0, &builder);
8899             if(test.create_builder_todo) {
8900                 todo_wine {
8901                     ok(hr == test.create_builder_expected,
8902                         "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
8903                         hr, test.create_builder_expected, i);
8904                 }
8905             } else {
8906                 ok(hr == test.create_builder_expected,
8907                     "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
8908                     hr, test.create_builder_expected, i);
8909             }
8910             if(SUCCEEDED(hr)) {
8911                 hr = IUriBuilder_RemoveProperties(builder, test.remove_properties);
8912                 if(test.remove_todo) {
8913                     todo_wine {
8914                         ok(hr == test.remove_expected,
8915                             "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x on test %d.\n",
8916                             hr, test.remove_expected, i);
8917                     }
8918                 } else {
8919                     ok(hr == test.remove_expected,
8920                         "Error: IUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
8921                         hr, test.remove_expected, i);
8922                 }
8923                 if(SUCCEEDED(hr)) {
8924                     IUri *result = NULL;
8925
8926                     hr = IUriBuilder_CreateUri(builder, test.expected_flags, 0, 0, &result);
8927                     if(test.expected_todo) {
8928                         todo_wine {
8929                             ok(hr == test.expected_hres,
8930                                 "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on test %d.\n",
8931                                 hr, test.expected_hres, i);
8932                         }
8933                     } else {
8934                         ok(hr == test.expected_hres,
8935                             "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on test %d.\n",
8936                             hr, test.expected_hres, i);
8937                     }
8938                     if(SUCCEEDED(hr)) {
8939                         BSTR received = NULL;
8940
8941                         hr = IUri_GetAbsoluteUri(result, &received);
8942                         ok(!strcmp_aw(test.expected_uri, received),
8943                             "Error: Expected %s but got %s instead on test %d.\n",
8944                             test.expected_uri, wine_dbgstr_w(received), i);
8945                         SysFreeString(received);
8946                     }
8947                     if(result) IUri_Release(result);
8948                 }
8949             }
8950             if(builder) IUriBuilder_Release(builder);
8951         }
8952         if(uri) IUri_Release(uri);
8953         heap_free(uriW);
8954     }
8955 }
8956
8957 static void test_IUriBuilder_Misc(void) {
8958     HRESULT hr;
8959     IUri *uri;
8960
8961     hr = pCreateUri(http_urlW, 0, 0, &uri);
8962     if(SUCCEEDED(hr)) {
8963         IUriBuilder *builder;
8964
8965         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
8966         ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8967         if(SUCCEEDED(hr)) {
8968             BOOL has = -1;
8969             DWORD port = -1;
8970
8971             hr = IUriBuilder_GetPort(builder, &has, &port);
8972             ok(hr == S_OK, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8973             if(SUCCEEDED(hr)) {
8974                 /* 'has' will be set to FALSE, even though uri had a port. */
8975                 ok(has == FALSE, "Error: Expected 'has' to be FALSE, was %d instead.\n", has);
8976                 /* Still sets 'port' to 80. */
8977                 ok(port == 80, "Error: Expected the port to be 80, but, was %d instead.\n", port);
8978             }
8979         }
8980         if(builder) IUriBuilder_Release(builder);
8981     }
8982     if(uri) IUri_Release(uri);
8983 }
8984
8985 static void test_CoInternetCombineIUri(void) {
8986     HRESULT hr;
8987     IUri *base, *relative, *result;
8988     DWORD i;
8989
8990     base = NULL;
8991     hr = pCreateUri(http_urlW, 0, 0, &base);
8992     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x.\n", hr);
8993     if(SUCCEEDED(hr)) {
8994         result = (void*) 0xdeadbeef;
8995         hr = pCoInternetCombineIUri(base, NULL, 0, &result, 0);
8996         ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
8997         ok(!result, "Error: Expected 'result' to be NULL, was %p.\n", result);
8998     }
8999
9000     relative = NULL;
9001     hr = pCreateUri(http_urlW, 0, 0, &relative);
9002     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x.\n", hr);
9003     if(SUCCEEDED(hr)) {
9004         result = (void*) 0xdeadbeef;
9005         hr = pCoInternetCombineIUri(NULL, relative, 0, &result, 0);
9006         ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9007         ok(!result, "Error: Expected 'result' to be NULL, was %p.\n", result);
9008     }
9009
9010     hr = pCoInternetCombineIUri(base, relative, 0, NULL, 0);
9011     ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9012
9013     if(base) IUri_Release(base);
9014     if(relative) IUri_Release(relative);
9015
9016     for(i = 0; i < sizeof(uri_combine_tests)/sizeof(uri_combine_tests[0]); ++i) {
9017         LPWSTR baseW = a2w(uri_combine_tests[i].base_uri);
9018
9019         hr = pCreateUri(baseW, uri_combine_tests[i].base_create_flags, 0, &base);
9020         ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x on uri_combine_tests[%d].\n", hr, i);
9021         if(SUCCEEDED(hr)) {
9022             LPWSTR relativeW = a2w(uri_combine_tests[i].relative_uri);
9023
9024             hr = pCreateUri(relativeW, uri_combine_tests[i].relative_create_flags, 0, &relative);
9025             ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x on uri_combine_tests[%d].\n", hr, i);
9026             if(SUCCEEDED(hr)) {
9027                 result = NULL;
9028
9029                 hr = pCoInternetCombineIUri(base, relative, uri_combine_tests[i].combine_flags, &result, 0);
9030                 if(uri_combine_tests[i].todo) {
9031                     todo_wine {
9032                         ok(hr == uri_combine_tests[i].expected,
9033                             "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9034                             hr, uri_combine_tests[i].expected, i);
9035                     }
9036                 } else {
9037                     ok(hr == uri_combine_tests[i].expected,
9038                         "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9039                         hr, uri_combine_tests[i]. expected, i);
9040                 }
9041                 if(SUCCEEDED(hr)) {
9042                     DWORD j;
9043
9044                     for(j = 0; j < sizeof(uri_combine_tests[i].str_props)/sizeof(uri_combine_tests[i].str_props[0]); ++j) {
9045                         uri_combine_str_property prop = uri_combine_tests[i].str_props[j];
9046                         BSTR received;
9047
9048                         hr = IUri_GetPropertyBSTR(result, j, &received, 0);
9049                         if(prop.todo) {
9050                             todo_wine {
9051                                 ok(hr == prop.expected,
9052                                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9053                                     hr, prop.expected, i, j);
9054                             }
9055                             todo_wine {
9056                                 ok(!strcmp_aw(prop.value, received) ||
9057                                    broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9058                                     "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9059                                     prop.value, wine_dbgstr_w(received), i, j);
9060                             }
9061                         } else {
9062                             ok(hr == prop.expected,
9063                                 "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9064                                 hr, prop.expected, i, j);
9065                             ok(!strcmp_aw(prop.value, received) ||
9066                                broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9067                                 "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9068                                 prop.value, wine_dbgstr_w(received), i, j);
9069                         }
9070                         SysFreeString(received);
9071                     }
9072
9073                     for(j = 0; j < sizeof(uri_combine_tests[i].dword_props)/sizeof(uri_combine_tests[i].dword_props[0]); ++j) {
9074                         uri_dword_property prop = uri_combine_tests[i].dword_props[j];
9075                         DWORD received;
9076
9077                         hr = IUri_GetPropertyDWORD(result, j+Uri_PROPERTY_DWORD_START, &received, 0);
9078                         if(prop.todo) {
9079                             todo_wine {
9080                                 ok(hr == prop.expected,
9081                                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9082                                     hr, prop.expected, i, j);
9083                             }
9084                             todo_wine {
9085                                 ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9086                                     prop.value, received, i, j);
9087                             }
9088                         } else {
9089                             ok(hr == prop.expected,
9090                                 "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9091                                 hr, prop.expected, i, j);
9092                             ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9093                                 prop.value, received, i, j);
9094                         }
9095                     }
9096                 }
9097                 if(result) IUri_Release(result);
9098             }
9099             if(relative) IUri_Release(relative);
9100             heap_free(relativeW);
9101         }
9102         if(base) IUri_Release(base);
9103         heap_free(baseW);
9104     }
9105 }
9106
9107 static HRESULT WINAPI InternetProtocolInfo_QueryInterface(IInternetProtocolInfo *iface,
9108                                                           REFIID riid, void **ppv)
9109 {
9110     ok(0, "unexpected call\n");
9111     return E_NOINTERFACE;
9112 }
9113
9114 static ULONG WINAPI InternetProtocolInfo_AddRef(IInternetProtocolInfo *iface)
9115 {
9116     return 2;
9117 }
9118
9119 static ULONG WINAPI InternetProtocolInfo_Release(IInternetProtocolInfo *iface)
9120 {
9121     return 1;
9122 }
9123
9124 static HRESULT WINAPI InternetProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
9125         PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
9126         DWORD *pcchResult, DWORD dwReserved)
9127 {
9128     ok(0, "unexpected call %d\n", ParseAction);
9129     return E_NOTIMPL;
9130 }
9131
9132 static HRESULT WINAPI InternetProtocolInfo_CombineUrl(IInternetProtocolInfo *iface,
9133         LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags,
9134         LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
9135 {
9136     CHECK_EXPECT(CombineUrl);
9137     ok(!lstrcmpW(pwzBaseUrl, combine_baseW), "Error: Expected %s, but got %s instead.\n",
9138         wine_dbgstr_w(combine_baseW), wine_dbgstr_w(pwzBaseUrl));
9139     ok(!lstrcmpW(pwzRelativeUrl, combine_relativeW), "Error: Expected %s, but got %s instead.\n",
9140         wine_dbgstr_w(combine_relativeW), wine_dbgstr_w(pwzRelativeUrl));
9141     ok(dwCombineFlags == (URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO),
9142         "Error: Expected 0, but got 0x%08x.\n", dwCombineFlags);
9143     ok(cchResult == INTERNET_MAX_URL_LENGTH+1, "Error: Expected %d, but got %d.\n", INTERNET_MAX_URL_LENGTH+1, cchResult);
9144
9145     memcpy(pwzResult, combine_resultW, sizeof(combine_resultW));
9146     *pcchResult = lstrlenW(combine_resultW);
9147
9148     return S_OK;
9149 }
9150
9151 static HRESULT WINAPI InternetProtocolInfo_CompareUrl(IInternetProtocolInfo *iface,
9152         LPCWSTR pwzUrl1, LPCWSTR pwzUrl2, DWORD dwCompareFlags)
9153 {
9154     ok(0, "unexpected call\n");
9155     return E_NOTIMPL;
9156 }
9157
9158 static HRESULT WINAPI InternetProtocolInfo_QueryInfo(IInternetProtocolInfo *iface,
9159         LPCWSTR pwzUrl, QUERYOPTION OueryOption, DWORD dwQueryFlags, LPVOID pBuffer,
9160         DWORD cbBuffer, DWORD *pcbBuf, DWORD dwReserved)
9161 {
9162     ok(0, "unexpected call\n");
9163     return E_NOTIMPL;
9164 }
9165
9166 static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl = {
9167     InternetProtocolInfo_QueryInterface,
9168     InternetProtocolInfo_AddRef,
9169     InternetProtocolInfo_Release,
9170     InternetProtocolInfo_ParseUrl,
9171     InternetProtocolInfo_CombineUrl,
9172     InternetProtocolInfo_CompareUrl,
9173     InternetProtocolInfo_QueryInfo
9174 };
9175
9176 static IInternetProtocolInfo protocol_info = { &InternetProtocolInfoVtbl };
9177
9178 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
9179 {
9180     if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) {
9181         *ppv = &protocol_info;
9182         return S_OK;
9183     }
9184
9185     ok(0, "unexpected call\n");
9186     return E_NOINTERFACE;
9187 }
9188
9189 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
9190 {
9191     return 2;
9192 }
9193
9194 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
9195 {
9196     return 1;
9197 }
9198
9199 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
9200                                         REFIID riid, void **ppv)
9201 {
9202     ok(0, "unexpected call\n");
9203     return E_NOTIMPL;
9204 }
9205
9206 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
9207 {
9208     ok(0, "unexpected call\n");
9209     return S_OK;
9210 }
9211
9212 static const IClassFactoryVtbl ClassFactoryVtbl = {
9213     ClassFactory_QueryInterface,
9214     ClassFactory_AddRef,
9215     ClassFactory_Release,
9216     ClassFactory_CreateInstance,
9217     ClassFactory_LockServer
9218 };
9219
9220 static IClassFactory protocol_cf = { &ClassFactoryVtbl };
9221
9222 static void register_protocols(void)
9223 {
9224     IInternetSession *session;
9225     HRESULT hres;
9226
9227     hres = pCoInternetGetSession(0, &session, 0);
9228     ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
9229     if(FAILED(hres))
9230         return;
9231
9232     hres = IInternetSession_RegisterNameSpace(session, &protocol_cf, &IID_NULL,
9233             winetestW, 0, NULL, 0);
9234     ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
9235
9236     IInternetSession_Release(session);
9237 }
9238
9239 static void unregister_protocols(void) {
9240     IInternetSession *session;
9241     HRESULT hr;
9242
9243     hr = pCoInternetGetSession(0, &session, 0);
9244     ok(hr == S_OK, "CoInternetGetSession failed: 0x%08x\n", hr);
9245     if(FAILED(hr))
9246         return;
9247
9248     hr = IInternetSession_UnregisterNameSpace(session, &protocol_cf, winetestW);
9249     ok(hr == S_OK, "UnregisterNameSpace failed: 0x%08x\n", hr);
9250
9251     IInternetSession_Release(session);
9252 }
9253
9254 static void test_CoInternetCombineIUri_Pluggable(void) {
9255     HRESULT hr;
9256     IUri *base = NULL;
9257
9258     register_protocols();
9259
9260     hr = pCreateUri(combine_baseW, 0, 0, &base);
9261     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9262     if(SUCCEEDED(hr)) {
9263         IUri *relative = NULL;
9264
9265         hr = pCreateUri(combine_relativeW, Uri_CREATE_ALLOW_RELATIVE, 0, &relative);
9266         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9267         if(SUCCEEDED(hr)) {
9268             IUri *result = NULL;
9269
9270             SET_EXPECT(CombineUrl);
9271
9272             hr = pCoInternetCombineIUri(base, relative, URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO,
9273                                         &result, 0);
9274             ok(hr == S_OK, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9275
9276             CHECK_CALLED(CombineUrl);
9277
9278             if(SUCCEEDED(hr)) {
9279                 BSTR received = NULL;
9280                 hr = IUri_GetAbsoluteUri(result, &received);
9281                 ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x instead.\n", hr);
9282                 if(SUCCEEDED(hr)) {
9283                     ok(!lstrcmpW(combine_resultW, received), "Error: Expected %s, but got %s.\n",
9284                         wine_dbgstr_w(combine_resultW), wine_dbgstr_w(received));
9285                 }
9286                 SysFreeString(received);
9287             }
9288             if(result) IUri_Release(result);
9289         }
9290         if(relative) IUri_Release(relative);
9291     }
9292     if(base) IUri_Release(base);
9293
9294     unregister_protocols();
9295 }
9296
9297 static void test_CoInternetCombineUrlEx(void) {
9298     HRESULT hr;
9299     IUri *base, *result;
9300     DWORD i;
9301
9302     base = NULL;
9303     hr = pCreateUri(http_urlW, 0, 0, &base);
9304     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9305     if(SUCCEEDED(hr)) {
9306         result = (void*) 0xdeadbeef;
9307         hr = pCoInternetCombineUrlEx(base, NULL, 0, &result, 0);
9308         ok(hr == E_UNEXPECTED, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
9309             hr, E_UNEXPECTED);
9310         ok(!result, "Error: Expected 'result' to be NULL was %p instead.\n", result);
9311     }
9312
9313     result = (void*) 0xdeadbeef;
9314     hr = pCoInternetCombineUrlEx(NULL, http_urlW, 0, &result, 0);
9315     ok(hr == E_INVALIDARG, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
9316         hr, E_INVALIDARG);
9317     ok(!result, "Error: Expected 'result' to be NULL, but was %p instead.\n", result);
9318
9319     result = (void*) 0xdeadbeef;
9320     hr = pCoInternetCombineUrlEx(NULL, NULL, 0, &result, 0);
9321     ok(hr == E_UNEXPECTED, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
9322         hr, E_UNEXPECTED);
9323     ok(!result, "Error: Expected 'result' to be NULL, but was %p instead.\n", result);
9324
9325     hr = pCoInternetCombineUrlEx(base, http_urlW, 0, NULL, 0);
9326     ok(hr == E_POINTER, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
9327         hr, E_POINTER);
9328     if(base) IUri_Release(base);
9329
9330     for(i = 0; i < sizeof(uri_combine_tests)/sizeof(uri_combine_tests[0]); ++i) {
9331         LPWSTR baseW = a2w(uri_combine_tests[i].base_uri);
9332
9333         hr = pCreateUri(baseW, uri_combine_tests[i].base_create_flags, 0, &base);
9334         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x on uri_combine_tests[%d].\n", hr, i);
9335         if(SUCCEEDED(hr)) {
9336             LPWSTR relativeW = a2w(uri_combine_tests[i].relative_uri);
9337
9338             hr = pCoInternetCombineUrlEx(base, relativeW, uri_combine_tests[i].combine_flags,
9339                                          &result, 0);
9340             if(uri_combine_tests[i].todo) {
9341                 todo_wine {
9342                     ok(hr == uri_combine_tests[i].expected,
9343                         "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9344                         hr, uri_combine_tests[i].expected, i);
9345                 }
9346             } else {
9347                 ok(hr == uri_combine_tests[i].expected,
9348                     "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9349                     hr, uri_combine_tests[i]. expected, i);
9350             }
9351             if(SUCCEEDED(hr)) {
9352                 DWORD j;
9353
9354                 for(j = 0; j < sizeof(uri_combine_tests[i].str_props)/sizeof(uri_combine_tests[i].str_props[0]); ++j) {
9355                     uri_combine_str_property prop = uri_combine_tests[i].str_props[j];
9356                     BSTR received;
9357                     LPCSTR value = (prop.value_ex) ? prop.value_ex : prop.value;
9358
9359                     hr = IUri_GetPropertyBSTR(result, j, &received, 0);
9360                     if(prop.todo) {
9361                         todo_wine {
9362                             ok(hr == prop.expected,
9363                                 "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9364                                 hr, prop.expected, i, j);
9365                         }
9366                         todo_wine {
9367                             ok(!strcmp_aw(value, received) ||
9368                                broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9369                                 "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9370                                 value, wine_dbgstr_w(received), i, j);
9371                         }
9372                     } else {
9373                         ok(hr == prop.expected,
9374                             "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9375                             hr, prop.expected, i, j);
9376                         ok(!strcmp_aw(value, received) ||
9377                            broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9378                             "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9379                             value, wine_dbgstr_w(received), i, j);
9380                     }
9381                     SysFreeString(received);
9382                 }
9383
9384                 for(j = 0; j < sizeof(uri_combine_tests[i].dword_props)/sizeof(uri_combine_tests[i].dword_props[0]); ++j) {
9385                     uri_dword_property prop = uri_combine_tests[i].dword_props[j];
9386                     DWORD received;
9387
9388                     hr = IUri_GetPropertyDWORD(result, j+Uri_PROPERTY_DWORD_START, &received, 0);
9389                     if(prop.todo) {
9390                         todo_wine {
9391                             ok(hr == prop.expected,
9392                                 "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9393                                 hr, prop.expected, i, j);
9394                         }
9395                         todo_wine {
9396                             ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9397                                 prop.value, received, i, j);
9398                         }
9399                     } else {
9400                         ok(hr == prop.expected,
9401                             "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9402                             hr, prop.expected, i, j);
9403                         ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9404                             prop.value, received, i, j);
9405                     }
9406                 }
9407             }
9408             if(result) IUri_Release(result);
9409             heap_free(relativeW);
9410         }
9411         if(base) IUri_Release(base);
9412         heap_free(baseW);
9413     }
9414 }
9415
9416 START_TEST(uri) {
9417     HMODULE hurlmon;
9418
9419     hurlmon = GetModuleHandle("urlmon.dll");
9420     pCoInternetGetSession = (void*) GetProcAddress(hurlmon, "CoInternetGetSession");
9421     pCreateUri = (void*) GetProcAddress(hurlmon, "CreateUri");
9422     pCreateUriWithFragment = (void*) GetProcAddress(hurlmon, "CreateUriWithFragment");
9423     pCreateIUriBuilder = (void*) GetProcAddress(hurlmon, "CreateIUriBuilder");
9424     pCoInternetCombineIUri = (void*) GetProcAddress(hurlmon, "CoInternetCombineIUri");
9425     pCoInternetCombineUrlEx = (void*) GetProcAddress(hurlmon, "CoInternetCombineUrlEx");
9426
9427     if(!pCreateUri) {
9428         win_skip("CreateUri is not present, skipping tests.\n");
9429         return;
9430     }
9431
9432     trace("test CreateUri invalid flags...\n");
9433     test_CreateUri_InvalidFlags();
9434
9435     trace("test CreateUri invalid args...\n");
9436     test_CreateUri_InvalidArgs();
9437
9438     trace("test CreateUri invalid URIs...\n");
9439     test_CreateUri_InvalidUri();
9440
9441     trace("test IUri_GetPropertyBSTR...\n");
9442     test_IUri_GetPropertyBSTR();
9443
9444     trace("test IUri_GetPropertyDWORD...\n");
9445     test_IUri_GetPropertyDWORD();
9446
9447     trace("test IUri_GetStrProperties...\n");
9448     test_IUri_GetStrProperties();
9449
9450     trace("test IUri_GetDwordProperties...\n");
9451     test_IUri_GetDwordProperties();
9452
9453     trace("test IUri_GetPropertyLength...\n");
9454     test_IUri_GetPropertyLength();
9455
9456     trace("test IUri_GetProperties...\n");
9457     test_IUri_GetProperties();
9458
9459     trace("test IUri_HasProperty...\n");
9460     test_IUri_HasProperty();
9461
9462     trace("test IUri_IsEqual...\n");
9463     test_IUri_IsEqual();
9464
9465     trace("test CreateUriWithFragment invalid args...\n");
9466     test_CreateUriWithFragment_InvalidArgs();
9467
9468     trace("test CreateUriWithFragment invalid flags...\n");
9469     test_CreateUriWithFragment_InvalidFlags();
9470
9471     trace("test CreateUriWithFragment...\n");
9472     test_CreateUriWithFragment();
9473
9474     trace("test CreateIUriBuilder...\n");
9475     test_CreateIUriBuilder();
9476
9477     trace("test IUriBuilder_CreateInvalidArgs...\n");
9478     test_IUriBuilder_CreateInvalidArgs();
9479
9480     trace("test IUriBuilder...\n");
9481     test_IUriBuilder();
9482
9483     trace("test IUriBuilder_GetInvalidArgs...\n");
9484     test_IUriBuilder_GetInvalidArgs();
9485
9486     trace("test IUriBuilder_HasBeenModified...\n");
9487     test_IUriBuilder_HasBeenModified();
9488
9489     trace("test IUriBuilder_IUriProperty...\n");
9490     test_IUriBuilder_IUriProperty();
9491
9492     trace("test IUriBuilder_RemoveProperties...\n");
9493     test_IUriBuilder_RemoveProperties();
9494
9495     trace("test IUriBuilder miscellaneous...\n");
9496     test_IUriBuilder_Misc();
9497
9498     trace("test CoInternetCombineIUri...\n");
9499     test_CoInternetCombineIUri();
9500
9501     trace("test CoInternetCombineUrlEx...\n");
9502     test_CoInternetCombineUrlEx();
9503
9504     trace("test CoInternetCombineIUri pluggable...\n");
9505     test_CoInternetCombineIUri_Pluggable();
9506 }