diff options
author | Korrawit Pruegsanusak <detective.conan.1412@gmail.com> | 2013-03-17 16:03:48 +0700 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2013-03-19 10:23:43 +0100 |
commit | 0c4a20ad9ce9b3b9db8f4ad458bd742f84e1b903 (patch) | |
tree | cc8ea1013639925a2062237fbeb07eac50ec300c /svl/qa | |
parent | eff94128b8434501a6f9c26a5a47cfd7d408f472 (diff) |
unit test for fdo#60915
Change-Id: Ib7c1e87521fbbfd76b8eeead17c58915c5d71728
Diffstat (limited to 'svl/qa')
-rw-r--r-- | svl/qa/unit/svl.cxx | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx index 805992ee6212..26a0b8d677f0 100644 --- a/svl/qa/unit/svl.cxx +++ b/svl/qa/unit/svl.cxx @@ -86,13 +86,20 @@ public: virtual void tearDown(); void testNumberFormat(); + void testFdo60915(); CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(testNumberFormat); + CPPUNIT_TEST(testFdo60915); CPPUNIT_TEST_SUITE_END(); private: uno::Reference< uno::XComponentContext > m_xContext; + void checkPreviewString(SvNumberFormatter& aFormatter, + const OUString& sCode, + double fPreviewNumber, + LanguageType eLang, + OUString& sExpected); }; Test::Test() @@ -300,6 +307,60 @@ void Test::testNumberFormat() } } +void Test::checkPreviewString(SvNumberFormatter& aFormatter, + const OUString& sCode, + double fPreviewNumber, + LanguageType eLang, + OUString& sExpected) +{ + OUString sStr; + Color* pColor = 0; + Color** ppColor = &pColor; + if (!aFormatter.GetPreviewString(sCode, fPreviewNumber, sStr, ppColor, eLang)) + CPPUNIT_FAIL("GetPreviewString() failed"); + CPPUNIT_ASSERT_EQUAL(sExpected, sStr); +} + +void Test::testFdo60915() +{ + LanguageType eLang = LANGUAGE_THAI; + OUString sCode, sExpected; + double fPreviewNumber = 1234; // equals 18/05/1903 (2446 B.E.) + SvNumberFormatter aFormatter(m_xContext, eLang); + { + sCode = "[~buddhist]D/MM/YYYY"; + sExpected = "18/05/2446"; + checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected); + } + { + sCode = "[~buddhist]D/MM/YY"; + sExpected = "18/05/46"; + checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected); + } + { + sCode = "[NatNum1][$-41E][~buddhist]D/MM/YYYY"; + sal_Unicode sTemp[] = + { + 0x0E51, 0x0E58, 0x002F, + 0x0E50, 0x0E55, 0x002F, + 0x0E52, 0x0E54, 0x0E54, 0x0E56 + }; + sExpected = OUString(sTemp, SAL_N_ELEMENTS(sTemp)); + checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected); + } + { + sCode = "[NatNum1][$-41E][~buddhist]D/MM/YY"; + sal_Unicode sTemp[] = + { + 0x0E51, 0x0E58, 0x002F, + 0x0E50, 0x0E55, 0x002F, + 0x0E54, 0x0E56 + }; + sExpected = OUString(sTemp, SAL_N_ELEMENTS(sTemp)); + checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected); + } +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); } |