diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-06-23 14:46:50 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-06-23 14:46:50 +0200 |
commit | b5091379007ddd1c736425f2d0de373ec8b4eae9 (patch) | |
tree | e10c39ce2544371e97ed6c2a9c0e46c896fc66bf /sal | |
parent | 80aafaf79306ea82cd24f10f200908addccaf34f (diff) |
Make test code unaffected by upcoming loplugin:stringconstant improvements
Change-Id: If375073001690e1ce2f8d18a3f128358f22aa98b
Diffstat (limited to 'sal')
-rw-r--r-- | sal/qa/rtl/strings/test_strings_replace.cxx | 74 |
1 files changed, 23 insertions, 51 deletions
diff --git a/sal/qa/rtl/strings/test_strings_replace.cxx b/sal/qa/rtl/strings/test_strings_replace.cxx index 2065078489ed..8976702aba5f 100644 --- a/sal/qa/rtl/strings/test_strings_replace.cxx +++ b/sal/qa/rtl/strings/test_strings_replace.cxx @@ -20,6 +20,13 @@ namespace { +OUString s_bar("bar"); +OUString s_bars("bars"); +OUString s_foo("foo"); +OUString s_other("other"); +OUString s_xx("xa"); +OUString s_xx("xx"); + class Test: public CppUnit::TestFixture { private: void stringReplaceFirst(); @@ -100,24 +107,17 @@ void Test::stringReplaceAll() { void Test::ustringReplaceFirst() { CPPUNIT_ASSERT_EQUAL( rtl::OUString("otherbarfoo"), - rtl::OUString("foobarfoo").replaceFirst( - rtl::OUString("foo"), - rtl::OUString("other"))); + rtl::OUString("foobarfoo").replaceFirst(s_foo, s_other)); CPPUNIT_ASSERT_EQUAL( rtl::OUString("foobarfoo"), - rtl::OUString("foobarfoo").replaceFirst( - rtl::OUString("bars"), - rtl::OUString("other"))); + rtl::OUString("foobarfoo").replaceFirst(s_bars, s_other)); { sal_Int32 n = 0; CPPUNIT_ASSERT_EQUAL( rtl::OUString("otherbarfoo"), - (rtl::OUString("foobarfoo"). - replaceFirst( - rtl::OUString("foo"), - rtl::OUString("other"), &n))); + rtl::OUString("foobarfoo").replaceFirst(s_foo, s_other, &n)); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), n); } @@ -125,10 +125,7 @@ void Test::ustringReplaceFirst() { sal_Int32 n = 1; CPPUNIT_ASSERT_EQUAL( rtl::OUString("foobarother"), - (rtl::OUString("foobarfoo"). - replaceFirst( - rtl::OUString("foo"), - rtl::OUString("other"), &n))); + rtl::OUString("foobarfoo").replaceFirst(s_foo, s_other, &n)); CPPUNIT_ASSERT_EQUAL(sal_Int32(6), n); } @@ -136,10 +133,7 @@ void Test::ustringReplaceFirst() { sal_Int32 n = 4; CPPUNIT_ASSERT_EQUAL( rtl::OUString("foobarfoo"), - (rtl::OUString("foobarfoo"). - replaceFirst( - rtl::OUString("bar"), - rtl::OUString("other"), &n))); + rtl::OUString("foobarfoo").replaceFirst(s_bar, s_other, &n)); CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), n); } } @@ -147,23 +141,17 @@ void Test::ustringReplaceFirst() { void Test::ustringReplaceFirstAsciiL() { CPPUNIT_ASSERT_EQUAL( rtl::OUString("otherbarfoo"), - (rtl::OUString("foobarfoo"). - replaceFirst("foo", - rtl::OUString("other")))); + rtl::OUString("foobarfoo").replaceFirst("foo", s_other)); CPPUNIT_ASSERT_EQUAL( rtl::OUString("foobarfoo"), - (rtl::OUString("foobarfoo"). - replaceFirst("bars", - rtl::OUString("other")))); + rtl::OUString("foobarfoo").replaceFirst("bars", s_other)); { sal_Int32 n = 0; CPPUNIT_ASSERT_EQUAL( rtl::OUString("otherbarfoo"), - (rtl::OUString("foobarfoo"). - replaceFirst("foo", - rtl::OUString("other"), &n))); + rtl::OUString("foobarfoo").replaceFirst("foo", s_other, &n)); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), n); } @@ -171,9 +159,7 @@ void Test::ustringReplaceFirstAsciiL() { sal_Int32 n = 1; CPPUNIT_ASSERT_EQUAL( rtl::OUString("foobarother"), - (rtl::OUString("foobarfoo"). - replaceFirst("foo", - rtl::OUString("other"), &n))); + rtl::OUString("foobarfoo").replaceFirst("foo", s_other, &n)); CPPUNIT_ASSERT_EQUAL(sal_Int32(6), n); } @@ -181,9 +167,7 @@ void Test::ustringReplaceFirstAsciiL() { sal_Int32 n = 4; CPPUNIT_ASSERT_EQUAL( rtl::OUString("foobarfoo"), - (rtl::OUString("foobarfoo"). - replaceFirst("bar", - rtl::OUString("other"), &n))); + rtl::OUString("foobarfoo").replaceFirst("bar", s_other, &n)); CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), n); } } @@ -230,41 +214,29 @@ void Test::ustringReplaceFirstAsciiLAsciiL() { void Test::ustringReplaceAll() { CPPUNIT_ASSERT_EQUAL( rtl::OUString("otherbarother"), - rtl::OUString("foobarfoo").replaceAll( - rtl::OUString("foo"), - rtl::OUString("other"))); + rtl::OUString("foobarfoo").replaceAll(s_foo, s_other)); CPPUNIT_ASSERT_EQUAL( rtl::OUString("foobarfoo"), - rtl::OUString("foobarfoo").replaceAll( - rtl::OUString("bars"), - rtl::OUString("other"))); + rtl::OUString("foobarfoo").replaceAll(s_bars, s_other)); CPPUNIT_ASSERT_EQUAL( rtl::OUString("xxa"), - rtl::OUString("xaa").replaceAll( - rtl::OUString("xa"), - rtl::OUString("xx"))); + rtl::OUString("xaa").replaceAll(s_xa, s_xx)); } void Test::ustringReplaceAllAsciiL() { CPPUNIT_ASSERT_EQUAL( rtl::OUString("otherbarother"), - (rtl::OUString("foobarfoo"). - replaceAll("foo", - rtl::OUString("other")))); + rtl::OUString("foobarfoo").replaceAll("foo", s_other)); CPPUNIT_ASSERT_EQUAL( rtl::OUString("foobarfoo"), - (rtl::OUString("foobarfoo"). - replaceAll("bars", - rtl::OUString("other")))); + rtl::OUString("foobarfoo").replaceAll("bars", s_other)); CPPUNIT_ASSERT_EQUAL( rtl::OUString("xxa"), - rtl::OUString("xaa").replaceAll( - "xa", - rtl::OUString("xx"))); + rtl::OUString("xaa").replaceAll("xa", s_xx)); } void Test::ustringReplaceAllAsciiLAsciiL() { |