diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2023-10-06 16:51:17 +0200 |
---|---|---|
committer | Stephan Bergmann <stephan.bergmann@allotropia.de> | 2024-04-28 11:29:52 +0200 |
commit | d98e014cf6d4cea7ebd7898cbc9124f6fba07684 (patch) | |
tree | 195a5e99cea2c8ec6d9bae19cb56f488d75bb6fa /svl | |
parent | 817d35eb829db00329ea5437d50e5c682139f505 (diff) |
Extended loplugin:ostr manual changes
I had done these a while ago, when I looked into extending loplugin:ostr to do
more automatic rewriting, and these were places where I needed to do something
manually, for one reason or another, because the automatic rewriting would not
pick it up correctly.
However, I got distracted, and a wholesale automatic rewrite would still run
into cases where an _ostr/_ustr instance from a library's .rodata would still be
referenced after the library has already been dlcose'd. So I never came around
to finishing all that.
But there appears to be renewed interest in (automatic) rewritings here now, so
it probably makes sense if I share this part of my work anyway.
Change-Id: I3da9d38398e4bca373cb0000a9d34b49a36ad58a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166792
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Tested-by: Jenkins
Diffstat (limited to 'svl')
-rw-r--r-- | svl/qa/unit/svl.cxx | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx index 3f3f092a5d18..28ef860ba74d 100644 --- a/svl/qa/unit/svl.cxx +++ b/svl/qa/unit/svl.cxx @@ -27,6 +27,7 @@ #include <math.h> +#include <o3tl/nonstaticstring.hxx> #include <svl/numformat.hxx> #include <svl/zforlist.hxx> #include <svl/zformat.hxx> @@ -370,9 +371,9 @@ void Test::testSharedStringPoolPurge() size_t extraCount = aPool.getCount(); // internal items such as SharedString::getEmptyString() size_t extraCountIgnoreCase = aPool.getCountIgnoreCase(); - aPool.intern("Andy"); - aPool.intern("andy"); - aPool.intern("ANDY"); + aPool.intern(o3tl::nonStaticString(u"Andy")); + aPool.intern(o3tl::nonStaticString(u"andy")); + aPool.intern(o3tl::nonStaticString(u"ANDY")); CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong string count.", 3+extraCount, aPool.getCount()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong case insensitive string count.", 1+extraCountIgnoreCase, aPool.getCountIgnoreCase()); @@ -384,10 +385,10 @@ void Test::testSharedStringPoolPurge() CPPUNIT_ASSERT_EQUAL(extraCountIgnoreCase, aPool.getCountIgnoreCase()); // Now, create string objects using optional so we can clear them - std::optional<svl::SharedString> pStr1 = aPool.intern("Andy"); - std::optional<svl::SharedString> pStr2 = aPool.intern("andy"); - std::optional<svl::SharedString> pStr3 = aPool.intern("ANDY"); - std::optional<svl::SharedString> pStr4 = aPool.intern("Bruce"); + std::optional<svl::SharedString> pStr1 = aPool.intern(o3tl::nonStaticString(u"Andy")); + std::optional<svl::SharedString> pStr2 = aPool.intern(o3tl::nonStaticString(u"andy")); + std::optional<svl::SharedString> pStr3 = aPool.intern(o3tl::nonStaticString(u"ANDY")); + std::optional<svl::SharedString> pStr4 = aPool.intern(o3tl::nonStaticString(u"Bruce")); CPPUNIT_ASSERT_EQUAL(5+extraCount, aPool.getCount()); CPPUNIT_ASSERT_EQUAL(2+extraCountIgnoreCase, aPool.getCountIgnoreCase()); @@ -430,8 +431,8 @@ void Test::testSharedStringPoolPurgeBug1() svl::SharedStringPool aPool(aSysLocale.GetCharClass()); size_t extraCount = aPool.getCount(); // internal items such as SharedString::getEmptyString() size_t extraCountIgnoreCase = aPool.getCountIgnoreCase(); - aPool.intern("Andy"); - aPool.intern("andy"); + aPool.intern(o3tl::nonStaticString(u"Andy")); + aPool.intern(o3tl::nonStaticString(u"andy")); aPool.purge(); CPPUNIT_ASSERT_EQUAL(extraCount, aPool.getCount()); CPPUNIT_ASSERT_EQUAL(extraCountIgnoreCase, aPool.getCountIgnoreCase()); |