diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-01-02 10:55:27 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-01-05 09:18:19 +0000 |
commit | bacfd2dc4cea1a5d87658ed8592116acd931e000 (patch) | |
tree | d22172a33fdd13a440b6882a28c23ea2d639bbad /comphelper/qa | |
parent | 6281eb0e0792da0194c07da18296e94dd944b8e5 (diff) |
add a comphelper::string::getTokenCount
suitable for conversion from [Byte]String::GetTokenCount
converted low-hanging variants to rtl::O[UString]::getToken loops
added unit test
Diffstat (limited to 'comphelper/qa')
-rw-r--r-- | comphelper/qa/string/test_string.cxx | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/comphelper/qa/string/test_string.cxx b/comphelper/qa/string/test_string.cxx index ae1fc58ef397..1fb892217740 100644 --- a/comphelper/qa/string/test_string.cxx +++ b/comphelper/qa/string/test_string.cxx @@ -52,6 +52,7 @@ public: void testStripEnd(); void testStrip(); void testToken(); + void testTokenCount(); void testDecimalStringToNumber(); void testIsdigitAsciiString(); void testIsalnumAsciiString(); @@ -68,6 +69,7 @@ public: CPPUNIT_TEST(testStripEnd); CPPUNIT_TEST(testStrip); CPPUNIT_TEST(testToken); + CPPUNIT_TEST(testTokenCount); CPPUNIT_TEST(testDecimalStringToNumber); CPPUNIT_TEST(testIsdigitAsciiString); CPPUNIT_TEST(testIsalnumAsciiString); @@ -516,6 +518,21 @@ void TestString::testToken() CPPUNIT_ASSERT(aOut.isEmpty()); } +void TestString::testTokenCount() +{ + ::rtl::OString aIn(RTL_CONSTASCII_STRINGPARAM("10.11.12")); + sal_Int32 nOut; + + nOut = ::comphelper::string::getTokenCount(aIn, '.'); + CPPUNIT_ASSERT(nOut == 3); + + nOut = ::comphelper::string::getTokenCount(aIn, 'X'); + CPPUNIT_ASSERT(nOut == 1); + + nOut = ::comphelper::string::getTokenCount(rtl::OString(), 'X'); + CPPUNIT_ASSERT(nOut == 0); +} + CPPUNIT_TEST_SUITE_REGISTRATION(TestString); } |