xref: /trunk/main/tools/workben/urltest.cxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_tools.hxx"
26 #include <tools/inetmime.hxx>
27 #include <tools/urlobj.hxx>
28 #include "com/sun/star/util/XStringWidth.hpp"
29 #include "com/sun/star/uno/Reference.hxx"
30 #include "cppuhelper/implbase1.hxx"
31 #include "osl/thread.h"
32 #include "rtl/string.h"
33 #include "rtl/string.hxx"
34 #include "rtl/textenc.h"
35 #include "rtl/ustring.h"
36 #include "rtl/ustring.hxx"
37 
38 #include <cstddef>
39 #include <cstdlib>
40 #include <iostream>
41 #include <ostream>
42 #include <stdio.h>
43 
44 using namespace com::sun;
45 
operator <<(std::ostream & out,rtl::OUString const & value)46 std::ostream & operator <<(std::ostream & out, rtl::OUString const & value) {
47     out << rtl::OUStringToOString(value, RTL_TEXTENCODING_ASCII_US).getStr();
48     return out;
49 }
50 
51 namespace {
52 
assertEqual(rtl::OUString const & message,T1 const & expected,T2 const & actual)53 template< typename T1, typename T2 > bool assertEqual(
54     rtl::OUString const & message, T1 const & expected, T2 const & actual)
55 {
56     bool success = expected == actual;
57     if (!success) {
58         std::cout
59             << "FAILED " << message << ": " << expected << " != " << actual
60             << '\n';
61     }
62     return success;
63 }
64 
65 }
66 
67 //============================================================================
68 //
69 //  testRelToAbs
70 //
71 //============================================================================
72 
73 struct RelToAbsTest
74 {
75     sal_Char const * m_pBase;
76     sal_Char const * m_pRel;
77     sal_Char const * m_pAbs;
78     sal_Char const * m_pAlt;
79 };
80 
81 //============================================================================
testRelToAbs(RelToAbsTest const * pTest,std::size_t nSize)82 bool testRelToAbs(RelToAbsTest const * pTest, std::size_t nSize)
83 {
84     bool bSuccess = true;
85     INetURLObject aBase;
86     String aTest;
87     for (std::size_t i = 0; i < nSize; ++i)
88     {
89         if (pTest[i].m_pBase)
90         {
91             aBase.SetURL(pTest[i].m_pBase);
92         }
93         if (aBase.HasError())
94         {
95             printf(" BAD BASE %s\n",
96                    pTest[i].m_pBase ? pTest[i].m_pBase : "");
97             bSuccess = false;
98             continue;
99         }
100         INetURLObject aAbs;
101         aBase.GetNewAbsURL(pTest[i].m_pRel, &aAbs);
102         ByteString aTheAbs(String(aAbs.GetMainURL(INetURLObject::NO_DECODE)),
103                            RTL_TEXTENCODING_ISO_8859_1);
104         if (!(aTheAbs.Equals(pTest[i].m_pAbs)
105               || pTest[i].m_pAlt && aTheAbs.Equals(pTest[i].m_pAlt)))
106         {
107             printf(" BAD GetNewAbsURL %s -> %s (%s)\n", pTest[i].m_pRel,
108                    aTheAbs.GetBuffer(), pTest[i].m_pAbs);
109             bSuccess = false;
110         }
111         aTheAbs = ByteString(
112             String(
113                 INetURLObject::GetAbsURL(
114                     aBase.GetMainURL(INetURLObject::NO_DECODE),
115                     UniString(pTest[i].m_pRel, RTL_TEXTENCODING_ISO_8859_1))),
116             RTL_TEXTENCODING_ISO_8859_1);
117         if (!(aTheAbs.Equals(pTest[i].m_pAbs)
118               || pTest[i].m_pAlt && aTheAbs.Equals(pTest[i].m_pAlt)))
119         {
120             printf(" BAD GetAbsURL %s -> %s (%s)\n", pTest[i].m_pRel,
121                    aTheAbs.GetBuffer(), pTest[i].m_pAbs);
122             bSuccess = false;
123         }
124     }
125     printf("\n");
126     return bSuccess;
127 }
128 
129 //============================================================================
130 //
131 //  testSetFSys
132 //
133 //============================================================================
134 
135 struct SetFSysTest
136 {
137     sal_Char const * m_pPath;
138     INetURLObject::FSysStyle m_eStyle;
139     sal_Char const * m_pUrl;
140 };
141 
142 //============================================================================
toString(INetURLObject::FSysStyle eStyle)143 inline sal_Char const * toString(INetURLObject::FSysStyle eStyle)
144 {
145     static sal_Char aBuffer[5];
146     int i = 0;
147     if (eStyle & INetURLObject::FSYS_VOS)
148         aBuffer[i++] = 'V';
149     if (eStyle & INetURLObject::FSYS_UNX)
150         aBuffer[i++] = 'U';
151     if (eStyle & INetURLObject::FSYS_DOS)
152         aBuffer[i++] = 'D';
153     if (eStyle & INetURLObject::FSYS_MAC)
154         aBuffer[i++] = 'M';
155     if (i == 0)
156         aBuffer[i++] = '-';
157     aBuffer[i] = '\0';
158     return aBuffer;
159 }
160 
161 //============================================================================
testSetFSys(SetFSysTest const * pTest,std::size_t nSize)162 bool testSetFSys(SetFSysTest const * pTest, std::size_t nSize)
163 {
164     bool bSuccess = true;
165     String aPath;
166     for (std::size_t i = 0; i < nSize; ++i)
167     {
168         if (pTest[i].m_pPath)
169             aPath = String::CreateFromAscii(pTest[i].m_pPath);
170         if (aPath.Len() == 0)
171         {
172             printf(" NO PATH\n");
173             continue;
174         }
175         INetURLObject aUrl1(aPath, pTest[i].m_eStyle);
176         INetURLObject aUrl2;
177         aUrl2.setFSysPath(aPath, pTest[i].m_eStyle);
178         if (aUrl1.GetMainURL(INetURLObject::NO_DECODE).
179                       equalsAscii(pTest[i].m_pUrl)
180             && aUrl2.GetMainURL(INetURLObject::NO_DECODE).
181                          equalsAscii(pTest[i].m_pUrl))
182             printf("  ok %s %s -> %s\n",
183                    ByteString(aPath, RTL_TEXTENCODING_ISO_8859_1).GetBuffer(),
184                    toString(pTest[i].m_eStyle), pTest[i].m_pUrl);
185         else
186         {
187             String aTestA = aUrl1.GetMainURL(INetURLObject::NO_DECODE);
188             String aTestB = aUrl2.GetMainURL(INetURLObject::NO_DECODE);
189 
190             printf(" BAD %s %s -> %s, %s (%s)\n",
191                    ByteString(aPath, RTL_TEXTENCODING_ISO_8859_1).GetBuffer(),
192                    toString(pTest[i].m_eStyle),
193                    ByteString(aTestA, RTL_TEXTENCODING_ISO_8859_1).GetBuffer(),
194                    ByteString(aTestB, RTL_TEXTENCODING_ISO_8859_1).GetBuffer(),
195                    pTest[i].m_pUrl);
196             bSuccess = false;
197         }
198     }
199     printf("\n");
200     return bSuccess;
201 }
202 
203 //============================================================================
204 //
205 //  main
206 //
207 //============================================================================
208 
209 namespace {
210 
211 class StringWidth: public cppu::WeakImplHelper1< star::util::XStringWidth >
212 {
213 public:
queryStringWidth(rtl::OUString const & rString)214     virtual sal_Int32 SAL_CALL queryStringWidth(rtl::OUString const & rString)
215     {
216         return rString.getLength();
217     }
218 };
219 
abbreviate(INetURLObject aObj)220 void abbreviate(INetURLObject aObj)
221 {
222     star::uno::Reference< star::util::XStringWidth > xWidth(new StringWidth);
223     sal_Int32 nMax = aObj.GetMainURL(INetURLObject::NO_DECODE).getLength() + 10;
224     for (sal_Int32 i = -10; i <= nMax; ++i)
225     {
226         rtl::OString
227             aAbbreviated(rtl::OUStringToOString(
228                              aObj.getAbbreviated(xWidth,
229                                                  i,
230                                                  INetURLObject::NO_DECODE),
231                              RTL_TEXTENCODING_UTF8));
232         printf(
233             "%4ld: <%s", static_cast< long int >(i), aAbbreviated.getStr());
234         for (sal_Int32 j = aAbbreviated.getLength(); j < i; ++j)
235             printf(" ");
236         printf(">\n");
237     }
238 }
239 
test_getSegmentCount(char const * url,bool ignoreFinalSlash,sal_Int32 result)240 bool test_getSegmentCount(
241     char const * url, bool ignoreFinalSlash, sal_Int32 result)
242 {
243     return
244         assertEqual(
245             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("test_getSegmentCount")),
246             result,
247             INetURLObject(rtl::OUString::createFromAscii(url)).getSegmentCount(
248                 ignoreFinalSlash));
249 }
250 
test_insertName(char const * url,char const * name,bool appendFinalSlash,sal_Int32 index,bool ignoreFinalSlash,bool success,char const * result)251 bool test_insertName(
252     char const * url, char const * name, bool appendFinalSlash, sal_Int32 index,
253     bool ignoreFinalSlash, bool success, char const * result)
254 {
255     INetURLObject tmp(rtl::OUString::createFromAscii(url));
256     return
257         assertEqual(
258             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("test_insertName")),
259             success,
260             tmp.insertName(
261                 rtl::OUString::createFromAscii(name), appendFinalSlash, index,
262                 ignoreFinalSlash)) &
263         assertEqual(
264             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("test_insertName")),
265             rtl::OUString::createFromAscii(result),
266             tmp.GetMainURL(INetURLObject::NO_DECODE));
267 }
268 
test_removeSegment(char const * url,sal_Int32 index,bool ignoreFinalSlash,bool success,char const * result)269 bool test_removeSegment(
270     char const * url, sal_Int32 index, bool ignoreFinalSlash, bool success,
271     char const * result)
272 {
273     INetURLObject tmp(rtl::OUString::createFromAscii(url));
274     return
275         assertEqual(
276             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("test_removeSegment")),
277             success, tmp.removeSegment(index, ignoreFinalSlash)) &
278         assertEqual(
279             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("test_removeSegment")),
280             rtl::OUString::createFromAscii(result),
281             tmp.GetMainURL(INetURLObject::NO_DECODE));
282 }
283 
284 }
285 
286 int
287 #if defined WNT
288 __cdecl
289 #endif // WNT
main()290 main()
291 {
292     bool bSuccess = true;
293 
294     if (true)
295     {
296         // The data for this test is taken from the files
297         // <http://www.ics.uci.edu/~fielding/url/testN.html> with N = 1,
298         // ..., 3, as of August 28, 2000:
299         static RelToAbsTest const aTest[]
300             = { //{ "http://a/b/c/d;p?q", "g:h", "g:h", 0 },
301                 { "http://a/b/c/d;p?q", "g", "http://a/b/c/g", 0 },
302                 { 0, "./g", "http://a/b/c/g", 0 },
303                 { 0, "g/", "http://a/b/c/g/", 0 },
304                 { 0, "/g", "http://a/g", 0 },
305                 { 0, "//g", "http://g", "http://g/" },
306                 //{ 0, "?y", "http://a/b/c/d;p?y", 0 },
307                 { 0, "g?y", "http://a/b/c/g?y", 0 },
308                 //{ 0, "#s", "http://a/b/c/d;p?q#s", 0 },
309                 { 0, "g#s", "http://a/b/c/g#s", 0 },
310                 { 0, "g?y#s", "http://a/b/c/g?y#s", 0 },
311                 { 0, ";x", "http://a/b/c/;x", 0 },
312                 { 0, "g;x", "http://a/b/c/g;x", 0 },
313                 { 0, "g;x?y#s", "http://a/b/c/g;x?y#s", 0 },
314                 { 0, ".", "http://a/b/c/", 0 },
315                 { 0, "./", "http://a/b/c/", 0 },
316                 { 0, "..", "http://a/b/", 0 },
317                 { 0, "../", "http://a/b/", 0 },
318                 { 0, "../g", "http://a/b/g", 0 },
319                 { 0, "../..", "http://a/", 0 },
320                 { 0, "../../", "http://a/", 0 },
321                 { 0, "../../g", "http://a/g", 0 },
322                 //{ 0, "", "http://a/b/c/d;p?q", 0 },
323                 { 0, "../../../g", "http://a/../g", "http://a/g" },
324                 { 0, "../../../../g", "http://a/../../g", "http://a/g" },
325                 { 0, "/./g", "http://a/./g", 0 },
326                 { 0, "/../g", "http://a/../g", 0 },
327                 { 0, "g.", "http://a/b/c/g.", 0 },
328                 { 0, ".g", "http://a/b/c/.g", 0 },
329                 { 0, "g..", "http://a/b/c/g..", 0 },
330                 { 0, "..g", "http://a/b/c/..g", 0 },
331                 { 0, "./../g", "http://a/b/g", 0 },
332                 { 0, "./g/.", "http://a/b/c/g/", 0 },
333                 { 0, "g/./h", "http://a/b/c/g/h", 0 },
334                 { 0, "g/../h", "http://a/b/c/h", 0 },
335                 { 0, "g;x=1/./y", "http://a/b/c/g;x=1/y", 0 },
336                 { 0, "g;x=1/../y", "http://a/b/c/y", 0 },
337                 { 0, "g?y/./x", "http://a/b/c/g?y/./x", 0 },
338                 { 0, "g?y/../x", "http://a/b/c/g?y/../x", 0 },
339                 { 0, "g#s/./x", "http://a/b/c/g#s/./x", 0 },
340                 { 0, "g#s/../x", "http://a/b/c/g#s/../x", 0 },
341                 { 0, "http:g", "http:g", "http://a/b/c/g" },
342                 //{ 0, "http:", "http:", 0 },
343                 { "http://a/b/c/d;p?q=1/2", "g", "http://a/b/c/g", 0 },
344                 { 0, "./g", "http://a/b/c/g", 0 },
345                 { 0, "g/", "http://a/b/c/g/", 0 },
346                 { 0, "/g", "http://a/g", 0 },
347                 { 0, "//g", "http://g", "http://g/" },
348                 { 0, "g?y", "http://a/b/c/g?y", 0 },
349                 { 0, "g?y/./x", "http://a/b/c/g?y/./x", 0 },
350                 { 0, "g?y/../x", "http://a/b/c/g?y/../x", 0 },
351                 { 0, "g#s", "http://a/b/c/g#s", 0 },
352                 { 0, "g#s/./x", "http://a/b/c/g#s/./x", 0 },
353                 { 0, "g#s/../x", "http://a/b/c/g#s/../x", 0 },
354                 { 0, "./", "http://a/b/c/", 0 },
355                 { 0, "../", "http://a/b/", 0 },
356                 { 0, "../g", "http://a/b/g", 0 },
357                 { 0, "../../", "http://a/", 0 },
358                 { 0, "../../g", "http://a/g", 0 },
359                 { "http://a/b/c/d;p=1/2?q", "g", "http://a/b/c/d;p=1/g", 0 },
360                 { 0, "./g", "http://a/b/c/d;p=1/g", 0 },
361                 { 0, "g/", "http://a/b/c/d;p=1/g/", 0 },
362                 { 0, "g?y", "http://a/b/c/d;p=1/g?y", 0 },
363                 { 0, ";x", "http://a/b/c/d;p=1/;x", 0 },
364                 { 0, "g;x", "http://a/b/c/d;p=1/g;x", 0 },
365                 { 0, "g;x=1/./y", "http://a/b/c/d;p=1/g;x=1/y", 0 },
366                 { 0, "g;x=1/../y", "http://a/b/c/d;p=1/y", 0 },
367                 { 0, "./", "http://a/b/c/d;p=1/", 0 },
368                 { 0, "../", "http://a/b/c/", 0 },
369                 { 0, "../g", "http://a/b/c/g", 0 },
370                 { 0, "../../", "http://a/b/", 0 },
371                 { 0, "../../g", "http://a/b/g", 0 },
372                 { "file:///", "generic:", "file:///generic:", 0 },
373                 { 0, "generic:#fragment", "file:///generic:#fragment", 0 },
374                 { 0, "generic:something", "generic:something", 0 },
375                 { 0, "c:/foo/bar", "file:///c:/foo/bar", 0 },
376                 { 0, "c:\\foo\\bar", "file:///c:%5Cfoo%5Cbar", 0 } };
377         if (!testRelToAbs(aTest, sizeof aTest / sizeof (RelToAbsTest)))
378             bSuccess = false;
379     }
380 
381     if (false)
382     {
383         static SetFSysTest const aTest[]
384             = { { "//.", INetURLObject::FSysStyle(0), "" },
385                 { 0, INetURLObject::FSysStyle(1), "file:///" },
386                 { 0, INetURLObject::FSysStyle(2), "file:////." },
387                 { 0, INetURLObject::FSysStyle(3), "file:///" },
388                 { 0, INetURLObject::FSysStyle(4), "file:///%2F%2F." },
389                 { 0, INetURLObject::FSysStyle(5), "file:///" },
390                 { 0, INetURLObject::FSysStyle(6), "file:////." },
391                 { 0, INetURLObject::FSysStyle(7), "file:///" },
392                 { 0, INetURLObject::FSysStyle(8), "file:///%2F%2F." },
393                 { 0, INetURLObject::FSysStyle(9), "file:///" },
394                 { 0, INetURLObject::FSysStyle(10), "file:////." },
395                 { 0, INetURLObject::FSysStyle(11), "file:///" },
396                 { 0, INetURLObject::FSysStyle(12), "file:///%2F%2F." },
397                 { 0, INetURLObject::FSysStyle(13), "file:///" },
398                 { 0, INetURLObject::FSysStyle(14), "file:////." },
399                 { 0, INetURLObject::FSysStyle(15), "file:///" },
400                 { "//./", INetURLObject::FSysStyle(0), "" },
401                 { 0, INetURLObject::FSysStyle(1), "file:///" },
402                 { 0, INetURLObject::FSysStyle(2), "file:////./" },
403                 { 0, INetURLObject::FSysStyle(3), "file:///" },
404                 { 0, INetURLObject::FSysStyle(4), "file:///%2F%2F.%2F" },
405                 { 0, INetURLObject::FSysStyle(5), "file:///" },
406                 { 0, INetURLObject::FSysStyle(6), "file:////./" },
407                 { 0, INetURLObject::FSysStyle(7), "file:///" },
408                 { 0, INetURLObject::FSysStyle(8), "file:///%2F%2F.%2F" },
409                 { 0, INetURLObject::FSysStyle(9), "file:///" },
410                 { 0, INetURLObject::FSysStyle(10), "file:////./" },
411                 { 0, INetURLObject::FSysStyle(11), "file:///" },
412                 { 0, INetURLObject::FSysStyle(12), "file:///%2F%2F.%2F" },
413                 { 0, INetURLObject::FSysStyle(13), "file:///" },
414                 { 0, INetURLObject::FSysStyle(14), "file:////./" },
415                 { 0, INetURLObject::FSysStyle(15), "file:///" },
416                 { "//./a/b\\c:d", INetURLObject::FSysStyle(0), "" },
417                 { 0, INetURLObject::FSysStyle(1), "file:///a/b%5Cc:d" },
418                 { 0, INetURLObject::FSysStyle(2), "file:////./a/b%5Cc:d" },
419                 { 0, INetURLObject::FSysStyle(3), "file:///a/b%5Cc:d" },
420                 { 0, INetURLObject::FSysStyle(4), "file:///%2F%2F.%2Fa%2Fb/c:d" },
421                 { 0, INetURLObject::FSysStyle(5), "file:///a/b%5Cc:d" },
422                 { 0, INetURLObject::FSysStyle(6), "file:////./a/b%5Cc:d" },
423                 { 0, INetURLObject::FSysStyle(7), "file:///a/b%5Cc:d" },
424                 { 0, INetURLObject::FSysStyle(8), "file:///%2F%2F.%2Fa%2Fb%5Cc/d" },
425                 { 0, INetURLObject::FSysStyle(9), "file:///a/b%5Cc:d" },
426                 { 0, INetURLObject::FSysStyle(10), "file:////./a/b%5Cc:d" },
427                 { 0, INetURLObject::FSysStyle(11), "file:///a/b%5Cc:d" },
428                 { 0, INetURLObject::FSysStyle(12), "file:///%2F%2F.%2Fa%2Fb/c:d" },
429                 { 0, INetURLObject::FSysStyle(13), "file:///a/b%5Cc:d" },
430                 { 0, INetURLObject::FSysStyle(14), "file:////./a/b%5Cc:d" },
431                 { 0, INetURLObject::FSysStyle(15), "file:///a/b%5Cc:d" } };
432         if (!testSetFSys(aTest, sizeof aTest / sizeof (SetFSysTest)))
433             bSuccess = false;
434     }
435 
436 /*
437     if (false)
438     {
439         bool bAbs = false;
440         INetURLObject aUrl1(INetURLObject().smartRel2Abs(L"/export/home/mba/Office/user/Basic/soffice.sbl", bAbs));
441 
442         INetURLObject aUrl2a(L"/export/home/mba/Office/user/Basic/soffice.sbl", INET_PROT_FILE);
443 
444         INetURLObject aUrl2b(L"file:///export/home/mba/Office/user/Basic/soffice.sbl", INET_PROT_FILE);
445 
446         INetURLObject aUrl3a(L"/export/home/mba/Office/user/Basic/soffice.sbl", INetURLObject::FSYS_DETECT);
447 
448         INetURLObject aUrl3b(L"file:///export/home/mba/Office/user/Basic/soffice.sbl", INetURLObject::FSYS_DETECT);
449     }
450 */
451 
452     if (true)
453     {
454         INetURLObject aUrl1("http://host:1234/xy/~zw?xxx=yyy");
455         if (aUrl1.HasError())
456         {
457             printf("BAD http\n");
458             bSuccess = false;
459         }
460         INetURLObject aUrl2("vnd.sun.star.webdav://host:1234/xy/~zw?xxx=yyy");
461         if (aUrl2.HasError())
462         {
463             printf("BAD vnd.sun.star.webdav\n");
464             bSuccess = false;
465         }
466     }
467 
468     if (true)
469     {
470         struct Test { char const * in; char const * out; };
471         static Test const aTest[]
472             = { { "vnd.sun.star.help://", "vnd.sun.star.help:///" },
473                 { "vnd.sun.star.help:///", 0 },
474                 { "vnd.sun.star.help://swriter",
475                   "vnd.sun.star.help://swriter/" },
476                 { "vnd.sun.star.help://swriter/", 0 },
477                 { "vnd.sun.star.help://swriter/12345", 0 },
478                 { "vnd.sun.star.help://swriter/1234X", 0 },
479                 { "vnd.sun.star.help://swriter/?a=b?c=d", 0 },
480                 { "vnd.sun.star.help://swriter/12345?a=b?c=d", 0 },
481                 { "vnd.sun.star.help://swriter/12345???", 0 },
482                 { "vnd.sun.star.help://swriter/#xxx", 0 },
483                 { "vnd.sun.star.help://swriter/12345#xxx", 0 },
484                 { "vnd.sun.star.help://swriter/1234X#xxx", 0 },
485                 { "vnd.sun.star.help://swriter/?a=b?c=d#xxx", 0 },
486                 { "vnd.sun.star.help://swriter/12345?a=b?c=d#xxx", 0 },
487                 { "vnd.sun.star.help://swriter/12345???#xxx", 0 },
488                 { "vnd.sun.star.help://swriter/start", 0 },
489                 { "vnd.sun.star.help://swriter/s/t/a/r/t", 0 },
490                 { "vnd.sun.star.help://swriter/a%2Fb%3Fc%2534d/e?f", 0 },
491                 { "vnd.sun.star.help://swriter?foo",
492                   "vnd.sun.star.help://swriter/?foo" },
493                 { "vnd.sun.star.help://swriter/?foo", 0 } };
494         for (std::size_t i = 0; i < sizeof aTest / sizeof aTest[0]; ++i)
495         {
496             INetURLObject aUrl(aTest[i].in);
497             if (aUrl.HasError())
498                 printf("BAD %s\n", aTest[i].in);
499             else if (aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI).
500                          equalsAscii(
501                              aTest[i].out == 0 ? aTest[i].in : aTest[i].out)
502                             != sal_True)
503             {
504                 String sTest(aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI));
505                 printf("BAD %s -> %s\n",
506                        aTest[i].in,
507                        ByteString(sTest, RTL_TEXTENCODING_ASCII_US).
508                        GetBuffer());
509             }
510         }
511     }
512 
513     if (true)
514     {
515         static sal_Char const * const aTest[]
516             = { /*TODO "vnd.sun.star.wfs://",*/
517                 /*TODO "vnd.sun.star.wfs://LocalHost",*/
518                 /*TODO "vnd.sun.star.wfs:///c|/xyz/",*/
519                 /*TODO "vnd.sun.star.wfs://xxx/yyy?zzz",*/
520                 "vnd.sun.star.wfs:///x/y/z",
521                 "vnd.sun.star.generic:///x/y/z",
522                 "vnd.sun.star.generic://host:34/x/y/z"
523                 /*TODO "wfs://",*/
524                 /*TODO "wfs://LocalHost",*/
525                 /*TODO "wfs:///c|/xyz/",*/
526                 /*TODO "wfs://xxx/yyy?zzz",*/
527                 /*TODO "wfs:///x/y/z"*/ };
528         for (std::size_t i = 0; i < sizeof aTest / sizeof aTest[0]; ++i)
529         {
530             INetURLObject aUrl(aTest[i]);
531             if (aUrl.HasError())
532                 printf("BAD %s\n", aTest[i]);
533             else
534             {
535                 if (aUrl.GetProtocol() != INET_PROT_GENERIC) {
536                     printf("BAD PROTOCOL %i -> %i\n",
537                            aUrl.GetProtocol(),
538                            INET_PROT_GENERIC);
539                 }
540                 if (aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI).
541                          equalsAscii(aTest[i]) != sal_True)
542                 {
543                 String sTest(aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI));
544                 printf("BAD %s -> %s\n",
545                        aTest[i],
546                        ByteString(sTest, RTL_TEXTENCODING_ASCII_US).GetBuffer());
547                 }
548             }
549         }
550     }
551 
552     if (true)
553     {
554         static sal_Char const * const aTest[]
555             = { /*TODO "vnd.sun.star.pkg:",*/
556                 /*TODO "vnd.sun.star.pkg:/",*/
557                 /*TODO "vnd.sun.star.pkg://abc",*/
558                 /*TODO "vnd.sun.star.pkg://file:%2F%2F%2Fa:%2Fb%20c",*/
559                 "vnd.sun.star.pkg://file:%2F%2F%2Fa:%2Fb%20c/",
560                 "vnd.sun.star.pkg://file:%2F%2F%2Fa:%2Fb%20c/xx",
561                 /*TODO "vnd.sun.star.pkg://file:%2F%2F%2Fa:%2Fb%20c/xx;yy",*/
562                 "vnd.sun.star.pkg://file:%2F%2F%2Fa:%2Fb%20c/xx//yy" };
563         for (std::size_t i = 0; i < sizeof aTest / sizeof aTest[0]; ++i)
564         {
565             INetURLObject aUrl(aTest[i]);
566             if (aUrl.HasError())
567                 printf("BAD %s\n", aTest[i]);
568             else if (aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI).
569                          equalsAscii(aTest[i]) != sal_True)
570             {
571                 String sTest(aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI));
572                 printf("BAD %s -> %s\n",
573                        aTest[i],
574                        ByteString(sTest, RTL_TEXTENCODING_ASCII_US).GetBuffer());
575             }
576         }
577     }
578 
579     if (true)
580     {
581         static sal_Char const * const aTest[]
582             = { /*TODO "vnd.sun.star.cmd:",*/
583                 /*TODO "vnd.sun.star.cmd:/",*/
584                 "vnd.sun.star.cmd:logout",
585                 "vnd.sun.star.cmd:log/out",
586                 /*TODO "vnd.sun.star.cmd:[logout]",*/
587                 "vnd.sun.star.cmd:log[out]" };
588         for (std::size_t i = 0; i < sizeof aTest / sizeof aTest[0]; ++i)
589         {
590             INetURLObject aUrl(aTest[i]);
591             if (aUrl.HasError())
592                 printf("BAD %s\n", aTest[i]);
593             else if (aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI).
594                          equalsAscii(aTest[i]) != sal_True)
595             {
596                 String sTest(aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI));
597                 printf("BAD %s -> %s\n",
598                        aTest[i],
599                        ByteString(sTest, RTL_TEXTENCODING_ASCII_US).GetBuffer());
600             }
601         }
602     }
603 
604     if (true)
605     {
606         rtl::OUString
607             aParameters(rtl::OUString::createFromAscii("; CharSet=UTF-8  ; Blubber=Blob"));
608         sal_Unicode const * pBegin = aParameters.getStr();
609         sal_Unicode const * pEnd = pBegin + aParameters.getLength();
610         INetContentTypeParameterList aList;
611         if (INetMIME::scanParameters(pBegin, pEnd, &aList) == pEnd)
612         {
613             ULONG nCount = aList.Count();
614             for (ULONG i = 0; i < nCount; ++i)
615             {
616                 INetContentTypeParameter const * p = aList.GetObject(i);
617                 if (p)
618                 {
619 /*
620                     printf("attribute: '%s'\n charset: '%s'\n language: '%s'\n value: '%s'\n converted: %s\n",
621                            p->m_sAttribute.GetBuffer(),
622                            p->m_sCharset.GetBuffer(),
623                            p->m_sLanguage.GetBuffer(),
624                            rtl::OUStringToOString(p->m_sValue,RTL_TEXTENCODING_UTF8).getStr(),
625                            p->m_bConverted ? "true" : "false");
626 */
627                 }
628                 else
629                     printf("BAD INetContentTypeParameter\n");
630             }
631         }
632         else
633         {
634             printf("BAD INetMIME::scanParameters()\n");
635             bSuccess = false;
636         }
637     }
638 
639     if (true)
640     {
641         {
642             INetURLObject aObj;
643             aObj.setFSysPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("a:")),
644                              INetURLObject::FSYS_DETECT);
645             if (!rtl::OUString(aObj.GetMainURL(INetURLObject::NO_DECODE)).
646                      equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("file:///a:")))
647             {
648                 printf("BAD setFSysPath(\"a:\")\n");
649                 bSuccess = false;
650             }
651         }
652         {
653             INetURLObject aObj;
654             aObj.setFSysPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
655                                                "a:/")),
656                              INetURLObject::FSYS_DETECT);
657             if (!rtl::OUString(aObj.GetMainURL(INetURLObject::NO_DECODE)).
658                      equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("file:///a:/")))
659             {
660                 printf("BAD setFSysPath(\"a:/\")\n");
661                 bSuccess = false;
662             }
663         }
664         {
665             INetURLObject aObj;
666             aObj.setFSysPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
667                                                "a:\\")),
668                              INetURLObject::FSYS_DETECT);
669             if (!rtl::OUString(aObj.GetMainURL(INetURLObject::NO_DECODE)).
670                      equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("file:///a:/")))
671             {
672                 printf("BAD setFSysPath(\"a:\\\")\n");
673                 bSuccess = false;
674             }
675         }
676 
677         if (!rtl::OUString(INetURLObject("file:///a:").
678                                getFSysPath(INetURLObject::FSYS_DETECT)).
679                  equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("a:")))
680         {
681             printf("BAD getFSysPath(\"file:///a:\")\n");
682             bSuccess = false;
683         }
684         if (!rtl::OUString(INetURLObject("file:///a:/").
685                                getFSysPath(INetURLObject::FSYS_DETECT)).
686                  equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("a:\\")))
687         {
688             printf("BAD getFSysPath(\"file:///a:/\")\n");
689             bSuccess = false;
690         }
691 
692         {
693             bool bWasAbsolute;
694             if (!rtl::OUString(INetURLObject(rtl::OUString(
695                                                  RTL_CONSTASCII_USTRINGPARAM(
696                                                      "file:///"))).
697                                    smartRel2Abs(
698                                            rtl::OUString(
699                                                RTL_CONSTASCII_USTRINGPARAM(
700                                                    "a:")),
701                                            bWasAbsolute).
702                                        GetMainURL(INetURLObject::NO_DECODE)).
703                      equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("file:///a:"))
704                 || !bWasAbsolute)
705             {
706                 printf("BAD smartRel2Abs(\"a:\")\n");
707                 bSuccess = false;
708             }
709         }
710         {
711             bool bWasAbsolute;
712             if (!rtl::OUString(INetURLObject(rtl::OUString(
713                                                  RTL_CONSTASCII_USTRINGPARAM(
714                                                      "file:///"))).
715                                    smartRel2Abs(
716                                            rtl::OUString(
717                                                RTL_CONSTASCII_USTRINGPARAM(
718                                                    "a:/")),
719                                            bWasAbsolute).
720                                        GetMainURL(INetURLObject::NO_DECODE)).
721                      equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("file:///a:/"))
722                 || !bWasAbsolute)
723             {
724                 printf("BAD smartRel2Abs(\"a:/\")\n");
725                 bSuccess = false;
726             }
727         }
728         {
729             bool bWasAbsolute;
730             if (!rtl::OUString(INetURLObject(rtl::OUString(
731                                                  RTL_CONSTASCII_USTRINGPARAM(
732                                                      "file:///"))).
733                                    smartRel2Abs(
734                                            rtl::OUString(
735                                                RTL_CONSTASCII_USTRINGPARAM(
736                                                    "a:\\")),
737                                            bWasAbsolute).
738                                        GetMainURL(INetURLObject::NO_DECODE)).
739                      equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("file:///a:/"))
740                 || !bWasAbsolute)
741             {
742                 printf("BAD smartRel2Abs(\"a:\\\")\n");
743                 bSuccess = false;
744             }
745         }
746         {
747             bool bWasAbsolute;
748             if (!rtl::OUString(INetURLObject(rtl::OUString(
749                                                  RTL_CONSTASCII_USTRINGPARAM(
750                                                      "file:///"))).
751                                    smartRel2Abs(
752                                            rtl::OUString(
753                                                RTL_CONSTASCII_USTRINGPARAM(
754                                                    "generic:")),
755                                            bWasAbsolute).
756                                        GetMainURL(INetURLObject::NO_DECODE)).
757                      equalsAsciiL(
758                          RTL_CONSTASCII_STRINGPARAM("file:///generic:"))
759                 || bWasAbsolute)
760             {
761                 printf("BAD smartRel2Abs(\"generic:\")\n");
762                 bSuccess = false;
763             }
764         }
765         {
766             bool bWasAbsolute;
767             if (!rtl::OUString(INetURLObject(rtl::OUString(
768                                                  RTL_CONSTASCII_USTRINGPARAM(
769                                                      "file:///"))).
770                                    smartRel2Abs(
771                                            rtl::OUString(
772                                                RTL_CONSTASCII_USTRINGPARAM(
773                                                    "generic:#fragment")),
774                                            bWasAbsolute).
775                                        GetMainURL(INetURLObject::NO_DECODE)).
776                      equalsAsciiL(
777                          RTL_CONSTASCII_STRINGPARAM(
778                              "file:///generic:#fragment"))
779                 || bWasAbsolute)
780             {
781                 printf("BAD smartRel2Abs(\"generic:#fragment\")\n");
782                 bSuccess = false;
783             }
784         }
785         {
786             bool bWasAbsolute;
787             if (!rtl::OUString(INetURLObject(rtl::OUString(
788                                                  RTL_CONSTASCII_USTRINGPARAM(
789                                                      "file:///"))).
790                                    smartRel2Abs(
791                                            rtl::OUString(
792                                                RTL_CONSTASCII_USTRINGPARAM(
793                                                    "generic:something")),
794                                            bWasAbsolute).
795                                        GetMainURL(INetURLObject::NO_DECODE)).
796                      equalsAsciiL(
797                          RTL_CONSTASCII_STRINGPARAM("generic:something"))
798                 || !bWasAbsolute)
799             {
800                 printf("BAD smartRel2Abs(\"generic:something\")\n");
801                 bSuccess = false;
802             }
803         }
804         {
805             bool bWasAbsolute;
806             if (!rtl::OUString(INetURLObject(rtl::OUString(
807                                                  RTL_CONSTASCII_USTRINGPARAM(
808                                                      "file:///"))).
809                                    smartRel2Abs(
810                                            rtl::OUString(
811                                                RTL_CONSTASCII_USTRINGPARAM(
812                                                    "\\\\unc_host\\path")),
813                                            bWasAbsolute).
814                                        GetMainURL(INetURLObject::NO_DECODE)).
815                      equalsAsciiL(
816                          RTL_CONSTASCII_STRINGPARAM("file://unc_host/path"))
817                 || !bWasAbsolute)
818             {
819                 printf("BAD smartRel2Abs(\"\\\\unc_host\\path\")\n");
820                 bSuccess = false;
821             }
822         }
823     }
824 
825     if (true)
826     {
827 /*TODO
828         {
829             INetURLObject aObj(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("http://xxx/yyy?abc/def~")));
830             if (!rtl::OUString(aObj.GetMainURL(INetURLObject::NO_DECODE)).
831                      equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("http://xxx/yyy?abc%2Fdef%7E")))
832             {
833                 printf("BAD http query 1\n");
834                 bSuccess = false;
835             }
836         }
837 */
838         {
839             INetURLObject aObj(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("https://xxx/yyy?abc/def~")));
840             if (!rtl::OUString(aObj.GetMainURL(INetURLObject::NO_DECODE)).
841                      equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("https://xxx/yyy?abc/def~")))
842             {
843                 printf("BAD https query 1\n");
844                 bSuccess = false;
845             }
846         }
847 /*TODO
848         {
849             INetURLObject aObj(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("http://xxx/yyy")));
850             aObj.SetParam("abc/def~");
851             if (!rtl::OUString(aObj.GetMainURL(INetURLObject::NO_DECODE)).
852                      equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("http://xxx/yyy?abc%2Fdef%7E")))
853             {
854                 printf("BAD http query 2\n");
855                 bSuccess = false;
856             }
857         }
858 */
859         {
860             INetURLObject aObj(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("https://xxx/yyy")));
861             aObj.SetParam("abc/def~");
862             if (!rtl::OUString(aObj.GetMainURL(INetURLObject::NO_DECODE)).
863                      equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("https://xxx/yyy?abc/def~")))
864             {
865                 printf("BAD https query 2\n");
866                 bSuccess = false;
867             }
868         }
869     }
870 
871     if (true)
872     {
873         if (INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.hier:"))).HasError())
874         {
875             printf("BAD vnd.sun.star.hier test 1\n");
876             bSuccess = false;
877         }
878         if (!INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.hier://"))).HasError())
879         {
880             printf("BAD vnd.sun.star.hier test 2\n");
881             bSuccess = false;
882         }
883         if (!INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.hier:///"))).HasError())
884         {
885             printf("BAD vnd.sun.star.hier test 3\n");
886             bSuccess = false;
887         }
888         if (!INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.hier:///abc"))).HasError())
889         {
890             printf("BAD vnd.sun.star.hier test 4\n");
891             bSuccess = false;
892         }
893         if (INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.hier://abc"))).HasError())
894         {
895             printf("BAD vnd.sun.star.hier test 5\n");
896             bSuccess = false;
897         }
898         if (INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.hier://abc/def"))).HasError())
899         {
900             printf("BAD vnd.sun.star.hier test 6\n");
901             bSuccess = false;
902         }
903     }
904 
905     if (false)
906     {
907         abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
908                                                    "file:///"))));
909         abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
910                                                    "file:///a"))));
911         abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
912                                                    "file:///a/def/"))));
913         abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
914                                                    "file:///ab/def/"))));
915         abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
916                                                    "file:///abc/def/"))));
917         abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
918                                                    "file:///a/def"))));
919         abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
920                                                    "file:///ab/def"))));
921         abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
922                                                    "file:///abc/def"))));
923         abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
924                                                    "file:///abcdef/d"))));
925         abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
926                                                    "file:///abcdef/de"))));
927         abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
928                                                    "file:///abcdef/def"))));
929         abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
930                                                    "file://some.host/"))));
931         abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
932                                                    "file://some.host/a"))));
933         abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
934                                                    "file://some.host/a/def/"))));
935         abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
936                                                    "file://some.host/ab/def/"))));
937         abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
938                                                    "file://some.host/abc/def/"))));
939         abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
940                                                    "file://some.host/a/def"))));
941         abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
942                                                    "file://some.host/ab/def"))));
943         abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
944                                                    "file://some.host/abc/def"))));
945         abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
946                                                    "file://some.host/abcdef/d"))));
947         abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
948                                                    "file://some.host/abcdef/de"))));
949         abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
950                                                    "file://some.host/abcdef/def"))));
951         abbreviate(INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
952             "http://foo/aa/bb//cc/d/eee////ff/ggggggg/hhhhhh/iii/j/"
953             "kkkkkkkkkkkkk/ll/mm/nn/oo/p"))));
954     }
955 
956     if (true)
957     {
958         {
959             rtl::OUString
960                 aBase(RTL_CONSTASCII_USTRINGPARAM("file:///a:/b/c"));
961             rtl::OUString aAbs(RTL_CONSTASCII_USTRINGPARAM("file:///a:/d/e"));
962             rtl::OUString aRel(INetURLObject::GetRelURL(aBase, aAbs));
963             if (!aRel.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("../d/e")))
964             {
965                 printf("BAD GetRelURL(%s, %s) = %s\n",
966                        rtl::OUStringToOString(aBase, RTL_TEXTENCODING_UTF8).
967                            getStr(),
968                        rtl::OUStringToOString(aAbs, RTL_TEXTENCODING_UTF8).
969                            getStr(),
970                        rtl::OUStringToOString(aRel, RTL_TEXTENCODING_UTF8).
971                            getStr());
972                 bSuccess = false;
973             }
974         }
975         {
976             rtl::OUString
977                 aBase(RTL_CONSTASCII_USTRINGPARAM("file:///a:/b/c"));
978             rtl::OUString aAbs(RTL_CONSTASCII_USTRINGPARAM("file:///d:/e/f"));
979             rtl::OUString aRel(INetURLObject::GetRelURL(aBase, aAbs));
980             if (aRel != aAbs)
981             {
982                 printf("BAD GetRelURL(%s, %s) = %s\n",
983                        rtl::OUStringToOString(aBase, RTL_TEXTENCODING_UTF8).
984                            getStr(),
985                        rtl::OUStringToOString(aAbs, RTL_TEXTENCODING_UTF8).
986                            getStr(),
987                        rtl::OUStringToOString(aRel, RTL_TEXTENCODING_UTF8).
988                            getStr());
989                 bSuccess = false;
990             }
991         }
992         {
993             rtl::OUString
994                 aBase(RTL_CONSTASCII_USTRINGPARAM("file:///a:/b/c"));
995             rtl::OUString aAbs(RTL_CONSTASCII_USTRINGPARAM("file:///d/e/f"));
996             rtl::OUString aRel(INetURLObject::GetRelURL(aBase, aAbs));
997             if (!aRel.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("../../d/e/f")))
998             {
999                 printf("BAD GetRelURL(%s, %s) = %s\n",
1000                        rtl::OUStringToOString(aBase, RTL_TEXTENCODING_UTF8).
1001                            getStr(),
1002                        rtl::OUStringToOString(aAbs, RTL_TEXTENCODING_UTF8).
1003                            getStr(),
1004                        rtl::OUStringToOString(aRel, RTL_TEXTENCODING_UTF8).
1005                            getStr());
1006                 bSuccess = false;
1007             }
1008         }
1009         {
1010             rtl::OUString
1011                 aBase(RTL_CONSTASCII_USTRINGPARAM("file:///a:/b/c"));
1012             rtl::OUString aAbs(RTL_CONSTASCII_USTRINGPARAM("file:///d:/e/f"));
1013             rtl::OUString
1014                 aRel(INetURLObject::GetRelURL(aBase,
1015                                               aAbs,
1016                                               INetURLObject::WAS_ENCODED,
1017                                               INetURLObject::DECODE_TO_IURI,
1018                                               RTL_TEXTENCODING_UTF8,
1019                                               INetURLObject::FSYS_UNX));
1020             if (!aRel.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(
1021                                        "../../d:/e/f")))
1022             {
1023                 printf("BAD GetRelURL(%s, %s) = %s\n",
1024                        rtl::OUStringToOString(aBase, RTL_TEXTENCODING_UTF8).
1025                            getStr(),
1026                        rtl::OUStringToOString(aAbs, RTL_TEXTENCODING_UTF8).
1027                            getStr(),
1028                        rtl::OUStringToOString(aRel, RTL_TEXTENCODING_UTF8).
1029                            getStr());
1030                 bSuccess = false;
1031             }
1032         }
1033 /*TODO
1034         {
1035             rtl::OUString
1036                 aBase(RTL_CONSTASCII_USTRINGPARAM("file:///test.html"));
1037             rtl::OUString
1038                 aAbs(RTL_CONSTASCII_USTRINGPARAM("/images/myimage.gif"));
1039             rtl::OUString aRel(INetURLObject::GetRelURL(aBase, aAbs));
1040             if (aRel != aAbs)
1041             {
1042                 printf("BAD GetRelURL(%s, %s) = %s\n",
1043                        rtl::OUStringToOString(aBase, RTL_TEXTENCODING_UTF8).
1044                            getStr(),
1045                        rtl::OUStringToOString(aAbs, RTL_TEXTENCODING_UTF8).
1046                            getStr(),
1047                        rtl::OUStringToOString(aRel, RTL_TEXTENCODING_UTF8).
1048                            getStr());
1049                 bSuccess = false;
1050             }
1051         }
1052 */
1053     }
1054 
1055     if (true)
1056     {
1057         INetURLObject aUrl(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
1058                                              "file://host/dir/file")));
1059         rtl::OUString aPath;
1060         aPath = aUrl.getFSysPath(INetURLObject::FSYS_DETECT);
1061         if (!aPath.
1062                  equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("//host/dir/file")))
1063         {
1064             printf("BAD getFSysPath(VOS|UNX|DOS|MAC) = %s\n",
1065                    rtl::OUStringToOString(aPath, RTL_TEXTENCODING_UTF8).
1066                        getStr());
1067             bSuccess = false;
1068         }
1069         aPath = aUrl.getFSysPath(INetURLObject::FSysStyle(
1070                                      INetURLObject::FSYS_UNX
1071                                          | INetURLObject::FSYS_DOS
1072                                          | INetURLObject::FSYS_MAC));
1073         if (!aPath.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(
1074                                     "\\\\host\\dir\\file")))
1075         {
1076             printf("BAD getFSysPath(UNX|DOS|MAC) = %s\n",
1077                    rtl::OUStringToOString(aPath, RTL_TEXTENCODING_UTF8).
1078                        getStr());
1079             bSuccess = false;
1080         }
1081         aPath = aUrl.getFSysPath(INetURLObject::FSysStyle(
1082                                      INetURLObject::FSYS_UNX
1083                                          | INetURLObject::FSYS_MAC));
1084         if (aPath.getLength() != 0)
1085         {
1086             printf("BAD getFSysPath(UNX|MAC) = %s\n",
1087                    rtl::OUStringToOString(aPath, RTL_TEXTENCODING_UTF8).
1088                        getStr());
1089             bSuccess = false;
1090         }
1091     }
1092 
1093     if (true)
1094     {
1095         {
1096             INetURLObject aUrl1(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.odma:")));
1097             rtl::OUString aUrl2(aUrl1.GetMainURL(
1098                                     INetURLObject::DECODE_TO_IURI));
1099             if (!aUrl2.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.odma:/")))
1100             {
1101                 printf("BAD vnd.sun.star.odma: != %s\n",
1102                        rtl::OUStringToOString(aUrl2, RTL_TEXTENCODING_UTF8).
1103                            getStr());
1104                 bSuccess = false;
1105             }
1106         }
1107         {
1108             INetURLObject aUrl1(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.odma:/")));
1109             rtl::OUString aUrl2(aUrl1.GetMainURL(
1110                                     INetURLObject::DECODE_TO_IURI));
1111             if (!aUrl2.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.odma:/")))
1112             {
1113                 printf("BAD vnd.sun.star.odma:/ != %s\n",
1114                        rtl::OUStringToOString(aUrl2, RTL_TEXTENCODING_UTF8).
1115                            getStr());
1116                 bSuccess = false;
1117             }
1118         }
1119         {
1120             INetURLObject aUrl1(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.odma:/bla/bla")));
1121             rtl::OUString aUrl2(aUrl1.GetMainURL(
1122                                     INetURLObject::DECODE_TO_IURI));
1123             if (!aUrl2.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.odma:/bla%2Fbla")))
1124             {
1125                 printf("BAD vnd.sun.star.odma:/bla/bla != %s\n",
1126                        rtl::OUStringToOString(aUrl2, RTL_TEXTENCODING_UTF8).
1127                            getStr());
1128                 bSuccess = false;
1129             }
1130         }
1131     }
1132 
1133     if (true)
1134     {
1135         struct Test
1136         {
1137             char const * m_pInput;
1138             char const * m_pOutput;
1139         };
1140         static Test const aTest[]
1141             = { { "file:///abc", "file:///abc" },
1142                 { "file://localhost/abc", "file:///abc" },
1143                 { "file://LocalHost/abc", "file:///abc" },
1144                 { "file://LOCALHOST/abc", "file:///abc" },
1145                 { "file://127.0.0.1/abc", "file://127.0.0.1/abc" },
1146                 { "file://xxx.yyy-zzz/abc", "file://xxx.yyy-zzz/abc" },
1147                 { "file://xxx_yyy/abc", "file://xxx_yyy/abc" },
1148                 { "file://!%23$%&'()-.@^_{}~/abc",
1149                   "file://!%23$%25&'()-.@%5E_%7B%7D~/abc" },
1150                 { "file://d:\\dir1\\file1", 0 },
1151                 { "http://as@alaska:8000/test/test.sxw", 0 },
1152                 { "telnet:", 0 },
1153                 { "telnet://", 0 },
1154                 { "telnet://ab:cd@ef:", "telnet://ab:cd@ef:/" },
1155                 { "telnet://ab:cd@ef:123", "telnet://ab:cd@ef:123/" },
1156                 { "TELNET://abc.def.ghi/", "telnet://abc.def.ghi/" },
1157                 { "telnet://abc.def.ghi/jkl", 0 },
1158                 { "telnet://abc.def.ghi?jkl", 0 },
1159                 { "telnet://abc.def.ghi/?jkl", 0 },
1160                 { "file:", 0 },
1161                 { "file:/", "file:///" },
1162                 { "file:/abc", "file:///abc" },
1163                 { "file:/abc/def", "file:///abc/def" },
1164                 { "file:/localhost", "file:///localhost" },
1165                 { "file://", "file:///" },
1166                 { "file:///", "file:///" },
1167                 { "http:", 0 },
1168                 { "http:/abc", 0 },
1169                 { "news:", 0 },
1170                 { "news:*", "news:*" },
1171                 { "news:**", 0 },
1172                 { "news:%2A", 0 },
1173                 { "news:a", "news:a" },
1174                 { "news:A", "news:A" },
1175                 { "news:+-._", 0 },
1176                 { "news:A0+-._", "news:A0+-._" },
1177                 { "news:0", 0 },
1178                 { "news:AB,", 0 },
1179                 { "news:abc@def", "news:abc@def" },
1180                 { "news:abc@def:33", 0 },
1181                 { "news:abc@123.456.789.0", "news:abc@123.456.789.0" },
1182                 { "news:abc@def.", "news:abc@def." },
1183                 { "news:abc@def.ghi", "news:abc@def.ghi" },
1184                 { "news:abc@def.-ghi", 0 },
1185                 { "news:abc@def.ghi@", 0 },
1186                 { "news:%21%22%23@def", "news:%21%22%23@def" },
1187                 { "news:!%22%23@def", "news:!%22%23@def" },
1188                 { "news: @def", "news:%20@def" },
1189                 { "vnd.sun.star.tdoc:", 0 },
1190                 { "vnd.sun.star.tdoc:a/b/c", 0 },
1191                 { "vnd.sun.star.tdoc:/", "vnd.sun.star.tdoc:/" },
1192                 { "vnd.sun.star.tdoc:/a;b/", "vnd.sun.star.tdoc:/a%3Bb/" },
1193                 { "vnd.sun.star.tdoc:/a?b", "vnd.sun.star.tdoc:/a%3Fb" },
1194                 { "http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/x",
1195                   "http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]:80/x" },
1196                 { "http://[1080:0:0:0:8:800:200C:417A]/index.html",
1197                   "http://[1080:0:0:0:8:800:200c:417a]/index.html" },
1198                 { "http://[3ffe:2a00:100:7031::1]",
1199                   "http://[3ffe:2a00:100:7031::1]/" },
1200                 { "http://[1080::8:800:200c:417a]/foo",
1201                   "http://[1080::8:800:200c:417a]/foo" },
1202                 { "http://[::192.9.5.5]/ipng", "http://[::192.9.5.5]/ipng" },
1203                 { "http://[:::192.9.5.5]/ipng", "http://[:::192.9.5.5]/ipng" },
1204                 { "http://[::FFFF:129.144.52.38]:80/index.html",
1205                   "http://[::ffff:129.144.52.38]:80/index.html" },
1206                 { "http://[2010:836B:4179::836B:4179]",
1207                   "http://[2010:836b:4179::836b:4179]/" },
1208                 { "http://[::1]", "http://[::1]/" },
1209                 { "http://[0:0:0:0:0:0:13.1.68.3]/",
1210                   "http://[0:0:0:0:0:0:13.1.68.3]/" },
1211                 { "http://[0:0:0:0:0:FFFF:129.144.52.38]/",
1212                   "http://[0:0:0:0:0:ffff:129.144.52.38]/" },
1213                 { "smb://", "smb:///" },
1214                 { "smb://foo", "smb://foo/" },
1215                 { "smb://x;foo:bar@baz.xyz:12345/ab?cd",
1216                   "smb://x;foo:bar@baz.xyz:12345/ab?cd" } };
1217         for (std::size_t i = 0; i < sizeof aTest / sizeof aTest[0]; ++i)
1218         {
1219             INetURLObject aUrl(aTest[i].m_pInput);
1220             if (aTest[i].m_pOutput == 0
1221                 ? !aUrl.HasError()
1222                 : (aUrl.HasError()
1223                    || (aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI).
1224                            equalsAscii(aTest[i].m_pOutput)
1225                        != sal_True)))
1226             {
1227                 String sTest(aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI));
1228                 printf("BAD %s -> %s != %s\n",
1229                        aTest[i].m_pInput,
1230                        aUrl.HasError() ? "<none>"
1231                        : ByteString(sTest, RTL_TEXTENCODING_ASCII_US).GetBuffer(),
1232                        aTest[i].m_pOutput == 0 ? "<none>" : aTest[i].m_pOutput);
1233             }
1234         }
1235     }
1236 
1237     if (true)
1238     {
1239         struct Test
1240         {
1241             char const * m_pInput;
1242             char const * m_pOutput;
1243         };
1244         static Test const aTest[]
1245             = { { "file://d:\\dir1\\file1", "file:///d:/dir1/file1" },
1246                 { "http://as@alaska:8000/test/test.sxw", 0 } };
1247         for (std::size_t i = 0; i < sizeof aTest / sizeof aTest[0]; ++i)
1248         {
1249             INetURLObject aUrl = INetURLObject(
1250                 String(aTest[i].m_pInput, RTL_TEXTENCODING_UTF8),
1251                 INET_PROT_HTTP);
1252             if (aTest[i].m_pOutput == 0
1253                 ? !aUrl.HasError()
1254                 : (aUrl.HasError()
1255                    || (aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI).
1256                            equalsAscii(aTest[i].m_pOutput)
1257                        != sal_True)))
1258             {
1259                 String sTest(aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI));
1260                 printf("BAD %s -> %s != %s\n",
1261                        aTest[i].m_pInput,
1262                        aUrl.HasError() ? "<none>"
1263                        : ByteString(sTest, RTL_TEXTENCODING_ASCII_US).GetBuffer(),
1264                        aTest[i].m_pOutput == 0 ? "<none>" : aTest[i].m_pOutput);
1265             }
1266         }
1267     }
1268 
1269     if (true)
1270     {
1271         INetURLObject aUrl;
1272         rtl::OUString aUser;
1273         aUrl = INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
1274                                                "ftp://test")));
1275         aUser = aUrl.GetUser();
1276         if (aUser.getLength() != 0)
1277             printf(
1278                 "BAD <ftp://test> user: \"%s\" != \"\"",
1279                 rtl::OUStringToOString(aUser, RTL_TEXTENCODING_UTF8).getStr());
1280         aUrl = INetURLObject(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
1281                                                "ftp://user@test")));
1282         aUser = aUrl.GetUser();
1283         if (!aUser.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("user")))
1284             printf(
1285                 "BAD <ftp://user@test> user: \"%s\" != \"user\"",
1286                 rtl::OUStringToOString(aUser, RTL_TEXTENCODING_UTF8).getStr());
1287     }
1288 
1289     if (true)
1290     {
1291         INetURLObject aUrl;
1292 
1293         aUrl = INetURLObject("vnd.sun.star.pkg://foo.bar/a/b/c?abc/def?");
1294         if (aUrl.GetProtocol() != INET_PROT_VND_SUN_STAR_PKG)
1295             printf("BAD <vnd.sun.star.pkg://foo.bar/a/b/c?abc/def?>:"
1296                    " scheme = %d\n",
1297                    static_cast< int >(aUrl.GetProtocol()));
1298         else
1299         {
1300             if (!rtl::OUString(aUrl.GetMainURL(INetURLObject::NO_DECODE)).
1301                 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(
1302                                  "vnd.sun.star.pkg://foo.bar/a/b/c?abc/def?")))
1303                 printf("BAD <vnd.sun.star.pkg://foo.bar/a/b/c?abc/def?>:"
1304                        " URL = %s\n",
1305                        rtl::OUStringToOString(
1306                            aUrl.GetMainURL(INetURLObject::NO_DECODE),
1307                            RTL_TEXTENCODING_UTF8).getStr());
1308             if (!rtl::OUString(aUrl.GetParam(INetURLObject::NO_DECODE)).
1309                 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("abc/def?")))
1310                 printf("BAD <vnd.sun.star.pkg://foo.bar/a/b/c?abc/def?>:"
1311                        " query = %s\n",
1312                        rtl::OUStringToOString(
1313                            aUrl.GetParam(INetURLObject::NO_DECODE),
1314                            RTL_TEXTENCODING_UTF8).getStr());
1315         }
1316 
1317         aUrl = INetURLObject("vnd.sun.star.pkg://foo.bar/a/b/c%3Fabc/def%3F");
1318         if (aUrl.GetProtocol() != INET_PROT_VND_SUN_STAR_PKG)
1319             printf("BAD <vnd.sun.star.pkg://foo.bar/a/b/c%%3Fabc/def%%3F>:"
1320                    " scheme = %d\n",
1321                    static_cast< int >(aUrl.GetProtocol()));
1322         else
1323         {
1324             if (!rtl::OUString(aUrl.GetMainURL(INetURLObject::NO_DECODE)).
1325                 equalsAsciiL(
1326                     RTL_CONSTASCII_STRINGPARAM(
1327                         "vnd.sun.star.pkg://foo.bar/a/b/c%3Fabc/def%3F")))
1328                 printf("BAD <vnd.sun.star.pkg://foo.bar/a/b/c?abc/def?>:"
1329                        " URL = %s\n",
1330                        rtl::OUStringToOString(
1331                            aUrl.GetMainURL(INetURLObject::NO_DECODE),
1332                            RTL_TEXTENCODING_UTF8).getStr());
1333             if (!rtl::OUString(aUrl.GetParam(INetURLObject::NO_DECODE)).
1334                 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("")))
1335                 printf("BAD <vnd.sun.star.pkg://foo.bar/a/b/c%%3Fabc/def%%3F>:"
1336                        " query = %s\n",
1337                        rtl::OUStringToOString(
1338                            aUrl.GetParam(INetURLObject::NO_DECODE),
1339                            RTL_TEXTENCODING_UTF8).getStr());
1340         }
1341     }
1342 
1343     if (true)
1344     {
1345         struct Test
1346         {
1347             INetProtocol eScheme;
1348             char const * pPath;
1349             char const * pUri;
1350         };
1351         static Test const aTest[]
1352             = { { INET_PROT_FILE, "", "file:///" },
1353                 { INET_PROT_FILE, "/", "file:///" },
1354                 { INET_PROT_FILE, "abc", 0 },
1355                 { INET_PROT_FILE, "/abc/", "file:///abc/" },
1356                 { INET_PROT_NEWS, "", 0 },
1357                 { INET_PROT_NEWS, "*", "news:*" },
1358                 { INET_PROT_NEWS, "**", 0 },
1359                 { INET_PROT_NEWS, "%2A", 0 },
1360                 { INET_PROT_NEWS, "a", "news:a" },
1361                 { INET_PROT_NEWS, "A", "news:A" },
1362                 { INET_PROT_NEWS, "+-._", 0 },
1363                 { INET_PROT_NEWS, "A0+-._", "news:A0+-._" },
1364                 { INET_PROT_NEWS, "0", 0 },
1365                 { INET_PROT_NEWS, "AB,", 0 },
1366                 { INET_PROT_NEWS, "abc@def", "news:abc@def" },
1367                 { INET_PROT_NEWS, "abc@def:33", 0 },
1368                 { INET_PROT_NEWS, "abc@123.456.789.0",
1369                   "news:abc@123.456.789.0" },
1370                 { INET_PROT_NEWS, "abc@def.", "news:abc@def." },
1371                 { INET_PROT_NEWS, "abc@def.ghi", "news:abc@def.ghi" },
1372                 { INET_PROT_NEWS, "abc@def.-ghi", 0 },
1373                 { INET_PROT_NEWS, "abc@def.ghi@", 0 },
1374                 { INET_PROT_NEWS, "!\"#@def", "news:!%22%23@def" },
1375                 { INET_PROT_NEWS, " @def", "news:%20@def" } };
1376         for (std::size_t i = 0; i < sizeof aTest / sizeof aTest[0]; ++i)
1377         {
1378             INetURLObject aUri;
1379             bool bOk = aUri.ConcatData(aTest[i].eScheme, String(), String(),
1380                                        String(), 0,
1381                                        String(aTest[i].pPath,
1382                                               RTL_TEXTENCODING_ASCII_US),
1383                                        INetURLObject::ENCODE_ALL);
1384             if (bOk == aUri.HasError())
1385                 printf(
1386                     "BAD ConcatData(%d, ..., %s) = %d, HasError() = %d\n",
1387                     static_cast< int >(aTest[i].eScheme), aTest[i].pPath,
1388                     static_cast< int >(bOk),
1389                     static_cast< int >(aUri.HasError()));
1390             else if (aTest[i].pUri == 0
1391                      ? !aUri.HasError()
1392                      : (aUri.HasError()
1393                         || (aUri.GetMainURL(INetURLObject::DECODE_TO_IURI).
1394                                 equalsAscii(aTest[i].pUri)
1395                             != sal_True)))
1396             {
1397                 String sTest(aUri.GetMainURL(INetURLObject::DECODE_TO_IURI));
1398                 printf("BAD ConcatData(%d, ..., %s) -> %s != %s\n",
1399                        static_cast< int >(aTest[i].eScheme), aTest[i].pPath,
1400                        aUri.HasError() ? "<none>"
1401                        : ByteString(sTest, RTL_TEXTENCODING_ASCII_US).GetBuffer(),
1402                        aTest[i].pUri == 0 ? "<none>" : aTest[i].pUri);
1403             }
1404         }
1405     }
1406 
1407     if (true)
1408     {
1409         // #i13760#
1410 
1411         // Test for unrelated URLs.
1412         const rtl::OUString aBaseURL(RTL_CONSTASCII_USTRINGPARAM(
1413                                 "http://www.openoffice.org"));
1414         rtl::OUString aRelURL (RTL_CONSTASCII_USTRINGPARAM(
1415                                 "http://www.sun.com"));
1416 
1417         rtl::OUString aRelURLToTest(
1418             INetURLObject::GetRelURL(aBaseURL, aRelURL));
1419 
1420         if (INetURLObject(aRelURLToTest) != INetURLObject(aRelURL))
1421             printf("BAD GetRelURL(%s, %s), ret = %s\n",
1422                        ByteString(aBaseURL.getStr(),
1423                                   RTL_TEXTENCODING_ASCII_US).GetBuffer(),
1424                        ByteString(aRelURL.getStr(),
1425                                   RTL_TEXTENCODING_ASCII_US).GetBuffer(),
1426                        ByteString(aRelURLToTest.getStr(),
1427                                   RTL_TEXTENCODING_ASCII_US).GetBuffer());
1428 
1429         // Test for related URLs.
1430         aRelURL = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
1431                                 "http://www.openoffice.org/api/test.html"));
1432         aRelURLToTest = rtl::OUString(
1433             INetURLObject::GetRelURL(aBaseURL, aRelURL));
1434 
1435         if (!aRelURLToTest.equalsAsciiL(
1436                 RTL_CONSTASCII_STRINGPARAM("api/test.html")))
1437             printf("BAD GetRelURL(%s, %s), ret = %s\n",
1438                        ByteString(aBaseURL.getStr(),
1439                                   RTL_TEXTENCODING_ASCII_US).GetBuffer(),
1440                        ByteString(aRelURL.getStr(),
1441                                   RTL_TEXTENCODING_ASCII_US).GetBuffer(),
1442                        ByteString(aRelURLToTest.getStr(),
1443                                   RTL_TEXTENCODING_ASCII_US).GetBuffer());
1444     }
1445 
1446     if (true) { // #112130#
1447         INetURLObject url1(rtl::OUString::createFromAscii(".uno:abc%3Fdef"));
1448         if (url1.GetProtocol() != INET_PROT_UNO) {
1449             printf("BAD .uno:abc%%3Fdef\n");
1450             bSuccess = false;
1451         }
1452         if (!rtl::OUString(url1.GetURLPath(INetURLObject::NO_DECODE)).
1453                 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("abc%3Fdef"))) {
1454             printf(
1455                 "BAD GetURLPath(.uno:abc%%3Fdef): %s\n",
1456                 rtl::OUStringToOString(
1457                     url1.GetURLPath(INetURLObject::NO_DECODE),
1458                     osl_getThreadTextEncoding()).getStr());
1459             bSuccess = false;
1460         }
1461         if (url1.HasParam()) {
1462             printf("BAD HasParam(.uno:abc%%3Fdef)\n");
1463             bSuccess = false;
1464         }
1465         INetURLObject url2(rtl::OUString::createFromAscii(".uno:abc?def?ghi"));
1466         if (url2.GetProtocol() != INET_PROT_UNO) {
1467             printf("BAD .uno:abc?def?ghi\n");
1468             bSuccess = false;
1469         }
1470         if (!rtl::OUString(url2.GetURLPath(INetURLObject::NO_DECODE)).
1471                 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("abc"))) {
1472             printf(
1473                 "BAD GetURLPath(.uno:abc?def?ghi): %s\n",
1474                 rtl::OUStringToOString(
1475                     url2.GetURLPath(INetURLObject::NO_DECODE),
1476                     osl_getThreadTextEncoding()).getStr());
1477             bSuccess = false;
1478         }
1479         if (!url2.HasParam()) {
1480             printf("BAD HasParam(.uno:abc?def?ghi)\n");
1481             bSuccess = false;
1482         }
1483         if (!rtl::OUString(url2.GetParam(INetURLObject::NO_DECODE)).
1484                 equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("def?ghi"))) {
1485             printf(
1486                 "BAD GetURLPath(.uno:abc?def?ghi): %s\n",
1487                 rtl::OUStringToOString(
1488                     url2.GetParam(INetURLObject::NO_DECODE),
1489                     osl_getThreadTextEncoding()).getStr());
1490             bSuccess = false;
1491         }
1492     }
1493 
1494     if (true) { // #116269#
1495         rtl::OUString url;
1496         INetURLObject urlobj;
1497 
1498         url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("A-b.3:/%2f?x#y"));
1499         urlobj = INetURLObject(url);
1500         bSuccess &= assertEqual(url, INET_PROT_GENERIC, urlobj.GetProtocol());
1501         bSuccess &= assertEqual(
1502             url, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("a-b.3:/%2F?x#y")),
1503             rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE)));
1504         bSuccess &= assertEqual(url, false, urlobj.HasUserData());
1505         bSuccess &= assertEqual(url, false, urlobj.hasPassword());
1506         bSuccess &= assertEqual(url, false, urlobj.HasPort());
1507         bSuccess &= assertEqual(
1508             url, rtl::OUString(), rtl::OUString(urlobj.GetHost()));
1509         bSuccess &= assertEqual(
1510             url, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/%2F?x")),
1511             rtl::OUString(urlobj.GetURLPath()));
1512         bSuccess &= assertEqual(url, false, urlobj.HasParam());
1513         bSuccess &= assertEqual(url, true, urlobj.HasMark());
1514         bSuccess &= assertEqual(
1515             url, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("y")),
1516             rtl::OUString(urlobj.GetMark()));
1517 
1518         url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foo:"));
1519         urlobj = INetURLObject(url);
1520         bSuccess &= assertEqual(url, true, urlobj.HasError());
1521 
1522         url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foo:#"));
1523         urlobj = INetURLObject(url);
1524         bSuccess &= assertEqual(url, true, urlobj.HasError());
1525 
1526         url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foo:/"));
1527         urlobj = INetURLObject(url);
1528         bSuccess &= assertEqual(url, INET_PROT_GENERIC, urlobj.GetProtocol());
1529         bSuccess &= assertEqual(
1530             url, url,
1531             rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE)));
1532 
1533         url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".foo:/"));
1534         urlobj = INetURLObject(url);
1535         bSuccess &= assertEqual(url, true, urlobj.HasError());
1536 
1537         url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("C:\\bla"));
1538         urlobj = INetURLObject(url);
1539         bSuccess &= assertEqual(url, true, urlobj.HasError());
1540 
1541         url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("C:\\bla"));
1542         urlobj = INetURLObject(url, INET_PROT_FILE);
1543         bSuccess &= assertEqual(url, INET_PROT_FILE, urlobj.GetProtocol());
1544         bSuccess &= assertEqual(
1545             url, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///C:/bla")),
1546             rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE)));
1547 
1548         url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LPR:\\bla"));
1549         urlobj = INetURLObject(url);
1550         bSuccess &= assertEqual(url, INET_PROT_GENERIC, urlobj.GetProtocol());
1551         bSuccess &= assertEqual(
1552             url, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("lpr:%5Cbla")),
1553             rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE)));
1554 
1555         url = rtl::OUString(
1556             RTL_CONSTASCII_USTRINGPARAM("private:factory/swriter"));
1557         urlobj = INetURLObject(url);
1558         bSuccess &= assertEqual(
1559             url, INET_PROT_PRIV_SOFFICE, urlobj.GetProtocol());
1560         bSuccess &= assertEqual(
1561             url, url,
1562             rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE)));
1563 
1564         url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("A-b.3:/%2f?x#y"));
1565         urlobj = INetURLObject(url, INET_PROT_CID);
1566         bSuccess &= assertEqual(url, INET_PROT_GENERIC, urlobj.GetProtocol());
1567         bSuccess &= assertEqual(
1568             url, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("a-b.3:/%2F?x#y")),
1569             rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE)));
1570 
1571         url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foo:"));
1572         urlobj = INetURLObject(url, INET_PROT_CID);
1573         bSuccess &= assertEqual(url, INET_PROT_CID, urlobj.GetProtocol());
1574         bSuccess &= assertEqual(
1575             url, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cid:foo:")),
1576             rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE)));
1577 
1578         url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foo:#"));
1579         urlobj = INetURLObject(url, INET_PROT_CID);
1580         bSuccess &= assertEqual(url, INET_PROT_CID, urlobj.GetProtocol());
1581         bSuccess &= assertEqual(
1582             url, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cid:foo:#")),
1583             rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE)));
1584 
1585         url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foo:/"));
1586         urlobj = INetURLObject(url, INET_PROT_CID);
1587         bSuccess &= assertEqual(url, INET_PROT_GENERIC, urlobj.GetProtocol());
1588         bSuccess &= assertEqual(
1589             url, url,
1590             rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE)));
1591 
1592         url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".foo:/"));
1593         urlobj = INetURLObject(url, INET_PROT_CID);
1594         bSuccess &= assertEqual(url, INET_PROT_CID, urlobj.GetProtocol());
1595         bSuccess &= assertEqual(
1596             url, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cid:.foo:/")),
1597             rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE)));
1598 
1599         url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("C:\\bla"));
1600         urlobj = INetURLObject(url, INET_PROT_CID);
1601         bSuccess &= assertEqual(url, INET_PROT_FILE, urlobj.GetProtocol());
1602         bSuccess &= assertEqual(
1603             url, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///C:/bla")),
1604             rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE)));
1605 
1606         url = rtl::OUString(
1607             RTL_CONSTASCII_USTRINGPARAM("private:factory/swriter"));
1608         urlobj = INetURLObject(url, INET_PROT_CID);
1609         bSuccess &= assertEqual(
1610             url, INET_PROT_PRIV_SOFFICE, urlobj.GetProtocol());
1611         bSuccess &= assertEqual(
1612             url, url,
1613             rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE)));
1614 
1615         // #i80134#:
1616         url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\\\\foobar\\%20#"));
1617         urlobj = INetURLObject(url, INET_PROT_FILE);
1618         bSuccess &= assertEqual(url, INET_PROT_FILE, urlobj.GetProtocol());
1619         bSuccess &= assertEqual(
1620             url,
1621             rtl::OUString(
1622                 RTL_CONSTASCII_USTRINGPARAM("file://foobar/%2520%23")),
1623             rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE)));
1624         url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\\\\foo_bar\\%20#"));
1625         urlobj = INetURLObject(url, INET_PROT_FILE);
1626         bSuccess &= assertEqual(url, INET_PROT_FILE, urlobj.GetProtocol());
1627         bSuccess &= assertEqual(
1628             url,
1629             rtl::OUString(
1630                 RTL_CONSTASCII_USTRINGPARAM("file://foo_bar/%2520%23")),
1631             rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE)));
1632     }
1633 
1634     if (true) { // #i53184#
1635         rtl::OUString url(RTL_CONSTASCII_USTRINGPARAM("file://comp_name/path"));
1636         bSuccess &= assertEqual(
1637             rtl::OUString(
1638                 RTL_CONSTASCII_USTRINGPARAM("#i53184# smart INET_PROT_FILE")),
1639             INetURLObject(url, INET_PROT_FILE).GetMainURL(
1640                 INetURLObject::NO_DECODE),
1641             url);
1642         bSuccess &= assertEqual(
1643             rtl::OUString(
1644                 RTL_CONSTASCII_USTRINGPARAM("#i53184# strict")),
1645             INetURLObject(url).GetMainURL(INetURLObject::NO_DECODE), url);
1646     }
1647 
1648     if (true) {
1649         rtl::OUString path;
1650         path = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/a/b/c"));
1651         bSuccess &= assertEqual(
1652             path,
1653             rtl::OUString(
1654                 INetURLObject(path, INetURLObject::FSYS_DETECT).GetMainURL(
1655                     INetURLObject::NO_DECODE)),
1656             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///a/b/c")));
1657         path = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("a\\b\\c"));
1658         bSuccess &= assertEqual(
1659             path,
1660             rtl::OUString(
1661                 INetURLObject(path, INetURLObject::FSYS_DETECT).GetMainURL(
1662                     INetURLObject::NO_DECODE)),
1663             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///a/b/c")));
1664         path = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("a:b:c"));
1665         bSuccess &= assertEqual(
1666             path, INetURLObject(path, INetURLObject::FSYS_DETECT).HasError(),
1667             true);
1668         bSuccess &= assertEqual(
1669             path,
1670             rtl::OUString(
1671                 INetURLObject(
1672                     path,
1673                     INetURLObject::FSysStyle(
1674                         INetURLObject::FSYS_DETECT | INetURLObject::FSYS_MAC)).
1675                 GetMainURL(INetURLObject::NO_DECODE)),
1676             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///a/b/c")));
1677         rtl::OUString url;
1678         url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/a/b/c"));
1679         bSuccess &= assertEqual(
1680             url,
1681             rtl::OUString(
1682                 INetURLObject(url, INET_PROT_HTTP).GetMainURL(
1683                     INetURLObject::NO_DECODE)),
1684             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///a/b/c")));
1685         url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("a:\\b\\c"));
1686         bSuccess &= assertEqual(
1687             url,
1688             rtl::OUString(
1689                 INetURLObject(url, INET_PROT_HTTP).GetMainURL(
1690                     INetURLObject::NO_DECODE)),
1691             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///a:/b/c")));
1692         url = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("a:b:c"));
1693         bSuccess &= assertEqual(
1694             url, INetURLObject(url, INET_PROT_HTTP).HasError(), true);
1695         bSuccess &= assertEqual(
1696             url,
1697             (INetURLObject(
1698                 url, INET_PROT_HTTP, INetURLObject::WAS_ENCODED,
1699                 RTL_TEXTENCODING_UTF8,
1700                 INetURLObject::FSysStyle(
1701                     INetURLObject::FSYS_DETECT | INetURLObject::FSYS_MAC)).
1702              HasError()),
1703             true);
1704     }
1705 
1706     bSuccess &= test_getSegmentCount("mailto:a@b", false, 0);
1707     bSuccess &= test_getSegmentCount("vnd.sun.star.expand:$PREFIX", false, 1);
1708     bSuccess &= test_getSegmentCount("vnd.sun.star.expand:$PREFIX", true, 1);
1709     bSuccess &= test_getSegmentCount("vnd.sun.star.expand:$PREFIX/", false, 2);
1710     bSuccess &= test_getSegmentCount("vnd.sun.star.expand:$PREFIX/", true, 1);
1711     bSuccess &= test_getSegmentCount(
1712         "vnd.sun.star.expand:$PREFIX/foo", false, 2);
1713     bSuccess &= test_getSegmentCount(
1714         "vnd.sun.star.expand:$PREFIX/foo", true, 2);
1715     bSuccess &= test_getSegmentCount("file:///", false, 1);
1716     bSuccess &= test_getSegmentCount("file:///", true, 0);
1717     bSuccess &= test_getSegmentCount("file:///foo", false, 1);
1718     bSuccess &= test_getSegmentCount("file:///foo", true, 1);
1719 
1720     bSuccess &= test_insertName(
1721         "mailto:a@b", "foo", false, 0, false, false, "mailto:a@b");
1722     bSuccess &= test_insertName(
1723         "vnd.sun.star.expand:$PREFIX", "foo", false, 0, false, true,
1724         "vnd.sun.star.expand:%2Ffoo/$PREFIX");
1725     bSuccess &= test_insertName(
1726         "vnd.sun.star.expand:$PREFIX", "foo", false, 0, true, true,
1727         "vnd.sun.star.expand:%2Ffoo/$PREFIX");
1728     bSuccess &= test_insertName(
1729         "vnd.sun.star.expand:$PREFIX", "foo", true, 0, false, true,
1730         "vnd.sun.star.expand:%2Ffoo/$PREFIX");
1731     bSuccess &= test_insertName(
1732         "vnd.sun.star.expand:$PREFIX", "foo", true, 0, true, true,
1733         "vnd.sun.star.expand:%2Ffoo/$PREFIX");
1734     bSuccess &= test_insertName(
1735         "vnd.sun.star.expand:$PREFIX", "foo", false, 1, false, true,
1736         "vnd.sun.star.expand:$PREFIX/foo");
1737     bSuccess &= test_insertName(
1738         "vnd.sun.star.expand:$PREFIX", "foo", false, 1, true, true,
1739         "vnd.sun.star.expand:$PREFIX/foo");
1740     bSuccess &= test_insertName(
1741         "vnd.sun.star.expand:$PREFIX", "foo", true, 1, false, true,
1742         "vnd.sun.star.expand:$PREFIX/foo/");
1743     bSuccess &= test_insertName(
1744         "vnd.sun.star.expand:$PREFIX", "foo", true, 1, true, true,
1745         "vnd.sun.star.expand:$PREFIX/foo/");
1746     bSuccess &= test_insertName(
1747         "vnd.sun.star.expand:$PREFIX", "foo", false,
1748         INetURLObject::LAST_SEGMENT, false, true,
1749         "vnd.sun.star.expand:$PREFIX/foo");
1750     bSuccess &= test_insertName(
1751         "vnd.sun.star.expand:$PREFIX", "foo", false,
1752         INetURLObject::LAST_SEGMENT, true, true,
1753         "vnd.sun.star.expand:$PREFIX/foo");
1754     bSuccess &= test_insertName(
1755         "vnd.sun.star.expand:$PREFIX", "foo", true,
1756         INetURLObject::LAST_SEGMENT, false, true,
1757         "vnd.sun.star.expand:$PREFIX/foo/");
1758     bSuccess &= test_insertName(
1759         "vnd.sun.star.expand:$PREFIX", "foo", true,
1760         INetURLObject::LAST_SEGMENT, true, true,
1761         "vnd.sun.star.expand:$PREFIX/foo/");
1762     bSuccess &= test_insertName(
1763         "vnd.sun.star.expand:$PREFIX/", "foo", false,
1764         1, false, true,
1765         "vnd.sun.star.expand:$PREFIX/foo/");
1766     bSuccess &= test_insertName(
1767         "vnd.sun.star.expand:$PREFIX/", "foo", false,
1768         1, true, true,
1769         "vnd.sun.star.expand:$PREFIX/foo");
1770     bSuccess &= test_insertName(
1771         "vnd.sun.star.expand:$PREFIX/", "foo", true,
1772         1, false, true,
1773         "vnd.sun.star.expand:$PREFIX/foo/");
1774     bSuccess &= test_insertName(
1775         "vnd.sun.star.expand:$PREFIX/", "foo", true,
1776         1, true, true,
1777         "vnd.sun.star.expand:$PREFIX/foo/");
1778     bSuccess &= test_insertName(
1779         "vnd.sun.star.expand:$PREFIX/", "foo", false,
1780         INetURLObject::LAST_SEGMENT, false, true,
1781         "vnd.sun.star.expand:$PREFIX//foo");
1782     bSuccess &= test_insertName(
1783         "vnd.sun.star.expand:$PREFIX/", "foo", false,
1784         INetURLObject::LAST_SEGMENT, true, true,
1785         "vnd.sun.star.expand:$PREFIX/foo");
1786     bSuccess &= test_insertName(
1787         "vnd.sun.star.expand:$PREFIX/", "foo", true,
1788         INetURLObject::LAST_SEGMENT, false, true,
1789         "vnd.sun.star.expand:$PREFIX//foo/");
1790     bSuccess &= test_insertName(
1791         "vnd.sun.star.expand:$PREFIX/", "foo", true,
1792         INetURLObject::LAST_SEGMENT, true, true,
1793         "vnd.sun.star.expand:$PREFIX/foo/");
1794     bSuccess &= test_insertName(
1795         "file:///", "foo", false, 0, false, true, "file:///foo/");
1796     bSuccess &= test_insertName(
1797         "file:///", "foo", false, 0, true, true, "file:///foo");
1798     bSuccess &= test_insertName(
1799         "file:///", "foo", true, 0, false, true, "file:///foo/");
1800     bSuccess &= test_insertName(
1801         "file:///", "foo", true, 0, true, true, "file:///foo/");
1802     bSuccess &= test_insertName(
1803         "file:///bar", "foo", false, 0, false, true, "file:///foo/bar");
1804     bSuccess &= test_insertName(
1805         "file:///bar", "foo", false, 0, true, true, "file:///foo/bar");
1806     bSuccess &= test_insertName(
1807         "file:///bar", "foo", true, 0, false, true, "file:///foo/bar");
1808     bSuccess &= test_insertName(
1809         "file:///bar", "foo", true, 0, true, true, "file:///foo/bar");
1810 
1811     bSuccess &= test_removeSegment("mailto:a@b", 0, false, false, "mailto:a@b");
1812     bSuccess &= test_removeSegment(
1813         "vnd.sun.star.expand:$PREFIX", 0, false, false,
1814         "vnd.sun.star.expand:$PREFIX");
1815     bSuccess &= test_removeSegment(
1816         "vnd.sun.star.expand:$PREFIX", 0, true, true,
1817         "vnd.sun.star.expand:%2F");
1818     bSuccess &= test_removeSegment(
1819         "vnd.sun.star.expand:$PREFIX", 1, false, false,
1820         "vnd.sun.star.expand:$PREFIX");
1821     bSuccess &= test_removeSegment(
1822         "vnd.sun.star.expand:$PREFIX", 1, true, false,
1823         "vnd.sun.star.expand:$PREFIX");
1824     bSuccess &= test_removeSegment(
1825         "vnd.sun.star.expand:$PREFIX", 2, false, false,
1826         "vnd.sun.star.expand:$PREFIX");
1827     bSuccess &= test_removeSegment(
1828         "vnd.sun.star.expand:$PREFIX", 2, true, false,
1829         "vnd.sun.star.expand:$PREFIX");
1830     bSuccess &= test_removeSegment(
1831         "vnd.sun.star.expand:$PREFIX", INetURLObject::LAST_SEGMENT, false,
1832         false, "vnd.sun.star.expand:$PREFIX");
1833     bSuccess &= test_removeSegment(
1834         "vnd.sun.star.expand:$PREFIX", INetURLObject::LAST_SEGMENT, true, true,
1835         "vnd.sun.star.expand:%2F");
1836     bSuccess &= test_removeSegment(
1837         "vnd.sun.star.expand:$PREFIX/", 0, false, true,
1838         "vnd.sun.star.expand:%2F");
1839     bSuccess &= test_removeSegment(
1840         "vnd.sun.star.expand:$PREFIX/", 0, true, true,
1841         "vnd.sun.star.expand:%2F");
1842     bSuccess &= test_removeSegment(
1843         "vnd.sun.star.expand:$PREFIX/", 1, false, true,
1844         "vnd.sun.star.expand:$PREFIX");
1845     bSuccess &= test_removeSegment(
1846         "vnd.sun.star.expand:$PREFIX/", 1, true, true,
1847         "vnd.sun.star.expand:$PREFIX/");
1848     bSuccess &= test_removeSegment(
1849         "vnd.sun.star.expand:$PREFIX/", 2, false, false,
1850         "vnd.sun.star.expand:$PREFIX/");
1851     bSuccess &= test_removeSegment(
1852         "vnd.sun.star.expand:$PREFIX/", 2, true, false,
1853         "vnd.sun.star.expand:$PREFIX/");
1854     bSuccess &= test_removeSegment(
1855         "vnd.sun.star.expand:$PREFIX/", INetURLObject::LAST_SEGMENT, false,
1856         true, "vnd.sun.star.expand:$PREFIX");
1857     bSuccess &= test_removeSegment(
1858         "vnd.sun.star.expand:$PREFIX/", INetURLObject::LAST_SEGMENT, true,
1859         true, "vnd.sun.star.expand:%2F");
1860     bSuccess &= test_removeSegment("file:///", 0, false, true, "file:///");
1861     bSuccess &= test_removeSegment("file:///", 0, true, true, "file:///");
1862     bSuccess &= test_removeSegment("file:///", 1, false, false, "file:///");
1863     bSuccess &= test_removeSegment("file:///", 1, true, false, "file:///");
1864     bSuccess &= test_removeSegment("file:///", 2, false, false, "file:///");
1865     bSuccess &= test_removeSegment("file:///", 2, true, false, "file:///");
1866     bSuccess &= test_removeSegment(
1867         "file:///", INetURLObject::LAST_SEGMENT, false, true, "file:///");
1868     bSuccess &= test_removeSegment(
1869         "file:///", INetURLObject::LAST_SEGMENT, true, false, "file:///");
1870     bSuccess &= test_removeSegment("file:///foo", 0, false, true, "file:///");
1871     bSuccess &= test_removeSegment("file:///foo", 0, true, true, "file:///");
1872     bSuccess &= test_removeSegment(
1873         "file:///foo", 1, false, false, "file:///foo");
1874     bSuccess &= test_removeSegment(
1875         "file:///foo", 1, true, false, "file:///foo");
1876     bSuccess &= test_removeSegment(
1877         "file:///foo", 2, false, false, "file:///foo");
1878     bSuccess &= test_removeSegment(
1879         "file:///foo", 2, true, false, "file:///foo");
1880     bSuccess &= test_removeSegment(
1881         "file:///foo", INetURLObject::LAST_SEGMENT, false, true, "file:///");
1882     bSuccess &= test_removeSegment(
1883         "file:///foo", INetURLObject::LAST_SEGMENT, true, true, "file:///");
1884     bSuccess &= test_removeSegment("file:///foo/", 0, false, true, "file:///");
1885     bSuccess &= test_removeSegment("file:///foo/", 0, true, true, "file:///");
1886     bSuccess &= test_removeSegment(
1887         "file:///foo/", 1, false, true, "file:///foo");
1888     bSuccess &= test_removeSegment(
1889         "file:///foo/", 1, true, true, "file:///foo/");
1890     bSuccess &= test_removeSegment(
1891         "file:///foo/", 2, false, false, "file:///foo/");
1892     bSuccess &= test_removeSegment(
1893         "file:///foo/", 2, true, false, "file:///foo/");
1894     bSuccess &= test_removeSegment(
1895         "file:///foo/", INetURLObject::LAST_SEGMENT, false, true,
1896         "file:///foo");
1897     bSuccess &= test_removeSegment(
1898         "file:///foo/", INetURLObject::LAST_SEGMENT, true, true, "file:///");
1899 
1900     return bSuccess ? EXIT_SUCCESS : EXIT_FAILURE;
1901 }
1902