diff options
Diffstat (limited to 'comphelper/qa')
-rw-r--r-- | comphelper/qa/string/test_string.cxx | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/comphelper/qa/string/test_string.cxx b/comphelper/qa/string/test_string.cxx index a5826ae3628d..2f92b8190d15 100644 --- a/comphelper/qa/string/test_string.cxx +++ b/comphelper/qa/string/test_string.cxx @@ -49,10 +49,12 @@ class TestString: public CppUnit::TestFixture public: void test(); void testNatural(); + void testDecimalStringToNumber(); CPPUNIT_TEST_SUITE(TestString); CPPUNIT_TEST(test); CPPUNIT_TEST(testNatural); + CPPUNIT_TEST(testDecimalStringToNumber); CPPUNIT_TEST_SUITE_END(); }; @@ -86,6 +88,17 @@ void TestString::test() CPPUNIT_ASSERT(n3 == -1); } +void TestString::testDecimalStringToNumber() { + rtl::OUString s1(RTL_CONSTASCII_USTRINGPARAM("1234")); + CPPUNIT_ASSERT_EQUAL((sal_uInt32)1234, comphelper::string::decimalStringToNumber(s1)); + s1 += rtl::OUString(L'\u07C6'); + CPPUNIT_ASSERT_EQUAL((sal_uInt32)12346, comphelper::string::decimalStringToNumber(s1)); + // Codepoints on 2 16bits words + sal_uInt32 utf16String[] = { 0x1D7FE /* 8 */, 0x1D7F7 /* 1 */}; + s1 = rtl::OUString(utf16String, 2); + CPPUNIT_ASSERT_EQUAL((sal_uInt32)81, comphelper::string::decimalStringToNumber(s1)); +} + using namespace ::com::sun::star; class testCollator : public cppu::WeakImplHelper1< i18n::XCollator > |