diff options
author | Sébastien Le Ray <sebastien-libreoffice@orniz.org> | 2011-02-17 10:41:21 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-02-18 10:20:15 +0000 |
commit | a6ba342adec9edad3e4bcf4d614d3525b4e66186 (patch) | |
tree | 2975f1c4b78c69358857e40285d685644ded7340 /comphelper/qa | |
parent | e5f8a07078033bc6774f9f5496d5e985f59be775 (diff) |
Added comphelper::string::decimalStringToNumber
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 > |