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