tools/qa/cppunit/test_urlobj.cxx |   39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

New commits:
commit 17ae6c31743db72d96c5addb9abf00a7842bc433
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Fri Jun 21 13:51:56 2019 +0200
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Fri Jun 21 17:13:44 2019 +0200

    Add test clarifying behavior of INetURLObject::setName on empty path
    
    ...as the commit message of f270bd15fed87a9cb0f8dfa73b34c617d66f59c2 "Fix
    INetURLObject::setName description" observes:  "But for a hierarchical URL 
with
    an empty (i.e., just "/" in the canonic form) path, setName("foo") actually
    returns false."  (I /think/ it should work for bIgnoreFinalSlash=false, but
    which had been removed from setName with
    359e0b47a0f96ffa595a0c38a5e5318d797812fe "loplugin:unuseddefaultparams".)
    
    Change-Id: I063000625d55c589782fe855923107719709df3a
    Reviewed-on: https://gerrit.libreoffice.org/74504
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/tools/qa/cppunit/test_urlobj.cxx b/tools/qa/cppunit/test_urlobj.cxx
index 2c391fbf513d..87ce9aa77758 100644
--- a/tools/qa/cppunit/test_urlobj.cxx
+++ b/tools/qa/cppunit/test_urlobj.cxx
@@ -304,6 +304,44 @@ namespace tools_urlobj
                 
!INetURLObject("vnd.sun.star.pkg://example.org").isAnyKnownWebDAVScheme());
         }
 
+        void testSetName() {
+            {
+                INetURLObject obj("file:///");
+                bool ok = obj.setName("foo");
+                CPPUNIT_ASSERT(!ok);
+            }
+            {
+                INetURLObject obj("file:///foo");
+                bool ok = obj.setName("bar");
+                CPPUNIT_ASSERT(ok);
+                CPPUNIT_ASSERT_EQUAL(
+                    OUString("file:///bar"), 
obj.GetMainURL(INetURLObject::DecodeMechanism::NONE));
+            }
+            {
+                INetURLObject obj("file:///foo/");
+                bool ok = obj.setName("bar");
+                CPPUNIT_ASSERT(ok);
+                CPPUNIT_ASSERT_EQUAL(
+                    OUString("file:///bar/"), 
obj.GetMainURL(INetURLObject::DecodeMechanism::NONE));
+            }
+            {
+                INetURLObject obj("file:///foo/bar");
+                bool ok = obj.setName("baz");
+                CPPUNIT_ASSERT(ok);
+                CPPUNIT_ASSERT_EQUAL(
+                    OUString("file:///foo/baz"),
+                    obj.GetMainURL(INetURLObject::DecodeMechanism::NONE));
+            }
+            {
+                INetURLObject obj("file:///foo/bar/");
+                bool ok = obj.setName("baz");
+                CPPUNIT_ASSERT(ok);
+                CPPUNIT_ASSERT_EQUAL(
+                    OUString("file:///foo/baz/"),
+                    obj.GetMainURL(INetURLObject::DecodeMechanism::NONE));
+            }
+        }
+
         void testSetExtension() {
             INetURLObject obj("file:///foo/bar.baz/");
             bool ok = obj.setExtension(
@@ -330,6 +368,7 @@ namespace tools_urlobj
         CPPUNIT_TEST( urlobjTest_data );
         CPPUNIT_TEST( urlobjTest_isSchemeEqualTo );
         CPPUNIT_TEST( urlobjTest_isAnyKnownWebDAVScheme );
+        CPPUNIT_TEST( testSetName );
         CPPUNIT_TEST( testSetExtension );
         CPPUNIT_TEST_SUITE_END(  );
     };                          // class createPool
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to