LCOV - code coverage report
Current view: top level - svl/qa/unit - svl.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 209 213 98.1 %
Date: 2015-06-13 12:38:46 Functions: 24 25 96.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #ifdef WNT
      11             : # undef ERROR
      12             : #endif
      13             : 
      14             : #include <sal/types.h>
      15             : #include <cppunit/TestAssert.h>
      16             : #include <cppunit/TestFixture.h>
      17             : #include <cppunit/extensions/HelperMacros.h>
      18             : #include <cppunit/plugin/TestPlugIn.h>
      19             : 
      20             : #include <sal/config.h>
      21             : #include <osl/file.hxx>
      22             : #include <osl/process.h>
      23             : #include <rtl/ustrbuf.hxx>
      24             : 
      25             : #include <cppuhelper/bootstrap.hxx>
      26             : #include <comphelper/processfactory.hxx>
      27             : 
      28             : #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
      29             : #include <com/sun/star/sheet/GeneralFunction.hpp>
      30             : #include <com/sun/star/lang/XComponent.hpp>
      31             : 
      32             : #include <i18nlangtag/lang.h>
      33             : 
      34             : #include <svl/zforlist.hxx>
      35             : #include <svl/zformat.hxx>
      36             : #include <svl/sharedstringpool.hxx>
      37             : #include <svl/sharedstring.hxx>
      38             : #include <unotools/syslocale.hxx>
      39             : 
      40             : #include <boost/scoped_ptr.hpp>
      41             : #include <unicode/calendar.h>
      42             : 
      43             : using namespace ::com::sun::star;
      44             : using namespace svl;
      45             : 
      46             : namespace {
      47             : 
      48             : class Test : public CppUnit::TestFixture {
      49             : public:
      50             :     Test();
      51             :     virtual ~Test();
      52             : 
      53             :     virtual void setUp() SAL_OVERRIDE;
      54             :     virtual void tearDown() SAL_OVERRIDE;
      55             : 
      56             :     void testNumberFormat();
      57             :     void testSharedString();
      58             :     void testSharedStringPool();
      59             :     void testSharedStringPoolPurge();
      60             :     void testFdo60915();
      61             :     void testI116701();
      62             :     void testDateInput();
      63             :     void testIsNumberFormat();
      64             : 
      65           2 :     CPPUNIT_TEST_SUITE(Test);
      66           1 :     CPPUNIT_TEST(testNumberFormat);
      67           1 :     CPPUNIT_TEST(testSharedString);
      68           1 :     CPPUNIT_TEST(testSharedStringPool);
      69           1 :     CPPUNIT_TEST(testSharedStringPoolPurge);
      70           1 :     CPPUNIT_TEST(testFdo60915);
      71           1 :     CPPUNIT_TEST(testI116701);
      72           1 :     CPPUNIT_TEST(testDateInput);
      73           1 :     CPPUNIT_TEST(testIsNumberFormat);
      74           5 :     CPPUNIT_TEST_SUITE_END();
      75             : 
      76             : private:
      77             :     uno::Reference< uno::XComponentContext > m_xContext;
      78             :     void checkPreviewString(SvNumberFormatter& aFormatter,
      79             :                             const OUString& sCode,
      80             :                             double fPreviewNumber,
      81             :                             LanguageType eLang,
      82             :                             OUString& sExpected);
      83             :     void checkDateInput( SvNumberFormatter& rFormatter, const char* pTimezone, const char* pIsoDate );
      84             :     boost::scoped_ptr<icu::TimeZone> m_pDefaultTimeZone;
      85             : };
      86             : 
      87           8 : Test::Test()
      88             : {
      89           8 :     m_xContext = cppu::defaultBootstrap_InitialComponentContext();
      90             : 
      91           8 :     uno::Reference<lang::XMultiComponentFactory> xFactory(m_xContext->getServiceManager());
      92          16 :     uno::Reference<lang::XMultiServiceFactory> xSM(xFactory, uno::UNO_QUERY_THROW);
      93             : 
      94             :     //Without this we're crashing because callees are using
      95             :     //getProcessServiceFactory.  In general those should be removed in favour
      96             :     //of retaining references to the root ServiceFactory as its passed around
      97           8 :     comphelper::setProcessServiceFactory(xSM);
      98          16 :     m_pDefaultTimeZone.reset(icu::TimeZone::createDefault());
      99           8 : }
     100             : 
     101           8 : void Test::setUp()
     102             : {
     103           8 : }
     104             : 
     105           8 : void Test::tearDown()
     106             : {
     107           8 :     icu::TimeZone::setDefault(*m_pDefaultTimeZone);
     108           8 : }
     109             : 
     110          24 : Test::~Test()
     111             : {
     112           8 :     uno::Reference< lang::XComponent >(m_xContext, uno::UNO_QUERY_THROW)->dispose();
     113          16 : }
     114             : 
     115           1 : void Test::testNumberFormat()
     116             : {
     117           1 :     LanguageType eLang = LANGUAGE_ENGLISH_US;
     118             : 
     119             :     const char* pNumber[] = {
     120             :         "General",
     121             :         "0",
     122             :         "0.00",
     123             :         "#,##0",
     124             :         "#,##0.00",
     125             :         "#,###.00",
     126             :         0
     127           1 :     };
     128             : 
     129             :     const char* pScientific[] = {
     130             :         "0.00E+000",
     131             :         "0.00E+00",
     132             :         0
     133           1 :     };
     134             : 
     135             :     const char* pPercent[] = {
     136             :         "0%",
     137             :         "0.00%",
     138             :         0
     139           1 :     };
     140             : 
     141             :     const char* pFraction[] = {
     142             :         "# \?/\?",
     143             :         "# \?\?/\?\?",
     144             : #if 0
     145             : // TODO: Followings aren't in range of NF_FRACTION_START and NF_FRACTION_END
     146             : // see enum NfIndexTableOffset in svl/inc/svl/zforlist.hxx
     147             :         "# \?/4",
     148             :         "# \?\?/100",
     149             : #endif
     150             :         0
     151           1 :     };
     152             : 
     153             : #if 0 // TODO: Find out why on some systems the last two currency format codes differ.
     154             :     const char* pCurrency[] = {
     155             :         "$#,##0;[RED]-$#,##0",
     156             :         "$#,##0.00;[RED]-$#,##0.00",
     157             :         "#,##0.00 CCC",
     158             :         "$#,##0.--;[RED]-$#,##0.--",
     159             :         "$#,##0;-$#,##0",
     160             :         "$#,##0;-$#,##0",
     161             :         0
     162             :     };
     163             : #endif
     164             : 
     165             : #if 0 // TODO: This currently fails
     166             :     const char* pDate[] = {
     167             :         "MM/DD/YY",
     168             :         "MM/DD/YYYY",
     169             :         "MMM D, YY",
     170             :         "MMM D, YYYY",
     171             :         "D. MMM. YYYY",
     172             :         "MMMM D, YYYY",
     173             :         "D. MMMM YYYY",
     174             :         "NN, MMM D, YY",
     175             :         "NN DD/MMM YY",
     176             :         "NN, MMMM D, YYYY",
     177             :         "NNNNMMMM D, YYYY",
     178             :         "MM-DD",
     179             :         "YY-MM-DD",
     180             :         "YYYY-MM-DD",
     181             :         "MM/YY",
     182             :         "MMM DD",
     183             :         "MMMM",
     184             :         "QQ YY",
     185             :         "WW",
     186             :         "MM/DD/YY",
     187             :         "WW",
     188             :         0
     189             :     };
     190             : #endif
     191             : 
     192             :     const char* pTime[] = {
     193             :         "HH:MM",
     194             :         "HH:MM:SS",
     195             :         "HH:MM AM/PM",
     196             :         "HH:MM:SS AM/PM",
     197             :         "[HH]:MM:SS",
     198             :         "MM:SS.00",
     199             :         "[HH]:MM:SS.00",
     200             :         0
     201           1 :     };
     202             : 
     203             : #if 0 // TODO: This currently fails
     204             :     const char* pDateTime[] = {
     205             :         "MM/DD/YY HH:MM AM/PM",
     206             :         "MM/DD/YY HH:MM AM/PM",
     207             :         0
     208             :     };
     209             : #endif
     210             : 
     211             :     const char* pBoolean[] = {
     212             :         "BOOLEAN",
     213             :         0
     214           1 :     };
     215             : 
     216             :     const char* pText[] = {
     217             :         "@",
     218             :         0
     219           1 :     };
     220             : 
     221             :     struct {
     222             :         NfIndexTableOffset eStart;
     223             :         NfIndexTableOffset eEnd;
     224             :         size_t nSize;
     225             :         const char** pCodes;
     226             :     } aTests[] = {
     227             :         { NF_NUMBER_START, NF_NUMBER_END, 6, pNumber },
     228             :         { NF_SCIENTIFIC_START, NF_SCIENTIFIC_END, 2, pScientific },
     229             :         { NF_PERCENT_START, NF_PERCENT_END, 2, pPercent },
     230             :         { NF_FRACTION_START, NF_FRACTION_END, 2, pFraction },
     231             : #if 0 // TODO: Find out why on some systems the last two currency format codes differ.
     232             :         { NF_CURRENCY_START, NF_CURRENCY_END, 6, pCurrency },
     233             : #endif
     234             : #if 0 // TODO: This currently fails
     235             :         { NF_DATE_START, NF_DATE_END, 21, pDate },
     236             : #endif
     237             :         { NF_TIME_START, NF_TIME_END, 7, pTime },
     238             : #if 0 // TODO: This currently fails
     239             :         { NF_DATETIME_START, NF_DATETIME_END, 2, pDateTime },
     240             : #endif
     241             :         { NF_BOOLEAN, NF_BOOLEAN, 1, pBoolean },
     242             :         { NF_TEXT, NF_TEXT, 1, pText }
     243           1 :     };
     244             : 
     245           1 :     SvNumberFormatter aFormatter(m_xContext, eLang);
     246             : 
     247           8 :     for (size_t i = 0; i < SAL_N_ELEMENTS(aTests); ++i)
     248             :     {
     249           7 :         size_t nStart = aTests[i].eStart;
     250           7 :         size_t nEnd = aTests[i].eEnd;
     251             : 
     252          14 :         CPPUNIT_ASSERT_MESSAGE("Unexpected number of formats for this category.",
     253           7 :                                (nEnd - nStart + 1) == aTests[i].nSize);
     254             : 
     255          28 :         for (size_t j = nStart; j <= nEnd; ++j)
     256             :         {
     257             :             sal_uInt32 nIndex =
     258          21 :                 aFormatter.GetFormatIndex(static_cast<NfIndexTableOffset>(j));
     259          21 :             const SvNumberformat* p = aFormatter.GetEntry(nIndex);
     260             : 
     261          21 :             CPPUNIT_ASSERT_MESSAGE("Number format entry is expected, but doesn't exist.", p);
     262          21 :             OUString aCode = p->GetFormatstring();
     263          21 :             bool bEqual = aCode.equalsAscii(aTests[i].pCodes[j-nStart]);
     264          21 :             CPPUNIT_ASSERT_MESSAGE("Unexpected number format code.", bEqual);
     265          21 :         }
     266             :     }
     267             : 
     268             :     sal_Int32 nPos;
     269           1 :     short nType = css::util::NumberFormat::DEFINED;
     270             :     sal_uInt32 nKey;
     271           2 :     OUString aCode;
     272             :     // Thai date format (implicit locale).
     273           1 :     aCode = "[$-1070000]d/mm/yyyy;@";
     274           1 :     if (!aFormatter.PutEntry(aCode, nPos, nType, nKey))
     275             :     {
     276           0 :         CPPUNIT_ASSERT_MESSAGE("failed to insert format code '[$-1070000]d/mm/yyyy;@'", false);
     277             :     }
     278             : 
     279             :     // Thai date format (explicit locale)
     280           1 :     aCode = "[$-107041E]d/mm/yyyy;@";
     281           1 :     if (!aFormatter.PutEntry(aCode, nPos, nType, nKey))
     282             :     {
     283           0 :         CPPUNIT_ASSERT_MESSAGE("failed to insert format code '[$-107041E]d/mm/yyyy;@'", false);
     284             :     }
     285             : 
     286             :     // Thai date format (using buddhist calendar type).
     287           1 :     aCode = "[~buddhist]D MMMM YYYY";
     288           1 :     if (!aFormatter.PutEntry(aCode, nPos, nType, nKey))
     289             :     {
     290           0 :         CPPUNIT_ASSERT_MESSAGE("failed to insert format code '[~buddhist]D MMMM YYYY'", false);
     291           1 :     }
     292           1 : }
     293             : 
     294           1 : void Test::testSharedString()
     295             : {
     296             :     // Use shared string as normal, non-shared string, which is allowed.
     297           2 :     SharedString aSS1("Test"), aSS2("Test");
     298           1 :     CPPUNIT_ASSERT_MESSAGE("Equality check should return true.", aSS1 == aSS2);
     299           2 :     SharedString aSS3("test");
     300           2 :     CPPUNIT_ASSERT_MESSAGE("Equality check is case sensitive.", aSS1 != aSS3);
     301           1 : }
     302             : 
     303           1 : void Test::testSharedStringPool()
     304             : {
     305           1 :     SvtSysLocale aSysLocale;
     306           2 :     svl::SharedStringPool aPool(aSysLocale.GetCharClassPtr());
     307             : 
     308           2 :     svl::SharedString p1, p2;
     309           1 :     p1 = aPool.intern("Andy");
     310           1 :     p2 = aPool.intern("Andy");
     311           1 :     CPPUNIT_ASSERT_EQUAL(p1.getData(), p2.getData());
     312             : 
     313           1 :     p2 = aPool.intern("Bruce");
     314           1 :     CPPUNIT_ASSERT_MESSAGE("They must differ.", p1.getData() != p2.getData());
     315             : 
     316           2 :     OUString aAndy("Andy");
     317           1 :     p1 = aPool.intern("Andy");
     318           1 :     p2 = aPool.intern(aAndy);
     319           1 :     CPPUNIT_ASSERT_MESSAGE("Identifier shouldn't be NULL.", p1.getData());
     320           1 :     CPPUNIT_ASSERT_MESSAGE("Identifier shouldn't be NULL.", p2.getData());
     321           1 :     CPPUNIT_ASSERT_EQUAL(p1.getData(), p2.getData());
     322             : 
     323             :     // Test case insensitive string ID's.
     324           2 :     OUString aAndyLower("andy"), aAndyUpper("ANDY");
     325           1 :     p1 = aPool.intern(aAndy);
     326           1 :     p2 = aPool.intern(aAndyLower);
     327           1 :     CPPUNIT_ASSERT_MESSAGE("Failed to intern strings.", p1.getData() && p2.getData());
     328           1 :     CPPUNIT_ASSERT_MESSAGE("These two ID's should differ.", p1.getData() != p2.getData());
     329           1 :     CPPUNIT_ASSERT_MESSAGE("These two ID's should be equal.", p1.getDataIgnoreCase() == p2.getDataIgnoreCase());
     330           1 :     p2 = aPool.intern(aAndyUpper);
     331           1 :     CPPUNIT_ASSERT_MESSAGE("Failed to intern string.", p2.getData());
     332           1 :     CPPUNIT_ASSERT_MESSAGE("These two ID's should differ.", p1.getData() != p2.getData());
     333           2 :     CPPUNIT_ASSERT_MESSAGE("These two ID's should be equal.", p1.getDataIgnoreCase() == p2.getDataIgnoreCase());
     334           1 : }
     335             : 
     336           1 : void Test::testSharedStringPoolPurge()
     337             : {
     338           1 :     SvtSysLocale aSysLocale;
     339           2 :     svl::SharedStringPool aPool(aSysLocale.GetCharClassPtr());
     340           1 :     aPool.intern("Andy");
     341           1 :     aPool.intern("andy");
     342           1 :     aPool.intern("ANDY");
     343             : 
     344           1 :     CPPUNIT_ASSERT_MESSAGE("Wrong string count.", aPool.getCount() == 3);
     345           1 :     CPPUNIT_ASSERT_MESSAGE("Wrong case insensitive string count.", aPool.getCountIgnoreCase() == 1);
     346             : 
     347             :     // Since no string objects referencing the pooled strings exist, purging
     348             :     // the pool should empty it.
     349           1 :     aPool.purge();
     350           1 :     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), aPool.getCount());
     351           1 :     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), aPool.getCountIgnoreCase());
     352             : 
     353             :     // Now, create string objects on the heap.
     354           2 :     boost::scoped_ptr<OUString> pStr1(new OUString("Andy"));
     355           2 :     boost::scoped_ptr<OUString> pStr2(new OUString("andy"));
     356           2 :     boost::scoped_ptr<OUString> pStr3(new OUString("ANDY"));
     357           2 :     boost::scoped_ptr<OUString> pStr4(new OUString("Bruce"));
     358           1 :     aPool.intern(*pStr1);
     359           1 :     aPool.intern(*pStr2);
     360           1 :     aPool.intern(*pStr3);
     361           1 :     aPool.intern(*pStr4);
     362             : 
     363           1 :     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), aPool.getCount());
     364           1 :     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aPool.getCountIgnoreCase());
     365             : 
     366             :     // This shouldn't purge anything.
     367           1 :     aPool.purge();
     368           1 :     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), aPool.getCount());
     369           1 :     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aPool.getCountIgnoreCase());
     370             : 
     371             :     // Delete one heap string object, and purge. That should purge one string.
     372           1 :     pStr1.reset();
     373           1 :     aPool.purge();
     374           1 :     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), aPool.getCount());
     375           1 :     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aPool.getCountIgnoreCase());
     376             : 
     377             :     // Ditto...
     378           1 :     pStr3.reset();
     379           1 :     aPool.purge();
     380           1 :     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aPool.getCount());
     381           1 :     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aPool.getCountIgnoreCase());
     382             : 
     383             :     // Again.
     384           1 :     pStr2.reset();
     385           1 :     aPool.purge();
     386           1 :     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aPool.getCount());
     387           1 :     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aPool.getCountIgnoreCase());
     388             : 
     389             :     // Delete 'Bruce' and purge.
     390           1 :     pStr4.reset();
     391           1 :     aPool.purge();
     392           1 :     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), aPool.getCount());
     393           2 :     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), aPool.getCountIgnoreCase());
     394           1 : }
     395             : 
     396           6 : void Test::checkPreviewString(SvNumberFormatter& aFormatter,
     397             :                               const OUString& sCode,
     398             :                               double fPreviewNumber,
     399             :                               LanguageType eLang,
     400             :                               OUString& sExpected)
     401             : {
     402           6 :     OUString sStr;
     403           6 :     Color* pColor = 0;
     404           6 :     Color** ppColor = &pColor;
     405           6 :     if (!aFormatter.GetPreviewString(sCode, fPreviewNumber, sStr, ppColor, eLang))
     406           0 :         CPPUNIT_FAIL("GetPreviewString() failed");
     407           6 :     CPPUNIT_ASSERT_EQUAL(sExpected, sStr);
     408           6 : }
     409             : 
     410           1 : void Test::testFdo60915()
     411             : {
     412           1 :     LanguageType eLang = LANGUAGE_THAI;
     413           2 :     OUString sCode, sExpected;
     414           1 :     double fPreviewNumber = 36486; // equals 1999-11-22 (2542 B.E.)
     415           2 :     SvNumberFormatter aFormatter(m_xContext, eLang);
     416             :     {
     417           1 :         sCode = "[~buddhist]D/MM/YYYY";
     418           1 :         sExpected = "22/11/2542";
     419           1 :         checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected);
     420             :     }
     421             :     {
     422           1 :         sCode = "[~buddhist]D/MM/YY";
     423           1 :         sExpected = "22/11/42";
     424           1 :         checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected);
     425             :     }
     426             :     {
     427           1 :         sCode = "[NatNum1][$-41E][~buddhist]D/MM/YYYY";
     428             :         sal_Unicode sTemp[] =
     429             :         {
     430             :             0x0E52, 0x0E52, 0x002F,
     431             :             0x0E51, 0x0E51, 0x002F,
     432             :             0x0E52, 0x0E55, 0x0E54, 0x0E52
     433           1 :         };
     434           1 :         sExpected = OUString(sTemp, SAL_N_ELEMENTS(sTemp));
     435           1 :         checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected);
     436             :     }
     437             :     {
     438           1 :         sCode = "[NatNum1][$-41E][~buddhist]D/MM/YY";
     439             :         sal_Unicode sTemp[] =
     440             :         {
     441             :             0x0E52, 0x0E52, 0x002F,
     442             :             0x0E51, 0x0E51, 0x002F,
     443             :             0x0E54, 0x0E52
     444           1 :         };
     445           1 :         sExpected = OUString(sTemp, SAL_N_ELEMENTS(sTemp));
     446           1 :         checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected);
     447           1 :     }
     448           1 : }
     449             : 
     450             : // https://bz.apache.org/ooo/show_bug.cgi?id=116701
     451           1 : void Test::testI116701()
     452             : {
     453           1 :     LanguageType eLang = LANGUAGE_CHINESE_TRADITIONAL;
     454           2 :     OUString sCode, sExpected;
     455           1 :     double fPreviewNumber = 40573; // equals 30/01/2011
     456           2 :     SvNumberFormatter aFormatter(m_xContext, eLang);
     457             :     // DateFormatskey25 in i18npool/source/localedata/data/zh_TW.xml
     458             :     sal_Unicode CODE1[] =
     459             :     {
     460             :         0x0047, 0x0047, 0x0047, 0x0045, 0x0045, // GGGEE
     461             :         0x0022, 0x5E74, 0x0022,
     462             :         0x004D, // M
     463             :         0x0022, 0x6708, 0x0022,
     464             :         0x0044, // D
     465             :         0x0022, 0x65E5, 0x0022
     466           1 :     };
     467           1 :     sCode = OUString(CODE1, SAL_N_ELEMENTS(CODE1));
     468             :     sal_Unicode EXPECTED[] =
     469             :     {
     470             :         0x4E2D, 0x83EF, 0x6C11, 0x570B,
     471             :         0x0031, 0x0030, 0x0030, // 100
     472             :         0x5E74,
     473             :         0x0031, // 1
     474             :         0x6708,
     475             :         0x0033, 0x0030, // 30
     476             :         0x65E5
     477           1 :     };
     478           1 :     sExpected = OUString(EXPECTED, SAL_N_ELEMENTS(EXPECTED));
     479           1 :     checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected);
     480             :     sal_Unicode CODE2[] =
     481             :     {
     482             :         0x0047, 0x0047, 0x0047, 0x0045, // GGGE
     483             :         0x0022, 0x5E74, 0x0022,
     484             :         0x004D, // M
     485             :         0x0022, 0x6708, 0x0022,
     486             :         0x0044, // D
     487             :         0x0022, 0x65E5, 0x0022
     488           1 :     };
     489           1 :     sCode = OUString(CODE2, SAL_N_ELEMENTS(CODE2));
     490           2 :     checkPreviewString(aFormatter, sCode, fPreviewNumber, eLang, sExpected);
     491           1 : }
     492             : 
     493           1 : void Test::testDateInput()
     494             : {
     495             :     const char* aData[][2] = {
     496             :         { "Europe/Paris", "1938-10-07" },      // i#76623
     497             :         { "Europe/Moscow", "1919-07-01" },     // i#86094
     498             :         { "Europe/Tallinn", "1790-03-01" },    // i#105864
     499             :         { "Australia/Perth", "2004-04-11" },   // i#17222
     500             :         { "America/Sao_Paulo", "1902-04-22" }, // tdf#44286
     501             :         { "Europe/Berlin", "1790-07-27" },
     502             :         { "US/Mountain", "1790-07-26" },
     503             : 
     504             :         // Data from https://bugs.documentfoundation.org/show_bug.cgi?id=63230
     505             :         // https://bugs.documentfoundation.org/attachment.cgi?id=79051
     506             :         { "Africa/Accra", "1800-01-01" },
     507             :         { "Africa/Accra", "1800-04-10" },
     508             :         { "Africa/Addis_Ababa", "1870-01-01" },
     509             :         { "Africa/Addis_Ababa", "1936-05-05" },
     510             :         { "Africa/Algiers", "1956-01-29" },
     511             :         { "Africa/Algiers", "1981-05-01" },
     512             :         { "Africa/Asmara", "1936-05-05" },
     513             :         { "Africa/Asmera", "1936-05-05" },
     514             :         { "Africa/Bujumbura", "1890-01-01" },
     515             :         { "Africa/Casablanca", "1984-03-16" },
     516             :         { "Africa/Ceuta", "1984-03-16" },
     517             :         { "Africa/Dar_es_Salaam", "1931-01-01" },
     518             :         { "Africa/Dar_es_Salaam", "1961-01-01" },
     519             :         { "Africa/Djibouti", "1911-07-01" },
     520             :         { "Africa/Douala", "1912-01-01" },
     521             :         { "Africa/El_Aaiun", "1934-01-01" },
     522             :         { "Africa/Freetown", "1913-06-01" },
     523             :         { "Africa/Gaborone", "1885-01-01" },
     524             :         { "Africa/Johannesburg", "1903-03-01" },
     525             :         { "Africa/Kampala", "1928-07-01" },
     526             :         { "Africa/Kampala", "1948-01-01" },
     527             :         { "Africa/Kampala", "1957-01-01" },
     528             :         { "Africa/Lagos", "1919-09-01" },
     529             :         { "Africa/Libreville", "1912-01-01" },
     530             :         { "Africa/Luanda", "1911-05-26" },
     531             :         { "Africa/Lubumbashi", "1897-11-09" },
     532             :         { "Africa/Lusaka", "1903-03-01" },
     533             :         { "Africa/Malabo", "1963-12-15" },
     534             :         { "Africa/Maseru", "1903-03-01" },
     535             :         { "Africa/Mogadishu", "1957-01-01" },
     536             :         { "Africa/Monrovia", "1919-03-01" },
     537             :         { "Africa/Nairobi", "1928-07-01" },
     538             :         { "Africa/Nairobi", "1940-01-01" },
     539             :         { "Africa/Nairobi", "1960-01-01" },
     540             :         { "Africa/Niamey", "1960-01-01" },
     541             :         { "Africa/Porto-Novo", "1934-02-26" },
     542             :         { "Africa/Tripoli", "1920-01-01" },
     543             :         { "Africa/Tripoli", "1959-01-01" },
     544             :         { "Africa/Tripoli", "1990-05-04" },
     545             :         { "Africa/Tunis", "1911-03-11" },
     546             :         { "Africa/Windhoek", "1892-02-08" },
     547             :         { "Africa/Windhoek", "1903-03-01" },
     548             :         { "America/Antigua", "1912-03-02" },
     549             :         { "America/Argentina/Buenos_Aires", "1894-10-31" },
     550             :         { "America/Argentina/Catamarca", "1991-10-20" },
     551             :         { "America/Argentina/Catamarca", "2004-06-01" },
     552             :         { "America/Argentina/ComodRivadavia", "1991-10-20" },
     553             :         { "America/Argentina/ComodRivadavia", "2004-06-01" },
     554             :         { "America/Argentina/Cordoba", "1991-10-20" },
     555             :         { "America/Argentina/Jujuy", "1991-10-06" },
     556             :         { "America/Argentina/La_Rioja", "2004-06-01" },
     557             :         { "America/Argentina/Mendoza", "1992-10-18" },
     558             :         { "America/Argentina/Mendoza", "2004-05-23" },
     559             :         { "America/Argentina/Rio_Gallegos", "2004-06-01" },
     560             :         { "America/Argentina/Salta", "1991-10-20" },
     561             :         { "America/Argentina/San_Juan", "2004-05-31" },
     562             :         { "America/Argentina/San_Luis", "2004-05-31" },
     563             :         { "America/Argentina/San_Luis", "2008-01-21" },
     564             :         { "America/Argentina/Tucuman", "1991-10-20" },
     565             :         { "America/Argentina/Tucuman", "2004-06-01" },
     566             :         { "America/Argentina/Ushuaia", "2004-05-30" },
     567             :         { "America/Asuncion", "1931-10-10" },
     568             :         { "America/Asuncion", "1974-04-01" },
     569             :         { "America/Bahia", "1914-01-01" },
     570             :         { "America/Bahia_Banderas", "1930-11-15" },
     571             :         { "America/Bahia_Banderas", "1931-10-01" },
     572             :         { "America/Bahia_Banderas", "1942-04-24" },
     573             :         { "America/Bahia_Banderas", "1949-01-14" },
     574             :         { "America/Barbados", "1932-01-01" },
     575             :         { "America/Belize", "1912-04-01" },
     576             :         { "America/Blanc-Sablon", "1884-01-01" },
     577             :         { "America/Bogota", "1914-11-23" },
     578             :         { "America/Buenos_Aires", "1894-10-31" },
     579             :         { "America/Cambridge_Bay", "2000-11-05" },
     580             :         { "America/Campo_Grande", "1914-01-01" },
     581             :         { "America/Caracas", "1912-02-12" },
     582             :         { "America/Catamarca", "1991-10-20" },
     583             :         { "America/Catamarca", "2004-06-01" },
     584             :         { "America/Cayenne", "1911-07-01" },
     585             :         { "America/Chihuahua", "1930-11-15" },
     586             :         { "America/Chihuahua", "1931-10-01" },
     587             :         { "America/Cordoba", "1991-10-20" },
     588             :         { "America/Costa_Rica", "1921-01-15" },
     589             :         { "America/Cuiaba", "1914-01-01" },
     590             :         { "America/Danmarkshavn", "1916-07-28" },
     591             :         { "America/Detroit", "1905-01-01" },
     592             :         { "America/Eirunepe", "1914-01-01" },
     593             :         { "America/El_Salvador", "1921-01-01" },
     594             :         { "America/Ensenada", "1924-01-01" },
     595             :         { "America/Ensenada", "1930-11-15" },
     596             :         { "America/Fortaleza", "1914-01-01" },
     597             :         { "America/Glace_Bay", "1902-06-15" },
     598             :         { "America/Grand_Turk", "1890-01-01" },
     599             :         { "America/Guyana", "1991-01-01" },
     600             :         { "America/Havana", "1890-01-01" },
     601             :         { "America/Hermosillo", "1930-11-15" },
     602             :         { "America/Hermosillo", "1931-10-01" },
     603             :         { "America/Hermosillo", "1942-04-24" },
     604             :         { "America/Hermosillo", "1949-01-14" },
     605             :         { "America/Jujuy", "1991-10-06" },
     606             :         { "America/Lima", "1890-01-01" },
     607             :         { "America/Maceio", "1914-01-01" },
     608             :         { "America/Managua", "1890-01-01" },
     609             :         { "America/Managua", "1934-06-23" },
     610             :         { "America/Managua", "1975-02-16" },
     611             :         { "America/Managua", "1992-09-24" },
     612             :         { "America/Managua", "1997-01-01" },
     613             :         { "America/Mazatlan", "1930-11-15" },
     614             :         { "America/Mazatlan", "1931-10-01" },
     615             :         { "America/Mazatlan", "1942-04-24" },
     616             :         { "America/Mazatlan", "1949-01-14" },
     617             :         { "America/Mendoza", "1992-10-18" },
     618             :         { "America/Mendoza", "2004-05-23" },
     619             :         { "America/Merida", "1982-12-02" },
     620             :         { "America/Mexico_City", "1930-11-15" },
     621             :         { "America/Mexico_City", "1931-10-01" },
     622             :         { "America/Miquelon", "1911-05-15" },
     623             :         { "America/Moncton", "1883-12-09" },
     624             :         { "America/Montevideo", "1942-12-14" },
     625             :         { "America/Montreal", "1884-01-01" },
     626             :         { "America/Ojinaga", "1930-11-15" },
     627             :         { "America/Ojinaga", "1931-10-01" },
     628             :         { "America/Panama", "1890-01-01" },
     629             :         { "America/Paramaribo", "1911-01-01" },
     630             :         { "America/Porto_Acre", "1914-01-01" },
     631             :         { "America/Recife", "1914-01-01" },
     632             :         { "America/Regina", "1905-09-01" },
     633             :         { "America/Rio_Branco", "1914-01-01" },
     634             :         { "America/Rosario", "1991-10-20" },
     635             :         { "America/Santa_Isabel", "1924-01-01" },
     636             :         { "America/Santa_Isabel", "1930-11-15" },
     637             :         { "America/Santarem", "1914-01-01" },
     638             :         { "America/Santiago", "1910-01-01" },
     639             :         { "America/Santiago", "1919-07-01" },
     640             :         { "America/Santo_Domingo", "1890-01-01" },
     641             :         { "America/Scoresbysund", "1916-07-28" },
     642             :         { "America/Scoresbysund", "1981-03-29" },
     643             :         { "America/Tegucigalpa", "1921-04-01" },
     644             :         { "America/Thunder_Bay", "1895-01-01" },
     645             :         { "America/Tijuana", "1924-01-01" },
     646             :         { "America/Tijuana", "1930-11-15" },
     647             :         { "Antarctica/Casey", "1969-01-01" },
     648             :         { "Antarctica/Casey", "2009-10-18" },
     649             :         { "Antarctica/Davis", "1957-01-13" },
     650             :         { "Antarctica/Davis", "1969-02-01" },
     651             :         { "Antarctica/Davis", "2010-03-11" },
     652             :         { "Antarctica/DumontDUrville", "1947-01-01" },
     653             :         { "Antarctica/DumontDUrville", "1956-11-01" },
     654             :         { "Antarctica/Macquarie", "1911-01-01" },
     655             :         { "Antarctica/Mawson", "1954-02-13" },
     656             :         { "Antarctica/McMurdo", "1956-01-01" },
     657             :         { "Antarctica/Palmer", "1982-05-01" },
     658             :         { "Antarctica/South_Pole", "1956-01-01" },
     659             :         { "Antarctica/Syowa", "1957-01-29" },
     660             :         { "Antarctica/Vostok", "1957-12-16" },
     661             :         { "Arctic/Longyearbyen", "1895-01-01" },
     662             :         { "Asia/Almaty", "1930-06-21" },
     663             :         { "Asia/Anadyr", "1924-05-02" },
     664             :         { "Asia/Anadyr", "1930-06-21" },
     665             :         { "Asia/Anadyr", "1992-01-19" },
     666             :         { "Asia/Anadyr", "2011-03-27" },
     667             :         { "Asia/Aqtau", "1924-05-02" },
     668             :         { "Asia/Aqtau", "1930-06-21" },
     669             :         { "Asia/Aqtau", "1981-10-01" },
     670             :         { "Asia/Aqtau", "2005-03-15" },
     671             :         { "Asia/Aqtobe", "1924-05-02" },
     672             :         { "Asia/Aqtobe", "1930-06-21" },
     673             :         { "Asia/Ashgabat", "1924-05-02" },
     674             :         { "Asia/Ashgabat", "1930-06-21" },
     675             :         { "Asia/Ashgabat", "1992-01-19" },
     676             :         { "Asia/Ashkhabad", "1924-05-02" },
     677             :         { "Asia/Ashkhabad", "1930-06-21" },
     678             :         { "Asia/Ashkhabad", "1992-01-19" },
     679             :         { "Asia/Baghdad", "1918-01-01" },
     680             :         { "Asia/Bahrain", "1920-01-01" },
     681             :         { "Asia/Baku", "1957-03-01" },
     682             :         { "Asia/Bangkok", "1920-04-01" },
     683             :         { "Asia/Bishkek", "1924-05-02" },
     684             :         { "Asia/Bishkek", "1930-06-21" },
     685             :         { "Asia/Brunei", "1933-01-01" },
     686             :         { "Asia/Calcutta", "1941-10-01" },
     687             :         { "Asia/Choibalsan", "1978-01-01" },
     688             :         { "Asia/Chongqing", "1980-05-01" },
     689             :         { "Asia/Chungking", "1980-05-01" },
     690             :         { "Asia/Colombo", "1880-01-01" },
     691             :         { "Asia/Colombo", "1906-01-01" },
     692             :         { "Asia/Colombo", "1996-05-25" },
     693             :         { "Asia/Dacca", "1941-10-01" },
     694             :         { "Asia/Dacca", "1942-09-01" },
     695             :         { "Asia/Dhaka", "1941-10-01" },
     696             :         { "Asia/Dhaka", "1942-09-01" },
     697             :         { "Asia/Dili", "2000-09-17" },
     698             :         { "Asia/Dubai", "1920-01-01" },
     699             :         { "Asia/Dushanbe", "1924-05-02" },
     700             :         { "Asia/Dushanbe", "1930-06-21" },
     701             :         { "Asia/Harbin", "1928-01-01" },
     702             :         { "Asia/Harbin", "1940-01-01" },
     703             :         { "Asia/Ho_Chi_Minh", "1912-05-01" },
     704             :         { "Asia/Hong_Kong", "1904-10-30" },
     705             :         { "Asia/Hong_Kong", "1941-12-25" },
     706             :         { "Asia/Hovd", "1978-01-01" },
     707             :         { "Asia/Irkutsk", "1920-01-25" },
     708             :         { "Asia/Irkutsk", "1930-06-21" },
     709             :         { "Asia/Irkutsk", "1992-01-19" },
     710             :         { "Asia/Irkutsk", "2011-03-27" },
     711             :         { "Asia/Istanbul", "1880-01-01" },
     712             :         { "Asia/Istanbul", "1910-10-01" },
     713             :         { "Asia/Istanbul", "1978-10-15" },
     714             :         { "Asia/Jakarta", "1932-11-01" },
     715             :         { "Asia/Jakarta", "1942-03-23" },
     716             :         { "Asia/Jakarta", "1948-05-01" },
     717             :         { "Asia/Jayapura", "1944-09-01" },
     718             :         { "Asia/Kabul", "1945-01-01" },
     719             :         { "Asia/Kamchatka", "1922-11-10" },
     720             :         { "Asia/Kamchatka", "1930-06-21" },
     721             :         { "Asia/Kamchatka", "1992-01-19" },
     722             :         { "Asia/Kamchatka", "2011-03-27" },
     723             :         { "Asia/Karachi", "1907-01-01" },
     724             :         { "Asia/Kashgar", "1928-01-01" },
     725             :         { "Asia/Kashgar", "1980-05-01" },
     726             :         { "Asia/Kathmandu", "1986-01-01" },
     727             :         { "Asia/Katmandu", "1986-01-01" },
     728             :         { "Asia/Kolkata", "1941-10-01" },
     729             :         { "Asia/Krasnoyarsk", "1930-06-21" },
     730             :         { "Asia/Krasnoyarsk", "1992-01-19" },
     731             :         { "Asia/Krasnoyarsk", "2011-03-27" },
     732             :         { "Asia/Kuala_Lumpur", "1901-01-01" },
     733             :         { "Asia/Kuala_Lumpur", "1905-06-01" },
     734             :         { "Asia/Kuala_Lumpur", "1941-09-01" },
     735             :         { "Asia/Kuala_Lumpur", "1942-02-16" },
     736             :         { "Asia/Kuala_Lumpur", "1982-01-01" },
     737             :         { "Asia/Kuching", "1926-03-01" },
     738             :         { "Asia/Kuching", "1933-01-01" },
     739             :         { "Asia/Kuching", "1942-02-16" },
     740             :         { "Asia/Macao", "1912-01-01" },
     741             :         { "Asia/Macau", "1912-01-01" },
     742             :         { "Asia/Magadan", "1930-06-21" },
     743             :         { "Asia/Magadan", "1992-01-19" },
     744             :         { "Asia/Magadan", "2011-03-27" },
     745             :         { "Asia/Makassar", "1932-11-01" },
     746             :         { "Asia/Makassar", "1942-02-09" },
     747             :         { "Asia/Manila", "1942-05-01" },
     748             :         { "Asia/Muscat", "1920-01-01" },
     749             :         { "Asia/Novokuznetsk", "1920-01-06" },
     750             :         { "Asia/Novokuznetsk", "1930-06-21" },
     751             :         { "Asia/Novokuznetsk", "1992-01-19" },
     752             :         { "Asia/Novokuznetsk", "2011-03-27" },
     753             :         { "Asia/Novosibirsk", "1930-06-21" },
     754             :         { "Asia/Novosibirsk", "1992-01-19" },
     755             :         { "Asia/Novosibirsk", "2011-03-27" },
     756             :         { "Asia/Omsk", "1919-11-14" },
     757             :         { "Asia/Omsk", "1930-06-21" },
     758             :         { "Asia/Omsk", "1992-01-19" },
     759             :         { "Asia/Omsk", "2011-03-27" },
     760             :         { "Asia/Oral", "1924-05-02" },
     761             :         { "Asia/Oral", "1930-06-21" },
     762             :         { "Asia/Oral", "2005-03-15" },
     763             :         { "Asia/Phnom_Penh", "1906-06-09" },
     764             :         { "Asia/Phnom_Penh", "1912-05-01" },
     765             :         { "Asia/Pontianak", "1932-11-01" },
     766             :         { "Asia/Pontianak", "1942-01-29" },
     767             :         { "Asia/Pontianak", "1948-05-01" },
     768             :         { "Asia/Pontianak", "1964-01-01" },
     769             :         { "Asia/Pyongyang", "1890-01-01" },
     770             :         { "Asia/Pyongyang", "1904-12-01" },
     771             :         { "Asia/Pyongyang", "1932-01-01" },
     772             :         { "Asia/Pyongyang", "1961-08-10" },
     773             :         { "Asia/Qatar", "1920-01-01" },
     774             :         { "Asia/Qyzylorda", "1930-06-21" },
     775             :         { "Asia/Qyzylorda", "1992-01-19" },
     776             :         { "Asia/Rangoon", "1920-01-01" },
     777             :         { "Asia/Rangoon", "1942-05-01" },
     778             :         { "Asia/Saigon", "1912-05-01" },
     779             :         { "Asia/Sakhalin", "1945-08-25" },
     780             :         { "Asia/Sakhalin", "1992-01-19" },
     781             :         { "Asia/Sakhalin", "2011-03-27" },
     782             :         { "Asia/Samarkand", "1930-06-21" },
     783             :         { "Asia/Seoul", "1890-01-01" },
     784             :         { "Asia/Seoul", "1904-12-01" },
     785             :         { "Asia/Seoul", "1932-01-01" },
     786             :         { "Asia/Seoul", "1961-08-10" },
     787             :         { "Asia/Seoul", "1968-10-01" },
     788             :         { "Asia/Singapore", "1905-06-01" },
     789             :         { "Asia/Singapore", "1941-09-01" },
     790             :         { "Asia/Singapore", "1942-02-16" },
     791             :         { "Asia/Singapore", "1982-01-01" },
     792             :         { "Asia/Tashkent", "1924-05-02" },
     793             :         { "Asia/Tashkent", "1930-06-21" },
     794             :         { "Asia/Tbilisi", "1924-05-02" },
     795             :         { "Asia/Tbilisi", "1957-03-01" },
     796             :         { "Asia/Tbilisi", "2005-03-27" },
     797             :         { "Asia/Tehran", "1946-01-01" },
     798             :         { "Asia/Tehran", "1977-11-01" },
     799             :         { "Asia/Thimbu", "1987-10-01" },
     800             :         { "Asia/Thimphu", "1987-10-01" },
     801             :         { "Asia/Ujung_Pandang", "1932-11-01" },
     802             :         { "Asia/Ujung_Pandang", "1942-02-09" },
     803             :         { "Asia/Ulaanbaatar", "1978-01-01" },
     804             :         { "Asia/Ulan_Bator", "1978-01-01" },
     805             :         { "Asia/Urumqi", "1928-01-01" },
     806             :         { "Asia/Urumqi", "1980-05-01" },
     807             :         { "Asia/Vientiane", "1906-06-09" },
     808             :         { "Asia/Vientiane", "1912-05-01" },
     809             :         { "Asia/Vladivostok", "1922-11-15" },
     810             :         { "Asia/Vladivostok", "1930-06-21" },
     811             :         { "Asia/Vladivostok", "1992-01-19" },
     812             :         { "Asia/Vladivostok", "2011-03-27" },
     813             :         { "Asia/Yakutsk", "1930-06-21" },
     814             :         { "Asia/Yakutsk", "1992-01-19" },
     815             :         { "Asia/Yakutsk", "2011-03-27" },
     816             :         { "Asia/Yekaterinburg", "1930-06-21" },
     817             :         { "Asia/Yekaterinburg", "1992-01-19" },
     818             :         { "Asia/Yekaterinburg", "2011-03-27" },
     819             :         { "Asia/Yerevan", "1924-05-02" },
     820             :         { "Asia/Yerevan", "1957-03-01" },
     821             :         { "Atlantic/Azores", "1884-01-01" },
     822             :         { "Atlantic/Azores", "1911-05-24" },
     823             :         { "Atlantic/Cape_Verde", "1907-01-01" },
     824             :         { "Atlantic/Jan_Mayen", "1895-01-01" },
     825             :         { "Atlantic/Reykjavik", "1837-01-01" },
     826             :         { "Atlantic/Stanley", "1912-03-12" },
     827             :         { "Australia/Adelaide", "1899-05-01" },
     828             :         { "Australia/Broken_Hill", "1895-02-01" },
     829             :         { "Australia/Broken_Hill", "1899-05-01" },
     830             :         { "Australia/Currie", "1895-09-01" },
     831             :         { "Australia/Darwin", "1895-02-01" },
     832             :         { "Australia/Darwin", "1899-05-01" },
     833             :         { "Australia/Eucla", "1895-12-01" },
     834             :         { "Australia/Hobart", "1895-09-01" },
     835             :         { "Australia/LHI", "1981-03-01" },
     836             :         { "Australia/Lindeman", "1895-01-01" },
     837             :         { "Australia/Lord_Howe", "1981-03-01" },
     838             :         { "Australia/Melbourne", "1895-02-01" },
     839             :         { "Australia/North", "1895-02-01" },
     840             :         { "Australia/North", "1899-05-01" },
     841             :         { "Australia/Perth", "1895-12-01" },
     842             :         { "Australia/South", "1899-05-01" },
     843             :         { "Australia/Tasmania", "1895-09-01" },
     844             :         { "Australia/Victoria", "1895-02-01" },
     845             :         { "Australia/West", "1895-12-01" },
     846             :         { "Australia/Yancowinna", "1895-02-01" },
     847             :         { "Australia/Yancowinna", "1899-05-01" },
     848             :         { "Brazil/Acre", "1914-01-01" },
     849             :         { "Canada/East-Saskatchewan", "1905-09-01" },
     850             :         { "Canada/Saskatchewan", "1905-09-01" },
     851             :         { "Chile/Continental", "1910-01-01" },
     852             :         { "Chile/Continental", "1919-07-01" },
     853             :         { "Chile/EasterIsland", "1932-09-01" },
     854             :         { "Cuba", "1890-01-01" },
     855             :         { "Eire", "1880-08-02" },
     856             :         { "Europe/Amsterdam", "1937-07-01" },
     857             :         { "Europe/Andorra", "1946-09-30" },
     858             :         { "Europe/Athens", "1916-07-28" },
     859             :         { "Europe/Athens", "1944-04-04" },
     860             :         { "Europe/Berlin", "1893-04-01" },
     861             :         { "Europe/Bratislava", "1891-10-01" },
     862             :         { "Europe/Brussels", "1914-11-08" },
     863             :         { "Europe/Bucharest", "1931-07-24" },
     864             :         { "Europe/Chisinau", "1931-07-24" },
     865             :         { "Europe/Copenhagen", "1894-01-01" },
     866             :         { "Europe/Dublin", "1880-08-02" },
     867             :         { "Europe/Helsinki", "1921-05-01" },
     868             :         { "Europe/Istanbul", "1880-01-01" },
     869             :         { "Europe/Istanbul", "1910-10-01" },
     870             :         { "Europe/Istanbul", "1978-10-15" },
     871             :         { "Europe/Kaliningrad", "1945-01-01" },
     872             :         { "Europe/Kaliningrad", "1946-01-01" },
     873             :         { "Europe/Kaliningrad", "2011-03-27" },
     874             :         { "Europe/Kiev", "1930-06-21" },
     875             :         { "Europe/Kiev", "1943-11-06" },
     876             :         { "Europe/Luxembourg", "1904-06-01" },
     877             :         { "Europe/Malta", "1893-11-02" },
     878             :         { "Europe/Mariehamn", "1921-05-01" },
     879             :         { "Europe/Minsk", "1924-05-02" },
     880             :         { "Europe/Minsk", "1930-06-21" },
     881             :         { "Europe/Minsk", "2011-03-27" },
     882             :         { "Europe/Moscow", "1916-07-03" },
     883             :         { "Europe/Moscow", "1930-06-21" },
     884             :         { "Europe/Moscow", "1992-01-19" },
     885             :         { "Europe/Moscow", "2011-03-27" },
     886             :         { "Europe/Oslo", "1895-01-01" },
     887             :         { "Europe/Prague", "1891-10-01" },
     888             :         { "Europe/Riga", "1926-05-11" },
     889             :         { "Europe/Riga", "1940-08-05" },
     890             :         { "Europe/Riga", "1944-10-13" },
     891             :         { "Europe/Rome", "1893-11-01" },
     892             :         { "Europe/Samara", "1930-06-21" },
     893             :         { "Europe/Samara", "1991-10-20" },
     894             :         { "Europe/Samara", "2011-03-27" },
     895             :         { "Europe/San_Marino", "1893-11-01" },
     896             :         { "Europe/Simferopol", "1930-06-21" },
     897             :         { "Europe/Simferopol", "1994-05-01" },
     898             :         { "Europe/Sofia", "1880-01-01" },
     899             :         { "Europe/Sofia", "1894-11-30" },
     900             :         { "Europe/Tallinn", "1919-07-01" },
     901             :         { "Europe/Tallinn", "1921-05-01" },
     902             :         { "Europe/Tallinn", "1940-08-06" },
     903             :         { "Europe/Tiraspol", "1931-07-24" },
     904             :         { "Europe/Uzhgorod", "1945-06-29" },
     905             :         { "Europe/Vaduz", "1894-06-01" },
     906             :         { "Europe/Vatican", "1893-11-01" },
     907             :         { "Europe/Vilnius", "1917-01-01" },
     908             :         { "Europe/Vilnius", "1920-07-12" },
     909             :         { "Europe/Vilnius", "1940-08-03" },
     910             :         { "Europe/Volgograd", "1920-01-03" },
     911             :         { "Europe/Volgograd", "1930-06-21" },
     912             :         { "Europe/Volgograd", "1991-03-31" },
     913             :         { "Europe/Volgograd", "2011-03-27" },
     914             :         { "Europe/Zaporozhye", "1930-06-21" },
     915             :         { "Europe/Zaporozhye", "1943-10-25" },
     916             :         { "Europe/Zurich", "1894-06-01" },
     917             :         { "Hongkong", "1904-10-30" },
     918             :         { "Hongkong", "1941-12-25" },
     919             :         { "Iceland", "1837-01-01" },
     920             :         { "Indian/Chagos", "1907-01-01" },
     921             :         { "Indian/Chagos", "1996-01-01" },
     922             :         { "Indian/Cocos", "1900-01-01" },
     923             :         { "Indian/Comoro", "1911-07-01" },
     924             :         { "Indian/Kerguelen", "1950-01-01" },
     925             :         { "Indian/Mahe", "1906-06-01" },
     926             :         { "Indian/Maldives", "1960-01-01" },
     927             :         { "Indian/Mauritius", "1907-01-01" },
     928             :         { "Indian/Reunion", "1911-06-01" },
     929             :         { "Iran", "1946-01-01" },
     930             :         { "Iran", "1977-11-01" },
     931             :         { "Libya", "1920-01-01" },
     932             :         { "Libya", "1959-01-01" },
     933             :         { "Libya", "1990-05-04" },
     934             :         { "Mexico/BajaNorte", "1924-01-01" },
     935             :         { "Mexico/BajaNorte", "1930-11-15" },
     936             :         { "Mexico/BajaSur", "1930-11-15" },
     937             :         { "Mexico/BajaSur", "1931-10-01" },
     938             :         { "Mexico/BajaSur", "1942-04-24" },
     939             :         { "Mexico/BajaSur", "1949-01-14" },
     940             :         { "Mexico/General", "1930-11-15" },
     941             :         { "Mexico/General", "1931-10-01" },
     942             :         { "NZ-CHAT", "1957-01-01" },
     943             :         { "Pacific/Apia", "1911-01-01" },
     944             :         { "Pacific/Chatham", "1957-01-01" },
     945             :         { "Pacific/Easter", "1932-09-01" },
     946             :         { "Pacific/Enderbury", "1901-01-01" },
     947             :         { "Pacific/Fiji", "1915-10-26" },
     948             :         { "Pacific/Funafuti", "1901-01-01" },
     949             :         { "Pacific/Galapagos", "1986-01-01" },
     950             :         { "Pacific/Gambier", "1912-10-01" },
     951             :         { "Pacific/Guadalcanal", "1912-10-01" },
     952             :         { "Pacific/Guam", "1901-01-01" },
     953             :         { "Pacific/Kiritimati", "1901-01-01" },
     954             :         { "Pacific/Kosrae", "1901-01-01" },
     955             :         { "Pacific/Kosrae", "1969-10-01" },
     956             :         { "Pacific/Majuro", "1969-10-01" },
     957             :         { "Pacific/Marquesas", "1912-10-01" },
     958             :         { "Pacific/Nauru", "1921-01-15" },
     959             :         { "Pacific/Nauru", "1944-08-15" },
     960             :         { "Pacific/Nauru", "1979-05-01" },
     961             :         { "Pacific/Niue", "1901-01-01" },
     962             :         { "Pacific/Niue", "1951-01-01" },
     963             :         { "Pacific/Norfolk", "1901-01-01" },
     964             :         { "Pacific/Norfolk", "1951-01-01" },
     965             :         { "Pacific/Pago_Pago", "1911-01-01" },
     966             :         { "Pacific/Palau", "1901-01-01" },
     967             :         { "Pacific/Pohnpei", "1901-01-01" },
     968             :         { "Pacific/Ponape", "1901-01-01" },
     969             :         { "Pacific/Port_Moresby", "1895-01-01" },
     970             :         { "Pacific/Rarotonga", "1978-11-12" },
     971             :         { "Pacific/Saipan", "1969-10-01" },
     972             :         { "Pacific/Samoa", "1911-01-01" },
     973             :         { "Pacific/Tahiti", "1912-10-01" },
     974             :         { "Pacific/Tarawa", "1901-01-01" },
     975             :         { "Pacific/Tongatapu", "1901-01-01" },
     976             :         { "Pacific/Tongatapu", "1941-01-01" },
     977             :         { "Pacific/Wake", "1901-01-01" },
     978             :         { "ROK", "1890-01-01" },
     979             :         { "ROK", "1904-12-01" },
     980             :         { "ROK", "1932-01-01" },
     981             :         { "ROK", "1961-08-10" },
     982             :         { "ROK", "1968-10-01" },
     983             :         { "Singapore", "1905-06-01" },
     984             :         { "Singapore", "1941-09-01" },
     985             :         { "Singapore", "1942-02-16" },
     986             :         { "Singapore", "1982-01-01" },
     987             :         { "Turkey", "1880-01-01" },
     988             :         { "Turkey", "1910-10-01" },
     989             :         { "Turkey", "1978-10-15" },
     990             :         { "US/Michigan", "1905-01-01" },
     991             :         { "US/Samoa", "1911-01-01" },
     992             :         { "W-SU", "1916-07-03" },
     993             :         { "W-SU", "1930-06-21" },
     994             :         { "W-SU", "1992-01-19" },
     995             :         { "W-SU", "2011-03-27" }
     996           1 :     };
     997             : 
     998           1 :     LanguageType eLang = LANGUAGE_ENGLISH_US;
     999           1 :     SvNumberFormatter aFormatter(m_xContext, eLang);
    1000             : 
    1001         498 :     for (size_t i=0; i < SAL_N_ELEMENTS(aData); ++i)
    1002             :     {
    1003         497 :         checkDateInput( aFormatter, aData[i][0], aData[i][1]);
    1004           1 :     }
    1005           1 : }
    1006             : 
    1007         497 : void Test::checkDateInput( SvNumberFormatter& rFormatter, const char* pTimezone, const char* pIsoDate )
    1008             : {
    1009         497 :     icu::TimeZone::adoptDefault( icu::TimeZone::createTimeZone( pTimezone));
    1010         497 :     OUString aDate( OUString::createFromAscii(pIsoDate));
    1011         497 :     sal_uInt32 nIndex = 0;
    1012         497 :     double fVal = 0.0;
    1013         497 :     bool bVal = rFormatter.IsNumberFormat( aDate, nIndex, fVal);
    1014         497 :     CPPUNIT_ASSERT_MESSAGE("Date not recognized.", bVal);
    1015         994 :     CPPUNIT_ASSERT_MESSAGE("Format parsed is not date.",
    1016         497 :             (rFormatter.GetType(nIndex) & css::util::NumberFormat::DATE));
    1017         994 :     OUString aOutString;
    1018             :     Color *pColor;
    1019         497 :     rFormatter.GetOutputString( fVal, nIndex, aOutString, &pColor);
    1020         994 :     CPPUNIT_ASSERT_EQUAL( aDate, aOutString);
    1021         497 : }
    1022             : 
    1023           1 : void Test::testIsNumberFormat()
    1024             : {
    1025           1 :     LanguageType eLang = LANGUAGE_ENGLISH_US;
    1026           1 :     SvNumberFormatter aFormatter(m_xContext, eLang);
    1027             : 
    1028             :     struct NumberFormatData
    1029             :     {
    1030             :         const char* pFormat;
    1031             :         bool bIsNumber;
    1032             :     } aTests[] = {
    1033             :         { "20.3", true },
    1034             :         { "2", true },
    1035             :         { "test", false },
    1036             :         { "Jan1", false },
    1037             :         { "Jan1 2000", true },
    1038             :         { "Jan 1", true },
    1039             :         { "Jan 1 2000", true}
    1040           1 :     };
    1041             : 
    1042           8 :     for (size_t i = 0; i < SAL_N_ELEMENTS(aTests); ++i)
    1043             :     {
    1044           7 :         sal_uInt32 nIndex = 0;
    1045           7 :         double nNumber = 0;
    1046           7 :         OUString aString = OUString::createFromAscii(aTests[i].pFormat);
    1047           7 :         bool bIsNumber = aFormatter.IsNumberFormat(aString, nIndex, nNumber);
    1048           7 :         CPPUNIT_ASSERT_EQUAL(aTests[i].bIsNumber, bIsNumber);
    1049             : 
    1050           8 :     }
    1051           1 : }
    1052             : 
    1053           1 : CPPUNIT_TEST_SUITE_REGISTRATION(Test);
    1054             : 
    1055             : }
    1056             : 
    1057           4 : CPPUNIT_PLUGIN_IMPLEMENT();
    1058             : 
    1059             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11