2000-01-15 02:00:06 +00:00
|
|
|
/********************************************************************
|
|
|
|
* COPYRIGHT:
|
|
|
|
* Copyright (c) 1997-1999, International Business Machines Corporation and
|
|
|
|
* others. All Rights Reserved.
|
|
|
|
********************************************************************/
|
1999-08-16 21:50:52 +00:00
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
#include "unicode/utypes.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
#include "tsdtfmsy.h"
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
#include "unicode/dtfmtsym.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
|
2000-08-23 19:11:16 +00:00
|
|
|
void IntlTestDateFormatSymbols::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
|
1999-08-16 21:50:52 +00:00
|
|
|
{
|
|
|
|
if (exec) logln("TestSuite DateFormatSymbols");
|
|
|
|
switch (index) {
|
|
|
|
case 0: name = "DateFormatSymbols test";
|
|
|
|
if (exec) {
|
|
|
|
logln("DateFormatSymbols test---"); logln("");
|
2000-08-23 19:11:16 +00:00
|
|
|
testSymbols(/*par*/);
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: name = "TestGetMonths";
|
|
|
|
if (exec) {
|
|
|
|
logln("TestGetMonths test---"); logln("");
|
|
|
|
TestGetMonths();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: name = ""; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test getMonths.
|
|
|
|
*/
|
|
|
|
void IntlTestDateFormatSymbols::TestGetMonths()
|
|
|
|
{
|
1999-10-07 00:07:53 +00:00
|
|
|
UErrorCode status = U_ZERO_ERROR;
|
1999-08-16 21:50:52 +00:00
|
|
|
int32_t cnt;
|
|
|
|
const UnicodeString* month;
|
|
|
|
DateFormatSymbols *symbol;
|
|
|
|
|
|
|
|
symbol=new DateFormatSymbols(Locale::getDefault(), status);
|
|
|
|
|
|
|
|
month=symbol->getMonths(cnt);
|
|
|
|
|
|
|
|
logln((UnicodeString)"size = " + cnt);
|
|
|
|
|
|
|
|
for (int32_t i=0; i<cnt; ++i)
|
|
|
|
{
|
|
|
|
logln(month[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
delete symbol;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test the API of DateFormatSymbols; primarily a simple get/set set.
|
|
|
|
*/
|
2000-08-23 19:11:16 +00:00
|
|
|
void IntlTestDateFormatSymbols::testSymbols(/* char *par */)
|
1999-08-16 21:50:52 +00:00
|
|
|
{
|
1999-10-07 00:07:53 +00:00
|
|
|
UErrorCode status = U_ZERO_ERROR;
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
DateFormatSymbols fr(Locale::FRENCH, status);
|
1999-10-18 22:48:32 +00:00
|
|
|
if(U_FAILURE(status)) {
|
1999-08-16 21:50:52 +00:00
|
|
|
errln("ERROR: Couldn't create French DateFormatSymbols");
|
|
|
|
}
|
|
|
|
|
1999-10-07 00:07:53 +00:00
|
|
|
status = U_ZERO_ERROR;
|
1999-08-16 21:50:52 +00:00
|
|
|
DateFormatSymbols en(Locale::ENGLISH, status);
|
1999-10-18 22:48:32 +00:00
|
|
|
if(U_FAILURE(status)) {
|
1999-08-16 21:50:52 +00:00
|
|
|
errln("ERROR: Couldn't create English DateFormatSymbols");
|
|
|
|
}
|
|
|
|
|
|
|
|
if(en == fr || ! (en != fr) ) {
|
|
|
|
errln("ERROR: English DateFormatSymbols equal to French");
|
|
|
|
}
|
|
|
|
|
|
|
|
// just do some VERY basic tests to make sure that get/set work
|
|
|
|
|
|
|
|
int32_t count = 0;
|
|
|
|
const UnicodeString *eras = en.getEras(count);
|
|
|
|
fr.setEras(eras, count);
|
|
|
|
if( *en.getEras(count) != *fr.getEras(count)) {
|
|
|
|
errln("ERROR: setEras() failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
const UnicodeString *months = en.getMonths(count);
|
|
|
|
fr.setMonths(months, count);
|
|
|
|
if( *en.getMonths(count) != *fr.getMonths(count)) {
|
|
|
|
errln("ERROR: setMonths() failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
const UnicodeString *shortMonths = en.getShortMonths(count);
|
|
|
|
fr.setShortMonths(shortMonths, count);
|
|
|
|
if( *en.getShortMonths(count) != *fr.getShortMonths(count)) {
|
|
|
|
errln("ERROR: setShortMonths() failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
const UnicodeString *weekdays = en.getWeekdays(count);
|
|
|
|
fr.setWeekdays(weekdays, count);
|
|
|
|
if( *en.getWeekdays(count) != *fr.getWeekdays(count)) {
|
|
|
|
errln("ERROR: setWeekdays() failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
const UnicodeString *shortWeekdays = en.getShortWeekdays(count);
|
|
|
|
fr.setShortWeekdays(shortWeekdays, count);
|
|
|
|
if( *en.getShortWeekdays(count) != *fr.getShortWeekdays(count)) {
|
|
|
|
errln("ERROR: setShortWeekdays() failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
const UnicodeString *ampms = en.getAmPmStrings(count);
|
|
|
|
fr.setAmPmStrings(ampms, count);
|
|
|
|
if( *en.getAmPmStrings(count) != *fr.getAmPmStrings(count)) {
|
|
|
|
errln("ERROR: setAmPmStrings() failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t rowCount = 0, columnCount = 0;
|
|
|
|
const UnicodeString **strings = en.getZoneStrings(rowCount, columnCount);
|
|
|
|
fr.setZoneStrings(strings, rowCount, columnCount);
|
|
|
|
const UnicodeString **strings1 = fr.getZoneStrings(rowCount, columnCount);
|
|
|
|
for(int32_t i = 0; i < rowCount; i++) {
|
|
|
|
for(int32_t j = 0; j < columnCount; j++) {
|
|
|
|
if( strings[i][j] != strings1[i][j] ) {
|
|
|
|
errln("ERROR: setZoneStrings() failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const UnicodeString pattern = DateFormatSymbols::getPatternChars();
|
|
|
|
|
|
|
|
UnicodeString localPattern, pat1, pat2;
|
|
|
|
localPattern = en.getLocalPatternChars(localPattern);
|
|
|
|
fr.setLocalPatternChars(localPattern);
|
|
|
|
if( en.getLocalPatternChars(pat1) != fr.getLocalPatternChars(pat2)) {
|
|
|
|
errln("ERROR: setLocalPatternChars() failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-07 00:07:53 +00:00
|
|
|
status = U_ZERO_ERROR;
|
1999-08-16 21:50:52 +00:00
|
|
|
DateFormatSymbols foo(status);
|
|
|
|
DateFormatSymbols bar(foo);
|
|
|
|
|
|
|
|
en = fr;
|
|
|
|
|
|
|
|
if(en != fr || foo != bar) {
|
|
|
|
errln("ERROR: Copy Constructor or Assignment failed");
|
|
|
|
}
|
|
|
|
}
|