Add test clarifying behavior of INetURLObject::setName on empty path
...as the commit message off270bd15fe"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 with359e0b47a0"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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user