From 14d2a60053e30dcb7e6956637fe8d57d18563e3f Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 28 Aug 2011 00:17:42 +0100 Subject: remove ByteString::IsAlphaNumericAscii and refactor a bit --- comphelper/qa/string/test_string.cxx | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'comphelper/qa') diff --git a/comphelper/qa/string/test_string.cxx b/comphelper/qa/string/test_string.cxx index 4ac96dccc5f7..d7187e04fd75 100644 --- a/comphelper/qa/string/test_string.cxx +++ b/comphelper/qa/string/test_string.cxx @@ -46,6 +46,8 @@ public: void testReplace(); void testToken(); void testDecimalStringToNumber(); + void testIsdigitAsciiString(); + void testIsalnumAsciiString(); CPPUNIT_TEST_SUITE(TestString); CPPUNIT_TEST(testSearchAndReplaceAsciiL); @@ -53,6 +55,8 @@ public: CPPUNIT_TEST(testReplace); CPPUNIT_TEST(testToken); CPPUNIT_TEST(testDecimalStringToNumber); + CPPUNIT_TEST(testIsdigitAsciiString); + CPPUNIT_TEST(testIsalnumAsciiString); CPPUNIT_TEST_SUITE_END(); }; @@ -98,6 +102,33 @@ void TestString::testDecimalStringToNumber() CPPUNIT_ASSERT_EQUAL((sal_uInt32)81, comphelper::string::decimalStringToNumber(s1)); } +void TestString::testIsdigitAsciiString() +{ + rtl::OString s1(RTL_CONSTASCII_STRINGPARAM("1234")); + CPPUNIT_ASSERT_EQUAL(comphelper::string::isdigitAsciiString(s1), true); + + rtl::OString s2(RTL_CONSTASCII_STRINGPARAM("1A34")); + CPPUNIT_ASSERT_EQUAL(comphelper::string::isdigitAsciiString(s2), false); + + rtl::OString s3; + CPPUNIT_ASSERT_EQUAL(comphelper::string::isdigitAsciiString(s3), true); +} + +void TestString::testIsalnumAsciiString() +{ + rtl::OString s1(RTL_CONSTASCII_STRINGPARAM("1234")); + CPPUNIT_ASSERT_EQUAL(comphelper::string::isalnumAsciiString(s1), true); + + rtl::OString s2(RTL_CONSTASCII_STRINGPARAM("1A34")); + CPPUNIT_ASSERT_EQUAL(comphelper::string::isalnumAsciiString(s2), true); + + rtl::OString s3; + CPPUNIT_ASSERT_EQUAL(comphelper::string::isalnumAsciiString(s3), true); + + rtl::OString s4(RTL_CONSTASCII_STRINGPARAM("1A[4")); + CPPUNIT_ASSERT_EQUAL(comphelper::string::isalnumAsciiString(s4), false); +} + using namespace ::com::sun::star; class testCollator : public cppu::WeakImplHelper1< i18n::XCollator > -- cgit