VirtualBox

source: vbox/trunk/src/VBox/Runtime/testcase/tstRTUri.cpp@ 102792

Last change on this file since 102792 was 98103, checked in by vboxsync, 22 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 38.7 KB
Line 
1/* $Id: tstRTUri.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * IPRT Testcase - URI parsing and creation.
4 */
5
6/*
7 * Copyright (C) 2011-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37
38/*********************************************************************************************************************************
39* Header Files *
40*********************************************************************************************************************************/
41#include <iprt/uri.h>
42
43#include <iprt/string.h>
44#include <iprt/err.h>
45#include <iprt/mem.h>
46#include <iprt/path.h>
47#include <iprt/test.h>
48
49#if 0 && defined(RT_OS_WINDOWS) /* Enable for windows API reference results. */
50# define TSTRTURI_WITH_WINDOWS_REFERENCE_RESULTS
51# include <iprt/win/shlwapi.h>
52# include <iprt/stream.h>
53#endif
54
55
56/*********************************************************************************************************************************
57* Test data *
58*********************************************************************************************************************************/
59
60static struct
61{
62 const char *pszUri;
63 const char *pszScheme;
64 const char *pszAuthority;
65 const char *pszPath;
66 const char *pszQuery;
67 const char *pszFragment;
68
69 const char *pszUsername;
70 const char *pszPassword;
71 const char *pszHost;
72 uint32_t uPort;
73
74 const char *pszCreated;
75} g_aTests[] =
76{
77 { /* #0 */
78 "foo://tt:yt@example.com:8042/over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there?name=%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60ferret#nose%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60",
79 /*.pszScheme =*/ "foo",
80 /*.pszAuthority =*/ "tt:yt@example.com:8042",
81 /*.pszPath =*/ "/over/ <>#%\"{}|^[]`/there",
82 /*.pszQuery =*/ "name= <>#%\"{}|^[]`ferret",
83 /*.pszFragment =*/ "nose <>#%\"{}|^[]`",
84 /*.pszUsername =*/ "tt",
85 /*.pszPassword =*/ "yt",
86 /*.pszHost =*/ "example.com",
87 /*.uPort =*/ 8042,
88 /*.pszCreated =*/ NULL /* same as pszUri*/,
89 },
90 { /* #1 */
91 "foo://tt:yt@example.com:8042/over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there?name=%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60ferret",
92 /*.pszScheme =*/ "foo",
93 /*.pszAuthority =*/ "tt:yt@example.com:8042",
94 /*.pszPath =*/ "/over/ <>#%\"{}|^[]`/there",
95 /*.pszQuery =*/ "name= <>#%\"{}|^[]`ferret",
96 /*.pszFragment =*/ NULL,
97 /*.pszUsername =*/ "tt",
98 /*.pszPassword =*/ "yt",
99 /*.pszHost =*/ "example.com",
100 /*.uPort =*/ 8042,
101 /*.pszCreated =*/ NULL /* same as pszUri*/,
102 },
103 { /* #2 */
104 "foo://tt:yt@example.com:8042/over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there",
105 /*.pszScheme =*/ "foo",
106 /*.pszAuthority =*/ "tt:yt@example.com:8042",
107 /*.pszPath =*/ "/over/ <>#%\"{}|^[]`/there",
108 /*.pszQuery =*/ NULL,
109 /*.pszFragment =*/ NULL,
110 /*.pszUsername =*/ "tt",
111 /*.pszPassword =*/ "yt",
112 /*.pszHost =*/ "example.com",
113 /*.uPort =*/ 8042,
114 /*.pszCreated =*/ NULL /* same as pszUri*/,
115 },
116 { /* #3 */
117 "foo:tt@example.com",
118 /*.pszScheme =*/ "foo",
119 /*.pszAuthority =*/ NULL,
120 /*.pszPath =*/ "tt@example.com",
121 /*.pszQuery =*/ NULL,
122 /*.pszFragment =*/ NULL,
123 /*.pszUsername =*/ NULL,
124 /*.pszPassword =*/ NULL,
125 /*.pszHost =*/ NULL,
126 /*.uPort =*/ UINT32_MAX,
127 /*.pszCreated =*/ NULL /* same as pszUri*/,
128 },
129 { /* #4 */
130 "foo:/over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there?name=%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60ferret#nose%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60",
131 /*.pszScheme =*/ "foo",
132 /*.pszAuthority =*/ NULL,
133 /*.pszPath =*/ "/over/ <>#%\"{}|^[]`/there",
134 /*.pszQuery =*/ "name= <>#%\"{}|^[]`ferret",
135 /*.pszFragment =*/ "nose <>#%\"{}|^[]`",
136 /*.pszUsername =*/ NULL,
137 /*.pszPassword =*/ NULL,
138 /*.pszHost =*/ NULL,
139 /*.uPort =*/ UINT32_MAX,
140 /*.pszCreated =*/ NULL /* same as pszUri*/,
141 },
142 { /* #5 */
143 "foo:/over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there#nose%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60",
144 /*.pszScheme =*/ "foo",
145 /*.pszAuthority =*/ NULL,
146 /*.pszPath =*/ "/over/ <>#%\"{}|^[]`/there",
147 /*.pszQuery =*/ NULL,
148 /*.pszFragment =*/ "nose <>#%\"{}|^[]`",
149 /*.pszUsername =*/ NULL,
150 /*.pszPassword =*/ NULL,
151 /*.pszHost =*/ NULL,
152 /*.uPort =*/ UINT32_MAX,
153 /*.pszCreated =*/ NULL /* same as pszUri*/,
154 },
155 { /* #6 */
156 "urn:example:animal:ferret:nose",
157 /*.pszScheme =*/ "urn",
158 /*.pszAuthority =*/ NULL,
159 /*.pszPath =*/ "example:animal:ferret:nose",
160 /*.pszQuery =*/ NULL,
161 /*.pszFragment =*/ NULL,
162 /*.pszUsername =*/ NULL,
163 /*.pszPassword =*/ NULL,
164 /*.pszHost =*/ NULL,
165 /*.uPort =*/ UINT32_MAX,
166 /*.pszCreated =*/ NULL /* same as pszUri*/,
167 },
168 { /* #7 */
169 "foo:?name=%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60ferret#nose%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60",
170 /*.pszScheme =*/ "foo",
171 /*.pszAuthority =*/ NULL,
172 /*.pszPath =*/ NULL,
173 /*.pszQuery =*/ "name= <>#%\"{}|^[]`ferret",
174 /*.pszFragment =*/ "nose <>#%\"{}|^[]`",
175 /*.pszUsername =*/ NULL,
176 /*.pszPassword =*/ NULL,
177 /*.pszHost =*/ NULL,
178 /*.uPort =*/ UINT32_MAX,
179 /*.pszCreated =*/ NULL /* same as pszUri*/,
180 },
181 { /* #8 */
182 "foo:#nose%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60",
183 /*.pszScheme =*/ "foo",
184 /*.pszAuthority =*/ NULL,
185 /*.pszPath =*/ NULL,
186 /*.pszQuery =*/ NULL,
187 /*.pszFragment =*/ "nose <>#%\"{}|^[]`",
188 /*.pszUsername =*/ NULL,
189 /*.pszPassword =*/ NULL,
190 /*.pszHost =*/ NULL,
191 /*.uPort =*/ UINT32_MAX,
192 /*.pszCreated =*/ NULL /* same as pszUri*/,
193 },
194 { /* #9 */
195 "foo://tt:yt@example.com:8042/?name=%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60ferret#nose%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60",
196 /*.pszScheme =*/ "foo",
197 /*.pszAuthority =*/ "tt:yt@example.com:8042",
198 /*.pszPath =*/ "/",
199 /*.pszQuery =*/ "name= <>#%\"{}|^[]`ferret",
200 /*.pszFragment =*/ "nose <>#%\"{}|^[]`",
201 /*.pszUsername =*/ "tt",
202 /*.pszPassword =*/ "yt",
203 /*.pszHost =*/ "example.com",
204 /*.uPort =*/ 8042,
205 /*.pszCreated =*/ NULL /* same as pszUri*/,
206 },
207 { /* #10 */
208 "foo://tt:yt@example.com:8042/",
209 /*.pszScheme =*/ "foo",
210 /*.pszAuthority =*/ "tt:yt@example.com:8042",
211 /*.pszPath =*/ "/",
212 /*.pszQuery =*/ NULL,
213 /*.pszFragment =*/ NULL,
214 /*.pszUsername =*/ "tt",
215 /*.pszPassword =*/ "yt",
216 /*.pszHost =*/ "example.com",
217 /*.uPort =*/ 8042,
218 /*.pszCreated =*/ NULL /* same as pszUri*/,
219 },
220 { /* #11 */
221 "foo://tt:yt@example.com:8042?name=%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60ferret#nose%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60",
222 /*.pszScheme =*/ "foo",
223 /*.pszAuthority =*/ "tt:yt@example.com:8042",
224 /*.pszPath =*/ NULL,
225 /*.pszQuery =*/ "name= <>#%\"{}|^[]`ferret",
226 /*.pszFragment =*/ "nose <>#%\"{}|^[]`",
227 /*.pszUsername =*/ "tt",
228 /*.pszPassword =*/ "yt",
229 /*.pszHost =*/ "example.com",
230 /*.uPort =*/ 8042,
231 /*.pszCreated =*/ NULL /* same as pszUri*/,
232 },
233 { /* #12 */
234 "foo://tt:yt@example.com:8042#nose%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60",
235 /*.pszScheme =*/ "foo",
236 /*.pszAuthority =*/ "tt:yt@example.com:8042",
237 /*.pszPath =*/ NULL,
238 /*.pszQuery =*/ NULL,
239 /*.pszFragment =*/ "nose <>#%\"{}|^[]`",
240 /*.pszUsername =*/ "tt",
241 /*.pszPassword =*/ "yt",
242 /*.pszHost =*/ "example.com",
243 /*.uPort =*/ 8042,
244 /*.pszCreated =*/ NULL /* same as pszUri*/,
245 },
246 { /* #13 */
247 "foo://tt:yt@example.com:8042",
248 /*.pszScheme =*/ "foo",
249 /*.pszAuthority =*/ "tt:yt@example.com:8042",
250 /*.pszPath =*/ NULL,
251 /*.pszQuery =*/ NULL,
252 /*.pszFragment =*/ NULL,
253 /*.pszUsername =*/ "tt",
254 /*.pszPassword =*/ "yt",
255 /*.pszHost =*/ "example.com",
256 /*.uPort =*/ 8042,
257 /*.pszCreated =*/ NULL /* same as pszUri*/,
258 },
259 { /* #14 */
260 "file:///dir/dir/file",
261 /*.pszScheme =*/ "file",
262 /*.pszAuthority =*/ "",
263 /*.pszPath =*/ "/dir/dir/file",
264 /*.pszQuery =*/ NULL,
265 /*.pszFragment =*/ NULL,
266 /*.pszUsername =*/ NULL,
267 /*.pszPassword =*/ NULL,
268 /*.pszHost =*/ NULL,
269 /*.uPort =*/ UINT32_MAX,
270 /*.pszCreated =*/ NULL /* same as pszUri*/,
271 },
272 { /* #15 */
273 "foo:///",
274 /*.pszScheme =*/ "foo",
275 /*.pszAuthority =*/ "",
276 /*.pszPath =*/ "/",
277 /*.pszQuery =*/ NULL,
278 /*.pszFragment =*/ NULL,
279 /*.pszUsername =*/ NULL,
280 /*.pszPassword =*/ NULL,
281 /*.pszHost =*/ NULL,
282 /*.uPort =*/ UINT32_MAX,
283 /*.pszCreated =*/ NULL /* same as pszUri*/,
284 },
285 { /* #16 */
286 "foo://",
287 /*.pszScheme =*/ "foo",
288 /*.pszAuthority =*/ "",
289 /*.pszPath =*/ NULL,
290 /*.pszQuery =*/ NULL,
291 /*.pszFragment =*/ NULL,
292 /*.pszUsername =*/ NULL,
293 /*.pszPassword =*/ NULL,
294 /*.pszHost =*/ NULL,
295 /*.uPort =*/ UINT32_MAX,
296 /*.pszCreated =*/ NULL /* same as pszUri*/,
297 },
298 { /* #17 - UTF-8 escape sequences. */
299 "http://example.com/%ce%b3%ce%bb%cf%83%ce%b1%20%e0%a4%95\xe0\xa4\x95",
300 /*.pszScheme =*/ "http",
301 /*.pszAuthority =*/ "example.com",
302 /*.pszPath =*/ "/\xce\xb3\xce\xbb\xcf\x83\xce\xb1 \xe0\xa4\x95\xe0\xa4\x95",
303 /*.pszQuery =*/ NULL,
304 /*.pszFragment =*/ NULL,
305 /*.pszUsername =*/ NULL,
306 /*.pszPassword =*/ NULL,
307 /*.pszHost =*/ "example.com",
308 /*.uPort =*/ UINT32_MAX,
309 /*.pszCreated =*/ "http://example.com/\xce\xb3\xce\xbb\xcf\x83\xce\xb1%20\xe0\xa4\x95\xe0\xa4\x95",
310 },
311};
312
313
314static struct URIFILETEST
315{
316 const char *pszPath;
317 uint32_t fPathPathStyle;
318 const char *pszUri;
319 uint32_t fUriPathStyle;
320 const char *pszCreatedPath;
321 const char *pszCreatedUri;
322} g_aCreateFileURIs[] =
323{
324 { /* #0: */
325 /* .pszPath =*/ "C:\\over\\ <>#%\"{}|^[]`\\there",
326 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
327 /* .pszUri =*/ "file:///C:%5Cover/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60%5Cthere",
328 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
329 /* .pszCreatedPath =*/ "C:\\over\\ <>#%\"{}|^[]`\\there",
330 /* .pszCreatedUri =*/ "file:///C:/over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there",
331 /* PathCreateFromUrl = "C:\\over\\ <>#%\"{}|^[]`\\there" - same */
332 /* UrlCreateFromPath = "file:///C:/over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there" - same */
333 },
334 { /* #1: */
335 /* .pszPath =*/ "/over/ <>#%\"{}|^[]`/there",
336 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_UNIX,
337 /* .pszUri =*/ "file:///over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there",
338 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_UNIX,
339 /* .pszCreatedPath =*/ "/over/ <>#%\"{}|^[]`/there",
340 /* .pszCreatedUri =*/ "file:///over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there",
341 /* PathCreateFromUrl = "\\over\\ <>#%\"{}|^[]`\\there" - differs */
342 /* UrlCreateFromPath = "file:///over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there" - same */
343 },
344 { /* #2: */
345 /* .pszPath =*/ NULL,
346 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_UNIX,
347 /* .pszUri =*/ "file://",
348 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_UNIX,
349 /* .pszCreatedPath =*/ NULL,
350 /* .pszCreatedUri =*/ NULL,
351 /* PathCreateFromUrl = "" - differs */
352 /* UrlCreateFromPath => 0x80070057 (E_INVALIDARG) */
353 },
354 { /* #3: */
355 /* .pszPath =*/ NULL,
356 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
357 /* .pszUri =*/ "file://",
358 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
359 /* .pszCreatedPath =*/ NULL,
360 /* .pszCreatedUri =*/ NULL,
361 /* PathCreateFromUrl = "" - differs */
362 /* UrlCreateFromPath => 0x80070057 (E_INVALIDARG) */
363 },
364 { /* #4: */
365 /* .pszPath =*/ "/",
366 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_UNIX,
367 /* .pszUri =*/ "file:///",
368 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_UNIX,
369 /* .pszCreatedPath =*/ "/",
370 /* .pszCreatedUri =*/ "file:///",
371 /* PathCreateFromUrl = "" - differs */
372 /* UrlCreateFromPath = "file:///" - same */
373 },
374 { /* #5: */
375 /* .pszPath =*/ "\\",
376 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
377 /* .pszUri =*/ "file:///",
378 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
379 /* .pszCreatedPath =*/ "\\",
380 /* .pszCreatedUri =*/ "file:///",
381 /* PathCreateFromUrl = "" - differs */
382 /* UrlCreateFromPath = "file:///" - same */
383 },
384 { /* #6: */
385 /* .pszPath =*/ "/foo/bar",
386 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_UNIX,
387 /* .pszUri =*/ "file:///foo/bar",
388 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_UNIX,
389 /* .pszCreatedPath =*/ "/foo/bar",
390 /* .pszCreatedUri =*/ "file:///foo/bar",
391 /* PathCreateFromUrl = "\\foo\\bar" - differs */
392 /* UrlCreateFromPath = "file:///foo/bar" - same */
393 },
394 { /* #7: */
395 /* .pszPath =*/ "\\foo\\bar",
396 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
397 /* .pszUri =*/ "file:///foo%5Cbar",
398 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
399 /* .pszCreatedPath =*/ "\\foo\\bar",
400 /* .pszCreatedUri =*/ "file:///foo/bar",
401 /* PathCreateFromUrl = "\\foo\\bar" - same */
402 /* UrlCreateFromPath = "file:///foo/bar" - same */
403 },
404 { /* #8: */
405 /* .pszPath =*/ "C:/over/ <>#%\"{}|^[]`/there",
406 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_UNIX,
407 /* .pszUri =*/ "file:///C:/over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there",
408 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_UNIX,
409 /* .pszCreatedPath =*/ "C:/over/ <>#%\"{}|^[]`/there",
410 /* .pszCreatedUri =*/ "file:///C:/over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there",
411 /* PathCreateFromUrl = "C:\\over\\ <>#%\"{}|^[]`\\there" - differs */
412 /* UrlCreateFromPath = "file:///C:/over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there" - same */
413 },
414 { /* #9: */
415 /* .pszPath =*/ "\\over\\ <>#%\"{}|^[]`\\there",
416 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
417 /* .pszUri =*/ "file:///over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there",
418 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
419 /* .pszCreatedPath =*/ "\\over\\ <>#%\"{}|^[]`\\there",
420 /* .pszCreatedUri =*/ "file:///over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there",
421 /* PathCreateFromUrl = "\\over\\ <>#%\"{}|^[]`\\there" - same */
422 /* UrlCreateFromPath = "file:///over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there" - same */
423 },
424 { /* #10: */
425 /* .pszPath =*/ "/usr/bin/grep",
426 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_UNIX,
427 /* .pszUri =*/ "file:///usr/bin/grep",
428 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_UNIX,
429 /* .pszCreatedPath =*/ "/usr/bin/grep",
430 /* .pszCreatedUri =*/ "file:///usr/bin/grep",
431 /* PathCreateFromUrl = "\\usr\\bin\\grep" - differs */
432 /* UrlCreateFromPath = "file:///usr/bin/grep" - same */
433 },
434 { /* #11: */
435 /* .pszPath =*/ "\\usr\\bin\\grep",
436 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
437 /* .pszUri =*/ "file:///usr/bin/grep",
438 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
439 /* .pszCreatedPath =*/ "\\usr\\bin\\grep",
440 /* .pszCreatedUri =*/ "file:///usr/bin/grep",
441 /* PathCreateFromUrl = "\\usr\\bin\\grep" - same */
442 /* UrlCreateFromPath = "file:///usr/bin/grep" - same */
443 },
444 { /* #12: */
445 /* .pszPath =*/ "/somerootsubdir/isos/files.lst",
446 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_UNIX,
447 /* .pszUri =*/ "file:///somerootsubdir/isos/files.lst",
448 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_UNIX,
449 /* .pszCreatedPath =*/ "/somerootsubdir/isos/files.lst",
450 /* .pszCreatedUri =*/ "file:///somerootsubdir/isos/files.lst",
451 /* PathCreateFromUrl = "\\somerootsubdir\\isos\\files.lst" - differs */
452 /* UrlCreateFromPath = "file:///somerootsubdir/isos/files.lst" - same */
453 },
454 { /* #13: */
455 /* .pszPath =*/ "\\not-a-cifsserver\\isos\\files.lst",
456 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
457 /* .pszUri =*/ "file:///not-a-cifsserver/isos/files.lst",
458 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
459 /* .pszCreatedPath =*/ "\\not-a-cifsserver\\isos\\files.lst",
460 /* .pszCreatedUri =*/ "file:///not-a-cifsserver/isos/files.lst",
461 /* PathCreateFromUrl = "\\not-a-cifsserver\\isos\\files.lst" - same */
462 /* UrlCreateFromPath = "file:///not-a-cifsserver/isos/files.lst" - same */
463 },
464 { /* #14: */
465 /* .pszPath =*/ "/rootsubdir/isos/files.lst",
466 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_UNIX,
467 /* .pszUri =*/ "file:///rootsubdir/isos/files.lst",
468 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_UNIX,
469 /* .pszCreatedPath =*/ "/rootsubdir/isos/files.lst",
470 /* .pszCreatedUri =*/ "file:///rootsubdir/isos/files.lst",
471 /* PathCreateFromUrl = "\\rootsubdir\\isos\\files.lst" - differs */
472 /* UrlCreateFromPath = "file:///rootsubdir/isos/files.lst" - same */
473 },
474 { /* #15: */
475 /* .pszPath =*/ "\\not-a-cifsserver-either\\isos\\files.lst",
476 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
477 /* .pszUri =*/ "file:///not-a-cifsserver-either/isos/files.lst",
478 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
479 /* .pszCreatedPath =*/ "\\not-a-cifsserver-either\\isos\\files.lst",
480 /* .pszCreatedUri =*/ "file:///not-a-cifsserver-either/isos/files.lst",
481 /* PathCreateFromUrl = "\\not-a-cifsserver-either\\isos\\files.lst" - same */
482 /* UrlCreateFromPath = "file:///not-a-cifsserver-either/isos/files.lst" - same */
483 },
484 { /* #16: */
485 /* .pszPath =*/ "\\\\cifsserver\\isos\\files.lst",
486 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
487 /* .pszUri =*/ "file:////cifsserver/isos/files.lst",
488 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
489 /* .pszCreatedPath =*/ "\\\\cifsserver\\isos\\files.lst",
490 /* .pszCreatedUri =*/ "file://cifsserver/isos/files.lst",
491 /* PathCreateFromUrl = "\\\\cifsserver\\isos\\files.lst" - same */
492 /* UrlCreateFromPath = "file://cifsserver/isos/files.lst" - same */
493 },
494 { /* #17: */
495 /* .pszPath =*/ "c:boot.ini",
496 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
497 /* .pszUri =*/ "file://localhost/c:boot.ini",
498 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
499 /* .pszCreatedPath =*/ "c:boot.ini",
500 /* .pszCreatedUri =*/ "file:///c:boot.ini",
501 /* PathCreateFromUrl = "c:boot.ini" - same */
502 /* UrlCreateFromPath = "file:///c:boot.ini" - same */
503 },
504 { /* #18: */
505 /* .pszPath =*/ "c:boot.ini",
506 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
507 /* .pszUri =*/ "file:///c|boot.ini",
508 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
509 /* .pszCreatedPath =*/ "c:boot.ini",
510 /* .pszCreatedUri =*/ "file:///c:boot.ini",
511 /* PathCreateFromUrl = "c:boot.ini" - same */
512 /* UrlCreateFromPath = "file:///c:boot.ini" - same */
513 },
514 { /* #19: */
515 /* .pszPath =*/ "c:\\legacy-no-slash.ini",
516 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
517 /* .pszUri =*/ "file:c:\\legacy-no-slash%2Eini",
518 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
519 /* .pszCreatedPath =*/ "c:\\legacy-no-slash.ini",
520 /* .pszCreatedUri =*/ "file:///c:/legacy-no-slash.ini",
521 /* PathCreateFromUrl = "c:\\legacy-no-slash.ini" - same */
522 /* UrlCreateFromPath = "file:///c:/legacy-no-slash.ini" - same */
523 },
524 { /* #20: */
525 /* .pszPath =*/ "c:\\legacy-no-slash.ini",
526 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
527 /* .pszUri =*/ "file:c|\\legacy-no-slash%2Eini",
528 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
529 /* .pszCreatedPath =*/ "c:\\legacy-no-slash.ini",
530 /* .pszCreatedUri =*/ "file:///c:/legacy-no-slash.ini",
531 /* PathCreateFromUrl = "c:\\legacy-no-slash.ini" - same */
532 /* UrlCreateFromPath = "file:///c:/legacy-no-slash.ini" - same */
533 },
534 { /* #21: */
535 /* .pszPath =*/ "c:\\legacy-single-slash.ini",
536 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
537 /* .pszUri =*/ "file:/c:\\legacy-single-slash%2Eini",
538 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
539 /* .pszCreatedPath =*/ "c:\\legacy-single-slash.ini",
540 /* .pszCreatedUri =*/ "file:///c:/legacy-single-slash.ini",
541 /* PathCreateFromUrl = "c:\\legacy-single-slash.ini" - same */
542 /* UrlCreateFromPath = "file:///c:/legacy-single-slash.ini" - same */
543 },
544 { /* #22: */
545 /* .pszPath =*/ "c:\\legacy-single-slash.ini",
546 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
547 /* .pszUri =*/ "file:/c:\\legacy-single-slash%2Eini",
548 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
549 /* .pszCreatedPath =*/ "c:\\legacy-single-slash.ini",
550 /* .pszCreatedUri =*/ "file:///c:/legacy-single-slash.ini",
551 /* PathCreateFromUrl = "c:\\legacy-single-slash.ini" - same */
552 /* UrlCreateFromPath = "file:///c:/legacy-single-slash.ini" - same */
553 },
554 { /* #23: */
555 /* .pszPath =*/ "\\legacy-single-slash.ini",
556 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
557 /* .pszUri =*/ "file:/legacy-single-slash%2Eini",
558 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
559 /* .pszCreatedPath =*/ "\\legacy-single-slash.ini",
560 /* .pszCreatedUri =*/ "file:///legacy-single-slash.ini",
561 /* PathCreateFromUrl = "\\legacy-single-slash.ini" - same */
562 /* UrlCreateFromPath = "file:///legacy-single-slash.ini" - same */
563 },
564 { /* #24: */
565 /* .pszPath =*/ "C:\\legacy-double-slash%2E.ini",
566 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
567 /* .pszUri =*/ "file://C:\\legacy-double-slash%2E.ini",
568 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
569 /* .pszCreatedPath =*/ "C:\\legacy-double-slash%2E.ini",
570 /* .pszCreatedUri =*/ "file:///C:/legacy-double-slash%252E.ini",
571 /* PathCreateFromUrl = "C:\\legacy-double-slash%2E.ini" - same */
572 /* UrlCreateFromPath = "file:///C:/legacy-double-slash.ini" - same */
573 },
574 { /* #25: */
575 /* .pszPath =*/ "C:\\legacy-double-slash%2E.ini",
576 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
577 /* .pszUri =*/ "file://C|/legacy-double-slash%2E.ini",
578 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
579 /* .pszCreatedPath =*/ "C:\\legacy-double-slash%2E.ini",
580 /* .pszCreatedUri =*/ "file:///C:/legacy-double-slash%252E.ini",
581 /* PathCreateFromUrl = "C:\\legacy-double-slash%2E.ini" - same */
582 /* UrlCreateFromPath = "file:///C:/legacy-double-slash%252E.ini" - same */
583 },
584 { /* #26: */
585 /* .pszPath =*/ "C:\\legacy-4-slashes%2E.ini",
586 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
587 /* .pszUri =*/ "file:////C|/legacy-4-slashes%2E.ini",
588 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
589 /* .pszCreatedPath =*/ "C:\\legacy-4-slashes%2E.ini",
590 /* .pszCreatedUri =*/ "file:///C:/legacy-4-slashes%252E.ini",
591 /* PathCreateFromUrl = "C:\\legacy-4-slashes%2E.ini" - same */
592 /* UrlCreateFromPath = "file:///C:/legacy-4-slashes%252E.ini" - same */
593 },
594 { /* #27: */
595 /* .pszPath =*/ "C:\\legacy-4-slashes%2E.ini",
596 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
597 /* .pszUri =*/ "file:////C:/legacy-4-slashes%2E.ini",
598 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
599 /* .pszCreatedPath =*/ "C:\\legacy-4-slashes%2E.ini",
600 /* .pszCreatedUri =*/ "file:///C:/legacy-4-slashes%252E.ini",
601 /* PathCreateFromUrl = "C:\\legacy-4-slashes%2E.ini" - same */
602 /* UrlCreateFromPath = "file:///C:/legacy-4-slashes%252E.ini" - same */
603 },
604 { /* #28: */
605 /* .pszPath =*/ "\\\\cifsserver\\share\\legacy-4-slashes%2E.ini",
606 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
607 /* .pszUri =*/ "file:////cifsserver/share/legacy-4-slashes%2E.ini",
608 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
609 /* .pszCreatedPath =*/ "\\\\cifsserver\\share\\legacy-4-slashes%2E.ini",
610 /* .pszCreatedUri =*/ "file://cifsserver/share/legacy-4-slashes%252E.ini",
611 /* PathCreateFromUrl = "\\\\cifsserver\\share\\legacy-4-slashes%2E.ini" - same */
612 /* UrlCreateFromPath = "file://cifsserver/share/legacy-4-slashes%252E.ini" - same */
613 },
614 { /* #29: */
615 /* .pszPath =*/ "\\\\cifsserver\\share\\legacy-5-slashes.ini",
616 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
617 /* .pszUri =*/ "file://///cifsserver/share/legacy-5-slashes%2Eini",
618 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
619 /* .pszCreatedPath =*/ "\\\\cifsserver\\share\\legacy-5-slashes.ini",
620 /* .pszCreatedUri =*/ "file://cifsserver/share/legacy-5-slashes.ini",
621 /* PathCreateFromUrl = "\\\\cifsserver\\share\\legacy-5-slashes.ini" - same */
622 /* UrlCreateFromPath = "file://cifsserver/share/legacy-5-slashes.ini" - same */
623 },
624 { /* #30: */
625 /* .pszPath =*/ "\\\\C|\\share\\legacy-5-slashes.ini",
626 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
627 /* .pszUri =*/ "file://///C|/share/legacy-5-slashes%2Eini",
628 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS,
629 /* .pszCreatedPath =*/ "\\\\C|\\share\\legacy-5-slashes.ini",
630 /* .pszCreatedUri =*/ "file://C%7C/share/legacy-5-slashes.ini",
631 /* PathCreateFromUrl = "\\\\C|\\share\\legacy-5-slashes.ini" - same */
632 /* UrlCreateFromPath = "file:///C%7C/share/legacy-5-slashes.ini" - differs */
633 },
634};
635
636#ifdef TSTRTURI_WITH_WINDOWS_REFERENCE_RESULTS
637
638static void tstPrintCString(const char *pszString)
639{
640 if (pszString)
641 {
642 char ch;
643 RTPrintf("\"");
644 while ((ch = *pszString++) != '\0')
645 {
646 if (ch >= 0x20 && ch < 0x7f)
647 switch (ch)
648 {
649 default:
650 RTPrintf("%c", ch);
651 break;
652 case '\\':
653 case '"':
654 RTPrintf("\\%c", ch);
655 break;
656 }
657 else
658 RTPrintf("\\x%02X", ch); /* good enough */
659 }
660 RTPrintf("\"");
661 }
662 else
663 RTPrintf("NULL");
664}
665
666static const char *tstNamePathStyle(uint32_t fPathStyle)
667{
668 switch (fPathStyle)
669 {
670 case RTPATH_STR_F_STYLE_DOS: return "RTPATH_STR_F_STYLE_DOS";
671 case RTPATH_STR_F_STYLE_UNIX: return "RTPATH_STR_F_STYLE_UNIX";
672 case RTPATH_STR_F_STYLE_HOST: return "RTPATH_STR_F_STYLE_HOST";
673 default: AssertFailedReturn("Invalid");
674 }
675}
676
677static void tstWindowsReferenceResults(void)
678{
679 /*
680 * Feed the g_aCreateFileURIs values as input to the Windows
681 * PathCreateFromUrl and URlCreateFromPath APIs and print the results.
682 *
683 * We reproduce the entire source file content of g_aCreateFileURIs here.
684 */
685 for (size_t i = 0; i < RT_ELEMENTS(g_aCreateFileURIs); ++i)
686 {
687 RTPrintf(" { /* #%u: */\n", i);
688 RTPrintf(" /* .pszPath =*/ ");
689 tstPrintCString(g_aCreateFileURIs[i].pszPath);
690 RTPrintf(",\n");
691 RTPrintf(" /* .fPathPathStyle =*/ %s,\n", tstNamePathStyle(g_aCreateFileURIs[i].fPathPathStyle));
692 RTPrintf(" /* .pszUri =*/ ");
693 tstPrintCString(g_aCreateFileURIs[i].pszUri);
694 RTPrintf(",\n");
695 RTPrintf(" /* .fUriPathStyle =*/ %s,\n", tstNamePathStyle(g_aCreateFileURIs[i].fUriPathStyle));
696 RTPrintf(" /* .pszCreatedPath =*/ ");
697 tstPrintCString(g_aCreateFileURIs[i].pszCreatedPath);
698 RTPrintf(",\n");
699 RTPrintf(" /* .pszCreatedUri =*/ ");
700 tstPrintCString(g_aCreateFileURIs[i].pszCreatedUri);
701 RTPrintf(",\n");
702
703 /*
704 * PathCreateFromUrl
705 */
706 PRTUTF16 pwszInput = NULL;
707 if (g_aCreateFileURIs[i].pszUri)
708 RTTESTI_CHECK_RC_OK_RETV(RTStrToUtf16(g_aCreateFileURIs[i].pszUri, &pwszInput));
709 WCHAR wszResult[_1K];
710 DWORD cwcResult = RT_ELEMENTS(wszResult);
711 RT_ZERO(wszResult);
712 HRESULT hrc = PathCreateFromUrlW(pwszInput, wszResult, &cwcResult, 0 /*dwFlags*/);
713 RTUtf16Free(pwszInput);
714
715 if (SUCCEEDED(hrc))
716 {
717 char *pszResult;
718 RTTESTI_CHECK_RC_OK_RETV(RTUtf16ToUtf8(wszResult, &pszResult));
719 RTPrintf(" /* PathCreateFromUrl = ");
720 tstPrintCString(pszResult);
721 if ( g_aCreateFileURIs[i].pszCreatedPath
722 && strcmp(pszResult, g_aCreateFileURIs[i].pszCreatedPath) == 0)
723 RTPrintf(" - same */\n");
724 else
725 RTPrintf(" - differs */\n");
726 RTStrFree(pszResult);
727 }
728 else
729 RTPrintf(" /* PathCreateFromUrl => %#x (%Rhrc) */\n", hrc, hrc);
730
731 /*
732 * UrlCreateFromPath + UrlEscape
733 */
734 pwszInput = NULL;
735 if (g_aCreateFileURIs[i].pszPath)
736 RTTESTI_CHECK_RC_OK_RETV(RTStrToUtf16(g_aCreateFileURIs[i].pszPath, &pwszInput));
737 RT_ZERO(wszResult);
738 cwcResult = RT_ELEMENTS(wszResult);
739 hrc = UrlCreateFromPathW(pwszInput, wszResult, &cwcResult, 0 /*dwFlags*/);
740 RTUtf16Free(pwszInput);
741
742 if (SUCCEEDED(hrc))
743 {
744 WCHAR wszResult2[_1K];
745 DWORD cwcResult2 = RT_ELEMENTS(wszResult2);
746 hrc = UrlEscapeW(wszResult, wszResult2, &cwcResult2, URL_DONT_ESCAPE_EXTRA_INFO | URL_ESCAPE_AS_UTF8 );
747 if (SUCCEEDED(hrc))
748 {
749 char *pszResult;
750 RTTESTI_CHECK_RC_OK_RETV(RTUtf16ToUtf8(wszResult2, &pszResult));
751 RTPrintf(" /* UrlCreateFromPath = ");
752 tstPrintCString(pszResult);
753 if ( g_aCreateFileURIs[i].pszCreatedUri
754 && strcmp(pszResult, g_aCreateFileURIs[i].pszCreatedUri) == 0)
755 RTPrintf(" - same */\n");
756 else
757 RTPrintf(" - differs */\n");
758 RTStrFree(pszResult);
759 }
760 else
761 RTPrintf(" /* UrlEscapeW => %#x (%Rhrc) */\n", hrc, hrc);
762 }
763 else
764 RTPrintf(" /* UrlCreateFromPath => %#x (%Rhrc) */\n", hrc, hrc);
765 RTPrintf(" },\n");
766 }
767}
768
769#endif /* TSTRTURI_WITH_WINDOWS_REFERENCE_RESULTS */
770
771
772static void tstRTUriFilePathEx(void)
773{
774 RTTestISub("RTUriFilePathEx");
775 for (size_t i = 0; i < RT_ELEMENTS(g_aCreateFileURIs); ++i)
776 {
777 uint32_t const fPathStyle = g_aCreateFileURIs[i].fUriPathStyle;
778 const char * const pszUri = g_aCreateFileURIs[i].pszUri;
779 char *pszPath = (char *)&pszPath;
780 int rc = RTUriFilePathEx(pszUri, fPathStyle, &pszPath, 0, NULL);
781 if (RT_SUCCESS(rc))
782 {
783 if (g_aCreateFileURIs[i].pszCreatedPath)
784 {
785 if (strcmp(pszPath, g_aCreateFileURIs[i].pszCreatedPath) == 0)
786 {
787 /** @todo check out the other variations of the API. */
788 }
789 else
790 RTTestIFailed("#%u: '%s'/%#x => '%s', expected '%s'",
791 i, pszUri, fPathStyle, pszPath, g_aCreateFileURIs[i].pszCreatedPath);
792 }
793 else
794 RTTestIFailed("#%u: bad testcase; pszCreatedPath is NULL\n", i);
795 RTStrFree(pszPath);
796 }
797 else if (rc != VERR_PATH_ZERO_LENGTH || RTStrCmp(pszUri, "file://") != 0)
798 RTTestIFailed("#%u: '%s'/%#x => %Rrc", i, pszUri, fPathStyle, rc);
799 }
800}
801
802
803static void tstRTUriFileCreateEx(void)
804{
805 RTTestISub("RTUriFileCreateEx");
806 for (size_t i = 0; i < RT_ELEMENTS(g_aCreateFileURIs); ++i)
807 {
808 uint32_t const fPathStyle = g_aCreateFileURIs[i].fPathPathStyle;
809 const char * const pszPath = g_aCreateFileURIs[i].pszPath;
810 char *pszUri = (char *)&pszUri;
811 int rc = RTUriFileCreateEx(pszPath, fPathStyle, &pszUri, 0, NULL);
812 if (RT_SUCCESS(rc))
813 {
814 if (g_aCreateFileURIs[i].pszCreatedUri)
815 {
816 if (strcmp(pszUri, g_aCreateFileURIs[i].pszCreatedUri) == 0)
817 {
818 /** @todo check out the other variations of the API. */
819 }
820 else
821 RTTestIFailed("#%u: '%s'/%#x => '%s', expected '%s'",
822 i, pszPath, fPathStyle, pszUri, g_aCreateFileURIs[i].pszCreatedUri);
823 }
824 else
825 RTTestIFailed("#%u: bad testcase; pszCreatedUri is NULL\n", i);
826 RTStrFree(pszUri);
827 }
828 else if (rc != VERR_INVALID_POINTER || pszPath != NULL)
829 RTTestIFailed("#%u: '%s'/%#x => %Rrc", i, pszPath, fPathStyle, rc);
830 }
831}
832
833
834int main()
835{
836 RTTEST hTest;
837 int rc = RTTestInitAndCreate("tstRTUri", &hTest);
838 if (rc)
839 return rc;
840 RTTestBanner(hTest);
841
842#define CHECK_STR_API(a_Call, a_pszExpected) \
843 do { \
844 char *pszTmp = a_Call; \
845 if (a_pszExpected) \
846 { \
847 if (!pszTmp) \
848 RTTestIFailed("#%u: %s returns NULL, expected '%s'", i, #a_Call, a_pszExpected); \
849 else if (strcmp(pszTmp, a_pszExpected)) \
850 RTTestIFailed("#%u: %s returns '%s', expected '%s'", i, #a_Call, pszTmp, a_pszExpected); \
851 } \
852 else if (pszTmp) \
853 RTTestIFailed("#%u: %s returns '%s', expected NULL", i, #a_Call, pszTmp); \
854 RTStrFree(pszTmp); \
855 } while (0)
856
857 RTTestISub("RTUriParse & RTUriParsed*");
858 for (uint32_t i = 0; i < RT_ELEMENTS(g_aTests); i++)
859 {
860 RTURIPARSED Parsed;
861 RTTESTI_CHECK_RC(rc = RTUriParse(g_aTests[i].pszUri, &Parsed), VINF_SUCCESS);
862 if (RT_SUCCESS(rc))
863 {
864 CHECK_STR_API(RTUriParsedScheme(g_aTests[i].pszUri, &Parsed), g_aTests[i].pszScheme);
865 CHECK_STR_API(RTUriParsedAuthority(g_aTests[i].pszUri, &Parsed), g_aTests[i].pszAuthority);
866 CHECK_STR_API(RTUriParsedAuthorityUsername(g_aTests[i].pszUri, &Parsed), g_aTests[i].pszUsername);
867 CHECK_STR_API(RTUriParsedAuthorityPassword(g_aTests[i].pszUri, &Parsed), g_aTests[i].pszPassword);
868 CHECK_STR_API(RTUriParsedAuthorityHost(g_aTests[i].pszUri, &Parsed), g_aTests[i].pszHost);
869 CHECK_STR_API(RTUriParsedPath(g_aTests[i].pszUri, &Parsed), g_aTests[i].pszPath);
870 CHECK_STR_API(RTUriParsedQuery(g_aTests[i].pszUri, &Parsed), g_aTests[i].pszQuery);
871 CHECK_STR_API(RTUriParsedFragment(g_aTests[i].pszUri, &Parsed), g_aTests[i].pszFragment);
872 uint32_t uPort = RTUriParsedAuthorityPort(g_aTests[i].pszUri, &Parsed);
873 if (uPort != g_aTests[i].uPort)
874 RTTestIFailed("#%u: RTUriParsedAuthorityPort returns %#x, expected %#x", i, uPort, g_aTests[i].uPort);
875 }
876 }
877
878 /* Creation */
879 RTTestISub("RTUriCreate");
880 for (uint32_t i = 0; i < RT_ELEMENTS(g_aTests); i++)
881 CHECK_STR_API(RTUriCreate(g_aTests[i].pszScheme, g_aTests[i].pszAuthority, g_aTests[i].pszPath,
882 g_aTests[i].pszQuery, g_aTests[i].pszFragment),
883 g_aTests[i].pszCreated ? g_aTests[i].pszCreated : g_aTests[i].pszUri);
884
885#ifdef TSTRTURI_WITH_WINDOWS_REFERENCE_RESULTS
886 tstWindowsReferenceResults();
887#endif
888
889 bool fSavedMayPanic = RTAssertSetMayPanic(false);
890 bool fSavedQuiet = RTAssertSetQuiet(true);
891
892 tstRTUriFilePathEx();
893 tstRTUriFileCreateEx();
894
895 RTAssertSetMayPanic(fSavedMayPanic);
896 RTAssertSetQuiet(fSavedQuiet);
897
898 return RTTestSummaryAndDestroy(hTest);
899}
900
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette