mshtml: Implement IHTMLDOMNode replaceChild.
[wine] / dlls / urlmon / tests / uri.c
1 /*
2  * UrlMon IUri tests
3  *
4  * Copyright 2010 Thomas Mullaly
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include <wine/test.h>
22 #include <stdarg.h>
23 #include <stddef.h>
24
25 #define COBJMACROS
26 #define CONST_VTABLE
27
28 #include "windef.h"
29 #include "winbase.h"
30 #include "urlmon.h"
31 #include "shlwapi.h"
32 #include "wininet.h"
33 #include "strsafe.h"
34
35 #define URI_STR_PROPERTY_COUNT Uri_PROPERTY_STRING_LAST+1
36 #define URI_DWORD_PROPERTY_COUNT (Uri_PROPERTY_DWORD_LAST - Uri_PROPERTY_DWORD_START)+1
37 #define URI_BUILDER_STR_PROPERTY_COUNT 7
38
39 #define DEFINE_EXPECT(func) \
40     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
41
42 #define SET_EXPECT(func) \
43     expect_ ## func = TRUE
44
45 #define CHECK_EXPECT(func) \
46     do { \
47         ok(expect_ ##func, "unexpected call " #func "\n"); \
48         expect_ ## func = FALSE; \
49         called_ ## func = TRUE; \
50     }while(0)
51
52 #define CHECK_EXPECT2(func) \
53     do { \
54         ok(expect_ ##func, "unexpected call " #func "\n"); \
55         called_ ## func = TRUE; \
56     }while(0)
57
58 #define CHECK_CALLED(func) \
59     do { \
60         ok(called_ ## func, "expected " #func "\n"); \
61         expect_ ## func = called_ ## func = FALSE; \
62     }while(0)
63
64 DEFINE_EXPECT(CombineUrl);
65 DEFINE_EXPECT(ParseUrl);
66
67 static HRESULT (WINAPI *pCreateUri)(LPCWSTR, DWORD, DWORD_PTR, IUri**);
68 static HRESULT (WINAPI *pCreateUriWithFragment)(LPCWSTR, LPCWSTR, DWORD, DWORD_PTR, IUri**);
69 static HRESULT (WINAPI *pCreateIUriBuilder)(IUri*, DWORD, DWORD_PTR, IUriBuilder**);
70 static HRESULT (WINAPI *pCoInternetCombineIUri)(IUri*,IUri*,DWORD,IUri**,DWORD_PTR);
71 static HRESULT (WINAPI *pCoInternetGetSession)(DWORD,IInternetSession**,DWORD);
72 static HRESULT (WINAPI *pCoInternetCombineUrlEx)(IUri*,LPCWSTR,DWORD,IUri**,DWORD_PTR);
73 static HRESULT (WINAPI *pCoInternetParseIUri)(IUri*,PARSEACTION,DWORD,LPWSTR,DWORD,DWORD*,DWORD_PTR);
74 static HRESULT (WINAPI *pCreateURLMonikerEx)(IMoniker*,LPCWSTR,IMoniker**,DWORD);
75 static HRESULT (WINAPI *pCreateURLMonikerEx2)(IMoniker*,IUri*,IMoniker**,DWORD);
76
77 static const WCHAR http_urlW[] = { 'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
78         '.','o','r','g','/',0};
79 static const WCHAR http_url_fragW[] = { 'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
80         '.','o','r','g','/','#','F','r','a','g',0};
81
82 static const WCHAR combine_baseW[] = {'w','i','n','e','t','e','s','t',':','?','t',
83         'e','s','t','i','n','g',0};
84 static const WCHAR combine_relativeW[] = {'?','t','e','s','t',0};
85 static const WCHAR combine_resultW[] = {'z','i','p',':','t','e','s','t',0};
86
87 static const WCHAR winetestW[] = {'w','i','n','e','t','e','s','t',0};
88
89 static const WCHAR parse_urlW[] = {'w','i','n','e','t','e','s','t',':','t','e','s','t',0};
90 static const WCHAR parse_resultW[] = {'z','i','p',':','t','e','s','t',0};
91
92 static PARSEACTION parse_action;
93 static DWORD parse_flags;
94
95 typedef struct _uri_create_flag_test {
96     DWORD   flags;
97     HRESULT expected;
98 } uri_create_flag_test;
99
100 static const uri_create_flag_test invalid_flag_tests[] = {
101     /* Set of invalid flag combinations to test for. */
102     {Uri_CREATE_DECODE_EXTRA_INFO | Uri_CREATE_NO_DECODE_EXTRA_INFO, E_INVALIDARG},
103     {Uri_CREATE_CANONICALIZE | Uri_CREATE_NO_CANONICALIZE, E_INVALIDARG},
104     {Uri_CREATE_CRACK_UNKNOWN_SCHEMES | Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES, E_INVALIDARG},
105     {Uri_CREATE_PRE_PROCESS_HTML_URI | Uri_CREATE_NO_PRE_PROCESS_HTML_URI, E_INVALIDARG},
106     {Uri_CREATE_IE_SETTINGS | Uri_CREATE_NO_IE_SETTINGS, E_INVALIDARG}
107 };
108
109 typedef struct _uri_str_property {
110     const char* value;
111     HRESULT     expected;
112     BOOL        todo;
113     const char* broken_value;
114 } uri_str_property;
115
116 typedef struct _uri_dword_property {
117     DWORD   value;
118     HRESULT expected;
119     BOOL    todo;
120 } uri_dword_property;
121
122 typedef struct _uri_properties {
123     const char*         uri;
124     DWORD               create_flags;
125     HRESULT             create_expected;
126     BOOL                create_todo;
127
128     uri_str_property    str_props[URI_STR_PROPERTY_COUNT];
129     uri_dword_property  dword_props[URI_DWORD_PROPERTY_COUNT];
130 } uri_properties;
131
132 static const uri_properties uri_tests[] = {
133     {   "http://www.winehq.org/tests/../tests/../..", 0, S_OK, FALSE,
134         {
135             {"http://www.winehq.org/",S_OK,FALSE},                      /* ABSOLUTE_URI */
136             {"www.winehq.org",S_OK,FALSE},                              /* AUTHORITY */
137             {"http://www.winehq.org/",S_OK,FALSE},                      /* DISPLAY_URI */
138             {"winehq.org",S_OK,FALSE},                                  /* DOMAIN */
139             {"",S_FALSE,FALSE},                                         /* EXTENSION */
140             {"",S_FALSE,FALSE},                                         /* FRAGMENT */
141             {"www.winehq.org",S_OK,FALSE},                              /* HOST */
142             {"",S_FALSE,FALSE},                                         /* PASSWORD */
143             {"/",S_OK,FALSE},                                           /* PATH */
144             {"/",S_OK,FALSE},                                           /* PATH_AND_QUERY */
145             {"",S_FALSE,FALSE},                                         /* QUERY */
146             {"http://www.winehq.org/tests/../tests/../..",S_OK,FALSE},  /* RAW_URI */
147             {"http",S_OK,FALSE},                                        /* SCHEME_NAME */
148             {"",S_FALSE,FALSE},                                         /* USER_INFO */
149             {"",S_FALSE,FALSE}                                          /* USER_NAME */
150         },
151         {
152             {Uri_HOST_DNS,S_OK,FALSE},                                  /* HOST_TYPE */
153             {80,S_OK,FALSE},                                            /* PORT */
154             {URL_SCHEME_HTTP,S_OK,FALSE},                               /* SCHEME */
155             {URLZONE_INVALID,E_NOTIMPL,FALSE}                           /* ZONE */
156         }
157     },
158     {   "http://winehq.org/tests/.././tests", 0, S_OK, FALSE,
159         {
160             {"http://winehq.org/tests",S_OK,FALSE},
161             {"winehq.org",S_OK,FALSE},
162             {"http://winehq.org/tests",S_OK,FALSE},
163             {"winehq.org",S_OK,FALSE},
164             {"",S_FALSE,FALSE},
165             {"",S_FALSE,FALSE},
166             {"winehq.org",S_OK,FALSE},
167             {"",S_FALSE,FALSE},
168             {"/tests",S_OK,FALSE},
169             {"/tests",S_OK,FALSE},
170             {"",S_FALSE,FALSE},
171             {"http://winehq.org/tests/.././tests",S_OK,FALSE},
172             {"http",S_OK,FALSE},
173             {"",S_FALSE,FALSE},
174             {"",S_FALSE,FALSE}
175         },
176         {
177             {Uri_HOST_DNS,S_OK,FALSE},
178             {80,S_OK,FALSE},
179             {URL_SCHEME_HTTP,S_OK,FALSE},
180             {URLZONE_INVALID,E_NOTIMPL,FALSE}
181         }
182     },
183     {   "HtTp://www.winehq.org/tests/..?query=x&return=y", 0, S_OK, FALSE,
184         {
185             {"http://www.winehq.org/?query=x&return=y",S_OK,FALSE},
186             {"www.winehq.org",S_OK,FALSE},
187             {"http://www.winehq.org/?query=x&return=y",S_OK,FALSE},
188             {"winehq.org",S_OK,FALSE},
189             {"",S_FALSE,FALSE},
190             {"",S_FALSE,FALSE},
191             {"www.winehq.org",S_OK,FALSE},
192             {"",S_FALSE,FALSE},
193             {"/",S_OK,FALSE},
194             {"/?query=x&return=y",S_OK,FALSE},
195             {"?query=x&return=y",S_OK,FALSE},
196             {"HtTp://www.winehq.org/tests/..?query=x&return=y",S_OK,FALSE},
197             {"http",S_OK,FALSE},
198             {"",S_FALSE,FALSE},
199             {"",S_FALSE,FALSE}
200         },
201         {
202             {Uri_HOST_DNS,S_OK,FALSE},
203             {80,S_OK,FALSE},
204             {URL_SCHEME_HTTP,S_OK,FALSE},
205             {URLZONE_INVALID,E_NOTIMPL,FALSE},
206         }
207     },
208     {   "hTTp://us%45r%3Ainfo@examp%4CE.com:80/path/a/b/./c/../%2E%2E/Forbidden'<|> Characters", 0, S_OK, FALSE,
209         {
210             {"http://usEr%3Ainfo@example.com/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
211             {"usEr%3Ainfo@example.com",S_OK,FALSE},
212             {"http://example.com/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
213             {"example.com",S_OK,FALSE},
214             {"",S_FALSE,FALSE},
215             {"",S_FALSE,FALSE},
216             {"example.com",S_OK,FALSE},
217             {"",S_FALSE,FALSE},
218             {"/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
219             {"/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,FALSE},
220             {"",S_FALSE,FALSE},
221             {"hTTp://us%45r%3Ainfo@examp%4CE.com:80/path/a/b/./c/../%2E%2E/Forbidden'<|> Characters",S_OK,FALSE},
222             {"http",S_OK,FALSE},
223             {"usEr%3Ainfo",S_OK,FALSE},
224             {"usEr%3Ainfo",S_OK,FALSE}
225         },
226         {
227             {Uri_HOST_DNS,S_OK,FALSE},
228             {80,S_OK,FALSE},
229             {URL_SCHEME_HTTP,S_OK,FALSE},
230             {URLZONE_INVALID,E_NOTIMPL,FALSE},
231         }
232     },
233     {   "ftp://winepass:wine@ftp.winehq.org:9999/dir/foo bar.txt", 0, S_OK, FALSE,
234         {
235             {"ftp://winepass:wine@ftp.winehq.org:9999/dir/foo%20bar.txt",S_OK,FALSE},
236             {"winepass:wine@ftp.winehq.org:9999",S_OK,FALSE},
237             {"ftp://ftp.winehq.org:9999/dir/foo%20bar.txt",S_OK,FALSE},
238             {"winehq.org",S_OK,FALSE},
239             {".txt",S_OK,FALSE},
240             {"",S_FALSE,FALSE},
241             {"ftp.winehq.org",S_OK,FALSE},
242             {"wine",S_OK,FALSE},
243             {"/dir/foo%20bar.txt",S_OK,FALSE},
244             {"/dir/foo%20bar.txt",S_OK,FALSE},
245             {"",S_FALSE,FALSE},
246             {"ftp://winepass:wine@ftp.winehq.org:9999/dir/foo bar.txt",S_OK,FALSE},
247             {"ftp",S_OK,FALSE},
248             {"winepass:wine",S_OK,FALSE},
249             {"winepass",S_OK,FALSE}
250         },
251         {
252             {Uri_HOST_DNS,S_OK,FALSE},
253             {9999,S_OK,FALSE},
254             {URL_SCHEME_FTP,S_OK,FALSE},
255             {URLZONE_INVALID,E_NOTIMPL,FALSE}
256         }
257     },
258     {   "file://c:\\tests\\../tests/foo%20bar.mp3", 0, S_OK, FALSE,
259         {
260             {"file:///c:/tests/foo%2520bar.mp3",S_OK,FALSE},
261             {"",S_FALSE,FALSE},
262             {"file:///c:/tests/foo%2520bar.mp3",S_OK,FALSE},
263             {"",S_FALSE,FALSE},
264             {".mp3",S_OK,FALSE},
265             {"",S_FALSE,FALSE},
266             {"",S_FALSE,FALSE},
267             {"",S_FALSE,FALSE},
268             {"/c:/tests/foo%2520bar.mp3",S_OK,FALSE},
269             {"/c:/tests/foo%2520bar.mp3",S_OK,FALSE},
270             {"",S_FALSE,FALSE},
271             {"file://c:\\tests\\../tests/foo%20bar.mp3",S_OK,FALSE},
272             {"file",S_OK,FALSE},
273             {"",S_FALSE,FALSE},
274             {"",S_FALSE,FALSE}
275         },
276         {
277             {Uri_HOST_UNKNOWN,S_OK,FALSE},
278             {0,S_FALSE,FALSE},
279             {URL_SCHEME_FILE,S_OK,FALSE},
280             {URLZONE_INVALID,E_NOTIMPL,FALSE}
281         }
282     },
283     {   "FILE://localhost/test dir\\../tests/test%20file.README.txt", 0, S_OK, FALSE,
284         {
285             {"file:///tests/test%20file.README.txt",S_OK,FALSE},
286             {"",S_FALSE,FALSE},
287             {"file:///tests/test%20file.README.txt",S_OK,FALSE},
288             {"",S_FALSE,FALSE},
289             {".txt",S_OK,FALSE},
290             {"",S_FALSE,FALSE},
291             {"",S_FALSE,FALSE},
292             {"",S_FALSE,FALSE},
293             {"/tests/test%20file.README.txt",S_OK,FALSE},
294             {"/tests/test%20file.README.txt",S_OK,FALSE},
295             {"",S_FALSE,FALSE},
296             {"FILE://localhost/test dir\\../tests/test%20file.README.txt",S_OK,FALSE},
297             {"file",S_OK,FALSE},
298             {"",S_FALSE,FALSE},
299             {"",S_FALSE,FALSE}
300         },
301         {
302             {Uri_HOST_UNKNOWN,S_OK,FALSE},
303             {0,S_FALSE,FALSE},
304             {URL_SCHEME_FILE,S_OK,FALSE},
305             {URLZONE_INVALID,E_NOTIMPL,FALSE}
306         }
307     },
308     {   "urn:nothing:should:happen here", 0, S_OK, FALSE,
309         {
310             {"urn:nothing:should:happen here",S_OK,FALSE},
311             {"",S_FALSE,FALSE},
312             {"urn:nothing:should:happen here",S_OK,FALSE},
313             {"",S_FALSE,FALSE},
314             {"",S_FALSE,FALSE},
315             {"",S_FALSE,FALSE},
316             {"",S_FALSE,FALSE},
317             {"",S_FALSE,FALSE},
318             {"nothing:should:happen here",S_OK,FALSE},
319             {"nothing:should:happen here",S_OK,FALSE},
320             {"",S_FALSE,FALSE},
321             {"urn:nothing:should:happen here",S_OK,FALSE},
322             {"urn",S_OK,FALSE},
323             {"",S_FALSE,FALSE},
324             {"",S_FALSE,FALSE}
325         },
326         {
327             {Uri_HOST_UNKNOWN,S_OK,FALSE},
328             {0,S_FALSE,FALSE},
329             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
330             {URLZONE_INVALID,E_NOTIMPL,FALSE}
331         }
332     },
333     {   "http://127.0.0.1/tests/../test dir/./test.txt", 0, S_OK, FALSE,
334         {
335             {"http://127.0.0.1/test%20dir/test.txt",S_OK,FALSE},
336             {"127.0.0.1",S_OK,FALSE},
337             {"http://127.0.0.1/test%20dir/test.txt",S_OK,FALSE},
338             {"",S_FALSE,FALSE},
339             {".txt",S_OK,FALSE},
340             {"",S_FALSE,FALSE},
341             {"127.0.0.1",S_OK,FALSE},
342             {"",S_FALSE,FALSE},
343             {"/test%20dir/test.txt",S_OK,FALSE},
344             {"/test%20dir/test.txt",S_OK,FALSE},
345             {"",S_FALSE,FALSE},
346             {"http://127.0.0.1/tests/../test dir/./test.txt",S_OK,FALSE},
347             {"http",S_OK,FALSE},
348             {"",S_FALSE,FALSE},
349             {"",S_FALSE,FALSE}
350         },
351         {
352             {Uri_HOST_IPV4,S_OK,FALSE},
353             {80,S_OK,FALSE},
354             {URL_SCHEME_HTTP,S_OK,FALSE},
355             {URLZONE_INVALID,E_NOTIMPL,FALSE}
356         }
357     },
358     {   "http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]", 0, S_OK, FALSE,
359         {
360             {"http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/",S_OK,FALSE},
361             {"[fedc:ba98:7654:3210:fedc:ba98:7654:3210]",S_OK,FALSE},
362             {"http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/",S_OK,FALSE},
363             {"",S_FALSE,FALSE},
364             {"",S_FALSE,FALSE},
365             {"",S_FALSE,FALSE},
366             {"fedc:ba98:7654:3210:fedc:ba98:7654:3210",S_OK,FALSE},
367             {"",S_FALSE,FALSE},
368             {"/",S_OK,FALSE},
369             {"/",S_OK,FALSE},
370             {"",S_FALSE,FALSE},
371             {"http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]",S_OK,FALSE},
372             {"http",S_OK,FALSE},
373             {"",S_FALSE,FALSE},
374             {"",S_FALSE,FALSE}
375         },
376         {
377             {Uri_HOST_IPV6,S_OK,FALSE},
378             {80,S_OK,FALSE},
379             {URL_SCHEME_HTTP,S_OK,FALSE},
380             {URLZONE_INVALID,E_NOTIMPL,FALSE}
381         }
382     },
383     {   "ftp://[::13.1.68.3]", 0, S_OK, FALSE,
384         {
385             {"ftp://[::13.1.68.3]/",S_OK,FALSE},
386             {"[::13.1.68.3]",S_OK,FALSE},
387             {"ftp://[::13.1.68.3]/",S_OK,FALSE},
388             {"",S_FALSE,FALSE},
389             {"",S_FALSE,FALSE},
390             {"",S_FALSE,FALSE},
391             {"::13.1.68.3",S_OK,FALSE},
392             {"",S_FALSE,FALSE},
393             {"/",S_OK,FALSE},
394             {"/",S_OK,FALSE},
395             {"",S_FALSE,FALSE},
396             {"ftp://[::13.1.68.3]",S_OK,FALSE},
397             {"ftp",S_OK,FALSE},
398             {"",S_FALSE,FALSE},
399             {"",S_FALSE,FALSE}
400         },
401         {
402             {Uri_HOST_IPV6,S_OK,FALSE},
403             {21,S_OK,FALSE},
404             {URL_SCHEME_FTP,S_OK,FALSE},
405             {URLZONE_INVALID,E_NOTIMPL,FALSE}
406         }
407     },
408     {   "http://[FEDC:BA98:0:0:0:0:0:3210]", 0, S_OK, FALSE,
409         {
410             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
411             {"[fedc:ba98::3210]",S_OK,FALSE},
412             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
413             {"",S_FALSE,FALSE},
414             {"",S_FALSE,FALSE},
415             {"",S_FALSE,FALSE},
416             {"fedc:ba98::3210",S_OK,FALSE},
417             {"",S_FALSE,FALSE},
418             {"/",S_OK,FALSE},
419             {"/",S_OK,FALSE},
420             {"",S_FALSE,FALSE},
421             {"http://[FEDC:BA98:0:0:0:0:0:3210]",S_OK,FALSE},
422             {"http",S_OK,FALSE},
423             {"",S_FALSE,FALSE},
424             {"",S_FALSE,FALSE},
425         },
426         {
427             {Uri_HOST_IPV6,S_OK,FALSE},
428             {80,S_OK,FALSE},
429             {URL_SCHEME_HTTP,S_OK,FALSE},
430             {URLZONE_INVALID,E_NOTIMPL,FALSE}
431         }
432     },
433     {   "1234://www.winehq.org", 0, S_OK, FALSE,
434         {
435             {"1234://www.winehq.org/",S_OK,FALSE},
436             {"www.winehq.org",S_OK,FALSE},
437             {"1234://www.winehq.org/",S_OK,FALSE},
438             {"winehq.org",S_OK,FALSE},
439             {"",S_FALSE,FALSE},
440             {"",S_FALSE,FALSE},
441             {"www.winehq.org",S_OK,FALSE},
442             {"",S_FALSE,FALSE},
443             {"/",S_OK,FALSE},
444             {"/",S_OK,FALSE},
445             {"",S_FALSE,FALSE},
446             {"1234://www.winehq.org",S_OK,FALSE},
447             {"1234",S_OK,FALSE},
448             {"",S_FALSE,FALSE},
449             {"",S_FALSE,FALSE}
450         },
451         {
452             {Uri_HOST_DNS,S_OK,FALSE},
453             {0,S_FALSE,FALSE},
454             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
455             {URLZONE_INVALID,E_NOTIMPL,FALSE}
456         }
457     },
458     /* Test's to make sure the parser/canonicalizer handles implicit file schemes correctly. */
459     {   "C:/test/test.mp3", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, S_OK, FALSE,
460         {
461             {"file:///C:/test/test.mp3",S_OK,FALSE},
462             {"",S_FALSE,FALSE},
463             {"file:///C:/test/test.mp3",S_OK,FALSE},
464             {"",S_FALSE,FALSE},
465             {".mp3",S_OK,FALSE},
466             {"",S_FALSE,FALSE},
467             {"",S_FALSE,FALSE},
468             {"",S_FALSE,FALSE},
469             {"/C:/test/test.mp3",S_OK,FALSE},
470             {"/C:/test/test.mp3",S_OK,FALSE},
471             {"",S_FALSE,FALSE},
472             {"C:/test/test.mp3",S_OK,FALSE},
473             {"file",S_OK,FALSE},
474             {"",S_FALSE,FALSE},
475             {"",S_FALSE,FALSE}
476         },
477         {
478             {Uri_HOST_UNKNOWN,S_OK,FALSE},
479             {0,S_FALSE,FALSE},
480             {URL_SCHEME_FILE,S_OK,FALSE},
481             {URLZONE_INVALID,E_NOTIMPL,FALSE}
482         }
483     },
484     /* Test's to make sure the parser/canonicalizer handles implicit file schemes correctly. */
485     {   "\\\\Server/test.mp3", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, S_OK, FALSE,
486         {
487             {"file://server/test.mp3",S_OK,FALSE},
488             {"server",S_OK,FALSE},
489             {"file://server/test.mp3",S_OK,FALSE},
490             {"",S_FALSE,FALSE},
491             {".mp3",S_OK,FALSE},
492             {"",S_FALSE,FALSE},
493             {"server",S_OK,FALSE},
494             {"",S_FALSE,FALSE},
495             {"/test.mp3",S_OK,FALSE},
496             {"/test.mp3",S_OK,FALSE},
497             {"",S_FALSE,FALSE},
498             {"\\\\Server/test.mp3",S_OK,FALSE},
499             {"file",S_OK,FALSE},
500             {"",S_FALSE,FALSE},
501             {"",S_FALSE,FALSE}
502         },
503         {
504             {Uri_HOST_DNS,S_OK,FALSE},
505             {0,S_FALSE,FALSE},
506             {URL_SCHEME_FILE,S_OK,FALSE},
507             {URLZONE_INVALID,E_NOTIMPL,FALSE}
508         }
509     },
510     {   "www.winehq.org/test", Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME, S_OK, FALSE,
511         {
512             {"*:www.winehq.org/test",S_OK,FALSE},
513             {"www.winehq.org",S_OK,FALSE},
514             {"*:www.winehq.org/test",S_OK,FALSE},
515             {"winehq.org",S_OK,FALSE},
516             {"",S_FALSE,FALSE},
517             {"",S_FALSE,FALSE},
518             {"www.winehq.org",S_OK,FALSE},
519             {"",S_FALSE,FALSE},
520             {"/test",S_OK,FALSE},
521             {"/test",S_OK,FALSE},
522             {"",S_FALSE,FALSE},
523             {"www.winehq.org/test",S_OK,FALSE},
524             {"*",S_OK,FALSE},
525             {"",S_FALSE,FALSE},
526             {"",S_FALSE,FALSE}
527         },
528         {
529             {Uri_HOST_DNS,S_OK,FALSE},
530             {0,S_FALSE,FALSE},
531             {URL_SCHEME_WILDCARD,S_OK,FALSE},
532             {URLZONE_INVALID,E_NOTIMPL,FALSE}
533         }
534     },
535     /* Valid since the '*' is the only character in the scheme name. */
536     {   "*:www.winehq.org/test", 0, S_OK, FALSE,
537         {
538             {"*:www.winehq.org/test",S_OK,FALSE},
539             {"www.winehq.org",S_OK,FALSE},
540             {"*:www.winehq.org/test",S_OK,FALSE},
541             {"winehq.org",S_OK,FALSE},
542             {"",S_FALSE,FALSE},
543             {"",S_FALSE,FALSE},
544             {"www.winehq.org",S_OK,FALSE},
545             {"",S_FALSE,FALSE},
546             {"/test",S_OK,FALSE},
547             {"/test",S_OK,FALSE},
548             {"",S_FALSE,FALSE},
549             {"*:www.winehq.org/test",S_OK,FALSE},
550             {"*",S_OK,FALSE},
551             {"",S_FALSE,FALSE},
552             {"",S_FALSE,FALSE}
553         },
554         {
555             {Uri_HOST_DNS,S_OK,FALSE},
556             {0,S_FALSE,FALSE},
557             {URL_SCHEME_WILDCARD,S_OK,FALSE},
558             {URLZONE_INVALID,E_NOTIMPL,FALSE}
559         }
560     },
561     {   "/../some dir/test.ext", Uri_CREATE_ALLOW_RELATIVE, S_OK, FALSE,
562         {
563             {"/../some dir/test.ext",S_OK,FALSE},
564             {"",S_FALSE,FALSE},
565             {"/../some dir/test.ext",S_OK,FALSE},
566             {"",S_FALSE,FALSE},
567             {".ext",S_OK,FALSE},
568             {"",S_FALSE,FALSE},
569             {"",S_FALSE,FALSE},
570             {"",S_FALSE,FALSE},
571             {"/../some dir/test.ext",S_OK,FALSE},
572             {"/../some dir/test.ext",S_OK,FALSE},
573             {"",S_FALSE,FALSE},
574             {"/../some dir/test.ext",S_OK,FALSE},
575             {"",S_FALSE,FALSE},
576             {"",S_FALSE,FALSE},
577             {"",S_FALSE,FALSE}
578         },
579         {
580             {Uri_HOST_UNKNOWN,S_OK,FALSE},
581             {0,S_FALSE,FALSE},
582             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
583             {URLZONE_INVALID,E_NOTIMPL,FALSE}
584         }
585     },
586     {   "//implicit/wildcard/uri scheme", Uri_CREATE_ALLOW_RELATIVE|Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME, S_OK, FALSE,
587         {
588             {"*://implicit/wildcard/uri%20scheme",S_OK,FALSE},
589             {"",S_OK,FALSE},
590             {"*://implicit/wildcard/uri%20scheme",S_OK,FALSE},
591             {"",S_FALSE,FALSE},
592             {"",S_FALSE,FALSE},
593             {"",S_FALSE,FALSE},
594             {"",S_OK,FALSE},
595             {"",S_FALSE,FALSE},
596             {"//implicit/wildcard/uri%20scheme",S_OK,FALSE},
597             {"//implicit/wildcard/uri%20scheme",S_OK,FALSE},
598             {"",S_FALSE,FALSE},
599             {"//implicit/wildcard/uri scheme",S_OK,FALSE},
600             {"*",S_OK,FALSE},
601             {"",S_FALSE,FALSE},
602             {"",S_FALSE,FALSE},
603         },
604         {
605             {Uri_HOST_UNKNOWN,S_OK,FALSE},
606             {0,S_FALSE,FALSE},
607             {URL_SCHEME_WILDCARD,S_OK,FALSE},
608             {URLZONE_INVALID,E_NOTIMPL,FALSE}
609         }
610     },
611     /* URI is considered opaque since CREATE_NO_CRACK_UNKNOWN_SCHEMES is set and its an unknown scheme. */
612     {   "zip://google.com", Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES, S_OK, FALSE,
613         {
614             {"zip:/.//google.com",S_OK,FALSE},
615             {"",S_FALSE,FALSE},
616             {"zip:/.//google.com",S_OK,FALSE},
617             {"",S_FALSE,FALSE},
618             {".com",S_OK,FALSE},
619             {"",S_FALSE,FALSE},
620             {"",S_FALSE,FALSE},
621             {"",S_FALSE,FALSE},
622             {"/.//google.com",S_OK,FALSE},
623             {"/.//google.com",S_OK,FALSE},
624             {"",S_FALSE,FALSE},
625             {"zip://google.com",S_OK,FALSE},
626             {"zip",S_OK,FALSE},
627             {"",S_FALSE,FALSE},
628             {"",S_FALSE,FALSE}
629         },
630         {
631             {Uri_HOST_UNKNOWN,S_OK,FALSE},
632             {0,S_FALSE,FALSE},
633             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
634             {URLZONE_INVALID,E_NOTIMPL,FALSE}
635         }
636     },
637     /* Windows uses the first occurrence of ':' to delimit the userinfo. */
638     {   "ftp://user:pass:word@winehq.org/", 0, S_OK, FALSE,
639         {
640             {"ftp://user:pass:word@winehq.org/",S_OK,FALSE},
641             {"user:pass:word@winehq.org",S_OK,FALSE},
642             {"ftp://winehq.org/",S_OK,FALSE},
643             {"winehq.org",S_OK,FALSE},
644             {"",S_FALSE,FALSE},
645             {"",S_FALSE,FALSE},
646             {"winehq.org",S_OK,FALSE},
647             {"pass:word",S_OK,FALSE},
648             {"/",S_OK,FALSE},
649             {"/",S_OK,FALSE},
650             {"",S_FALSE,FALSE},
651             {"ftp://user:pass:word@winehq.org/",S_OK,FALSE},
652             {"ftp",S_OK,FALSE},
653             {"user:pass:word",S_OK,FALSE},
654             {"user",S_OK,FALSE}
655         },
656         {
657             {Uri_HOST_DNS,S_OK,FALSE},
658             {21,S_OK,FALSE},
659             {URL_SCHEME_FTP,S_OK,FALSE},
660             {URLZONE_INVALID,E_NOTIMPL,FALSE}
661         }
662     },
663     /* Make sure % encoded unreserved characters are decoded. */
664     {   "ftp://w%49%4Ee:PA%53%53@ftp.google.com/", 0, S_OK, FALSE,
665         {
666             {"ftp://wINe:PASS@ftp.google.com/",S_OK,FALSE},
667             {"wINe:PASS@ftp.google.com",S_OK,FALSE},
668             {"ftp://ftp.google.com/",S_OK,FALSE},
669             {"google.com",S_OK,FALSE},
670             {"",S_FALSE,FALSE},
671             {"",S_FALSE,FALSE},
672             {"ftp.google.com",S_OK,FALSE},
673             {"PASS",S_OK,FALSE},
674             {"/",S_OK,FALSE},
675             {"/",S_OK,FALSE},
676             {"",S_FALSE,FALSE},
677             {"ftp://w%49%4Ee:PA%53%53@ftp.google.com/",S_OK,FALSE},
678             {"ftp",S_OK,FALSE},
679             {"wINe:PASS",S_OK,FALSE},
680             {"wINe",S_OK,FALSE}
681         },
682         {
683             {Uri_HOST_DNS,S_OK,FALSE},
684             {21,S_OK,FALSE},
685             {URL_SCHEME_FTP,S_OK,FALSE},
686             {URLZONE_INVALID,E_NOTIMPL,FALSE}
687         }
688     },
689     /* Make sure % encoded characters which are NOT unreserved are NOT decoded. */
690     {   "ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/", 0, S_OK, FALSE,
691         {
692             {"ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/",S_OK,FALSE},
693             {"w%5D%5Be:PA%7B%7D@ftp.google.com",S_OK,FALSE},
694             {"ftp://ftp.google.com/",S_OK,FALSE},
695             {"google.com",S_OK,FALSE},
696             {"",S_FALSE,FALSE},
697             {"",S_FALSE,FALSE},
698             {"ftp.google.com",S_OK,FALSE},
699             {"PA%7B%7D",S_OK,FALSE},
700             {"/",S_OK,FALSE},
701             {"/",S_OK,FALSE},
702             {"",S_FALSE,FALSE},
703             {"ftp://w%5D%5Be:PA%7B%7D@ftp.google.com/",S_OK,FALSE},
704             {"ftp",S_OK,FALSE},
705             {"w%5D%5Be:PA%7B%7D",S_OK,FALSE},
706             {"w%5D%5Be",S_OK,FALSE}
707         },
708         {
709             {Uri_HOST_DNS,S_OK,FALSE},
710             {21,S_OK,FALSE},
711             {URL_SCHEME_FTP,S_OK,FALSE},
712             {URLZONE_INVALID,E_NOTIMPL,FALSE}
713         }
714     },
715     /* You're allowed to have an empty password portion in the userinfo section. */
716     {   "ftp://empty:@ftp.google.com/", 0, S_OK, FALSE,
717         {
718             {"ftp://empty:@ftp.google.com/",S_OK,FALSE},
719             {"empty:@ftp.google.com",S_OK,FALSE},
720             {"ftp://ftp.google.com/",S_OK,FALSE},
721             {"google.com",S_OK,FALSE},
722             {"",S_FALSE,FALSE},
723             {"",S_FALSE,FALSE},
724             {"ftp.google.com",S_OK,FALSE},
725             {"",S_OK,FALSE},
726             {"/",S_OK,FALSE},
727             {"/",S_OK,FALSE},
728             {"",S_FALSE,FALSE},
729             {"ftp://empty:@ftp.google.com/",S_OK,FALSE},
730             {"ftp",S_OK,FALSE},
731             {"empty:",S_OK,FALSE},
732             {"empty",S_OK,FALSE}
733         },
734         {
735             {Uri_HOST_DNS,S_OK,FALSE},
736             {21,S_OK,FALSE},
737             {URL_SCHEME_FTP,S_OK,FALSE},
738             {URLZONE_INVALID,E_NOTIMPL,FALSE}
739         }
740     },
741     /* Make sure forbidden characters in "userinfo" get encoded. */
742     {   "ftp://\" \"weird@ftp.google.com/", 0, S_OK, FALSE,
743         {
744             {"ftp://%22%20%22weird@ftp.google.com/",S_OK,FALSE},
745             {"%22%20%22weird@ftp.google.com",S_OK,FALSE},
746             {"ftp://ftp.google.com/",S_OK,FALSE},
747             {"google.com",S_OK,FALSE},
748             {"",S_FALSE,FALSE},
749             {"",S_FALSE,FALSE},
750             {"ftp.google.com",S_OK,FALSE},
751             {"",S_FALSE,FALSE},
752             {"/",S_OK,FALSE},
753             {"/",S_OK,FALSE},
754             {"",S_FALSE,FALSE},
755             {"ftp://\" \"weird@ftp.google.com/",S_OK,FALSE},
756             {"ftp",S_OK,FALSE},
757             {"%22%20%22weird",S_OK,FALSE},
758             {"%22%20%22weird",S_OK,FALSE}
759         },
760         {
761             {Uri_HOST_DNS,S_OK,FALSE},
762             {21,S_OK,FALSE},
763             {URL_SCHEME_FTP,S_OK,FALSE},
764             {URLZONE_INVALID,E_NOTIMPL,FALSE}
765         }
766     },
767     /* Make sure the forbidden characters don't get percent encoded. */
768     {   "ftp://\" \"weird@ftp.google.com/", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
769         {
770             {"ftp://\" \"weird@ftp.google.com/",S_OK,FALSE},
771             {"\" \"weird@ftp.google.com",S_OK,FALSE},
772             {"ftp://ftp.google.com/",S_OK,FALSE},
773             {"google.com",S_OK,FALSE},
774             {"",S_FALSE,FALSE},
775             {"",S_FALSE,FALSE},
776             {"ftp.google.com",S_OK,FALSE},
777             {"",S_FALSE,FALSE},
778             {"/",S_OK,FALSE},
779             {"/",S_OK,FALSE},
780             {"",S_FALSE,FALSE},
781             {"ftp://\" \"weird@ftp.google.com/",S_OK,FALSE},
782             {"ftp",S_OK,FALSE},
783             {"\" \"weird",S_OK,FALSE},
784             {"\" \"weird",S_OK,FALSE}
785         },
786         {
787             {Uri_HOST_DNS,S_OK,FALSE},
788             {21,S_OK,FALSE},
789             {URL_SCHEME_FTP,S_OK,FALSE},
790             {URLZONE_INVALID,E_NOTIMPL,FALSE}
791         }
792     },
793     /* Make sure already percent encoded characters don't get unencoded. */
794     {   "ftp://\"%20\"weird@ftp.google.com/\"%20\"weird", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
795         {
796             {"ftp://\"%20\"weird@ftp.google.com/\"%20\"weird",S_OK,FALSE},
797             {"\"%20\"weird@ftp.google.com",S_OK,FALSE},
798             {"ftp://ftp.google.com/\"%20\"weird",S_OK,FALSE},
799             {"google.com",S_OK,FALSE},
800             {"",S_FALSE,FALSE},
801             {"",S_FALSE,FALSE},
802             {"ftp.google.com",S_OK,FALSE},
803             {"",S_FALSE,FALSE},
804             {"/\"%20\"weird",S_OK,FALSE},
805             {"/\"%20\"weird",S_OK,FALSE},
806             {"",S_FALSE,FALSE},
807             {"ftp://\"%20\"weird@ftp.google.com/\"%20\"weird",S_OK,FALSE},
808             {"ftp",S_OK,FALSE},
809             {"\"%20\"weird",S_OK,FALSE},
810             {"\"%20\"weird",S_OK,FALSE}
811         },
812         {
813             {Uri_HOST_DNS,S_OK,FALSE},
814             {21,S_OK,FALSE},
815             {URL_SCHEME_FTP,S_OK,FALSE},
816             {URLZONE_INVALID,E_NOTIMPL,FALSE}
817         }
818     },
819     /* Allowed to have invalid % encoded because its an unknown scheme type. */
820     {   "zip://%xy:word@winehq.org/", 0, S_OK, FALSE,
821         {
822             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
823             {"%xy:word@winehq.org",S_OK,FALSE},
824             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
825             {"winehq.org",S_OK,FALSE},
826             {"",S_FALSE,FALSE},
827             {"",S_FALSE,FALSE},
828             {"winehq.org",S_OK,FALSE},
829             {"word",S_OK,FALSE},
830             {"/",S_OK,FALSE},
831             {"/",S_OK,FALSE},
832             {"",S_FALSE,FALSE},
833             {"zip://%xy:word@winehq.org/",S_OK,FALSE},
834             {"zip",S_OK,FALSE},
835             {"%xy:word",S_OK,FALSE},
836             {"%xy",S_OK,FALSE}
837         },
838         {
839             {Uri_HOST_DNS,S_OK,FALSE},
840             {0,S_FALSE,FALSE},
841             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
842             {URLZONE_INVALID,E_NOTIMPL,FALSE}
843         }
844     },
845     /* Unreserved, percent encoded characters aren't decoded in the userinfo because the scheme
846      * isn't known.
847      */
848     {   "zip://%2E:%52%53ord@winehq.org/", 0, S_OK, FALSE,
849         {
850             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
851             {"%2E:%52%53ord@winehq.org",S_OK,FALSE},
852             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
853             {"winehq.org",S_OK,FALSE},
854             {"",S_FALSE,FALSE},
855             {"",S_FALSE,FALSE},
856             {"winehq.org",S_OK,FALSE},
857             {"%52%53ord",S_OK,FALSE},
858             {"/",S_OK,FALSE},
859             {"/",S_OK,FALSE},
860             {"",S_FALSE,FALSE},
861             {"zip://%2E:%52%53ord@winehq.org/",S_OK,FALSE},
862             {"zip",S_OK,FALSE},
863             {"%2E:%52%53ord",S_OK,FALSE},
864             {"%2E",S_OK,FALSE}
865         },
866         {
867             {Uri_HOST_DNS,S_OK,FALSE},
868             {0,S_FALSE,FALSE},
869             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
870             {URLZONE_INVALID,E_NOTIMPL,FALSE}
871         }
872     },
873     {   "ftp://[](),'test':word@winehq.org/", 0, S_OK, FALSE,
874         {
875             {"ftp://[](),'test':word@winehq.org/",S_OK,FALSE},
876             {"[](),'test':word@winehq.org",S_OK,FALSE},
877             {"ftp://winehq.org/",S_OK,FALSE},
878             {"winehq.org",S_OK,FALSE},
879             {"",S_FALSE,FALSE},
880             {"",S_FALSE,FALSE},
881             {"winehq.org",S_OK,FALSE},
882             {"word",S_OK,FALSE},
883             {"/",S_OK,FALSE},
884             {"/",S_OK,FALSE},
885             {"",S_FALSE,FALSE},
886             {"ftp://[](),'test':word@winehq.org/",S_OK,FALSE},
887             {"ftp",S_OK,FALSE},
888             {"[](),'test':word",S_OK,FALSE},
889             {"[](),'test'",S_OK,FALSE}
890         },
891         {
892             {Uri_HOST_DNS,S_OK,FALSE},
893             {21,S_OK,FALSE},
894             {URL_SCHEME_FTP,S_OK,FALSE},
895             {URLZONE_INVALID,E_NOTIMPL,FALSE}
896         }
897     },
898     {   "ftp://test?:word@winehq.org/", 0, S_OK, FALSE,
899         {
900             {"ftp://test/?:word@winehq.org/",S_OK,FALSE},
901             {"test",S_OK,FALSE},
902             {"ftp://test/?:word@winehq.org/",S_OK,FALSE},
903             {"",S_FALSE,FALSE},
904             {"",S_FALSE,FALSE},
905             {"",S_FALSE,FALSE},
906             {"test",S_OK,FALSE},
907             {"",S_FALSE,FALSE},
908             {"/",S_OK,FALSE},
909             {"/?:word@winehq.org/",S_OK,FALSE},
910             {"?:word@winehq.org/",S_OK,FALSE},
911             {"ftp://test?:word@winehq.org/",S_OK,FALSE},
912             {"ftp",S_OK,FALSE},
913             {"",S_FALSE,FALSE},
914             {"",S_FALSE,FALSE}
915         },
916         {
917             {Uri_HOST_DNS,S_OK,FALSE},
918             {21,S_OK,FALSE},
919             {URL_SCHEME_FTP,S_OK,FALSE},
920             {URLZONE_INVALID,E_NOTIMPL,FALSE}
921         }
922     },
923     {   "ftp://test#:word@winehq.org/", 0, S_OK, FALSE,
924         {
925             {"ftp://test/#:word@winehq.org/",S_OK,FALSE},
926             {"test",S_OK,FALSE},
927             {"ftp://test/#:word@winehq.org/",S_OK,FALSE},
928             {"",S_FALSE,FALSE},
929             {"",S_FALSE,FALSE},
930             {"#:word@winehq.org/",S_OK,FALSE},
931             {"test",S_OK,FALSE},
932             {"",S_FALSE,FALSE},
933             {"/",S_OK,FALSE},
934             {"/",S_OK,FALSE},
935             {"",S_FALSE,FALSE},
936             {"ftp://test#:word@winehq.org/",S_OK,FALSE},
937             {"ftp",S_OK,FALSE},
938             {"",S_FALSE,FALSE},
939             {"",S_FALSE,FALSE}
940         },
941         {
942             {Uri_HOST_DNS,S_OK,FALSE},
943             {21,S_OK,FALSE},
944             {URL_SCHEME_FTP,S_OK,FALSE},
945             {URLZONE_INVALID,E_NOTIMPL,FALSE}
946         }
947     },
948     /* Allowed to have a backslash in the userinfo since it's an unknown scheme. */
949     {   "zip://test\\:word@winehq.org/", 0, S_OK, FALSE,
950         {
951             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
952             {"test\\:word@winehq.org",S_OK,FALSE},
953             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
954             {"winehq.org",S_OK,FALSE},
955             {"",S_FALSE,FALSE},
956             {"",S_FALSE,FALSE},
957             {"winehq.org",S_OK,FALSE},
958             {"word",S_OK,FALSE},
959             {"/",S_OK,FALSE},
960             {"/",S_OK,FALSE},
961             {"",S_FALSE,FALSE},
962             {"zip://test\\:word@winehq.org/",S_OK,FALSE},
963             {"zip",S_OK,FALSE},
964             {"test\\:word",S_OK,FALSE},
965             {"test\\",S_OK,FALSE}
966         },
967         {
968             {Uri_HOST_DNS,S_OK,FALSE},
969             {0,S_FALSE,FALSE},
970             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
971             {URLZONE_INVALID,E_NOTIMPL,FALSE}
972         }
973     },
974     /* It normalizes IPv4 addresses correctly. */
975     {   "http://127.000.000.100/", 0, S_OK, FALSE,
976         {
977             {"http://127.0.0.100/",S_OK,FALSE},
978             {"127.0.0.100",S_OK,FALSE},
979             {"http://127.0.0.100/",S_OK,FALSE},
980             {"",S_FALSE,FALSE},
981             {"",S_FALSE,FALSE},
982             {"",S_FALSE,FALSE},
983             {"127.0.0.100",S_OK,FALSE},
984             {"",S_FALSE,FALSE},
985             {"/",S_OK,FALSE},
986             {"/",S_OK,FALSE},
987             {"",S_FALSE,FALSE},
988             {"http://127.000.000.100/",S_OK,FALSE},
989             {"http",S_OK,FALSE},
990             {"",S_FALSE,FALSE},
991             {"",S_FALSE,FALSE}
992         },
993         {
994             {Uri_HOST_IPV4,S_OK,FALSE},
995             {80,S_OK,FALSE},
996             {URL_SCHEME_HTTP,S_OK,FALSE},
997             {URLZONE_INVALID,E_NOTIMPL,FALSE}
998         }
999     },
1000     {   "http://127.0.0.1:8000", 0, S_OK, FALSE,
1001         {
1002             {"http://127.0.0.1:8000/",S_OK},
1003             {"127.0.0.1:8000",S_OK},
1004             {"http://127.0.0.1:8000/",S_OK},
1005             {"",S_FALSE},
1006             {"",S_FALSE},
1007             {"",S_FALSE},
1008             {"127.0.0.1",S_OK},
1009             {"",S_FALSE},
1010             {"/",S_OK},
1011             {"/",S_OK},
1012             {"",S_FALSE},
1013             {"http://127.0.0.1:8000",S_OK},
1014             {"http",S_OK},
1015             {"",S_FALSE},
1016             {"",S_FALSE}
1017         },
1018         {
1019             {Uri_HOST_IPV4,S_OK,FALSE},
1020             {8000,S_OK,FALSE},
1021             {URL_SCHEME_HTTP,S_OK,FALSE},
1022             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1023         }
1024     },
1025     /* Make sure it normalizes partial IPv4 addresses correctly. */
1026     {   "http://127.0/", 0, S_OK, FALSE,
1027         {
1028             {"http://127.0.0.0/",S_OK,FALSE},
1029             {"127.0.0.0",S_OK,FALSE},
1030             {"http://127.0.0.0/",S_OK,FALSE},
1031             {"",S_FALSE,FALSE},
1032             {"",S_FALSE,FALSE},
1033             {"",S_FALSE,FALSE},
1034             {"127.0.0.0",S_OK,FALSE},
1035             {"",S_FALSE,FALSE},
1036             {"/",S_OK,FALSE},
1037             {"/",S_OK,FALSE},
1038             {"",S_FALSE,FALSE},
1039             {"http://127.0/",S_OK,FALSE},
1040             {"http",S_OK,FALSE},
1041             {"",S_FALSE,FALSE},
1042             {"",S_FALSE,FALSE}
1043         },
1044         {
1045             {Uri_HOST_IPV4,S_OK,FALSE},
1046             {80,S_OK,FALSE},
1047             {URL_SCHEME_HTTP,S_OK,FALSE},
1048             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1049         }
1050     },
1051     /* Make sure it converts implicit IPv4's correctly. */
1052     {   "http://123456/", 0, S_OK, FALSE,
1053         {
1054             {"http://0.1.226.64/",S_OK,FALSE},
1055             {"0.1.226.64",S_OK,FALSE},
1056             {"http://0.1.226.64/",S_OK,FALSE},
1057             {"",S_FALSE,FALSE},
1058             {"",S_FALSE,FALSE},
1059             {"",S_FALSE,FALSE},
1060             {"0.1.226.64",S_OK,FALSE},
1061             {"",S_FALSE,FALSE},
1062             {"/",S_OK,FALSE},
1063             {"/",S_OK,FALSE},
1064             {"",S_FALSE,FALSE},
1065             {"http://123456/",S_OK,FALSE},
1066             {"http",S_OK,FALSE},
1067             {"",S_FALSE,FALSE},
1068             {"",S_FALSE,FALSE}
1069         },
1070         {
1071             {Uri_HOST_IPV4,S_OK,FALSE},
1072             {80,S_OK,FALSE},
1073             {URL_SCHEME_HTTP,S_OK,FALSE},
1074             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1075         }
1076     },
1077     /* UINT_MAX */
1078     {   "http://4294967295/", 0, S_OK, FALSE,
1079         {
1080             {"http://255.255.255.255/",S_OK,FALSE},
1081             {"255.255.255.255",S_OK,FALSE},
1082             {"http://255.255.255.255/",S_OK,FALSE},
1083             {"",S_FALSE,FALSE},
1084             {"",S_FALSE,FALSE},
1085             {"",S_FALSE,FALSE},
1086             {"255.255.255.255",S_OK,FALSE},
1087             {"",S_FALSE,FALSE},
1088             {"/",S_OK,FALSE},
1089             {"/",S_OK,FALSE},
1090             {"",S_FALSE,FALSE},
1091             {"http://4294967295/",S_OK,FALSE},
1092             {"http",S_OK,FALSE},
1093             {"",S_FALSE,FALSE},
1094             {"",S_FALSE,FALSE}
1095         },
1096         {
1097             {Uri_HOST_IPV4,S_OK,FALSE},
1098             {80,S_OK,FALSE},
1099             {URL_SCHEME_HTTP,S_OK,FALSE},
1100             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1101         }
1102     },
1103     /* UINT_MAX+1 */
1104     {   "http://4294967296/", 0, S_OK, FALSE,
1105         {
1106             {"http://4294967296/",S_OK,FALSE},
1107             {"4294967296",S_OK,FALSE},
1108             {"http://4294967296/",S_OK,FALSE},
1109             {"",S_FALSE,FALSE},
1110             {"",S_FALSE,FALSE},
1111             {"",S_FALSE,FALSE},
1112             {"4294967296",S_OK,FALSE},
1113             {"",S_FALSE,FALSE},
1114             {"/",S_OK,FALSE},
1115             {"/",S_OK,FALSE},
1116             {"",S_FALSE,FALSE},
1117             {"http://4294967296/",S_OK,FALSE},
1118             {"http",S_OK,FALSE},
1119             {"",S_FALSE,FALSE},
1120             {"",S_FALSE,FALSE}
1121         },
1122         {
1123             {Uri_HOST_DNS,S_OK,FALSE},
1124             {80,S_OK,FALSE},
1125             {URL_SCHEME_HTTP,S_OK,FALSE},
1126             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1127         }
1128     },
1129     /* Window's doesn't normalize IP address for unknown schemes. */
1130     {   "1234://4294967295/", 0, S_OK, FALSE,
1131         {
1132             {"1234://4294967295/",S_OK,FALSE},
1133             {"4294967295",S_OK,FALSE},
1134             {"1234://4294967295/",S_OK,FALSE},
1135             {"",S_FALSE,FALSE},
1136             {"",S_FALSE,FALSE},
1137             {"",S_FALSE,FALSE},
1138             {"4294967295",S_OK,FALSE},
1139             {"",S_FALSE,FALSE},
1140             {"/",S_OK,FALSE},
1141             {"/",S_OK,FALSE},
1142             {"",S_FALSE,FALSE},
1143             {"1234://4294967295/",S_OK,FALSE},
1144             {"1234",S_OK,FALSE},
1145             {"",S_FALSE,FALSE},
1146             {"",S_FALSE,FALSE}
1147         },
1148         {
1149             {Uri_HOST_IPV4,S_OK,FALSE},
1150             {0,S_FALSE,FALSE},
1151             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1152             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1153         }
1154     },
1155     /* Window's doesn't normalize IP address for unknown schemes. */
1156     {   "1234://127.001/", 0, S_OK, FALSE,
1157         {
1158             {"1234://127.001/",S_OK,FALSE},
1159             {"127.001",S_OK,FALSE},
1160             {"1234://127.001/",S_OK,FALSE},
1161             {"",S_FALSE,FALSE},
1162             {"",S_FALSE,FALSE},
1163             {"",S_FALSE,FALSE},
1164             {"127.001",S_OK,FALSE},
1165             {"",S_FALSE,FALSE},
1166             {"/",S_OK,FALSE},
1167             {"/",S_OK,FALSE},
1168             {"",S_FALSE,FALSE},
1169             {"1234://127.001/",S_OK,FALSE},
1170             {"1234",S_OK,FALSE},
1171             {"",S_FALSE,FALSE},
1172             {"",S_FALSE,FALSE}
1173         },
1174         {
1175             {Uri_HOST_IPV4,S_OK,FALSE},
1176             {0,S_FALSE,FALSE},
1177             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1178             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1179         }
1180     },
1181     {   "http://[FEDC:BA98::3210]", 0, S_OK, FALSE,
1182         {
1183             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
1184             {"[fedc:ba98::3210]",S_OK,FALSE},
1185             {"http://[fedc:ba98::3210]/",S_OK,FALSE},
1186             {"",S_FALSE,FALSE},
1187             {"",S_FALSE,FALSE},
1188             {"",S_FALSE,FALSE},
1189             {"fedc:ba98::3210",S_OK,FALSE},
1190             {"",S_FALSE,FALSE},
1191             {"/",S_OK,FALSE},
1192             {"/",S_OK,FALSE},
1193             {"",S_FALSE,FALSE},
1194             {"http://[FEDC:BA98::3210]",S_OK,FALSE},
1195             {"http",S_OK,FALSE},
1196             {"",S_FALSE,FALSE},
1197             {"",S_FALSE,FALSE},
1198         },
1199         {
1200             {Uri_HOST_IPV6,S_OK,FALSE},
1201             {80,S_OK,FALSE},
1202             {URL_SCHEME_HTTP,S_OK,FALSE},
1203             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1204         }
1205     },
1206     {   "http://[::]", 0, S_OK, FALSE,
1207         {
1208             {"http://[::]/",S_OK,FALSE},
1209             {"[::]",S_OK,FALSE},
1210             {"http://[::]/",S_OK,FALSE},
1211             {"",S_FALSE,FALSE},
1212             {"",S_FALSE,FALSE},
1213             {"",S_FALSE,FALSE},
1214             {"::",S_OK,FALSE},
1215             {"",S_FALSE,FALSE},
1216             {"/",S_OK,FALSE},
1217             {"/",S_OK,FALSE},
1218             {"",S_FALSE,FALSE},
1219             {"http://[::]",S_OK,FALSE},
1220             {"http",S_OK,FALSE},
1221             {"",S_FALSE,FALSE},
1222             {"",S_FALSE,FALSE},
1223         },
1224         {
1225             {Uri_HOST_IPV6,S_OK,FALSE},
1226             {80,S_OK,FALSE},
1227             {URL_SCHEME_HTTP,S_OK,FALSE},
1228             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1229         }
1230     },
1231     {   "http://[FEDC:BA98::]", 0, S_OK, FALSE,
1232         {
1233             {"http://[fedc:ba98::]/",S_OK,FALSE},
1234             {"[fedc:ba98::]",S_OK,FALSE},
1235             {"http://[fedc:ba98::]/",S_OK,FALSE},
1236             {"",S_FALSE,FALSE},
1237             {"",S_FALSE,FALSE},
1238             {"",S_FALSE,FALSE},
1239             {"fedc:ba98::",S_OK,FALSE},
1240             {"",S_FALSE,FALSE},
1241             {"/",S_OK,FALSE},
1242             {"/",S_OK,FALSE},
1243             {"",S_FALSE,FALSE},
1244             {"http://[FEDC:BA98::]",S_OK,FALSE},
1245             {"http",S_OK,FALSE},
1246             {"",S_FALSE,FALSE},
1247             {"",S_FALSE,FALSE},
1248         },
1249         {
1250             {Uri_HOST_IPV6,S_OK,FALSE},
1251             {80,S_OK,FALSE},
1252             {URL_SCHEME_HTTP,S_OK,FALSE},
1253             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1254         }
1255     },
1256     /* Valid even with 2 byte elision because it doesn't appear the beginning or end. */
1257     {   "http://[1::3:4:5:6:7:8]", 0, S_OK, FALSE,
1258         {
1259             {"http://[1:0:3:4:5:6:7:8]/",S_OK,FALSE},
1260             {"[1:0:3:4:5:6:7:8]",S_OK,FALSE},
1261             {"http://[1:0:3:4:5:6:7:8]/",S_OK,FALSE},
1262             {"",S_FALSE,FALSE},
1263             {"",S_FALSE,FALSE},
1264             {"",S_FALSE,FALSE},
1265             {"1:0:3:4:5:6:7:8",S_OK,FALSE},
1266             {"",S_FALSE,FALSE},
1267             {"/",S_OK,FALSE},
1268             {"/",S_OK,FALSE},
1269             {"",S_FALSE,FALSE},
1270             {"http://[1::3:4:5:6:7:8]",S_OK,FALSE},
1271             {"http",S_OK,FALSE},
1272             {"",S_FALSE,FALSE},
1273             {"",S_FALSE,FALSE},
1274         },
1275         {
1276             {Uri_HOST_IPV6,S_OK,FALSE},
1277             {80,S_OK,FALSE},
1278             {URL_SCHEME_HTTP,S_OK,FALSE},
1279             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1280         }
1281     },
1282     {   "http://[v2.34]/", 0, S_OK, FALSE,
1283         {
1284             {"http://[v2.34]/",S_OK,FALSE},
1285             {"[v2.34]",S_OK,FALSE},
1286             {"http://[v2.34]/",S_OK,FALSE},
1287             {"",S_FALSE,FALSE},
1288             {"",S_FALSE,FALSE},
1289             {"",S_FALSE,FALSE},
1290             {"[v2.34]",S_OK,FALSE},
1291             {"",S_FALSE,FALSE},
1292             {"/",S_OK,FALSE},
1293             {"/",S_OK,FALSE},
1294             {"",S_FALSE,FALSE},
1295             {"http://[v2.34]/",S_OK,FALSE},
1296             {"http",S_OK,FALSE},
1297             {"",S_FALSE,FALSE},
1298             {"",S_FALSE,FALSE}
1299         },
1300         {
1301             {Uri_HOST_UNKNOWN,S_OK,FALSE},
1302             {80,S_OK,FALSE},
1303             {URL_SCHEME_HTTP,S_OK,FALSE},
1304             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1305         }
1306     },
1307     /* Windows ignores ':' if they appear after a '[' on a non-IPLiteral host. */
1308     {   "http://[xyz:12345.com/test", 0, S_OK, FALSE,
1309         {
1310             {"http://[xyz:12345.com/test",S_OK,FALSE},
1311             {"[xyz:12345.com",S_OK,FALSE},
1312             {"http://[xyz:12345.com/test",S_OK,FALSE},
1313             {"[xyz:12345.com",S_OK,FALSE},
1314             {"",S_FALSE,FALSE},
1315             {"",S_FALSE,FALSE},
1316             {"[xyz:12345.com",S_OK,FALSE},
1317             {"",S_FALSE,FALSE},
1318             {"/test",S_OK,FALSE},
1319             {"/test",S_OK,FALSE},
1320             {"",S_FALSE,FALSE},
1321             {"http://[xyz:12345.com/test",S_OK,FALSE},
1322             {"http",S_OK,FALSE},
1323             {"",S_FALSE,FALSE},
1324             {"",S_FALSE,FALSE}
1325         },
1326         {
1327             {Uri_HOST_DNS,S_OK,FALSE},
1328             {80,S_OK,FALSE},
1329             {URL_SCHEME_HTTP,S_OK,FALSE},
1330             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1331         }
1332     },
1333     /* Valid URI since the '[' and ']' don't appear at the beginning and end
1334      * of the host name (respectively).
1335      */
1336     {   "ftp://www.[works].com/", 0, S_OK, FALSE,
1337         {
1338             {"ftp://www.[works].com/",S_OK,FALSE},
1339             {"www.[works].com",S_OK,FALSE},
1340             {"ftp://www.[works].com/",S_OK,FALSE},
1341             {"[works].com",S_OK,FALSE},
1342             {"",S_FALSE,FALSE},
1343             {"",S_FALSE,FALSE},
1344             {"www.[works].com",S_OK,FALSE},
1345             {"",S_FALSE,FALSE},
1346             {"/",S_OK,FALSE},
1347             {"/",S_OK,FALSE},
1348             {"",S_FALSE,FALSE},
1349             {"ftp://www.[works].com/",S_OK,FALSE},
1350             {"ftp",S_OK,FALSE},
1351             {"",S_FALSE,FALSE},
1352             {"",S_FALSE,FALSE}
1353         },
1354         {
1355             {Uri_HOST_DNS,S_OK,FALSE},
1356             {21,S_OK,FALSE},
1357             {URL_SCHEME_FTP,S_OK,FALSE},
1358             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1359         }
1360     },
1361     /* Considers ':' a delimiter since it appears after the ']'. */
1362     {   "http://www.google.com]:12345/", 0, S_OK, FALSE,
1363         {
1364             {"http://www.google.com]:12345/",S_OK,FALSE},
1365             {"www.google.com]:12345",S_OK,FALSE},
1366             {"http://www.google.com]:12345/",S_OK,FALSE},
1367             {"google.com]",S_OK,FALSE},
1368             {"",S_FALSE,FALSE},
1369             {"",S_FALSE,FALSE},
1370             {"www.google.com]",S_OK,FALSE},
1371             {"",S_FALSE,FALSE},
1372             {"/",S_OK,FALSE},
1373             {"/",S_OK,FALSE},
1374             {"",S_FALSE,FALSE},
1375             {"http://www.google.com]:12345/",S_OK,FALSE},
1376             {"http",S_OK,FALSE},
1377             {"",S_FALSE,FALSE},
1378             {"",S_FALSE,FALSE}
1379         },
1380         {
1381             {Uri_HOST_DNS,S_OK,FALSE},
1382             {12345,S_OK,FALSE},
1383             {URL_SCHEME_HTTP,S_OK,FALSE},
1384             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1385         }
1386     },
1387     /* Unknown scheme types can have invalid % encoded data in the hostname. */
1388     {   "zip://w%XXw%GEw.google.com/", 0, S_OK, FALSE,
1389         {
1390             {"zip://w%XXw%GEw.google.com/",S_OK,FALSE},
1391             {"w%XXw%GEw.google.com",S_OK,FALSE},
1392             {"zip://w%XXw%GEw.google.com/",S_OK,FALSE},
1393             {"google.com",S_OK,FALSE},
1394             {"",S_FALSE,FALSE},
1395             {"",S_FALSE,FALSE},
1396             {"w%XXw%GEw.google.com",S_OK,FALSE},
1397             {"",S_FALSE,FALSE},
1398             {"/",S_OK,FALSE},
1399             {"/",S_OK,FALSE},
1400             {"",S_FALSE,FALSE},
1401             {"zip://w%XXw%GEw.google.com/",S_OK,FALSE},
1402             {"zip",S_OK,FALSE},
1403             {"",S_FALSE,FALSE},
1404             {"",S_FALSE,FALSE}
1405         },
1406         {
1407             {Uri_HOST_DNS,S_OK,FALSE},
1408             {0,S_FALSE,FALSE},
1409             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1410             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1411         }
1412     },
1413     /* Unknown scheme types hostname doesn't get lower cased. */
1414     {   "zip://GOOGLE.com/", 0, S_OK, FALSE,
1415         {
1416             {"zip://GOOGLE.com/",S_OK,FALSE},
1417             {"GOOGLE.com",S_OK,FALSE},
1418             {"zip://GOOGLE.com/",S_OK,FALSE},
1419             {"GOOGLE.com",S_OK,FALSE},
1420             {"",S_FALSE,FALSE},
1421             {"",S_FALSE,FALSE},
1422             {"GOOGLE.com",S_OK,FALSE},
1423             {"",S_FALSE,FALSE},
1424             {"/",S_OK,FALSE},
1425             {"/",S_OK,FALSE},
1426             {"",S_FALSE,FALSE},
1427             {"zip://GOOGLE.com/",S_OK,FALSE},
1428             {"zip",S_OK,FALSE},
1429             {"",S_FALSE,FALSE},
1430             {"",S_FALSE,FALSE}
1431         },
1432         {
1433             {Uri_HOST_DNS,S_OK,FALSE},
1434             {0,S_FALSE,FALSE},
1435             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1436             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1437         }
1438     },
1439     /* Hostname gets lower-cased for known scheme types. */
1440     {   "http://WWW.GOOGLE.com/", 0, S_OK, FALSE,
1441         {
1442             {"http://www.google.com/",S_OK,FALSE},
1443             {"www.google.com",S_OK,FALSE},
1444             {"http://www.google.com/",S_OK,FALSE},
1445             {"google.com",S_OK,FALSE},
1446             {"",S_FALSE,FALSE},
1447             {"",S_FALSE,FALSE},
1448             {"www.google.com",S_OK,FALSE},
1449             {"",S_FALSE,FALSE},
1450             {"/",S_OK,FALSE},
1451             {"/",S_OK,FALSE},
1452             {"",S_FALSE,FALSE},
1453             {"http://WWW.GOOGLE.com/",S_OK,FALSE},
1454             {"http",S_OK,FALSE},
1455             {"",S_FALSE,FALSE},
1456             {"",S_FALSE,FALSE}
1457         },
1458         {
1459             {Uri_HOST_DNS,S_OK,FALSE},
1460             {80,S_OK,FALSE},
1461             {URL_SCHEME_HTTP,S_OK,FALSE},
1462             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1463         }
1464     },
1465     /* Characters that get % encoded in the hostname also have their percent
1466      * encoded forms lower cased.
1467      */
1468     {   "http://www.%7Cgoogle|.com/", 0, S_OK, FALSE,
1469         {
1470             {"http://www.%7cgoogle%7c.com/",S_OK,FALSE},
1471             {"www.%7cgoogle%7c.com",S_OK,FALSE},
1472             {"http://www.%7cgoogle%7c.com/",S_OK,FALSE},
1473             {"%7cgoogle%7c.com",S_OK,FALSE},
1474             {"",S_FALSE,FALSE},
1475             {"",S_FALSE,FALSE},
1476             {"www.%7cgoogle%7c.com",S_OK,FALSE},
1477             {"",S_FALSE,FALSE},
1478             {"/",S_OK,FALSE},
1479             {"/",S_OK,FALSE},
1480             {"",S_FALSE,FALSE},
1481             {"http://www.%7Cgoogle|.com/",S_OK,FALSE},
1482             {"http",S_OK,FALSE},
1483             {"",S_FALSE,FALSE},
1484             {"",S_FALSE,FALSE}
1485         },
1486         {
1487             {Uri_HOST_DNS,S_OK,FALSE},
1488             {80,S_OK,FALSE},
1489             {URL_SCHEME_HTTP,S_OK,FALSE},
1490             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1491         }
1492     },
1493     /* IPv4 addresses attached to IPv6 can be included in elisions. */
1494     {   "http://[1:2:3:4:5:6:0.0.0.0]", 0, S_OK, FALSE,
1495         {
1496             {"http://[1:2:3:4:5:6::]/",S_OK,FALSE},
1497             {"[1:2:3:4:5:6::]",S_OK,FALSE},
1498             {"http://[1:2:3:4:5:6::]/",S_OK,FALSE},
1499             {"",S_FALSE,FALSE},
1500             {"",S_FALSE,FALSE},
1501             {"",S_FALSE,FALSE},
1502             {"1:2:3:4:5:6::",S_OK,FALSE},
1503             {"",S_FALSE,FALSE},
1504             {"/",S_OK,FALSE},
1505             {"/",S_OK,FALSE},
1506             {"",S_FALSE,FALSE},
1507             {"http://[1:2:3:4:5:6:0.0.0.0]",S_OK,FALSE},
1508             {"http",S_OK,FALSE},
1509             {"",S_FALSE,FALSE},
1510             {"",S_FALSE,FALSE},
1511         },
1512         {
1513             {Uri_HOST_IPV6,S_OK,FALSE},
1514             {80,S_OK,FALSE},
1515             {URL_SCHEME_HTTP,S_OK,FALSE},
1516             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1517         }
1518     },
1519     /* IPv4 addresses get normalized. */
1520     {   "http://[::001.002.003.000]", 0, S_OK, FALSE,
1521         {
1522             {"http://[::1.2.3.0]/",S_OK,FALSE},
1523             {"[::1.2.3.0]",S_OK,FALSE},
1524             {"http://[::1.2.3.0]/",S_OK,FALSE},
1525             {"",S_FALSE,FALSE},
1526             {"",S_FALSE,FALSE},
1527             {"",S_FALSE,FALSE},
1528             {"::1.2.3.0",S_OK,FALSE},
1529             {"",S_FALSE,FALSE},
1530             {"/",S_OK,FALSE},
1531             {"/",S_OK,FALSE},
1532             {"",S_FALSE,FALSE},
1533             {"http://[::001.002.003.000]",S_OK,FALSE},
1534             {"http",S_OK,FALSE},
1535             {"",S_FALSE,FALSE},
1536             {"",S_FALSE,FALSE},
1537         },
1538         {
1539             {Uri_HOST_IPV6,S_OK,FALSE},
1540             {80,S_OK,FALSE},
1541             {URL_SCHEME_HTTP,S_OK,FALSE},
1542             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1543         }
1544     },
1545     /* Windows doesn't do anything to IPv6's in unknown schemes. */
1546     {   "zip://[0001:0:000:0004:0005:0006:001.002.003.000]", 0, S_OK, FALSE,
1547         {
1548             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]/",S_OK,FALSE},
1549             {"[0001:0:000:0004:0005:0006:001.002.003.000]",S_OK,FALSE},
1550             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]/",S_OK,FALSE},
1551             {"",S_FALSE,FALSE},
1552             {"",S_FALSE,FALSE},
1553             {"",S_FALSE,FALSE},
1554             {"0001:0:000:0004:0005:0006:001.002.003.000",S_OK,FALSE},
1555             {"",S_FALSE,FALSE},
1556             {"/",S_OK,FALSE},
1557             {"/",S_OK,FALSE},
1558             {"",S_FALSE,FALSE},
1559             {"zip://[0001:0:000:0004:0005:0006:001.002.003.000]",S_OK,FALSE},
1560             {"zip",S_OK,FALSE},
1561             {"",S_FALSE,FALSE},
1562             {"",S_FALSE,FALSE},
1563         },
1564         {
1565             {Uri_HOST_IPV6,S_OK,FALSE},
1566             {0,S_FALSE,FALSE},
1567             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1568             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1569         }
1570     },
1571     /* IPv4 address is converted into 2 h16 components. */
1572     {   "http://[ffff::192.222.111.32]", 0, S_OK, FALSE,
1573         {
1574             {"http://[ffff::c0de:6f20]/",S_OK,FALSE},
1575             {"[ffff::c0de:6f20]",S_OK,FALSE},
1576             {"http://[ffff::c0de:6f20]/",S_OK,FALSE},
1577             {"",S_FALSE,FALSE},
1578             {"",S_FALSE,FALSE},
1579             {"",S_FALSE,FALSE},
1580             {"ffff::c0de:6f20",S_OK,FALSE},
1581             {"",S_FALSE,FALSE},
1582             {"/",S_OK,FALSE},
1583             {"/",S_OK,FALSE},
1584             {"",S_FALSE,FALSE},
1585             {"http://[ffff::192.222.111.32]",S_OK,FALSE},
1586             {"http",S_OK,FALSE},
1587             {"",S_FALSE,FALSE},
1588             {"",S_FALSE,FALSE},
1589         },
1590         {
1591             {Uri_HOST_IPV6,S_OK,FALSE},
1592             {80,S_OK,FALSE},
1593             {URL_SCHEME_HTTP,S_OK,FALSE},
1594             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1595         }
1596     },
1597     /* Max value for a port. */
1598     {   "http://google.com:65535", 0, S_OK, FALSE,
1599         {
1600             {"http://google.com:65535/",S_OK,FALSE},
1601             {"google.com:65535",S_OK,FALSE},
1602             {"http://google.com:65535/",S_OK,FALSE},
1603             {"google.com",S_OK,FALSE},
1604             {"",S_FALSE,FALSE},
1605             {"",S_FALSE,FALSE},
1606             {"google.com",S_OK,FALSE},
1607             {"",S_FALSE,FALSE},
1608             {"/",S_OK,FALSE},
1609             {"/",S_OK,FALSE},
1610             {"",S_FALSE,FALSE},
1611             {"http://google.com:65535",S_OK,FALSE},
1612             {"http",S_OK,FALSE},
1613             {"",S_FALSE,FALSE},
1614             {"",S_FALSE,FALSE}
1615         },
1616         {
1617             {Uri_HOST_DNS,S_OK,FALSE},
1618             {65535,S_OK,FALSE},
1619             {URL_SCHEME_HTTP,S_OK,FALSE},
1620             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1621         }
1622     },
1623     {   "zip://google.com:65536", 0, S_OK, FALSE,
1624         {
1625             {"zip://google.com:65536/",S_OK,FALSE},
1626             {"google.com:65536",S_OK,FALSE},
1627             {"zip://google.com:65536/",S_OK,FALSE},
1628             {"google.com:65536",S_OK,FALSE},
1629             {"",S_FALSE,FALSE},
1630             {"",S_FALSE,FALSE},
1631             {"google.com:65536",S_OK,FALSE},
1632             {"",S_FALSE,FALSE},
1633             {"/",S_OK,FALSE},
1634             {"/",S_OK,FALSE},
1635             {"",S_FALSE,FALSE},
1636             {"zip://google.com:65536",S_OK,FALSE},
1637             {"zip",S_OK,FALSE},
1638             {"",S_FALSE,FALSE},
1639             {"",S_FALSE,FALSE}
1640         },
1641         {
1642             {Uri_HOST_DNS,S_OK,FALSE},
1643             {0,S_FALSE,FALSE},
1644             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1645             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1646         }
1647     },
1648     {   "zip://google.com:65536:25", 0, S_OK, FALSE,
1649         {
1650             {"zip://google.com:65536:25/",S_OK,FALSE},
1651             {"google.com:65536:25",S_OK,FALSE},
1652             {"zip://google.com:65536:25/",S_OK,FALSE},
1653             {"google.com:65536:25",S_OK,FALSE},
1654             {"",S_FALSE,FALSE},
1655             {"",S_FALSE,FALSE},
1656             {"google.com:65536:25",S_OK,FALSE},
1657             {"",S_FALSE,FALSE},
1658             {"/",S_OK,FALSE},
1659             {"/",S_OK,FALSE},
1660             {"",S_FALSE,FALSE},
1661             {"zip://google.com:65536:25",S_OK,FALSE},
1662             {"zip",S_OK,FALSE},
1663             {"",S_FALSE,FALSE},
1664             {"",S_FALSE,FALSE}
1665         },
1666         {
1667             {Uri_HOST_DNS,S_OK,FALSE},
1668             {0,S_FALSE,FALSE},
1669             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1670             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1671         }
1672     },
1673     {   "zip://[::ffff]:abcd", 0, S_OK, FALSE,
1674         {
1675             {"zip://[::ffff]:abcd/",S_OK,FALSE},
1676             {"[::ffff]:abcd",S_OK,FALSE},
1677             {"zip://[::ffff]:abcd/",S_OK,FALSE},
1678             {"",S_FALSE,FALSE},
1679             {"",S_FALSE,FALSE},
1680             {"",S_FALSE,FALSE},
1681             {"[::ffff]:abcd",S_OK,FALSE},
1682             {"",S_FALSE,FALSE},
1683             {"/",S_OK,FALSE},
1684             {"/",S_OK,FALSE},
1685             {"",S_FALSE,FALSE},
1686             {"zip://[::ffff]:abcd",S_OK,FALSE},
1687             {"zip",S_OK,FALSE},
1688             {"",S_FALSE,FALSE},
1689             {"",S_FALSE,FALSE}
1690         },
1691         {
1692             {Uri_HOST_DNS,S_OK,FALSE},
1693             {0,S_FALSE,FALSE},
1694             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1695             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1696         }
1697     },
1698     {   "zip://127.0.0.1:abcd", 0, S_OK, FALSE,
1699         {
1700             {"zip://127.0.0.1:abcd/",S_OK,FALSE},
1701             {"127.0.0.1:abcd",S_OK,FALSE},
1702             {"zip://127.0.0.1:abcd/",S_OK,FALSE},
1703             {"0.1:abcd",S_OK,FALSE},
1704             {"",S_FALSE,FALSE},
1705             {"",S_FALSE,FALSE},
1706             {"127.0.0.1:abcd",S_OK,FALSE},
1707             {"",S_FALSE,FALSE},
1708             {"/",S_OK,FALSE},
1709             {"/",S_OK,FALSE},
1710             {"",S_FALSE,FALSE},
1711             {"zip://127.0.0.1:abcd",S_OK,FALSE},
1712             {"zip",S_OK,FALSE},
1713             {"",S_FALSE,FALSE},
1714             {"",S_FALSE,FALSE}
1715         },
1716         {
1717             {Uri_HOST_DNS,S_OK,FALSE},
1718             {0,S_FALSE,FALSE},
1719             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
1720             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1721         }
1722     },
1723     /* Port is just copied over. */
1724     {   "http://google.com:00035", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
1725         {
1726             {"http://google.com:00035",S_OK,FALSE},
1727             {"google.com:00035",S_OK,FALSE},
1728             {"http://google.com:00035",S_OK,FALSE,"http://google.com:35"},
1729             {"google.com",S_OK,FALSE},
1730             {"",S_FALSE,FALSE},
1731             {"",S_FALSE,FALSE},
1732             {"google.com",S_OK,FALSE},
1733             {"",S_FALSE,FALSE},
1734             {"",S_FALSE,FALSE},
1735             {"",S_FALSE,FALSE},
1736             {"",S_FALSE,FALSE},
1737             {"http://google.com:00035",S_OK,FALSE},
1738             {"http",S_OK,FALSE},
1739             {"",S_FALSE,FALSE},
1740             {"",S_FALSE,FALSE}
1741         },
1742         {
1743             {Uri_HOST_DNS,S_OK,FALSE},
1744             {35,S_OK,FALSE},
1745             {URL_SCHEME_HTTP,S_OK,FALSE},
1746             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1747         }
1748     },
1749     /* Default port is copied over. */
1750     {   "http://google.com:80", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
1751         {
1752             {"http://google.com:80",S_OK,FALSE},
1753             {"google.com:80",S_OK,FALSE},
1754             {"http://google.com:80",S_OK,FALSE},
1755             {"google.com",S_OK,FALSE},
1756             {"",S_FALSE,FALSE},
1757             {"",S_FALSE,FALSE},
1758             {"google.com",S_OK,FALSE},
1759             {"",S_FALSE,FALSE},
1760             {"",S_FALSE,FALSE},
1761             {"",S_FALSE,FALSE},
1762             {"",S_FALSE,FALSE},
1763             {"http://google.com:80",S_OK,FALSE},
1764             {"http",S_OK,FALSE},
1765             {"",S_FALSE,FALSE},
1766             {"",S_FALSE,FALSE}
1767         },
1768         {
1769             {Uri_HOST_DNS,S_OK,FALSE},
1770             {80,S_OK,FALSE},
1771             {URL_SCHEME_HTTP,S_OK,FALSE},
1772             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1773         }
1774     },
1775     {   "http://google.com.uk", 0, S_OK, FALSE,
1776         {
1777             {"http://google.com.uk/",S_OK,FALSE},
1778             {"google.com.uk",S_OK,FALSE},
1779             {"http://google.com.uk/",S_OK,FALSE},
1780             {"google.com.uk",S_OK,FALSE},
1781             {"",S_FALSE,FALSE},
1782             {"",S_FALSE,FALSE},
1783             {"google.com.uk",S_OK,FALSE},
1784             {"",S_FALSE,FALSE},
1785             {"/",S_OK,FALSE},
1786             {"/",S_OK,FALSE},
1787             {"",S_FALSE,FALSE},
1788             {"http://google.com.uk",S_OK,FALSE},
1789             {"http",S_OK,FALSE},
1790             {"",S_FALSE,FALSE},
1791             {"",S_FALSE,FALSE}
1792         },
1793         {
1794             {Uri_HOST_DNS,S_OK,FALSE},
1795             {80,S_OK,FALSE},
1796             {URL_SCHEME_HTTP,S_OK,FALSE},
1797             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1798         }
1799     },
1800     {   "http://google.com.com", 0, S_OK, FALSE,
1801         {
1802             {"http://google.com.com/",S_OK,FALSE},
1803             {"google.com.com",S_OK,FALSE},
1804             {"http://google.com.com/",S_OK,FALSE},
1805             {"com.com",S_OK,FALSE},
1806             {"",S_FALSE,FALSE},
1807             {"",S_FALSE,FALSE},
1808             {"google.com.com",S_OK,FALSE},
1809             {"",S_FALSE,FALSE},
1810             {"/",S_OK,FALSE},
1811             {"/",S_OK,FALSE},
1812             {"",S_FALSE,FALSE},
1813             {"http://google.com.com",S_OK,FALSE},
1814             {"http",S_OK,FALSE},
1815             {"",S_FALSE,FALSE},
1816             {"",S_FALSE,FALSE}
1817         },
1818         {
1819             {Uri_HOST_DNS,S_OK,FALSE},
1820             {80,S_OK,FALSE},
1821             {URL_SCHEME_HTTP,S_OK,FALSE},
1822             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1823         }
1824     },
1825     {   "http://google.uk.1", 0, S_OK, FALSE,
1826         {
1827             {"http://google.uk.1/",S_OK,FALSE},
1828             {"google.uk.1",S_OK,FALSE},
1829             {"http://google.uk.1/",S_OK,FALSE},
1830             {"google.uk.1",S_OK,FALSE},
1831             {"",S_FALSE,FALSE},
1832             {"",S_FALSE,FALSE},
1833             {"google.uk.1",S_OK,FALSE},
1834             {"",S_FALSE,FALSE},
1835             {"/",S_OK,FALSE},
1836             {"/",S_OK,FALSE},
1837             {"",S_FALSE,FALSE},
1838             {"http://google.uk.1",S_OK,FALSE},
1839             {"http",S_OK,FALSE},
1840             {"",S_FALSE,FALSE},
1841             {"",S_FALSE,FALSE}
1842         },
1843         {
1844             {Uri_HOST_DNS,S_OK,FALSE},
1845             {80,S_OK,FALSE},
1846             {URL_SCHEME_HTTP,S_OK,FALSE},
1847             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1848         }
1849     },
1850     /* Since foo isn't a recognized 3 character TLD its considered the domain name. */
1851     {   "http://google.foo.uk", 0, S_OK, FALSE,
1852         {
1853             {"http://google.foo.uk/",S_OK,FALSE},
1854             {"google.foo.uk",S_OK,FALSE},
1855             {"http://google.foo.uk/",S_OK,FALSE},
1856             {"foo.uk",S_OK,FALSE},
1857             {"",S_FALSE,FALSE},
1858             {"",S_FALSE,FALSE},
1859             {"google.foo.uk",S_OK,FALSE},
1860             {"",S_FALSE,FALSE},
1861             {"/",S_OK,FALSE},
1862             {"/",S_OK,FALSE},
1863             {"",S_FALSE,FALSE},
1864             {"http://google.foo.uk",S_OK,FALSE},
1865             {"http",S_OK,FALSE},
1866             {"",S_FALSE,FALSE},
1867             {"",S_FALSE,FALSE}
1868         },
1869         {
1870             {Uri_HOST_DNS,S_OK,FALSE},
1871             {80,S_OK,FALSE},
1872             {URL_SCHEME_HTTP,S_OK,FALSE},
1873             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1874         }
1875     },
1876     {   "http://.com", 0, S_OK, FALSE,
1877         {
1878             {"http://.com/",S_OK,FALSE},
1879             {".com",S_OK,FALSE},
1880             {"http://.com/",S_OK,FALSE},
1881             {".com",S_OK,FALSE},
1882             {"",S_FALSE,FALSE},
1883             {"",S_FALSE,FALSE},
1884             {".com",S_OK,FALSE},
1885             {"",S_FALSE,FALSE},
1886             {"/",S_OK,FALSE},
1887             {"/",S_OK,FALSE},
1888             {"",S_FALSE,FALSE},
1889             {"http://.com",S_OK,FALSE},
1890             {"http",S_OK,FALSE},
1891             {"",S_FALSE,FALSE},
1892             {"",S_FALSE,FALSE}
1893         },
1894         {
1895             {Uri_HOST_DNS,S_OK,FALSE},
1896             {80,S_OK,FALSE},
1897             {URL_SCHEME_HTTP,S_OK,FALSE},
1898             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1899         }
1900     },
1901     {   "http://.uk", 0, S_OK, FALSE,
1902         {
1903             {"http://.uk/",S_OK,FALSE},
1904             {".uk",S_OK,FALSE},
1905             {"http://.uk/",S_OK,FALSE},
1906             {"",S_FALSE,FALSE},
1907             {"",S_FALSE,FALSE},
1908             {"",S_FALSE,FALSE},
1909             {".uk",S_OK,FALSE},
1910             {"",S_FALSE,FALSE},
1911             {"/",S_OK,FALSE},
1912             {"/",S_OK,FALSE},
1913             {"",S_FALSE,FALSE},
1914             {"http://.uk",S_OK,FALSE},
1915             {"http",S_OK,FALSE},
1916             {"",S_FALSE,FALSE},
1917             {"",S_FALSE,FALSE}
1918         },
1919         {
1920             {Uri_HOST_DNS,S_OK,FALSE},
1921             {80,S_OK,FALSE},
1922             {URL_SCHEME_HTTP,S_OK,FALSE},
1923             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1924         }
1925     },
1926     {   "http://www.co.google.com.[]", 0, S_OK, FALSE,
1927         {
1928             {"http://www.co.google.com.[]/",S_OK,FALSE},
1929             {"www.co.google.com.[]",S_OK,FALSE},
1930             {"http://www.co.google.com.[]/",S_OK,FALSE},
1931             {"google.com.[]",S_OK,FALSE},
1932             {"",S_FALSE,FALSE},
1933             {"",S_FALSE,FALSE},
1934             {"www.co.google.com.[]",S_OK,FALSE},
1935             {"",S_FALSE,FALSE},
1936             {"/",S_OK,FALSE},
1937             {"/",S_OK,FALSE},
1938             {"",S_FALSE,FALSE},
1939             {"http://www.co.google.com.[]",S_OK,FALSE},
1940             {"http",S_OK,FALSE},
1941             {"",S_FALSE,FALSE},
1942             {"",S_FALSE,FALSE}
1943         },
1944         {
1945             {Uri_HOST_DNS,S_OK,FALSE},
1946             {80,S_OK,FALSE},
1947             {URL_SCHEME_HTTP,S_OK,FALSE},
1948             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1949         }
1950     },
1951     {   "http://co.uk", 0, S_OK, FALSE,
1952         {
1953             {"http://co.uk/",S_OK,FALSE},
1954             {"co.uk",S_OK,FALSE},
1955             {"http://co.uk/",S_OK,FALSE},
1956             {"",S_FALSE,FALSE},
1957             {"",S_FALSE,FALSE},
1958             {"",S_FALSE,FALSE},
1959             {"co.uk",S_OK,FALSE},
1960             {"",S_FALSE,FALSE},
1961             {"/",S_OK,FALSE},
1962             {"/",S_OK,FALSE},
1963             {"",S_FALSE,FALSE},
1964             {"http://co.uk",S_OK,FALSE},
1965             {"http",S_OK,FALSE},
1966             {"",S_FALSE,FALSE},
1967             {"",S_FALSE,FALSE}
1968         },
1969         {
1970             {Uri_HOST_DNS,S_OK,FALSE},
1971             {80,S_OK,FALSE},
1972             {URL_SCHEME_HTTP,S_OK,FALSE},
1973             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1974         }
1975     },
1976     {   "http://www.co.google.us.test", 0, S_OK, FALSE,
1977         {
1978             {"http://www.co.google.us.test/",S_OK,FALSE},
1979             {"www.co.google.us.test",S_OK,FALSE},
1980             {"http://www.co.google.us.test/",S_OK,FALSE},
1981             {"us.test",S_OK,FALSE},
1982             {"",S_FALSE,FALSE},
1983             {"",S_FALSE,FALSE},
1984             {"www.co.google.us.test",S_OK,FALSE},
1985             {"",S_FALSE,FALSE},
1986             {"/",S_OK,FALSE},
1987             {"/",S_OK,FALSE},
1988             {"",S_FALSE,FALSE},
1989             {"http://www.co.google.us.test",S_OK,FALSE},
1990             {"http",S_OK,FALSE},
1991             {"",S_FALSE,FALSE},
1992             {"",S_FALSE,FALSE}
1993         },
1994         {
1995             {Uri_HOST_DNS,S_OK,FALSE},
1996             {80,S_OK,FALSE},
1997             {URL_SCHEME_HTTP,S_OK,FALSE},
1998             {URLZONE_INVALID,E_NOTIMPL,FALSE}
1999         }
2000     },
2001     {   "http://gov.uk", 0, S_OK, FALSE,
2002         {
2003             {"http://gov.uk/",S_OK,FALSE},
2004             {"gov.uk",S_OK,FALSE},
2005             {"http://gov.uk/",S_OK,FALSE},
2006             {"",S_FALSE,FALSE},
2007             {"",S_FALSE,FALSE},
2008             {"",S_FALSE,FALSE},
2009             {"gov.uk",S_OK,FALSE},
2010             {"",S_FALSE,FALSE},
2011             {"/",S_OK,FALSE},
2012             {"/",S_OK,FALSE},
2013             {"",S_FALSE,FALSE},
2014             {"http://gov.uk",S_OK,FALSE},
2015             {"http",S_OK,FALSE},
2016             {"",S_FALSE,FALSE},
2017             {"",S_FALSE,FALSE}
2018         },
2019         {
2020             {Uri_HOST_DNS,S_OK,FALSE},
2021             {80,S_OK,FALSE},
2022             {URL_SCHEME_HTTP,S_OK,FALSE},
2023             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2024         }
2025     },
2026     {   "zip://www.google.com\\test", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2027         {
2028             {"zip://www.google.com\\test",S_OK,FALSE},
2029             {"www.google.com\\test",S_OK,FALSE},
2030             {"zip://www.google.com\\test",S_OK,FALSE},
2031             {"google.com\\test",S_OK,FALSE},
2032             {"",S_FALSE,FALSE},
2033             {"",S_FALSE,FALSE},
2034             {"www.google.com\\test",S_OK,FALSE},
2035             {"",S_FALSE,FALSE},
2036             {"",S_FALSE,FALSE},
2037             {"",S_FALSE,FALSE},
2038             {"",S_FALSE,FALSE},
2039             {"zip://www.google.com\\test",S_OK,FALSE},
2040             {"zip",S_OK,FALSE},
2041             {"",S_FALSE,FALSE},
2042             {"",S_FALSE,FALSE}
2043         },
2044         {
2045             {Uri_HOST_DNS,S_OK,FALSE},
2046             {0,S_FALSE,FALSE},
2047             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2048             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2049         }
2050     },
2051     {   "urn:excepts:bad:%XY:encoded", 0, S_OK, FALSE,
2052         {
2053             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
2054             {"",S_FALSE,FALSE},
2055             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
2056             {"",S_FALSE,FALSE},
2057             {"",S_FALSE,FALSE},
2058             {"",S_FALSE,FALSE},
2059             {"",S_FALSE,FALSE},
2060             {"",S_FALSE,FALSE},
2061             {"excepts:bad:%XY:encoded",S_OK,FALSE},
2062             {"excepts:bad:%XY:encoded",S_OK,FALSE},
2063             {"",S_FALSE,FALSE},
2064             {"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
2065             {"urn",S_OK,FALSE},
2066             {"",S_FALSE,FALSE},
2067             {"",S_FALSE,FALSE}
2068         },
2069         {
2070             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2071             {0,S_FALSE,FALSE},
2072             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2073             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2074         }
2075     },
2076     /* Since the original URI doesn't contain an extra '/' before the path no % encoded values
2077      * are decoded and all '%' are encoded.
2078      */
2079     {   "file://C:/te%3Es%2Et/tes%t.mp3", 0, S_OK, FALSE,
2080         {
2081             {"file:///C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2082             {"",S_FALSE,FALSE},
2083             {"file:///C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2084             {"",S_FALSE,FALSE},
2085             {".mp3",S_OK,FALSE},
2086             {"",S_FALSE,FALSE},
2087             {"",S_FALSE,FALSE},
2088             {"",S_FALSE,FALSE},
2089             {"/C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2090             {"/C:/te%253Es%252Et/tes%25t.mp3",S_OK,FALSE},
2091             {"",S_FALSE,FALSE},
2092             {"file://C:/te%3Es%2Et/tes%t.mp3",S_OK,FALSE},
2093             {"file",S_OK,FALSE},
2094             {"",S_FALSE,FALSE},
2095             {"",S_FALSE,FALSE}
2096         },
2097         {
2098             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2099             {0,S_FALSE,FALSE},
2100             {URL_SCHEME_FILE,S_OK,FALSE},
2101             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2102         }
2103     },
2104     /* Since there's a '/' in front of the drive letter, any percent encoded, non-forbidden character
2105      * is decoded and only %'s in front of invalid hex digits are encoded.
2106      */
2107     {   "file:///C:/te%3Es%2Et/t%23es%t.mp3", 0, S_OK, FALSE,
2108         {
2109             {"file:///C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2110             {"",S_FALSE,FALSE},
2111             {"file:///C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2112             {"",S_FALSE,FALSE},
2113             {".mp3",S_OK,FALSE},
2114             {"",S_FALSE,FALSE},
2115             {"",S_FALSE,FALSE},
2116             {"",S_FALSE,FALSE},
2117             {"/C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2118             {"/C:/te%3Es.t/t#es%25t.mp3",S_OK,FALSE},
2119             {"",S_FALSE,FALSE},
2120             {"file:///C:/te%3Es%2Et/t%23es%t.mp3",S_OK,FALSE},
2121             {"file",S_OK,FALSE},
2122             {"",S_FALSE,FALSE},
2123             {"",S_FALSE,FALSE}
2124         },
2125         {
2126             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2127             {0,S_FALSE,FALSE},
2128             {URL_SCHEME_FILE,S_OK,FALSE},
2129             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2130         }
2131     },
2132     /* Only unreserved percent encoded characters are decoded for known schemes that aren't file. */
2133     {   "http://[::001.002.003.000]/%3F%23%2E%54/test", 0, S_OK, FALSE,
2134         {
2135             {"http://[::1.2.3.0]/%3F%23.T/test",S_OK,FALSE},
2136             {"[::1.2.3.0]",S_OK,FALSE},
2137             {"http://[::1.2.3.0]/%3F%23.T/test",S_OK,FALSE},
2138             {"",S_FALSE,FALSE},
2139             {"",S_FALSE,FALSE},
2140             {"",S_FALSE,FALSE},
2141             {"::1.2.3.0",S_OK,FALSE},
2142             {"",S_FALSE,FALSE},
2143             {"/%3F%23.T/test",S_OK,FALSE},
2144             {"/%3F%23.T/test",S_OK,FALSE},
2145             {"",S_FALSE,FALSE},
2146             {"http://[::001.002.003.000]/%3F%23%2E%54/test",S_OK,FALSE},
2147             {"http",S_OK,FALSE},
2148             {"",S_FALSE,FALSE},
2149             {"",S_FALSE,FALSE},
2150         },
2151         {
2152             {Uri_HOST_IPV6,S_OK,FALSE},
2153             {80,S_OK,FALSE},
2154             {URL_SCHEME_HTTP,S_OK,FALSE},
2155             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2156         }
2157     },
2158     /* Forbidden characters are always encoded for file URIs. */
2159     {   "file:///C:/\"test\"/test.mp3", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2160         {
2161             {"file:///C:/%22test%22/test.mp3",S_OK,FALSE},
2162             {"",S_FALSE,FALSE},
2163             {"file:///C:/%22test%22/test.mp3",S_OK,FALSE},
2164             {"",S_FALSE,FALSE},
2165             {".mp3",S_OK,FALSE},
2166             {"",S_FALSE,FALSE},
2167             {"",S_FALSE,FALSE},
2168             {"",S_FALSE,FALSE},
2169             {"/C:/%22test%22/test.mp3",S_OK,FALSE},
2170             {"/C:/%22test%22/test.mp3",S_OK,FALSE},
2171             {"",S_FALSE,FALSE},
2172             {"file:///C:/\"test\"/test.mp3",S_OK,FALSE},
2173             {"file",S_OK,FALSE},
2174             {"",S_FALSE,FALSE},
2175             {"",S_FALSE,FALSE}
2176         },
2177         {
2178             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2179             {0,S_FALSE,FALSE},
2180             {URL_SCHEME_FILE,S_OK,FALSE},
2181             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2182         }
2183     },
2184     /* Forbidden characters are never encoded for unknown scheme types. */
2185     {   "1234://4294967295/<|>\" test<|>", 0, S_OK, FALSE,
2186         {
2187             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2188             {"4294967295",S_OK,FALSE},
2189             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2190             {"",S_FALSE,FALSE},
2191             {"",S_FALSE,FALSE},
2192             {"",S_FALSE,FALSE},
2193             {"4294967295",S_OK,FALSE},
2194             {"",S_FALSE,FALSE},
2195             {"/<|>\" test<|>",S_OK,FALSE},
2196             {"/<|>\" test<|>",S_OK,FALSE},
2197             {"",S_FALSE,FALSE},
2198             {"1234://4294967295/<|>\" test<|>",S_OK,FALSE},
2199             {"1234",S_OK,FALSE},
2200             {"",S_FALSE,FALSE},
2201             {"",S_FALSE,FALSE}
2202         },
2203         {
2204             {Uri_HOST_IPV4,S_OK,FALSE},
2205             {0,S_FALSE,FALSE},
2206             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2207             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2208         }
2209     },
2210     /* Make sure forbidden characters are percent encoded. */
2211     {   "http://gov.uk/<|> test<|>", 0, S_OK, FALSE,
2212         {
2213             {"http://gov.uk/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2214             {"gov.uk",S_OK,FALSE},
2215             {"http://gov.uk/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2216             {"",S_FALSE,FALSE},
2217             {"",S_FALSE,FALSE},
2218             {"",S_FALSE,FALSE},
2219             {"gov.uk",S_OK,FALSE},
2220             {"",S_FALSE,FALSE},
2221             {"/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2222             {"/%3C%7C%3E%20test%3C%7C%3E",S_OK,FALSE},
2223             {"",S_FALSE,FALSE},
2224             {"http://gov.uk/<|> test<|>",S_OK,FALSE},
2225             {"http",S_OK,FALSE},
2226             {"",S_FALSE,FALSE},
2227             {"",S_FALSE,FALSE}
2228         },
2229         {
2230             {Uri_HOST_DNS,S_OK,FALSE},
2231             {80,S_OK,FALSE},
2232             {URL_SCHEME_HTTP,S_OK,FALSE},
2233             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2234         }
2235     },
2236     {   "http://gov.uk/test/../test2/././../test3/.././././", 0, S_OK, FALSE,
2237         {
2238             {"http://gov.uk/",S_OK,FALSE},
2239             {"gov.uk",S_OK,FALSE},
2240             {"http://gov.uk/",S_OK,FALSE},
2241             {"",S_FALSE,FALSE},
2242             {"",S_FALSE,FALSE},
2243             {"",S_FALSE,FALSE},
2244             {"gov.uk",S_OK,FALSE},
2245             {"",S_FALSE,FALSE},
2246             {"/",S_OK,FALSE},
2247             {"/",S_OK,FALSE},
2248             {"",S_FALSE,FALSE},
2249             {"http://gov.uk/test/../test2/././../test3/.././././",S_OK,FALSE},
2250             {"http",S_OK,FALSE},
2251             {"",S_FALSE,FALSE},
2252             {"",S_FALSE,FALSE}
2253         },
2254         {
2255             {Uri_HOST_DNS,S_OK,FALSE},
2256             {80,S_OK,FALSE},
2257             {URL_SCHEME_HTTP,S_OK,FALSE},
2258             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2259         }
2260     },
2261     {   "http://gov.uk/test/test2/../../..", 0, S_OK, FALSE,
2262         {
2263             {"http://gov.uk/",S_OK,FALSE},
2264             {"gov.uk",S_OK,FALSE},
2265             {"http://gov.uk/",S_OK,FALSE},
2266             {"",S_FALSE,FALSE},
2267             {"",S_FALSE,FALSE},
2268             {"",S_FALSE,FALSE},
2269             {"gov.uk",S_OK,FALSE},
2270             {"",S_FALSE,FALSE},
2271             {"/",S_OK,FALSE},
2272             {"/",S_OK,FALSE},
2273             {"",S_FALSE,FALSE},
2274             {"http://gov.uk/test/test2/../../..",S_OK,FALSE},
2275             {"http",S_OK,FALSE},
2276             {"",S_FALSE,FALSE},
2277             {"",S_FALSE,FALSE}
2278         },
2279         {
2280             {Uri_HOST_DNS,S_OK,FALSE},
2281             {80,S_OK,FALSE},
2282             {URL_SCHEME_HTTP,S_OK,FALSE},
2283             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2284         }
2285     },
2286     {   "http://gov.uk/test/test2/../../.", 0, S_OK, FALSE,
2287         {
2288             {"http://gov.uk/",S_OK,FALSE},
2289             {"gov.uk",S_OK,FALSE},
2290             {"http://gov.uk/",S_OK,FALSE},
2291             {"",S_FALSE,FALSE},
2292             {"",S_FALSE,FALSE},
2293             {"",S_FALSE,FALSE},
2294             {"gov.uk",S_OK,FALSE},
2295             {"",S_FALSE,FALSE},
2296             {"/",S_OK,FALSE},
2297             {"/",S_OK,FALSE},
2298             {"",S_FALSE,FALSE},
2299             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2300             {"http",S_OK,FALSE},
2301             {"",S_FALSE,FALSE},
2302             {"",S_FALSE,FALSE}
2303         },
2304         {
2305             {Uri_HOST_DNS,S_OK,FALSE},
2306             {80,S_OK,FALSE},
2307             {URL_SCHEME_HTTP,S_OK,FALSE},
2308             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2309         }
2310     },
2311     {   "file://c:\\tests\\../tests\\./.\\..\\foo%20bar.mp3", 0, S_OK, FALSE,
2312         {
2313             {"file:///c:/foo%2520bar.mp3",S_OK,FALSE},
2314             {"",S_FALSE,FALSE},
2315             {"file:///c:/foo%2520bar.mp3",S_OK,FALSE},
2316             {"",S_FALSE,FALSE},
2317             {".mp3",S_OK,FALSE},
2318             {"",S_FALSE,FALSE},
2319             {"",S_FALSE,FALSE},
2320             {"",S_FALSE,FALSE},
2321             {"/c:/foo%2520bar.mp3",S_OK,FALSE},
2322             {"/c:/foo%2520bar.mp3",S_OK,FALSE},
2323             {"",S_FALSE,FALSE},
2324             {"file://c:\\tests\\../tests\\./.\\..\\foo%20bar.mp3",S_OK,FALSE},
2325             {"file",S_OK,FALSE},
2326             {"",S_FALSE,FALSE},
2327             {"",S_FALSE,FALSE}
2328         },
2329         {
2330             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2331             {0,S_FALSE,FALSE},
2332             {URL_SCHEME_FILE,S_OK,FALSE},
2333             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2334         }
2335     },
2336     /* Dot removal happens for unknown scheme types. */
2337     {   "zip://gov.uk/test/test2/../../.", 0, S_OK, FALSE,
2338         {
2339             {"zip://gov.uk/",S_OK,FALSE},
2340             {"gov.uk",S_OK,FALSE},
2341             {"zip://gov.uk/",S_OK,FALSE},
2342             {"",S_FALSE,FALSE},
2343             {"",S_FALSE,FALSE},
2344             {"",S_FALSE,FALSE},
2345             {"gov.uk",S_OK,FALSE},
2346             {"",S_FALSE,FALSE},
2347             {"/",S_OK,FALSE},
2348             {"/",S_OK,FALSE},
2349             {"",S_FALSE,FALSE},
2350             {"zip://gov.uk/test/test2/../../.",S_OK,FALSE},
2351             {"zip",S_OK,FALSE},
2352             {"",S_FALSE,FALSE},
2353             {"",S_FALSE,FALSE}
2354         },
2355         {
2356             {Uri_HOST_DNS,S_OK,FALSE},
2357             {0,S_FALSE,FALSE},
2358             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2359             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2360         }
2361     },
2362     /* Dot removal doesn't happen if NO_CANONICALIZE is set. */
2363     {   "http://gov.uk/test/test2/../../.", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2364         {
2365             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2366             {"gov.uk",S_OK,FALSE},
2367             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2368             {"",S_FALSE,FALSE},
2369             {".",S_OK,FALSE},
2370             {"",S_FALSE,FALSE},
2371             {"gov.uk",S_OK,FALSE},
2372             {"",S_FALSE,FALSE},
2373             {"/test/test2/../../.",S_OK,FALSE},
2374             {"/test/test2/../../.",S_OK,FALSE},
2375             {"",S_FALSE,FALSE},
2376             {"http://gov.uk/test/test2/../../.",S_OK,FALSE},
2377             {"http",S_OK,FALSE},
2378             {"",S_FALSE,FALSE},
2379             {"",S_FALSE,FALSE}
2380         },
2381         {
2382             {Uri_HOST_DNS,S_OK,FALSE},
2383             {80,S_OK,FALSE},
2384             {URL_SCHEME_HTTP,S_OK,FALSE},
2385             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2386         }
2387     },
2388     /* Dot removal doesn't happen for wildcard scheme types. */
2389     {   "*:gov.uk/test/test2/../../.", 0, S_OK, FALSE,
2390         {
2391             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2392             {"gov.uk",S_OK,FALSE},
2393             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2394             {"",S_FALSE,FALSE},
2395             {".",S_OK,FALSE},
2396             {"",S_FALSE,FALSE},
2397             {"gov.uk",S_OK,FALSE},
2398             {"",S_FALSE,FALSE},
2399             {"/test/test2/../../.",S_OK,FALSE},
2400             {"/test/test2/../../.",S_OK,FALSE},
2401             {"",S_FALSE,FALSE},
2402             {"*:gov.uk/test/test2/../../.",S_OK,FALSE},
2403             {"*",S_OK,FALSE},
2404             {"",S_FALSE,FALSE},
2405             {"",S_FALSE,FALSE}
2406         },
2407         {
2408             {Uri_HOST_DNS,S_OK,FALSE},
2409             {0,S_FALSE,FALSE},
2410             {URL_SCHEME_WILDCARD,S_OK,FALSE},
2411             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2412         }
2413     },
2414     /* Forbidden characters are encoded for opaque known scheme types. */
2415     {   "mailto:\"acco<|>unt@example.com\"", 0, S_OK, FALSE,
2416         {
2417             {"mailto:%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2418             {"",S_FALSE,FALSE},
2419             {"mailto:%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2420             {"",S_FALSE,FALSE},
2421             {".com%22",S_OK,FALSE},
2422             {"",S_FALSE,FALSE},
2423             {"",S_FALSE,FALSE},
2424             {"",S_FALSE,FALSE},
2425             {"%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2426             {"%22acco%3C%7C%3Eunt@example.com%22",S_OK,FALSE},
2427             {"",S_FALSE,FALSE},
2428             {"mailto:\"acco<|>unt@example.com\"",S_OK,FALSE},
2429             {"mailto",S_OK,FALSE},
2430             {"",S_FALSE,FALSE},
2431             {"",S_FALSE,FALSE}
2432         },
2433         {
2434             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2435             {0,S_FALSE,FALSE},
2436             {URL_SCHEME_MAILTO,S_OK,FALSE},
2437             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2438         }
2439     },
2440     {   "news:test.tes<|>t.com", 0, S_OK, FALSE,
2441         {
2442             {"news:test.tes%3C%7C%3Et.com",S_OK,FALSE},
2443             {"",S_FALSE,FALSE},
2444             {"news:test.tes%3C%7C%3Et.com",S_OK,FALSE},
2445             {"",S_FALSE,FALSE},
2446             {".com",S_OK,FALSE},
2447             {"",S_FALSE,FALSE},
2448             {"",S_FALSE,FALSE},
2449             {"",S_FALSE,FALSE},
2450             {"test.tes%3C%7C%3Et.com",S_OK,FALSE},
2451             {"test.tes%3C%7C%3Et.com",S_OK,FALSE},
2452             {"",S_FALSE,FALSE},
2453             {"news:test.tes<|>t.com",S_OK,FALSE},
2454             {"news",S_OK,FALSE},
2455             {"",S_FALSE,FALSE},
2456             {"",S_FALSE,FALSE}
2457         },
2458         {
2459             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2460             {0,S_FALSE,FALSE},
2461             {URL_SCHEME_NEWS,S_OK,FALSE},
2462             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2463         }
2464     },
2465     /* Don't encode forbidden characters. */
2466     {   "news:test.tes<|>t.com", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2467         {
2468             {"news:test.tes<|>t.com",S_OK,FALSE},
2469             {"",S_FALSE,FALSE},
2470             {"news:test.tes<|>t.com",S_OK,FALSE},
2471             {"",S_FALSE,FALSE},
2472             {".com",S_OK,FALSE},
2473             {"",S_FALSE,FALSE},
2474             {"",S_FALSE,FALSE},
2475             {"",S_FALSE,FALSE},
2476             {"test.tes<|>t.com",S_OK,FALSE},
2477             {"test.tes<|>t.com",S_OK,FALSE},
2478             {"",S_FALSE,FALSE},
2479             {"news:test.tes<|>t.com",S_OK,FALSE},
2480             {"news",S_OK,FALSE},
2481             {"",S_FALSE,FALSE},
2482             {"",S_FALSE,FALSE}
2483         },
2484         {
2485             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2486             {0,S_FALSE,FALSE},
2487             {URL_SCHEME_NEWS,S_OK,FALSE},
2488             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2489         }
2490     },
2491     /* Forbidden characters aren't encoded for unknown, opaque URIs. */
2492     {   "urn:test.tes<|>t.com", 0, S_OK, FALSE,
2493         {
2494             {"urn:test.tes<|>t.com",S_OK,FALSE},
2495             {"",S_FALSE,FALSE},
2496             {"urn:test.tes<|>t.com",S_OK,FALSE},
2497             {"",S_FALSE,FALSE},
2498             {".com",S_OK,FALSE},
2499             {"",S_FALSE,FALSE},
2500             {"",S_FALSE,FALSE},
2501             {"",S_FALSE,FALSE},
2502             {"test.tes<|>t.com",S_OK,FALSE},
2503             {"test.tes<|>t.com",S_OK,FALSE},
2504             {"",S_FALSE,FALSE},
2505             {"urn:test.tes<|>t.com",S_OK,FALSE},
2506             {"urn",S_OK,FALSE},
2507             {"",S_FALSE,FALSE},
2508             {"",S_FALSE,FALSE}
2509         },
2510         {
2511             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2512             {0,S_FALSE,FALSE},
2513             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2514             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2515         }
2516     },
2517     /* Percent encoded unreserved characters are decoded for known opaque URIs. */
2518     {   "news:test.%74%65%73%74.com", 0, S_OK, FALSE,
2519         {
2520             {"news:test.test.com",S_OK,FALSE},
2521             {"",S_FALSE,FALSE},
2522             {"news:test.test.com",S_OK,FALSE},
2523             {"",S_FALSE,FALSE},
2524             {".com",S_OK,FALSE},
2525             {"",S_FALSE,FALSE},
2526             {"",S_FALSE,FALSE},
2527             {"",S_FALSE,FALSE},
2528             {"test.test.com",S_OK,FALSE},
2529             {"test.test.com",S_OK,FALSE},
2530             {"",S_FALSE,FALSE},
2531             {"news:test.%74%65%73%74.com",S_OK,FALSE},
2532             {"news",S_OK,FALSE},
2533             {"",S_FALSE,FALSE},
2534             {"",S_FALSE,FALSE}
2535         },
2536         {
2537             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2538             {0,S_FALSE,FALSE},
2539             {URL_SCHEME_NEWS,S_OK,FALSE},
2540             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2541         }
2542     },
2543     /* Percent encoded characters are still decoded for known scheme types. */
2544     {   "news:test.%74%65%73%74.com", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2545         {
2546             {"news:test.test.com",S_OK,FALSE},
2547             {"",S_FALSE,FALSE},
2548             {"news:test.test.com",S_OK,FALSE},
2549             {"",S_FALSE,FALSE},
2550             {".com",S_OK,FALSE},
2551             {"",S_FALSE,FALSE},
2552             {"",S_FALSE,FALSE},
2553             {"",S_FALSE,FALSE},
2554             {"test.test.com",S_OK,FALSE},
2555             {"test.test.com",S_OK,FALSE},
2556             {"",S_FALSE,FALSE},
2557             {"news:test.%74%65%73%74.com",S_OK,FALSE},
2558             {"news",S_OK,FALSE},
2559             {"",S_FALSE,FALSE},
2560             {"",S_FALSE,FALSE}
2561         },
2562         {
2563             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2564             {0,S_FALSE,FALSE},
2565             {URL_SCHEME_NEWS,S_OK,FALSE},
2566             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2567         }
2568     },
2569     /* Percent encoded characters aren't decoded for unknown scheme types. */
2570     {   "urn:test.%74%65%73%74.com", 0, S_OK, FALSE,
2571         {
2572             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2573             {"",S_FALSE,FALSE},
2574             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2575             {"",S_FALSE,FALSE},
2576             {".com",S_OK,FALSE},
2577             {"",S_FALSE,FALSE},
2578             {"",S_FALSE,FALSE},
2579             {"",S_FALSE,FALSE},
2580             {"test.%74%65%73%74.com",S_OK,FALSE},
2581             {"test.%74%65%73%74.com",S_OK,FALSE},
2582             {"",S_FALSE,FALSE},
2583             {"urn:test.%74%65%73%74.com",S_OK,FALSE},
2584             {"urn",S_OK,FALSE},
2585             {"",S_FALSE,FALSE},
2586             {"",S_FALSE,FALSE}
2587         },
2588         {
2589             {Uri_HOST_UNKNOWN,S_OK,FALSE},
2590             {0,S_FALSE,FALSE},
2591             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2592             {URLZONE_INVALID,E_NOTIMPL,FALSE}
2593         }
2594     },
2595     /* Unknown scheme types can have invalid % encoded data in query string. */
2596     {   "zip://www.winehq.org/tests/..?query=%xx&return=y", 0, S_OK, FALSE,
2597         {
2598             {"zip://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2599             {"www.winehq.org",S_OK,FALSE},
2600             {"zip://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2601             {"winehq.org",S_OK,FALSE},
2602             {"",S_FALSE,FALSE},
2603             {"",S_FALSE,FALSE},
2604             {"www.winehq.org",S_OK,FALSE},
2605             {"",S_FALSE,FALSE},
2606             {"/",S_OK,FALSE},
2607             {"/?query=%xx&return=y",S_OK,FALSE},
2608             {"?query=%xx&return=y",S_OK,FALSE},
2609             {"zip://www.winehq.org/tests/..?query=%xx&return=y",S_OK,FALSE},
2610             {"zip",S_OK,FALSE},
2611             {"",S_FALSE,FALSE},
2612             {"",S_FALSE,FALSE}
2613         },
2614         {
2615             {Uri_HOST_DNS,S_OK,FALSE},
2616             {0,S_FALSE,FALSE},
2617             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2618             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2619         }
2620     },
2621     /* Known scheme types can have invalid % encoded data with the right flags. */
2622     {   "http://www.winehq.org/tests/..?query=%xx&return=y", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2623         {
2624             {"http://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2625             {"www.winehq.org",S_OK,FALSE},
2626             {"http://www.winehq.org/?query=%xx&return=y",S_OK,FALSE},
2627             {"winehq.org",S_OK,FALSE},
2628             {"",S_FALSE,FALSE},
2629             {"",S_FALSE,FALSE},
2630             {"www.winehq.org",S_OK,FALSE},
2631             {"",S_FALSE,FALSE},
2632             {"/",S_OK,FALSE},
2633             {"/?query=%xx&return=y",S_OK,FALSE},
2634             {"?query=%xx&return=y",S_OK,FALSE},
2635             {"http://www.winehq.org/tests/..?query=%xx&return=y",S_OK,FALSE},
2636             {"http",S_OK,FALSE},
2637             {"",S_FALSE,FALSE},
2638             {"",S_FALSE,FALSE}
2639         },
2640         {
2641             {Uri_HOST_DNS,S_OK,FALSE},
2642             {80,S_OK,FALSE},
2643             {URL_SCHEME_HTTP,S_OK,FALSE},
2644             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2645         }
2646     },
2647     /* Forbidden characters in query aren't percent encoded for known scheme types with this flag. */
2648     {   "http://www.winehq.org/tests/..?query=<|>&return=y", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2649         {
2650             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2651             {"www.winehq.org",S_OK,FALSE},
2652             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2653             {"winehq.org",S_OK,FALSE},
2654             {"",S_FALSE,FALSE},
2655             {"",S_FALSE,FALSE},
2656             {"www.winehq.org",S_OK,FALSE},
2657             {"",S_FALSE,FALSE},
2658             {"/",S_OK,FALSE},
2659             {"/?query=<|>&return=y",S_OK,FALSE},
2660             {"?query=<|>&return=y",S_OK,FALSE},
2661             {"http://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2662             {"http",S_OK,FALSE},
2663             {"",S_FALSE,FALSE},
2664             {"",S_FALSE,FALSE}
2665         },
2666         {
2667             {Uri_HOST_DNS,S_OK,FALSE},
2668             {80,S_OK,FALSE},
2669             {URL_SCHEME_HTTP,S_OK,FALSE},
2670             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2671         }
2672     },
2673     /* Forbidden characters in query aren't percent encoded for known scheme types with this flag. */
2674     {   "http://www.winehq.org/tests/..?query=<|>&return=y", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2675         {
2676             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2677             {"www.winehq.org",S_OK,FALSE},
2678             {"http://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2679             {"winehq.org",S_OK,FALSE},
2680             {"",S_FALSE,FALSE},
2681             {"",S_FALSE,FALSE},
2682             {"www.winehq.org",S_OK,FALSE},
2683             {"",S_FALSE,FALSE},
2684             {"/",S_OK,FALSE},
2685             {"/?query=<|>&return=y",S_OK,FALSE},
2686             {"?query=<|>&return=y",S_OK,FALSE},
2687             {"http://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2688             {"http",S_OK,FALSE},
2689             {"",S_FALSE,FALSE},
2690             {"",S_FALSE,FALSE}
2691         },
2692         {
2693             {Uri_HOST_DNS,S_OK,FALSE},
2694             {80,S_OK,FALSE},
2695             {URL_SCHEME_HTTP,S_OK,FALSE},
2696             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2697         }
2698     },
2699     /* Forbidden characters are encoded for known scheme types. */
2700     {   "http://www.winehq.org/tests/..?query=<|>&return=y", 0, S_OK, FALSE,
2701         {
2702             {"http://www.winehq.org/?query=%3C%7C%3E&return=y",S_OK,FALSE},
2703             {"www.winehq.org",S_OK,FALSE},
2704             {"http://www.winehq.org/?query=%3C%7C%3E&return=y",S_OK,FALSE},
2705             {"winehq.org",S_OK,FALSE},
2706             {"",S_FALSE,FALSE},
2707             {"",S_FALSE,FALSE},
2708             {"www.winehq.org",S_OK,FALSE},
2709             {"",S_FALSE,FALSE},
2710             {"/",S_OK,FALSE},
2711             {"/?query=%3C%7C%3E&return=y",S_OK,FALSE},
2712             {"?query=%3C%7C%3E&return=y",S_OK,FALSE},
2713             {"http://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2714             {"http",S_OK,FALSE},
2715             {"",S_FALSE,FALSE},
2716             {"",S_FALSE,FALSE}
2717         },
2718         {
2719             {Uri_HOST_DNS,S_OK,FALSE},
2720             {80,S_OK,FALSE},
2721             {URL_SCHEME_HTTP,S_OK,FALSE},
2722             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2723         }
2724     },
2725     /* Forbidden characters are not encoded for unknown scheme types. */
2726     {   "zip://www.winehq.org/tests/..?query=<|>&return=y", 0, S_OK, FALSE,
2727         {
2728             {"zip://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2729             {"www.winehq.org",S_OK,FALSE},
2730             {"zip://www.winehq.org/?query=<|>&return=y",S_OK,FALSE},
2731             {"winehq.org",S_OK,FALSE},
2732             {"",S_FALSE,FALSE},
2733             {"",S_FALSE,FALSE},
2734             {"www.winehq.org",S_OK,FALSE},
2735             {"",S_FALSE,FALSE},
2736             {"/",S_OK,FALSE},
2737             {"/?query=<|>&return=y",S_OK,FALSE},
2738             {"?query=<|>&return=y",S_OK,FALSE},
2739             {"zip://www.winehq.org/tests/..?query=<|>&return=y",S_OK,FALSE},
2740             {"zip",S_OK,FALSE},
2741             {"",S_FALSE,FALSE},
2742             {"",S_FALSE,FALSE}
2743         },
2744         {
2745             {Uri_HOST_DNS,S_OK,FALSE},
2746             {0,S_FALSE,FALSE},
2747             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2748             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2749         }
2750     },
2751     /* Percent encoded, unreserved characters are decoded for known scheme types. */
2752     {   "http://www.winehq.org/tests/..?query=%30%31&return=y", 0, S_OK, FALSE,
2753         {
2754             {"http://www.winehq.org/?query=01&return=y",S_OK,FALSE},
2755             {"www.winehq.org",S_OK,FALSE},
2756             {"http://www.winehq.org/?query=01&return=y",S_OK,FALSE},
2757             {"winehq.org",S_OK,FALSE},
2758             {"",S_FALSE,FALSE},
2759             {"",S_FALSE,FALSE},
2760             {"www.winehq.org",S_OK,FALSE},
2761             {"",S_FALSE,FALSE},
2762             {"/",S_OK,FALSE},
2763             {"/?query=01&return=y",S_OK,FALSE},
2764             {"?query=01&return=y",S_OK,FALSE},
2765             {"http://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2766             {"http",S_OK,FALSE},
2767             {"",S_FALSE,FALSE},
2768             {"",S_FALSE,FALSE}
2769         },
2770         {
2771             {Uri_HOST_DNS,S_OK,FALSE},
2772             {80,S_OK,FALSE},
2773             {URL_SCHEME_HTTP,S_OK,FALSE},
2774             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2775         }
2776     },
2777     /* Percent encoded, unreserved characters aren't decoded for unknown scheme types. */
2778     {   "zip://www.winehq.org/tests/..?query=%30%31&return=y", 0, S_OK, FALSE,
2779         {
2780             {"zip://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2781             {"www.winehq.org",S_OK,FALSE},
2782             {"zip://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2783             {"winehq.org",S_OK,FALSE},
2784             {"",S_FALSE,FALSE},
2785             {"",S_FALSE,FALSE},
2786             {"www.winehq.org",S_OK,FALSE},
2787             {"",S_FALSE,FALSE},
2788             {"/",S_OK,FALSE},
2789             {"/?query=%30%31&return=y",S_OK,FALSE},
2790             {"?query=%30%31&return=y",S_OK,FALSE},
2791             {"zip://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2792             {"zip",S_OK,FALSE},
2793             {"",S_FALSE,FALSE},
2794             {"",S_FALSE,FALSE}
2795         },
2796         {
2797             {Uri_HOST_DNS,S_OK,FALSE},
2798             {0,S_FALSE,FALSE},
2799             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2800             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2801         }
2802     },
2803     /* Percent encoded characters aren't decoded when NO_DECODE_EXTRA_INFO is set. */
2804     {   "http://www.winehq.org/tests/..?query=%30%31&return=y", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2805         {
2806             {"http://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2807             {"www.winehq.org",S_OK,FALSE},
2808             {"http://www.winehq.org/?query=%30%31&return=y",S_OK,FALSE},
2809             {"winehq.org",S_OK,FALSE},
2810             {"",S_FALSE,FALSE},
2811             {"",S_FALSE,FALSE},
2812             {"www.winehq.org",S_OK,FALSE},
2813             {"",S_FALSE,FALSE},
2814             {"/",S_OK,FALSE},
2815             {"/?query=%30%31&return=y",S_OK,FALSE},
2816             {"?query=%30%31&return=y",S_OK,FALSE},
2817             {"http://www.winehq.org/tests/..?query=%30%31&return=y",S_OK,FALSE},
2818             {"http",S_OK,FALSE},
2819             {"",S_FALSE,FALSE},
2820             {"",S_FALSE,FALSE}
2821         },
2822         {
2823             {Uri_HOST_DNS,S_OK,FALSE},
2824             {80,S_OK,FALSE},
2825             {URL_SCHEME_HTTP,S_OK,FALSE},
2826             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2827         }
2828     },
2829     {   "http://www.winehq.org?query=12&return=y", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
2830         {
2831             {"http://www.winehq.org?query=12&return=y",S_OK,FALSE},
2832             {"www.winehq.org",S_OK,FALSE},
2833             {"http://www.winehq.org?query=12&return=y",S_OK,FALSE},
2834             {"winehq.org",S_OK,FALSE},
2835             {"",S_FALSE,FALSE},
2836             {"",S_FALSE,FALSE},
2837             {"www.winehq.org",S_OK,FALSE},
2838             {"",S_FALSE,FALSE},
2839             {"",S_FALSE,FALSE},
2840             {"?query=12&return=y",S_OK,FALSE},
2841             {"?query=12&return=y",S_OK,FALSE},
2842             {"http://www.winehq.org?query=12&return=y",S_OK,FALSE},
2843             {"http",S_OK,FALSE},
2844             {"",S_FALSE,FALSE},
2845             {"",S_FALSE,FALSE}
2846         },
2847         {
2848             {Uri_HOST_DNS,S_OK,FALSE},
2849             {80,S_OK,FALSE},
2850             {URL_SCHEME_HTTP,S_OK,FALSE},
2851             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2852         }
2853     },
2854     /* Unknown scheme types can have invalid % encoded data in fragments. */
2855     {   "zip://www.winehq.org/tests/#Te%xx", 0, S_OK, FALSE,
2856         {
2857             {"zip://www.winehq.org/tests/#Te%xx",S_OK,FALSE},
2858             {"www.winehq.org",S_OK,FALSE},
2859             {"zip://www.winehq.org/tests/#Te%xx",S_OK,FALSE},
2860             {"winehq.org",S_OK,FALSE},
2861             {"",S_FALSE,FALSE},
2862             {"#Te%xx",S_OK,FALSE},
2863             {"www.winehq.org",S_OK,FALSE},
2864             {"",S_FALSE,FALSE},
2865             {"/tests/",S_OK,FALSE},
2866             {"/tests/",S_OK,FALSE},
2867             {"",S_FALSE,FALSE},
2868             {"zip://www.winehq.org/tests/#Te%xx",S_OK,FALSE},
2869             {"zip",S_OK,FALSE},
2870             {"",S_FALSE,FALSE},
2871             {"",S_FALSE,FALSE}
2872         },
2873         {
2874             {Uri_HOST_DNS,S_OK,FALSE},
2875             {0,S_FALSE,FALSE},
2876             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2877             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2878         }
2879     },
2880     /* Forbidden characters in fragment aren't encoded for unknown schemes. */
2881     {   "zip://www.winehq.org/tests/#Te<|>", 0, S_OK, FALSE,
2882         {
2883             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2884             {"www.winehq.org",S_OK,FALSE},
2885             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2886             {"winehq.org",S_OK,FALSE},
2887             {"",S_FALSE,FALSE},
2888             {"#Te<|>",S_OK,FALSE},
2889             {"www.winehq.org",S_OK,FALSE},
2890             {"",S_FALSE,FALSE},
2891             {"/tests/",S_OK,FALSE},
2892             {"/tests/",S_OK,FALSE},
2893             {"",S_FALSE,FALSE},
2894             {"zip://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2895             {"zip",S_OK,FALSE},
2896             {"",S_FALSE,FALSE},
2897             {"",S_FALSE,FALSE}
2898         },
2899         {
2900             {Uri_HOST_DNS,S_OK,FALSE},
2901             {0,S_FALSE,FALSE},
2902             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
2903             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2904         }
2905     },
2906     /* Forbidden characters in the fragment are percent encoded for known schemes. */
2907     {   "http://www.winehq.org/tests/#Te<|>", 0, S_OK, FALSE,
2908         {
2909             {"http://www.winehq.org/tests/#Te%3C%7C%3E",S_OK,FALSE},
2910             {"www.winehq.org",S_OK,FALSE},
2911             {"http://www.winehq.org/tests/#Te%3C%7C%3E",S_OK,FALSE},
2912             {"winehq.org",S_OK,FALSE},
2913             {"",S_FALSE,FALSE},
2914             {"#Te%3C%7C%3E",S_OK,FALSE},
2915             {"www.winehq.org",S_OK,FALSE},
2916             {"",S_FALSE,FALSE},
2917             {"/tests/",S_OK,FALSE},
2918             {"/tests/",S_OK,FALSE},
2919             {"",S_FALSE,FALSE},
2920             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2921             {"http",S_OK,FALSE},
2922             {"",S_FALSE,FALSE},
2923             {"",S_FALSE,FALSE}
2924         },
2925         {
2926             {Uri_HOST_DNS,S_OK,FALSE},
2927             {80,S_OK,FALSE},
2928             {URL_SCHEME_HTTP,S_OK,FALSE},
2929             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2930         }
2931     },
2932     /* Forbidden characters aren't encoded in the fragment with this flag. */
2933     {   "http://www.winehq.org/tests/#Te<|>", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
2934         {
2935             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2936             {"www.winehq.org",S_OK,FALSE},
2937             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2938             {"winehq.org",S_OK,FALSE},
2939             {"",S_FALSE,FALSE},
2940             {"#Te<|>",S_OK,FALSE},
2941             {"www.winehq.org",S_OK,FALSE},
2942             {"",S_FALSE,FALSE},
2943             {"/tests/",S_OK,FALSE},
2944             {"/tests/",S_OK,FALSE},
2945             {"",S_FALSE,FALSE},
2946             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2947             {"http",S_OK,FALSE},
2948             {"",S_FALSE,FALSE},
2949             {"",S_FALSE,FALSE}
2950         },
2951         {
2952             {Uri_HOST_DNS,S_OK,FALSE},
2953             {80,S_OK,FALSE},
2954             {URL_SCHEME_HTTP,S_OK,FALSE},
2955             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2956         }
2957     },
2958     /* Forbidden characters aren't encoded in the fragment with this flag. */
2959     {   "http://www.winehq.org/tests/#Te<|>", Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS, S_OK, FALSE,
2960         {
2961             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2962             {"www.winehq.org",S_OK,FALSE},
2963             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2964             {"winehq.org",S_OK,FALSE},
2965             {"",S_FALSE,FALSE},
2966             {"#Te<|>",S_OK,FALSE},
2967             {"www.winehq.org",S_OK,FALSE},
2968             {"",S_FALSE,FALSE},
2969             {"/tests/",S_OK,FALSE},
2970             {"/tests/",S_OK,FALSE},
2971             {"",S_FALSE,FALSE},
2972             {"http://www.winehq.org/tests/#Te<|>",S_OK,FALSE},
2973             {"http",S_OK,FALSE},
2974             {"",S_FALSE,FALSE},
2975             {"",S_FALSE,FALSE}
2976         },
2977         {
2978             {Uri_HOST_DNS,S_OK,FALSE},
2979             {80,S_OK,FALSE},
2980             {URL_SCHEME_HTTP,S_OK,FALSE},
2981             {URLZONE_INVALID,E_NOTIMPL,FALSE},
2982         }
2983     },
2984     /* Percent encoded, unreserved characters aren't decoded for known scheme types. */
2985     {   "zip://www.winehq.org/tests/#Te%30%31%32", 0, S_OK, FALSE,
2986         {
2987             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2988             {"www.winehq.org",S_OK,FALSE},
2989             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2990             {"winehq.org",S_OK,FALSE},
2991             {"",S_FALSE,FALSE},
2992             {"#Te%30%31%32",S_OK,FALSE},
2993             {"www.winehq.org",S_OK,FALSE},
2994             {"",S_FALSE,FALSE},
2995             {"/tests/",S_OK,FALSE},
2996             {"/tests/",S_OK,FALSE},
2997             {"",S_FALSE,FALSE},
2998             {"zip://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
2999             {"zip",S_OK,FALSE},
3000             {"",S_FALSE,FALSE},
3001             {"",S_FALSE,FALSE}
3002         },
3003         {
3004             {Uri_HOST_DNS,S_OK,FALSE},
3005             {0,S_FALSE,FALSE},
3006             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3007             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3008         }
3009     },
3010     /* Percent encoded, unreserved characters are decoded for known schemes. */
3011     {   "http://www.winehq.org/tests/#Te%30%31%32", 0, S_OK, FALSE,
3012         {
3013             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
3014             {"www.winehq.org",S_OK,FALSE},
3015             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
3016             {"winehq.org",S_OK,FALSE},
3017             {"",S_FALSE,FALSE},
3018             {"#Te012",S_OK,FALSE},
3019             {"www.winehq.org",S_OK,FALSE},
3020             {"",S_FALSE,FALSE},
3021             {"/tests/",S_OK,FALSE},
3022             {"/tests/",S_OK,FALSE},
3023             {"",S_FALSE,FALSE},
3024             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3025             {"http",S_OK,FALSE},
3026             {"",S_FALSE,FALSE},
3027             {"",S_FALSE,FALSE}
3028         },
3029         {
3030             {Uri_HOST_DNS,S_OK,FALSE},
3031             {80,S_OK,FALSE},
3032             {URL_SCHEME_HTTP,S_OK,FALSE},
3033             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3034         }
3035     },
3036     /* Percent encoded, unreserved characters are decoded even if NO_CANONICALIZE is set. */
3037     {   "http://www.winehq.org/tests/#Te%30%31%32", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
3038         {
3039             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
3040             {"www.winehq.org",S_OK,FALSE},
3041             {"http://www.winehq.org/tests/#Te012",S_OK,FALSE},
3042             {"winehq.org",S_OK,FALSE},
3043             {"",S_FALSE,FALSE},
3044             {"#Te012",S_OK,FALSE},
3045             {"www.winehq.org",S_OK,FALSE},
3046             {"",S_FALSE,FALSE},
3047             {"/tests/",S_OK,FALSE},
3048             {"/tests/",S_OK,FALSE},
3049             {"",S_FALSE,FALSE},
3050             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3051             {"http",S_OK,FALSE},
3052             {"",S_FALSE,FALSE},
3053             {"",S_FALSE,FALSE}
3054         },
3055         {
3056             {Uri_HOST_DNS,S_OK,FALSE},
3057             {80,S_OK,FALSE},
3058             {URL_SCHEME_HTTP,S_OK,FALSE},
3059             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3060         }
3061     },
3062     /* Percent encoded, unreserved characters aren't decoded when NO_DECODE_EXTRA is set. */
3063     {   "http://www.winehq.org/tests/#Te%30%31%32", Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE,
3064         {
3065             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3066             {"www.winehq.org",S_OK,FALSE},
3067             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3068             {"winehq.org",S_OK,FALSE},
3069             {"",S_FALSE,FALSE},
3070             {"#Te%30%31%32",S_OK,FALSE},
3071             {"www.winehq.org",S_OK,FALSE},
3072             {"",S_FALSE,FALSE},
3073             {"/tests/",S_OK,FALSE},
3074             {"/tests/",S_OK,FALSE},
3075             {"",S_FALSE,FALSE},
3076             {"http://www.winehq.org/tests/#Te%30%31%32",S_OK,FALSE},
3077             {"http",S_OK,FALSE},
3078             {"",S_FALSE,FALSE},
3079             {"",S_FALSE,FALSE}
3080         },
3081         {
3082             {Uri_HOST_DNS,S_OK,FALSE},
3083             {80,S_OK,FALSE},
3084             {URL_SCHEME_HTTP,S_OK,FALSE},
3085             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3086         }
3087     },
3088     /* Leading/Trailing whitespace is removed. */
3089     {   "    http://google.com/     ", 0, S_OK, FALSE,
3090         {
3091             {"http://google.com/",S_OK,FALSE},
3092             {"google.com",S_OK,FALSE},
3093             {"http://google.com/",S_OK,FALSE},
3094             {"google.com",S_OK,FALSE},
3095             {"",S_FALSE,FALSE},
3096             {"",S_FALSE,FALSE},
3097             {"google.com",S_OK,FALSE},
3098             {"",S_FALSE,FALSE},
3099             {"/",S_OK,FALSE},
3100             {"/",S_OK,FALSE},
3101             {"",S_FALSE,FALSE},
3102             {"http://google.com/",S_OK,FALSE},
3103             {"http",S_OK,FALSE},
3104             {"",S_FALSE,FALSE},
3105             {"",S_FALSE,FALSE}
3106         },
3107         {
3108             {Uri_HOST_DNS,S_OK,FALSE},
3109             {80,S_OK,FALSE},
3110             {URL_SCHEME_HTTP,S_OK,FALSE},
3111             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3112         }
3113     },
3114     {   "\t\t\r\nhttp\n://g\noogle.co\rm/\n\n\n", 0, S_OK, FALSE,
3115         {
3116             {"http://google.com/",S_OK,FALSE},
3117             {"google.com",S_OK,FALSE},
3118             {"http://google.com/",S_OK,FALSE},
3119             {"google.com",S_OK,FALSE},
3120             {"",S_FALSE,FALSE},
3121             {"",S_FALSE,FALSE},
3122             {"google.com",S_OK,FALSE},
3123             {"",S_FALSE,FALSE},
3124             {"/",S_OK,FALSE},
3125             {"/",S_OK,FALSE},
3126             {"",S_FALSE,FALSE},
3127             {"http://google.com/",S_OK,FALSE},
3128             {"http",S_OK,FALSE},
3129             {"",S_FALSE,FALSE},
3130             {"",S_FALSE,FALSE}
3131         },
3132         {
3133             {Uri_HOST_DNS,S_OK,FALSE},
3134             {80,S_OK,FALSE},
3135             {URL_SCHEME_HTTP,S_OK,FALSE},
3136             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3137         }
3138     },
3139     {   "http://g\noogle.co\rm/\n\n\n", Uri_CREATE_NO_PRE_PROCESS_HTML_URI, S_OK, FALSE,
3140         {
3141             {"http://g%0aoogle.co%0dm/%0A%0A%0A",S_OK,FALSE},
3142             {"g%0aoogle.co%0dm",S_OK,FALSE},
3143             {"http://g%0aoogle.co%0dm/%0A%0A%0A",S_OK,FALSE},
3144             {"g%0aoogle.co%0dm",S_OK,FALSE},
3145             {"",S_FALSE,FALSE},
3146             {"",S_FALSE,FALSE},
3147             {"g%0aoogle.co%0dm",S_OK,FALSE},
3148             {"",S_FALSE,FALSE},
3149             {"/%0A%0A%0A",S_OK,FALSE},
3150             {"/%0A%0A%0A",S_OK,FALSE},
3151             {"",S_FALSE,FALSE},
3152             {"http://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3153             {"http",S_OK,FALSE},
3154             {"",S_FALSE,FALSE},
3155             {"",S_FALSE,FALSE}
3156         },
3157         {
3158             {Uri_HOST_DNS,S_OK,FALSE},
3159             {80,S_OK,FALSE},
3160             {URL_SCHEME_HTTP,S_OK,FALSE},
3161             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3162         }
3163     },
3164     {   "zip://g\noogle.co\rm/\n\n\n", Uri_CREATE_NO_PRE_PROCESS_HTML_URI, S_OK, FALSE,
3165         {
3166             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3167             {"g\noogle.co\rm",S_OK,FALSE},
3168             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3169             {"g\noogle.co\rm",S_OK,FALSE},
3170             {"",S_FALSE,FALSE},
3171             {"",S_FALSE,FALSE},
3172             {"g\noogle.co\rm",S_OK,FALSE},
3173             {"",S_FALSE,FALSE},
3174             {"/\n\n\n",S_OK,FALSE},
3175             {"/\n\n\n",S_OK,FALSE},
3176             {"",S_FALSE,FALSE},
3177             {"zip://g\noogle.co\rm/\n\n\n",S_OK,FALSE},
3178             {"zip",S_OK,FALSE},
3179             {"",S_FALSE,FALSE},
3180             {"",S_FALSE,FALSE}
3181         },
3182         {
3183             {Uri_HOST_DNS,S_OK,FALSE},
3184             {0,S_FALSE,FALSE},
3185             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3186             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3187         }
3188     },
3189     /* Since file URLs are usually hierarchical, it returns an empty string
3190      * for the absolute URI property since it was declared as an opaque URI.
3191      */
3192     {   "file:index.html", 0, S_OK, FALSE,
3193         {
3194             {"",S_FALSE,FALSE},
3195             {"",S_FALSE,FALSE},
3196             {"file:index.html",S_OK,FALSE},
3197             {"",S_FALSE,FALSE},
3198             {".html",S_OK,FALSE},
3199             {"",S_FALSE,FALSE},
3200             {"",S_FALSE,FALSE},
3201             {"",S_FALSE,FALSE},
3202             {"index.html",S_OK,FALSE},
3203             {"index.html",S_OK,FALSE},
3204             {"",S_FALSE,FALSE},
3205             {"file:index.html",S_OK,FALSE},
3206             {"file",S_OK,FALSE},
3207             {"",S_FALSE,FALSE},
3208             {"",S_FALSE,FALSE}
3209         },
3210         {
3211             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3212             {0,S_FALSE,FALSE},
3213             {URL_SCHEME_FILE,S_OK,FALSE},
3214             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3215         }
3216     },
3217     /* Doesn't have an absolute since it's opaque, but gets it port set. */
3218     {   "http:test.com/index.html", 0, S_OK, FALSE,
3219         {
3220             {"",S_FALSE,FALSE},
3221             {"",S_FALSE,FALSE},
3222             {"http:test.com/index.html",S_OK,FALSE},
3223             {"",S_FALSE,FALSE},
3224             {".html",S_OK,FALSE},
3225             {"",S_FALSE,FALSE},
3226             {"",S_FALSE,FALSE},
3227             {"",S_FALSE,FALSE},
3228             {"test.com/index.html",S_OK,FALSE},
3229             {"test.com/index.html",S_OK,FALSE},
3230             {"",S_FALSE,FALSE},
3231             {"http:test.com/index.html",S_OK,FALSE},
3232             {"http",S_OK,FALSE},
3233             {"",S_FALSE,FALSE},
3234             {"",S_FALSE,FALSE}
3235         },
3236         {
3237             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3238             {80,S_OK,FALSE},
3239             {URL_SCHEME_HTTP,S_OK,FALSE},
3240             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3241         }
3242     },
3243     {   "ftp:test.com/index.html", 0, S_OK, FALSE,
3244         {
3245             {"",S_FALSE,FALSE},
3246             {"",S_FALSE,FALSE},
3247             {"ftp:test.com/index.html",S_OK,FALSE},
3248             {"",S_FALSE,FALSE},
3249             {".html",S_OK,FALSE},
3250             {"",S_FALSE,FALSE},
3251             {"",S_FALSE,FALSE},
3252             {"",S_FALSE,FALSE},
3253             {"test.com/index.html",S_OK,FALSE},
3254             {"test.com/index.html",S_OK,FALSE},
3255             {"",S_FALSE,FALSE},
3256             {"ftp:test.com/index.html",S_OK,FALSE},
3257             {"ftp",S_OK,FALSE},
3258             {"",S_FALSE,FALSE},
3259             {"",S_FALSE,FALSE}
3260         },
3261         {
3262             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3263             {21,S_OK,FALSE},
3264             {URL_SCHEME_FTP,S_OK,FALSE},
3265             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3266         }
3267     },
3268     {   "file://C|/test.mp3", 0, S_OK, FALSE,
3269         {
3270             {"file:///C:/test.mp3",S_OK,FALSE},
3271             {"",S_FALSE,FALSE},
3272             {"file:///C:/test.mp3",S_OK,FALSE},
3273             {"",S_FALSE,FALSE},
3274             {".mp3",S_OK,FALSE},
3275             {"",S_FALSE,FALSE},
3276             {"",S_FALSE,FALSE},
3277             {"",S_FALSE,FALSE},
3278             {"/C:/test.mp3",S_OK,FALSE},
3279             {"/C:/test.mp3",S_OK,FALSE},
3280             {"",S_FALSE,FALSE},
3281             {"file://C|/test.mp3",S_OK,FALSE},
3282             {"file",S_OK,FALSE},
3283             {"",S_FALSE,FALSE},
3284             {"",S_FALSE,FALSE}
3285         },
3286         {
3287             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3288             {0,S_FALSE,FALSE},
3289             {URL_SCHEME_FILE,S_OK,FALSE},
3290             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3291         }
3292     },
3293     {   "file:///C|/test.mp3", 0, S_OK, FALSE,
3294         {
3295             {"file:///C:/test.mp3",S_OK,FALSE},
3296             {"",S_FALSE,FALSE},
3297             {"file:///C:/test.mp3",S_OK,FALSE},
3298             {"",S_FALSE,FALSE},
3299             {".mp3",S_OK,FALSE},
3300             {"",S_FALSE,FALSE},
3301             {"",S_FALSE,FALSE},
3302             {"",S_FALSE,FALSE},
3303             {"/C:/test.mp3",S_OK,FALSE},
3304             {"/C:/test.mp3",S_OK,FALSE},
3305             {"",S_FALSE,FALSE},
3306             {"file:///C|/test.mp3",S_OK,FALSE},
3307             {"file",S_OK,FALSE},
3308             {"",S_FALSE,FALSE},
3309             {"",S_FALSE,FALSE}
3310         },
3311         {
3312             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3313             {0,S_FALSE,FALSE},
3314             {URL_SCHEME_FILE,S_OK,FALSE},
3315             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3316         }
3317     },
3318     /* Extra '/' isn't added before "c:" since USE_DOS_PATH is set and '/' are converted
3319      * to '\\'.
3320      */
3321     {   "file://c:/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3322         {
3323             {"file://c:\\dir\\index.html",S_OK,FALSE},
3324             {"",S_FALSE,FALSE},
3325             {"file://c:\\dir\\index.html",S_OK,FALSE},
3326             {"",S_FALSE,FALSE},
3327             {".html",S_OK,FALSE},
3328             {"",S_FALSE,FALSE},
3329             {"",S_FALSE,FALSE},
3330             {"",S_FALSE,FALSE},
3331             {"c:\\dir\\index.html",S_OK,FALSE},
3332             {"c:\\dir\\index.html",S_OK,FALSE},
3333             {"",S_FALSE,FALSE},
3334             {"file://c:/dir/index.html",S_OK,FALSE},
3335             {"file",S_OK,FALSE},
3336             {"",S_FALSE,FALSE},
3337             {"",S_FALSE,FALSE}
3338         },
3339         {
3340             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3341             {0,S_FALSE,FALSE},
3342             {URL_SCHEME_FILE,S_OK,FALSE},
3343             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3344         }
3345     },
3346     /* Extra '/' after "file://" is removed. */
3347     {   "file:///c:/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3348         {
3349             {"file://c:\\dir\\index.html",S_OK,FALSE},
3350             {"",S_FALSE,FALSE},
3351             {"file://c:\\dir\\index.html",S_OK,FALSE},
3352             {"",S_FALSE,FALSE},
3353             {".html",S_OK,FALSE},
3354             {"",S_FALSE,FALSE},
3355             {"",S_FALSE,FALSE},
3356             {"",S_FALSE,FALSE},
3357             {"c:\\dir\\index.html",S_OK,FALSE},
3358             {"c:\\dir\\index.html",S_OK,FALSE},
3359             {"",S_FALSE,FALSE},
3360             {"file:///c:/dir/index.html",S_OK,FALSE},
3361             {"file",S_OK,FALSE},
3362             {"",S_FALSE,FALSE},
3363             {"",S_FALSE,FALSE}
3364         },
3365         {
3366             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3367             {0,S_FALSE,FALSE},
3368             {URL_SCHEME_FILE,S_OK,FALSE},
3369             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3370         }
3371     },
3372     /* Allow more characters when Uri_CREATE_FILE_USE_DOS_PATH is specified */
3373     {   "file:///c:/dir\\%%61%20%5Fname/file%2A.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3374         {
3375             {"file://c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3376             {"",S_FALSE,FALSE},
3377             {"file://c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3378             {"",S_FALSE,FALSE},
3379             {".html",S_OK,FALSE},
3380             {"",S_FALSE,FALSE},
3381             {"",S_FALSE,FALSE},
3382             {"",S_FALSE,FALSE},
3383             {"c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3384             {"c:\\dir\\%a _name\\file*.html",S_OK,FALSE},
3385             {"",S_FALSE,FALSE},
3386             {"file:///c:/dir\\%%61%20%5Fname/file%2A.html",S_OK,FALSE},
3387             {"file",S_OK,FALSE},
3388             {"",S_FALSE,FALSE},
3389             {"",S_FALSE,FALSE}
3390         },
3391         {
3392             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3393             {0,S_FALSE,FALSE},
3394             {URL_SCHEME_FILE,S_OK,FALSE},
3395             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3396         }
3397     },
3398     {   "file://c|/dir\\index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3399         {
3400             {"file://c:\\dir\\index.html",S_OK,FALSE},
3401             {"",S_FALSE,FALSE},
3402             {"file://c:\\dir\\index.html",S_OK,FALSE},
3403             {"",S_FALSE,FALSE},
3404             {".html",S_OK,FALSE},
3405             {"",S_FALSE,FALSE},
3406             {"",S_FALSE,FALSE},
3407             {"",S_FALSE,FALSE},
3408             {"c:\\dir\\index.html",S_OK,FALSE},
3409             {"c:\\dir\\index.html",S_OK,FALSE},
3410             {"",S_FALSE,FALSE},
3411             {"file://c|/dir\\index.html",S_OK,FALSE},
3412             {"file",S_OK,FALSE},
3413             {"",S_FALSE,FALSE},
3414             {"",S_FALSE,FALSE}
3415         },
3416         {
3417             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3418             {0,S_FALSE,FALSE},
3419             {URL_SCHEME_FILE,S_OK,FALSE},
3420             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3421         }
3422     },
3423     /* The backslashes after the scheme name are converted to forward slashes. */
3424     {   "file:\\\\c:\\dir\\index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3425         {
3426             {"file://c:\\dir\\index.html",S_OK,FALSE},
3427             {"",S_FALSE,FALSE},
3428             {"file://c:\\dir\\index.html",S_OK,FALSE},
3429             {"",S_FALSE,FALSE},
3430             {".html",S_OK,FALSE},
3431             {"",S_FALSE,FALSE},
3432             {"",S_FALSE,FALSE},
3433             {"",S_FALSE,FALSE},
3434             {"c:\\dir\\index.html",S_OK,FALSE},
3435             {"c:\\dir\\index.html",S_OK,FALSE},
3436             {"",S_FALSE,FALSE},
3437             {"file:\\\\c:\\dir\\index.html",S_OK,FALSE},
3438             {"file",S_OK,FALSE},
3439             {"",S_FALSE,FALSE},
3440             {"",S_FALSE,FALSE}
3441         },
3442         {
3443             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3444             {0,S_FALSE,FALSE},
3445             {URL_SCHEME_FILE,S_OK,FALSE},
3446             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3447         }
3448     },
3449     {   "file:\\\\c:/dir/index.html", 0, S_OK, FALSE,
3450         {
3451             {"file:///c:/dir/index.html",S_OK,FALSE},
3452             {"",S_FALSE,FALSE},
3453             {"file:///c:/dir/index.html",S_OK,FALSE},
3454             {"",S_FALSE,FALSE},
3455             {".html",S_OK,FALSE},
3456             {"",S_FALSE,FALSE},
3457             {"",S_FALSE,FALSE},
3458             {"",S_FALSE,FALSE},
3459             {"/c:/dir/index.html",S_OK,FALSE},
3460             {"/c:/dir/index.html",S_OK,FALSE},
3461             {"",S_FALSE,FALSE},
3462             {"file:\\\\c:/dir/index.html",S_OK,FALSE},
3463             {"file",S_OK,FALSE},
3464             {"",S_FALSE,FALSE},
3465             {"",S_FALSE,FALSE}
3466         },
3467         {
3468             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3469             {0,S_FALSE,FALSE},
3470             {URL_SCHEME_FILE,S_OK,FALSE},
3471             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3472         }
3473     },
3474     {   "http:\\\\google.com", 0, S_OK, FALSE,
3475         {
3476             {"http://google.com/",S_OK,FALSE},
3477             {"google.com",S_OK,FALSE},
3478             {"http://google.com/",S_OK,FALSE},
3479             {"google.com",S_OK,FALSE},
3480             {"",S_FALSE,FALSE},
3481             {"",S_FALSE,FALSE},
3482             {"google.com",S_OK,FALSE},
3483             {"",S_FALSE,FALSE},
3484             {"/",S_OK,FALSE},
3485             {"/",S_OK,FALSE},
3486             {"",S_FALSE,FALSE},
3487             {"http:\\\\google.com",S_OK,FALSE},
3488             {"http",S_OK,FALSE},
3489             {"",S_FALSE,FALSE},
3490             {"",S_FALSE,FALSE}
3491         },
3492         {
3493             {Uri_HOST_DNS,S_OK,FALSE},
3494             {80,S_OK,FALSE},
3495             {URL_SCHEME_HTTP,S_OK,FALSE},
3496             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3497         }
3498     },
3499     /* the "\\\\" aren't converted to "//" for unknown scheme types and it's considered opaque. */
3500     {   "zip:\\\\google.com", 0, S_OK, FALSE,
3501         {
3502             {"zip:\\\\google.com",S_OK,FALSE},
3503             {"",S_FALSE,FALSE},
3504             {"zip:\\\\google.com",S_OK,FALSE},
3505             {"",S_FALSE,FALSE},
3506             {".com",S_OK,FALSE},
3507             {"",S_FALSE,FALSE},
3508             {"",S_FALSE,FALSE},
3509             {"",S_FALSE,FALSE},
3510             {"\\\\google.com",S_OK,FALSE},
3511             {"\\\\google.com",S_OK,FALSE},
3512             {"",S_FALSE,FALSE},
3513             {"zip:\\\\google.com",S_OK,FALSE},
3514             {"zip",S_OK,FALSE},
3515             {"",S_FALSE,FALSE},
3516             {"",S_FALSE,FALSE}
3517         },
3518         {
3519             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3520             {0,S_FALSE,FALSE},
3521             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3522             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3523         }
3524     },
3525     /* Dot segments aren't removed. */
3526     {   "file://c:\\dir\\../..\\./index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3527         {
3528             {"file://c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3529             {"",S_FALSE,FALSE},
3530             {"file://c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3531             {"",S_FALSE,FALSE},
3532             {".html",S_OK,FALSE},
3533             {"",S_FALSE,FALSE},
3534             {"",S_FALSE,FALSE},
3535             {"",S_FALSE,FALSE},
3536             {"c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3537             {"c:\\dir\\..\\..\\.\\index.html",S_OK,FALSE},
3538             {"",S_FALSE,FALSE},
3539             {"file://c:\\dir\\../..\\./index.html",S_OK,FALSE},
3540             {"file",S_OK,FALSE},
3541             {"",S_FALSE,FALSE},
3542             {"",S_FALSE,FALSE}
3543         },
3544         {
3545             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3546             {0,S_FALSE,FALSE},
3547             {URL_SCHEME_FILE,S_OK,FALSE},
3548             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3549         }
3550     },
3551     /* Forbidden characters aren't percent encoded. */
3552     {   "file://c:\\dir\\i^|ndex.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3553         {
3554             {"file://c:\\dir\\i^|ndex.html",S_OK,FALSE},
3555             {"",S_FALSE,FALSE},
3556             {"file://c:\\dir\\i^|ndex.html",S_OK,FALSE},
3557             {"",S_FALSE,FALSE},
3558             {".html",S_OK,FALSE},
3559             {"",S_FALSE,FALSE},
3560             {"",S_FALSE,FALSE},
3561             {"",S_FALSE,FALSE},
3562             {"c:\\dir\\i^|ndex.html",S_OK,FALSE},
3563             {"c:\\dir\\i^|ndex.html",S_OK,FALSE},
3564             {"",S_FALSE,FALSE},
3565             {"file://c:\\dir\\i^|ndex.html",S_OK,FALSE},
3566             {"file",S_OK,FALSE},
3567             {"",S_FALSE,FALSE},
3568             {"",S_FALSE,FALSE}
3569         },
3570         {
3571             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3572             {0,S_FALSE,FALSE},
3573             {URL_SCHEME_FILE,S_OK,FALSE},
3574             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3575         }
3576     },
3577     /* The '\' are still converted to '/' even though it's an opaque file URI. */
3578     {   "file:c:\\dir\\../..\\index.html", 0, S_OK, FALSE,
3579         {
3580             {"",S_FALSE,FALSE},
3581             {"",S_FALSE,FALSE},
3582             {"file:c:/dir/../../index.html",S_OK,FALSE},
3583             {"",S_FALSE,FALSE},
3584             {".html",S_OK,FALSE},
3585             {"",S_FALSE,FALSE},
3586             {"",S_FALSE,FALSE},
3587             {"",S_FALSE,FALSE},
3588             {"c:/dir/../../index.html",S_OK,FALSE},
3589             {"c:/dir/../../index.html",S_OK,FALSE},
3590             {"",S_FALSE,FALSE},
3591             {"file:c:\\dir\\../..\\index.html",S_OK,FALSE},
3592             {"file",S_OK,FALSE},
3593             {"",S_FALSE,FALSE},
3594             {"",S_FALSE,FALSE}
3595         },
3596         {
3597             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3598             {0,S_FALSE,FALSE},
3599             {URL_SCHEME_FILE,S_OK,FALSE},
3600             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3601         }
3602     },
3603     /* '/' are still converted to '\' even though it's an opaque URI. */
3604     {   "file:c:/dir\\../..\\index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3605         {
3606             {"",S_FALSE,FALSE},
3607             {"",S_FALSE,FALSE},
3608             {"file:c:\\dir\\..\\..\\index.html",S_OK,FALSE},
3609             {"",S_FALSE,FALSE},
3610             {".html",S_OK,FALSE},
3611             {"",S_FALSE,FALSE},
3612             {"",S_FALSE,FALSE},
3613             {"",S_FALSE,FALSE},
3614             {"c:\\dir\\..\\..\\index.html",S_OK,FALSE},
3615             {"c:\\dir\\..\\..\\index.html",S_OK,FALSE},
3616             {"",S_FALSE,FALSE},
3617             {"file:c:/dir\\../..\\index.html",S_OK,FALSE},
3618             {"file",S_OK,FALSE},
3619             {"",S_FALSE,FALSE},
3620             {"",S_FALSE,FALSE}
3621         },
3622         {
3623             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3624             {0,S_FALSE,FALSE},
3625             {URL_SCHEME_FILE,S_OK,FALSE},
3626             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3627         }
3628     },
3629     /* Forbidden characters aren't percent encoded. */
3630     {   "file:c:\\in^|dex.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3631         {
3632             {"",S_FALSE,FALSE},
3633             {"",S_FALSE,FALSE},
3634             {"file:c:\\in^|dex.html",S_OK,FALSE},
3635             {"",S_FALSE,FALSE},
3636             {".html",S_OK,FALSE},
3637             {"",S_FALSE,FALSE},
3638             {"",S_FALSE,FALSE},
3639             {"",S_FALSE,FALSE},
3640             {"c:\\in^|dex.html",S_OK,FALSE},
3641             {"c:\\in^|dex.html",S_OK,FALSE},
3642             {"",S_FALSE,FALSE},
3643             {"file:c:\\in^|dex.html",S_OK,FALSE},
3644             {"file",S_OK,FALSE},
3645             {"",S_FALSE,FALSE},
3646             {"",S_FALSE,FALSE}
3647         },
3648         {
3649             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3650             {0,S_FALSE,FALSE},
3651             {URL_SCHEME_FILE,S_OK,FALSE},
3652             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3653         }
3654     },
3655     /* Doesn't have a UserName since the ':' appears at the beginning of the
3656      * userinfo section.
3657      */
3658     {   "http://:password@gov.uk", 0, S_OK, FALSE,
3659         {
3660             {"http://:password@gov.uk/",S_OK,FALSE},
3661             {":password@gov.uk",S_OK,FALSE},
3662             {"http://gov.uk/",S_OK,FALSE},
3663             {"",S_FALSE,FALSE},
3664             {"",S_FALSE,FALSE},
3665             {"",S_FALSE,FALSE},
3666             {"gov.uk",S_OK,FALSE},
3667             {"password",S_OK,FALSE},
3668             {"/",S_OK,FALSE},
3669             {"/",S_OK,FALSE},
3670             {"",S_FALSE,FALSE},
3671             {"http://:password@gov.uk",S_OK,FALSE},
3672             {"http",S_OK,FALSE},
3673             {":password",S_OK,FALSE},
3674             {"",S_FALSE,FALSE}
3675         },
3676         {
3677             {Uri_HOST_DNS,S_OK,FALSE},
3678             {80,S_OK,FALSE},
3679             {URL_SCHEME_HTTP,S_OK,FALSE},
3680             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3681         }
3682     },
3683     /* Has a UserName since the userinfo section doesn't contain a password. */
3684     {   "http://@gov.uk", 0, S_OK, FALSE,
3685         {
3686             {"http://gov.uk/",S_OK,FALSE,"http://@gov.uk/"},
3687             {"@gov.uk",S_OK,FALSE},
3688             {"http://gov.uk/",S_OK,FALSE},
3689             {"",S_FALSE,FALSE},
3690             {"",S_FALSE,FALSE},
3691             {"",S_FALSE,FALSE},
3692             {"gov.uk",S_OK,FALSE},
3693             {"",S_FALSE,FALSE},
3694             {"/",S_OK,FALSE},
3695             {"/",S_OK,FALSE},
3696             {"",S_FALSE,FALSE},
3697             {"http://@gov.uk",S_OK,FALSE},
3698             {"http",S_OK,FALSE},
3699             {"",S_OK,FALSE},
3700             {"",S_OK,FALSE}
3701         },
3702         {
3703             {Uri_HOST_DNS,S_OK,FALSE},
3704             {80,S_OK,FALSE},
3705             {URL_SCHEME_HTTP,S_OK,FALSE},
3706             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3707         }
3708     },
3709     /* ":@" not included in the absolute URI. */
3710     {   "http://:@gov.uk", 0, S_OK, FALSE,
3711         {
3712             {"http://gov.uk/",S_OK,FALSE,"http://:@gov.uk/"},
3713             {":@gov.uk",S_OK,FALSE},
3714             {"http://gov.uk/",S_OK,FALSE},
3715             {"",S_FALSE,FALSE},
3716             {"",S_FALSE,FALSE},
3717             {"",S_FALSE,FALSE},
3718             {"gov.uk",S_OK,FALSE},
3719             {"",S_OK,FALSE},
3720             {"/",S_OK,FALSE},
3721             {"/",S_OK,FALSE},
3722             {"",S_FALSE,FALSE},
3723             {"http://:@gov.uk",S_OK,FALSE},
3724             {"http",S_OK,FALSE},
3725             {":",S_OK,FALSE},
3726             {"",S_FALSE,FALSE}
3727         },
3728         {
3729             {Uri_HOST_DNS,S_OK,FALSE},
3730             {80,S_OK,FALSE},
3731             {URL_SCHEME_HTTP,S_OK,FALSE},
3732             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3733         }
3734     },
3735     /* '@' is included because it's an unknown scheme type. */
3736     {   "zip://@gov.uk", 0, S_OK, FALSE,
3737         {
3738             {"zip://@gov.uk/",S_OK,FALSE},
3739             {"@gov.uk",S_OK,FALSE},
3740             {"zip://@gov.uk/",S_OK,FALSE},
3741             {"",S_FALSE,FALSE},
3742             {"",S_FALSE,FALSE},
3743             {"",S_FALSE,FALSE},
3744             {"gov.uk",S_OK,FALSE},
3745             {"",S_FALSE,FALSE},
3746             {"/",S_OK,FALSE},
3747             {"/",S_OK,FALSE},
3748             {"",S_FALSE,FALSE},
3749             {"zip://@gov.uk",S_OK,FALSE},
3750             {"zip",S_OK,FALSE},
3751             {"",S_OK,FALSE},
3752             {"",S_OK,FALSE}
3753         },
3754         {
3755             {Uri_HOST_DNS,S_OK,FALSE},
3756             {0,S_FALSE,FALSE},
3757             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3758             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3759         }
3760     },
3761     /* ":@" are included because it's an unknown scheme type. */
3762     {   "zip://:@gov.uk", 0, S_OK, FALSE,
3763         {
3764             {"zip://:@gov.uk/",S_OK,FALSE},
3765             {":@gov.uk",S_OK,FALSE},
3766             {"zip://:@gov.uk/",S_OK,FALSE},
3767             {"",S_FALSE,FALSE},
3768             {"",S_FALSE,FALSE},
3769             {"",S_FALSE,FALSE},
3770             {"gov.uk",S_OK,FALSE},
3771             {"",S_OK,FALSE},
3772             {"/",S_OK,FALSE},
3773             {"/",S_OK,FALSE},
3774             {"",S_FALSE,FALSE},
3775             {"zip://:@gov.uk",S_OK,FALSE},
3776             {"zip",S_OK,FALSE},
3777             {":",S_OK,FALSE},
3778             {"",S_FALSE,FALSE}
3779         },
3780         {
3781             {Uri_HOST_DNS,S_OK,FALSE},
3782             {0,S_FALSE,FALSE},
3783             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
3784             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3785         }
3786     },
3787     {   "about:blank", 0, S_OK, FALSE,
3788         {
3789             {"about:blank",S_OK,FALSE},
3790             {"",S_FALSE,FALSE},
3791             {"about:blank",S_OK,FALSE},
3792             {"",S_FALSE,FALSE},
3793             {"",S_FALSE,FALSE},
3794             {"",S_FALSE,FALSE},
3795             {"",S_FALSE,FALSE},
3796             {"",S_FALSE,FALSE},
3797             {"blank",S_OK,FALSE},
3798             {"blank",S_OK,FALSE},
3799             {"",S_FALSE,FALSE},
3800             {"about:blank",S_OK,FALSE},
3801             {"about",S_OK,FALSE},
3802             {"",S_FALSE,FALSE},
3803             {"",S_FALSE,FALSE}
3804         },
3805         {
3806             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3807             {0,S_FALSE,FALSE},
3808             {URL_SCHEME_ABOUT,S_OK,FALSE},
3809             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3810         }
3811     },
3812     {   "mk:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",0,S_OK,FALSE,
3813         {
3814             {"mk:@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3815             {"",S_FALSE,FALSE},
3816             {"mk:@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3817             {"",S_FALSE,FALSE},
3818             {".htm",S_OK,FALSE},
3819             {"",S_FALSE,FALSE},
3820             {"",S_FALSE,FALSE},
3821             {"",S_FALSE,FALSE},
3822             {"@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3823             {"@MSITStore:C:\\Program%20Files/AutoCAD%202008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3824             {"",S_FALSE,FALSE},
3825             {"mk:@MSITStore:C:\\Program Files/AutoCAD 2008\\Help/acad_acg.chm::/WSfacf1429558a55de1a7524c1004e616f8b-322b.htm",S_OK,FALSE},
3826             {"mk",S_OK,FALSE},
3827             {"",S_FALSE,FALSE},
3828             {"",S_FALSE,FALSE}
3829         },
3830         {
3831             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3832             {0,S_FALSE,FALSE},
3833             {URL_SCHEME_MK,S_OK,FALSE},
3834             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3835         }
3836     },
3837     {   "mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",0,S_OK,FALSE,
3838         {
3839             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3840             {"",S_FALSE,FALSE},
3841             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3842             {"",S_FALSE,FALSE},
3843             {".htm",S_OK,FALSE},
3844             {"",S_FALSE,FALSE},
3845             {"",S_FALSE,FALSE},
3846             {"",S_FALSE,FALSE},
3847             {"@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3848             {"@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3849             {"",S_FALSE,FALSE},
3850             {"mk:@MSITStore:Z:\\home\\test\\chm\\silqhelp.chm::/thesilqquickstartguide.htm",S_OK,FALSE},
3851             {"mk",S_OK,FALSE},
3852             {"",S_FALSE,FALSE},
3853             {"",S_FALSE,FALSE}
3854         },
3855         {
3856             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3857             {0,S_FALSE,FALSE},
3858             {URL_SCHEME_MK,S_OK,FALSE},
3859             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3860         }
3861     },
3862     /* Two '\' are added to the URI when USE_DOS_PATH is set, and it's a UNC path. */
3863     {   "file://server/dir/index.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE,
3864         {
3865             {"file://\\\\server\\dir\\index.html",S_OK,FALSE},
3866             {"server",S_OK,FALSE},
3867             {"file://\\\\server\\dir\\index.html",S_OK,FALSE},
3868             {"",S_FALSE,FALSE},
3869             {".html",S_OK,FALSE},
3870             {"",S_FALSE,FALSE},
3871             {"server",S_OK,FALSE},
3872             {"",S_FALSE,FALSE},
3873             {"\\dir\\index.html",S_OK,FALSE},
3874             {"\\dir\\index.html",S_OK,FALSE},
3875             {"",S_FALSE,FALSE},
3876             {"file://server/dir/index.html",S_OK,FALSE},
3877             {"file",S_OK,FALSE},
3878             {"",S_FALSE,FALSE},
3879             {"",S_FALSE,FALSE}
3880         },
3881         {
3882             {Uri_HOST_DNS,S_OK,FALSE},
3883             {0,S_FALSE,FALSE},
3884             {URL_SCHEME_FILE,S_OK,FALSE},
3885             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3886         }
3887     },
3888     /* When CreateUri generates an IUri, it still displays the default port in the
3889      * authority.
3890      */
3891     {   "http://google.com:80/", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
3892         {
3893             {"http://google.com:80/",S_OK,FALSE},
3894             {"google.com:80",S_OK,FALSE},
3895             {"http://google.com:80/",S_OK,FALSE},
3896             {"google.com",S_OK,FALSE},
3897             {"",S_FALSE,FALSE},
3898             {"",S_FALSE,FALSE},
3899             {"google.com",S_OK,FALSE},
3900             {"",S_FALSE,FALSE},
3901             {"/",S_OK,FALSE},
3902             {"/",S_OK,FALSE},
3903             {"",S_FALSE,FALSE},
3904             {"http://google.com:80/",S_OK,FALSE},
3905             {"http",S_OK,FALSE},
3906             {"",S_FALSE,FALSE},
3907             {"",S_FALSE,FALSE}
3908         },
3909         {
3910             {Uri_HOST_DNS,S_OK,FALSE},
3911             {80,S_OK,FALSE},
3912             {URL_SCHEME_HTTP,S_OK,FALSE},
3913             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3914         }
3915     },
3916     /* For res URIs the host is everything up until the first '/'. */
3917     {   "res://C:\\dir\\file.exe/DATA/test.html", 0, S_OK, FALSE,
3918         {
3919             {"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
3920             {"C:\\dir\\file.exe",S_OK,FALSE},
3921             {"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
3922             {"",S_FALSE,FALSE},
3923             {".html",S_OK,FALSE},
3924             {"",S_FALSE,FALSE},
3925             {"C:\\dir\\file.exe",S_OK,FALSE},
3926             {"",S_FALSE,FALSE},
3927             {"/DATA/test.html",S_OK,FALSE},
3928             {"/DATA/test.html",S_OK,FALSE},
3929             {"",S_FALSE,FALSE},
3930             {"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
3931             {"res",S_OK,FALSE},
3932             {"",S_FALSE,FALSE},
3933             {"",S_FALSE,FALSE}
3934         },
3935         {
3936             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3937             {0,S_FALSE,FALSE},
3938             {URL_SCHEME_RES,S_OK,FALSE},
3939             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3940         }
3941     },
3942     /* Res URI can contain a '|' in the host name. */
3943     {   "res://c:\\di|r\\file.exe/test", 0, S_OK, FALSE,
3944         {
3945             {"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
3946             {"c:\\di|r\\file.exe",S_OK,FALSE},
3947             {"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
3948             {"",S_FALSE,FALSE},
3949             {"",S_FALSE,FALSE},
3950             {"",S_FALSE,FALSE},
3951             {"c:\\di|r\\file.exe",S_OK,FALSE},
3952             {"",S_FALSE,FALSE},
3953             {"/test",S_OK,FALSE},
3954             {"/test",S_OK,FALSE},
3955             {"",S_FALSE,FALSE},
3956             {"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
3957             {"res",S_OK,FALSE},
3958             {"",S_FALSE,FALSE},
3959             {"",S_FALSE,FALSE}
3960         },
3961         {
3962             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3963             {0,S_FALSE,FALSE},
3964             {URL_SCHEME_RES,S_OK,FALSE},
3965             {URLZONE_INVALID,E_NOTIMPL,FALSE},
3966         }
3967     },
3968     /* Res URIs can have invalid percent encoded values. */
3969     {   "res://c:\\dir%xx\\file.exe/test", 0, S_OK, FALSE,
3970         {
3971             {"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
3972             {"c:\\dir%xx\\file.exe",S_OK,FALSE},
3973             {"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
3974             {"",S_FALSE,FALSE},
3975             {"",S_FALSE,FALSE},
3976             {"",S_FALSE,FALSE},
3977             {"c:\\dir%xx\\file.exe",S_OK,FALSE},
3978             {"",S_FALSE,FALSE},
3979             {"/test",S_OK,FALSE},
3980             {"/test",S_OK,FALSE},
3981             {"",S_FALSE,FALSE},
3982             {"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
3983             {"res",S_OK,FALSE},
3984             {"",S_FALSE,FALSE},
3985             {"",S_FALSE,FALSE}
3986         },
3987         {
3988             {Uri_HOST_UNKNOWN,S_OK,FALSE},
3989             {0,S_FALSE,FALSE},
3990             {URL_SCHEME_RES,S_OK,FALSE},
3991             {URLZONE_INVALID,E_NOTIMPL,FALSE}
3992         }
3993     },
3994     /* Res doesn't get forbidden characters percent encoded in it's path. */
3995     {   "res://c:\\test/tes<|>t", 0, S_OK, FALSE,
3996         {
3997             {"res://c:\\test/tes<|>t",S_OK,FALSE},
3998             {"c:\\test",S_OK,FALSE},
3999             {"res://c:\\test/tes<|>t",S_OK,FALSE},
4000             {"",S_FALSE,FALSE},
4001             {"",S_FALSE,FALSE},
4002             {"",S_FALSE,FALSE},
4003             {"c:\\test",S_OK,FALSE},
4004             {"",S_FALSE,FALSE},
4005             {"/tes<|>t",S_OK,FALSE},
4006             {"/tes<|>t",S_OK,FALSE},
4007             {"",S_FALSE,FALSE},
4008             {"res://c:\\test/tes<|>t",S_OK,FALSE},
4009             {"res",S_OK,FALSE},
4010             {"",S_FALSE,FALSE},
4011             {"",S_FALSE,FALSE}
4012         },
4013         {
4014             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4015             {0,S_FALSE,FALSE},
4016             {URL_SCHEME_RES,S_OK,FALSE},
4017             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4018         }
4019     },
4020     {   "mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg", 0, S_OK, FALSE,
4021         {
4022             {"mk:@MSITStore:Z:\\dir\\test.chm::/images/xxx.jpg",S_OK,FALSE},
4023             {"",S_FALSE,FALSE},
4024             {"mk:@MSITStore:Z:\\dir\\test.chm::/images/xxx.jpg",S_OK,FALSE},
4025             {"",S_FALSE,FALSE},
4026             {".jpg",S_OK,FALSE},
4027             {"",S_FALSE,FALSE},
4028             {"",S_FALSE,FALSE},
4029             {"",S_FALSE,FALSE},
4030             {"@MSITStore:Z:\\dir\\test.chm::/images/xxx.jpg",S_OK,FALSE},
4031             {"@MSITStore:Z:\\dir\\test.chm::/images/xxx.jpg",S_OK,FALSE},
4032             {"",S_FALSE,FALSE},
4033             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4034             {"mk",S_OK,FALSE},
4035             {"",S_FALSE,FALSE},
4036             {"",S_FALSE,FALSE}
4037         },
4038         {
4039             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4040             {0,S_FALSE,FALSE},
4041             {URL_SCHEME_MK,S_OK,FALSE},
4042             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4043         }
4044     },
4045     {   "mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE,
4046         {
4047             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4048             {"",S_FALSE,FALSE},
4049             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4050             {"",S_FALSE,FALSE},
4051             {".jpg",S_OK,FALSE},
4052             {"",S_FALSE,FALSE},
4053             {"",S_FALSE,FALSE},
4054             {"",S_FALSE,FALSE},
4055             {"@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4056             {"@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4057             {"",S_FALSE,FALSE},
4058             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4059             {"mk",S_OK,FALSE},
4060             {"",S_FALSE,FALSE},
4061             {"",S_FALSE,FALSE}
4062         },
4063         {
4064             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4065             {0,S_FALSE,FALSE},
4066             {URL_SCHEME_MK,S_OK,FALSE},
4067             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4068         }
4069     },
4070     {   "xx:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg", 0, S_OK, FALSE,
4071         {
4072             {"xx:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4073             {"",S_FALSE,FALSE},
4074             {"xx:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4075             {"",S_FALSE,FALSE},
4076             {".jpg",S_OK,FALSE},
4077             {"",S_FALSE,FALSE},
4078             {"",S_FALSE,FALSE},
4079             {"",S_FALSE,FALSE},
4080             {"@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4081             {"@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4082             {"",S_FALSE,FALSE},
4083             {"xx:@MSITStore:Z:\\dir\\test.chm::/html/../images/xxx.jpg",S_OK,FALSE},
4084             {"xx",S_OK,FALSE},
4085             {"",S_FALSE,FALSE},
4086             {"",S_FALSE,FALSE}
4087         },
4088         {
4089             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4090             {0,S_FALSE,FALSE},
4091             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
4092             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4093         }
4094     },
4095     {   "mk:@MSITStore:Z:\\dir\\test.chm::/html/../../images/xxx.jpg", 0, S_OK, FALSE,
4096         {
4097             {"mk:@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4098             {"",S_FALSE,FALSE},
4099             {"mk:@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4100             {"",S_FALSE,FALSE},
4101             {".jpg",S_OK,FALSE},
4102             {"",S_FALSE,FALSE},
4103             {"",S_FALSE,FALSE},
4104             {"",S_FALSE,FALSE},
4105             {"@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4106             {"@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4107             {"",S_FALSE,FALSE},
4108             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../../images/xxx.jpg",S_OK,FALSE},
4109             {"mk",S_OK,FALSE},
4110             {"",S_FALSE,FALSE},
4111             {"",S_FALSE,FALSE}
4112         },
4113         {
4114             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4115             {0,S_FALSE,FALSE},
4116             {URL_SCHEME_MK,S_OK,FALSE},
4117             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4118         }
4119     },
4120     {   "mk:@MSITStore:Z:\\dir\\dir2\\..\\test.chm::/html/../../images/xxx.jpg", 0, S_OK, FALSE,
4121         {
4122             {"mk:@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4123             {"",S_FALSE,FALSE},
4124             {"mk:@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4125             {"",S_FALSE,FALSE},
4126             {".jpg",S_OK,FALSE},
4127             {"",S_FALSE,FALSE},
4128             {"",S_FALSE,FALSE},
4129             {"",S_FALSE,FALSE},
4130             {"@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4131             {"@MSITStore:Z:\\dir\\images/xxx.jpg",S_OK,FALSE},
4132             {"",S_FALSE,FALSE},
4133             {"mk:@MSITStore:Z:\\dir\\dir2\\..\\test.chm::/html/../../images/xxx.jpg",S_OK,FALSE},
4134             {"mk",S_OK,FALSE},
4135             {"",S_FALSE,FALSE},
4136             {"",S_FALSE,FALSE}
4137         },
4138         {
4139             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4140             {0,S_FALSE,FALSE},
4141             {URL_SCHEME_MK,S_OK,FALSE},
4142             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4143         }
4144     },
4145     {   "mk:@MSITStore:Z:\\dir\\test.chm::/html/../../../../images/xxx.jpg", 0, S_OK, FALSE,
4146         {
4147             {"mk:images/xxx.jpg",S_OK,FALSE},
4148             {"",S_FALSE,FALSE},
4149             {"mk:images/xxx.jpg",S_OK,FALSE},
4150             {"",S_FALSE,FALSE},
4151             {".jpg",S_OK,FALSE},
4152             {"",S_FALSE,FALSE},
4153             {"",S_FALSE,FALSE},
4154             {"",S_FALSE,FALSE},
4155             {"images/xxx.jpg",S_OK,FALSE},
4156             {"images/xxx.jpg",S_OK,FALSE},
4157             {"",S_FALSE,FALSE},
4158             {"mk:@MSITStore:Z:\\dir\\test.chm::/html/../../../../images/xxx.jpg",S_OK,FALSE},
4159             {"mk",S_OK,FALSE},
4160             {"",S_FALSE,FALSE},
4161             {"",S_FALSE,FALSE}
4162         },
4163         {
4164             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4165             {0,S_FALSE,FALSE},
4166             {URL_SCHEME_MK,S_OK,FALSE},
4167             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4168         }
4169     },
4170     {   "", Uri_CREATE_ALLOW_RELATIVE, S_OK, FALSE,
4171         {
4172             {"",S_OK,FALSE},
4173             {"",S_FALSE,FALSE},
4174             {"",S_OK,FALSE},
4175             {"",S_FALSE,FALSE},
4176             {"",S_FALSE,FALSE},
4177             {"",S_FALSE,FALSE},
4178             {"",S_FALSE,FALSE},
4179             {"",S_FALSE,FALSE},
4180             {"",S_OK,FALSE},
4181             {"",S_OK,FALSE},
4182             {"",S_FALSE,FALSE},
4183             {"",S_OK,FALSE},
4184             {"",S_FALSE,FALSE},
4185             {"",S_FALSE,FALSE},
4186             {"",S_FALSE,FALSE}
4187         },
4188         {
4189             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4190             {0,S_FALSE,FALSE},
4191             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
4192             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4193         }
4194     },
4195     {   " \t ", Uri_CREATE_ALLOW_RELATIVE, S_OK, FALSE,
4196         {
4197             {"",S_OK,FALSE},
4198             {"",S_FALSE,FALSE},
4199             {"",S_OK,FALSE},
4200             {"",S_FALSE,FALSE},
4201             {"",S_FALSE,FALSE},
4202             {"",S_FALSE,FALSE},
4203             {"",S_FALSE,FALSE},
4204             {"",S_FALSE,FALSE},
4205             {"",S_OK,FALSE},
4206             {"",S_OK,FALSE},
4207             {"",S_FALSE,FALSE},
4208             {"",S_OK,FALSE},
4209             {"",S_FALSE,FALSE},
4210             {"",S_FALSE,FALSE},
4211             {"",S_FALSE,FALSE}
4212         },
4213         {
4214             {Uri_HOST_UNKNOWN,S_OK,FALSE},
4215             {0,S_FALSE,FALSE},
4216             {URL_SCHEME_UNKNOWN,S_OK,FALSE},
4217             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4218         }
4219     },
4220     {   "javascript:void", 0, S_OK, FALSE,
4221         {
4222             {"javascript:void",S_OK},
4223             {"",S_FALSE},
4224             {"javascript:void",S_OK},
4225             {"",S_FALSE},
4226             {"",S_FALSE},
4227             {"",S_FALSE},
4228             {"",S_FALSE},
4229             {"",S_FALSE},
4230             {"void",S_OK},
4231             {"void",S_OK},
4232             {"",S_FALSE},
4233             {"javascript:void",S_OK},
4234             {"javascript",S_OK},
4235             {"",S_FALSE},
4236             {"",S_FALSE}
4237         },
4238         {
4239             {Uri_HOST_UNKNOWN,S_OK},
4240             {0,S_FALSE},
4241             {URL_SCHEME_JAVASCRIPT,S_OK},
4242             {URLZONE_INVALID,E_NOTIMPL}
4243         }
4244     },
4245     {   "javascript://undefined", 0, S_OK, FALSE,
4246         {
4247             {"javascript://undefined",S_OK},
4248             {"",S_FALSE},
4249             {"javascript://undefined",S_OK},
4250             {"",S_FALSE},
4251             {"",S_FALSE},
4252             {"",S_FALSE},
4253             {"",S_FALSE},
4254             {"",S_FALSE},
4255             {"//undefined",S_OK},
4256             {"//undefined",S_OK},
4257             {"",S_FALSE},
4258             {"javascript://undefined",S_OK},
4259             {"javascript",S_OK},
4260             {"",S_FALSE},
4261             {"",S_FALSE}
4262         },
4263         {
4264             {Uri_HOST_UNKNOWN,S_OK},
4265             {0,S_FALSE},
4266             {URL_SCHEME_JAVASCRIPT,S_OK},
4267             {URLZONE_INVALID,E_NOTIMPL}
4268         }
4269     },
4270     {   "JavaSCript:escape('/\\?#?')", 0, S_OK, FALSE,
4271         {
4272             {"javascript:escape('/\\?#?')",S_OK},
4273             {"",S_FALSE},
4274             {"javascript:escape('/\\?#?')",S_OK},
4275             {"",S_FALSE},
4276             {"",S_FALSE},
4277             {"",S_FALSE},
4278             {"",S_FALSE},
4279             {"",S_FALSE},
4280             {"escape('/\\?#?')",S_OK},
4281             {"escape('/\\?#?')",S_OK},
4282             {"",S_FALSE},
4283             {"JavaSCript:escape('/\\?#?')",S_OK},
4284             {"javascript",S_OK},
4285             {"",S_FALSE},
4286             {"",S_FALSE}
4287         },
4288         {
4289             {Uri_HOST_UNKNOWN,S_OK},
4290             {0,S_FALSE},
4291             {URL_SCHEME_JAVASCRIPT,S_OK},
4292             {URLZONE_INVALID,E_NOTIMPL}
4293         }
4294     },
4295     {   "*://google.com", 0, S_OK, FALSE,
4296         {
4297             {"*:google.com/",S_OK,FALSE},
4298             {"google.com",S_OK},
4299             {"*:google.com/",S_OK,FALSE},
4300             {"google.com",S_OK,FALSE},
4301             {"",S_FALSE,FALSE},
4302             {"",S_FALSE,FALSE},
4303             {"google.com",S_OK,FALSE},
4304             {"",S_FALSE,FALSE},
4305             {"/",S_OK,FALSE},
4306             {"/",S_OK,FALSE},
4307             {"",S_FALSE,FALSE},
4308             {"*://google.com",S_OK,FALSE},
4309             {"*",S_OK,FALSE},
4310             {"",S_FALSE,FALSE},
4311             {"",S_FALSE,FALSE}
4312         },
4313         {
4314             {Uri_HOST_DNS,S_OK,FALSE},
4315             {0,S_FALSE,FALSE},
4316             {URL_SCHEME_WILDCARD,S_OK,FALSE},
4317             {URLZONE_INVALID,E_NOTIMPL,FALSE}
4318         }
4319     }
4320 };
4321
4322 typedef struct _invalid_uri {
4323     const char* uri;
4324     DWORD       flags;
4325     BOOL        todo;
4326 } invalid_uri;
4327
4328 static const invalid_uri invalid_uri_tests[] = {
4329     /* Has to have a scheme name. */
4330     {"://www.winehq.org",0,FALSE},
4331     /* Window's doesn't like URI's which are implicitly file paths without the
4332      * ALLOW_IMPLICIT_FILE_SCHEME flag set.
4333      */
4334     {"C:/test/test.mp3",0,FALSE},
4335     {"\\\\Server/test/test.mp3",0,FALSE},
4336     {"C:/test/test.mp3",Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME,FALSE},
4337     {"\\\\Server/test/test.mp3",Uri_CREATE_ALLOW_RELATIVE,FALSE},
4338     /* Invalid schemes. */
4339     {"*abcd://not.valid.com",0,FALSE},
4340     {"*a*b*c*d://not.valid.com",0,FALSE},
4341     /* Not allowed to have invalid % encoded data. */
4342     {"ftp://google.co%XX/",0,FALSE},
4343     /* To many h16 components. */
4344     {"http://[1:2:3:4:5:6:7:8:9]",0,FALSE},
4345     /* Not enough room for IPv4 address. */
4346     {"http://[1:2:3:4:5:6:7:192.0.1.0]",0,FALSE},
4347     /* Not enough h16 components. */
4348     {"http://[1:2:3:4]",0,FALSE},
4349     /* Not enough components including IPv4. */
4350     {"http://[1:192.0.1.0]",0,FALSE},
4351     /* Not allowed to have partial IPv4 in IPv6. */
4352     {"http://[::192.0]",0,FALSE},
4353     /* Can't have elision of 1 h16 at beginning of address. */
4354     {"http://[::2:3:4:5:6:7:8]",0,FALSE},
4355     /* Can't have elision of 1 h16 at end of address. */
4356     {"http://[1:2:3:4:5:6:7::]",0,FALSE},
4357     /* Expects a valid IP Literal. */
4358     {"ftp://[not.valid.uri]/",0,FALSE},
4359     /* Expects valid port for a known scheme type. */
4360     {"ftp://www.winehq.org:123fgh",0,FALSE},
4361     /* Port exceeds USHORT_MAX for known scheme type. */
4362     {"ftp://www.winehq.org:65536",0,FALSE},
4363     /* Invalid port with IPv4 address. */
4364     {"http://www.winehq.org:1abcd",0,FALSE},
4365     /* Invalid port with IPv6 address. */
4366     {"http://[::ffff]:32xy",0,FALSE},
4367     /* Not allowed to have backslashes with NO_CANONICALIZE. */
4368     {"gopher://www.google.com\\test",Uri_CREATE_NO_CANONICALIZE,FALSE},
4369     /* Not allowed to have invalid % encoded data in opaque URI path. */
4370     {"news:test%XX",0,FALSE},
4371     {"mailto:wine@winehq%G8.com",0,FALSE},
4372     /* Known scheme types can't have invalid % encoded data in query string. */
4373     {"http://google.com/?query=te%xx",0,FALSE},
4374     /* Invalid % encoded data in fragment of know scheme type. */
4375     {"ftp://google.com/#Test%xx",0,FALSE},
4376     {"  http://google.com/",Uri_CREATE_NO_PRE_PROCESS_HTML_URI,FALSE},
4377     {"\n\nhttp://google.com/",Uri_CREATE_NO_PRE_PROCESS_HTML_URI,FALSE},
4378     {"file://c:\\test<test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4379     {"file://c:\\test>test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4380     {"file://c:\\test\"test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4381     {"file:c:\\test<test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4382     {"file:c:\\test>test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4383     {"file:c:\\test\"test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
4384     /* res URIs aren't allowed to have forbidden dos path characters in the
4385      * hostname.
4386      */
4387     {"res://c:\\te<st\\test/test",0,FALSE},
4388     {"res://c:\\te>st\\test/test",0,FALSE},
4389     {"res://c:\\te\"st\\test/test",0,FALSE},
4390     {"res://c:\\test/te%xxst",0,FALSE}
4391 };
4392
4393 typedef struct _uri_equality {
4394     const char* a;
4395     DWORD       create_flags_a;
4396     BOOL        create_todo_a;
4397     const char* b;
4398     DWORD       create_flags_b;
4399     BOOL        create_todo_b;
4400     BOOL        equal;
4401     BOOL        todo;
4402 } uri_equality;
4403
4404 static const uri_equality equality_tests[] = {
4405     {
4406         "HTTP://www.winehq.org/test dir/./",0,FALSE,
4407         "http://www.winehq.org/test dir/../test dir/",0,FALSE,
4408         TRUE, FALSE
4409     },
4410     {
4411         /* http://www.winehq.org/test%20dir */
4412         "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,
4413         "http://www.winehq.org/test dir",0,FALSE,
4414         TRUE, FALSE
4415     },
4416     {
4417         "c:\\test.mp3",Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME,FALSE,
4418         "file:///c:/test.mp3",0,FALSE,
4419         TRUE, FALSE
4420     },
4421     {
4422         "ftp://ftp.winehq.org/",0,FALSE,
4423         "ftp://ftp.winehq.org",0,FALSE,
4424         TRUE, FALSE
4425     },
4426     {
4427         "ftp://ftp.winehq.org/test/test2/../../testB/",0,FALSE,
4428         "ftp://ftp.winehq.org/t%45stB/",0,FALSE,
4429         FALSE, FALSE
4430     },
4431     {
4432         "http://google.com/TEST",0,FALSE,
4433         "http://google.com/test",0,FALSE,
4434         FALSE, FALSE
4435     },
4436     {
4437         "http://GOOGLE.com/",0,FALSE,
4438         "http://google.com/",0,FALSE,
4439         TRUE, FALSE
4440     },
4441     /* Performs case insensitive compare of host names (for known scheme types). */
4442     {
4443         "ftp://GOOGLE.com/",Uri_CREATE_NO_CANONICALIZE,FALSE,
4444         "ftp://google.com/",0,FALSE,
4445         TRUE, FALSE
4446     },
4447     {
4448         "zip://GOOGLE.com/",0,FALSE,
4449         "zip://google.com/",0,FALSE,
4450         FALSE, FALSE
4451     },
4452     {
4453         "file:///c:/TEST/TeST/",0,FALSE,
4454         "file:///c:/test/test/",0,FALSE,
4455         TRUE, FALSE
4456     },
4457     {
4458         "file:///server/TEST",0,FALSE,
4459         "file:///SERVER/TEST",0,FALSE,
4460         TRUE, FALSE
4461     },
4462     {
4463         "http://google.com",Uri_CREATE_NO_CANONICALIZE,FALSE,
4464         "http://google.com/",0,FALSE,
4465         TRUE, FALSE
4466     },
4467     {
4468         "ftp://google.com:21/",0,FALSE,
4469         "ftp://google.com/",0,FALSE,
4470         TRUE, FALSE
4471     },
4472     {
4473         "http://google.com:80/",Uri_CREATE_NO_CANONICALIZE,FALSE,
4474         "http://google.com/",0,FALSE,
4475         TRUE, FALSE
4476     },
4477     {
4478         "http://google.com:70/",0,FALSE,
4479         "http://google.com:71/",0,FALSE,
4480         FALSE, FALSE
4481     }
4482 };
4483
4484 typedef struct _uri_with_fragment {
4485     const char* uri;
4486     const char* fragment;
4487     DWORD       create_flags;
4488     HRESULT     create_expected;
4489     BOOL        create_todo;
4490
4491     const char* expected_uri;
4492     BOOL        expected_todo;
4493 } uri_with_fragment;
4494
4495 static const uri_with_fragment uri_fragment_tests[] = {
4496     {
4497         "http://google.com/","#fragment",0,S_OK,FALSE,
4498         "http://google.com/#fragment",FALSE
4499     },
4500     {
4501         "http://google.com/","fragment",0,S_OK,FALSE,
4502         "http://google.com/#fragment",FALSE
4503     },
4504     {
4505         "zip://test.com/","?test",0,S_OK,FALSE,
4506         "zip://test.com/#?test",FALSE
4507     },
4508     /* The fragment can be empty. */
4509     {
4510         "ftp://ftp.google.com/","",0,S_OK,FALSE,
4511         "ftp://ftp.google.com/#",FALSE
4512     }
4513 };
4514
4515 typedef struct _uri_builder_property {
4516     BOOL            change;
4517     const char      *value;
4518     const char      *expected_value;
4519     Uri_PROPERTY    property;
4520     HRESULT         expected;
4521     BOOL            todo;
4522 } uri_builder_property;
4523
4524 typedef struct _uri_builder_port {
4525     BOOL    change;
4526     BOOL    set;
4527     DWORD   value;
4528     HRESULT expected;
4529     BOOL    todo;
4530 } uri_builder_port;
4531
4532 typedef struct _uri_builder_str_property {
4533     const char* expected;
4534     HRESULT     result;
4535     BOOL        todo;
4536 } uri_builder_str_property;
4537
4538 typedef struct _uri_builder_dword_property {
4539     DWORD   expected;
4540     HRESULT result;
4541     BOOL    todo;
4542 } uri_builder_dword_property;
4543
4544 typedef struct _uri_builder_test {
4545     const char                  *uri;
4546     DWORD                       create_flags;
4547     HRESULT                     create_builder_expected;
4548     BOOL                        create_builder_todo;
4549
4550     uri_builder_property        properties[URI_BUILDER_STR_PROPERTY_COUNT];
4551
4552     uri_builder_port            port_prop;
4553
4554     DWORD                       uri_flags;
4555     HRESULT                     uri_hres;
4556     BOOL                        uri_todo;
4557
4558     DWORD                       uri_simple_encode_flags;
4559     HRESULT                     uri_simple_hres;
4560     BOOL                        uri_simple_todo;
4561
4562     DWORD                       uri_with_flags;
4563     DWORD                       uri_with_builder_flags;
4564     DWORD                       uri_with_encode_flags;
4565     HRESULT                     uri_with_hres;
4566     BOOL                        uri_with_todo;
4567
4568     uri_builder_str_property    expected_str_props[URI_STR_PROPERTY_COUNT];
4569     uri_builder_dword_property  expected_dword_props[URI_DWORD_PROPERTY_COUNT];
4570 } uri_builder_test;
4571
4572 static const uri_builder_test uri_builder_tests[] = {
4573     {   "http://google.com/",0,S_OK,FALSE,
4574         {
4575             {TRUE,"#fragment",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE},
4576             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE},
4577             {TRUE,"?query=x",NULL,Uri_PROPERTY_QUERY,S_OK,FALSE},
4578             {TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
4579         },
4580         {FALSE},
4581         0,S_OK,FALSE,
4582         0,S_OK,FALSE,
4583         0,0,0,S_OK,FALSE,
4584         {
4585             {"http://username:password@google.com/?query=x#fragment",S_OK},
4586             {"username:password@google.com",S_OK},
4587             {"http://google.com/?query=x#fragment",S_OK},
4588             {"google.com",S_OK},
4589             {"",S_FALSE},
4590             {"#fragment",S_OK},
4591             {"google.com",S_OK},
4592             {"password",S_OK},
4593             {"/",S_OK},
4594             {"/?query=x",S_OK},
4595             {"?query=x",S_OK},
4596             {"http://username:password@google.com/?query=x#fragment",S_OK},
4597             {"http",S_OK},
4598             {"username:password",S_OK},
4599             {"username",S_OK}
4600         },
4601         {
4602             {Uri_HOST_DNS,S_OK},
4603             {80,S_OK},
4604             {URL_SCHEME_HTTP,S_OK},
4605             {URLZONE_INVALID,E_NOTIMPL}
4606         }
4607     },
4608     {   "http://google.com/",0,S_OK,FALSE,
4609         {
4610             {TRUE,"test",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE}
4611         },
4612         {TRUE,TRUE,120,S_OK,FALSE},
4613         0,S_OK,FALSE,
4614         0,S_OK,FALSE,
4615         0,0,0,S_OK,FALSE,
4616         {
4617             {"test://google.com:120/",S_OK},
4618             {"google.com:120",S_OK},
4619             {"test://google.com:120/",S_OK},
4620             {"google.com",S_OK},
4621             {"",S_FALSE},
4622             {"",S_FALSE},
4623             {"google.com",S_OK},
4624             {"",S_FALSE},
4625             {"/",S_OK},
4626             {"/",S_OK},
4627             {"",S_FALSE},
4628             {"test://google.com:120/",S_OK},
4629             {"test",S_OK},
4630             {"",S_FALSE},
4631             {"",S_FALSE}
4632         },
4633         {
4634             {Uri_HOST_DNS,S_OK},
4635             {120,S_OK},
4636             {URL_SCHEME_UNKNOWN,S_OK},
4637             {URLZONE_INVALID,E_NOTIMPL}
4638         }
4639     },
4640     {   "/Test/test dir",Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4641         {
4642             {TRUE,"http",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE},
4643             {TRUE,"::192.2.3.4",NULL,Uri_PROPERTY_HOST,S_OK,FALSE},
4644             {TRUE,NULL,NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
4645         },
4646         {FALSE},
4647         0,S_OK,FALSE,
4648         0,S_OK,FALSE,
4649         0,0,0,S_OK,FALSE,
4650         {
4651             {"http://[::192.2.3.4]/",S_OK},
4652             {"[::192.2.3.4]",S_OK},
4653             {"http://[::192.2.3.4]/",S_OK},
4654             {"",S_FALSE},
4655             {"",S_FALSE},
4656             {"",S_FALSE},
4657             {"::192.2.3.4",S_OK},
4658             {"",S_FALSE},
4659             {"/",S_OK},
4660             {"/",S_OK},
4661             {"",S_FALSE},
4662             {"http://[::192.2.3.4]/",S_OK},
4663             {"http",S_OK},
4664             {"",S_FALSE},
4665             {"",S_FALSE}
4666         },
4667         {
4668             {Uri_HOST_IPV6,S_OK},
4669             {80,S_OK},
4670             {URL_SCHEME_HTTP,S_OK},
4671             {URLZONE_INVALID,E_NOTIMPL}
4672         }
4673     },
4674     {   "http://google.com/",0,S_OK,FALSE,
4675         {
4676             {TRUE,"Frag","#Frag",Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
4677         },
4678         {FALSE},
4679         0,S_OK,FALSE,
4680         0,S_OK,FALSE,
4681         0,0,0,S_OK,FALSE,
4682         {
4683             {"http://google.com/#Frag",S_OK},
4684             {"google.com",S_OK},
4685             {"http://google.com/#Frag",S_OK},
4686             {"google.com",S_OK},
4687             {"",S_FALSE},
4688             {"#Frag",S_OK},
4689             {"google.com",S_OK},
4690             {"",S_FALSE},
4691             {"/",S_OK},
4692             {"/",S_OK},
4693             {"",S_FALSE},
4694             {"http://google.com/#Frag",S_OK},
4695             {"http",S_OK},
4696             {"",S_FALSE},
4697             {"",S_FALSE}
4698         },
4699         {
4700             {Uri_HOST_DNS,S_OK},
4701             {80,S_OK},
4702             {URL_SCHEME_HTTP,S_OK},
4703             {URLZONE_INVALID,E_NOTIMPL}
4704         }
4705     },
4706     {   "http://google.com/",0,S_OK,FALSE,
4707         {
4708             {TRUE,"","#",Uri_PROPERTY_FRAGMENT,S_OK,FALSE},
4709         },
4710         {FALSE},
4711         0,S_OK,FALSE,
4712         0,S_OK,FALSE,
4713         0,0,0,S_OK,FALSE,
4714         {
4715             {"http://google.com/#",S_OK},
4716             {"google.com",S_OK},
4717             {"http://google.com/#",S_OK},
4718             {"google.com",S_OK},
4719             {"",S_FALSE},
4720             {"#",S_OK},
4721             {"google.com",S_OK},
4722             {"",S_FALSE},
4723             {"/",S_OK},
4724             {"/",S_OK},
4725             {"",S_FALSE},
4726             {"http://google.com/#",S_OK},
4727             {"http",S_OK},
4728             {"",S_FALSE},
4729             {"",S_FALSE}
4730         },
4731         {
4732             {Uri_HOST_DNS,S_OK},
4733             {80,S_OK},
4734             {URL_SCHEME_HTTP,S_OK},
4735             {URLZONE_INVALID,E_NOTIMPL}
4736         }
4737     },
4738     {   "http://google.com/",0,S_OK,FALSE,
4739         {
4740             {TRUE,":password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4741         },
4742         {FALSE},
4743         0,S_OK,FALSE,
4744         0,S_OK,FALSE,
4745         0,0,0,S_OK,FALSE,
4746         {
4747             {"http://::password@google.com/",S_OK},
4748             {"::password@google.com",S_OK},
4749             {"http://google.com/",S_OK},
4750             {"google.com",S_OK},
4751             {"",S_FALSE},
4752             {"",S_FALSE},
4753             {"google.com",S_OK},
4754             {":password",S_OK},
4755             {"/",S_OK},
4756             {"/",S_OK},
4757             {"",S_FALSE},
4758             {"http://::password@google.com/",S_OK},
4759             {"http",S_OK},
4760             {"::password",S_OK},
4761             {"",S_FALSE}
4762         },
4763         {
4764             {Uri_HOST_DNS,S_OK},
4765             {80,S_OK},
4766             {URL_SCHEME_HTTP,S_OK},
4767             {URLZONE_INVALID,E_NOTIMPL}
4768         }
4769     },
4770     {   "test/test",Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4771         {
4772             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
4773         },
4774         {FALSE},
4775         Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
4776         0,S_OK,FALSE,
4777         Uri_CREATE_ALLOW_RELATIVE,0,0,S_OK,FALSE,
4778         {
4779             {":password@test/test",S_OK},
4780             {":password@",S_OK},
4781             {":password@test/test",S_OK},
4782             {"",S_FALSE},
4783             {"",S_FALSE},
4784             {"",S_FALSE},
4785             {"",S_FALSE},
4786             {"password",S_OK},
4787             {"test/test",S_OK},
4788             {"test/test",S_OK},
4789             {"",S_FALSE},
4790             {":password@test/test",S_OK},
4791             {"",S_FALSE},
4792             {":password",S_OK},
4793             {"",S_FALSE}
4794         },
4795         {
4796             {Uri_HOST_UNKNOWN,S_OK},
4797             {0,S_FALSE},
4798             {URL_SCHEME_UNKNOWN,S_OK},
4799             {URLZONE_INVALID,E_NOTIMPL}
4800         }
4801     },
4802     {   "http://google.com/",0,S_OK,FALSE,
4803         {
4804             {TRUE,"test/test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
4805         },
4806         {FALSE},
4807         0,S_OK,FALSE,
4808         0,S_OK,FALSE,
4809         0,0,0,S_OK,FALSE,
4810         {
4811             {"http://google.com/test/test",S_OK},
4812             {"google.com",S_OK},
4813             {"http://google.com/test/test",S_OK},
4814             {"google.com",S_OK},
4815             {"",S_FALSE},
4816             {"",S_FALSE},
4817             {"google.com",S_OK},
4818             {"",S_FALSE},
4819             {"/test/test",S_OK},
4820             {"/test/test",S_OK},
4821             {"",S_FALSE},
4822             {"http://google.com/test/test",S_OK},
4823             {"http",S_OK},
4824             {"",S_FALSE},
4825             {"",S_FALSE}
4826         },
4827         {
4828             {Uri_HOST_DNS,S_OK},
4829             {80,S_OK},
4830             {URL_SCHEME_HTTP,S_OK},
4831             {URLZONE_INVALID,E_NOTIMPL}
4832         }
4833     },
4834     {   "zip:testing/test",0,S_OK,FALSE,
4835         {
4836             {TRUE,"test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
4837         },
4838         {FALSE},
4839         0,S_OK,FALSE,
4840         0,S_OK,FALSE,
4841         0,0,0,S_OK,FALSE,
4842         {
4843             {"zip:test",S_OK},
4844             {"",S_FALSE},
4845             {"zip:test",S_OK},
4846             {"",S_FALSE},
4847             {"",S_FALSE},
4848             {"",S_FALSE},
4849             {"",S_FALSE},
4850             {"",S_FALSE},
4851             {"test",S_OK},
4852             {"test",S_OK},
4853             {"",S_FALSE},
4854             {"zip:test",S_OK},
4855             {"zip",S_OK},
4856             {"",S_FALSE},
4857             {"",S_FALSE}
4858         },
4859         {
4860             {Uri_HOST_UNKNOWN,S_OK},
4861             {0,S_FALSE},
4862             {URL_SCHEME_UNKNOWN,S_OK},
4863             {URLZONE_INVALID,E_NOTIMPL}
4864         }
4865     },
4866     {   "http://google.com/",0,S_OK,FALSE,
4867         {
4868             {FALSE},
4869         },
4870         /* 555 will be returned from GetPort even though FALSE was passed as the hasPort parameter. */
4871         {TRUE,FALSE,555,S_OK,FALSE},
4872         0,S_OK,FALSE,
4873         0,S_OK,FALSE,
4874         0,0,0,S_OK,FALSE,
4875         {
4876             {"http://google.com/",S_OK},
4877             {"google.com",S_OK},
4878             {"http://google.com/",S_OK},
4879             {"google.com",S_OK},
4880             {"",S_FALSE},
4881             {"",S_FALSE},
4882             {"google.com",S_OK},
4883             {"",S_FALSE},
4884             {"/",S_OK},
4885             {"/",S_OK},
4886             {"",S_FALSE},
4887             {"http://google.com/",S_OK},
4888             {"http",S_OK},
4889             {"",S_FALSE},
4890             {"",S_FALSE}
4891         },
4892         {
4893             {Uri_HOST_DNS,S_OK},
4894             /* Still returns 80, even though earlier the port was disabled. */
4895             {80,S_OK},
4896             {URL_SCHEME_HTTP,S_OK},
4897             {URLZONE_INVALID,E_NOTIMPL}
4898         }
4899     },
4900     {   "http://google.com/",0,S_OK,FALSE,
4901         {
4902             {FALSE},
4903         },
4904         /* Instead of getting "TRUE" back as the "hasPort" parameter in GetPort,
4905          * you'll get 122345 instead.
4906          */
4907         {TRUE,122345,222,S_OK,FALSE},
4908         0,S_OK,FALSE,
4909         0,S_OK,FALSE,
4910         0,0,0,S_OK,FALSE,
4911         {
4912             {"http://google.com:222/",S_OK},
4913             {"google.com:222",S_OK},
4914             {"http://google.com:222/",S_OK},
4915             {"google.com",S_OK},
4916             {"",S_FALSE},
4917             {"",S_FALSE},
4918             {"google.com",S_OK},
4919             {"",S_FALSE},
4920             {"/",S_OK},
4921             {"/",S_OK},
4922             {"",S_FALSE},
4923             {"http://google.com:222/",S_OK},
4924             {"http",S_OK},
4925             {"",S_FALSE},
4926             {"",S_FALSE}
4927         },
4928         {
4929             {Uri_HOST_DNS,S_OK},
4930             {222,S_OK},
4931             {URL_SCHEME_HTTP,S_OK},
4932             {URLZONE_INVALID,E_NOTIMPL}
4933         }
4934     },
4935     /* IUri's created with the IUriBuilder can have ports that exceed USHORT_MAX. */
4936     {   "http://google.com/",0,S_OK,FALSE,
4937         {
4938             {FALSE},
4939         },
4940         {TRUE,TRUE,999999,S_OK,FALSE},
4941         0,S_OK,FALSE,
4942         0,S_OK,FALSE,
4943         0,0,0,S_OK,FALSE,
4944         {
4945             {"http://google.com:999999/",S_OK},
4946             {"google.com:999999",S_OK},
4947             {"http://google.com:999999/",S_OK},
4948             {"google.com",S_OK},
4949             {"",S_FALSE},
4950             {"",S_FALSE},
4951             {"google.com",S_OK},
4952             {"",S_FALSE},
4953             {"/",S_OK},
4954             {"/",S_OK},
4955             {"",S_FALSE},
4956             {"http://google.com:999999/",S_OK},
4957             {"http",S_OK},
4958             {"",S_FALSE},
4959             {"",S_FALSE}
4960         },
4961         {
4962             {Uri_HOST_DNS,S_OK},
4963             {999999,S_OK},
4964             {URL_SCHEME_HTTP,S_OK},
4965             {URLZONE_INVALID,E_NOTIMPL}
4966         }
4967     },
4968     {   "http://google.com/",0,S_OK,FALSE,
4969         {
4970             {TRUE,"test","?test",Uri_PROPERTY_QUERY,S_OK,FALSE},
4971         },
4972
4973         {FALSE},
4974         0,S_OK,FALSE,
4975         0,S_OK,FALSE,
4976         0,0,0,S_OK,FALSE,
4977         {
4978             {"http://google.com/?test",S_OK},
4979             {"google.com",S_OK},
4980             {"http://google.com/?test",S_OK},
4981             {"google.com",S_OK},
4982             {"",S_FALSE},
4983             {"",S_FALSE},
4984             {"google.com",S_OK},
4985             {"",S_FALSE},
4986             {"/",S_OK},
4987             {"/?test",S_OK},
4988             {"?test",S_OK},
4989             {"http://google.com/?test",S_OK},
4990             {"http",S_OK},
4991             {"",S_FALSE},
4992             {"",S_FALSE}
4993         },
4994         {
4995             {Uri_HOST_DNS,S_OK},
4996             {80,S_OK},
4997             {URL_SCHEME_HTTP,S_OK},
4998             {URLZONE_INVALID,E_NOTIMPL}
4999         }
5000     },
5001     {   "http://:password@google.com/",0,S_OK,FALSE,
5002         {
5003             {FALSE},
5004         },
5005         {FALSE},
5006         0,S_OK,FALSE,
5007         0,S_OK,FALSE,
5008         0,0,0,S_OK,FALSE,
5009         {
5010             {"http://:password@google.com/",S_OK},
5011             {":password@google.com",S_OK},
5012             {"http://google.com/",S_OK},
5013             {"google.com",S_OK},
5014             {"",S_FALSE},
5015             {"",S_FALSE},
5016             {"google.com",S_OK},
5017             {"password",S_OK},
5018             {"/",S_OK},
5019             {"/",S_OK},
5020             {"",S_FALSE},
5021             {"http://:password@google.com/",S_OK},
5022             {"http",S_OK},
5023             {":password",S_OK},
5024             {"",S_FALSE}
5025         },
5026         {
5027             {Uri_HOST_DNS,S_OK},
5028             {80,S_OK},
5029             {URL_SCHEME_HTTP,S_OK},
5030             {URLZONE_INVALID,E_NOTIMPL}
5031         }
5032     },
5033     /* IUriBuilder doesn't need a base IUri to build a IUri. */
5034     {   NULL,0,S_OK,FALSE,
5035         {
5036             {TRUE,"http",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE},
5037             {TRUE,"google.com",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5038         },
5039         {FALSE},
5040         0,S_OK,FALSE,
5041         0,S_OK,FALSE,
5042         0,0,0,S_OK,FALSE,
5043         {
5044             {"http://google.com/",S_OK},
5045             {"google.com",S_OK},
5046             {"http://google.com/",S_OK},
5047             {"google.com",S_OK},
5048             {"",S_FALSE},
5049             {"",S_FALSE},
5050             {"google.com",S_OK},
5051             {"",S_FALSE},
5052             {"/",S_OK},
5053             {"/",S_OK},
5054             {"",S_FALSE},
5055             {"http://google.com/",S_OK},
5056             {"http",S_OK},
5057             {"",S_FALSE},
5058             {"",S_FALSE}
5059         },
5060         {
5061             {Uri_HOST_DNS,S_OK},
5062             {80,S_OK},
5063             {URL_SCHEME_HTTP,S_OK},
5064             {URLZONE_INVALID,E_NOTIMPL}
5065         }
5066     },
5067     /* Can't set the scheme name to NULL. */
5068     {   "zip://google.com/",0,S_OK,FALSE,
5069         {
5070             {TRUE,NULL,"zip",Uri_PROPERTY_SCHEME_NAME,E_INVALIDARG,FALSE}
5071         },
5072         {FALSE},
5073         0,S_OK,FALSE,
5074         0,S_OK,FALSE,
5075         0,0,0,S_OK,FALSE,
5076         {
5077             {"zip://google.com/",S_OK},
5078             {"google.com",S_OK},
5079             {"zip://google.com/",S_OK},
5080             {"google.com",S_OK},
5081             {"",S_FALSE},
5082             {"",S_FALSE},
5083             {"google.com",S_OK},
5084             {"",S_FALSE},
5085             {"/",S_OK},
5086             {"/",S_OK},
5087             {"",S_FALSE},
5088             {"zip://google.com/",S_OK},
5089             {"zip",S_OK},
5090             {"",S_FALSE},
5091             {"",S_FALSE}
5092         },
5093         {
5094             {Uri_HOST_DNS,S_OK},
5095             {0,S_FALSE},
5096             {URL_SCHEME_UNKNOWN,S_OK},
5097             {URLZONE_INVALID,E_NOTIMPL}
5098         }
5099     },
5100     /* Can't set the scheme name to an empty string. */
5101     {   "zip://google.com/",0,S_OK,FALSE,
5102         {
5103             {TRUE,"","zip",Uri_PROPERTY_SCHEME_NAME,E_INVALIDARG,FALSE}
5104         },
5105         {FALSE},
5106         0,S_OK,FALSE,
5107         0,S_OK,FALSE,
5108         0,0,0,S_OK,FALSE,
5109         {
5110             {"zip://google.com/",S_OK},
5111             {"google.com",S_OK},
5112             {"zip://google.com/",S_OK},
5113             {"google.com",S_OK},
5114             {"",S_FALSE},
5115             {"",S_FALSE},
5116             {"google.com",S_OK},
5117             {"",S_FALSE},
5118             {"/",S_OK},
5119             {"/",S_OK},
5120             {"",S_FALSE},
5121             {"zip://google.com/",S_OK},
5122             {"zip",S_OK},
5123             {"",S_FALSE},
5124             {"",S_FALSE}
5125         },
5126         {
5127             {Uri_HOST_DNS,S_OK},
5128             {0,S_FALSE},
5129             {URL_SCHEME_UNKNOWN,S_OK},
5130             {URLZONE_INVALID,E_NOTIMPL}
5131         }
5132     },
5133     /* -1 to CreateUri makes it use the same flags as the base IUri was created with.
5134      * CreateUriSimple always uses the flags the base IUri was created with (if any).
5135      */
5136     {   "http://google.com/../../",Uri_CREATE_NO_CANONICALIZE,S_OK,FALSE,
5137         {{FALSE}},
5138         {FALSE},
5139         -1,S_OK,FALSE,
5140         0,S_OK,FALSE,
5141         0,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
5142         {
5143             {"http://google.com/../../",S_OK},
5144             {"google.com",S_OK},
5145             {"http://google.com/../../",S_OK},
5146             {"google.com",S_OK},
5147             {"",S_FALSE},
5148             {"",S_FALSE},
5149             {"google.com",S_OK},
5150             {"",S_FALSE},
5151             {"/../../",S_OK},
5152             {"/../../",S_OK},
5153             {"",S_FALSE},
5154             {"http://google.com/../../",S_OK},
5155             {"http",S_OK},
5156             {"",S_FALSE},
5157             {"",S_FALSE}
5158         },
5159         {
5160             {Uri_HOST_DNS,S_OK},
5161             {80,S_OK},
5162             {URL_SCHEME_HTTP,S_OK},
5163             {URLZONE_INVALID,E_NOTIMPL}
5164         }
5165     },
5166     {   "http://google.com/",0,S_OK,FALSE,
5167         {
5168             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
5169         },
5170         {FALSE},
5171         -1,S_OK,FALSE,
5172         0,S_OK,FALSE,
5173         Uri_CREATE_NO_DECODE_EXTRA_INFO,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
5174         {
5175             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5176             {"google.com",S_OK},
5177             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5178             {"google.com",S_OK},
5179             {"",S_FALSE},
5180             {"#Fr%3C%7C%3Eg",S_OK},
5181             {"google.com",S_OK},
5182             {"",S_FALSE},
5183             {"/",S_OK},
5184             {"/",S_OK},
5185             {"",S_FALSE},
5186             {"http://google.com/#Fr<|>g",S_OK},
5187             {"http",S_OK},
5188             {"",S_FALSE},
5189             {"",S_FALSE}
5190         },
5191         {
5192             {Uri_HOST_DNS,S_OK},
5193             {80,S_OK},
5194             {URL_SCHEME_HTTP,S_OK},
5195             {URLZONE_INVALID,E_NOTIMPL}
5196         }
5197     },
5198     {   "http://google.com/",0,S_OK,FALSE,
5199         {
5200             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
5201         },
5202         {FALSE},
5203         Uri_CREATE_CANONICALIZE|Uri_CREATE_NO_CANONICALIZE,E_INVALIDARG,FALSE,
5204         0,S_OK,FALSE,
5205         Uri_CREATE_CANONICALIZE|Uri_CREATE_NO_CANONICALIZE,UriBuilder_USE_ORIGINAL_FLAGS,0,S_OK,FALSE,
5206         {
5207             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5208             {"google.com",S_OK},
5209             {"http://google.com/#Fr%3C%7C%3Eg",S_OK},
5210             {"google.com",S_OK},
5211             {"",S_FALSE},
5212             {"#Fr%3C%7C%3Eg",S_OK},
5213             {"google.com",S_OK},
5214             {"",S_FALSE},
5215             {"/",S_OK},
5216             {"/",S_OK},
5217             {"",S_FALSE},
5218             {"http://google.com/#Fr<|>g",S_OK},
5219             {"http",S_OK},
5220             {"",S_FALSE},
5221             {"",S_FALSE}
5222         },
5223         {
5224             {Uri_HOST_DNS,S_OK},
5225             {80,S_OK},
5226             {URL_SCHEME_HTTP,S_OK},
5227             {URLZONE_INVALID,E_NOTIMPL}
5228         }
5229     },
5230     {   NULL,0,S_OK,FALSE,
5231         {
5232             {TRUE,"/test/test/",NULL,Uri_PROPERTY_PATH,S_OK,FALSE},
5233             {TRUE,"#Fr<|>g",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
5234         },
5235         {FALSE},
5236         0,INET_E_INVALID_URL,FALSE,
5237         0,INET_E_INVALID_URL,FALSE,
5238         0,0,0,INET_E_INVALID_URL,FALSE
5239     },
5240     {   "http://google.com/",0,S_OK,FALSE,
5241         {
5242             {TRUE,"ht%xxtp",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,FALSE}
5243         },
5244         {FALSE},
5245         0,INET_E_INVALID_URL,FALSE,
5246         0,INET_E_INVALID_URL,FALSE,
5247         0,0,0,INET_E_INVALID_URL,FALSE
5248     },
5249     /* File scheme's can't have a username set. */
5250     {   "file://google.com/",0,S_OK,FALSE,
5251         {
5252             {TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5253         },
5254         {FALSE},
5255         0,INET_E_INVALID_URL,FALSE,
5256         0,INET_E_INVALID_URL,FALSE,
5257         0,0,0,INET_E_INVALID_URL,FALSE
5258     },
5259     /* File schemes can't have a password set. */
5260     {   "file://google.com/",0,S_OK,FALSE,
5261         {
5262             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5263         },
5264         {FALSE},
5265         0,INET_E_INVALID_URL,FALSE,
5266         0,INET_E_INVALID_URL,FALSE,
5267         0,0,0,INET_E_INVALID_URL,FALSE
5268     },
5269     /* UserName can't contain any character that is a delimeter for another
5270      * component that appears after it in a normal URI.
5271      */
5272     {   "http://google.com/",0,S_OK,FALSE,
5273         {
5274             {TRUE,"user:pass",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5275         },
5276         {FALSE},
5277         0,INET_E_INVALID_URL,FALSE,
5278         0,INET_E_INVALID_URL,FALSE,
5279         0,0,0,INET_E_INVALID_URL,FALSE
5280     },
5281     {   "http://google.com/",0,S_OK,FALSE,
5282         {
5283             {TRUE,"user@google.com",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5284         },
5285         {FALSE},
5286         0,INET_E_INVALID_URL,FALSE,
5287         0,INET_E_INVALID_URL,FALSE,
5288         0,0,0,INET_E_INVALID_URL,FALSE
5289     },
5290     {   "http://google.com/",0,S_OK,FALSE,
5291         {
5292             {TRUE,"user/path",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5293         },
5294         {FALSE},
5295         0,INET_E_INVALID_URL,FALSE,
5296         0,INET_E_INVALID_URL,FALSE,
5297         0,0,0,INET_E_INVALID_URL,FALSE
5298     },
5299     {   "http://google.com/",0,S_OK,FALSE,
5300         {
5301             {TRUE,"user?Query",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5302         },
5303         {FALSE},
5304         0,INET_E_INVALID_URL,FALSE,
5305         0,INET_E_INVALID_URL,FALSE,
5306         0,0,0,INET_E_INVALID_URL,FALSE
5307     },
5308     {   "http://google.com/",0,S_OK,FALSE,
5309         {
5310             {TRUE,"user#Frag",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
5311         },
5312         {FALSE},
5313         0,INET_E_INVALID_URL,FALSE,
5314         0,INET_E_INVALID_URL,FALSE,
5315         0,0,0,INET_E_INVALID_URL,FALSE
5316     },
5317     {   "http://google.com/",0,S_OK,FALSE,
5318         {
5319             {TRUE,"pass@google.com",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5320         },
5321         {FALSE},
5322         0,INET_E_INVALID_URL,FALSE,
5323         0,INET_E_INVALID_URL,FALSE,
5324         0,0,0,INET_E_INVALID_URL,FALSE
5325     },
5326     {   "http://google.com/",0,S_OK,FALSE,
5327         {
5328             {TRUE,"pass/path",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5329         },
5330         {FALSE},
5331         0,INET_E_INVALID_URL,FALSE,
5332         0,INET_E_INVALID_URL,FALSE,
5333         0,0,0,INET_E_INVALID_URL,FALSE
5334     },
5335     {   "http://google.com/",0,S_OK,FALSE,
5336         {
5337             {TRUE,"pass?query",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5338         },
5339         {FALSE},
5340         0,INET_E_INVALID_URL,FALSE,
5341         0,INET_E_INVALID_URL,FALSE,
5342        0,0,0,INET_E_INVALID_URL,FALSE
5343     },
5344     {   "http://google.com/",0,S_OK,FALSE,
5345         {
5346             {TRUE,"pass#frag",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE}
5347         },
5348         {FALSE},
5349         0,INET_E_INVALID_URL,FALSE,
5350         0,INET_E_INVALID_URL,FALSE,
5351         0,0,0,INET_E_INVALID_URL,FALSE
5352     },
5353     {   "http://google.com/",0,S_OK,FALSE,
5354         {
5355             {TRUE,"winehq.org/test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5356         },
5357         {FALSE},
5358         0,INET_E_INVALID_URL,FALSE,
5359         0,INET_E_INVALID_URL,FALSE,
5360         0,0,0,INET_E_INVALID_URL,FALSE
5361     },
5362     {   "http://google.com/",0,S_OK,FALSE,
5363         {
5364             {TRUE,"winehq.org?test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5365         },
5366         {FALSE},
5367         0,INET_E_INVALID_URL,FALSE,
5368         0,INET_E_INVALID_URL,FALSE,
5369         0,0,0,INET_E_INVALID_URL,FALSE
5370     },
5371     {   "http://google.com/",0,S_OK,FALSE,
5372         {
5373             {TRUE,"winehq.org#test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5374         },
5375         {FALSE},
5376         0,INET_E_INVALID_URL,FALSE,
5377         0,INET_E_INVALID_URL,FALSE,
5378         0,0,0,INET_E_INVALID_URL,FALSE
5379     },
5380     /* Hostname is allowed to contain a ':' (even for known scheme types). */
5381     {   "http://google.com/",0,S_OK,FALSE,
5382         {
5383             {TRUE,"winehq.org:test",NULL,Uri_PROPERTY_HOST,S_OK,FALSE},
5384         },
5385         {FALSE},
5386         0,S_OK,FALSE,
5387         0,S_OK,FALSE,
5388         0,0,0,S_OK,FALSE,
5389         {
5390             {"http://winehq.org:test/",S_OK},
5391             {"winehq.org:test",S_OK},
5392             {"http://winehq.org:test/",S_OK},
5393             {"winehq.org:test",S_OK},
5394             {"",S_FALSE},
5395             {"",S_FALSE},
5396             {"winehq.org:test",S_OK},
5397             {"",S_FALSE},
5398             {"/",S_OK},
5399             {"/",S_OK},
5400             {"",S_FALSE},
5401             {"http://winehq.org:test/",S_OK},
5402             {"http",S_OK},
5403             {"",S_FALSE},
5404             {"",S_FALSE}
5405         },
5406         {
5407             {Uri_HOST_DNS,S_OK},
5408             {80,S_OK},
5409             {URL_SCHEME_HTTP,S_OK},
5410             {URLZONE_INVALID,E_NOTIMPL}
5411         }
5412     },
5413     /* Can't set the host name to NULL. */
5414     {   "http://google.com/",0,S_OK,FALSE,
5415         {
5416             {TRUE,NULL,"google.com",Uri_PROPERTY_HOST,E_INVALIDARG,FALSE}
5417         },
5418         {FALSE},
5419         0,S_OK,FALSE,
5420         0,S_OK,FALSE,
5421         0,0,0,S_OK,FALSE,
5422         {
5423             {"http://google.com/",S_OK},
5424             {"google.com",S_OK},
5425             {"http://google.com/",S_OK},
5426             {"google.com",S_OK},
5427             {"",S_FALSE},
5428             {"",S_FALSE},
5429             {"google.com",S_OK},
5430             {"",S_FALSE},
5431             {"/",S_OK},
5432             {"/",S_OK},
5433             {"",S_FALSE},
5434             {"http://google.com/",S_OK},
5435             {"http",S_OK},
5436             {"",S_FALSE},
5437             {"",S_FALSE}
5438         },
5439         {
5440             {Uri_HOST_DNS,S_OK},
5441             {80,S_OK},
5442             {URL_SCHEME_HTTP,S_OK},
5443             {URLZONE_INVALID,E_NOTIMPL}
5444         }
5445     },
5446     /* Can set the host name to an empty string. */
5447     {   "http://google.com/",0,S_OK,FALSE,
5448         {
5449             {TRUE,"",NULL,Uri_PROPERTY_HOST,S_OK,FALSE}
5450         },
5451         {FALSE},
5452         0,S_OK,FALSE,
5453         0,S_OK,FALSE,
5454         0,0,0,S_OK,FALSE,
5455         {
5456             {"http:///",S_OK},
5457             {"",S_OK},
5458             {"http:///",S_OK},
5459             {"",S_FALSE},
5460             {"",S_FALSE},
5461             {"",S_FALSE},
5462             {"",S_OK},
5463             {"",S_FALSE},
5464             {"/",S_OK},
5465             {"/",S_OK},
5466             {"",S_FALSE},
5467             {"http:///",S_OK},
5468             {"http",S_OK},
5469             {"",S_FALSE},
5470             {"",S_FALSE}
5471         },
5472         {
5473             {Uri_HOST_UNKNOWN,S_OK},
5474             {80,S_OK},
5475             {URL_SCHEME_HTTP,S_OK},
5476             {URLZONE_INVALID,E_NOTIMPL}
5477         }
5478     },
5479     {   "http://google.com/",0,S_OK,FALSE,
5480         {
5481             {TRUE,"/path?query",NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
5482         },
5483         {FALSE},
5484         0,INET_E_INVALID_URL,FALSE,
5485         0,INET_E_INVALID_URL,FALSE,
5486         0,0,0,INET_E_INVALID_URL,FALSE
5487     },
5488     {   "http://google.com/",0,S_OK,FALSE,
5489         {
5490             {TRUE,"/path#test",NULL,Uri_PROPERTY_PATH,S_OK,FALSE}
5491         },
5492         {FALSE},
5493         0,INET_E_INVALID_URL,FALSE,
5494         0,INET_E_INVALID_URL,FALSE,
5495         0,0,0,INET_E_INVALID_URL,FALSE
5496     },
5497     {   "http://google.com/",0,S_OK,FALSE,
5498         {
5499             {TRUE,"?path#test",NULL,Uri_PROPERTY_QUERY,S_OK,FALSE}
5500         },
5501         {FALSE},
5502         0,INET_E_INVALID_URL,FALSE,
5503         0,INET_E_INVALID_URL,FALSE,
5504         0,0,0,INET_E_INVALID_URL,FALSE
5505     }
5506 };
5507
5508 typedef struct _uri_builder_remove_test {
5509     const char  *uri;
5510     DWORD       create_flags;
5511     HRESULT     create_builder_expected;
5512     BOOL        create_builder_todo;
5513
5514     DWORD       remove_properties;
5515     HRESULT     remove_expected;
5516     BOOL        remove_todo;
5517
5518     const char  *expected_uri;
5519     DWORD       expected_flags;
5520     HRESULT     expected_hres;
5521     BOOL        expected_todo;
5522 } uri_builder_remove_test;
5523
5524 static const uri_builder_remove_test uri_builder_remove_tests[] = {
5525     {   "http://google.com/test?test=y#Frag",0,S_OK,FALSE,
5526         Uri_HAS_FRAGMENT|Uri_HAS_PATH|Uri_HAS_QUERY,S_OK,FALSE,
5527         "http://google.com/",0,S_OK,FALSE
5528     },
5529     {   "http://user:pass@winehq.org/",0,S_OK,FALSE,
5530         Uri_HAS_USER_NAME|Uri_HAS_PASSWORD,S_OK,FALSE,
5531         "http://winehq.org/",0,S_OK,FALSE
5532     },
5533     {   "zip://google.com?Test=x",0,S_OK,FALSE,
5534         Uri_HAS_HOST,S_OK,FALSE,
5535         "zip:/?Test=x",0,S_OK,FALSE
5536     },
5537     /* Doesn't remove the whole userinfo component. */
5538     {   "http://username:pass@google.com/",0,S_OK,FALSE,
5539         Uri_HAS_USER_INFO,S_OK,FALSE,
5540         "http://username:pass@google.com/",0,S_OK,FALSE
5541     },
5542     /* Doesn't remove the domain. */
5543     {   "http://google.com/",0,S_OK,FALSE,
5544         Uri_HAS_DOMAIN,S_OK,FALSE,
5545         "http://google.com/",0,S_OK,FALSE
5546     },
5547     {   "http://google.com:120/",0,S_OK,FALSE,
5548         Uri_HAS_AUTHORITY,S_OK,FALSE,
5549         "http://google.com:120/",0,S_OK,FALSE
5550     },
5551     {   "http://google.com/test.com/",0,S_OK,FALSE,
5552         Uri_HAS_EXTENSION,S_OK,FALSE,
5553         "http://google.com/test.com/",0,S_OK,FALSE
5554     },
5555     {   "http://google.com/?test=x",0,S_OK,FALSE,
5556         Uri_HAS_PATH_AND_QUERY,S_OK,FALSE,
5557         "http://google.com/?test=x",0,S_OK,FALSE
5558     },
5559     /* Can't remove the scheme name. */
5560     {   "http://google.com/?test=x",0,S_OK,FALSE,
5561         Uri_HAS_SCHEME_NAME|Uri_HAS_QUERY,E_INVALIDARG,FALSE,
5562         "http://google.com/?test=x",0,S_OK,FALSE
5563     }
5564 };
5565
5566 typedef struct _uri_combine_str_property {
5567     const char  *value;
5568     HRESULT     expected;
5569     BOOL        todo;
5570     const char  *broken_value;
5571     const char  *value_ex;
5572 } uri_combine_str_property;
5573
5574 typedef struct _uri_combine_test {
5575     const char  *base_uri;
5576     DWORD       base_create_flags;
5577     const char  *relative_uri;
5578     DWORD       relative_create_flags;
5579     DWORD       combine_flags;
5580     HRESULT     expected;
5581     BOOL        todo;
5582
5583     uri_combine_str_property    str_props[URI_STR_PROPERTY_COUNT];
5584     uri_dword_property          dword_props[URI_DWORD_PROPERTY_COUNT];
5585 } uri_combine_test;
5586
5587 static const uri_combine_test uri_combine_tests[] = {
5588     {   "http://google.com/fun/stuff",0,
5589         "../not/fun/stuff",Uri_CREATE_ALLOW_RELATIVE,
5590         0,S_OK,FALSE,
5591         {
5592             {"http://google.com/not/fun/stuff",S_OK},
5593             {"google.com",S_OK},
5594             {"http://google.com/not/fun/stuff",S_OK},
5595             {"google.com",S_OK},
5596             {"",S_FALSE},
5597             {"",S_FALSE},
5598             {"google.com",S_OK},
5599             {"",S_FALSE},
5600             {"/not/fun/stuff",S_OK},
5601             {"/not/fun/stuff",S_OK},
5602             {"",S_FALSE},
5603             {"http://google.com/not/fun/stuff",S_OK},
5604             {"http",S_OK},
5605             {"",S_FALSE},
5606             {"",S_FALSE}
5607         },
5608         {
5609             {Uri_HOST_DNS,S_OK},
5610             {80,S_OK},
5611             {URL_SCHEME_HTTP,S_OK},
5612             {URLZONE_INVALID,E_NOTIMPL}
5613         }
5614     },
5615     {   "http://google.com/test",0,
5616         "zip://test.com/cool",0,
5617         0,S_OK,FALSE,
5618         {
5619             {"zip://test.com/cool",S_OK},
5620             {"test.com",S_OK},
5621             {"zip://test.com/cool",S_OK},
5622             {"test.com",S_OK},
5623             {"",S_FALSE},
5624             {"",S_FALSE},
5625             {"test.com",S_OK},
5626             {"",S_FALSE},
5627             {"/cool",S_OK},
5628             {"/cool",S_OK},
5629             {"",S_FALSE},
5630             {"zip://test.com/cool",S_OK},
5631             {"zip",S_OK},
5632             {"",S_FALSE},
5633             {"",S_FALSE}
5634         },
5635         {
5636             {Uri_HOST_DNS,S_OK},
5637             {0,S_FALSE},
5638             {URL_SCHEME_UNKNOWN,S_OK},
5639             {URLZONE_INVALID,E_NOTIMPL}
5640         }
5641     },
5642     {   "http://google.com/use/base/path",0,
5643         "?relative",Uri_CREATE_ALLOW_RELATIVE,
5644         0,S_OK,FALSE,
5645         {
5646             {"http://google.com/use/base/path?relative",S_OK},
5647             {"google.com",S_OK},
5648             {"http://google.com/use/base/path?relative",S_OK},
5649             {"google.com",S_OK},
5650             {"",S_FALSE},
5651             {"",S_FALSE},
5652             {"google.com",S_OK},
5653             {"",S_FALSE},
5654             {"/use/base/path",S_OK},
5655             {"/use/base/path?relative",S_OK},
5656             {"?relative",S_OK},
5657             {"http://google.com/use/base/path?relative",S_OK},
5658             {"http",S_OK},
5659             {"",S_FALSE},
5660             {"",S_FALSE}
5661         },
5662         {
5663             {Uri_HOST_DNS,S_OK},
5664             {80,S_OK},
5665             {URL_SCHEME_HTTP,S_OK},
5666             {URLZONE_INVALID,E_NOTIMPL}
5667         }
5668     },
5669     {   "http://google.com/path",0,
5670         "/test/../test/.././testing",Uri_CREATE_ALLOW_RELATIVE,
5671         0,S_OK,FALSE,
5672         {
5673             {"http://google.com/testing",S_OK},
5674             {"google.com",S_OK},
5675             {"http://google.com/testing",S_OK},
5676             {"google.com",S_OK},
5677             {"",S_FALSE},
5678             {"",S_FALSE},
5679             {"google.com",S_OK},
5680             {"",S_FALSE},
5681             {"/testing",S_OK},
5682             {"/testing",S_OK},
5683             {"",S_FALSE},
5684             {"http://google.com/testing",S_OK},
5685             {"http",S_OK},
5686             {"",S_FALSE},
5687             {"",S_FALSE}
5688         },
5689         {
5690             {Uri_HOST_DNS,S_OK},
5691             {80,S_OK},
5692             {URL_SCHEME_HTTP,S_OK},
5693             {URLZONE_INVALID,E_NOTIMPL}
5694         }
5695     },
5696     {   "http://google.com/path",0,
5697         "/test/../test/.././testing",Uri_CREATE_ALLOW_RELATIVE,
5698         URL_DONT_SIMPLIFY,S_OK,FALSE,
5699         {
5700             {"http://google.com:80/test/../test/.././testing",S_OK},
5701             {"google.com",S_OK},
5702             {"http://google.com:80/test/../test/.././testing",S_OK},
5703             {"google.com",S_OK},
5704             {"",S_FALSE},
5705             {"",S_FALSE},
5706             {"google.com",S_OK},
5707             {"",S_FALSE},
5708             {"/test/../test/.././testing",S_OK},
5709             {"/test/../test/.././testing",S_OK},
5710             {"",S_FALSE},
5711             {"http://google.com:80/test/../test/.././testing",S_OK},
5712             {"http",S_OK},
5713             {"",S_FALSE},
5714             {"",S_FALSE}
5715         },
5716         {
5717             {Uri_HOST_DNS,S_OK},
5718             {80,S_OK},
5719             {URL_SCHEME_HTTP,S_OK},
5720             {URLZONE_INVALID,E_NOTIMPL}
5721         }
5722     },
5723     {   "http://winehq.org/test/abc",0,
5724         "testing/abc/../test",Uri_CREATE_ALLOW_RELATIVE,
5725         0,S_OK,FALSE,
5726         {
5727             {"http://winehq.org/test/testing/test",S_OK},
5728             {"winehq.org",S_OK},
5729             {"http://winehq.org/test/testing/test",S_OK},
5730             {"winehq.org",S_OK},
5731             {"",S_FALSE},
5732             {"",S_FALSE},
5733             {"winehq.org",S_OK},
5734             {"",S_FALSE},
5735             {"/test/testing/test",S_OK},
5736             {"/test/testing/test",S_OK},
5737             {"",S_FALSE},
5738             {"http://winehq.org/test/testing/test",S_OK},
5739             {"http",S_OK},
5740             {"",S_FALSE},
5741             {"",S_FALSE}
5742         },
5743         {
5744             {Uri_HOST_DNS,S_OK},
5745             {80,S_OK},
5746             {URL_SCHEME_HTTP,S_OK},
5747             {URLZONE_INVALID,E_NOTIMPL}
5748         }
5749     },
5750     {   "http://winehq.org/test/abc",0,
5751         "testing/abc/../test",Uri_CREATE_ALLOW_RELATIVE,
5752         URL_DONT_SIMPLIFY,S_OK,FALSE,
5753         {
5754             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5755             /* Default port is hidden in the authority. */
5756             {"winehq.org",S_OK},
5757             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5758             {"winehq.org",S_OK},
5759             {"",S_FALSE},
5760             {"",S_FALSE},
5761             {"winehq.org",S_OK},
5762             {"",S_FALSE},
5763             {"/test/testing/abc/../test",S_OK},
5764             {"/test/testing/abc/../test",S_OK},
5765             {"",S_FALSE},
5766             {"http://winehq.org:80/test/testing/abc/../test",S_OK},
5767             {"http",S_OK},
5768             {"",S_FALSE},
5769             {"",S_FALSE}
5770         },
5771         {
5772             {Uri_HOST_DNS,S_OK},
5773             {80,S_OK},
5774             {URL_SCHEME_HTTP,S_OK},
5775             {URLZONE_INVALID,E_NOTIMPL}
5776         }
5777     },
5778     {   "http://winehq.org/test?query",0,
5779         "testing",Uri_CREATE_ALLOW_RELATIVE,
5780         0,S_OK,FALSE,
5781         {
5782             {"http://winehq.org/testing",S_OK},
5783             {"winehq.org",S_OK},
5784             {"http://winehq.org/testing",S_OK},
5785             {"winehq.org",S_OK},
5786             {"",S_FALSE},
5787             {"",S_FALSE},
5788             {"winehq.org",S_OK},
5789             {"",S_FALSE},
5790             {"/testing",S_OK},
5791             {"/testing",S_OK},
5792             {"",S_FALSE},
5793             {"http://winehq.org/testing",S_OK},
5794             {"http",S_OK},
5795             {"",S_FALSE},
5796             {"",S_FALSE}
5797         },
5798         {
5799             {Uri_HOST_DNS,S_OK},
5800             {80,S_OK},
5801             {URL_SCHEME_HTTP,S_OK},
5802             {URLZONE_INVALID,E_NOTIMPL}
5803         }
5804     },
5805     {   "http://winehq.org/test#frag",0,
5806         "testing",Uri_CREATE_ALLOW_RELATIVE,
5807         0,S_OK,FALSE,
5808         {
5809             {"http://winehq.org/testing",S_OK},
5810             {"winehq.org",S_OK},
5811             {"http://winehq.org/testing",S_OK},
5812             {"winehq.org",S_OK},
5813             {"",S_FALSE},
5814             {"",S_FALSE},
5815             {"winehq.org",S_OK},
5816             {"",S_FALSE},
5817             {"/testing",S_OK},
5818             {"/testing",S_OK},
5819             {"",S_FALSE},
5820             {"http://winehq.org/testing",S_OK},
5821             {"http",S_OK},
5822             {"",S_FALSE},
5823             {"",S_FALSE}
5824         },
5825         {
5826             {Uri_HOST_DNS,S_OK},
5827             {80,S_OK},
5828             {URL_SCHEME_HTTP,S_OK},
5829             {URLZONE_INVALID,E_NOTIMPL}
5830         }
5831     },
5832     {   "testing?query#frag",Uri_CREATE_ALLOW_RELATIVE,
5833         "test",Uri_CREATE_ALLOW_RELATIVE,
5834         0,S_OK,FALSE,
5835         {
5836             {"test",S_OK},
5837             {"",S_FALSE},
5838             {"test",S_OK},
5839             {"",S_FALSE},
5840             {"",S_FALSE},
5841             {"",S_FALSE},
5842             {"",S_FALSE},
5843             {"",S_FALSE},
5844             {"test",S_OK},
5845             {"test",S_OK},
5846             {"",S_FALSE},
5847             {"test",S_OK},
5848             {"",S_FALSE},
5849             {"",S_FALSE},
5850             {"",S_FALSE}
5851         },
5852         {
5853             {Uri_HOST_UNKNOWN,S_OK},
5854             {0,S_FALSE},
5855             {URL_SCHEME_UNKNOWN,S_OK},
5856             {URLZONE_INVALID,E_NOTIMPL}
5857         }
5858     },
5859     {   "file:///c:/test/test",0,
5860         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
5861         URL_FILE_USE_PATHURL,S_OK,FALSE,
5862         {
5863             {"file://c:\\testing.mp3",S_OK},
5864             {"",S_FALSE},
5865             {"file://c:\\testing.mp3",S_OK},
5866             {"",S_FALSE},
5867             {".mp3",S_OK},
5868             {"",S_FALSE},
5869             {"",S_FALSE},
5870             {"",S_FALSE},
5871             {"c:\\testing.mp3",S_OK},
5872             {"c:\\testing.mp3",S_OK},
5873             {"",S_FALSE},
5874             {"file://c:\\testing.mp3",S_OK},
5875             {"file",S_OK},
5876             {"",S_FALSE},
5877             {"",S_FALSE}
5878         },
5879         {
5880             {Uri_HOST_UNKNOWN,S_OK},
5881             {0,S_FALSE},
5882             {URL_SCHEME_FILE,S_OK},
5883             {URLZONE_INVALID,E_NOTIMPL}
5884         }
5885     },
5886     {   "file:///c:/test/test",0,
5887         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
5888         0,S_OK,FALSE,
5889         {
5890             {"file:///c:/testing.mp3",S_OK},
5891             {"",S_FALSE},
5892             {"file:///c:/testing.mp3",S_OK},
5893             {"",S_FALSE},
5894             {".mp3",S_OK},
5895             {"",S_FALSE},
5896             {"",S_FALSE},
5897             {"",S_FALSE},
5898             {"/c:/testing.mp3",S_OK},
5899             {"/c:/testing.mp3",S_OK},
5900             {"",S_FALSE},
5901             {"file:///c:/testing.mp3",S_OK},
5902             {"file",S_OK},
5903             {"",S_FALSE},
5904             {"",S_FALSE}
5905         },
5906         {
5907             {Uri_HOST_UNKNOWN,S_OK},
5908             {0,S_FALSE},
5909             {URL_SCHEME_FILE,S_OK},
5910             {URLZONE_INVALID,E_NOTIMPL}
5911         }
5912     },
5913     {   "file://test.com/test/test",0,
5914         "/testing.mp3",Uri_CREATE_ALLOW_RELATIVE,
5915         URL_FILE_USE_PATHURL,S_OK,FALSE,
5916         {
5917             {"file://\\\\test.com\\testing.mp3",S_OK},
5918             {"test.com",S_OK},
5919             {"file://\\\\test.com\\testing.mp3",S_OK},
5920             {"test.com",S_OK},
5921             {".mp3",S_OK},
5922             {"",S_FALSE},
5923             {"test.com",S_OK},
5924             {"",S_FALSE},
5925             {"\\testing.mp3",S_OK},
5926             {"\\testing.mp3",S_OK},
5927             {"",S_FALSE},
5928             {"file://\\\\test.com\\testing.mp3",S_OK},
5929             {"file",S_OK},
5930             {"",S_FALSE},
5931             {"",S_FALSE}
5932         },
5933         {
5934             {Uri_HOST_DNS,S_OK},
5935             {0,S_FALSE},
5936             {URL_SCHEME_FILE,S_OK},
5937             {URLZONE_INVALID,E_NOTIMPL}
5938         }
5939     },
5940     /* URL_DONT_SIMPLIFY has no effect. */
5941     {   "http://google.com/test",0,
5942         "zip://test.com/cool/../cool/test",0,
5943         URL_DONT_SIMPLIFY,S_OK,FALSE,
5944         {
5945             {"zip://test.com/cool/test",S_OK,FALSE,NULL,"zip://test.com/cool/../cool/test"},
5946             {"test.com",S_OK},
5947             {"zip://test.com/cool/test",S_OK,FALSE,NULL,"zip://test.com/cool/../cool/test"},
5948             {"test.com",S_OK},
5949             {"",S_FALSE},
5950             {"",S_FALSE},
5951             {"test.com",S_OK},
5952             {"",S_FALSE},
5953             {"/cool/test",S_OK,FALSE,NULL,"/cool/../cool/test"},
5954             {"/cool/test",S_OK,FALSE,NULL,"/cool/../cool/test"},
5955             {"",S_FALSE},
5956             /* The resulting IUri has the same Raw URI as the relative URI (only IE 8).
5957              * On IE 7 it reduces the path in the Raw URI.
5958              */
5959             {"zip://test.com/cool/../cool/test",S_OK,FALSE,"zip://test.com/cool/test"},
5960             {"zip",S_OK},
5961             {"",S_FALSE},
5962             {"",S_FALSE}
5963         },
5964         {
5965             {Uri_HOST_DNS,S_OK},
5966             {0,S_FALSE},
5967             {URL_SCHEME_UNKNOWN,S_OK},
5968             {URLZONE_INVALID,E_NOTIMPL}
5969         }
5970     },
5971     /* FILE_USE_PATHURL has no effect in IE 8, in IE 7 the
5972      * resulting URI is converted into a dos path.
5973      */
5974     {   "http://google.com/test",0,
5975         "file:///c:/test/",0,
5976         URL_FILE_USE_PATHURL,S_OK,FALSE,
5977         {
5978             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
5979             {"",S_FALSE},
5980             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
5981             {"",S_FALSE},
5982             {"",S_FALSE},
5983             {"",S_FALSE},
5984             {"",S_FALSE},
5985             {"",S_FALSE},
5986             {"/c:/test/",S_OK,FALSE,"c:\\test\\"},
5987             {"/c:/test/",S_OK,FALSE,"c:\\test\\"},
5988             {"",S_FALSE},
5989             {"file:///c:/test/",S_OK,FALSE,"file://c:\\test\\"},
5990             {"file",S_OK},
5991             {"",S_FALSE},
5992             {"",S_FALSE}
5993         },
5994         {
5995             {Uri_HOST_UNKNOWN,S_OK},
5996             {0,S_FALSE},
5997             {URL_SCHEME_FILE,S_OK},
5998             {URLZONE_INVALID,E_NOTIMPL}
5999         }
6000     },
6001     {   "http://google.com/test",0,
6002         "http://test.com/test#%30test",0,
6003         URL_DONT_UNESCAPE_EXTRA_INFO,S_OK,FALSE,
6004         {
6005             {"http://test.com/test#0test",S_OK,FALSE,NULL,"http://test.com/test#%30test"},
6006             {"test.com",S_OK},
6007             {"http://test.com/test#0test",S_OK,FALSE,NULL,"http://test.com/test#%30test"},
6008             {"test.com",S_OK},
6009             {"",S_FALSE},
6010             {"#0test",S_OK,FALSE,NULL,"#%30test"},
6011             {"test.com",S_OK},
6012             {"",S_FALSE},
6013             {"/test",S_OK},
6014             {"/test",S_OK},
6015             {"",S_FALSE},
6016             /* IE 7 decodes the %30 to a 0 in the Raw URI. */
6017             {"http://test.com/test#%30test",S_OK,FALSE,"http://test.com/test#0test"},
6018             {"http",S_OK},
6019             {"",S_FALSE},
6020             {"",S_FALSE}
6021         },
6022         {
6023             {Uri_HOST_DNS,S_OK},
6024             {80,S_OK},
6025             {URL_SCHEME_HTTP,S_OK},
6026             {URLZONE_INVALID,E_NOTIMPL}
6027         }
6028     },
6029     /* Windows validates the path component from the relative Uri. */
6030     {   "http://google.com/test",0,
6031         "/Te%XXst",Uri_CREATE_ALLOW_RELATIVE,
6032         0,E_INVALIDARG,FALSE
6033     },
6034     /* Windows doesn't validate the query from the relative Uri. */
6035     {   "http://google.com/test",0,
6036         "?Tes%XXt",Uri_CREATE_ALLOW_RELATIVE,
6037         0,S_OK,FALSE,
6038         {
6039             {"http://google.com/test?Tes%XXt",S_OK},
6040             {"google.com",S_OK},
6041             {"http://google.com/test?Tes%XXt",S_OK},
6042             {"google.com",S_OK},
6043             {"",S_FALSE},
6044             {"",S_FALSE},
6045             {"google.com",S_OK},
6046             {"",S_FALSE},
6047             {"/test",S_OK},
6048             {"/test?Tes%XXt",S_OK},
6049             {"?Tes%XXt",S_OK},
6050             {"http://google.com/test?Tes%XXt",S_OK},
6051             {"http",S_OK},
6052             {"",S_FALSE},
6053             {"",S_FALSE}
6054         },
6055         {
6056             {Uri_HOST_DNS,S_OK},
6057             {80,S_OK},
6058             {URL_SCHEME_HTTP,S_OK},
6059             {URLZONE_INVALID,E_NOTIMPL}
6060         }
6061     },
6062     /* Windows doesn't validate the fragment from the relative Uri. */
6063     {   "http://google.com/test",0,
6064         "#Tes%XXt",Uri_CREATE_ALLOW_RELATIVE,
6065         0,S_OK,FALSE,
6066         {
6067             {"http://google.com/test#Tes%XXt",S_OK},
6068             {"google.com",S_OK},
6069             {"http://google.com/test#Tes%XXt",S_OK},
6070             {"google.com",S_OK},
6071             {"",S_FALSE},
6072             {"#Tes%XXt",S_OK},
6073             {"google.com",S_OK},
6074             {"",S_FALSE},
6075             {"/test",S_OK},
6076             {"/test",S_OK},
6077             {"",S_FALSE},
6078             {"http://google.com/test#Tes%XXt",S_OK},
6079             {"http",S_OK},
6080             {"",S_FALSE},
6081             {"",S_FALSE}
6082         },
6083         {
6084             {Uri_HOST_DNS,S_OK},
6085             {80,S_OK},
6086             {URL_SCHEME_HTTP,S_OK},
6087             {URLZONE_INVALID,E_NOTIMPL}
6088         }
6089     },
6090     /* Creates an IUri which contains an invalid dos path char. */
6091     {   "file:///c:/test",0,
6092         "/test<ing",Uri_CREATE_ALLOW_RELATIVE,
6093         URL_FILE_USE_PATHURL,S_OK,FALSE,
6094         {
6095             {"file://c:\\test<ing",S_OK},
6096             {"",S_FALSE},
6097             {"file://c:\\test<ing",S_OK},
6098             {"",S_FALSE},
6099             {"",S_FALSE},
6100             {"",S_FALSE},
6101             {"",S_FALSE},
6102             {"",S_FALSE},
6103             {"c:\\test<ing",S_OK},
6104             {"c:\\test<ing",S_OK},
6105             {"",S_FALSE},
6106             {"file://c:\\test<ing",S_OK},
6107             {"file",S_OK},
6108             {"",S_FALSE},
6109             {"",S_FALSE}
6110         },
6111         {
6112             {Uri_HOST_UNKNOWN,S_OK},
6113             {0,S_FALSE},
6114             {URL_SCHEME_FILE,S_OK},
6115             {URLZONE_INVALID,E_NOTIMPL}
6116         }
6117     },
6118     /* Appends the path after the drive letter (if any). */
6119     {   "file:///c:/test",0,
6120         "/c:/testing",Uri_CREATE_ALLOW_RELATIVE,
6121         0,S_OK,FALSE,
6122         {
6123             {"file:///c:/c:/testing",S_OK},
6124             {"",S_FALSE},
6125             {"file:///c:/c:/testing",S_OK},
6126             {"",S_FALSE},
6127             {"",S_FALSE},
6128             {"",S_FALSE},
6129             {"",S_FALSE},
6130             {"",S_FALSE},
6131             {"/c:/c:/testing",S_OK},
6132             {"/c:/c:/testing",S_OK},
6133             {"",S_FALSE},
6134             {"file:///c:/c:/testing",S_OK},
6135             {"file",S_OK},
6136             {"",S_FALSE},
6137             {"",S_FALSE}
6138         },
6139         {
6140             {Uri_HOST_UNKNOWN,S_OK},
6141             {0,S_FALSE},
6142             {URL_SCHEME_FILE,S_OK},
6143             {URLZONE_INVALID,E_NOTIMPL}
6144         }
6145     },
6146     /* A '/' is added if the base URI doesn't have a path and the
6147      * relative URI doesn't contain a path (since the base URI is
6148      * hierarchical.
6149      */
6150     {   "http://google.com",Uri_CREATE_NO_CANONICALIZE,
6151         "?test",Uri_CREATE_ALLOW_RELATIVE,
6152         0,S_OK,FALSE,
6153         {
6154             {"http://google.com/?test",S_OK},
6155             {"google.com",S_OK},
6156             {"http://google.com/?test",S_OK},
6157             {"google.com",S_OK},
6158             {"",S_FALSE},
6159             {"",S_FALSE},
6160             {"google.com",S_OK},
6161             {"",S_FALSE},
6162             {"/",S_OK},
6163             {"/?test",S_OK},
6164             {"?test",S_OK},
6165             {"http://google.com/?test",S_OK},
6166             {"http",S_OK},
6167             {"",S_FALSE},
6168             {"",S_FALSE}
6169         },
6170         {
6171             {Uri_HOST_DNS,S_OK},
6172             {80,S_OK},
6173             {URL_SCHEME_HTTP,S_OK},
6174             {URLZONE_INVALID,E_NOTIMPL}
6175         }
6176     },
6177     {   "zip://google.com",Uri_CREATE_NO_CANONICALIZE,
6178         "?test",Uri_CREATE_ALLOW_RELATIVE,
6179         0,S_OK,FALSE,
6180         {
6181             {"zip://google.com/?test",S_OK},
6182             {"google.com",S_OK},
6183             {"zip://google.com/?test",S_OK},
6184             {"google.com",S_OK},
6185             {"",S_FALSE},
6186             {"",S_FALSE},
6187             {"google.com",S_OK},
6188             {"",S_FALSE},
6189             {"/",S_OK},
6190             {"/?test",S_OK},
6191             {"?test",S_OK},
6192             {"zip://google.com/?test",S_OK},
6193             {"zip",S_OK},
6194             {"",S_FALSE},
6195             {"",S_FALSE}
6196         },
6197         {
6198             {Uri_HOST_DNS,S_OK},
6199             {0,S_FALSE},
6200             {URL_SCHEME_UNKNOWN,S_OK},
6201             {URLZONE_INVALID,E_NOTIMPL}
6202         }
6203     },
6204     /* No path is appended since the base URI is opaque. */
6205     {   "zip:?testing",0,
6206         "?test",Uri_CREATE_ALLOW_RELATIVE,
6207         0,S_OK,FALSE,
6208         {
6209             {"zip:?test",S_OK},
6210             {"",S_FALSE},
6211             {"zip:?test",S_OK},
6212             {"",S_FALSE},
6213             {"",S_FALSE},
6214             {"",S_FALSE},
6215             {"",S_FALSE},
6216             {"",S_FALSE},
6217             {"",S_OK},
6218             {"?test",S_OK},
6219             {"?test",S_OK},
6220             {"zip:?test",S_OK},
6221             {"zip",S_OK},
6222             {"",S_FALSE},
6223             {"",S_FALSE}
6224         },
6225         {
6226             {Uri_HOST_UNKNOWN,S_OK},
6227             {0,S_FALSE},
6228             {URL_SCHEME_UNKNOWN,S_OK},
6229             {URLZONE_INVALID,E_NOTIMPL}
6230         }
6231     },
6232     {   "file:///c:/",0,
6233         "../testing/test",Uri_CREATE_ALLOW_RELATIVE,
6234         0,S_OK,FALSE,
6235         {
6236             {"file:///c:/testing/test",S_OK},
6237             {"",S_FALSE},
6238             {"file:///c:/testing/test",S_OK},
6239             {"",S_FALSE},
6240             {"",S_FALSE},
6241             {"",S_FALSE},
6242             {"",S_FALSE},
6243             {"",S_FALSE},
6244             {"/c:/testing/test",S_OK},
6245             {"/c:/testing/test",S_OK},
6246             {"",S_FALSE},
6247             {"file:///c:/testing/test",S_OK},
6248             {"file",S_OK},
6249             {"",S_FALSE},
6250             {"",S_FALSE}
6251         },
6252         {
6253             {Uri_HOST_UNKNOWN,S_OK},
6254             {0,S_FALSE},
6255             {URL_SCHEME_FILE,S_OK},
6256             {URLZONE_INVALID,E_NOTIMPL}
6257         }
6258     },
6259     {   "http://winehq.org/dir/testfile",0,
6260         "test?querystring",Uri_CREATE_ALLOW_RELATIVE,
6261         0,S_OK,FALSE,
6262         {
6263             {"http://winehq.org/dir/test?querystring",S_OK},
6264             {"winehq.org",S_OK},
6265             {"http://winehq.org/dir/test?querystring",S_OK},
6266             {"winehq.org",S_OK},
6267             {"",S_FALSE},
6268             {"",S_FALSE},
6269             {"winehq.org",S_OK},
6270             {"",S_FALSE},
6271             {"/dir/test",S_OK},
6272             {"/dir/test?querystring",S_OK},
6273             {"?querystring",S_OK},
6274             {"http://winehq.org/dir/test?querystring",S_OK},
6275             {"http",S_OK},
6276             {"",S_FALSE},
6277             {"",S_FALSE}
6278         },
6279         {
6280             {Uri_HOST_DNS,S_OK},
6281             {80,S_OK},
6282             {URL_SCHEME_HTTP,S_OK},
6283             {URLZONE_INVALID,E_NOTIMPL}
6284         }
6285     },
6286     {   "http://winehq.org/dir/test",0,
6287         "test?querystring",Uri_CREATE_ALLOW_RELATIVE,
6288         0,S_OK,FALSE,
6289         {
6290             {"http://winehq.org/dir/test?querystring",S_OK},
6291             {"winehq.org",S_OK},
6292             {"http://winehq.org/dir/test?querystring",S_OK},
6293             {"winehq.org",S_OK},
6294             {"",S_FALSE},
6295             {"",S_FALSE},
6296             {"winehq.org",S_OK},
6297             {"",S_FALSE},
6298             {"/dir/test",S_OK},
6299             {"/dir/test?querystring",S_OK},
6300             {"?querystring",S_OK},
6301             {"http://winehq.org/dir/test?querystring",S_OK},
6302             {"http",S_OK},
6303             {"",S_FALSE},
6304             {"",S_FALSE}
6305         },
6306         {
6307             {Uri_HOST_DNS,S_OK},
6308             {80,S_OK},
6309             {URL_SCHEME_HTTP,S_OK},
6310             {URLZONE_INVALID,E_NOTIMPL}
6311         }
6312     },
6313     {   "http://winehq.org/dir/test?querystring",0,
6314         "#hash",Uri_CREATE_ALLOW_RELATIVE,
6315         0,S_OK,FALSE,
6316         {
6317             {"http://winehq.org/dir/test?querystring#hash",S_OK},
6318             {"winehq.org",S_OK},
6319             {"http://winehq.org/dir/test?querystring#hash",S_OK},
6320             {"winehq.org",S_OK},
6321             {"",S_FALSE},
6322             {"#hash",S_OK},
6323             {"winehq.org",S_OK},
6324             {"",S_FALSE},
6325             {"/dir/test",S_OK},
6326             {"/dir/test?querystring",S_OK},
6327             {"?querystring",S_OK},
6328             {"http://winehq.org/dir/test?querystring#hash",S_OK},
6329             {"http",S_OK},
6330             {"",S_FALSE},
6331             {"",S_FALSE}
6332         },
6333         {
6334             {Uri_HOST_DNS,S_OK},
6335             {80,S_OK},
6336             {URL_SCHEME_HTTP,S_OK},
6337             {URLZONE_INVALID,E_NOTIMPL}
6338         }
6339     }
6340 };
6341
6342 typedef struct _uri_parse_test {
6343     const char  *uri;
6344     DWORD       uri_flags;
6345     PARSEACTION action;
6346     DWORD       flags;
6347     const char  *property;
6348     HRESULT     expected;
6349     BOOL        todo;
6350 } uri_parse_test;
6351
6352 static const uri_parse_test uri_parse_tests[] = {
6353     /* PARSE_CANONICALIZE tests. */
6354     {"zip://google.com/test<|>",0,PARSE_CANONICALIZE,0,"zip://google.com/test<|>",S_OK,FALSE},
6355     {"http://google.com/test<|>",0,PARSE_CANONICALIZE,0,"http://google.com/test%3C%7C%3E",S_OK,FALSE},
6356     {"http://google.com/%30%23%3F",0,PARSE_CANONICALIZE,URL_UNESCAPE,"http://google.com/0#?",S_OK,FALSE},
6357     {"test <|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_ESCAPE_UNSAFE,"test %3C%7C%3E",S_OK,FALSE},
6358     {"test <|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_ESCAPE_SPACES_ONLY,"test%20<|>",S_OK,FALSE},
6359     {"test%20<|>",Uri_CREATE_ALLOW_RELATIVE,PARSE_CANONICALIZE,URL_UNESCAPE|URL_ESCAPE_UNSAFE,"test%20%3C%7C%3E",S_OK,FALSE},
6360     {"http://google.com/%20",0,PARSE_CANONICALIZE,URL_ESCAPE_PERCENT,"http://google.com/%2520",S_OK,FALSE},
6361     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_DONT_SIMPLIFY,"http://google.com/test/../",S_OK,FALSE},
6362     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_NO_META,"http://google.com/test/../",S_OK,FALSE},
6363     {"http://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,0,"http://google.com/",S_OK,FALSE},
6364     {"zip://google.com/test/../",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,0,"zip://google.com/",S_OK,FALSE},
6365     {"file:///c:/test/../test",Uri_CREATE_NO_CANONICALIZE,PARSE_CANONICALIZE,URL_DONT_SIMPLIFY,"file:///c:/test/../test",S_OK,FALSE},
6366
6367     /* PARSE_FRIENDLY tests. */
6368     {"http://test@google.com/test#test",0,PARSE_FRIENDLY,0,"http://google.com/test#test",S_OK,FALSE},
6369     {"zip://test@google.com/test",0,PARSE_FRIENDLY,0,"zip://test@google.com/test",S_OK,FALSE},
6370
6371     /* PARSE_ROOTDOCUMENT tests. */
6372     {"http://google.com:200/test/test",0,PARSE_ROOTDOCUMENT,0,"http://google.com:200/",S_OK,FALSE},
6373     {"http://google.com",Uri_CREATE_NO_CANONICALIZE,PARSE_ROOTDOCUMENT,0,"http://google.com/",S_OK,FALSE},
6374     {"zip://google.com/",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6375     {"file:///c:/testing/",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6376     {"file://server/test",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6377     {"zip:test/test",0,PARSE_ROOTDOCUMENT,0,"",S_OK,FALSE},
6378
6379     /* PARSE_DOCUMENT tests. */
6380     {"http://test@google.com/test?query#frag",0,PARSE_DOCUMENT,0,"http://test@google.com/test?query",S_OK,FALSE},
6381     {"http:testing#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6382     {"file:///c:/test#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6383     {"zip://google.com/#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6384     {"zip:test#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6385     {"testing#frag",Uri_CREATE_ALLOW_RELATIVE,PARSE_DOCUMENT,0,"",S_OK,FALSE},
6386
6387     /* PARSE_PATH_FROM_URL tests. */
6388     {"file:///c:/test.mp3",0,PARSE_PATH_FROM_URL,0,"c:\\test.mp3",S_OK,FALSE},
6389     {"file:///c:/t<|>est.mp3",0,PARSE_PATH_FROM_URL,0,"c:\\t<|>est.mp3",S_OK,FALSE},
6390     {"file:///c:/te%XX t/",0,PARSE_PATH_FROM_URL,0,"c:\\te%XX t\\",S_OK,FALSE},
6391     {"file://server/test",0,PARSE_PATH_FROM_URL,0,"\\\\server\\test",S_OK,FALSE},
6392     {"http://google.com/",0,PARSE_PATH_FROM_URL,0,"",E_INVALIDARG,FALSE},
6393
6394     /* PARSE_URL_FROM_PATH tests. */
6395     /* This function almost seems to useless (just returns the absolute uri). */
6396     {"test.com",Uri_CREATE_ALLOW_RELATIVE,PARSE_URL_FROM_PATH,0,"test.com",S_OK,FALSE},
6397     {"/test/test",Uri_CREATE_ALLOW_RELATIVE,PARSE_URL_FROM_PATH,0,"/test/test",S_OK,FALSE},
6398     {"file://c:\\test\\test",Uri_CREATE_FILE_USE_DOS_PATH,PARSE_URL_FROM_PATH,0,"file://c:\\test\\test",S_OK,FALSE},
6399     {"file:c:/test",0,PARSE_URL_FROM_PATH,0,"",S_OK,FALSE},
6400     {"http:google.com/",0,PARSE_URL_FROM_PATH,0,"",S_OK,FALSE},
6401
6402     /* PARSE_SCHEMA tests. */
6403     {"http://google.com/test",0,PARSE_SCHEMA,0,"http",S_OK,FALSE},
6404     {"test",Uri_CREATE_ALLOW_RELATIVE,PARSE_SCHEMA,0,"",S_OK,FALSE},
6405
6406     /* PARSE_SITE tests. */
6407     {"http://google.uk.com/",0,PARSE_SITE,0,"google.uk.com",S_OK,FALSE},
6408     {"http://google.com.com/",0,PARSE_SITE,0,"google.com.com",S_OK,FALSE},
6409     {"google.com",Uri_CREATE_ALLOW_RELATIVE,PARSE_SITE,0,"",S_OK,FALSE},
6410     {"file://server/test",0,PARSE_SITE,0,"server",S_OK,FALSE},
6411
6412     /* PARSE_DOMAIN tests. */
6413     {"http://google.com.uk/",0,PARSE_DOMAIN,0,"google.com.uk",S_OK,FALSE},
6414     {"http://google.com.com/",0,PARSE_DOMAIN,0,"com.com",S_OK,FALSE},
6415     {"test/test",Uri_CREATE_ALLOW_RELATIVE,PARSE_DOMAIN,0,"",S_OK,FALSE},
6416     {"file://server/test",0,PARSE_DOMAIN,0,"",S_OK,FALSE},
6417
6418     /* PARSE_LOCATION and PARSE_ANCHOR tests. */
6419     {"http://google.com/test#Test",0,PARSE_ANCHOR,0,"#Test",S_OK,FALSE},
6420     {"http://google.com/test#Test",0,PARSE_LOCATION,0,"#Test",S_OK,FALSE},
6421     {"test",Uri_CREATE_ALLOW_RELATIVE,PARSE_ANCHOR,0,"",S_OK,FALSE},
6422     {"test",Uri_CREATE_ALLOW_RELATIVE,PARSE_LOCATION,0,"",S_OK,FALSE}
6423 };
6424
6425 static inline LPWSTR a2w(LPCSTR str) {
6426     LPWSTR ret = NULL;
6427
6428     if(str) {
6429         DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
6430         ret = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
6431         MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
6432     }
6433
6434     return ret;
6435 }
6436
6437 static inline BOOL heap_free(void* mem) {
6438     return HeapFree(GetProcessHeap(), 0, mem);
6439 }
6440
6441 static inline DWORD strcmp_aw(LPCSTR strA, LPCWSTR strB) {
6442     LPWSTR strAW = a2w(strA);
6443     DWORD ret = lstrcmpW(strAW, strB);
6444     heap_free(strAW);
6445     return ret;
6446 }
6447
6448 static inline ULONG get_refcnt(IUri *uri) {
6449     IUri_AddRef(uri);
6450     return IUri_Release(uri);
6451 }
6452
6453 static void change_property(IUriBuilder *builder, const uri_builder_property *prop,
6454                             DWORD test_index) {
6455     HRESULT hr;
6456     LPWSTR valueW;
6457
6458     valueW = a2w(prop->value);
6459     switch(prop->property) {
6460     case Uri_PROPERTY_FRAGMENT:
6461         hr = IUriBuilder_SetFragment(builder, valueW);
6462         if(prop->todo) {
6463             todo_wine {
6464                 ok(hr == prop->expected,
6465                     "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6466                     hr, prop->expected, test_index);
6467             }
6468         } else {
6469             ok(hr == prop->expected,
6470                 "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6471                 hr, prop->expected, test_index);
6472         }
6473         break;
6474     case Uri_PROPERTY_HOST:
6475         hr = IUriBuilder_SetHost(builder, valueW);
6476         if(prop->todo) {
6477             todo_wine {
6478                 ok(hr == prop->expected,
6479                     "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6480                     hr, prop->expected, test_index);
6481             }
6482         } else {
6483             ok(hr == prop->expected,
6484                 "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6485                 hr, prop->expected, test_index);
6486         }
6487         break;
6488     case Uri_PROPERTY_PASSWORD:
6489         hr = IUriBuilder_SetPassword(builder, valueW);
6490         if(prop->todo) {
6491             todo_wine {
6492                 ok(hr == prop->expected,
6493                     "Error: IUriBuilder_SetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6494                     hr, prop->expected, test_index);
6495             }
6496         } else {
6497             ok(hr == prop->expected,
6498                 "Error: IUriBuilder_SetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6499                 hr, prop->expected, test_index);
6500         }
6501         break;
6502     case Uri_PROPERTY_PATH:
6503         hr = IUriBuilder_SetPath(builder, valueW);
6504         if(prop->todo) {
6505             todo_wine {
6506                 ok(hr == prop->expected,
6507                     "Error: IUriBuilder_SetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6508                     hr, prop->expected, test_index);
6509             }
6510         } else {
6511             ok(hr == prop->expected,
6512                 "Error: IUriBuilder_SetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6513                 hr, prop->expected, test_index);
6514         }
6515         break;
6516     case Uri_PROPERTY_QUERY:
6517         hr = IUriBuilder_SetQuery(builder, valueW);
6518         if(prop->todo) {
6519             todo_wine {
6520                 ok(hr == prop->expected,
6521                     "Error: IUriBuilder_SetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6522                     hr, prop->expected, test_index);
6523             }
6524         } else {
6525             ok(hr == prop->expected,
6526                 "Error: IUriBuilder_SetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6527                 hr, prop->expected, test_index);
6528         }
6529         break;
6530     case Uri_PROPERTY_SCHEME_NAME:
6531         hr = IUriBuilder_SetSchemeName(builder, valueW);
6532         if(prop->todo) {
6533             todo_wine {
6534                 ok(hr == prop->expected,
6535                     "Error: IUriBuilder_SetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6536                     hr, prop->expected, test_index);
6537             }
6538         } else {
6539             ok(hr == prop->expected,
6540                 "Error: IUriBuilder_SetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6541                 hr, prop->expected, test_index);
6542         }
6543         break;
6544     case Uri_PROPERTY_USER_NAME:
6545         hr = IUriBuilder_SetUserName(builder, valueW);
6546         if(prop->todo) {
6547             todo_wine {
6548                 ok(hr == prop->expected,
6549                     "Error: IUriBuilder_SetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6550                     hr, prop->expected, test_index);
6551             }
6552         } else {
6553             ok(hr == prop->expected,
6554                 "Error: IUriBuilder_SetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
6555                 hr, prop->expected, test_index);
6556         }
6557         break;
6558     default:
6559         trace("Unsupported operation for %d on uri_builder_tests[%d].\n", prop->property, test_index);
6560     }
6561
6562     heap_free(valueW);
6563 }
6564
6565 /*
6566  * Simple tests to make sure the CreateUri function handles invalid flag combinations
6567  * correctly.
6568  */
6569 static void test_CreateUri_InvalidFlags(void) {
6570     DWORD i;
6571
6572     for(i = 0; i < sizeof(invalid_flag_tests)/sizeof(invalid_flag_tests[0]); ++i) {
6573         HRESULT hr;
6574         IUri *uri = (void*) 0xdeadbeef;
6575
6576         hr = pCreateUri(http_urlW, invalid_flag_tests[i].flags, 0, &uri);
6577         ok(hr == invalid_flag_tests[i].expected, "Error: CreateUri returned 0x%08x, expected 0x%08x, flags=0x%08x\n",
6578                 hr, invalid_flag_tests[i].expected, invalid_flag_tests[i].flags);
6579         ok(uri == NULL, "Error: expected the IUri to be NULL, but it was %p instead\n", uri);
6580     }
6581 }
6582
6583 static void test_CreateUri_InvalidArgs(void) {
6584     HRESULT hr;
6585     IUri *uri = (void*) 0xdeadbeef;
6586
6587     const WCHAR invalidW[] = {'i','n','v','a','l','i','d',0};
6588     static const WCHAR emptyW[] = {0};
6589
6590     hr = pCreateUri(http_urlW, 0, 0, NULL);
6591     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG);
6592
6593     hr = pCreateUri(NULL, 0, 0, &uri);
6594     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG);
6595     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6596
6597     uri = (void*) 0xdeadbeef;
6598     hr = pCreateUri(invalidW, 0, 0, &uri);
6599     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6600     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6601
6602     uri = (void*) 0xdeadbeef;
6603     hr = pCreateUri(emptyW, 0, 0, &uri);
6604     ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6605     ok(uri == NULL, "Error: Expected the IUri to be NULL, but it was %p instead\n", uri);
6606 }
6607
6608 static void test_CreateUri_InvalidUri(void) {
6609     DWORD i;
6610
6611     for(i = 0; i < sizeof(invalid_uri_tests)/sizeof(invalid_uri_tests[0]); ++i) {
6612         invalid_uri test = invalid_uri_tests[i];
6613         IUri *uri = NULL;
6614         LPWSTR uriW;
6615         HRESULT hr;
6616
6617         uriW = a2w(test.uri);
6618         hr = pCreateUri(uriW, test.flags, 0, &uri);
6619         if(test.todo) {
6620             todo_wine {
6621                 ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x on invalid_uri_tests[%d].\n",
6622                     hr, E_INVALIDARG, i);
6623             }
6624         } else {
6625             ok(hr == E_INVALIDARG, "Error: CreateUri returned 0x%08x, expected 0x%08x on invalid_uri_tests[%d].\n",
6626                 hr, E_INVALIDARG, i);
6627         }
6628         if(uri) IUri_Release(uri);
6629
6630         heap_free(uriW);
6631     }
6632 }
6633
6634 static void test_IUri_GetPropertyBSTR(void) {
6635     IUri *uri = NULL;
6636     HRESULT hr;
6637     DWORD i;
6638
6639     /* Make sure GetPropertyBSTR handles invalid args correctly. */
6640     hr = pCreateUri(http_urlW, 0, 0, &uri);
6641     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6642     if(SUCCEEDED(hr)) {
6643         BSTR received = NULL;
6644
6645         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_RAW_URI, NULL, 0);
6646         ok(hr == E_POINTER, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6647
6648         /* Make sure it handles a invalid Uri_PROPERTY's correctly. */
6649         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_PORT, &received, 0);
6650         ok(hr == S_OK, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6651         ok(received != NULL, "Error: Expected the string not to be NULL.\n");
6652         ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
6653         SysFreeString(received);
6654
6655         /* Make sure it handles the ZONE property correctly. */
6656         received = NULL;
6657         hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_ZONE, &received, 0);
6658         ok(hr == S_FALSE, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_FALSE);
6659         ok(received != NULL, "Error: Expected the string not to be NULL.\n");
6660         ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
6661         SysFreeString(received);
6662     }
6663     if(uri) IUri_Release(uri);
6664
6665     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6666         uri_properties test = uri_tests[i];
6667         LPWSTR uriW;
6668         uri = NULL;
6669
6670         uriW = a2w(test.uri);
6671         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6672         if(test.create_todo) {
6673             todo_wine {
6674                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6675                         hr, test.create_expected, i);
6676             }
6677         } else {
6678             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6679                     hr, test.create_expected, i);
6680         }
6681
6682         if(SUCCEEDED(hr)) {
6683             DWORD j;
6684
6685             /* Checks all the string properties of the uri. */
6686             for(j = Uri_PROPERTY_STRING_START; j <= Uri_PROPERTY_STRING_LAST; ++j) {
6687                 BSTR received = NULL;
6688                 uri_str_property prop = test.str_props[j];
6689
6690                 hr = IUri_GetPropertyBSTR(uri, j, &received, 0);
6691                 if(prop.todo) {
6692                     todo_wine {
6693                         ok(hr == prop.expected, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
6694                                 hr, prop.expected, i, j);
6695                     }
6696                     todo_wine {
6697                         ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6698                                 "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
6699                                 prop.value, wine_dbgstr_w(received), i, j);
6700                     }
6701                 } else {
6702                     ok(hr == prop.expected, "GetPropertyBSTR returned 0x%08x, expected 0x%08x. On uri_tests[%d].str_props[%d].\n",
6703                             hr, prop.expected, i, j);
6704                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6705                             "Expected %s but got %s on uri_tests[%d].str_props[%d].\n",
6706                             prop.value, wine_dbgstr_w(received), i, j);
6707                 }
6708
6709                 SysFreeString(received);
6710             }
6711         }
6712
6713         if(uri) IUri_Release(uri);
6714
6715         heap_free(uriW);
6716     }
6717 }
6718
6719 static void test_IUri_GetPropertyDWORD(void) {
6720     IUri *uri = NULL;
6721     HRESULT hr;
6722     DWORD i;
6723
6724     hr = pCreateUri(http_urlW, 0, 0, &uri);
6725     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6726     if(SUCCEEDED(hr)) {
6727         DWORD received = 0xdeadbeef;
6728
6729         hr = IUri_GetPropertyDWORD(uri, Uri_PROPERTY_DWORD_START, NULL, 0);
6730         ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6731
6732         hr = IUri_GetPropertyDWORD(uri, Uri_PROPERTY_ABSOLUTE_URI, &received, 0);
6733         ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
6734         ok(received == 0, "Error: Expected received=%d but instead received=%d.\n", 0, received);
6735     }
6736     if(uri) IUri_Release(uri);
6737
6738     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6739         uri_properties test = uri_tests[i];
6740         LPWSTR uriW;
6741         uri = NULL;
6742
6743         uriW = a2w(test.uri);
6744         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6745         if(test.create_todo) {
6746             todo_wine {
6747                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6748                         hr, test.create_expected, i);
6749             }
6750         } else {
6751             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x. Failed on uri_tests[%d].\n",
6752                     hr, test.create_expected, i);
6753         }
6754
6755         if(SUCCEEDED(hr)) {
6756             DWORD j;
6757
6758             /* Checks all the DWORD properties of the uri. */
6759             for(j = 0; j < sizeof(test.dword_props)/sizeof(test.dword_props[0]); ++j) {
6760                 DWORD received;
6761                 uri_dword_property prop = test.dword_props[j];
6762
6763                 hr = IUri_GetPropertyDWORD(uri, j+Uri_PROPERTY_DWORD_START, &received, 0);
6764                 if(prop.todo) {
6765                     todo_wine {
6766                         ok(hr == prop.expected, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
6767                                 hr, prop.expected, i, j);
6768                     }
6769                     todo_wine {
6770                         ok(prop.value == received, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
6771                                 prop.value, received, i, j);
6772                     }
6773                 } else {
6774                     ok(hr == prop.expected, "GetPropertyDWORD returned 0x%08x, expected 0x%08x. On uri_tests[%d].dword_props[%d].\n",
6775                             hr, prop.expected, i, j);
6776                     ok(prop.value == received, "Expected %d but got %d on uri_tests[%d].dword_props[%d].\n",
6777                             prop.value, received, i, j);
6778                 }
6779             }
6780         }
6781
6782         if(uri) IUri_Release(uri);
6783
6784         heap_free(uriW);
6785     }
6786 }
6787
6788 /* Tests all the 'Get*' property functions which deal with strings. */
6789 static void test_IUri_GetStrProperties(void) {
6790     IUri *uri = NULL;
6791     HRESULT hr;
6792     DWORD i;
6793
6794     /* Make sure all the 'Get*' string property functions handle invalid args correctly. */
6795     hr = pCreateUri(http_urlW, 0, 0, &uri);
6796     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
6797     if(SUCCEEDED(hr)) {
6798         hr = IUri_GetAbsoluteUri(uri, NULL);
6799         ok(hr == E_POINTER, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6800
6801         hr = IUri_GetAuthority(uri, NULL);
6802         ok(hr == E_POINTER, "Error: GetAuthority returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6803
6804         hr = IUri_GetDisplayUri(uri, NULL);
6805         ok(hr == E_POINTER, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6806
6807         hr = IUri_GetDomain(uri, NULL);
6808         ok(hr == E_POINTER, "Error: GetDomain returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6809
6810         hr = IUri_GetExtension(uri, NULL);
6811         ok(hr == E_POINTER, "Error: GetExtension returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6812
6813         hr = IUri_GetFragment(uri, NULL);
6814         ok(hr == E_POINTER, "Error: GetFragment returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6815
6816         hr = IUri_GetHost(uri, NULL);
6817         ok(hr == E_POINTER, "Error: GetHost returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6818
6819         hr = IUri_GetPassword(uri, NULL);
6820         ok(hr == E_POINTER, "Error: GetPassword returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6821
6822         hr = IUri_GetPath(uri, NULL);
6823         ok(hr == E_POINTER, "Error: GetPath returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6824
6825         hr = IUri_GetPathAndQuery(uri, NULL);
6826         ok(hr == E_POINTER, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6827
6828         hr = IUri_GetQuery(uri, NULL);
6829         ok(hr == E_POINTER, "Error: GetQuery returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6830
6831         hr = IUri_GetRawUri(uri, NULL);
6832         ok(hr == E_POINTER, "Error: GetRawUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6833
6834         hr = IUri_GetSchemeName(uri, NULL);
6835         ok(hr == E_POINTER, "Error: GetSchemeName returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6836
6837         hr = IUri_GetUserInfo(uri, NULL);
6838         ok(hr == E_POINTER, "Error: GetUserInfo returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6839
6840         hr = IUri_GetUserName(uri, NULL);
6841         ok(hr == E_POINTER, "Error: GetUserName returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
6842     }
6843     if(uri) IUri_Release(uri);
6844
6845     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
6846         uri_properties test = uri_tests[i];
6847         LPWSTR uriW;
6848         uri = NULL;
6849
6850         uriW = a2w(test.uri);
6851         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
6852         if(test.create_todo) {
6853             todo_wine {
6854                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6855                         hr, test.create_expected, i);
6856             }
6857         } else {
6858             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6859                     hr, test.create_expected, i);
6860         }
6861
6862         if(SUCCEEDED(hr)) {
6863             uri_str_property prop;
6864             BSTR received = NULL;
6865
6866             /* GetAbsoluteUri() tests. */
6867             prop = test.str_props[Uri_PROPERTY_ABSOLUTE_URI];
6868             hr = IUri_GetAbsoluteUri(uri, &received);
6869             if(prop.todo) {
6870                 todo_wine {
6871                     ok(hr == prop.expected, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6872                             hr, prop.expected, i);
6873                 }
6874                 todo_wine {
6875                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6876                             "Error: Expected %s but got %s on uri_tests[%d].\n",
6877                             prop.value, wine_dbgstr_w(received), i);
6878                 }
6879             } else {
6880                 ok(hr == prop.expected, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6881                         hr, prop.expected, i);
6882                 ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6883                         "Error: Expected %s but got %s on uri_tests[%d].\n",
6884                         prop.value, wine_dbgstr_w(received), i);
6885             }
6886             SysFreeString(received);
6887             received = NULL;
6888
6889             /* GetAuthority() tests. */
6890             prop = test.str_props[Uri_PROPERTY_AUTHORITY];
6891             hr = IUri_GetAuthority(uri, &received);
6892             if(prop.todo) {
6893                 todo_wine {
6894                     ok(hr == prop.expected, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6895                             hr, prop.expected, i);
6896                 }
6897                 todo_wine {
6898                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6899                             prop.value, wine_dbgstr_w(received), i);
6900                 }
6901             } else {
6902                 ok(hr == prop.expected, "Error: GetAuthority returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6903                         hr, prop.expected, i);
6904                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6905                         prop.value, wine_dbgstr_w(received), i);
6906             }
6907             SysFreeString(received);
6908             received = NULL;
6909
6910             /* GetDisplayUri() tests. */
6911             prop = test.str_props[Uri_PROPERTY_DISPLAY_URI];
6912             hr = IUri_GetDisplayUri(uri, &received);
6913             if(prop.todo) {
6914                 todo_wine {
6915                     ok(hr == prop.expected, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6916                             hr, prop.expected, i);
6917                 }
6918                 todo_wine {
6919                     ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6920                             "Error: Expected %s but got %s on uri_test[%d].\n",
6921                             prop.value, wine_dbgstr_w(received), i);
6922                 }
6923             } else {
6924                 ok(hr == prop.expected, "Error: GetDisplayUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6925                         hr, prop.expected, i);
6926                 ok(!strcmp_aw(prop.value, received) || broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
6927                         "Error: Expected %s but got %s on uri_tests[%d].\n",
6928                         prop.value, wine_dbgstr_w(received), i);
6929             }
6930             SysFreeString(received);
6931             received = NULL;
6932
6933             /* GetDomain() tests. */
6934             prop = test.str_props[Uri_PROPERTY_DOMAIN];
6935             hr = IUri_GetDomain(uri, &received);
6936             if(prop.todo) {
6937                 todo_wine {
6938                     ok(hr == prop.expected, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6939                             hr, prop.expected, i);
6940                 }
6941                 todo_wine {
6942                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6943                             prop.value, wine_dbgstr_w(received), i);
6944                 }
6945             } else {
6946                 ok(hr == prop.expected, "Error: GetDomain returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6947                         hr, prop.expected, i);
6948                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6949                         prop.value, wine_dbgstr_w(received), i);
6950             }
6951             SysFreeString(received);
6952             received = NULL;
6953
6954             /* GetExtension() tests. */
6955             prop = test.str_props[Uri_PROPERTY_EXTENSION];
6956             hr = IUri_GetExtension(uri, &received);
6957             if(prop.todo) {
6958                 todo_wine {
6959                     ok(hr == prop.expected, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6960                             hr, prop.expected, i);
6961                 }
6962                 todo_wine {
6963                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6964                             prop.value, wine_dbgstr_w(received), i);
6965                 }
6966             } else {
6967                 ok(hr == prop.expected, "Error: GetExtension returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6968                         hr, prop.expected, i);
6969                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6970                         prop.value, wine_dbgstr_w(received), i);
6971             }
6972             SysFreeString(received);
6973             received = NULL;
6974
6975             /* GetFragment() tests. */
6976             prop = test.str_props[Uri_PROPERTY_FRAGMENT];
6977             hr = IUri_GetFragment(uri, &received);
6978             if(prop.todo) {
6979                 todo_wine {
6980                     ok(hr == prop.expected, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6981                             hr, prop.expected, i);
6982                 }
6983                 todo_wine {
6984                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6985                             prop.value, wine_dbgstr_w(received), i);
6986                 }
6987             } else {
6988                 ok(hr == prop.expected, "Error: GetFragment returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
6989                         hr, prop.expected, i);
6990                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
6991                         prop.value, wine_dbgstr_w(received), i);
6992             }
6993             SysFreeString(received);
6994             received = NULL;
6995
6996             /* GetHost() tests. */
6997             prop = test.str_props[Uri_PROPERTY_HOST];
6998             hr = IUri_GetHost(uri, &received);
6999             if(prop.todo) {
7000                 todo_wine {
7001                     ok(hr == prop.expected, "Error: GetHost returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7002                             hr, prop.expected, i);
7003                 }
7004                 todo_wine {
7005                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7006                             prop.value, wine_dbgstr_w(received), i);
7007                 }
7008             } else {
7009                 ok(hr == prop.expected, "Error: GetHost returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7010                         hr, prop.expected, i);
7011                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7012                         prop.value, wine_dbgstr_w(received), i);
7013             }
7014             SysFreeString(received);
7015             received = NULL;
7016
7017             /* GetPassword() tests. */
7018             prop = test.str_props[Uri_PROPERTY_PASSWORD];
7019             hr = IUri_GetPassword(uri, &received);
7020             if(prop.todo) {
7021                 todo_wine {
7022                     ok(hr == prop.expected, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7023                             hr, prop.expected, i);
7024                 }
7025                 todo_wine {
7026                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7027                             prop.value, wine_dbgstr_w(received), i);
7028                 }
7029             } else {
7030                 ok(hr == prop.expected, "Error: GetPassword returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7031                         hr, prop.expected, i);
7032                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7033                         prop.value, wine_dbgstr_w(received), i);
7034             }
7035             SysFreeString(received);
7036             received = NULL;
7037
7038             /* GetPath() tests. */
7039             prop = test.str_props[Uri_PROPERTY_PATH];
7040             hr = IUri_GetPath(uri, &received);
7041             if(prop.todo) {
7042                 todo_wine {
7043                     ok(hr == prop.expected, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7044                             hr, prop.expected, i);
7045                 }
7046                 todo_wine {
7047                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7048                             prop.value, wine_dbgstr_w(received), i);
7049                 }
7050             } else {
7051                 ok(hr == prop.expected, "Error: GetPath returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7052                         hr, prop.expected, i);
7053                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7054                         prop.value, wine_dbgstr_w(received), i);
7055             }
7056             SysFreeString(received);
7057             received = NULL;
7058
7059             /* GetPathAndQuery() tests. */
7060             prop = test.str_props[Uri_PROPERTY_PATH_AND_QUERY];
7061             hr = IUri_GetPathAndQuery(uri, &received);
7062             if(prop.todo) {
7063                 todo_wine {
7064                     ok(hr == prop.expected, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7065                             hr, prop.expected, i);
7066                 }
7067                 todo_wine {
7068                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7069                             prop.value, wine_dbgstr_w(received), i);
7070                 }
7071             } else {
7072                 ok(hr == prop.expected, "Error: GetPathAndQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7073                         hr, prop.expected, i);
7074                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7075                         prop.value, wine_dbgstr_w(received), i);
7076             }
7077             SysFreeString(received);
7078             received = NULL;
7079
7080             /* GetQuery() tests. */
7081             prop = test.str_props[Uri_PROPERTY_QUERY];
7082             hr = IUri_GetQuery(uri, &received);
7083             if(prop.todo) {
7084                 todo_wine {
7085                     ok(hr == prop.expected, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7086                             hr, prop.expected, i);
7087                 }
7088                 todo_wine {
7089                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7090                             prop.value, wine_dbgstr_w(received), i);
7091                 }
7092             } else {
7093                 ok(hr == prop.expected, "Error: GetQuery returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7094                         hr, prop.expected, i);
7095                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7096                         prop.value, wine_dbgstr_w(received), i);
7097             }
7098             SysFreeString(received);
7099             received = NULL;
7100
7101             /* GetRawUri() tests. */
7102             prop = test.str_props[Uri_PROPERTY_RAW_URI];
7103             hr = IUri_GetRawUri(uri, &received);
7104             if(prop.todo) {
7105                 todo_wine {
7106                     ok(hr == prop.expected, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7107                             hr, prop.expected, i);
7108                 }
7109                 todo_wine {
7110                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7111                             prop.value, wine_dbgstr_w(received), i);
7112                 }
7113             } else {
7114                 ok(hr == prop.expected, "Error: GetRawUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7115                         hr, prop.expected, i);
7116                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7117                         prop.value, wine_dbgstr_w(received), i);
7118             }
7119             SysFreeString(received);
7120             received = NULL;
7121
7122             /* GetSchemeName() tests. */
7123             prop = test.str_props[Uri_PROPERTY_SCHEME_NAME];
7124             hr = IUri_GetSchemeName(uri, &received);
7125             if(prop.todo) {
7126                 todo_wine {
7127                     ok(hr == prop.expected, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7128                             hr, prop.expected, i);
7129                 }
7130                 todo_wine {
7131                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7132                             prop.value, wine_dbgstr_w(received), i);
7133                 }
7134             } else {
7135                 ok(hr == prop.expected, "Error: GetSchemeName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7136                         hr, prop.expected, i);
7137                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7138                         prop.value, wine_dbgstr_w(received), i);
7139             }
7140             SysFreeString(received);
7141             received = NULL;
7142
7143             /* GetUserInfo() tests. */
7144             prop = test.str_props[Uri_PROPERTY_USER_INFO];
7145             hr = IUri_GetUserInfo(uri, &received);
7146             if(prop.todo) {
7147                 todo_wine {
7148                     ok(hr == prop.expected, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7149                             hr, prop.expected, i);
7150                 }
7151                 todo_wine {
7152                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7153                             prop.value, wine_dbgstr_w(received), i);
7154                 }
7155             } else {
7156                 ok(hr == prop.expected, "Error: GetUserInfo returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7157                         hr, prop.expected, i);
7158                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7159                         prop.value, wine_dbgstr_w(received), i);
7160             }
7161             SysFreeString(received);
7162             received = NULL;
7163
7164             /* GetUserName() tests. */
7165             prop = test.str_props[Uri_PROPERTY_USER_NAME];
7166             hr = IUri_GetUserName(uri, &received);
7167             if(prop.todo) {
7168                 todo_wine {
7169                     ok(hr == prop.expected, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7170                             hr, prop.expected, i);
7171                 }
7172                 todo_wine {
7173                     ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7174                             prop.value, wine_dbgstr_w(received), i);
7175                 }
7176             } else {
7177                 ok(hr == prop.expected, "Error: GetUserName returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7178                         hr, prop.expected, i);
7179                 ok(!strcmp_aw(prop.value, received), "Error: Expected %s but got %s on uri_tests[%d].\n",
7180                         prop.value, wine_dbgstr_w(received), i);
7181             }
7182             SysFreeString(received);
7183         }
7184
7185         if(uri) IUri_Release(uri);
7186
7187         heap_free(uriW);
7188     }
7189 }
7190
7191 static void test_IUri_GetDwordProperties(void) {
7192     IUri *uri = NULL;
7193     HRESULT hr;
7194     DWORD i;
7195
7196     /* Make sure all the 'Get*' dword property functions handle invalid args correctly. */
7197     hr = pCreateUri(http_urlW, 0, 0, &uri);
7198     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7199     if(SUCCEEDED(hr)) {
7200         hr = IUri_GetHostType(uri, NULL);
7201         ok(hr == E_INVALIDARG, "Error: GetHostType returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7202
7203         hr = IUri_GetPort(uri, NULL);
7204         ok(hr == E_INVALIDARG, "Error: GetPort returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7205
7206         hr = IUri_GetScheme(uri, NULL);
7207         ok(hr == E_INVALIDARG, "Error: GetScheme returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7208
7209         hr = IUri_GetZone(uri, NULL);
7210         ok(hr == E_INVALIDARG, "Error: GetZone returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7211     }
7212     if(uri) IUri_Release(uri);
7213
7214     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7215         uri_properties test = uri_tests[i];
7216         LPWSTR uriW;
7217         uri = NULL;
7218
7219         uriW = a2w(test.uri);
7220         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7221         if(test.create_todo) {
7222             todo_wine {
7223                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7224                         hr, test.create_expected, i);
7225             }
7226         } else {
7227             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7228                     hr, test.create_expected, i);
7229         }
7230
7231         if(SUCCEEDED(hr)) {
7232             uri_dword_property prop;
7233             DWORD received;
7234
7235             /* Assign an insane value so tests don't accidentally pass when
7236              * they shouldn't!
7237              */
7238             received = -9999999;
7239
7240             /* GetHostType() tests. */
7241             prop = test.dword_props[Uri_PROPERTY_HOST_TYPE-Uri_PROPERTY_DWORD_START];
7242             hr = IUri_GetHostType(uri, &received);
7243             if(prop.todo) {
7244                 todo_wine {
7245                     ok(hr == prop.expected, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7246                             hr, prop.expected, i);
7247                 }
7248                 todo_wine {
7249                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7250                 }
7251             } else {
7252                 ok(hr == prop.expected, "Error: GetHostType returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7253                         hr, prop.expected, i);
7254                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7255             }
7256             received = -9999999;
7257
7258             /* GetPort() tests. */
7259             prop = test.dword_props[Uri_PROPERTY_PORT-Uri_PROPERTY_DWORD_START];
7260             hr = IUri_GetPort(uri, &received);
7261             if(prop.todo) {
7262                 todo_wine {
7263                     ok(hr == prop.expected, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7264                             hr, prop.expected, i);
7265                 }
7266                 todo_wine {
7267                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7268                 }
7269             } else {
7270                 ok(hr == prop.expected, "Error: GetPort returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7271                         hr, prop.expected, i);
7272                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7273             }
7274             received = -9999999;
7275
7276             /* GetScheme() tests. */
7277             prop = test.dword_props[Uri_PROPERTY_SCHEME-Uri_PROPERTY_DWORD_START];
7278             hr = IUri_GetScheme(uri, &received);
7279             if(prop.todo) {
7280                 todo_wine {
7281                     ok(hr == prop.expected, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7282                             hr, prop.expected, i);
7283                 }
7284                 todo_wine {
7285                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7286                 }
7287             } else {
7288                 ok(hr == prop.expected, "Error: GetScheme returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7289                         hr, prop.expected, i);
7290                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7291             }
7292             received = -9999999;
7293
7294             /* GetZone() tests. */
7295             prop = test.dword_props[Uri_PROPERTY_ZONE-Uri_PROPERTY_DWORD_START];
7296             hr = IUri_GetZone(uri, &received);
7297             if(prop.todo) {
7298                 todo_wine {
7299                     ok(hr == prop.expected, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7300                             hr, prop.expected, i);
7301                 }
7302                 todo_wine {
7303                     ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7304                 }
7305             } else {
7306                 ok(hr == prop.expected, "Error: GetZone returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7307                         hr, prop.expected, i);
7308                 ok(received == prop.value, "Error: Expected %d but got %d on uri_tests[%d].\n", prop.value, received, i);
7309             }
7310         }
7311
7312         if(uri) IUri_Release(uri);
7313
7314         heap_free(uriW);
7315     }
7316 }
7317
7318 static void test_IUri_GetPropertyLength(void) {
7319     IUri *uri = NULL;
7320     HRESULT hr;
7321     DWORD i;
7322
7323     /* Make sure it handles invalid args correctly. */
7324     hr = pCreateUri(http_urlW, 0, 0, &uri);
7325     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7326     if(SUCCEEDED(hr)) {
7327         DWORD received = 0xdeadbeef;
7328
7329         hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_STRING_START, NULL, 0);
7330         ok(hr == E_INVALIDARG, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7331
7332         hr = IUri_GetPropertyLength(uri, Uri_PROPERTY_DWORD_START, &received, 0);
7333         ok(hr == E_INVALIDARG, "Error: GetPropertyLength return 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7334         ok(received == 0xdeadbeef, "Error: Expected 0xdeadbeef but got 0x%08x.\n", received);
7335     }
7336     if(uri) IUri_Release(uri);
7337
7338     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7339         uri_properties test = uri_tests[i];
7340         LPWSTR uriW;
7341         uri = NULL;
7342
7343         uriW = a2w(test.uri);
7344         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7345         if(test.create_todo) {
7346             todo_wine {
7347                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_tests[%d].\n",
7348                         hr, test.create_expected, i);
7349             }
7350         } else {
7351             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_test[%d].\n",
7352                     hr, test.create_expected, i);
7353         }
7354
7355         if(SUCCEEDED(hr)) {
7356             DWORD j;
7357
7358             for(j = Uri_PROPERTY_STRING_START; j <= Uri_PROPERTY_STRING_LAST; ++j) {
7359                 DWORD expectedLen, brokenLen, receivedLen;
7360                 uri_str_property prop = test.str_props[j];
7361
7362                 expectedLen = lstrlen(prop.value);
7363                 brokenLen = lstrlen(prop.broken_value);
7364
7365                 /* This won't be necessary once GetPropertyLength is implemented. */
7366                 receivedLen = -1;
7367
7368                 hr = IUri_GetPropertyLength(uri, j, &receivedLen, 0);
7369                 if(prop.todo) {
7370                     todo_wine {
7371                         ok(hr == prop.expected, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
7372                                 hr, prop.expected, i, j);
7373                     }
7374                     todo_wine {
7375                         ok(receivedLen == expectedLen || broken(receivedLen == brokenLen),
7376                                 "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
7377                                 expectedLen, receivedLen, i, j);
7378                     }
7379                 } else {
7380                     ok(hr == prop.expected, "Error: GetPropertyLength returned 0x%08x, expected 0x%08x on uri_tests[%d].str_props[%d].\n",
7381                             hr, prop.expected, i, j);
7382                     ok(receivedLen == expectedLen || broken(receivedLen == brokenLen),
7383                             "Error: Expected a length of %d but got %d on uri_tests[%d].str_props[%d].\n",
7384                             expectedLen, receivedLen, i, j);
7385                 }
7386             }
7387         }
7388
7389         if(uri) IUri_Release(uri);
7390
7391         heap_free(uriW);
7392     }
7393 }
7394
7395 static DWORD compute_expected_props(uri_properties *test)
7396 {
7397     DWORD ret = 0, i;
7398
7399     for(i=Uri_PROPERTY_STRING_START; i <= Uri_PROPERTY_STRING_LAST; i++) {
7400         if(test->str_props[i-Uri_PROPERTY_STRING_START].expected == S_OK)
7401             ret |= 1<<i;
7402     }
7403
7404     for(i=Uri_PROPERTY_DWORD_START; i <= Uri_PROPERTY_DWORD_LAST; i++) {
7405         if(test->dword_props[i-Uri_PROPERTY_DWORD_START].expected == S_OK)
7406             ret |= 1<<i;
7407     }
7408
7409     return ret;
7410 }
7411
7412 static void test_IUri_GetProperties(void) {
7413     IUri *uri = NULL;
7414     HRESULT hr;
7415     DWORD i;
7416
7417     hr = pCreateUri(http_urlW, 0, 0, &uri);
7418     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7419     if(SUCCEEDED(hr)) {
7420         hr = IUri_GetProperties(uri, NULL);
7421         ok(hr == E_INVALIDARG, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7422     }
7423     if(uri) IUri_Release(uri);
7424
7425     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7426         uri_properties test = uri_tests[i];
7427         LPWSTR uriW;
7428         uri = NULL;
7429
7430         uriW = a2w(test.uri);
7431         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7432         if(test.create_todo) {
7433             todo_wine {
7434                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7435             }
7436         } else {
7437             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7438         }
7439
7440         if(SUCCEEDED(hr)) {
7441             DWORD received = 0, expected_props;
7442             DWORD j;
7443
7444             hr = IUri_GetProperties(uri, &received);
7445             ok(hr == S_OK, "Error: GetProperties returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7446
7447             expected_props = compute_expected_props(&test);
7448
7449             for(j = 0; j <= Uri_PROPERTY_DWORD_LAST; ++j) {
7450                 /* (1 << j) converts a Uri_PROPERTY to its corresponding Uri_HAS_* flag mask. */
7451                 if(expected_props & (1 << j))
7452                     ok(received & (1 << j), "Error: Expected flag for property %d on uri_tests[%d].\n", j, i);
7453                 else
7454                     ok(!(received & (1 << j)), "Error: Received flag for property %d when not expected on uri_tests[%d].\n", j, i);
7455             }
7456         }
7457
7458         if(uri) IUri_Release(uri);
7459
7460         heap_free(uriW);
7461     }
7462 }
7463
7464 static void test_IUri_HasProperty(void) {
7465     IUri *uri = NULL;
7466     HRESULT hr;
7467     DWORD i;
7468
7469     hr = pCreateUri(http_urlW, 0, 0, &uri);
7470     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7471     if(SUCCEEDED(hr)) {
7472         hr = IUri_HasProperty(uri, Uri_PROPERTY_RAW_URI, NULL);
7473         ok(hr == E_INVALIDARG, "Error: HasProperty returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7474     }
7475     if(uri) IUri_Release(uri);
7476
7477     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
7478         uri_properties test = uri_tests[i];
7479         LPWSTR uriW;
7480         uri = NULL;
7481
7482         uriW = a2w(test.uri);
7483
7484         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
7485         if(test.create_todo) {
7486             todo_wine {
7487                 ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7488             }
7489         } else {
7490             ok(hr == test.create_expected, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, test.create_expected);
7491         }
7492
7493         if(SUCCEEDED(hr)) {
7494             DWORD expected_props, j;
7495
7496             expected_props = compute_expected_props(&test);
7497
7498             for(j = 0; j <= Uri_PROPERTY_DWORD_LAST; ++j) {
7499                 /* Assign -1, then explicitly test for TRUE or FALSE later. */
7500                 BOOL received = -1;
7501
7502                 hr = IUri_HasProperty(uri, j, &received);
7503                 ok(hr == S_OK, "Error: HasProperty returned 0x%08x, expected 0x%08x for property %d on uri_tests[%d].\n",
7504                         hr, S_OK, j, i);
7505
7506                 if(expected_props & (1 << j)) {
7507                     ok(received == TRUE, "Error: Expected to have property %d on uri_tests[%d].\n", j, i);
7508                 } else {
7509                     ok(received == FALSE, "Error: Wasn't expecting to have property %d on uri_tests[%d].\n", j, i);
7510                 }
7511             }
7512         }
7513
7514         if(uri) IUri_Release(uri);
7515
7516         heap_free(uriW);
7517     }
7518 }
7519
7520 static void test_IUri_IsEqual(void) {
7521     IUri *uriA, *uriB;
7522     HRESULT hrA, hrB;
7523     DWORD i;
7524
7525     uriA = uriB = NULL;
7526
7527     /* Make sure IsEqual handles invalid args correctly. */
7528     hrA = pCreateUri(http_urlW, 0, 0, &uriA);
7529     hrB = pCreateUri(http_urlW, 0, 0, &uriB);
7530     ok(hrA == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hrA, S_OK);
7531     ok(hrB == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hrB, S_OK);
7532     if(SUCCEEDED(hrA) && SUCCEEDED(hrB)) {
7533         BOOL equal = -1;
7534         hrA = IUri_IsEqual(uriA, NULL, &equal);
7535         ok(hrA == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x.\n", hrA, S_OK);
7536         ok(equal == FALSE, "Error: Expected equal to be FALSE, but was %d instead.\n", equal);
7537
7538         hrA = IUri_IsEqual(uriA, uriB, NULL);
7539         ok(hrA == E_POINTER, "Error: IsEqual returned 0x%08x, expected 0x%08x.\n", hrA, E_POINTER);
7540     }
7541     if(uriA) IUri_Release(uriA);
7542     if(uriB) IUri_Release(uriB);
7543
7544     for(i = 0; i < sizeof(equality_tests)/sizeof(equality_tests[0]); ++i) {
7545         uri_equality test = equality_tests[i];
7546         LPWSTR uriA_W, uriB_W;
7547
7548         uriA = uriB = NULL;
7549
7550         uriA_W = a2w(test.a);
7551         uriB_W = a2w(test.b);
7552
7553         hrA = pCreateUri(uriA_W, test.create_flags_a, 0, &uriA);
7554         if(test.create_todo_a) {
7555             todo_wine {
7556                 ok(hrA == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].a\n",
7557                         hrA, S_OK, i);
7558             }
7559         } else {
7560             ok(hrA == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].a\n",
7561                     hrA, S_OK, i);
7562         }
7563
7564         hrB = pCreateUri(uriB_W, test.create_flags_b, 0, &uriB);
7565         if(test.create_todo_b) {
7566             todo_wine {
7567                 ok(hrB == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].b\n",
7568                         hrB, S_OK, i);
7569             }
7570         } else {
7571             ok(hrB == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on equality_tests[%d].b\n",
7572                     hrB, S_OK, i);
7573         }
7574
7575         if(SUCCEEDED(hrA) && SUCCEEDED(hrB)) {
7576             BOOL equal = -1;
7577
7578             hrA = IUri_IsEqual(uriA, uriB, &equal);
7579             if(test.todo) {
7580                 todo_wine {
7581                     ok(hrA == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x on equality_tests[%d].\n",
7582                             hrA, S_OK, i);
7583                 }
7584                 todo_wine {
7585                     ok(equal == test.equal, "Error: Expected the comparison to be %d on equality_tests[%d].\n", test.equal, i);
7586                 }
7587             } else {
7588                 ok(hrA == S_OK, "Error: IsEqual returned 0x%08x, expected 0x%08x on equality_tests[%d].\n", hrA, S_OK, i);
7589                 ok(equal == test.equal, "Error: Expected the comparison to be %d on equality_tests[%d].\n", test.equal, i);
7590             }
7591         }
7592         if(uriA) IUri_Release(uriA);
7593         if(uriB) IUri_Release(uriB);
7594
7595         heap_free(uriA_W);
7596         heap_free(uriB_W);
7597     }
7598 }
7599
7600 static void test_CreateUriWithFragment_InvalidArgs(void) {
7601     HRESULT hr;
7602     IUri *uri = (void*) 0xdeadbeef;
7603     const WCHAR fragmentW[] = {'#','f','r','a','g','m','e','n','t',0};
7604
7605     hr = pCreateUriWithFragment(NULL, fragmentW, 0, 0, &uri);
7606     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7607     ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7608
7609     hr = pCreateUriWithFragment(http_urlW, fragmentW, 0, 0, NULL);
7610     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7611
7612     /* Original URI can't already contain a fragment component. */
7613     uri = (void*) 0xdeadbeef;
7614     hr = pCreateUriWithFragment(http_url_fragW, fragmentW, 0, 0, &uri);
7615     ok(hr == E_INVALIDARG, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
7616     ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7617 }
7618
7619 /* CreateUriWithFragment has the same invalid flag combinations as CreateUri. */
7620 static void test_CreateUriWithFragment_InvalidFlags(void) {
7621     DWORD i;
7622
7623     for(i = 0; i < sizeof(invalid_flag_tests)/sizeof(invalid_flag_tests[0]); ++i) {
7624         HRESULT hr;
7625         IUri *uri = (void*) 0xdeadbeef;
7626
7627         hr = pCreateUriWithFragment(http_urlW, NULL, invalid_flag_tests[i].flags, 0, &uri);
7628         ok(hr == invalid_flag_tests[i].expected, "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x. flags=0x%08x.\n",
7629             hr, invalid_flag_tests[i].expected, invalid_flag_tests[i].flags);
7630         ok(uri == NULL, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
7631     }
7632 }
7633
7634 static void test_CreateUriWithFragment(void) {
7635     DWORD i;
7636
7637     for(i = 0; i < sizeof(uri_fragment_tests)/sizeof(uri_fragment_tests[0]); ++i) {
7638         HRESULT hr;
7639         IUri *uri = NULL;
7640         LPWSTR uriW, fragW;
7641         uri_with_fragment test = uri_fragment_tests[i];
7642
7643         uriW = a2w(test.uri);
7644         fragW = a2w(test.fragment);
7645
7646         hr = pCreateUriWithFragment(uriW, fragW, test.create_flags, 0, &uri);
7647         if(test.expected_todo) {
7648             todo_wine {
7649                 ok(hr == test.create_expected,
7650                     "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7651                     hr, test.create_expected, i);
7652             }
7653         } else
7654             ok(hr == test.create_expected,
7655                 "Error: CreateUriWithFragment returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7656                 hr, test.create_expected, i);
7657
7658         if(SUCCEEDED(hr)) {
7659             BSTR received = NULL;
7660
7661             hr = IUri_GetAbsoluteUri(uri, &received);
7662             if(test.expected_todo) {
7663                 todo_wine {
7664                     ok(hr == S_OK,
7665                         "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7666                         hr, S_OK, i);
7667                 }
7668                 todo_wine {
7669                     ok(!strcmp_aw(test.expected_uri, received),
7670                         "Error: Expected %s but got %s on uri_fragment_tests[%d].\n",
7671                         test.expected_uri, wine_dbgstr_w(received), i);
7672                 }
7673             } else {
7674                 ok(hr == S_OK, "Error: GetAbsoluteUri returned 0x%08x, expected 0x%08x on uri_fragment_tests[%d].\n",
7675                     hr, S_OK, i);
7676                 ok(!strcmp_aw(test.expected_uri, received), "Error: Expected %s but got %s on uri_fragment_tests[%d].\n",
7677                     test.expected_uri, wine_dbgstr_w(received), i);
7678             }
7679
7680             SysFreeString(received);
7681         }
7682
7683         if(uri) IUri_Release(uri);
7684         heap_free(uriW);
7685         heap_free(fragW);
7686     }
7687 }
7688
7689 static void test_CreateIUriBuilder(void) {
7690     HRESULT hr;
7691     IUriBuilder *builder = NULL;
7692     IUri *uri;
7693
7694     hr = pCreateIUriBuilder(NULL, 0, 0, NULL);
7695     ok(hr == E_POINTER, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x\n",
7696         hr, E_POINTER);
7697
7698     /* CreateIUriBuilder increases the ref count of the IUri it receives. */
7699     hr = pCreateUri(http_urlW, 0, 0, &uri);
7700     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7701     if(SUCCEEDED(hr)) {
7702         ULONG cur_count, orig_count;
7703
7704         orig_count = get_refcnt(uri);
7705         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
7706         ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7707         ok(builder != NULL, "Error: Expecting builder not to be NULL\n");
7708
7709         cur_count = get_refcnt(uri);
7710         ok(cur_count == orig_count+1, "Error: Expected the ref count to be %u, but was %u instead.\n", orig_count+1, cur_count);
7711
7712         if(builder) IUriBuilder_Release(builder);
7713         cur_count = get_refcnt(uri);
7714         ok(cur_count == orig_count, "Error: Expected the ref count to be %u, but was %u instead.\n", orig_count, cur_count);
7715     }
7716     if(uri) IUri_Release(uri);
7717 }
7718
7719 static void test_IUriBuilder_CreateUri(IUriBuilder *builder, const uri_builder_test *test,
7720                                        DWORD test_index) {
7721     HRESULT hr;
7722     IUri *uri = NULL;
7723
7724     hr = IUriBuilder_CreateUri(builder, test->uri_flags, 0, 0, &uri);
7725     if(test->uri_todo) {
7726         todo_wine {
7727             ok(hr == test->uri_hres,
7728                 "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7729                 hr, test->uri_hres, test_index);
7730         }
7731     } else {
7732         ok(hr == test->uri_hres,
7733             "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7734             hr, test->uri_hres, test_index);
7735     }
7736
7737     if(SUCCEEDED(hr)) {
7738         DWORD i;
7739
7740         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
7741             uri_builder_str_property prop = test->expected_str_props[i];
7742             BSTR received = NULL;
7743
7744             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
7745             if(prop.todo) {
7746                 todo_wine {
7747                     ok(hr == prop.result,
7748                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7749                         hr, prop.result, test_index, i);
7750                 }
7751             } else {
7752                 ok(hr == prop.result,
7753                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7754                     hr, prop.result, test_index, i);
7755             }
7756             if(SUCCEEDED(hr)) {
7757                 if(prop.todo) {
7758                     todo_wine {
7759                         ok(!strcmp_aw(prop.expected, received),
7760                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7761                             prop.expected, wine_dbgstr_w(received), test_index, i);
7762                     }
7763                 } else {
7764                     ok(!strcmp_aw(prop.expected, received),
7765                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7766                         prop.expected, wine_dbgstr_w(received), test_index, i);
7767                 }
7768             }
7769             SysFreeString(received);
7770         }
7771
7772         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
7773             uri_builder_dword_property prop = test->expected_dword_props[i];
7774             DWORD received = -2;
7775
7776             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
7777             if(prop.todo) {
7778                 todo_wine {
7779                     ok(hr == prop.result,
7780                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7781                         hr, prop.result, test_index, i);
7782                 }
7783             } else {
7784                 ok(hr == prop.result,
7785                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7786                     hr, prop.result, test_index, i);
7787             }
7788             if(SUCCEEDED(hr)) {
7789                 if(prop.todo) {
7790                     todo_wine {
7791                         ok(received == prop.expected,
7792                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7793                             prop.expected, received, test_index, i);
7794                     }
7795                 } else {
7796                     ok(received == prop.expected,
7797                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7798                         prop.expected, received, test_index, i);
7799                 }
7800             }
7801         }
7802     }
7803     if(uri) IUri_Release(uri);
7804 }
7805
7806 static void test_IUriBuilder_CreateUriSimple(IUriBuilder *builder, const uri_builder_test *test,
7807                                        DWORD test_index) {
7808     HRESULT hr;
7809     IUri *uri = NULL;
7810
7811     hr = IUriBuilder_CreateUriSimple(builder, test->uri_simple_encode_flags, 0, &uri);
7812     if(test->uri_simple_todo) {
7813         todo_wine {
7814             ok(hr == test->uri_simple_hres,
7815                 "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7816                 hr, test->uri_simple_hres, test_index);
7817         }
7818     } else {
7819         ok(hr == test->uri_simple_hres,
7820             "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7821             hr, test->uri_simple_hres, test_index);
7822     }
7823
7824     if(SUCCEEDED(hr)) {
7825         DWORD i;
7826
7827         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
7828             uri_builder_str_property prop = test->expected_str_props[i];
7829             BSTR received = NULL;
7830
7831             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
7832             if(prop.todo) {
7833                 todo_wine {
7834                     ok(hr == prop.result,
7835                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7836                         hr, prop.result, test_index, i);
7837                 }
7838             } else {
7839                 ok(hr == prop.result,
7840                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7841                     hr, prop.result, test_index, i);
7842             }
7843             if(SUCCEEDED(hr)) {
7844                 if(prop.todo) {
7845                     todo_wine {
7846                         ok(!strcmp_aw(prop.expected, received),
7847                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7848                             prop.expected, wine_dbgstr_w(received), test_index, i);
7849                     }
7850                 } else {
7851                     ok(!strcmp_aw(prop.expected, received),
7852                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7853                         prop.expected, wine_dbgstr_w(received), test_index, i);
7854                 }
7855             }
7856             SysFreeString(received);
7857         }
7858
7859         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
7860             uri_builder_dword_property prop = test->expected_dword_props[i];
7861             DWORD received = -2;
7862
7863             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
7864             if(prop.todo) {
7865                 todo_wine {
7866                     ok(hr == prop.result,
7867                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7868                         hr, prop.result, test_index, i);
7869                 }
7870             } else {
7871                 ok(hr == prop.result,
7872                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7873                     hr, prop.result, test_index, i);
7874             }
7875             if(SUCCEEDED(hr)) {
7876                 if(prop.todo) {
7877                     todo_wine {
7878                         ok(received == prop.expected,
7879                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7880                             prop.expected, received, test_index, i);
7881                     }
7882                 } else {
7883                     ok(received == prop.expected,
7884                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7885                         prop.expected, received, test_index, i);
7886                 }
7887             }
7888         }
7889     }
7890     if(uri) IUri_Release(uri);
7891 }
7892
7893 static void test_IUriBuilder_CreateUriWithFlags(IUriBuilder *builder, const uri_builder_test *test,
7894                                                 DWORD test_index) {
7895     HRESULT hr;
7896     IUri *uri = NULL;
7897
7898     hr = IUriBuilder_CreateUriWithFlags(builder, test->uri_with_flags, test->uri_with_builder_flags,
7899                                         test->uri_with_encode_flags, 0, &uri);
7900     if(test->uri_with_todo) {
7901         todo_wine {
7902             ok(hr == test->uri_with_hres,
7903                 "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7904                 hr, test->uri_with_hres, test_index);
7905         }
7906     } else {
7907         ok(hr == test->uri_with_hres,
7908             "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
7909             hr, test->uri_with_hres, test_index);
7910     }
7911
7912     if(SUCCEEDED(hr)) {
7913         DWORD i;
7914
7915         for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
7916             uri_builder_str_property prop = test->expected_str_props[i];
7917             BSTR received = NULL;
7918
7919             hr = IUri_GetPropertyBSTR(uri, i, &received, 0);
7920             if(prop.todo) {
7921                 todo_wine {
7922                     ok(hr == prop.result,
7923                         "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7924                         hr, prop.result, test_index, i);
7925                 }
7926             } else {
7927                 ok(hr == prop.result,
7928                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_str_props[%d].\n",
7929                     hr, prop.result, test_index, i);
7930             }
7931             if(SUCCEEDED(hr)) {
7932                 if(prop.todo) {
7933                     todo_wine {
7934                         ok(!strcmp_aw(prop.expected, received),
7935                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7936                             prop.expected, wine_dbgstr_w(received), test_index, i);
7937                     }
7938                 } else {
7939                     ok(!strcmp_aw(prop.expected, received),
7940                         "Error: Expected %s but got %s instead on uri_builder_tests[%d].expected_str_props[%d].\n",
7941                         prop.expected, wine_dbgstr_w(received), test_index, i);
7942                 }
7943             }
7944             SysFreeString(received);
7945         }
7946
7947         for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
7948             uri_builder_dword_property prop = test->expected_dword_props[i];
7949             DWORD received = -2;
7950
7951             hr = IUri_GetPropertyDWORD(uri, i+Uri_PROPERTY_DWORD_START, &received, 0);
7952             if(prop.todo) {
7953                 todo_wine {
7954                     ok(hr == prop.result,
7955                         "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7956                         hr, prop.result, test_index, i);
7957                 }
7958             } else {
7959                 ok(hr == prop.result,
7960                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].expected_dword_props[%d].\n",
7961                     hr, prop.result, test_index, i);
7962             }
7963             if(SUCCEEDED(hr)) {
7964                 if(prop.todo) {
7965                     todo_wine {
7966                         ok(received == prop.expected,
7967                             "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7968                             prop.expected, received, test_index, i);
7969                     }
7970                 } else {
7971                     ok(received == prop.expected,
7972                         "Error: Expected %d but got %d instead on uri_builder_tests[%d].expected_dword_props[%d].\n",
7973                         prop.expected, received, test_index, i);
7974                 }
7975             }
7976         }
7977     }
7978     if(uri) IUri_Release(uri);
7979 }
7980
7981 static void test_IUriBuilder_CreateInvalidArgs(void) {
7982     IUriBuilder *builder;
7983     HRESULT hr;
7984
7985     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
7986     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
7987     if(SUCCEEDED(hr)) {
7988         IUri *test = NULL, *uri = (void*) 0xdeadbeef;
7989
7990         /* Test what happens if the IUriBuilder doesn't have a IUri set. */
7991         hr = IUriBuilder_CreateUri(builder, 0, 0, 0, NULL);
7992         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
7993
7994         uri = (void*) 0xdeadbeef;
7995         hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
7996         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, E_NOTIMPL);
7997         ok(uri == NULL, "Error: expected uri to be NULL, but was %p instead.\n", uri);
7998
7999         hr = IUriBuilder_CreateUriSimple(builder, 0, 0, NULL);
8000         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
8001             hr, E_POINTER);
8002
8003         uri = (void*) 0xdeadbeef;
8004         hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
8005         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
8006             hr, E_NOTIMPL);
8007         ok(!uri, "Error: Expected uri to NULL, but was %p instead.\n", uri);
8008
8009         hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, NULL);
8010         ok(hr == E_POINTER, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
8011             hr, E_POINTER);
8012
8013         uri = (void*) 0xdeadbeef;
8014         hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, Uri_HAS_USER_NAME, 0, &uri);
8015         ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
8016             hr, E_NOTIMPL);
8017         ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
8018
8019         hr = pCreateUri(http_urlW, 0, 0, &test);
8020         ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8021         if(SUCCEEDED(hr)) {
8022             hr = IUriBuilder_SetIUri(builder, test);
8023             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8024
8025             /* No longer returns E_NOTIMPL, since a IUri has been set and hasn't been modified. */
8026             uri = NULL;
8027             hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
8028             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8029             ok(uri != NULL, "Error: The uri was NULL.\n");
8030             if(uri) IUri_Release(uri);
8031
8032             uri = NULL;
8033             hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
8034             ok(hr == S_OK, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
8035                 hr, S_OK);
8036             ok(uri != NULL, "Error: uri was NULL.\n");
8037             if(uri) IUri_Release(uri);
8038
8039             uri = NULL;
8040             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, &uri);
8041             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
8042                 hr, S_OK);
8043             ok(uri != NULL, "Error: uri was NULL.\n");
8044             if(uri) IUri_Release(uri);
8045
8046             hr = IUriBuilder_SetFragment(builder, NULL);
8047             ok(hr == S_OK, "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8048
8049             /* The IUriBuilder is changed, so it returns E_NOTIMPL again. */
8050             uri = (void*) 0xdeadbeef;
8051             hr = IUriBuilder_CreateUri(builder, 0, Uri_HAS_USER_NAME, 0, &uri);
8052             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8053             ok(!uri, "Error: Expected uri to be NULL but was %p instead.\n", uri);
8054
8055             uri = (void*) 0xdeadbeef;
8056             hr = IUriBuilder_CreateUriSimple(builder, Uri_HAS_USER_NAME, 0, &uri);
8057             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n",
8058                 hr, S_OK);
8059             ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
8060
8061             uri = (void*) 0xdeadbeef;
8062             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, Uri_HAS_USER_NAME, 0, &uri);
8063             ok(hr == E_NOTIMPL, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
8064                 hr, E_NOTIMPL);
8065             ok(!uri, "Error: Expected uri to be NULL, but was %p instead.\n", uri);
8066         }
8067         if(test) IUri_Release(test);
8068     }
8069     if(builder) IUriBuilder_Release(builder);
8070 }
8071
8072 /* Tests invalid args to the "Get*" functions. */
8073 static void test_IUriBuilder_GetInvalidArgs(void) {
8074     IUriBuilder *builder = NULL;
8075     HRESULT hr;
8076
8077     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
8078     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
8079     if(SUCCEEDED(hr)) {
8080         LPCWSTR received = (void*) 0xdeadbeef;
8081         DWORD len = -1, port = -1;
8082         BOOL set = -1;
8083
8084         hr = IUriBuilder_GetFragment(builder, NULL, NULL);
8085         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
8086             hr, E_POINTER);
8087         hr = IUriBuilder_GetFragment(builder, NULL, &received);
8088         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
8089             hr, E_POINTER);
8090         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8091         hr = IUriBuilder_GetFragment(builder, &len, NULL);
8092         ok(hr == E_POINTER, "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x.\n",
8093             hr, E_POINTER);
8094         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8095
8096         hr = IUriBuilder_GetHost(builder, NULL, NULL);
8097         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
8098             hr, E_POINTER);
8099         received = (void*) 0xdeadbeef;
8100         hr = IUriBuilder_GetHost(builder, NULL, &received);
8101         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
8102             hr, E_POINTER);
8103         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8104         len = -1;
8105         hr = IUriBuilder_GetHost(builder, &len, NULL);
8106         ok(hr == E_POINTER, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n",
8107             hr, E_POINTER);
8108         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8109
8110         hr = IUriBuilder_GetPassword(builder, NULL, NULL);
8111         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
8112             hr, E_POINTER);
8113         received = (void*) 0xdeadbeef;
8114         hr = IUriBuilder_GetPassword(builder, NULL, &received);
8115         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
8116             hr, E_POINTER);
8117         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8118         len = -1;
8119         hr = IUriBuilder_GetPassword(builder, &len, NULL);
8120         ok(hr == E_POINTER, "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x.\n",
8121             hr, E_POINTER);
8122         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8123
8124         hr = IUriBuilder_GetPath(builder, NULL, NULL);
8125         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
8126             hr, E_POINTER);
8127         received = (void*) 0xdeadbeef;
8128         hr = IUriBuilder_GetPath(builder, NULL, &received);
8129         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
8130             hr, E_POINTER);
8131         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8132         len = -1;
8133         hr = IUriBuilder_GetPath(builder, &len, NULL);
8134         ok(hr == E_POINTER, "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x.\n",
8135             hr, E_POINTER);
8136         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8137
8138         hr = IUriBuilder_GetPort(builder, NULL, NULL);
8139         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
8140             hr, E_POINTER);
8141         hr = IUriBuilder_GetPort(builder, NULL, &port);
8142         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
8143             hr, E_POINTER);
8144         ok(!port, "Error: Expected port to be 0, but was %d instead.\n", port);
8145         hr = IUriBuilder_GetPort(builder, &set, NULL);
8146         ok(hr == E_POINTER, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n",
8147             hr, E_POINTER);
8148         ok(!set, "Error: Expected set to be FALSE, but was %d instead.\n", set);
8149
8150         hr = IUriBuilder_GetQuery(builder, NULL, NULL);
8151         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
8152             hr, E_POINTER);
8153         received = (void*) 0xdeadbeef;
8154         hr = IUriBuilder_GetQuery(builder, NULL, &received);
8155         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
8156             hr, E_POINTER);
8157         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8158         len = -1;
8159         hr = IUriBuilder_GetQuery(builder, &len, NULL);
8160         ok(hr == E_POINTER, "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x.\n",
8161             hr, E_POINTER);
8162         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8163
8164         hr = IUriBuilder_GetSchemeName(builder, NULL, NULL);
8165         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
8166             hr, E_POINTER);
8167         received = (void*) 0xdeadbeef;
8168         hr = IUriBuilder_GetSchemeName(builder, NULL, &received);
8169         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
8170             hr, E_POINTER);
8171         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8172         len = -1;
8173         hr = IUriBuilder_GetSchemeName(builder, &len, NULL);
8174         ok(hr == E_POINTER, "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x.\n",
8175             hr, E_POINTER);
8176         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8177
8178         hr = IUriBuilder_GetUserName(builder, NULL, NULL);
8179         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
8180             hr, E_POINTER);
8181         received = (void*) 0xdeadbeef;
8182         hr = IUriBuilder_GetUserName(builder, NULL, &received);
8183         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
8184             hr, E_POINTER);
8185         ok(!received, "Error: Expected received to be NULL, but was %p instead.\n", received);
8186         len = -1;
8187         hr = IUriBuilder_GetUserName(builder, &len, NULL);
8188         ok(hr == E_POINTER, "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x.\n",
8189             hr, E_POINTER);
8190         ok(!len, "Error: Expected len to be 0, but was %d instead.\n", len);
8191     }
8192     if(builder) IUriBuilder_Release(builder);
8193 }
8194
8195 static void test_IUriBuilder_GetFragment(IUriBuilder *builder, const uri_builder_test *test,
8196                                          DWORD test_index) {
8197     HRESULT hr;
8198     DWORD i;
8199     LPCWSTR received = NULL;
8200     DWORD len = -1;
8201     const uri_builder_property *prop = NULL;
8202
8203     /* Check if the property was set earlier. */
8204     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8205         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_FRAGMENT)
8206             prop = &(test->properties[i]);
8207     }
8208
8209     if(prop) {
8210         /* Use expected_value unless it's NULL, then use value. */
8211         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8212         hr = IUriBuilder_GetFragment(builder, &len, &received);
8213         if(prop->todo) {
8214             todo_wine {
8215                 ok(hr == (expected ? S_OK : S_FALSE),
8216                     "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8217                     hr, (expected ? S_OK : S_FALSE), test_index);
8218             }
8219             if(SUCCEEDED(hr)) {
8220                 todo_wine {
8221                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8222                         expected, wine_dbgstr_w(received), test_index);
8223                 }
8224                 todo_wine {
8225                     ok(lstrlen(expected) == len,
8226                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8227                         lstrlen(expected), len, test_index);
8228                 }
8229             }
8230         } else {
8231             ok(hr == (expected ? S_OK : S_FALSE),
8232                 "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8233                 hr, (expected ? S_OK : S_FALSE), test_index);
8234             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8235                 expected, wine_dbgstr_w(received), test_index);
8236             ok(lstrlen(expected) == len,
8237                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8238                 lstrlen(expected), len, test_index);
8239         }
8240     } else {
8241         /* The property wasn't set earlier, so it should return whatever
8242          * the base IUri contains (if anything).
8243          */
8244         IUri *uri = NULL;
8245         hr = IUriBuilder_GetIUri(builder, &uri);
8246         ok(hr == S_OK,
8247             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8248             hr, S_OK, test_index);
8249         if(SUCCEEDED(hr)) {
8250             if(!uri) {
8251                 received = (void*) 0xdeadbeef;
8252                 len = -1;
8253
8254                 hr = IUriBuilder_GetFragment(builder, &len, &received);
8255                 ok(hr == S_FALSE,
8256                     "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8257                     hr, S_FALSE, test_index);
8258                 if(SUCCEEDED(hr)) {
8259                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8260                         len, test_index);
8261                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8262                         received, test_index);
8263                 }
8264             } else {
8265                 BOOL has_prop = FALSE;
8266                 BSTR expected = NULL;
8267
8268                 hr = IUri_GetFragment(uri, &expected);
8269                 ok(SUCCEEDED(hr),
8270                     "Error: Expected IUri_GetFragment to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8271                     hr, test_index);
8272                 has_prop = hr == S_OK;
8273
8274                 hr = IUriBuilder_GetFragment(builder, &len, &received);
8275                 if(has_prop) {
8276                     ok(hr == S_OK,
8277                         "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8278                         hr, S_OK, test_index);
8279                     if(SUCCEEDED(hr)) {
8280                         ok(!lstrcmpW(expected, received),
8281                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8282                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8283                         ok(lstrlenW(expected) == len,
8284                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8285                             lstrlenW(expected), len, test_index);
8286                     }
8287                 } else {
8288                     ok(hr == S_FALSE,
8289                         "Error: IUriBuilder_GetFragment returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8290                         hr, S_FALSE, test_index);
8291                     if(SUCCEEDED(hr)) {
8292                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8293                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8294                             len, test_index);
8295                     }
8296                 }
8297                 SysFreeString(expected);
8298             }
8299         }
8300         if(uri) IUri_Release(uri);
8301     }
8302 }
8303
8304 static void test_IUriBuilder_GetHost(IUriBuilder *builder, const uri_builder_test *test,
8305                                      DWORD test_index) {
8306     HRESULT hr;
8307     DWORD i;
8308     LPCWSTR received = NULL;
8309     DWORD len = -1;
8310     const uri_builder_property *prop = NULL;
8311
8312     /* Check if the property was set earlier. */
8313     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8314         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_HOST)
8315             prop = &(test->properties[i]);
8316     }
8317
8318     if(prop) {
8319         /* Use expected_value unless it's NULL, then use value. */
8320         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8321         hr = IUriBuilder_GetHost(builder, &len, &received);
8322         if(prop->todo) {
8323             todo_wine {
8324                 ok(hr == (expected ? S_OK : S_FALSE),
8325                     "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8326                     hr, (expected ? S_OK : S_FALSE), test_index);
8327             }
8328             if(SUCCEEDED(hr)) {
8329                 todo_wine {
8330                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8331                         expected, wine_dbgstr_w(received), test_index);
8332                 }
8333                 todo_wine {
8334                     ok(lstrlen(expected) == len,
8335                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8336                         lstrlen(expected), len, test_index);
8337                 }
8338             }
8339         } else {
8340             ok(hr == (expected ? S_OK : S_FALSE),
8341                 "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8342                 hr, (expected ? S_OK : S_FALSE), test_index);
8343             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8344                 expected, wine_dbgstr_w(received), test_index);
8345             ok(lstrlen(expected) == len,
8346                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8347                 lstrlen(expected), len, test_index);
8348         }
8349     } else {
8350         /* The property wasn't set earlier, so it should return whatever
8351          * the base IUri contains (if anything).
8352          */
8353         IUri *uri = NULL;
8354         hr = IUriBuilder_GetIUri(builder, &uri);
8355         ok(hr == S_OK,
8356             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8357             hr, S_OK, test_index);
8358         if(SUCCEEDED(hr)) {
8359             if(!uri) {
8360                 received = (void*) 0xdeadbeef;
8361                 len = -1;
8362
8363                 hr = IUriBuilder_GetHost(builder, &len, &received);
8364                 ok(hr == S_FALSE,
8365                     "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8366                     hr, S_FALSE, test_index);
8367                 if(SUCCEEDED(hr)) {
8368                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8369                         len, test_index);
8370                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8371                         received, test_index);
8372                 }
8373             } else {
8374                 BOOL has_prop = FALSE;
8375                 BSTR expected = NULL;
8376
8377                 hr = IUri_GetHost(uri, &expected);
8378                 ok(SUCCEEDED(hr),
8379                     "Error: Expected IUri_GetHost to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8380                     hr, test_index);
8381                 has_prop = hr == S_OK;
8382
8383                 hr = IUriBuilder_GetHost(builder, &len, &received);
8384                 if(has_prop) {
8385                     ok(hr == S_OK,
8386                         "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8387                         hr, S_OK, test_index);
8388                     if(SUCCEEDED(hr)) {
8389                         ok(!lstrcmpW(expected, received),
8390                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8391                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8392                         ok(lstrlenW(expected) == len,
8393                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8394                             lstrlenW(expected), len, test_index);
8395                     }
8396                 } else {
8397                     ok(hr == S_FALSE,
8398                         "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8399                         hr, S_FALSE, test_index);
8400                     if(SUCCEEDED(hr)) {
8401                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8402                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8403                             len, test_index);
8404                     }
8405                 }
8406                 SysFreeString(expected);
8407             }
8408         }
8409         if(uri) IUri_Release(uri);
8410     }
8411 }
8412
8413 static void test_IUriBuilder_GetPassword(IUriBuilder *builder, const uri_builder_test *test,
8414                                          DWORD test_index) {
8415     HRESULT hr;
8416     DWORD i;
8417     LPCWSTR received = NULL;
8418     DWORD len = -1;
8419     const uri_builder_property *prop = NULL;
8420
8421     /* Check if the property was set earlier. */
8422     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8423         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_PASSWORD)
8424             prop = &(test->properties[i]);
8425     }
8426
8427     if(prop) {
8428         /* Use expected_value unless it's NULL, then use value. */
8429         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8430         hr = IUriBuilder_GetPassword(builder, &len, &received);
8431         if(prop->todo) {
8432             todo_wine {
8433                 ok(hr == (expected ? S_OK : S_FALSE),
8434                     "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8435                     hr, (expected ? S_OK : S_FALSE), test_index);
8436             }
8437             if(SUCCEEDED(hr)) {
8438                 todo_wine {
8439                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8440                         expected, wine_dbgstr_w(received), test_index);
8441                 }
8442                 todo_wine {
8443                     ok(lstrlen(expected) == len,
8444                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8445                         lstrlen(expected), len, test_index);
8446                 }
8447             }
8448         } else {
8449             ok(hr == (expected ? S_OK : S_FALSE),
8450                 "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8451                 hr, (expected ? S_OK : S_FALSE), test_index);
8452             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8453                 expected, wine_dbgstr_w(received), test_index);
8454             ok(lstrlen(expected) == len,
8455                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8456                 lstrlen(expected), len, test_index);
8457         }
8458     } else {
8459         /* The property wasn't set earlier, so it should return whatever
8460          * the base IUri contains (if anything).
8461          */
8462         IUri *uri = NULL;
8463         hr = IUriBuilder_GetIUri(builder, &uri);
8464         ok(hr == S_OK,
8465             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8466             hr, S_OK, test_index);
8467         if(SUCCEEDED(hr)) {
8468             if(!uri) {
8469                 received = (void*) 0xdeadbeef;
8470                 len = -1;
8471
8472                 hr = IUriBuilder_GetPassword(builder, &len, &received);
8473                 ok(hr == S_FALSE,
8474                     "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8475                     hr, S_FALSE, test_index);
8476                 if(SUCCEEDED(hr)) {
8477                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8478                         len, test_index);
8479                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8480                         received, test_index);
8481                 }
8482             } else {
8483                 BOOL has_prop = FALSE;
8484                 BSTR expected = NULL;
8485
8486                 hr = IUri_GetPassword(uri, &expected);
8487                 ok(SUCCEEDED(hr),
8488                     "Error: Expected IUri_GetPassword to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8489                     hr, test_index);
8490                 has_prop = hr == S_OK;
8491
8492                 hr = IUriBuilder_GetPassword(builder, &len, &received);
8493                 if(has_prop) {
8494                     ok(hr == S_OK,
8495                         "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8496                         hr, S_OK, test_index);
8497                     if(SUCCEEDED(hr)) {
8498                         ok(!lstrcmpW(expected, received),
8499                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8500                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8501                         ok(lstrlenW(expected) == len,
8502                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8503                             lstrlenW(expected), len, test_index);
8504                     }
8505                 } else {
8506                     ok(hr == S_FALSE,
8507                         "Error: IUriBuilder_GetPassword returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8508                         hr, S_FALSE, test_index);
8509                     if(SUCCEEDED(hr)) {
8510                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8511                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8512                             len, test_index);
8513                     }
8514                 }
8515                 SysFreeString(expected);
8516             }
8517         }
8518         if(uri) IUri_Release(uri);
8519     }
8520 }
8521
8522 static void test_IUriBuilder_GetPath(IUriBuilder *builder, const uri_builder_test *test,
8523                                      DWORD test_index) {
8524     HRESULT hr;
8525     DWORD i;
8526     LPCWSTR received = NULL;
8527     DWORD len = -1;
8528     const uri_builder_property *prop = NULL;
8529
8530     /* Check if the property was set earlier. */
8531     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8532         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_PATH)
8533             prop = &(test->properties[i]);
8534     }
8535
8536     if(prop) {
8537         /* Use expected_value unless it's NULL, then use value. */
8538         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8539         hr = IUriBuilder_GetPath(builder, &len, &received);
8540         if(prop->todo) {
8541             todo_wine {
8542                 ok(hr == (expected ? S_OK : S_FALSE),
8543                     "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8544                     hr, (expected ? S_OK : S_FALSE), test_index);
8545             }
8546             if(SUCCEEDED(hr)) {
8547                 todo_wine {
8548                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8549                         expected, wine_dbgstr_w(received), test_index);
8550                 }
8551                 todo_wine {
8552                     ok(lstrlen(expected) == len,
8553                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8554                         lstrlen(expected), len, test_index);
8555                 }
8556             }
8557         } else {
8558             ok(hr == (expected ? S_OK : S_FALSE),
8559                 "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8560                 hr, (expected ? S_OK : S_FALSE), test_index);
8561             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8562                 expected, wine_dbgstr_w(received), test_index);
8563             ok(lstrlen(expected) == len,
8564                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8565                 lstrlen(expected), len, test_index);
8566         }
8567     } else {
8568         /* The property wasn't set earlier, so it should return whatever
8569          * the base IUri contains (if anything).
8570          */
8571         IUri *uri = NULL;
8572         hr = IUriBuilder_GetIUri(builder, &uri);
8573         ok(hr == S_OK,
8574             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8575             hr, S_OK, test_index);
8576         if(SUCCEEDED(hr)) {
8577             if(!uri) {
8578                 received = (void*) 0xdeadbeef;
8579                 len = -1;
8580
8581                 hr = IUriBuilder_GetPath(builder, &len, &received);
8582                 ok(hr == S_FALSE,
8583                     "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8584                     hr, S_FALSE, test_index);
8585                 if(SUCCEEDED(hr)) {
8586                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8587                         len, test_index);
8588                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8589                         received, test_index);
8590                 }
8591             } else {
8592                 BOOL has_prop = FALSE;
8593                 BSTR expected = NULL;
8594
8595                 hr = IUri_GetPath(uri, &expected);
8596                 ok(SUCCEEDED(hr),
8597                     "Error: Expected IUri_GetPath to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8598                     hr, test_index);
8599                 has_prop = hr == S_OK;
8600
8601                 hr = IUriBuilder_GetPath(builder, &len, &received);
8602                 if(has_prop) {
8603                     ok(hr == S_OK,
8604                         "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8605                         hr, S_OK, test_index);
8606                     if(SUCCEEDED(hr)) {
8607                         ok(!lstrcmpW(expected, received),
8608                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8609                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8610                         ok(lstrlenW(expected) == len,
8611                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8612                             lstrlenW(expected), len, test_index);
8613                     }
8614                 } else {
8615                     ok(hr == S_FALSE,
8616                         "Error: IUriBuilder_GetPath returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8617                         hr, S_FALSE, test_index);
8618                     if(SUCCEEDED(hr)) {
8619                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8620                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8621                             len, test_index);
8622                     }
8623                 }
8624                 SysFreeString(expected);
8625             }
8626         }
8627         if(uri) IUri_Release(uri);
8628     }
8629 }
8630
8631 static void test_IUriBuilder_GetPort(IUriBuilder *builder, const uri_builder_test *test,
8632                                      DWORD test_index) {
8633     HRESULT hr;
8634     BOOL has_port = FALSE;
8635     DWORD received = -1;
8636
8637     if(test->port_prop.change) {
8638         DWORD expected = test->port_prop.value;
8639
8640         hr = IUriBuilder_GetPort(builder, &has_port, &received);
8641         if(test->port_prop.todo) {
8642             todo_wine {
8643                 ok(hr == S_OK,
8644                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8645                     hr, S_OK, test_index);
8646             }
8647             if(SUCCEEDED(hr)) {
8648                 todo_wine {
8649                     ok(has_port == test->port_prop.set,
8650                         "Error: Expected has_port to be %d but was %d instead on uri_builder_tests[%d].\n",
8651                         test->port_prop.set, has_port, test_index);
8652                 }
8653                 todo_wine {
8654                     ok(received == expected,
8655                         "Error: Expected received to be %d, but was %d instead on uri_builder_tests[%d].\n",
8656                         expected, received, test_index);
8657                 }
8658             }
8659         } else {
8660             ok(hr == S_OK,
8661                 "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8662                 hr, S_OK, test_index);
8663             ok(has_port == test->port_prop.set,
8664                 "Error: Expected has_port to be %d, but was %d instead on uri_builder_tests[%d].\n",
8665                 test->port_prop.set, has_port, test_index);
8666             ok(received == test->port_prop.value,
8667                 "Error: Expected port to be %d, but was %d instead on uri_builder_tests[%d].\n",
8668                 test->port_prop.value, received, test_index);
8669         }
8670     } else {
8671         IUri *uri = NULL;
8672
8673         hr = IUriBuilder_GetIUri(builder, &uri);
8674         ok(hr == S_OK,
8675             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8676             hr, S_OK, test_index);
8677         if(SUCCEEDED(hr)) {
8678             if(!uri) {
8679                 hr = IUriBuilder_GetPort(builder, &has_port, &received);
8680                 ok(hr == S_OK,
8681                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8682                     hr, S_OK, test_index);
8683                 if(SUCCEEDED(hr)) {
8684                     ok(has_port == FALSE,
8685                         "Error: Expected has_port to be FALSE, but was %d instead on uri_builder_tests[%d].\n",
8686                         has_port, test_index);
8687                     ok(!received, "Error: Expected received to be 0, but was %d instead on uri_builder_tests[%d].\n",
8688                         received, test_index);
8689                 }
8690             } else {
8691                 DWORD expected;
8692
8693                 hr = IUri_GetPort(uri, &expected);
8694                 ok(SUCCEEDED(hr),
8695                     "Error: Expected IUri_Port to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8696                     hr, test_index);
8697
8698                 hr = IUriBuilder_GetPort(builder, &has_port, &received);
8699                 ok(hr == S_OK,
8700                     "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8701                     hr, S_OK, test_index);
8702                 if(SUCCEEDED(hr)) {
8703                     ok(!has_port,
8704                         "Error: Expected has_port to be FALSE but was TRUE instead on uri_builder_tests[%d].\n",
8705                         test_index);
8706                     ok(received == expected,
8707                         "Error: Expected received to be %d, but was %d instead on uri_builder_tests[%d].\n",
8708                         expected, received, test_index);
8709                 }
8710             }
8711         }
8712         if(uri) IUri_Release(uri);
8713     }
8714 }
8715
8716 static void test_IUriBuilder_GetQuery(IUriBuilder *builder, const uri_builder_test *test,
8717                                       DWORD test_index) {
8718     HRESULT hr;
8719     DWORD i;
8720     LPCWSTR received = NULL;
8721     DWORD len = -1;
8722     const uri_builder_property *prop = NULL;
8723
8724     /* Check if the property was set earlier. */
8725     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8726         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_QUERY)
8727             prop = &(test->properties[i]);
8728     }
8729
8730     if(prop) {
8731         /* Use expected_value unless it's NULL, then use value. */
8732         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8733         hr = IUriBuilder_GetQuery(builder, &len, &received);
8734         if(prop->todo) {
8735             todo_wine {
8736                 ok(hr == (expected ? S_OK : S_FALSE),
8737                     "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8738                     hr, (expected ? S_OK : S_FALSE), test_index);
8739             }
8740             if(SUCCEEDED(hr)) {
8741                 todo_wine {
8742                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8743                         expected, wine_dbgstr_w(received), test_index);
8744                 }
8745                 todo_wine {
8746                     ok(lstrlen(expected) == len,
8747                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8748                         lstrlen(expected), len, test_index);
8749                 }
8750             }
8751         } else {
8752             ok(hr == (expected ? S_OK : S_FALSE),
8753                 "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8754                 hr, (expected ? S_OK : S_FALSE), test_index);
8755             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8756                 expected, wine_dbgstr_w(received), test_index);
8757             ok(lstrlen(expected) == len,
8758                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8759                 lstrlen(expected), len, test_index);
8760         }
8761     } else {
8762         /* The property wasn't set earlier, so it should return whatever
8763          * the base IUri contains (if anything).
8764          */
8765         IUri *uri = NULL;
8766         hr = IUriBuilder_GetIUri(builder, &uri);
8767         ok(hr == S_OK,
8768             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8769             hr, S_OK, test_index);
8770         if(SUCCEEDED(hr)) {
8771             if(!uri) {
8772                 received = (void*) 0xdeadbeef;
8773                 len = -1;
8774
8775                 hr = IUriBuilder_GetQuery(builder, &len, &received);
8776                 ok(hr == S_FALSE,
8777                     "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8778                     hr, S_FALSE, test_index);
8779                 if(SUCCEEDED(hr)) {
8780                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8781                         len, test_index);
8782                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8783                         received, test_index);
8784                 }
8785             } else {
8786                 BOOL has_prop = FALSE;
8787                 BSTR expected = NULL;
8788
8789                 hr = IUri_GetQuery(uri, &expected);
8790                 ok(SUCCEEDED(hr),
8791                     "Error: Expected IUri_GetQuery to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8792                     hr, test_index);
8793                 has_prop = hr == S_OK;
8794
8795                 hr = IUriBuilder_GetQuery(builder, &len, &received);
8796                 if(has_prop) {
8797                     ok(hr == S_OK,
8798                         "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8799                         hr, S_OK, test_index);
8800                     if(SUCCEEDED(hr)) {
8801                         ok(!lstrcmpW(expected, received),
8802                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8803                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8804                         ok(lstrlenW(expected) == len,
8805                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8806                             lstrlenW(expected), len, test_index);
8807                     }
8808                 } else {
8809                     ok(hr == S_FALSE,
8810                         "Error: IUriBuilder_GetQuery returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8811                         hr, S_FALSE, test_index);
8812                     if(SUCCEEDED(hr)) {
8813                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8814                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8815                             len, test_index);
8816                     }
8817                 }
8818                 SysFreeString(expected);
8819             }
8820         }
8821         if(uri) IUri_Release(uri);
8822     }
8823 }
8824
8825 static void test_IUriBuilder_GetSchemeName(IUriBuilder *builder, const uri_builder_test *test,
8826                                            DWORD test_index) {
8827     HRESULT hr;
8828     DWORD i;
8829     LPCWSTR received = NULL;
8830     DWORD len = -1;
8831     const uri_builder_property *prop = NULL;
8832
8833     /* Check if the property was set earlier. */
8834     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8835         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_SCHEME_NAME)
8836             prop = &(test->properties[i]);
8837     }
8838
8839     if(prop) {
8840         /* Use expected_value unless it's NULL, then use value. */
8841         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8842         hr = IUriBuilder_GetSchemeName(builder, &len, &received);
8843         if(prop->todo) {
8844             todo_wine {
8845                 ok(hr == (expected ? S_OK : S_FALSE),
8846                     "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8847                     hr, (expected ? S_OK : S_FALSE), test_index);
8848             }
8849             if(SUCCEEDED(hr)) {
8850                 todo_wine {
8851                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8852                         expected, wine_dbgstr_w(received), test_index);
8853                 }
8854                 todo_wine {
8855                     ok(lstrlen(expected) == len,
8856                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8857                         lstrlen(expected), len, test_index);
8858                 }
8859             }
8860         } else {
8861             ok(hr == (expected ? S_OK : S_FALSE),
8862                 "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8863                 hr, (expected ? S_OK : S_FALSE), test_index);
8864             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8865                 expected, wine_dbgstr_w(received), test_index);
8866             ok(lstrlen(expected) == len,
8867                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8868                 lstrlen(expected), len, test_index);
8869         }
8870     } else {
8871         /* The property wasn't set earlier, so it should return whatever
8872          * the base IUri contains (if anything).
8873          */
8874         IUri *uri = NULL;
8875         hr = IUriBuilder_GetIUri(builder, &uri);
8876         ok(hr == S_OK,
8877             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8878             hr, S_OK, test_index);
8879         if(SUCCEEDED(hr)) {
8880             if(!uri) {
8881                 received = (void*) 0xdeadbeef;
8882                 len = -1;
8883
8884                 hr = IUriBuilder_GetSchemeName(builder, &len, &received);
8885                 ok(hr == S_FALSE,
8886                     "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8887                     hr, S_FALSE, test_index);
8888                 if(SUCCEEDED(hr)) {
8889                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8890                         len, test_index);
8891                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
8892                         received, test_index);
8893                 }
8894             } else {
8895                 BOOL has_prop = FALSE;
8896                 BSTR expected = NULL;
8897
8898                 hr = IUri_GetSchemeName(uri, &expected);
8899                 ok(SUCCEEDED(hr),
8900                     "Error: Expected IUri_GetSchemeName to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
8901                     hr, test_index);
8902                 has_prop = hr == S_OK;
8903
8904                 hr = IUriBuilder_GetSchemeName(builder, &len, &received);
8905                 if(has_prop) {
8906                     ok(hr == S_OK,
8907                         "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8908                         hr, S_OK, test_index);
8909                     if(SUCCEEDED(hr)) {
8910                         ok(!lstrcmpW(expected, received),
8911                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
8912                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
8913                         ok(lstrlenW(expected) == len,
8914                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8915                             lstrlenW(expected), len, test_index);
8916                     }
8917                 } else {
8918                     ok(hr == S_FALSE,
8919                         "Error: IUriBuilder_GetSchemeName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8920                         hr, S_FALSE, test_index);
8921                     if(SUCCEEDED(hr)) {
8922                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
8923                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
8924                             len, test_index);
8925                     }
8926                 }
8927                 SysFreeString(expected);
8928             }
8929         }
8930         if(uri) IUri_Release(uri);
8931     }
8932 }
8933
8934 static void test_IUriBuilder_GetUserName(IUriBuilder *builder, const uri_builder_test *test,
8935                                          DWORD test_index) {
8936     HRESULT hr;
8937     DWORD i;
8938     LPCWSTR received = NULL;
8939     DWORD len = -1;
8940     const uri_builder_property *prop = NULL;
8941
8942     /* Check if the property was set earlier. */
8943     for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
8944         if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_USER_NAME)
8945             prop = &(test->properties[i]);
8946     }
8947
8948     if(prop && prop->value && *prop->value) {
8949         /* Use expected_value unless it's NULL, then use value. */
8950         LPCSTR expected = prop->expected_value ? prop->expected_value : prop->value;
8951         hr = IUriBuilder_GetUserName(builder, &len, &received);
8952         if(prop->todo) {
8953             todo_wine {
8954                 ok(hr == (expected ? S_OK : S_FALSE),
8955                     "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8956                     hr, (expected ? S_OK : S_FALSE), test_index);
8957             }
8958             if(SUCCEEDED(hr)) {
8959                 todo_wine {
8960                     ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8961                         expected, wine_dbgstr_w(received), test_index);
8962                 }
8963                 todo_wine {
8964                     ok(lstrlen(expected) == len,
8965                         "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8966                         lstrlen(expected), len, test_index);
8967                 }
8968             }
8969         } else {
8970             ok(hr == (expected ? S_OK : S_FALSE),
8971                 "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8972                 hr, (expected ? S_OK : S_FALSE), test_index);
8973             ok(!strcmp_aw(expected, received), "Error: Expected %s but got %s on uri_builder_tests[%d].\n",
8974                 expected, wine_dbgstr_w(received), test_index);
8975             ok(lstrlen(expected) == len,
8976                 "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
8977                 lstrlen(expected), len, test_index);
8978         }
8979     } else {
8980         /* The property wasn't set earlier, so it should return whatever
8981          * the base IUri contains (if anything).
8982          */
8983         IUri *uri = NULL;
8984         hr = IUriBuilder_GetIUri(builder, &uri);
8985         ok(hr == S_OK,
8986             "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8987             hr, S_OK, test_index);
8988         if(SUCCEEDED(hr)) {
8989             if(!uri) {
8990                 received = (void*) 0xdeadbeef;
8991                 len = -1;
8992
8993                 hr = IUriBuilder_GetUserName(builder, &len, &received);
8994                 ok(hr == S_FALSE,
8995                     "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
8996                     hr, S_FALSE, test_index);
8997                 if(SUCCEEDED(hr)) {
8998                     ok(!len, "Error: Expected len to be 0, but was %d instead on uri_builder_tests[%d].\n",
8999                         len, test_index);
9000                     ok(!received, "Error: Expected received to be NULL, but was %p instead on uri_builder_tests[%d].\n",
9001                         received, test_index);
9002                 }
9003             } else {
9004                 BSTR expected = NULL;
9005                 BOOL has_prop = FALSE;
9006
9007                 hr = IUri_GetUserName(uri, &expected);
9008                 ok(SUCCEEDED(hr),
9009                     "Error: Expected IUri_GetUserName to succeed, but got 0x%08x instead on uri_builder_tests[%d].\n",
9010                     hr, test_index);
9011                 has_prop = hr == S_OK;
9012
9013                 hr = IUriBuilder_GetUserName(builder, &len, &received);
9014                 if(has_prop) {
9015                     ok(hr == S_OK,
9016                         "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9017                         hr, S_OK, test_index);
9018                     if(SUCCEEDED(hr)) {
9019                         ok(!lstrcmpW(expected, received),
9020                             "Error: Expected %s but got %s instead on uri_builder_tests[%d].\n",
9021                             wine_dbgstr_w(expected), wine_dbgstr_w(received), test_index);
9022                         ok(lstrlenW(expected) == len,
9023                             "Error: Expected the length to be %d, but was %d instead on uri_builder_tests[%d].\n",
9024                             lstrlenW(expected), len, test_index);
9025                     }
9026                 } else {
9027                     ok(hr == S_FALSE,
9028                         "Error: IUriBuilder_GetUserName returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9029                         hr, S_FALSE, test_index);
9030                     if(SUCCEEDED(hr)) {
9031                         ok(!received, "Error: Expected received to be NULL on uri_builder_tests[%d].\n", test_index);
9032                         ok(!len, "Error: Expected the length to be 0, but was %d instead on uri_builder_tests[%d].\n",
9033                             len, test_index);
9034                     }
9035                 }
9036                 SysFreeString(expected);
9037             }
9038         }
9039         if(uri) IUri_Release(uri);
9040     }
9041 }
9042
9043 /* Tests IUriBuilder functions. */
9044 static void test_IUriBuilder(void) {
9045     HRESULT hr;
9046     IUriBuilder *builder;
9047     DWORD i;
9048
9049     for(i = 0; i < sizeof(uri_builder_tests)/sizeof(uri_builder_tests[0]); ++i) {
9050         IUri *uri = NULL;
9051         uri_builder_test test = uri_builder_tests[i];
9052         LPWSTR uriW = NULL;
9053
9054         if(test.uri) {
9055             uriW = a2w(test.uri);
9056             hr = pCreateUri(uriW, test.create_flags, 0, &uri);
9057             ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9058                 hr, S_OK, i);
9059             if(FAILED(hr)) continue;
9060         }
9061         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
9062         if(test.create_builder_todo) {
9063             todo_wine {
9064                 ok(hr == test.create_builder_expected,
9065                     "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9066                     hr, test.create_builder_expected, i);
9067             }
9068         } else {
9069             ok(hr == test.create_builder_expected,
9070                 "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9071                 hr, test.create_builder_expected, i);
9072         }
9073         if(SUCCEEDED(hr)) {
9074             DWORD j;
9075             BOOL modified = FALSE, received = FALSE;
9076
9077             /* Perform all the string property changes. */
9078             for(j = 0; j < URI_BUILDER_STR_PROPERTY_COUNT; ++j) {
9079                 uri_builder_property prop = test.properties[j];
9080                 if(prop.change) {
9081                     change_property(builder, &prop, i);
9082                     if(prop.property != Uri_PROPERTY_SCHEME_NAME &&
9083                        prop.property != Uri_PROPERTY_HOST)
9084                         modified = TRUE;
9085                     else if(prop.value && *prop.value)
9086                         modified = TRUE;
9087                     else if(prop.value && !*prop.value && prop.property == Uri_PROPERTY_HOST)
9088                         /* Host name property can't be NULL, but it can be empty. */
9089                         modified = TRUE;
9090                 }
9091             }
9092
9093             if(test.port_prop.change) {
9094                 hr = IUriBuilder_SetPort(builder, test.port_prop.set, test.port_prop.value);
9095                 modified = TRUE;
9096                 if(test.port_prop.todo) {
9097                     todo_wine {
9098                         ok(hr == test.port_prop.expected,
9099                             "Error: IUriBuilder_SetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9100                             hr, test.port_prop.expected, i);
9101                     }
9102                 } else {
9103                     ok(hr == test.port_prop.expected,
9104                         "Error: IUriBuilder_SetPort returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9105                         hr, test.port_prop.expected, i);
9106                 }
9107             }
9108
9109             hr = IUriBuilder_HasBeenModified(builder, &received);
9110             ok(hr == S_OK,
9111                 "Error IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x on uri_builder_tests[%d].\n",
9112                 hr, S_OK, i);
9113             if(SUCCEEDED(hr))
9114                 ok(received == modified,
9115                     "Error: Expected received to be %d but was %d instead on uri_builder_tests[%d].\n",
9116                     modified, received, i);
9117
9118             /* Test the "Get*" functions. */
9119             test_IUriBuilder_GetFragment(builder, &test, i);
9120             test_IUriBuilder_GetHost(builder, &test, i);
9121             test_IUriBuilder_GetPassword(builder, &test, i);
9122             test_IUriBuilder_GetPath(builder, &test, i);
9123             test_IUriBuilder_GetPort(builder, &test, i);
9124             test_IUriBuilder_GetQuery(builder, &test, i);
9125             test_IUriBuilder_GetSchemeName(builder, &test, i);
9126             test_IUriBuilder_GetUserName(builder, &test, i);
9127
9128             test_IUriBuilder_CreateUri(builder, &test, i);
9129             test_IUriBuilder_CreateUriSimple(builder, &test, i);
9130             test_IUriBuilder_CreateUriWithFlags(builder, &test, i);
9131         }
9132         if(builder) IUriBuilder_Release(builder);
9133         if(uri) IUri_Release(uri);
9134         heap_free(uriW);
9135     }
9136 }
9137
9138 static void test_IUriBuilder_HasBeenModified(void) {
9139     HRESULT hr;
9140     IUriBuilder *builder = NULL;
9141
9142     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
9143     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9144     if(SUCCEEDED(hr)) {
9145         static const WCHAR hostW[] = {'g','o','o','g','l','e','.','c','o','m',0};
9146         IUri *uri = NULL;
9147         BOOL received;
9148
9149         hr = IUriBuilder_HasBeenModified(builder, NULL);
9150         ok(hr == E_POINTER, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9151             hr, E_POINTER);
9152
9153         hr = IUriBuilder_SetHost(builder, hostW);
9154         ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n",
9155             hr, S_OK);
9156
9157         hr = IUriBuilder_HasBeenModified(builder, &received);
9158         ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9159             hr, S_OK);
9160         if(SUCCEEDED(hr))
9161             ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9162
9163         hr = pCreateUri(http_urlW, 0, 0, &uri);
9164         ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9165         if(SUCCEEDED(hr)) {
9166             LPCWSTR prop;
9167             DWORD len = -1;
9168
9169             hr = IUriBuilder_SetIUri(builder, uri);
9170             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n",
9171                 hr, S_OK);
9172
9173             hr = IUriBuilder_HasBeenModified(builder, &received);
9174             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9175                 hr, S_OK);
9176             if(SUCCEEDED(hr))
9177                 ok(received == FALSE, "Error: Expected received to be FALSE.\n");
9178
9179             /* Test what happens with you call SetIUri with the same IUri again. */
9180             hr = IUriBuilder_SetHost(builder, hostW);
9181             ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9182
9183             hr = IUriBuilder_HasBeenModified(builder, &received);
9184             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9185                 hr, S_OK);
9186             if(SUCCEEDED(hr))
9187                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9188
9189             hr = IUriBuilder_SetIUri(builder, uri);
9190             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9191
9192             /* IUriBuilder already had 'uri' as it's IUri property and so Windows doesn't
9193              * reset any of the changes that were made to the IUriBuilder.
9194              */
9195             hr = IUriBuilder_HasBeenModified(builder, &received);
9196             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9197             if(SUCCEEDED(hr))
9198                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9199
9200             hr = IUriBuilder_GetHost(builder, &len, &prop);
9201             ok(hr == S_OK, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9202             if(SUCCEEDED(hr)) {
9203                 ok(!lstrcmpW(prop, hostW), "Error: Expected %s but got %s instead.\n",
9204                     wine_dbgstr_w(hostW), wine_dbgstr_w(prop));
9205                 ok(len == lstrlenW(hostW), "Error: Expected len to be %d, but was %d instead.\n",
9206                     lstrlenW(hostW), len);
9207             }
9208
9209             hr = IUriBuilder_SetIUri(builder, NULL);
9210             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9211
9212             hr = IUriBuilder_SetHost(builder, hostW);
9213             ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9214             hr = IUriBuilder_HasBeenModified(builder, &received);
9215             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9216                 hr, S_OK);
9217             if(SUCCEEDED(hr))
9218                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9219
9220             hr = IUriBuilder_SetIUri(builder, NULL);
9221             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%09x.\n", hr, S_OK);
9222
9223             hr = IUriBuilder_HasBeenModified(builder, &received);
9224             ok(hr == S_OK, "Error: IUriBuilder_HasBeenModified returned 0x%08x, expected 0x%08x.\n",
9225                 hr, S_OK);
9226             if(SUCCEEDED(hr))
9227                 ok(received == TRUE, "Error: Expected received to be TRUE.\n");
9228
9229             hr = IUriBuilder_GetHost(builder, &len, &prop);
9230             ok(hr == S_OK, "Error: IUriBuilder_GetHost returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9231             if(SUCCEEDED(hr)) {
9232                 ok(!lstrcmpW(prop, hostW), "Error: Expected %s but got %s instead.\n",
9233                     wine_dbgstr_w(hostW), wine_dbgstr_w(prop));
9234                 ok(len == lstrlenW(hostW), "Error: Expected len to %d, but was %d instead.\n",
9235                     lstrlenW(hostW), len);
9236             }
9237         }
9238         if(uri) IUri_Release(uri);
9239     }
9240     if(builder) IUriBuilder_Release(builder);
9241 }
9242
9243 /* Test IUriBuilder {Get,Set}IUri functions. */
9244 static void test_IUriBuilder_IUriProperty(void) {
9245     IUriBuilder *builder = NULL;
9246     HRESULT hr;
9247
9248     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
9249     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9250     if(SUCCEEDED(hr)) {
9251         IUri *uri = NULL;
9252
9253         hr = IUriBuilder_GetIUri(builder, NULL);
9254         ok(hr == E_POINTER, "Error: IUriBuilder_GetIUri returned 0x%08x, expected 0x%08x.\n",
9255             hr, E_POINTER);
9256
9257         hr = pCreateUri(http_urlW, 0, 0, &uri);
9258         if(SUCCEEDED(hr)) {
9259             IUri *test = NULL;
9260             ULONG cur_count, orig_count;
9261
9262             /* IUriBuilder doesn't clone the IUri, it use the same IUri. */
9263             orig_count = get_refcnt(uri);
9264             hr = IUriBuilder_SetIUri(builder, uri);
9265             cur_count = get_refcnt(uri);
9266             if(SUCCEEDED(hr))
9267                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9268                     orig_count+1, cur_count);
9269
9270             hr = IUriBuilder_SetIUri(builder, NULL);
9271             cur_count = get_refcnt(uri);
9272             if(SUCCEEDED(hr))
9273                 ok(cur_count == orig_count, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9274                     orig_count, cur_count);
9275
9276             /* CreateUri* functions will return back the same IUri if nothing has changed. */
9277             hr = IUriBuilder_SetIUri(builder, uri);
9278             ok(hr == S_OK, "Error: IUriBuilder_SetIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9279             orig_count = get_refcnt(uri);
9280
9281             hr = IUriBuilder_CreateUri(builder, 0, 0, 0, &test);
9282             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9283             if(SUCCEEDED(hr)) {
9284                 cur_count = get_refcnt(uri);
9285                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9286                     orig_count+1, cur_count);
9287                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n",
9288                     uri, test);
9289             }
9290             if(test) IUri_Release(test);
9291
9292             test = NULL;
9293             hr = IUriBuilder_CreateUri(builder, -1, 0, 0, &test);
9294             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9295             if(SUCCEEDED(hr)) {
9296                 cur_count = get_refcnt(uri);
9297                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9298                     orig_count+1, cur_count);
9299                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
9300             }
9301             if(test) IUri_Release(test);
9302
9303             /* Doesn't return the same IUri, if the flag combination is different then the one that created
9304              * the base IUri.
9305              */
9306             test = NULL;
9307             hr = IUriBuilder_CreateUri(builder, Uri_CREATE_ALLOW_RELATIVE, 0, 0, &test);
9308             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9309             if(SUCCEEDED(hr))
9310                 ok(test != uri, "Error: Wasn't expecting 'test' to be 'uri'\n");
9311
9312             if(test) IUri_Release(test);
9313
9314             /* Still returns the same IUri, even though the base one wasn't created with CREATE_CANONICALIZE
9315              * explicitly set (because it's a default flags).
9316              */
9317             test = NULL;
9318             hr = IUriBuilder_CreateUri(builder, Uri_CREATE_CANONICALIZE, 0, 0, &test);
9319             ok(hr == S_OK, "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9320             if(SUCCEEDED(hr)) {
9321                 cur_count = get_refcnt(uri);
9322                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9323                     orig_count+1, cur_count);
9324                 ok(test == uri, "Error: Expected 'test' to be %p, but was %p instead.\n", uri, test);
9325             }
9326             if(test) IUri_Release(test);
9327
9328             test = NULL;
9329             hr = IUriBuilder_CreateUriSimple(builder, 0, 0, &test);
9330             ok(hr == S_OK, "Error: IUriBuilder_CreateUriSimple returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9331             if(SUCCEEDED(hr)) {
9332                 cur_count = get_refcnt(uri);
9333                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9334                     orig_count+1, cur_count);
9335                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
9336             }
9337             if(test) IUri_Release(test);
9338
9339             test = NULL;
9340             hr = IUriBuilder_CreateUriWithFlags(builder, 0, 0, 0, 0, &test);
9341             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n",
9342                 hr, S_OK);
9343             if(SUCCEEDED(hr)) {
9344                 cur_count = get_refcnt(uri);
9345                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9346                     orig_count+1, cur_count);
9347                 ok(test == uri, "Error: Expected test to be %p, but was %p instead.\n", uri, test);
9348             }
9349             if(test) IUri_Release(test);
9350
9351             /* Doesn't return the same IUri, if the flag combination is different then the one that created
9352              * the base IUri.
9353              */
9354             test = NULL;
9355             hr = IUriBuilder_CreateUriWithFlags(builder, Uri_CREATE_ALLOW_RELATIVE, 0, 0, 0, &test);
9356             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9357             if(SUCCEEDED(hr))
9358                 ok(test != uri, "Error: Wasn't expecting 'test' to be 'uri'\n");
9359
9360             if(test) IUri_Release(test);
9361
9362             /* Still returns the same IUri, even though the base one wasn't created with CREATE_CANONICALIZE
9363              * explicitly set (because it's a default flags).
9364              */
9365             test = NULL;
9366             hr = IUriBuilder_CreateUriWithFlags(builder, Uri_CREATE_CANONICALIZE, 0, 0, 0, &test);
9367             ok(hr == S_OK, "Error: IUriBuilder_CreateUriWithFlags returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9368             if(SUCCEEDED(hr)) {
9369                 cur_count = get_refcnt(uri);
9370                 ok(cur_count == orig_count+1, "Error: Expected uri ref count to be %d, but was %d instead.\n",
9371                     orig_count+1, cur_count);
9372                 ok(test == uri, "Error: Expected 'test' to be %p, but was %p instead.\n", uri, test);
9373             }
9374             if(test) IUri_Release(test);
9375         }
9376         if(uri) IUri_Release(uri);
9377     }
9378     if(builder) IUriBuilder_Release(builder);
9379 }
9380
9381 static void test_IUriBuilder_RemoveProperties(void) {
9382     IUriBuilder *builder = NULL;
9383     HRESULT hr;
9384     DWORD i;
9385
9386     hr = pCreateIUriBuilder(NULL, 0, 0, &builder);
9387     ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9388     if(SUCCEEDED(hr)) {
9389         /* Properties that can't be removed. */
9390         const DWORD invalid = Uri_HAS_ABSOLUTE_URI|Uri_HAS_DISPLAY_URI|Uri_HAS_RAW_URI|Uri_HAS_HOST_TYPE|
9391                               Uri_HAS_SCHEME|Uri_HAS_ZONE;
9392
9393         for(i = Uri_PROPERTY_STRING_START; i <= Uri_PROPERTY_DWORD_LAST; ++i) {
9394             hr = IUriBuilder_RemoveProperties(builder, i << 1);
9395             if((i << 1) & invalid) {
9396                 ok(hr == E_INVALIDARG,
9397                     "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x with prop=%d.\n",
9398                     hr, E_INVALIDARG, i);
9399             } else {
9400                 ok(hr == S_OK,
9401                     "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x with prop=%d.\n",
9402                     hr, S_OK, i);
9403             }
9404         }
9405
9406         /* Also doesn't accept anything that's outside the range of the
9407          * Uri_HAS flags.
9408          */
9409         hr = IUriBuilder_RemoveProperties(builder, (Uri_PROPERTY_DWORD_LAST+1) << 1);
9410         ok(hr == E_INVALIDARG, "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x.\n",
9411             hr, E_INVALIDARG);
9412     }
9413     if(builder) IUriBuilder_Release(builder);
9414
9415     for(i = 0; i < sizeof(uri_builder_remove_tests)/sizeof(uri_builder_remove_tests[0]); ++i) {
9416         uri_builder_remove_test test = uri_builder_remove_tests[i];
9417         IUri *uri = NULL;
9418         LPWSTR uriW;
9419
9420         uriW = a2w(test.uri);
9421         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
9422         if(SUCCEEDED(hr)) {
9423             builder = NULL;
9424
9425             hr = pCreateIUriBuilder(uri, 0, 0, &builder);
9426             if(test.create_builder_todo) {
9427                 todo_wine {
9428                     ok(hr == test.create_builder_expected,
9429                         "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
9430                         hr, test.create_builder_expected, i);
9431                 }
9432             } else {
9433                 ok(hr == test.create_builder_expected,
9434                     "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
9435                     hr, test.create_builder_expected, i);
9436             }
9437             if(SUCCEEDED(hr)) {
9438                 hr = IUriBuilder_RemoveProperties(builder, test.remove_properties);
9439                 if(test.remove_todo) {
9440                     todo_wine {
9441                         ok(hr == test.remove_expected,
9442                             "Error: IUriBuilder_RemoveProperties returned 0x%08x, expected 0x%08x on test %d.\n",
9443                             hr, test.remove_expected, i);
9444                     }
9445                 } else {
9446                     ok(hr == test.remove_expected,
9447                         "Error: IUriBuilder returned 0x%08x, expected 0x%08x on test %d.\n",
9448                         hr, test.remove_expected, i);
9449                 }
9450                 if(SUCCEEDED(hr)) {
9451                     IUri *result = NULL;
9452
9453                     hr = IUriBuilder_CreateUri(builder, test.expected_flags, 0, 0, &result);
9454                     if(test.expected_todo) {
9455                         todo_wine {
9456                             ok(hr == test.expected_hres,
9457                                 "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on test %d.\n",
9458                                 hr, test.expected_hres, i);
9459                         }
9460                     } else {
9461                         ok(hr == test.expected_hres,
9462                             "Error: IUriBuilder_CreateUri returned 0x%08x, expected 0x%08x on test %d.\n",
9463                             hr, test.expected_hres, i);
9464                     }
9465                     if(SUCCEEDED(hr)) {
9466                         BSTR received = NULL;
9467
9468                         hr = IUri_GetAbsoluteUri(result, &received);
9469                         ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x instead.\n", hr);
9470                         ok(!strcmp_aw(test.expected_uri, received),
9471                             "Error: Expected %s but got %s instead on test %d.\n",
9472                             test.expected_uri, wine_dbgstr_w(received), i);
9473                         SysFreeString(received);
9474                     }
9475                     if(result) IUri_Release(result);
9476                 }
9477             }
9478             if(builder) IUriBuilder_Release(builder);
9479         }
9480         if(uri) IUri_Release(uri);
9481         heap_free(uriW);
9482     }
9483 }
9484
9485 static void test_IUriBuilder_Misc(void) {
9486     HRESULT hr;
9487     IUri *uri;
9488
9489     hr = pCreateUri(http_urlW, 0, 0, &uri);
9490     if(SUCCEEDED(hr)) {
9491         IUriBuilder *builder;
9492
9493         hr = pCreateIUriBuilder(uri, 0, 0, &builder);
9494         ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9495         if(SUCCEEDED(hr)) {
9496             BOOL has = -1;
9497             DWORD port = -1;
9498
9499             hr = IUriBuilder_GetPort(builder, &has, &port);
9500             ok(hr == S_OK, "Error: IUriBuilder_GetPort returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9501             if(SUCCEEDED(hr)) {
9502                 /* 'has' will be set to FALSE, even though uri had a port. */
9503                 ok(has == FALSE, "Error: Expected 'has' to be FALSE, was %d instead.\n", has);
9504                 /* Still sets 'port' to 80. */
9505                 ok(port == 80, "Error: Expected the port to be 80, but, was %d instead.\n", port);
9506             }
9507         }
9508         if(builder) IUriBuilder_Release(builder);
9509     }
9510     if(uri) IUri_Release(uri);
9511 }
9512
9513 static void test_IUriBuilderFactory(void) {
9514     HRESULT hr;
9515     IUri *uri;
9516     IUriBuilderFactory *factory;
9517     IUriBuilder *builder;
9518
9519     hr = pCreateUri(http_urlW, 0, 0, &uri);
9520     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9521     if(SUCCEEDED(hr)) {
9522         factory = NULL;
9523         hr = IUri_QueryInterface(uri, &IID_IUriBuilderFactory, (void**)&factory);
9524         ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x.\n", hr);
9525         ok(factory != NULL, "Error: Expected 'factory' to not be NULL.\n");
9526
9527         if(SUCCEEDED(hr)) {
9528             builder = (void*) 0xdeadbeef;
9529             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 10, 0, &builder);
9530             ok(hr == E_INVALIDARG, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9531                 hr, E_INVALIDARG);
9532             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9533
9534             builder = (void*) 0xdeadbeef;
9535             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 0, 10, &builder);
9536             ok(hr == E_INVALIDARG, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9537                 hr, E_INVALIDARG);
9538             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9539
9540             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 0, 0, NULL);
9541             ok(hr == E_POINTER, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9542                 hr, E_POINTER);
9543
9544             builder = NULL;
9545             hr = IUriBuilderFactory_CreateIUriBuilder(factory, 0, 0, &builder);
9546             ok(hr == S_OK, "Error: CreateInitializedIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9547                 hr, S_OK);
9548             if(SUCCEEDED(hr)) {
9549                 IUri *tmp = (void*) 0xdeadbeef;
9550                 LPCWSTR result;
9551                 DWORD result_len;
9552
9553                 hr = IUriBuilder_GetIUri(builder, &tmp);
9554                 ok(hr == S_OK, "Error: GetIUri returned 0x%08x, expected 0x%08x.\n",
9555                     hr, S_OK);
9556                 ok(!tmp, "Error: Expected 'tmp' to be NULL, but was %p instead.\n", tmp);
9557
9558                 hr = IUriBuilder_GetHost(builder, &result_len, &result);
9559                 ok(hr == S_FALSE, "Error: GetHost returned 0x%08x, expected 0x%08x.\n",
9560                     hr, S_FALSE);
9561             }
9562             if(builder) IUriBuilder_Release(builder);
9563
9564             builder = (void*) 0xdeadbeef;
9565             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 10, 0, &builder);
9566             ok(hr == E_INVALIDARG, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9567                 hr, E_INVALIDARG);
9568             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9569
9570             builder = (void*) 0xdeadbeef;
9571             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 0, 10, &builder);
9572             ok(hr == E_INVALIDARG, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9573                 hr, E_INVALIDARG);
9574             ok(!builder, "Error: Expected 'builder' to be NULL, but was %p.\n", builder);
9575
9576             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 0, 0, NULL);
9577             ok(hr == E_POINTER, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9578                 hr, E_POINTER);
9579
9580             builder = NULL;
9581             hr = IUriBuilderFactory_CreateInitializedIUriBuilder(factory, 0, 0, &builder);
9582             ok(hr == S_OK, "Error: CreateIUriBuilder returned 0x%08x, expected 0x%08x.\n",
9583                 hr, S_OK);
9584             if(SUCCEEDED(hr)) {
9585                 IUri *tmp = NULL;
9586
9587                 hr = IUriBuilder_GetIUri(builder, &tmp);
9588                 ok(hr == S_OK, "Error: GetIUri return 0x%08x, expected 0x%08x.\n",
9589                     hr, S_OK);
9590                 ok(tmp == uri, "Error: Expected tmp to be %p, but was %p.\n", uri, tmp);
9591                 if(uri) IUri_Release(uri);
9592             }
9593             if(builder) IUriBuilder_Release(builder);
9594         }
9595         if(factory) IUriBuilderFactory_Release(factory);
9596     }
9597     if(uri) IUri_Release(uri);
9598 }
9599
9600 static void test_CoInternetCombineIUri(void) {
9601     HRESULT hr;
9602     IUri *base, *relative, *result;
9603     DWORD i;
9604
9605     base = NULL;
9606     hr = pCreateUri(http_urlW, 0, 0, &base);
9607     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x.\n", hr);
9608     if(SUCCEEDED(hr)) {
9609         result = (void*) 0xdeadbeef;
9610         hr = pCoInternetCombineIUri(base, NULL, 0, &result, 0);
9611         ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9612         ok(!result, "Error: Expected 'result' to be NULL, was %p.\n", result);
9613     }
9614
9615     relative = NULL;
9616     hr = pCreateUri(http_urlW, 0, 0, &relative);
9617     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x.\n", hr);
9618     if(SUCCEEDED(hr)) {
9619         result = (void*) 0xdeadbeef;
9620         hr = pCoInternetCombineIUri(NULL, relative, 0, &result, 0);
9621         ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9622         ok(!result, "Error: Expected 'result' to be NULL, was %p.\n", result);
9623     }
9624
9625     hr = pCoInternetCombineIUri(base, relative, 0, NULL, 0);
9626     ok(hr == E_INVALIDARG, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
9627
9628     if(base) IUri_Release(base);
9629     if(relative) IUri_Release(relative);
9630
9631     for(i = 0; i < sizeof(uri_combine_tests)/sizeof(uri_combine_tests[0]); ++i) {
9632         LPWSTR baseW = a2w(uri_combine_tests[i].base_uri);
9633
9634         hr = pCreateUri(baseW, uri_combine_tests[i].base_create_flags, 0, &base);
9635         ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x on uri_combine_tests[%d].\n", hr, i);
9636         if(SUCCEEDED(hr)) {
9637             LPWSTR relativeW = a2w(uri_combine_tests[i].relative_uri);
9638
9639             hr = pCreateUri(relativeW, uri_combine_tests[i].relative_create_flags, 0, &relative);
9640             ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, got 0x%08x on uri_combine_tests[%d].\n", hr, i);
9641             if(SUCCEEDED(hr)) {
9642                 result = NULL;
9643
9644                 hr = pCoInternetCombineIUri(base, relative, uri_combine_tests[i].combine_flags, &result, 0);
9645                 if(uri_combine_tests[i].todo) {
9646                     todo_wine {
9647                         ok(hr == uri_combine_tests[i].expected,
9648                             "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9649                             hr, uri_combine_tests[i].expected, i);
9650                     }
9651                 } else {
9652                     ok(hr == uri_combine_tests[i].expected,
9653                         "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9654                         hr, uri_combine_tests[i]. expected, i);
9655                 }
9656                 if(SUCCEEDED(hr)) {
9657                     DWORD j;
9658
9659                     for(j = 0; j < sizeof(uri_combine_tests[i].str_props)/sizeof(uri_combine_tests[i].str_props[0]); ++j) {
9660                         uri_combine_str_property prop = uri_combine_tests[i].str_props[j];
9661                         BSTR received;
9662
9663                         hr = IUri_GetPropertyBSTR(result, j, &received, 0);
9664                         if(prop.todo) {
9665                             todo_wine {
9666                                 ok(hr == prop.expected,
9667                                     "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9668                                     hr, prop.expected, i, j);
9669                             }
9670                             todo_wine {
9671                                 ok(!strcmp_aw(prop.value, received) ||
9672                                    broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9673                                     "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9674                                     prop.value, wine_dbgstr_w(received), i, j);
9675                             }
9676                         } else {
9677                             ok(hr == prop.expected,
9678                                 "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9679                                 hr, prop.expected, i, j);
9680                             ok(!strcmp_aw(prop.value, received) ||
9681                                broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9682                                 "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9683                                 prop.value, wine_dbgstr_w(received), i, j);
9684                         }
9685                         SysFreeString(received);
9686                     }
9687
9688                     for(j = 0; j < sizeof(uri_combine_tests[i].dword_props)/sizeof(uri_combine_tests[i].dword_props[0]); ++j) {
9689                         uri_dword_property prop = uri_combine_tests[i].dword_props[j];
9690                         DWORD received;
9691
9692                         hr = IUri_GetPropertyDWORD(result, j+Uri_PROPERTY_DWORD_START, &received, 0);
9693                         if(prop.todo) {
9694                             todo_wine {
9695                                 ok(hr == prop.expected,
9696                                     "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9697                                     hr, prop.expected, i, j);
9698                             }
9699                             todo_wine {
9700                                 ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9701                                     prop.value, received, i, j);
9702                             }
9703                         } else {
9704                             ok(hr == prop.expected,
9705                                 "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
9706                                 hr, prop.expected, i, j);
9707                             ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
9708                                 prop.value, received, i, j);
9709                         }
9710                     }
9711                 }
9712                 if(result) IUri_Release(result);
9713             }
9714             if(relative) IUri_Release(relative);
9715             heap_free(relativeW);
9716         }
9717         if(base) IUri_Release(base);
9718         heap_free(baseW);
9719     }
9720 }
9721
9722 static HRESULT WINAPI InternetProtocolInfo_QueryInterface(IInternetProtocolInfo *iface,
9723                                                           REFIID riid, void **ppv)
9724 {
9725     ok(0, "unexpected call\n");
9726     return E_NOINTERFACE;
9727 }
9728
9729 static ULONG WINAPI InternetProtocolInfo_AddRef(IInternetProtocolInfo *iface)
9730 {
9731     return 2;
9732 }
9733
9734 static ULONG WINAPI InternetProtocolInfo_Release(IInternetProtocolInfo *iface)
9735 {
9736     return 1;
9737 }
9738
9739 static HRESULT WINAPI InternetProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
9740         PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
9741         DWORD *pcchResult, DWORD dwReserved)
9742 {
9743     CHECK_EXPECT(ParseUrl);
9744     ok(!lstrcmpW(pwzUrl, parse_urlW), "Error: Expected %s, but got %s instead.\n",
9745         wine_dbgstr_w(parse_urlW), wine_dbgstr_w(pwzUrl));
9746     ok(ParseAction == parse_action, "Error: Expected %d, but got %d.\n", parse_action, ParseAction);
9747     ok(dwParseFlags == parse_flags, "Error: Expected 0x%08x, but got 0x%08x.\n", parse_flags, dwParseFlags);
9748     ok(cchResult == 200, "Error: Got %d.\n", cchResult);
9749
9750     memcpy(pwzResult, parse_resultW, sizeof(parse_resultW));
9751     *pcchResult = lstrlenW(parse_resultW);
9752
9753     return S_OK;
9754 }
9755
9756 static HRESULT WINAPI InternetProtocolInfo_CombineUrl(IInternetProtocolInfo *iface,
9757         LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags,
9758         LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
9759 {
9760     CHECK_EXPECT(CombineUrl);
9761     ok(!lstrcmpW(pwzBaseUrl, combine_baseW), "Error: Expected %s, but got %s instead.\n",
9762         wine_dbgstr_w(combine_baseW), wine_dbgstr_w(pwzBaseUrl));
9763     ok(!lstrcmpW(pwzRelativeUrl, combine_relativeW), "Error: Expected %s, but got %s instead.\n",
9764         wine_dbgstr_w(combine_relativeW), wine_dbgstr_w(pwzRelativeUrl));
9765     ok(dwCombineFlags == (URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO),
9766         "Error: Expected 0, but got 0x%08x.\n", dwCombineFlags);
9767     ok(cchResult == INTERNET_MAX_URL_LENGTH+1, "Error: Got %d.\n", cchResult);
9768
9769     memcpy(pwzResult, combine_resultW, sizeof(combine_resultW));
9770     *pcchResult = lstrlenW(combine_resultW);
9771
9772     return S_OK;
9773 }
9774
9775 static HRESULT WINAPI InternetProtocolInfo_CompareUrl(IInternetProtocolInfo *iface,
9776         LPCWSTR pwzUrl1, LPCWSTR pwzUrl2, DWORD dwCompareFlags)
9777 {
9778     ok(0, "unexpected call\n");
9779     return E_NOTIMPL;
9780 }
9781
9782 static HRESULT WINAPI InternetProtocolInfo_QueryInfo(IInternetProtocolInfo *iface,
9783         LPCWSTR pwzUrl, QUERYOPTION OueryOption, DWORD dwQueryFlags, LPVOID pBuffer,
9784         DWORD cbBuffer, DWORD *pcbBuf, DWORD dwReserved)
9785 {
9786     ok(0, "unexpected call\n");
9787     return E_NOTIMPL;
9788 }
9789
9790 static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl = {
9791     InternetProtocolInfo_QueryInterface,
9792     InternetProtocolInfo_AddRef,
9793     InternetProtocolInfo_Release,
9794     InternetProtocolInfo_ParseUrl,
9795     InternetProtocolInfo_CombineUrl,
9796     InternetProtocolInfo_CompareUrl,
9797     InternetProtocolInfo_QueryInfo
9798 };
9799
9800 static IInternetProtocolInfo protocol_info = { &InternetProtocolInfoVtbl };
9801
9802 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
9803 {
9804     if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) {
9805         *ppv = &protocol_info;
9806         return S_OK;
9807     }
9808
9809     ok(0, "unexpected call\n");
9810     return E_NOINTERFACE;
9811 }
9812
9813 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
9814 {
9815     return 2;
9816 }
9817
9818 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
9819 {
9820     return 1;
9821 }
9822
9823 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
9824                                         REFIID riid, void **ppv)
9825 {
9826     ok(0, "unexpected call\n");
9827     return E_NOTIMPL;
9828 }
9829
9830 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
9831 {
9832     ok(0, "unexpected call\n");
9833     return S_OK;
9834 }
9835
9836 static const IClassFactoryVtbl ClassFactoryVtbl = {
9837     ClassFactory_QueryInterface,
9838     ClassFactory_AddRef,
9839     ClassFactory_Release,
9840     ClassFactory_CreateInstance,
9841     ClassFactory_LockServer
9842 };
9843
9844 static IClassFactory protocol_cf = { &ClassFactoryVtbl };
9845
9846 static void register_protocols(void)
9847 {
9848     IInternetSession *session;
9849     HRESULT hres;
9850
9851     hres = pCoInternetGetSession(0, &session, 0);
9852     ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
9853     if(FAILED(hres))
9854         return;
9855
9856     hres = IInternetSession_RegisterNameSpace(session, &protocol_cf, &IID_NULL,
9857             winetestW, 0, NULL, 0);
9858     ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
9859
9860     IInternetSession_Release(session);
9861 }
9862
9863 static void unregister_protocols(void) {
9864     IInternetSession *session;
9865     HRESULT hr;
9866
9867     hr = pCoInternetGetSession(0, &session, 0);
9868     ok(hr == S_OK, "CoInternetGetSession failed: 0x%08x\n", hr);
9869     if(FAILED(hr))
9870         return;
9871
9872     hr = IInternetSession_UnregisterNameSpace(session, &protocol_cf, winetestW);
9873     ok(hr == S_OK, "UnregisterNameSpace failed: 0x%08x\n", hr);
9874
9875     IInternetSession_Release(session);
9876 }
9877
9878 static void test_CoInternetCombineIUri_Pluggable(void) {
9879     HRESULT hr;
9880     IUri *base = NULL;
9881
9882     hr = pCreateUri(combine_baseW, 0, 0, &base);
9883     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9884     if(SUCCEEDED(hr)) {
9885         IUri *relative = NULL;
9886
9887         hr = pCreateUri(combine_relativeW, Uri_CREATE_ALLOW_RELATIVE, 0, &relative);
9888         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9889         if(SUCCEEDED(hr)) {
9890             IUri *result = NULL;
9891
9892             SET_EXPECT(CombineUrl);
9893
9894             hr = pCoInternetCombineIUri(base, relative, URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO,
9895                                         &result, 0);
9896             ok(hr == S_OK, "Error: CoInternetCombineIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
9897
9898             CHECK_CALLED(CombineUrl);
9899
9900             if(SUCCEEDED(hr)) {
9901                 BSTR received = NULL;
9902                 hr = IUri_GetAbsoluteUri(result, &received);
9903                 ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x instead.\n", hr);
9904                 if(SUCCEEDED(hr)) {
9905                     ok(!lstrcmpW(combine_resultW, received), "Error: Expected %s, but got %s.\n",
9906                         wine_dbgstr_w(combine_resultW), wine_dbgstr_w(received));
9907                 }
9908                 SysFreeString(received);
9909             }
9910             if(result) IUri_Release(result);
9911         }
9912         if(relative) IUri_Release(relative);
9913     }
9914     if(base) IUri_Release(base);
9915 }
9916
9917 static void test_CoInternetCombineUrlEx(void) {
9918     HRESULT hr;
9919     IUri *base, *result;
9920     DWORD i;
9921
9922     base = NULL;
9923     hr = pCreateUri(http_urlW, 0, 0, &base);
9924     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
9925     if(SUCCEEDED(hr)) {
9926         result = (void*) 0xdeadbeef;
9927         hr = pCoInternetCombineUrlEx(base, NULL, 0, &result, 0);
9928         ok(hr == E_UNEXPECTED, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
9929             hr, E_UNEXPECTED);
9930         ok(!result, "Error: Expected 'result' to be NULL was %p instead.\n", result);
9931     }
9932
9933     result = (void*) 0xdeadbeef;
9934     hr = pCoInternetCombineUrlEx(NULL, http_urlW, 0, &result, 0);
9935     ok(hr == E_INVALIDARG, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
9936         hr, E_INVALIDARG);
9937     ok(!result, "Error: Expected 'result' to be NULL, but was %p instead.\n", result);
9938
9939     result = (void*) 0xdeadbeef;
9940     hr = pCoInternetCombineUrlEx(NULL, NULL, 0, &result, 0);
9941     ok(hr == E_UNEXPECTED, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
9942         hr, E_UNEXPECTED);
9943     ok(!result, "Error: Expected 'result' to be NULL, but was %p instead.\n", result);
9944
9945     hr = pCoInternetCombineUrlEx(base, http_urlW, 0, NULL, 0);
9946     ok(hr == E_POINTER, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n",
9947         hr, E_POINTER);
9948     if(base) IUri_Release(base);
9949
9950     for(i = 0; i < sizeof(uri_combine_tests)/sizeof(uri_combine_tests[0]); ++i) {
9951         LPWSTR baseW = a2w(uri_combine_tests[i].base_uri);
9952
9953         hr = pCreateUri(baseW, uri_combine_tests[i].base_create_flags, 0, &base);
9954         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x on uri_combine_tests[%d].\n", hr, i);
9955         if(SUCCEEDED(hr)) {
9956             LPWSTR relativeW = a2w(uri_combine_tests[i].relative_uri);
9957
9958             hr = pCoInternetCombineUrlEx(base, relativeW, uri_combine_tests[i].combine_flags,
9959                                          &result, 0);
9960             if(uri_combine_tests[i].todo) {
9961                 todo_wine {
9962                     ok(hr == uri_combine_tests[i].expected,
9963                         "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9964                         hr, uri_combine_tests[i].expected, i);
9965                 }
9966             } else {
9967                 ok(hr == uri_combine_tests[i].expected,
9968                     "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].\n",
9969                     hr, uri_combine_tests[i]. expected, i);
9970             }
9971             if(SUCCEEDED(hr)) {
9972                 DWORD j;
9973
9974                 for(j = 0; j < sizeof(uri_combine_tests[i].str_props)/sizeof(uri_combine_tests[i].str_props[0]); ++j) {
9975                     uri_combine_str_property prop = uri_combine_tests[i].str_props[j];
9976                     BSTR received;
9977                     LPCSTR value = (prop.value_ex) ? prop.value_ex : prop.value;
9978
9979                     hr = IUri_GetPropertyBSTR(result, j, &received, 0);
9980                     if(prop.todo) {
9981                         todo_wine {
9982                             ok(hr == prop.expected,
9983                                 "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9984                                 hr, prop.expected, i, j);
9985                         }
9986                         todo_wine {
9987                             ok(!strcmp_aw(value, received) ||
9988                                broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9989                                 "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9990                                 value, wine_dbgstr_w(received), i, j);
9991                         }
9992                     } else {
9993                         ok(hr == prop.expected,
9994                             "Error: IUri_GetPropertyBSTR returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].str_props[%d].\n",
9995                             hr, prop.expected, i, j);
9996                         ok(!strcmp_aw(value, received) ||
9997                            broken(prop.broken_value && !strcmp_aw(prop.broken_value, received)),
9998                             "Error: Expected %s but got %s instead on uri_combine_tests[%d].str_props[%d].\n",
9999                             value, wine_dbgstr_w(received), i, j);
10000                     }
10001                     SysFreeString(received);
10002                 }
10003
10004                 for(j = 0; j < sizeof(uri_combine_tests[i].dword_props)/sizeof(uri_combine_tests[i].dword_props[0]); ++j) {
10005                     uri_dword_property prop = uri_combine_tests[i].dword_props[j];
10006                     DWORD received;
10007
10008                     hr = IUri_GetPropertyDWORD(result, j+Uri_PROPERTY_DWORD_START, &received, 0);
10009                     if(prop.todo) {
10010                         todo_wine {
10011                             ok(hr == prop.expected,
10012                                 "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
10013                                 hr, prop.expected, i, j);
10014                         }
10015                         todo_wine {
10016                             ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
10017                                 prop.value, received, i, j);
10018                         }
10019                     } else {
10020                         ok(hr == prop.expected,
10021                             "Error: IUri_GetPropertyDWORD returned 0x%08x, expected 0x%08x on uri_combine_tests[%d].dword_props[%d].\n",
10022                             hr, prop.expected, i, j);
10023                         ok(prop.value == received, "Error: Expected %d, but got %d instead on uri_combine_tests[%d].dword_props[%d].\n",
10024                             prop.value, received, i, j);
10025                     }
10026                 }
10027             }
10028             if(result) IUri_Release(result);
10029             heap_free(relativeW);
10030         }
10031         if(base) IUri_Release(base);
10032         heap_free(baseW);
10033     }
10034 }
10035
10036 static void test_CoInternetCombineUrlEx_Pluggable(void) {
10037     HRESULT hr;
10038     IUri *base = NULL;
10039
10040     hr = pCreateUri(combine_baseW, 0, 0, &base);
10041     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
10042     if(SUCCEEDED(hr)) {
10043         IUri *result = NULL;
10044
10045         SET_EXPECT(CombineUrl);
10046
10047         hr = pCoInternetCombineUrlEx(base, combine_relativeW, URL_DONT_SIMPLIFY|URL_FILE_USE_PATHURL|URL_DONT_UNESCAPE_EXTRA_INFO,
10048                                      &result, 0);
10049         ok(hr == S_OK, "Error: CoInternetCombineUrlEx returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
10050
10051         CHECK_CALLED(CombineUrl);
10052
10053         if(SUCCEEDED(hr)) {
10054             BSTR received = NULL;
10055             hr = IUri_GetAbsoluteUri(result, &received);
10056             ok(hr == S_OK, "Error: Expected S_OK, but got 0x%08x instead.\n", hr);
10057             if(SUCCEEDED(hr)) {
10058                 ok(!lstrcmpW(combine_resultW, received), "Error: Expected %s, but got %s.\n",
10059                     wine_dbgstr_w(combine_resultW), wine_dbgstr_w(received));
10060             }
10061             SysFreeString(received);
10062         }
10063         if(result) IUri_Release(result);
10064     }
10065     if(base) IUri_Release(base);
10066 }
10067
10068 static void test_CoInternetParseIUri_InvalidArgs(void) {
10069     HRESULT hr;
10070     IUri *uri = NULL;
10071     WCHAR tmp[3];
10072     DWORD result = -1;
10073
10074     hr = pCoInternetParseIUri(NULL, PARSE_CANONICALIZE, 0, tmp, 3, &result, 0);
10075     ok(hr == E_INVALIDARG, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10076         hr, E_INVALIDARG);
10077     ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10078
10079     hr = pCreateUri(http_urlW, 0, 0, &uri);
10080     ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x.\n", hr);
10081     if(SUCCEEDED(hr)) {
10082         DWORD expected_len;
10083
10084         result = -1;
10085         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, NULL, 0, &result, 0);
10086         ok(hr == E_INVALIDARG, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10087             hr, E_INVALIDARG);
10088         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10089
10090         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, tmp, 3, NULL, 0);
10091         ok(hr == E_POINTER, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10092             hr, E_POINTER);
10093
10094         result = -1;
10095         hr = pCoInternetParseIUri(uri, PARSE_SECURITY_URL, 0, tmp, 3, &result, 0);
10096         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x expected 0x%08x.\n",
10097             hr, E_FAIL);
10098         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10099
10100         result = -1;
10101         hr = pCoInternetParseIUri(uri, PARSE_MIME, 0, tmp, 3, &result, 0);
10102         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10103             hr, E_FAIL);
10104         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10105
10106         result = -1;
10107         hr = pCoInternetParseIUri(uri, PARSE_SERVER, 0, tmp, 3, &result, 0);
10108         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10109             hr, E_FAIL);
10110         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10111
10112         result = -1;
10113         hr = pCoInternetParseIUri(uri, PARSE_SECURITY_DOMAIN, 0, tmp, 3, &result, 0);
10114         ok(hr == E_FAIL, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10115             hr, E_FAIL);
10116         ok(!result, "Error: Expected 'result' to be 0, but was %d.\n", result);
10117
10118         expected_len = lstrlenW(http_urlW);
10119         result = -1;
10120         hr = pCoInternetParseIUri(uri, PARSE_CANONICALIZE, 0, tmp, 3, &result, 0);
10121         ok(hr == STRSAFE_E_INSUFFICIENT_BUFFER,
10122             "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n",
10123             hr, STRSAFE_E_INSUFFICIENT_BUFFER);
10124         ok(result == expected_len, "Error: Expected 'result' to be %d, but was %d instead.\n",
10125             expected_len, result);
10126     }
10127     if(uri) IUri_Release(uri);
10128 }
10129
10130 static void test_CoInternetParseIUri(void) {
10131     DWORD i;
10132
10133     for(i = 0; i < sizeof(uri_parse_tests)/sizeof(uri_parse_tests[0]); ++i) {
10134         HRESULT hr;
10135         IUri *uri;
10136         LPWSTR uriW;
10137         uri_parse_test test = uri_parse_tests[i];
10138
10139         uriW = a2w(test.uri);
10140         hr = pCreateUri(uriW, test.uri_flags, 0, &uri);
10141         ok(SUCCEEDED(hr), "Error: CreateUri returned 0x%08x on uri_parse_tests[%d].\n", hr, i);
10142         if(SUCCEEDED(hr)) {
10143             WCHAR result[INTERNET_MAX_URL_LENGTH+1];
10144             DWORD result_len = -1;
10145
10146             hr = pCoInternetParseIUri(uri, test.action, test.flags, result, INTERNET_MAX_URL_LENGTH+1, &result_len, 0);
10147             if(test.todo) {
10148                 todo_wine {
10149                     ok(hr == test.expected,
10150                         "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x on uri_parse_tests[%d].\n",
10151                         hr, test.expected, i);
10152                 }
10153             } else {
10154                 ok(hr == test.expected,
10155                     "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x on uri_parse_tests[%d].\n",
10156                     hr, test.expected, i);
10157             }
10158             if(SUCCEEDED(hr)) {
10159                 DWORD len = lstrlenA(test.property);
10160                 ok(!strcmp_aw(test.property, result),
10161                     "Error: Expected %s but got %s instead on uri_parse_tests[%d].\n",
10162                     test.property, wine_dbgstr_w(result), i);
10163                 ok(len == result_len,
10164                     "Error: Expected %d, but got %d instead on uri_parse_tests[%d].\n",
10165                     len, result_len, i);
10166             } else {
10167                 ok(!result_len,
10168                     "Error: Expected 'result_len' to be 0, but was %d on uri_parse_tests[%d].\n",
10169                     result_len, i);
10170             }
10171         }
10172         if(uri) IUri_Release(uri);
10173         heap_free(uriW);
10174     }
10175 }
10176
10177 static void test_CoInternetParseIUri_Pluggable(void) {
10178     HRESULT hr;
10179     IUri *uri = NULL;
10180
10181     hr = pCreateUri(parse_urlW, 0, 0, &uri);
10182     ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, but got 0x%08x.\n", hr);
10183     if(SUCCEEDED(hr)) {
10184         WCHAR result[200];
10185         DWORD result_len;
10186
10187         SET_EXPECT(ParseUrl);
10188
10189         parse_action = PARSE_CANONICALIZE;
10190         parse_flags = URL_UNESCAPE|URL_ESCAPE_UNSAFE;
10191
10192         hr = pCoInternetParseIUri(uri, parse_action, parse_flags, result, 200, &result_len, 0);
10193         ok(hr == S_OK, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
10194
10195         CHECK_CALLED(ParseUrl);
10196
10197         if(SUCCEEDED(hr)) {
10198             ok(result_len == lstrlenW(parse_resultW), "Error: Expected %d, but got %d.\n",
10199                 lstrlenW(parse_resultW), result_len);
10200             ok(!lstrcmpW(result, parse_resultW), "Error: Expected %s, but got %s.\n",
10201                 wine_dbgstr_w(parse_resultW), wine_dbgstr_w(result));
10202         }
10203     }
10204     if(uri) IUri_Release(uri);
10205 }
10206
10207 typedef struct {
10208     const char *url;
10209     DWORD uri_flags;
10210     const char *base_url;
10211     DWORD base_uri_flags;
10212     const char *legacy_url;
10213     const char *uniform_url;
10214     const char *no_canon_url;
10215     const char *uri_url;
10216 } create_urlmon_test_t;
10217
10218 static const create_urlmon_test_t create_urlmon_tests[] = {
10219     {
10220         "http://www.winehq.org",Uri_CREATE_NO_CANONICALIZE,
10221         NULL,0,
10222         "http://www.winehq.org/",
10223         "http://www.winehq.org/",
10224         "http://www.winehq.org",
10225         "http://www.winehq.org"
10226     },
10227     {
10228         "file://c:\\dir\\file.txt",Uri_CREATE_NO_CANONICALIZE,
10229         NULL,0,
10230         "file://c:\\dir\\file.txt",
10231         "file:///c:/dir/file.txt",
10232         "file:///c:/dir/file.txt",
10233         "file:///c:/dir/file.txt"
10234     },
10235     {
10236         "file://c:\\dir\\file.txt",Uri_CREATE_FILE_USE_DOS_PATH,
10237         NULL,0,
10238         "file://c:\\dir\\file.txt",
10239         "file:///c:/dir/file.txt",
10240         "file:///c:/dir/file.txt",
10241         "file://c:\\dir\\file.txt"
10242     },
10243     {
10244         "dat%61",Uri_CREATE_ALLOW_RELATIVE,
10245         "http://www.winehq.org",0,
10246         "http://www.winehq.org/data",
10247         "http://www.winehq.org/data",
10248         "http://www.winehq.org:80/data",
10249     },
10250     {
10251         "file.txt",Uri_CREATE_ALLOW_RELATIVE,
10252         "file://c:\\dir\\x.txt",Uri_CREATE_NO_CANONICALIZE,
10253         "file://c:\\dir\\file.txt",
10254         "file:///c:/dir/file.txt",
10255         "file:///c:/dir/file.txt",
10256     },
10257     {
10258         "",Uri_CREATE_ALLOW_RELATIVE,
10259         NULL,0,
10260         "",
10261         "",
10262         "",
10263         ""
10264     },
10265     {
10266         "test",Uri_CREATE_ALLOW_RELATIVE,
10267         NULL,0,
10268         "test",
10269         "test",
10270         "test",
10271         "test"
10272     },
10273     {
10274         "c:\\dir\\file.txt",Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME,
10275         NULL,0,
10276         "file://c:\\dir\\file.txt",
10277         "file:///c:/dir/file.txt",
10278         "file:///c:/dir/file.txt",
10279         "file:///c:/dir/file.txt",
10280     }
10281 };
10282
10283 #define test_urlmon_display_name(a,b) _test_urlmon_display_name(__LINE__,a,b)
10284 static void _test_urlmon_display_name(unsigned line, IMoniker *mon, const char *exurl)
10285 {
10286     WCHAR *display_name;
10287     HRESULT hres;
10288
10289     hres = IMoniker_GetDisplayName(mon, NULL, NULL, &display_name);
10290     ok_(__FILE__,line)(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
10291     ok_(__FILE__,line)(!strcmp_aw(exurl, display_name), "unexpected display name: %s, expected %s\n",
10292             wine_dbgstr_w(display_name), exurl);
10293
10294     CoTaskMemFree(display_name);
10295 }
10296
10297 #define test_display_uri(a,b) _test_display_uri(__LINE__,a,b)
10298 static void _test_display_uri(unsigned line, IMoniker *mon, const char *exurl)
10299 {
10300     IUriContainer *uri_container;
10301     IUri *uri;
10302     BSTR display_uri;
10303     HRESULT hres;
10304
10305     hres = IMoniker_QueryInterface(mon, &IID_IUriContainer, (void**)&uri_container);
10306     ok(hres == S_OK, "Could not get IUriContainer iface: %08x\n", hres);
10307
10308     uri = NULL;
10309     hres = IUriContainer_GetIUri(uri_container, &uri);
10310     IUriContainer_Release(uri_container);
10311     ok(hres == S_OK, "GetIUri failed: %08x\n", hres);
10312     ok(uri != NULL, "uri == NULL\n");
10313
10314     hres = IUri_GetDisplayUri(uri, &display_uri);
10315     IUri_Release(uri);
10316     ok(hres == S_OK, "GetDisplayUri failed: %08x\n", hres);
10317     ok_(__FILE__,line)(!strcmp_aw(exurl, display_uri), "unexpected display uri: %s, expected %s\n",
10318             wine_dbgstr_w(display_uri), exurl);
10319     SysFreeString(display_uri);
10320 }
10321
10322 static void test_CreateURLMoniker(void)
10323 {
10324     const create_urlmon_test_t *test;
10325     IMoniker *mon, *base_mon;
10326     WCHAR *url, *base_url;
10327     IUri *uri, *base_uri;
10328     HRESULT hres;
10329
10330     for(test = create_urlmon_tests; test < create_urlmon_tests + sizeof(create_urlmon_tests)/sizeof(*create_urlmon_tests); test++) {
10331         url = a2w(test->url);
10332         base_url = a2w(test->base_url);
10333
10334         if(base_url) {
10335             hres = pCreateUri(base_url, test->base_uri_flags, 0, &base_uri);
10336             ok(hres == S_OK, "CreateUri failed: %08x\n", hres);
10337
10338             hres = pCreateURLMonikerEx2(NULL, base_uri, &base_mon, URL_MK_NO_CANONICALIZE);
10339             ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10340         }else {
10341             base_uri = NULL;
10342             base_mon = NULL;
10343         }
10344
10345         hres = CreateURLMoniker(base_mon, url, &mon);
10346         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10347         test_urlmon_display_name(mon, test->legacy_url);
10348         test_display_uri(mon, test->legacy_url);
10349         IMoniker_Release(mon);
10350
10351         hres = pCreateURLMonikerEx(base_mon, url, &mon, URL_MK_LEGACY);
10352         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10353         test_urlmon_display_name(mon, test->legacy_url);
10354         test_display_uri(mon, test->legacy_url);
10355         IMoniker_Release(mon);
10356
10357         hres = pCreateURLMonikerEx(base_mon, url, &mon, URL_MK_UNIFORM);
10358         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10359         test_urlmon_display_name(mon, test->uniform_url);
10360         test_display_uri(mon, test->uniform_url);
10361         IMoniker_Release(mon);
10362
10363         hres = pCreateURLMonikerEx(base_mon, url, &mon, URL_MK_NO_CANONICALIZE);
10364         ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
10365         test_urlmon_display_name(mon, test->no_canon_url);
10366         test_display_uri(mon, test->no_canon_url);
10367         IMoniker_Release(mon);
10368
10369         hres = pCreateUri(url, test->uri_flags, 0, &uri);
10370         ok(hres == S_OK, "CreateUri failed: %08x\n", hres);
10371
10372         hres = pCreateURLMonikerEx2(base_mon, uri, &mon, URL_MK_LEGACY);
10373         ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10374         test_urlmon_display_name(mon, base_url ? test->legacy_url : test->uri_url);
10375         test_display_uri(mon, base_url ? test->legacy_url : test->uri_url);
10376         IMoniker_Release(mon);
10377
10378         hres = pCreateURLMonikerEx2(base_mon, uri, &mon, URL_MK_UNIFORM);
10379         ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10380         test_urlmon_display_name(mon, base_url ? test->uniform_url : test->uri_url);
10381         test_display_uri(mon, base_url ? test->uniform_url : test->uri_url);
10382         IMoniker_Release(mon);
10383
10384         hres = pCreateURLMonikerEx2(base_mon, uri, &mon, URL_MK_NO_CANONICALIZE);
10385         ok(hres == S_OK, "CreateURLMonikerEx2 failed: %08x\n", hres);
10386         test_urlmon_display_name(mon, base_url ? test->no_canon_url : test->uri_url);
10387         test_display_uri(mon, base_url ? test->no_canon_url : test->uri_url);
10388         IMoniker_Release(mon);
10389
10390         IUri_Release(uri);
10391         heap_free(url);
10392         heap_free(base_url);
10393         if(base_uri)
10394             IUri_Release(base_uri);
10395         if(base_mon)
10396             IMoniker_Release(base_mon);
10397     }
10398 }
10399
10400 START_TEST(uri) {
10401     HMODULE hurlmon;
10402
10403     hurlmon = GetModuleHandle("urlmon.dll");
10404     pCoInternetGetSession = (void*) GetProcAddress(hurlmon, "CoInternetGetSession");
10405     pCreateUri = (void*) GetProcAddress(hurlmon, "CreateUri");
10406     pCreateUriWithFragment = (void*) GetProcAddress(hurlmon, "CreateUriWithFragment");
10407     pCreateIUriBuilder = (void*) GetProcAddress(hurlmon, "CreateIUriBuilder");
10408     pCoInternetCombineIUri = (void*) GetProcAddress(hurlmon, "CoInternetCombineIUri");
10409     pCoInternetCombineUrlEx = (void*) GetProcAddress(hurlmon, "CoInternetCombineUrlEx");
10410     pCoInternetParseIUri = (void*) GetProcAddress(hurlmon, "CoInternetParseIUri");
10411     pCreateURLMonikerEx = (void*) GetProcAddress(hurlmon, "CreateURLMonikerEx");
10412     pCreateURLMonikerEx2 = (void*) GetProcAddress(hurlmon, "CreateURLMonikerEx2");
10413
10414     if(!pCreateUri) {
10415         win_skip("CreateUri is not present, skipping tests.\n");
10416         return;
10417     }
10418
10419     trace("test CreateUri invalid flags...\n");
10420     test_CreateUri_InvalidFlags();
10421
10422     trace("test CreateUri invalid args...\n");
10423     test_CreateUri_InvalidArgs();
10424
10425     trace("test CreateUri invalid URIs...\n");
10426     test_CreateUri_InvalidUri();
10427
10428     trace("test IUri_GetPropertyBSTR...\n");
10429     test_IUri_GetPropertyBSTR();
10430
10431     trace("test IUri_GetPropertyDWORD...\n");
10432     test_IUri_GetPropertyDWORD();
10433
10434     trace("test IUri_GetStrProperties...\n");
10435     test_IUri_GetStrProperties();
10436
10437     trace("test IUri_GetDwordProperties...\n");
10438     test_IUri_GetDwordProperties();
10439
10440     trace("test IUri_GetPropertyLength...\n");
10441     test_IUri_GetPropertyLength();
10442
10443     trace("test IUri_GetProperties...\n");
10444     test_IUri_GetProperties();
10445
10446     trace("test IUri_HasProperty...\n");
10447     test_IUri_HasProperty();
10448
10449     trace("test IUri_IsEqual...\n");
10450     test_IUri_IsEqual();
10451
10452     trace("test CreateUriWithFragment invalid args...\n");
10453     test_CreateUriWithFragment_InvalidArgs();
10454
10455     trace("test CreateUriWithFragment invalid flags...\n");
10456     test_CreateUriWithFragment_InvalidFlags();
10457
10458     trace("test CreateUriWithFragment...\n");
10459     test_CreateUriWithFragment();
10460
10461     trace("test CreateIUriBuilder...\n");
10462     test_CreateIUriBuilder();
10463
10464     trace("test IUriBuilder_CreateInvalidArgs...\n");
10465     test_IUriBuilder_CreateInvalidArgs();
10466
10467     trace("test IUriBuilder...\n");
10468     test_IUriBuilder();
10469
10470     trace("test IUriBuilder_GetInvalidArgs...\n");
10471     test_IUriBuilder_GetInvalidArgs();
10472
10473     trace("test IUriBuilder_HasBeenModified...\n");
10474     test_IUriBuilder_HasBeenModified();
10475
10476     trace("test IUriBuilder_IUriProperty...\n");
10477     test_IUriBuilder_IUriProperty();
10478
10479     trace("test IUriBuilder_RemoveProperties...\n");
10480     test_IUriBuilder_RemoveProperties();
10481
10482     trace("test IUriBuilder miscellaneous...\n");
10483     test_IUriBuilder_Misc();
10484
10485     trace("test IUriBuilderFactory...\n");
10486     test_IUriBuilderFactory();
10487
10488     trace("test CoInternetCombineIUri...\n");
10489     test_CoInternetCombineIUri();
10490
10491     trace("test CoInternetCombineUrlEx...\n");
10492     test_CoInternetCombineUrlEx();
10493
10494     trace("test CoInternetParseIUri Invalid Args...\n");
10495     test_CoInternetParseIUri_InvalidArgs();
10496
10497     trace("test CoInternetParseIUri...\n");
10498     test_CoInternetParseIUri();
10499
10500     register_protocols();
10501
10502     trace("test CoInternetCombineIUri pluggable...\n");
10503     test_CoInternetCombineIUri_Pluggable();
10504
10505     trace("test CoInternetCombineUrlEx Pluggable...\n");
10506     test_CoInternetCombineUrlEx_Pluggable();
10507
10508     trace("test CoInternetParseIUri pluggable...\n");
10509     test_CoInternetParseIUri_Pluggable();
10510
10511     trace("test CreateURLMoniker...\n");
10512     test_CreateURLMoniker();
10513
10514     unregister_protocols();
10515 }