[Libreoffice-commits] core.git: tools/qa

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 21 15:15:08 UTC 2019


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

New commits:
commit 17ae6c31743db72d96c5addb9abf00a7842bc433
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri Jun 21 13:51:56 2019 +0200
Commit:     Stephan Bergmann <sbergman at 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 <sbergman at 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


More information about the Libreoffice-commits mailing list