summaryrefslogtreecommitdiff
path: root/comphelper/qa/string
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-11-22 23:40:24 +0000
committerCaolán McNamara <caolanm@redhat.com>2011-11-23 10:10:09 +0000
commitb7ea36101497c275cb08b0e37facbde656197d9b (patch)
treea05e25d4f01c94c69712d17a1ab4cdbc925ef355 /comphelper/qa/string
parent62d880f3228c7f5c3f8a1d30f5a5c9ed390a1eb5 (diff)
add stripStart, can replace EraseTrailingChars
Diffstat (limited to 'comphelper/qa/string')
-rw-r--r--comphelper/qa/string/test_string.cxx22
1 files changed, 22 insertions, 0 deletions
diff --git a/comphelper/qa/string/test_string.cxx b/comphelper/qa/string/test_string.cxx
index 790519d07839..1e89408930bf 100644
--- a/comphelper/qa/string/test_string.cxx
+++ b/comphelper/qa/string/test_string.cxx
@@ -50,6 +50,7 @@ public:
void testReplace();
void testRemove();
void testStripStart();
+ void testStripEnd();
void testToken();
void testDecimalStringToNumber();
void testIsdigitAsciiString();
@@ -64,6 +65,7 @@ public:
CPPUNIT_TEST(testReplace);
CPPUNIT_TEST(testRemove);
CPPUNIT_TEST(testStripStart);
+ CPPUNIT_TEST(testStripEnd);
CPPUNIT_TEST(testToken);
CPPUNIT_TEST(testDecimalStringToNumber);
CPPUNIT_TEST(testIsdigitAsciiString);
@@ -452,6 +454,26 @@ void TestString::testStripStart()
CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("ba")));
}
+void TestString::testStripEnd()
+{
+ ::rtl::OString aIn(RTL_CONSTASCII_STRINGPARAM("abc"));
+ ::rtl::OString aOut;
+
+ aOut = ::comphelper::string::stripEnd(aIn, 'b');
+ CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("abc")));
+
+ aOut = ::comphelper::string::stripEnd(aIn, 'c');
+ CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("ab")));
+
+ aIn = rtl::OString(RTL_CONSTASCII_STRINGPARAM("aaa"));
+ aOut = ::comphelper::string::stripEnd(aIn, 'a');
+ CPPUNIT_ASSERT(aOut.isEmpty());
+
+ aIn = rtl::OString(RTL_CONSTASCII_STRINGPARAM("aba"));
+ aOut = ::comphelper::string::stripEnd(aIn, 'a');
+ CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("ab")));
+}
+
void TestString::testToken()
{
::rtl::OString aIn(RTL_CONSTASCII_STRINGPARAM("10.11.12"));