summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-01-27 16:45:22 +0100
committerStephan Bergmann <sbergman@redhat.com>2021-01-27 23:24:42 +0100
commitaa2064c5c5f23f6f4b7bc44e12345b37f66995bc (patch)
treea5073b6d0b0c5846575671975341f0e0b393d98d /sal
parent686582b4890f458b6b8ee0e1ab19d9ad64793c85 (diff)
Improve loplugin:stringliteralvar
...to also consider O[U]String ctors taking pointer and length Change-Id: Iea5041634bfbf5054a1317701e30b56f72e940fb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110025 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/qa/rtl/oustring/rtl_OUString2.cxx13
1 files changed, 7 insertions, 6 deletions
diff --git a/sal/qa/rtl/oustring/rtl_OUString2.cxx b/sal/qa/rtl/oustring/rtl_OUString2.cxx
index 516378dc14a7..0e85a066f33f 100644
--- a/sal/qa/rtl/oustring/rtl_OUString2.cxx
+++ b/sal/qa/rtl/oustring/rtl_OUString2.cxx
@@ -792,10 +792,10 @@ public:
};
void convertToString::test() {
- static sal_Unicode const utf16[] = { 0x0041, 0x00E4, 0x0061 };
+ static constexpr OUStringLiteral utf16 = u"A\u00E4a";
OString s;
CPPUNIT_ASSERT(
- OUString(utf16, SAL_N_ELEMENTS(utf16)).convertToString(
+ OUString(utf16).convertToString(
&s, RTL_TEXTENCODING_UTF7,
(RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)));
@@ -932,7 +932,8 @@ void createFromCodePoints::test() {
CPPUNIT_ASSERT_EQUAL(
sal_Int32(0),
OUString(static_cast< sal_uInt32 const * >(nullptr), 0).getLength());
- static sal_uInt32 const cp[] = { 0, 0xD800, 0xFFFF, 0x10000, 0x10FFFF };
+ sal_uInt32 cp[] = { 0, 0xD800, 0xFFFF, 0x10000, 0x10FFFF };
+ // non-const, to avoid loplugin:stringliteralvar
OUString s(cp, SAL_N_ELEMENTS(cp));
CPPUNIT_ASSERT_EQUAL(sal_Int32(7), s.getLength());
CPPUNIT_ASSERT_EQUAL(u'\0', s[0]);
@@ -954,9 +955,9 @@ public:
};
void iterateCodePoints::testNotWellFormed() {
- static sal_Unicode const utf16[] =
- { 0xD800, 0xDC00, 0x0041, 0xDBFF, 0xDFFF, 0xDDEF, 0xD9AB };
- OUString s(utf16, SAL_N_ELEMENTS(utf16));
+ static constexpr OUStringLiteral utf16 =
+ u"\U00010000A\U0010FFFF\xDDEF\xD9AB";
+ OUString s(utf16);
sal_Int32 i = 0;
CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x10000), s.iterateCodePoints(&i));
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), i);