fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / stoc / test / uriproc / test_uriproc.cxx
blobf60b687132f7deb1ea651cf122650c2cd76e0e63
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/lang/XComponent.hpp>
21 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
22 #include <com/sun/star/uno/Reference.hxx>
23 #include <com/sun/star/uno/XComponentContext.hpp>
24 #include <com/sun/star/uri/ExternalUriReferenceTranslator.hpp>
25 #include <com/sun/star/uri/UriReferenceFactory.hpp>
26 #include <com/sun/star/uri/VndSunStarPkgUrlReferenceFactory.hpp>
27 #include <com/sun/star/uri/XExternalUriReferenceTranslator.hpp>
28 #include <com/sun/star/uri/XUriReference.hpp>
29 #include <com/sun/star/uri/XUriReferenceFactory.hpp>
30 #include <com/sun/star/uri/XVndSunStarExpandUrlReference.hpp>
31 #include <com/sun/star/uri/XVndSunStarPkgUrlReferenceFactory.hpp>
32 #include <com/sun/star/uri/XVndSunStarScriptUrlReference.hpp>
33 #include <com/sun/star/util/XMacroExpander.hpp>
34 #include <cppuhelper/bootstrap.hxx>
35 #include "cppunit/TestAssert.h"
36 #include "cppunit/TestFixture.h"
37 #include "cppunit/extensions/HelperMacros.h"
38 #include "cppunit/plugin/TestPlugIn.h"
39 #include <osl/diagnose.h>
40 #include <rtl/string.h>
41 #include <rtl/string.hxx>
42 #include <rtl/textenc.h>
43 #include <rtl/ustrbuf.hxx>
44 #include <rtl/ustring.hxx>
45 #include <sal/types.h>
46 #include <sal/macros.h>
48 #include <cstdlib>
50 namespace {
52 #define TEST_ASSERT_EQUAL(token1, token2, token3, expected, actual) \
53 CPPUNIT_ASSERT_MESSAGE( \
54 createTestAssertEqualMessage( \
55 token1, token2, token3, #expected, #actual, expected, actual). \
56 getStr(), \
57 (actual) == (expected))
59 template< typename T > void append(
60 OUStringBuffer & buffer, T const & value)
62 buffer.append(value);
65 template<> void append(OUStringBuffer & buffer, bool const & value) {
66 buffer.append(static_cast< sal_Bool >(value));
69 template<> void append(OUStringBuffer & buffer, std::size_t const & value)
71 buffer.append(static_cast< sal_Int32 >(value));
74 template<> void append(OUStringBuffer & buffer, char const * const & value)
76 buffer.appendAscii(value);
79 template< typename T1, typename T2, typename T3, typename T4 >
80 OString createTestAssertEqualMessage(
81 char const * token1, T1 const & token2, T2 const & token3,
82 char const * expectedExpr, char const * actualExpr, T3 const & expected,
83 T4 const & actual)
85 OUStringBuffer buf;
86 buf.appendAscii(token1);
87 buf.append('|');
88 append(buf, token2);
89 buf.append('|');
90 append(buf, token3);
91 buf.append(": TEST_ASSERT_EQUAL(");
92 buf.appendAscii(expectedExpr);
93 buf.append(", ");
94 buf.appendAscii(actualExpr);
95 buf.append("): <");
96 append(buf, expected);
97 buf.append("> != <");
98 append(buf, actual);
99 buf.append('>');
100 return OUStringToOString(
101 buf.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US);
104 class Test: public CppUnit::TestFixture {
105 public:
106 virtual void setUp();
108 virtual void tearDown();
110 void testParse();
112 void testMakeAbsolute();
114 void testMakeRelative();
116 void testVndSunStarExpand();
118 void testVndSunStarScript();
120 void testTranslator();
122 void testPkgUrlFactory();
124 CPPUNIT_TEST_SUITE(Test);
125 CPPUNIT_TEST(testParse);
126 CPPUNIT_TEST(testMakeAbsolute);
127 CPPUNIT_TEST(testMakeRelative);
128 CPPUNIT_TEST(testVndSunStarExpand);
129 CPPUNIT_TEST(testVndSunStarScript);
130 CPPUNIT_TEST(testTranslator);
131 CPPUNIT_TEST(testPkgUrlFactory);
132 CPPUNIT_TEST_SUITE_END();
134 private:
135 css::uno::Reference< css::uno::XComponentContext > m_context;
136 css::uno::Reference< css::uri::XUriReferenceFactory > m_uriFactory;
139 void Test::setUp() {
140 m_context = cppu::defaultBootstrap_InitialComponentContext();
141 m_uriFactory = css::uri::UriReferenceFactory::create(m_context);
144 void Test::tearDown() {
145 m_uriFactory.clear();
146 css::uno::Reference< css::lang::XComponent >(
147 m_context, css::uno::UNO_QUERY_THROW)->dispose();
150 void Test::testParse() {
151 struct Data {
152 char const * uriReference;
153 char const * scheme;
154 char const * schemeSpecificPart;
155 bool isHierarchical;
156 char const * authority;
157 char const * path;
158 bool hasRelativePath;
159 sal_Int32 pathSegmentCount;
160 char const * pathSegment0;
161 char const * pathSegment1;
162 char const * pathSegment2;
163 char const * pathSegment3;
164 char const * pathSegment4;
165 char const * query;
166 char const * fragment;
168 Data data[] = {
169 { "", 0, "", true, 0,
170 "", true, 0, "", "", "", "", "", 0, 0 },
171 { "scheme:", 0, 0, false, 0,
172 0, false, 0, 0, 0, 0, 0, 0, 0, 0 },
173 { "scheme:/", "scheme", "/", true, 0,
174 "/", false, 1, "", "", "", "", "", 0, 0 },
175 { "scheme://", "scheme", "//", true, "",
176 "", false, 0, "", "", "", "", "", 0, 0 },
177 { "scheme:///", "scheme", "///", true, "",
178 "/", false, 1, "", "", "", "", "", 0, 0 },
179 { "scheme:////", "scheme", "////", true, "",
180 "//", false, 2, "", "", "", "", "", 0, 0 },
181 { "scheme:////", "scheme", "////", true, "",
182 "//", false, 2, "", "", "", "", "", 0, 0 },
183 { "scheme:#", 0, 0, false, 0,
184 0, false, 0, 0, 0, 0, 0, 0, 0, 0 },
185 { "scheme:?", "scheme", "?", false, 0,
186 "?", false, 0, "", "", "", "", "", 0, 0 },
187 { "/", 0, "/", true, 0,
188 "/", false, 1, "", "", "", "", "", 0, 0 },
189 { "//", 0, "//", true, "",
190 "", false, 0, "", "", "", "", "", 0, 0 },
191 { "///", 0, "///", true, "",
192 "/", false, 1, "", "", "", "", "", 0, 0 },
193 { "////", 0, "////", true, "",
194 "//", false, 2, "", "", "", "", "", 0, 0 } };
195 for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
196 css::uno::Reference< css::uri::XUriReference > uriRef(
197 m_uriFactory->parse(
198 OUString::createFromAscii(data[i].uriReference)));
199 CPPUNIT_ASSERT(uriRef.is() == (data[i].schemeSpecificPart != 0));
200 if (uriRef.is()) {
201 TEST_ASSERT_EQUAL(
202 "testParse", i, data[i].uriReference,
203 OUString::createFromAscii(data[i].uriReference),
204 uriRef->getUriReference());
205 TEST_ASSERT_EQUAL(
206 "testParse", i, data[i].uriReference,
207 data[i].scheme != 0, uriRef->isAbsolute());
208 TEST_ASSERT_EQUAL(
209 "testParse", i, data[i].uriReference,
210 OUString::createFromAscii(
211 data[i].scheme == 0 ? "" : data[i].scheme),
212 uriRef->getScheme());
213 TEST_ASSERT_EQUAL(
214 "testParse", i, data[i].uriReference,
215 OUString::createFromAscii(data[i].schemeSpecificPart),
216 uriRef->getSchemeSpecificPart());
217 TEST_ASSERT_EQUAL(
218 "testParse", i, data[i].uriReference,
219 data[i].isHierarchical,
220 static_cast< bool >(uriRef->isHierarchical()));
221 TEST_ASSERT_EQUAL(
222 "testParse", i, data[i].uriReference,
223 data[i].authority != 0, uriRef->hasAuthority());
224 TEST_ASSERT_EQUAL(
225 "testParse", i, data[i].uriReference,
226 OUString::createFromAscii(
227 data[i].authority == 0 ? "" : data[i].authority),
228 uriRef->getAuthority());
229 TEST_ASSERT_EQUAL(
230 "testParse", i, data[i].uriReference,
231 OUString::createFromAscii(data[i].path),
232 uriRef->getPath());
233 TEST_ASSERT_EQUAL(
234 "testParse", i, data[i].uriReference,
235 data[i].hasRelativePath,
236 static_cast< bool >(uriRef->hasRelativePath()));
237 TEST_ASSERT_EQUAL(
238 "testParse", i, data[i].uriReference,
239 data[i].pathSegmentCount, uriRef->getPathSegmentCount());
240 TEST_ASSERT_EQUAL(
241 "testParse", i, data[i].uriReference,
242 OUString(""), uriRef->getPathSegment(-1));
243 TEST_ASSERT_EQUAL(
244 "testParse", i, data[i].uriReference,
245 OUString::createFromAscii(data[i].pathSegment0),
246 uriRef->getPathSegment(0));
247 TEST_ASSERT_EQUAL(
248 "testParse", i, data[i].uriReference,
249 OUString::createFromAscii(data[i].pathSegment1),
250 uriRef->getPathSegment(1));
251 TEST_ASSERT_EQUAL(
252 "testParse", i, data[i].uriReference,
253 OUString::createFromAscii(data[i].pathSegment2),
254 uriRef->getPathSegment(2));
255 TEST_ASSERT_EQUAL(
256 "testParse", i, data[i].uriReference,
257 OUString::createFromAscii(data[i].pathSegment3),
258 uriRef->getPathSegment(3));
259 TEST_ASSERT_EQUAL(
260 "testParse", i, data[i].uriReference,
261 OUString::createFromAscii(data[i].pathSegment4),
262 uriRef->getPathSegment(4));
263 TEST_ASSERT_EQUAL(
264 "testParse", i, data[i].uriReference,
265 OUString(), uriRef->getPathSegment(5));
266 TEST_ASSERT_EQUAL(
267 "testParse", i, data[i].uriReference,
268 data[i].query != 0, uriRef->hasQuery());
269 TEST_ASSERT_EQUAL(
270 "testParse", i, data[i].uriReference,
271 OUString::createFromAscii(
272 data[i].query == 0 ? "" : data[i].query),
273 uriRef->getQuery());
274 TEST_ASSERT_EQUAL(
275 "testParse", i, data[i].uriReference,
276 data[i].fragment != 0, uriRef->hasFragment());
277 TEST_ASSERT_EQUAL(
278 "testParse", i, data[i].uriReference,
279 OUString::createFromAscii(
280 data[i].fragment == 0 ? "" : data[i].fragment),
281 uriRef->getFragment());
286 void Test::testMakeAbsolute() {
287 struct Data {
288 char const * baseUriReference;
289 char const * uriReference;
290 bool processSpecialBaseSegments;
291 css::uri::RelativeUriExcessParentSegments excessParentSegments;
292 char const * absolute;
294 Data data[] = {
295 // The following tests are taken from RFC 2396, Appendix C:
296 { "http://a/b/c/d;p?q", "g:h", true,
297 css::uri::RelativeUriExcessParentSegments_ERROR, "g:h" },
298 { "http://a/b/c/d;p?q", "g", true,
299 css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/g" },
300 { "http://a/b/c/d;p?q", "./g", true,
301 css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/g" },
302 { "http://a/b/c/d;p?q", "g/", true,
303 css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/g/" },
304 { "http://a/b/c/d;p?q", "//g", true,
305 css::uri::RelativeUriExcessParentSegments_ERROR, "http://g" },
306 { "http://a/b/c/d;p?q", "?y", true,
307 css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/?y" },
308 { "http://a/b/c/d;p?q", "g?y", true,
309 css::uri::RelativeUriExcessParentSegments_ERROR,
310 "http://a/b/c/g?y" },
311 { "http://a/b/c/d;p?q", "#s", true,
312 css::uri::RelativeUriExcessParentSegments_ERROR,
313 "http://a/b/c/d;p?q#s" },
314 { "http://a/b/c/d;p?q", "g#s", true,
315 css::uri::RelativeUriExcessParentSegments_ERROR,
316 "http://a/b/c/g#s" },
317 { "http://a/b/c/d;p?q", "g?y#s", true,
318 css::uri::RelativeUriExcessParentSegments_ERROR,
319 "http://a/b/c/g?y#s" },
320 { "http://a/b/c/d;p?q", ";x", true,
321 css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/;x" },
322 { "http://a/b/c/d;p?q", "g;x", true,
323 css::uri::RelativeUriExcessParentSegments_ERROR,
324 "http://a/b/c/g;x" },
325 { "http://a/b/c/d;p?q", "g;x?y#s", true,
326 css::uri::RelativeUriExcessParentSegments_ERROR,
327 "http://a/b/c/g;x?y#s" },
328 { "http://a/b/c/d;p?q", ".", true,
329 css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/" },
330 { "http://a/b/c/d;p?q", "./", true,
331 css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/" },
332 { "http://a/b/c/d;p?q", "..", true,
333 css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/" },
334 { "http://a/b/c/d;p?q", "../", true,
335 css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/" },
336 { "http://a/b/c/d;p?q", "../g", true,
337 css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/g" },
338 { "http://a/b/c/d;p?q", "../..", true,
339 css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/" },
340 { "http://a/b/c/d;p?q", "../../", true,
341 css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/" },
342 { "http://a/b/c/d;p?q", "../../g", true,
343 css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/g" },
344 { "http://a/b/c/d;p?q", "", true,
345 css::uri::RelativeUriExcessParentSegments_ERROR,
346 "http://a/b/c/d;p?q" },
347 { "http://a/b/c/d;p?q", "../../../g", true,
348 css::uri::RelativeUriExcessParentSegments_ERROR, 0 },
349 { "http://a/b/c/d;p?q", "../../../g", true,
350 css::uri::RelativeUriExcessParentSegments_RETAIN, "http://a/../g" },
351 { "http://a/b/c/d;p?q", "../../../g", true,
352 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/g" },
353 { "http://a/b/c/d;p?q", "../../../../g", true,
354 css::uri::RelativeUriExcessParentSegments_ERROR, 0 },
355 { "http://a/b/c/d;p?q", "../../../../g", true,
356 css::uri::RelativeUriExcessParentSegments_RETAIN,
357 "http://a/../../g" },
358 { "http://a/b/c/d;p?q", "../../../../g", true,
359 css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/g" },
360 { "http://a/b/c/d;p?q", "/./g", true,
361 css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/./g" },
362 { "http://a/b/c/d;p?q", "/../g", true,
363 css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/../g" },
364 { "http://a/b/c/d;p?q", "g.", true,
365 css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/g." },
366 { "http://a/b/c/d;p?q", ".g", true,
367 css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/.g" },
368 { "http://a/b/c/d;p?q", "g..", true,
369 css::uri::RelativeUriExcessParentSegments_ERROR,
370 "http://a/b/c/g.." },
371 { "http://a/b/c/d;p?q", "..g", true,
372 css::uri::RelativeUriExcessParentSegments_ERROR,
373 "http://a/b/c/..g" },
374 { "http://a/b/c/d;p?q", "./../g", true,
375 css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/g" },
376 { "http://a/b/c/d;p?q", "./g/.", true,
377 css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/g/" },
378 { "http://a/b/c/d;p?q", "g/./h", true,
379 css::uri::RelativeUriExcessParentSegments_ERROR,
380 "http://a/b/c/g/h" },
381 { "http://a/b/c/d;p?q", "g/../h", true,
382 css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/h" },
383 { "http://a/b/c/d;p?q", "g;x=1/./y", true,
384 css::uri::RelativeUriExcessParentSegments_ERROR,
385 "http://a/b/c/g;x=1/y" },
386 { "http://a/b/c/d;p?q", "g;x=1/../y", true,
387 css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/y" },
388 { "http://a/b/c/d;p?q", "g?y/./x", true,
389 css::uri::RelativeUriExcessParentSegments_ERROR,
390 "http://a/b/c/g?y/./x" },
391 { "http://a/b/c/d;p?q", "g?y/../x", true,
392 css::uri::RelativeUriExcessParentSegments_ERROR,
393 "http://a/b/c/g?y/../x" },
394 { "http://a/b/c/d;p?q", "g#s/./x", true,
395 css::uri::RelativeUriExcessParentSegments_ERROR,
396 "http://a/b/c/g#s/./x" },
397 { "http://a/b/c/d;p?q", "g#s/../x", true,
398 css::uri::RelativeUriExcessParentSegments_ERROR,
399 "http://a/b/c/g#s/../x" },
400 { "http.://a/b/c/d;p?q", "http.:g", true,
401 css::uri::RelativeUriExcessParentSegments_ERROR, "http.:g" },
403 { "scheme://a", "", true,
404 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
405 { "scheme://a", ".", true,
406 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
407 { "scheme://a", "./", true,
408 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
409 { "scheme://a", "./.", true,
410 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
411 { "scheme://a", "././", true,
412 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
413 { "scheme://a", "././.", true,
414 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
415 { "scheme://a", "x/..", true,
416 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
417 { "scheme://a", "x/../", true,
418 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
419 { "scheme://a", "x/../.", true,
420 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
421 { "scheme://a", "x/.././", true,
422 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
423 { "scheme://a", "x/.././.", true,
424 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
425 { "scheme://a", "x/../././", true,
426 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
427 { "scheme://a", "x/../././.", true,
428 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
429 { "scheme://a", "./x/..", true,
430 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
431 { "scheme://a", "././x/..", true,
432 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
433 { "scheme://a", "./././x/..", true,
434 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
435 { "scheme://a", "./x/../.", true,
436 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
437 { "scheme://a", "./x/.././", true,
438 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
439 { "scheme://a", "././x/.././.", true,
440 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
441 { "scheme://a", "././x/../././", true,
442 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
443 { "scheme://a", "./././x/../././.", true,
444 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
446 { "scheme://a/", "", true,
447 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
448 { "scheme://a/", ".", true,
449 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
450 { "scheme://a/", "./", true,
451 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
452 { "scheme://a/", "./.", true,
453 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
454 { "scheme://a/", "././", true,
455 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
456 { "scheme://a/", "././.", true,
457 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
458 { "scheme://a/", "x/..", true,
459 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
460 { "scheme://a/", "x/../", true,
461 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
462 { "scheme://a/", "x/../.", true,
463 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
464 { "scheme://a/", "x/.././", true,
465 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
466 { "scheme://a/", "x/.././.", true,
467 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
468 { "scheme://a/", "x/../././", true,
469 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
470 { "scheme://a/", "x/../././.", true,
471 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
472 { "scheme://a/", "./x/..", true,
473 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
474 { "scheme://a/", "././x/..", true,
475 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
476 { "scheme://a/", "./././x/..", true,
477 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
478 { "scheme://a/", "./x/../.", true,
479 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
480 { "scheme://a/", "./x/.././", true,
481 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
482 { "scheme://a/", "././x/.././.", true,
483 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
484 { "scheme://a/", "././x/../././", true,
485 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
486 { "scheme://a/", "./././x/../././.", true,
487 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
489 { "scheme://a/b", "", true,
490 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b" },
491 { "scheme://a/b", ".", true,
492 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
493 { "scheme://a/b", "./", true,
494 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
495 { "scheme://a/b", "./.", true,
496 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
497 { "scheme://a/b", "././", true,
498 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
499 { "scheme://a/b", "././.", true,
500 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
501 { "scheme://a/b", "x/..", true,
502 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
503 { "scheme://a/b", "x/../", true,
504 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
505 { "scheme://a/b", "x/../.", true,
506 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
507 { "scheme://a/b", "x/.././", true,
508 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
509 { "scheme://a/b", "x/.././.", true,
510 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
511 { "scheme://a/b", "x/../././", true,
512 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
513 { "scheme://a/b", "x/../././.", true,
514 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
515 { "scheme://a/b", "./x/..", true,
516 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
517 { "scheme://a/b", "././x/..", true,
518 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
519 { "scheme://a/b", "./././x/..", true,
520 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
521 { "scheme://a/b", "./x/../.", true,
522 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
523 { "scheme://a/b", "./x/.././", true,
524 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
525 { "scheme://a/b", "././x/.././.", true,
526 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
527 { "scheme://a/b", "././x/../././", true,
528 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
529 { "scheme://a/b", "./././x/../././.", true,
530 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
532 { "scheme://a/b/", "", true,
533 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
534 { "scheme://a/b/", ".", true,
535 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
536 { "scheme://a/b/", "./", true,
537 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
538 { "scheme://a/b/", "./.", true,
539 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
540 { "scheme://a/b/", "././", true,
541 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
542 { "scheme://a/b/", "././.", true,
543 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
544 { "scheme://a/b/", "x/..", true,
545 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
546 { "scheme://a/b/", "x/../", true,
547 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
548 { "scheme://a/b/", "x/../.", true,
549 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
550 { "scheme://a/b/", "x/.././", true,
551 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
552 { "scheme://a/b/", "x/.././.", true,
553 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
554 { "scheme://a/b/", "x/../././", true,
555 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
556 { "scheme://a/b/", "x/../././.", true,
557 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
558 { "scheme://a/b/", "./x/..", true,
559 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
560 { "scheme://a/b/", "././x/..", true,
561 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
562 { "scheme://a/b/", "./././x/..", true,
563 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
564 { "scheme://a/b/", "./x/../.", true,
565 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
566 { "scheme://a/b/", "./x/.././", true,
567 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
568 { "scheme://a/b/", "././x/.././.", true,
569 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
570 { "scheme://a/b/", "././x/../././", true,
571 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
572 { "scheme://a/b/", "./././x/../././.", true,
573 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
575 { "scheme://a#s", "", true,
576 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
577 { "scheme://a", "?q", true,
578 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a?q" },
579 { "scheme://a#s", "?q", true,
580 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a?q" },
581 { "scheme://a", "#s", true,
582 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a#s" },
583 { "scheme://a#s1", "#s2", true,
584 css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a#s2" } };
585 for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
586 css::uno::Reference< css::uri::XUriReference > baseUriRef(
587 m_uriFactory->parse(
588 OUString::createFromAscii(data[i].baseUriReference)));
589 CPPUNIT_ASSERT(baseUriRef.is());
590 css::uno::Reference< css::uri::XUriReference > uriRef(
591 m_uriFactory->parse(
592 OUString::createFromAscii(data[i].uriReference)));
593 CPPUNIT_ASSERT(uriRef.is());
594 css::uno::Reference< css::uri::XUriReference > absolute(
595 m_uriFactory->makeAbsolute(
596 baseUriRef, uriRef, data[i].processSpecialBaseSegments,
597 data[i].excessParentSegments));
598 TEST_ASSERT_EQUAL(
599 "testMakeAbsolute", i, data[i].uriReference,
600 data[i].absolute != 0, absolute.is());
601 if (absolute.is()) {
602 TEST_ASSERT_EQUAL(
603 "testMakeAbsolute", i, data[i].uriReference,
604 OUString::createFromAscii(data[i].absolute),
605 absolute->getUriReference());
610 void Test::testMakeRelative() {
611 struct Data {
612 char const * baseUriReference;
613 char const * uriReference;
614 bool preferAuthorityOverRelativePath;
615 bool preferAbsoluteOverRelativePath;
616 bool encodeRetainedSpecialSegments;
617 char const * relative;
618 char const * absolute;
620 Data data[] = {
621 { "scheme1://a/b/c", "scheme2://a/b/c?q#s", true, true, false,
622 "scheme2://a/b/c?q#s", 0 },
623 { "scheme://a/b/c", "scheme:a/b/c?q#s", true, true, false,
624 "scheme:a/b/c?q#s", 0 },
625 { "scheme://a/b/c", "", true, true, false, "", "scheme://a/b/c" },
626 { "scheme://a/b/c", "//d/e/f", true, true, false, "//d/e/f",
627 "scheme://d/e/f" },
628 { "scheme://a/b/c", "./e?q#s", true, true, false, "./e?q#s",
629 "scheme://a/b/e?q#s" },
630 { "scheme://a/b", "scheme://a?q", true, true, false, "/?q",
631 "scheme://a/?q" },
632 { "scheme://a/b", "scheme://a?q", true, false, false, "?q",
633 "scheme://a/?q" },
634 { "scheme://a", "scheme://a?q", true, true, false, "?q", 0 },
635 { "scheme://a/", "scheme://a?q", true, true, false, "?q",
636 "scheme://a/?q" },
637 { "scheme://a", "scheme://a/?q", true, true, false, "?q",
638 "scheme://a?q" },
639 { "scheme://a/", "scheme://a/?q", true, true, false, "?q",
640 "scheme://a/?q" },
641 { "scheme://a?q", "scheme://a?q", true, true, false, "", 0 },
642 { "scheme://a/?q", "scheme://a?q", true, true, false, "",
643 "scheme://a/?q" },
644 { "scheme://a?q", "scheme://a/?q", true, true, false, "",
645 "scheme://a?q" },
646 { "scheme://a/?q", "scheme://a/?q", true, true, false, "", 0 },
647 { "scheme://a/b/c/d", "scheme://a//", true, true, false, "//a//", 0 },
648 { "scheme://a/b/c/d", "scheme://a//", false, true, false, "../..//",
649 0 },
650 { "scheme://a/b/c/d", "scheme://a//", true, false, false, "../..//",
651 0 },
652 { "scheme://a/b/c/d", "scheme://a//", false, false, false, "../..//",
653 0 },
654 { "scheme://a/b/c/d", "scheme://a/e", true, true, false, "/e", 0 },
655 { "scheme://a/b/c/d", "scheme://a/e", true, false, false, "../../e",
656 0 },
657 { "scheme://a/b/c/d/e", "scheme://a/b/f", true, true, false, "../../f",
658 0 },
659 { "scheme://a/b/c/d/e", "scheme://a/b", true, true, false, "/b", 0 },
660 { "scheme://a/b/c/d/e", "scheme://a/b", true, false, false,
661 "../../../b", 0 },
662 { "scheme://a/b/c/d/e", "scheme://a/b/", true, true, false, "../..",
663 0 },
664 { "scheme://a/b/c/d/e", "scheme://a/b/c", true, true, false, "../../c",
665 0 },
666 { "scheme://a/b/c/d/e", "scheme://a/b/c/", true, true, false, "..", 0 },
667 { "scheme://a/b/", "scheme://a/b/c/d", true, true, false, "c/d", 0 },
668 { "scheme://a/b/", "scheme://a/b/c/d/", true, true, false, "c/d/", 0 },
669 { "scheme://a/b/c", "scheme://a/b//", true, true, false, ".//", 0 },
670 { "scheme://a/b/c", "scheme://a/b//d", true, true, false, ".//d", 0 },
671 { "scheme://a/b/c", "scheme://a/b//d//", true, true, false, ".//d//",
672 0 },
673 { "scheme://a/b/c", "scheme://a/b/d+:", true, true, false, "./d+:", 0 },
674 { "scheme://a/b/c", "scheme://a/b/+d:", true, true, false, "+d:", 0 },
675 { "scheme://a/b/c", "scheme://a/b/d#e:f", true, true, false, "d#e:f",
676 0 },
677 { "scheme://a/b/c/", "scheme://a/b/../d/.e/.", true, true, false,
678 "../../d/.e/.",
679 "scheme://a/d/.e/" },
680 { "scheme://a/b/c/", "scheme://a/b/../d/.e/.", true, true, true,
681 "../%2E%2E/d/.e/%2E", "scheme://a/b/%2E%2E/d/.e/%2E" },
682 { "scheme://auth/a/b", "scheme://auth//c/d", true, true, false,
683 "//auth//c/d", 0 },
684 { "scheme://auth/a/b", "scheme://auth//c/d", false, true, false,
685 "..//c/d", 0 },
686 { "scheme://auth/a/b", "scheme://auth/c/d", true, true, false, "/c/d",
687 0 },
688 { "scheme://auth/a/b", "scheme://auth/c/d", true, false, false,
689 "../c/d", 0 } };
690 for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
691 css::uno::Reference< css::uri::XUriReference > baseUriRef(
692 m_uriFactory->parse(
693 OUString::createFromAscii(data[i].baseUriReference)));
694 CPPUNIT_ASSERT(baseUriRef.is());
695 css::uno::Reference< css::uri::XUriReference > uriRef(
696 m_uriFactory->parse(
697 OUString::createFromAscii(data[i].uriReference)));
698 CPPUNIT_ASSERT(uriRef.is());
699 css::uno::Reference< css::uri::XUriReference > relative(
700 m_uriFactory->makeRelative(
701 baseUriRef, uriRef, data[i].preferAuthorityOverRelativePath,
702 data[i].preferAbsoluteOverRelativePath,
703 data[i].encodeRetainedSpecialSegments));
704 TEST_ASSERT_EQUAL(
705 "testMakeRelative", i, data[i].uriReference,
706 data[i].relative != 0, relative.is());
707 if (relative.is()) {
708 TEST_ASSERT_EQUAL(
709 "testMakeRelative", i, data[i].uriReference,
710 OUString::createFromAscii(data[i].relative),
711 relative->getUriReference());
712 css::uno::Reference< css::uri::XUriReference > absolute(
713 m_uriFactory->makeAbsolute(
714 baseUriRef, relative, true,
715 css::uri::RelativeUriExcessParentSegments_ERROR));
716 CPPUNIT_ASSERT(absolute.is());
717 TEST_ASSERT_EQUAL(
718 "testMakeRelative", i, data[i].uriReference,
719 OUString::createFromAscii(
720 data[i].absolute == 0
721 ? data[i].uriReference : data[i].absolute),
722 absolute->getUriReference());
727 void Test::testVndSunStarExpand() {
728 struct Data {
729 char const * uriReference;
730 char const * expanded;
732 Data data[] = {
733 { "vnd.sun.star.expand:", "" }, // liberally accepted
734 { "vnd.sun.star.expand:/", "/" }, // liberally accepted
735 { "vnd.sun.star.expand:%80", 0 },
736 { "vnd.sun.star.expand:%5C$%5C%24%5C%5C", "$$\\" } };
737 css::uno::Reference< css::util::XMacroExpander > expander(
738 m_context->getValueByName(
739 OUString( "/singletons/com.sun.star.util.theMacroExpander")),
740 css::uno::UNO_QUERY_THROW);
741 for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
742 css::uno::Reference< css::uri::XUriReference > uriRef(
743 m_uriFactory->parse(
744 OUString::createFromAscii(data[i].uriReference)));
745 TEST_ASSERT_EQUAL(
746 "testVndSunStarExpand", i, data[i].uriReference,
747 data[i].expanded != 0, uriRef.is());
748 if (uriRef.is()) {
749 css::uno::Reference< css::uri::XVndSunStarExpandUrlReference >
750 expandUrl(uriRef, css::uno::UNO_QUERY_THROW);
751 TEST_ASSERT_EQUAL(
752 "testVndSunStarExpand", i, data[i].uriReference,
753 OUString::createFromAscii(data[i].expanded),
754 expandUrl->expand(expander));
759 void Test::testVndSunStarScript() {
760 struct Parameter {
761 char const * key;
762 char const * value;
764 std::size_t const parameterCount = 3;
765 struct Data {
766 char const * uriReference;
767 char const * name;
768 const bool normalized;
769 Parameter parameters[parameterCount];
771 Data data[] = {
772 { "vnd.sun.star.script:", 0, false, {} },
773 { "vnd.sun.star.script:/", 0, false, {} },
774 { "vnd.sun.star.script:/abc/def?ghi=jkl&mno=pqr", 0, false, {} },
775 { "vnd.sun.star.script:abc%3fdef/ghi", "abc?def/ghi", false, {} },
776 { "vnd.sun.star.script:name?a", 0, false, {} },
777 { "vnd.sun.star.script:name?a=", "name", true, { { "a", "" }, { "A", 0 } } },
778 { "vnd.sun.star.script:name?a=&", 0, true, {} },
779 { "vnd.sun.star.script:name?key1=&%26=%3D&key1=hello", "name", true,
780 { { "key1", "" }, { "key2", 0 }, { "&", "=" } } } };
781 for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
782 css::uno::Reference< css::uri::XUriReference > uriRef(
783 m_uriFactory->parse(
784 OUString::createFromAscii(data[i].uriReference)));
785 TEST_ASSERT_EQUAL(
786 "testVndSunStarScript", i, data[i].uriReference, data[i].name != 0,
787 uriRef.is());
788 if (uriRef.is()) {
789 css::uno::Reference< css::uri::XVndSunStarScriptUrlReference >
790 scriptUrl(uriRef, css::uno::UNO_QUERY_THROW);
791 TEST_ASSERT_EQUAL(
792 "testVndSunStarScript", i, data[i].uriReference,
793 OUString::createFromAscii(data[i].uriReference),
794 scriptUrl->getUriReference());
795 TEST_ASSERT_EQUAL(
796 "testVndSunStarScript", i, data[i].uriReference,
797 OUString::createFromAscii(data[i].name),
798 scriptUrl->getName());
799 OUString originalReference(uriRef->getUriReference());
800 for (std::size_t j = 0; j < parameterCount; ++j) {
801 if (data[i].parameters[j].key != 0) {
802 TEST_ASSERT_EQUAL(
803 "testVndSunStarScript",
804 static_cast< double >(i)
805 + static_cast< double >(j) / 10.0,
806 data[i].uriReference,
807 data[i].parameters[j].value != 0,
808 scriptUrl->hasParameter(
809 OUString::createFromAscii(
810 data[i].parameters[j].key)));
811 TEST_ASSERT_EQUAL(
812 "testVndSunStarScript",
813 static_cast< double >(i)
814 + static_cast< double >(j) / 10.0,
815 data[i].uriReference,
816 OUString::createFromAscii(
817 data[i].parameters[j].value),
818 scriptUrl->getParameter(
819 OUString::createFromAscii(
820 data[i].parameters[j].key)));
822 // setting the parameter to its original value should not change
823 // the overall uri reference (provided it was normalized before)
824 if ( data[i].normalized ) {
825 if ( scriptUrl->hasParameter(OUString::createFromAscii(
826 data[i].parameters[j].key)) ) {
827 scriptUrl->setParameter(
828 OUString::createFromAscii(
829 data[i].parameters[j].key),
830 scriptUrl->getParameter(
831 OUString::createFromAscii(
832 data[i].parameters[j].key)));
833 TEST_ASSERT_EQUAL(
834 "testVndSunStarScript",
835 static_cast< double >(i)
836 + static_cast< double >(j) / 10.0,
837 OUString("setParameter"),
838 originalReference,
839 uriRef->getUriReference());
844 if ( data[i].normalized ) {
845 scriptUrl->setName(scriptUrl->getName());
846 TEST_ASSERT_EQUAL(
847 "testVndSunStarScript",
849 OUString("setName"),
850 originalReference,
851 uriRef->getUriReference());
856 css::uno::Reference< css::uri::XUriReference > uriRef(
857 m_uriFactory->parse(
858 OUString( "vnd.sun.star.script:Hello?location=Library.Module")),
859 css::uno::UNO_SET_THROW);
860 css::uno::Reference< css::uri::XVndSunStarScriptUrlReference >
861 scriptUrl(uriRef, css::uno::UNO_QUERY_THROW);
863 scriptUrl->setParameter(
864 OUString("location"),
865 OUString("foo"));
866 TEST_ASSERT_EQUAL(
867 "testVndSunStarScript", (sal_Int32)10, (sal_Int32)1,
868 uriRef->getUriReference(),
869 OUString("vnd.sun.star.script:Hello?location=foo"));
871 scriptUrl->setParameter(
872 OUString("language"),
873 OUString("StarBasic"));
874 TEST_ASSERT_EQUAL(
875 "testVndSunStarScript", (sal_Int32)10, (sal_Int32)2,
876 uriRef->getUriReference(),
877 OUString("vnd.sun.star.script:Hello?location=foo&language=StarBasic"));
880 bool caughtExpected = false;
881 try {
882 scriptUrl->setName(OUString());
884 catch( const css::lang::IllegalArgumentException& ) {
885 caughtExpected = true;
887 TEST_ASSERT_EQUAL(
888 "testVndSunStarScript",
889 OUString("illegal arguments"),
890 OUString("name"),
891 caughtExpected,
892 true);
894 caughtExpected = false;
895 try {
896 scriptUrl->setParameter(
897 OUString(),
898 OUString("non-empty"));
900 catch( const css::lang::IllegalArgumentException& ) {
901 caughtExpected = true;
903 TEST_ASSERT_EQUAL(
904 "testVndSunStarScript",
905 OUString("illegal arguments"),
906 OUString("parameter"),
907 caughtExpected,
908 true);
911 void Test::testTranslator() {
912 struct Data {
913 char const * externalUriReference;
914 char const * internalUriReference;
915 bool toInternal;
917 Data data[] = {
918 { "", "", true },
919 { "#fragment", "#fragment", true },
920 { "segment/segment?query#fragment", "segment/segment?query#fragment",
921 true },
922 { "/segment/segment?query#fragment", "/segment/segment?query#fragment",
923 true },
924 { "//authority/segment?query#fragment",
925 "//authority/segment?query#fragment", true },
926 { "foo:bar#fragment", "foo:bar#fragment", true },
927 { "file:///abc/def", "file:///abc/def", true },
928 { "file:///abc/%FEef", "file:///abc/%feef", false },
929 { "file:///abc/%80%80ef", "file:///abc/%80%80ef", false },
930 { "file:///abc/%ED%A0%80%ED%B0%80ef",
931 "file:///abc/%ED%A0%80%ED%B0%80ef", false },
932 { "file:///abc/%25.ef", "file:///abc/%.ef", false },
933 { "file:///abc/%25ef", "file:///abc/%25ef", true } };
934 css::uno::Reference< css::uri::XExternalUriReferenceTranslator >
935 translator(css::uri::ExternalUriReferenceTranslator::create(m_context));
936 for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
937 if (data[i].toInternal) {
938 TEST_ASSERT_EQUAL(
939 "testTranslator, translateToInternal", i,
940 data[i].externalUriReference,
941 OUString::createFromAscii(data[i].internalUriReference),
942 translator->translateToInternal(
943 OUString::createFromAscii(
944 data[i].externalUriReference)));
946 TEST_ASSERT_EQUAL(
947 "testTranslator, translateToExternal", i,
948 data[i].internalUriReference,
949 OUString::createFromAscii(data[i].externalUriReference),
950 translator->translateToExternal(
951 OUString::createFromAscii(data[i].internalUriReference)));
955 void Test::testPkgUrlFactory() {
956 struct Data {
957 char const * authority;
958 char const * result;
960 Data data[] = {
961 { "a/b/c", 0 },
962 { "file:///#foo", 0 },
963 { "file:///a%25b%2fc/d~e&f@g?h",
964 "vnd.sun.star.pkg://file:%2F%2F%2Fa%2525b%252fc%2Fd~e&f@g%3Fh" } };
965 css::uno::Reference< css::uri::XVndSunStarPkgUrlReferenceFactory > factory(
966 css::uri::VndSunStarPkgUrlReferenceFactory::create(m_context));
967 for (std::size_t i = 0; i < SAL_N_ELEMENTS(data); ++i) {
968 css::uno::Reference< css::uri::XUriReference > url(
969 factory->createVndSunStarPkgUrlReference(
970 m_uriFactory->parse(
971 OUString::createFromAscii(data[i].authority))));
972 TEST_ASSERT_EQUAL(
973 "testVndSunStarPkgFactory", i, data[i].authority,
974 data[i].result != 0, static_cast< bool >(url.is()));
975 if (data[i].result != 0) {
976 TEST_ASSERT_EQUAL(
977 "testVndSunStarPkgFactory", i, data[i].authority,
978 OUString::createFromAscii(data[i].result),
979 url->getUriReference());
984 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
988 CPPUNIT_PLUGIN_IMPLEMENT();
990 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */