From 65b5d1a3f045faca462e7370a315cc729105df86 Mon Sep 17 00:00:00 2001 From: Isamu Mogi Date: Fri, 13 Jun 2014 20:42:42 +0900 Subject: related fdo#63230: Add unit test for fdo#44286 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It fails if 6013fe19a40dd16ce435a2428f7405b51930689e is reverted. Change-Id: Iabf13b15e3c26d7ebafdc9284642183f27723d8c Reviewed-on: https://gerrit.libreoffice.org/9781 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- svl/qa/unit/svl.cxx | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'svl/qa') diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx index 9090c563a256..673c8d2a77a7 100644 --- a/svl/qa/unit/svl.cxx +++ b/svl/qa/unit/svl.cxx @@ -37,6 +37,7 @@ #include #include +#include using namespace ::com::sun::star; using namespace svl; @@ -55,6 +56,7 @@ public: void testSharedString(); void testSharedStringPool(); void testSharedStringPoolPurge(); + void testFdo44286(); void testFdo60915(); void testI116701(); @@ -63,6 +65,7 @@ public: CPPUNIT_TEST(testSharedString); CPPUNIT_TEST(testSharedStringPool); CPPUNIT_TEST(testSharedStringPoolPurge); + CPPUNIT_TEST(testFdo44286); CPPUNIT_TEST(testFdo60915); CPPUNIT_TEST(testI116701); CPPUNIT_TEST_SUITE_END(); @@ -74,6 +77,7 @@ private: double fPreviewNumber, LanguageType eLang, OUString& sExpected); + boost::scoped_ptr m_pDefaultTimeZone; }; Test::Test() @@ -87,6 +91,7 @@ Test::Test() //getProcessServiceFactory. In general those should be removed in favour //of retaining references to the root ServiceFactory as its passed around comphelper::setProcessServiceFactory(xSM); + m_pDefaultTimeZone.reset(icu::TimeZone::createDefault()); } void Test::setUp() @@ -95,6 +100,7 @@ void Test::setUp() void Test::tearDown() { + icu::TimeZone::setDefault(*m_pDefaultTimeZone); } Test::~Test() @@ -397,6 +403,32 @@ void Test::checkPreviewString(SvNumberFormatter& aFormatter, CPPUNIT_ASSERT_EQUAL(sExpected, sStr); } +void Test::testFdo44286() +{ + LanguageType eLang = LANGUAGE_SYSTEM; + OUString sCode = "YYYY-MM-DD", sExpected; + double fPreviewNumber; + SvNumberFormatter aFormatter(m_xContext, eLang); + { + icu::TimeZone::adoptDefault(icu::TimeZone::createTimeZone("America/Sao_Paulo")); + sExpected = "1902-04-22"; + fPreviewNumber = 843; + checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected); + } + { + icu::TimeZone::adoptDefault(icu::TimeZone::createTimeZone("Europe/Berlin")); + sExpected = "1790-07-27"; + fPreviewNumber = -39967; + checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected); + } + { + icu::TimeZone::adoptDefault(icu::TimeZone::createTimeZone("US/Mountain")); + sExpected = "1790-07-26"; + fPreviewNumber = -39968; + checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected); + } +} + void Test::testFdo60915() { LanguageType eLang = LANGUAGE_THAI; -- cgit v1.2.3