From 8e482e60c52ba427199a29045711b3f9cc870ac0 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 9 Nov 2011 22:07:24 +0000 Subject: an indexOfL would be useful --- comphelper/qa/string/test_string.cxx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'comphelper/qa') diff --git a/comphelper/qa/string/test_string.cxx b/comphelper/qa/string/test_string.cxx index db6d52ea1128..3e30ad22f440 100644 --- a/comphelper/qa/string/test_string.cxx +++ b/comphelper/qa/string/test_string.cxx @@ -53,6 +53,7 @@ public: void testIsdigitAsciiString(); void testIsalnumAsciiString(); void testIsupperAsciiString(); + void testIndexOfL(); CPPUNIT_TEST_SUITE(TestString); CPPUNIT_TEST(testSearchAndReplaceAsciiL); @@ -63,6 +64,7 @@ public: CPPUNIT_TEST(testIsdigitAsciiString); CPPUNIT_TEST(testIsalnumAsciiString); CPPUNIT_TEST(testIsupperAsciiString); + CPPUNIT_TEST(testIndexOfL); CPPUNIT_TEST_SUITE_END(); }; @@ -147,6 +149,23 @@ void TestString::testIsupperAsciiString() CPPUNIT_ASSERT_EQUAL(comphelper::string::isupperAsciiString(s3), true); } +void TestString::testIndexOfL() +{ + rtl::OString s1(RTL_CONSTASCII_STRINGPARAM("one two three")); + + CPPUNIT_ASSERT_EQUAL(comphelper::string::indexOfL(s1, + RTL_CONSTASCII_STRINGPARAM("one")), 0); + + CPPUNIT_ASSERT_EQUAL(comphelper::string::indexOfL(s1, + RTL_CONSTASCII_STRINGPARAM("two")), 4); + + CPPUNIT_ASSERT_EQUAL(comphelper::string::indexOfL(s1, + RTL_CONSTASCII_STRINGPARAM("four")), -1); + + CPPUNIT_ASSERT_EQUAL(comphelper::string::indexOfL(s1, + RTL_CONSTASCII_STRINGPARAM("two"), 5), -1); +} + using namespace ::com::sun::star; class testCollator : public cppu::WeakImplHelper1< i18n::XCollator > -- cgit v1.2.3