summaryrefslogtreecommitdiff
path: root/sal/qa
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2023-07-21 14:20:57 +0200
committerStephan Bergmann <sbergman@redhat.com>2023-07-31 07:58:08 +0200
commit6fce450b8a66d7e98a4d39528f8591184277e9fa (patch)
treed2bde14c195b0288e7efc3f3e6db06888759855b /sal/qa
parent3564e11a41c8d3f06c8be387691d5997942e9738 (diff)
Introduce "..."_tstr as a companion to "..."_ostr/u"..."_ustr in template code
...like > *path = "/"; in > template<typename T> oslFileError getSystemPathFromFileUrl( > OUString const & url, T * path, bool resolveHome) in sal/osl/unx/file_url.cxx, where T is either OString or OUString. That can now be replaced with > *path = "/"_tstr; and for OString it will be a no-cost constexpr operation, while for OUString it will still construct the OUString instance at runtime (as did the original code for both OString and OUString). (This change required moving the definition of rtl::detail::OStringHolder around in include/rtl/string.hxx. For consistency, I similarly moved around the definition of rtl::detail::OUStringHolder in include/rtl/ustring.hxx, too.) Change-Id: I7fb3a81b438f98c609684f7e70b7a60068d32fdb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154748 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sal/qa')
-rw-r--r--sal/qa/rtl/strings/test_ostring_stringliterals.cxx3
-rw-r--r--sal/qa/rtl/strings/test_oustring_stringliterals.cxx3
2 files changed, 6 insertions, 0 deletions
diff --git a/sal/qa/rtl/strings/test_ostring_stringliterals.cxx b/sal/qa/rtl/strings/test_ostring_stringliterals.cxx
index 8cfc3a65bdde..1017106e2800 100644
--- a/sal/qa/rtl/strings/test_ostring_stringliterals.cxx
+++ b/sal/qa/rtl/strings/test_ostring_stringliterals.cxx
@@ -280,6 +280,9 @@ void test::ostring::StringLiterals::checkOstr() {
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), ""_ostr.getLength());
CPPUNIT_ASSERT_EQUAL(sal_Int32(6), "foobar"_ostr.getLength());
CPPUNIT_ASSERT_EQUAL(sal_Int32(7), "foo\0bar"_ostr.getLength());
+ CPPUNIT_ASSERT_EQUAL(""_ostr, rtl::OString(""_tstr));
+ CPPUNIT_ASSERT_EQUAL("foobar"_ostr, rtl::OString("foobar"_tstr));
+ CPPUNIT_ASSERT_EQUAL("foo\0bar"_ostr, rtl::OString("foo\0bar"_tstr));
#endif
}
diff --git a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx
index 709ddb669cc5..197f72a50fea 100644
--- a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx
+++ b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx
@@ -432,6 +432,9 @@ void test::oustring::StringLiterals::checkOstr() {
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), u""_ustr.getLength());
CPPUNIT_ASSERT_EQUAL(sal_Int32(6), u"foobar"_ustr.getLength());
CPPUNIT_ASSERT_EQUAL(sal_Int32(7), u"foo\0bar"_ustr.getLength());
+ CPPUNIT_ASSERT_EQUAL(u""_ustr, rtl::OUString(""_tstr));
+ CPPUNIT_ASSERT_EQUAL(u"foobar"_ustr, rtl::OUString("foobar"_tstr));
+ CPPUNIT_ASSERT_EQUAL(u"foo\0bar"_ustr, rtl::OUString("foo\0bar"_tstr));
#endif
}