1 /********************************************************************
3 * Copyright (c) 1997-2003, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
7 #include "unicode/utypes.h"
9 #if !UCONFIG_NO_FORMATTING
13 #include "unicode/dtfmtsym.h"
16 void IntlTestDateFormatSymbols::runIndexedTest( int32_t index
, UBool exec
, const char* &name
, char* /*par*/ )
18 if (exec
) logln("TestSuite DateFormatSymbols");
20 case 0: name
= "DateFormatSymbols test";
22 logln("DateFormatSymbols test---"); logln("");
27 case 1: name
= "TestGetMonths";
29 logln("TestGetMonths test---"); logln("");
34 default: name
= ""; break;
41 void IntlTestDateFormatSymbols::TestGetMonths()
43 UErrorCode status
= U_ZERO_ERROR
;
45 const UnicodeString
* month
;
46 DateFormatSymbols
*symbol
;
48 symbol
=new DateFormatSymbols(Locale::getDefault(), status
);
50 month
=symbol
->getMonths(cnt
);
52 logln((UnicodeString
)"size = " + cnt
);
54 for (int32_t i
=0; i
<cnt
; ++i
)
63 * Test the API of DateFormatSymbols; primarily a simple get/set set.
65 void IntlTestDateFormatSymbols::testSymbols(/* char *par */)
67 UErrorCode status
= U_ZERO_ERROR
;
69 DateFormatSymbols
fr(Locale::getFrench(), status
);
70 if(U_FAILURE(status
)) {
71 errln("ERROR: Couldn't create French DateFormatSymbols " + (UnicodeString
)u_errorName(status
));
74 status
= U_ZERO_ERROR
;
75 DateFormatSymbols
en(Locale::getEnglish(), status
);
76 if(U_FAILURE(status
)) {
77 errln("ERROR: Couldn't create English DateFormatSymbols " + (UnicodeString
)u_errorName(status
));
80 if(en
== fr
|| ! (en
!= fr
) ) {
81 errln("ERROR: English DateFormatSymbols equal to French");
84 // just do some VERY basic tests to make sure that get/set work
87 const UnicodeString
*eras
= en
.getEras(count
);
89 errln("ERROR: 0 english eras.. exitting..\n");
93 fr
.setEras(eras
, count
);
94 if( *en
.getEras(count
) != *fr
.getEras(count
)) {
95 errln("ERROR: setEras() failed");
98 const UnicodeString
*months
= en
.getMonths(count
);
99 fr
.setMonths(months
, count
);
100 if( *en
.getMonths(count
) != *fr
.getMonths(count
)) {
101 errln("ERROR: setMonths() failed");
104 const UnicodeString
*shortMonths
= en
.getShortMonths(count
);
105 fr
.setShortMonths(shortMonths
, count
);
106 if( *en
.getShortMonths(count
) != *fr
.getShortMonths(count
)) {
107 errln("ERROR: setShortMonths() failed");
110 const UnicodeString
*weekdays
= en
.getWeekdays(count
);
111 fr
.setWeekdays(weekdays
, count
);
112 if( *en
.getWeekdays(count
) != *fr
.getWeekdays(count
)) {
113 errln("ERROR: setWeekdays() failed");
116 const UnicodeString
*shortWeekdays
= en
.getShortWeekdays(count
);
117 fr
.setShortWeekdays(shortWeekdays
, count
);
118 if( *en
.getShortWeekdays(count
) != *fr
.getShortWeekdays(count
)) {
119 errln("ERROR: setShortWeekdays() failed");
122 const UnicodeString
*ampms
= en
.getAmPmStrings(count
);
123 fr
.setAmPmStrings(ampms
, count
);
124 if( *en
.getAmPmStrings(count
) != *fr
.getAmPmStrings(count
)) {
125 errln("ERROR: setAmPmStrings() failed");
128 int32_t rowCount
= 0, columnCount
= 0;
129 const UnicodeString
**strings
= en
.getZoneStrings(rowCount
, columnCount
);
130 fr
.setZoneStrings(strings
, rowCount
, columnCount
);
131 const UnicodeString
**strings1
= fr
.getZoneStrings(rowCount
, columnCount
);
132 for(int32_t i
= 0; i
< rowCount
; i
++) {
133 for(int32_t j
= 0; j
< columnCount
; j
++) {
134 if( strings
[i
][j
] != strings1
[i
][j
] ) {
135 errln("ERROR: setZoneStrings() failed");
141 UnicodeString localPattern
, pat1
, pat2
;
142 localPattern
= en
.getLocalPatternChars(localPattern
);
143 fr
.setLocalPatternChars(localPattern
);
144 if( en
.getLocalPatternChars(pat1
) != fr
.getLocalPatternChars(pat2
)) {
145 errln("ERROR: setLocalPatternChars() failed");
149 status
= U_ZERO_ERROR
;
150 DateFormatSymbols
foo(status
);
151 DateFormatSymbols
bar(foo
);
155 if(en
!= fr
|| foo
!= bar
) {
156 errln("ERROR: Copy Constructor or Assignment failed");
160 #endif /* #if !UCONFIG_NO_FORMATTING */