diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-06-21 13:51:56 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-06-21 17:13:44 +0200 |
commit | 17ae6c31743db72d96c5addb9abf00a7842bc433 (patch) | |
tree | df06232b766049952adb6aa35f578398006dcbe2 | |
parent | 7ba891c85ae06c0806fe2349202da84b50ca6cbd (diff) |
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@redhat.com>
-rw-r--r-- | tools/qa/cppunit/test_urlobj.cxx | 39 |
1 files changed, 39 insertions, 0 deletions
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 |