Add test clarifying behavior of INetURLObject::setName on empty path

...as the commit message of f270bd15fe "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
359e0b47a0 "loplugin:unuseddefaultparams".)

Change-Id: I063000625d55c589782fe855923107719709df3a
Reviewed-on: https://gerrit.libreoffice.org/74504
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann
2019-06-21 17:13:44 +02:00
parent 7ba891c85a
commit 17ae6c3174
+39
View File
@@ -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