diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-06-23 14:53:56 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-06-23 14:53:56 +0200 |
commit | fd7889a9cfb601df65670dcdce8c4c2c2450f47c (patch) | |
tree | 771d97562d4023e975effbe3cae30a1ca204ef73 /sal/qa | |
parent | 0f03d20011c31e36823ca5260e1840593d6949a1 (diff) |
Implement full set of OUString::replaceFirst/All literal overloads
Change-Id: I5f525d91ce24d1d2653a6855f1c4fffc039ae398
Diffstat (limited to 'sal/qa')
-rw-r--r-- | sal/qa/rtl/strings/test_strings_replace.cxx | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/sal/qa/rtl/strings/test_strings_replace.cxx b/sal/qa/rtl/strings/test_strings_replace.cxx index 999df825a53a..0d47c3e6f4c5 100644 --- a/sal/qa/rtl/strings/test_strings_replace.cxx +++ b/sal/qa/rtl/strings/test_strings_replace.cxx @@ -37,12 +37,16 @@ private: void ustringReplaceFirstAsciiL(); + void ustringReplaceFirstToAsciiL(); + void ustringReplaceFirstAsciiLAsciiL(); void ustringReplaceAll(); void ustringReplaceAllAsciiL(); + void ustringReplaceAllToAsciiL(); + void ustringReplaceAllAsciiLAsciiL(); CPPUNIT_TEST_SUITE(Test); @@ -50,9 +54,11 @@ private: CPPUNIT_TEST(stringReplaceAll); CPPUNIT_TEST(ustringReplaceFirst); CPPUNIT_TEST(ustringReplaceFirstAsciiL); + CPPUNIT_TEST(ustringReplaceFirstToAsciiL); CPPUNIT_TEST(ustringReplaceFirstAsciiLAsciiL); CPPUNIT_TEST(ustringReplaceAll); CPPUNIT_TEST(ustringReplaceAllAsciiL); + CPPUNIT_TEST(ustringReplaceAllToAsciiL); CPPUNIT_TEST(ustringReplaceAllAsciiLAsciiL); CPPUNIT_TEST_SUITE_END(); }; @@ -172,6 +178,40 @@ void Test::ustringReplaceFirstAsciiL() { } } +void Test::ustringReplaceFirstToAsciiL() { + CPPUNIT_ASSERT_EQUAL( + rtl::OUString("otherbarfoo"), + rtl::OUString("foobarfoo").replaceFirst(s_foo, "other")); + + CPPUNIT_ASSERT_EQUAL( + rtl::OUString("foobarfoo"), + rtl::OUString("foobarfoo").replaceFirst(s_bars, "other")); + + { + sal_Int32 n = 0; + CPPUNIT_ASSERT_EQUAL( + rtl::OUString("otherbarfoo"), + rtl::OUString("foobarfoo").replaceFirst(s_foo, "other", &n)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), n); + } + + { + sal_Int32 n = 1; + CPPUNIT_ASSERT_EQUAL( + rtl::OUString("foobarother"), + rtl::OUString("foobarfoo").replaceFirst(s_foo, "other", &n)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), n); + } + + { + sal_Int32 n = 4; + CPPUNIT_ASSERT_EQUAL( + rtl::OUString("foobarfoo"), + rtl::OUString("foobarfoo").replaceFirst(s_bar, "other", &n)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), n); + } +} + void Test::ustringReplaceFirstAsciiLAsciiL() { CPPUNIT_ASSERT_EQUAL( rtl::OUString("otherbarfoo"), @@ -239,6 +279,20 @@ void Test::ustringReplaceAllAsciiL() { rtl::OUString("xaa").replaceAll("xa", s_xx)); } +void Test::ustringReplaceAllToAsciiL() { + CPPUNIT_ASSERT_EQUAL( + rtl::OUString("otherbarother"), + rtl::OUString("foobarfoo").replaceAll(s_foo, "other")); + + CPPUNIT_ASSERT_EQUAL( + rtl::OUString("foobarfoo"), + rtl::OUString("foobarfoo").replaceAll(s_bars, "other")); + + CPPUNIT_ASSERT_EQUAL( + rtl::OUString("xxa"), + rtl::OUString("xaa").replaceAll(s_xa, "xx")); +} + void Test::ustringReplaceAllAsciiLAsciiL() { CPPUNIT_ASSERT_EQUAL( rtl::OUString("otherbarother"), |