Kaydet (Commit) b5091379 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Make test code unaffected by upcoming loplugin:stringconstant improvements

Change-Id: If375073001690e1ce2f8d18a3f128358f22aa98b
üst 80aafaf7
...@@ -20,6 +20,13 @@ ...@@ -20,6 +20,13 @@
namespace { 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 { class Test: public CppUnit::TestFixture {
private: private:
void stringReplaceFirst(); void stringReplaceFirst();
...@@ -100,24 +107,17 @@ void Test::stringReplaceAll() { ...@@ -100,24 +107,17 @@ void Test::stringReplaceAll() {
void Test::ustringReplaceFirst() { void Test::ustringReplaceFirst() {
CPPUNIT_ASSERT_EQUAL( CPPUNIT_ASSERT_EQUAL(
rtl::OUString("otherbarfoo"), rtl::OUString("otherbarfoo"),
rtl::OUString("foobarfoo").replaceFirst( rtl::OUString("foobarfoo").replaceFirst(s_foo, s_other));
rtl::OUString("foo"),
rtl::OUString("other")));
CPPUNIT_ASSERT_EQUAL( CPPUNIT_ASSERT_EQUAL(
rtl::OUString("foobarfoo"), rtl::OUString("foobarfoo"),
rtl::OUString("foobarfoo").replaceFirst( rtl::OUString("foobarfoo").replaceFirst(s_bars, s_other));
rtl::OUString("bars"),
rtl::OUString("other")));
{ {
sal_Int32 n = 0; sal_Int32 n = 0;
CPPUNIT_ASSERT_EQUAL( CPPUNIT_ASSERT_EQUAL(
rtl::OUString("otherbarfoo"), rtl::OUString("otherbarfoo"),
(rtl::OUString("foobarfoo"). rtl::OUString("foobarfoo").replaceFirst(s_foo, s_other, &n));
replaceFirst(
rtl::OUString("foo"),
rtl::OUString("other"), &n)));
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), n); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), n);
} }
...@@ -125,10 +125,7 @@ void Test::ustringReplaceFirst() { ...@@ -125,10 +125,7 @@ void Test::ustringReplaceFirst() {
sal_Int32 n = 1; sal_Int32 n = 1;
CPPUNIT_ASSERT_EQUAL( CPPUNIT_ASSERT_EQUAL(
rtl::OUString("foobarother"), rtl::OUString("foobarother"),
(rtl::OUString("foobarfoo"). rtl::OUString("foobarfoo").replaceFirst(s_foo, s_other, &n));
replaceFirst(
rtl::OUString("foo"),
rtl::OUString("other"), &n)));
CPPUNIT_ASSERT_EQUAL(sal_Int32(6), n); CPPUNIT_ASSERT_EQUAL(sal_Int32(6), n);
} }
...@@ -136,10 +133,7 @@ void Test::ustringReplaceFirst() { ...@@ -136,10 +133,7 @@ void Test::ustringReplaceFirst() {
sal_Int32 n = 4; sal_Int32 n = 4;
CPPUNIT_ASSERT_EQUAL( CPPUNIT_ASSERT_EQUAL(
rtl::OUString("foobarfoo"), rtl::OUString("foobarfoo"),
(rtl::OUString("foobarfoo"). rtl::OUString("foobarfoo").replaceFirst(s_bar, s_other, &n));
replaceFirst(
rtl::OUString("bar"),
rtl::OUString("other"), &n)));
CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), n); CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), n);
} }
} }
...@@ -147,23 +141,17 @@ void Test::ustringReplaceFirst() { ...@@ -147,23 +141,17 @@ void Test::ustringReplaceFirst() {
void Test::ustringReplaceFirstAsciiL() { void Test::ustringReplaceFirstAsciiL() {
CPPUNIT_ASSERT_EQUAL( CPPUNIT_ASSERT_EQUAL(
rtl::OUString("otherbarfoo"), rtl::OUString("otherbarfoo"),
(rtl::OUString("foobarfoo"). rtl::OUString("foobarfoo").replaceFirst("foo", s_other));
replaceFirst("foo",
rtl::OUString("other"))));
CPPUNIT_ASSERT_EQUAL( CPPUNIT_ASSERT_EQUAL(
rtl::OUString("foobarfoo"), rtl::OUString("foobarfoo"),
(rtl::OUString("foobarfoo"). rtl::OUString("foobarfoo").replaceFirst("bars", s_other));
replaceFirst("bars",
rtl::OUString("other"))));
{ {
sal_Int32 n = 0; sal_Int32 n = 0;
CPPUNIT_ASSERT_EQUAL( CPPUNIT_ASSERT_EQUAL(
rtl::OUString("otherbarfoo"), rtl::OUString("otherbarfoo"),
(rtl::OUString("foobarfoo"). rtl::OUString("foobarfoo").replaceFirst("foo", s_other, &n));
replaceFirst("foo",
rtl::OUString("other"), &n)));
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), n); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), n);
} }
...@@ -171,9 +159,7 @@ void Test::ustringReplaceFirstAsciiL() { ...@@ -171,9 +159,7 @@ void Test::ustringReplaceFirstAsciiL() {
sal_Int32 n = 1; sal_Int32 n = 1;
CPPUNIT_ASSERT_EQUAL( CPPUNIT_ASSERT_EQUAL(
rtl::OUString("foobarother"), rtl::OUString("foobarother"),
(rtl::OUString("foobarfoo"). rtl::OUString("foobarfoo").replaceFirst("foo", s_other, &n));
replaceFirst("foo",
rtl::OUString("other"), &n)));
CPPUNIT_ASSERT_EQUAL(sal_Int32(6), n); CPPUNIT_ASSERT_EQUAL(sal_Int32(6), n);
} }
...@@ -181,9 +167,7 @@ void Test::ustringReplaceFirstAsciiL() { ...@@ -181,9 +167,7 @@ void Test::ustringReplaceFirstAsciiL() {
sal_Int32 n = 4; sal_Int32 n = 4;
CPPUNIT_ASSERT_EQUAL( CPPUNIT_ASSERT_EQUAL(
rtl::OUString("foobarfoo"), rtl::OUString("foobarfoo"),
(rtl::OUString("foobarfoo"). rtl::OUString("foobarfoo").replaceFirst("bar", s_other, &n));
replaceFirst("bar",
rtl::OUString("other"), &n)));
CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), n); CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), n);
} }
} }
...@@ -230,41 +214,29 @@ void Test::ustringReplaceFirstAsciiLAsciiL() { ...@@ -230,41 +214,29 @@ void Test::ustringReplaceFirstAsciiLAsciiL() {
void Test::ustringReplaceAll() { void Test::ustringReplaceAll() {
CPPUNIT_ASSERT_EQUAL( CPPUNIT_ASSERT_EQUAL(
rtl::OUString("otherbarother"), rtl::OUString("otherbarother"),
rtl::OUString("foobarfoo").replaceAll( rtl::OUString("foobarfoo").replaceAll(s_foo, s_other));
rtl::OUString("foo"),
rtl::OUString("other")));
CPPUNIT_ASSERT_EQUAL( CPPUNIT_ASSERT_EQUAL(
rtl::OUString("foobarfoo"), rtl::OUString("foobarfoo"),
rtl::OUString("foobarfoo").replaceAll( rtl::OUString("foobarfoo").replaceAll(s_bars, s_other));
rtl::OUString("bars"),
rtl::OUString("other")));
CPPUNIT_ASSERT_EQUAL( CPPUNIT_ASSERT_EQUAL(
rtl::OUString("xxa"), rtl::OUString("xxa"),
rtl::OUString("xaa").replaceAll( rtl::OUString("xaa").replaceAll(s_xa, s_xx));
rtl::OUString("xa"),
rtl::OUString("xx")));
} }
void Test::ustringReplaceAllAsciiL() { void Test::ustringReplaceAllAsciiL() {
CPPUNIT_ASSERT_EQUAL( CPPUNIT_ASSERT_EQUAL(
rtl::OUString("otherbarother"), rtl::OUString("otherbarother"),
(rtl::OUString("foobarfoo"). rtl::OUString("foobarfoo").replaceAll("foo", s_other));
replaceAll("foo",
rtl::OUString("other"))));
CPPUNIT_ASSERT_EQUAL( CPPUNIT_ASSERT_EQUAL(
rtl::OUString("foobarfoo"), rtl::OUString("foobarfoo"),
(rtl::OUString("foobarfoo"). rtl::OUString("foobarfoo").replaceAll("bars", s_other));
replaceAll("bars",
rtl::OUString("other"))));
CPPUNIT_ASSERT_EQUAL( CPPUNIT_ASSERT_EQUAL(
rtl::OUString("xxa"), rtl::OUString("xxa"),
rtl::OUString("xaa").replaceAll( rtl::OUString("xaa").replaceAll("xa", s_xx));
"xa",
rtl::OUString("xx")));
} }
void Test::ustringReplaceAllAsciiLAsciiL() { void Test::ustringReplaceAllAsciiLAsciiL() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment