diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-11-22 17:17:53 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-11-23 10:10:08 +0000 |
commit | 20153742d2dee2df022275a07cc958b1759b9b72 (patch) | |
tree | a91d3d42faa559783d407bb1fe08f4070d945762 /comphelper/qa | |
parent | a22ce3e4483f6fe462eaba8826a91355957e3676 (diff) |
add a stripStart, can replace EraseLeadingChars
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 2ce6f2cff1bb..790519d07839 100644 --- a/comphelper/qa/string/test_string.cxx +++ b/comphelper/qa/string/test_string.cxx @@ -49,6 +49,7 @@ public: void testNatural(); void testReplace(); void testRemove(); + void testStripStart(); void testToken(); void testDecimalStringToNumber(); void testIsdigitAsciiString(); @@ -62,6 +63,7 @@ public: CPPUNIT_TEST(testNatural); CPPUNIT_TEST(testReplace); CPPUNIT_TEST(testRemove); + CPPUNIT_TEST(testStripStart); CPPUNIT_TEST(testToken); CPPUNIT_TEST(testDecimalStringToNumber); CPPUNIT_TEST(testIsdigitAsciiString); @@ -430,6 +432,26 @@ void TestString::testRemove() CPPUNIT_ASSERT(aOut.isEmpty()); } +void TestString::testStripStart() +{ + ::rtl::OString aIn(RTL_CONSTASCII_STRINGPARAM("abc")); + ::rtl::OString aOut; + + aOut = ::comphelper::string::stripStart(aIn, 'b'); + CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("abc"))); + + aOut = ::comphelper::string::stripStart(aIn, 'a'); + CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("bc"))); + + aIn = rtl::OString(RTL_CONSTASCII_STRINGPARAM("aaa")); + aOut = ::comphelper::string::stripStart(aIn, 'a'); + CPPUNIT_ASSERT(aOut.isEmpty()); + + aIn = rtl::OString(RTL_CONSTASCII_STRINGPARAM("aba")); + aOut = ::comphelper::string::stripStart(aIn, 'a'); + CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("ba"))); +} + void TestString::testToken() { ::rtl::OString aIn(RTL_CONSTASCII_STRINGPARAM("10.11.12")); |