From b7ea36101497c275cb08b0e37facbde656197d9b Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 22 Nov 2011 23:40:24 +0000 Subject: add stripStart, can replace EraseTrailingChars --- comphelper/qa/string/test_string.cxx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'comphelper/qa') 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")); -- cgit