]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/intltest/tufmtts.cpp
ICU-551.24.tar.gz
[apple/icu.git] / icuSources / test / intltest / tufmtts.cpp
index 20ffe253f27f064397dff584dd2835a47569b819..8ed9b9f7956a9f16c677bc46fe6bf54ef5a5e4ac 100644 (file)
@@ -12,6 +12,7 @@
 #include "unicode/tmutamt.h"
 #include "unicode/tmutfmt.h"
 #include "tufmtts.h"
+#include "cmemory.h"
 #include "unicode/ustring.h"
 
 //TODO: put as compilation flag
@@ -21,8 +22,6 @@
 #include <iostream>
 #endif
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 void TimeUnitTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ ) {
     if (exec) logln("TestSuite TimeUnitTest");
     switch (index) {
@@ -276,15 +275,18 @@ void TimeUnitTest::testGreekWithFallback() {
     const UChar oneMonth[] = {0x0031, 0x0020, 0x03bc, 0x03ae, 0x03bd, 0x03b1, 0x03c2, 0};
     const UChar oneMonthShort[] = {0x0031, 0x0020, 0x03bc, 0x03ae, 0x03bd, 0x002e, 0};
     const UChar oneYear[] = {0x0031, 0x0020, 0x03ad, 0x03c4, 0x03bf, 0x03c2, 0};
+    const UChar oneYearShort[] = {0x0031, 0x0020, 0x03ad, 0x03c4, 0x002e, 0};
     const UChar sevenSeconds[] = {0x0037, 0x0020, 0x03b4, 0x03b5, 0x03c5, 0x03c4, 0x03b5, 0x03c1, 0x03cc, 0x03bb, 0x03b5, 0x03c0, 0x03c4, 0x03b1, 0};
     const UChar sevenSecondsShort[] = {0x0037, 0x0020, 0x03b4, 0x03b5, 0x03c5, 0x03c4, 0x002e, 0};
     const UChar sevenMinutes[] = {0x0037, 0x0020, 0x03bb, 0x03b5, 0x03c0, 0x03c4, 0x03ac, 0};
     const UChar sevenMinutesShort[] = {0x0037, 0x0020, 0x03bb, 0x03b5, 0x03c0, 0x002e, 0};
     const UChar sevenHours[] = {0x0037, 0x0020, 0x03ce, 0x03c1, 0x03b5, 0x03c2, 0};
+    const UChar sevenHoursShort[] = {0x0037, 0x0020, 0x03ce, 0x03c1, 0x002e, 0};
     const UChar sevenDays[] = {0x0037, 0x0020, 0x03b7, 0x03bc, 0x03ad, 0x03c1, 0x03b5, 0x03c2, 0};
     const UChar sevenMonths[] = {0x0037, 0x0020, 0x03bc, 0x03ae, 0x03bd, 0x03b5, 0x3c2, 0};
     const UChar sevenMonthsShort[] = {0x0037, 0x0020, 0x03bc, 0x03ae, 0x03bd, 0x002e, 0};
     const UChar sevenYears[] = {0x0037, 0x0020, 0x03ad, 0x03c4, 0x03b7, 0};
+    const UChar sevenYearsShort[] = {0x0037, 0x0020, 0x03ad, 0x03c4, 0x002e, 0};
 
     const UnicodeString oneSecondStr(oneSecond);
     const UnicodeString oneSecondShortStr(oneSecondShort);
@@ -295,24 +297,29 @@ void TimeUnitTest::testGreekWithFallback() {
     const UnicodeString oneMonthStr(oneMonth);
     const UnicodeString oneMonthShortStr(oneMonthShort);
     const UnicodeString oneYearStr(oneYear);
+    const UnicodeString oneYearShortStr(oneYearShort);
     const UnicodeString sevenSecondsStr(sevenSeconds);
     const UnicodeString sevenSecondsShortStr(sevenSecondsShort);
     const UnicodeString sevenMinutesStr(sevenMinutes);
     const UnicodeString sevenMinutesShortStr(sevenMinutesShort);
     const UnicodeString sevenHoursStr(sevenHours);
+    const UnicodeString sevenHoursShortStr(sevenHoursShort);
     const UnicodeString sevenDaysStr(sevenDays);
     const UnicodeString sevenMonthsStr(sevenMonths);
     const UnicodeString sevenMonthsShortStr(sevenMonthsShort);
     const UnicodeString sevenYearsStr(sevenYears);
+    const UnicodeString sevenYearsShortStr(sevenYearsShort);
+
+    const UnicodeString expected[] = {
+            oneSecondStr, oneMinuteStr, oneHourStr, oneDayStr, oneMonthStr, oneYearStr,
+            oneSecondShortStr, oneMinuteShortStr, oneHourStr, oneDayStr, oneMonthShortStr, oneYearShortStr,
+            sevenSecondsStr, sevenMinutesStr, sevenHoursStr, sevenDaysStr, sevenMonthsStr, sevenYearsStr,
+            sevenSecondsShortStr, sevenMinutesShortStr, sevenHoursShortStr, sevenDaysStr, sevenMonthsShortStr, sevenYearsShortStr,
 
-    const UnicodeString expected[] = {oneSecondStr, oneMinuteStr, oneHourStr, oneDayStr, oneMonthStr, oneYearStr,
-                              oneSecondShortStr, oneMinuteShortStr, oneHourStr, oneDayStr, oneMonthShortStr, oneYearStr,
-                              sevenSecondsStr, sevenMinutesStr, sevenHoursStr, sevenDaysStr, sevenMonthsStr, sevenYearsStr,
-                              sevenSecondsShortStr, sevenMinutesShortStr, sevenHoursStr, sevenDaysStr, sevenMonthsShortStr, sevenYearsStr,
-                              oneSecondStr, oneMinuteStr, oneHourStr, oneDayStr, oneMonthStr, oneYearStr,
-                              oneSecondShortStr, oneMinuteShortStr, oneHourStr, oneDayStr, oneMonthShortStr, oneYearStr,
-                              sevenSecondsStr, sevenMinutesStr, sevenHoursStr, sevenDaysStr, sevenMonthsStr, sevenYearsStr,
-                              sevenSecondsShortStr, sevenMinutesShortStr, sevenHoursStr, sevenDaysStr, sevenMonthsShortStr, sevenYearsStr};
+            oneSecondStr, oneMinuteStr, oneHourStr, oneDayStr, oneMonthStr, oneYearStr,
+            oneSecondShortStr, oneMinuteShortStr, oneHourStr, oneDayStr, oneMonthShortStr, oneYearShortStr,
+            sevenSecondsStr, sevenMinutesStr, sevenHoursStr, sevenDaysStr, sevenMonthsStr, sevenYearsStr,
+            sevenSecondsShortStr, sevenMinutesShortStr, sevenHoursShortStr, sevenDaysStr, sevenMonthsShortStr, sevenYearsShortStr};
 
     int counter = 0;
     for ( unsigned int locIndex = 0;
@@ -422,8 +429,8 @@ void TimeUnitTest::test10219Plurals() {
         dataerrln("generating NumberFormat Object failed: %s", u_errorName(status));
         return;
     }
-    for (int32_t j = 0; j < LENGTHOF(values); ++j) {
-        for (int32_t i = 0; i < LENGTHOF(expected[j]); ++i) {
+    for (int32_t j = 0; j < UPRV_LENGTHOF(values); ++j) {
+        for (int32_t i = 0; i < UPRV_LENGTHOF(expected[j]); ++i) {
             nf->setMinimumFractionDigits(i);
             nf->setMaximumFractionDigits(i);
             nf->setRoundingMode(DecimalFormat::kRoundDown);
@@ -434,7 +441,8 @@ void TimeUnitTest::test10219Plurals() {
             }
             UnicodeString actual;
             Formattable fmt;
-            LocalPointer<TimeUnitAmount> tamt(new TimeUnitAmount(values[j], TimeUnit::UTIMEUNIT_MINUTE, status));
+            LocalPointer<TimeUnitAmount> tamt(
+                new TimeUnitAmount(values[j], TimeUnit::UTIMEUNIT_MINUTE, status), status);
             if (U_FAILURE(status)) {
                 dataerrln("generating TimeUnitAmount Object failed: %s", u_errorName(status));
                 return;