diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-11-23 17:24:38 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-11-23 23:16:44 +0000 |
commit | 0dbc4fa3efdea90ba23e17e12c2bfe15d763acbf (patch) | |
tree | 857875b2edaee72abb836c8235c4bb87e6e6a18b /comphelper/qa | |
parent | 2dba28faae2266e72c05d8f3d55bfbc3e5771adb (diff) |
add string::strip, can replace EraseLeadingAndTrailingChars
Diffstat (limited to 'comphelper/qa')
-rw-r--r-- | comphelper/qa/string/test_string.cxx | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/comphelper/qa/string/test_string.cxx b/comphelper/qa/string/test_string.cxx index 1e89408930bf..5c161a21d4ee 100644 --- a/comphelper/qa/string/test_string.cxx +++ b/comphelper/qa/string/test_string.cxx @@ -51,6 +51,7 @@ public: void testRemove(); void testStripStart(); void testStripEnd(); + void testStrip(); void testToken(); void testDecimalStringToNumber(); void testIsdigitAsciiString(); @@ -66,6 +67,7 @@ public: CPPUNIT_TEST(testRemove); CPPUNIT_TEST(testStripStart); CPPUNIT_TEST(testStripEnd); + CPPUNIT_TEST(testStrip); CPPUNIT_TEST(testToken); CPPUNIT_TEST(testDecimalStringToNumber); CPPUNIT_TEST(testIsdigitAsciiString); @@ -474,6 +476,26 @@ void TestString::testStripEnd() CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("ab"))); } +void TestString::testStrip() +{ + ::rtl::OString aIn(RTL_CONSTASCII_STRINGPARAM("abc")); + ::rtl::OString aOut; + + aOut = ::comphelper::string::strip(aIn, 'b'); + CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("abc"))); + + aOut = ::comphelper::string::strip(aIn, 'c'); + CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("ab"))); + + aIn = rtl::OString(RTL_CONSTASCII_STRINGPARAM("aaa")); + aOut = ::comphelper::string::strip(aIn, 'a'); + CPPUNIT_ASSERT(aOut.isEmpty()); + + aIn = rtl::OString(RTL_CONSTASCII_STRINGPARAM("aba")); + aOut = ::comphelper::string::strip(aIn, 'a'); + CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("b"))); +} + void TestString::testToken() { ::rtl::OString aIn(RTL_CONSTASCII_STRINGPARAM("10.11.12")); |