diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-02-15 15:26:43 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-02-15 15:41:09 +0100 |
commit | 9ab0b38e95133dab720408cc2c80093b8a201c10 (patch) | |
tree | 416dde227ed5c4ded99292feb94f36a64c327999 /comphelper/qa | |
parent | 42422f2599220b678aa41c4aadeec28df113c3ec (diff) |
Various string function clean up
Added:
* rtl::OString::matchL
* rtl::OString::endsWith
* rtl::OString::endsWithL
* rtl::OString::indexOfL
* rtl::OString::replaceFirst
* rtl::OString::replaceAll
* rtl::OString::getToken
* rtl::OUString::endsWith
* rtl::OUString::replaceFirst
* rtl::OUString::replaceFirstAsciiL
* rtl::OUString::replaceFirstAsciiLAsciiL
* rtl::OUString::replaceAll
* rtl::OUString::replaceAllAsciiL
* rtl::OUString::replaceAllAsciiLAsciiL
* rtl::OUString::getToken
plus underlying C functions where necessary
Deprecated:
* comphelper::string::remove
* comphelper::string::getToken
Removed:
* comphelper::string::searchAndReplaceAsciiL
* comphelper::string::searchAndReplaceAllAsciiWithAscii
* comphelper::string::searchAndReplaceAsciiI
* comphelper::string::replace
* comphelper::string::matchL
* comphelper::string::matchIgnoreAsciiCaseL
* comphelper::string::indexOfL
Also fixed some apparent misuses of RTL_CONSTASCII_USTRINGPARAM ->
RTL_CONSTASCII_STRINGPARAM.
Diffstat (limited to 'comphelper/qa')
-rw-r--r-- | comphelper/qa/string/test_string.cxx | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/comphelper/qa/string/test_string.cxx b/comphelper/qa/string/test_string.cxx index e53ae9030fa4..b775e01804da 100644 --- a/comphelper/qa/string/test_string.cxx +++ b/comphelper/qa/string/test_string.cxx @@ -44,9 +44,7 @@ namespace { class TestString: public CppUnit::TestFixture { public: - void testSearchAndReplaceAsciiL(); void testNatural(); - void testReplace(); void testRemove(); void testStripStart(); void testStripEnd(); @@ -56,12 +54,9 @@ public: void testDecimalStringToNumber(); void testIsdigitAsciiString(); void testIndexOfL(); - void testMatchIgnoreAsciiCaseL(); CPPUNIT_TEST_SUITE(TestString); - CPPUNIT_TEST(testSearchAndReplaceAsciiL); CPPUNIT_TEST(testNatural); - CPPUNIT_TEST(testReplace); CPPUNIT_TEST(testRemove); CPPUNIT_TEST(testStripStart); CPPUNIT_TEST(testStripEnd); @@ -70,41 +65,9 @@ public: CPPUNIT_TEST(testTokenCount); CPPUNIT_TEST(testDecimalStringToNumber); CPPUNIT_TEST(testIsdigitAsciiString); - CPPUNIT_TEST(testIndexOfL); - CPPUNIT_TEST(testMatchIgnoreAsciiCaseL); CPPUNIT_TEST_SUITE_END(); }; -void TestString::testSearchAndReplaceAsciiL() -{ - rtl::OUString s1(RTL_CONSTASCII_USTRINGPARAM("foobarbar")); - sal_Int32 n1; - rtl::OUString s2( - comphelper::string::searchAndReplaceAsciiL( - s1, RTL_CONSTASCII_STRINGPARAM("bar"), - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("baaz")), 0, &n1)); - CPPUNIT_ASSERT( - s2 == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foobaazbar"))); - CPPUNIT_ASSERT(n1 == 3); - sal_Int32 n2; - rtl::OUString s3( - comphelper::string::searchAndReplaceAsciiL( - s2, RTL_CONSTASCII_STRINGPARAM("bar"), - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bz")), - n1 + RTL_CONSTASCII_LENGTH("baaz"), &n2)); - CPPUNIT_ASSERT( - s3 == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foobaazbz"))); - CPPUNIT_ASSERT(n2 == 7); - sal_Int32 n3; - rtl::OUString s4( - comphelper::string::searchAndReplaceAsciiL( - s3, RTL_CONSTASCII_STRINGPARAM("bar"), - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("baz")), - n2 + RTL_CONSTASCII_LENGTH("bz"), &n3)); - CPPUNIT_ASSERT(s4 == s3); - CPPUNIT_ASSERT(n3 == -1); -} - void TestString::testDecimalStringToNumber() { rtl::OUString s1(RTL_CONSTASCII_USTRINGPARAM("1234")); @@ -129,40 +92,6 @@ void TestString::testIsdigitAsciiString() CPPUNIT_ASSERT_EQUAL(comphelper::string::isdigitAsciiString(s3), true); } -void TestString::testIndexOfL() -{ - rtl::OString s1(RTL_CONSTASCII_STRINGPARAM("one two three")); - - CPPUNIT_ASSERT_EQUAL(comphelper::string::indexOfL(s1, - RTL_CONSTASCII_STRINGPARAM("one")), static_cast<sal_Int32>(0)); - - CPPUNIT_ASSERT_EQUAL(comphelper::string::indexOfL(s1, - RTL_CONSTASCII_STRINGPARAM("two")), static_cast<sal_Int32>(4)); - - CPPUNIT_ASSERT_EQUAL(comphelper::string::indexOfL(s1, - RTL_CONSTASCII_STRINGPARAM("four")), static_cast<sal_Int32>(-1)); - - CPPUNIT_ASSERT_EQUAL(comphelper::string::indexOfL(s1, - RTL_CONSTASCII_STRINGPARAM("two"), 5), static_cast<sal_Int32>(-1)); -} - -void TestString::testMatchIgnoreAsciiCaseL() -{ - rtl::OString s1(RTL_CONSTASCII_STRINGPARAM("one two three")); - - CPPUNIT_ASSERT_EQUAL(comphelper::string::matchIgnoreAsciiCaseL(s1, - RTL_CONSTASCII_STRINGPARAM("one")), sal_True); - - CPPUNIT_ASSERT_EQUAL(comphelper::string::matchIgnoreAsciiCaseL(s1, - RTL_CONSTASCII_STRINGPARAM("ONE")), sal_True); - - CPPUNIT_ASSERT_EQUAL(comphelper::string::matchIgnoreAsciiCaseL(s1, - RTL_CONSTASCII_STRINGPARAM("two")), sal_False); - - CPPUNIT_ASSERT_EQUAL(comphelper::string::matchIgnoreAsciiCaseL(s1, - RTL_CONSTASCII_STRINGPARAM("two"), 4), sal_True); -} - using namespace ::com::sun::star; class testCollator : public cppu::WeakImplHelper1< i18n::XCollator > @@ -357,41 +286,6 @@ void TestString::testNatural() ); } -void TestString::testReplace() -{ - ::rtl::OString aIn(RTL_CONSTASCII_STRINGPARAM("aaa")); - ::rtl::OString aOut; - - aOut = ::comphelper::string::replace(aIn, - rtl::OString(RTL_CONSTASCII_STRINGPARAM("aa")), - rtl::OString(RTL_CONSTASCII_STRINGPARAM("b"))); - CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("ba"))); - - aOut = ::comphelper::string::replace(aIn, - rtl::OString(), - rtl::OString(RTL_CONSTASCII_STRINGPARAM("whatever"))); - CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("aaa"))); - - aOut = ::comphelper::string::replace(aIn, - rtl::OString(RTL_CONSTASCII_STRINGPARAM("aaa")), - rtl::OString()); - CPPUNIT_ASSERT(aOut.isEmpty()); - - aIn = rtl::OString(RTL_CONSTASCII_STRINGPARAM("aaa foo aaa foo bbb")); - - aOut = ::comphelper::string::replace(aIn, - rtl::OString(RTL_CONSTASCII_STRINGPARAM("foo")), - rtl::OString(RTL_CONSTASCII_STRINGPARAM("bar"))); - CPPUNIT_ASSERT(aOut.equalsL( - RTL_CONSTASCII_STRINGPARAM("aaa bar aaa bar bbb"))); - - aOut = ::comphelper::string::replace(aIn, - rtl::OString(' '), - rtl::OString()); - CPPUNIT_ASSERT(aOut.equalsL( - RTL_CONSTASCII_STRINGPARAM("aaafooaaafoobbb"))); -} - void TestString::testRemove() { ::rtl::OString aIn(RTL_CONSTASCII_STRINGPARAM("abc")); |