]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/intltest/caltest.cpp
ICU-66108.tar.gz
[apple/icu.git] / icuSources / test / intltest / caltest.cpp
index 774b1c57949d17e1dca89cb4ac1bd546fbe394ea..8a2a31ac6bb1fdb53863c5a1493adb42ffd5a96a 100644 (file)
 
 #define mkcstr(U) u_austrcpy(calloc(8, u_strlen(U) + 1), U)
 
-#define TEST_CHECK_STATUS { \
+#define TEST_CHECK_STATUS UPRV_BLOCK_MACRO_BEGIN { \
     if (U_FAILURE(status)) { \
         if (status == U_MISSING_RESOURCE_ERROR) { \
             dataerrln("%s:%d: Test failure.  status=%s", __FILE__, __LINE__, u_errorName(status)); \
         } else { \
             errln("%s:%d: Test failure.  status=%s", __FILE__, __LINE__, u_errorName(status)); \
-        } return;}}
+        } \
+        return; \
+    } \
+} UPRV_BLOCK_MACRO_END
 
-#define TEST_CHECK_STATUS_LOCALE(testlocale) { \
+#define TEST_CHECK_STATUS_LOCALE(testlocale) UPRV_BLOCK_MACRO_BEGIN { \
     if (U_FAILURE(status)) { \
         if (status == U_MISSING_RESOURCE_ERROR) { \
             dataerrln("%s:%d: Test failure, locale %s.  status=%s", __FILE__, __LINE__, testlocale, u_errorName(status)); \
         } else { \
             errln("%s:%d: Test failure, locale %s.  status=%s", __FILE__, __LINE__, testlocale, u_errorName(status)); \
-        } return;}}
+        } \
+        return; \
+    } \
+} UPRV_BLOCK_MACRO_END
 
-#define TEST_ASSERT(expr) {if ((expr)==FALSE) {errln("%s:%d: Test failure \n", __FILE__, __LINE__);};}
+#define TEST_ASSERT(expr) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((expr)==FALSE) { \
+        errln("%s:%d: Test failure \n", __FILE__, __LINE__); \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 // *****************************************************************************
 // class CalendarTest
@@ -344,7 +354,7 @@ void CalendarTest::runIndexedTest( int32_t index, UBool exec, const char* &name,
 
 UnicodeString CalendarTest::fieldName(UCalendarDateFields f) {
     switch (f) {
-#define FIELD_NAME_STR(x) case x: return (#x+5)
+#define FIELD_NAME_STR(x) case x: return (#x)+5
       FIELD_NAME_STR( UCAL_ERA );
       FIELD_NAME_STR( UCAL_YEAR );
       FIELD_NAME_STR( UCAL_MONTH );
@@ -740,7 +750,7 @@ CalendarTest::TestClonesUnique908()
     UErrorCode status = U_ZERO_ERROR;
     Calendar *c = Calendar::createInstance(status);
     if (failure(status, "Calendar::createInstance", TRUE)) return;
-    Calendar *d = (Calendar*) c->clone();
+    Calendar *d = c->clone();
     c->set(UCAL_MILLISECOND, 123);
     d->set(UCAL_MILLISECOND, 456);
     if (c->get(UCAL_MILLISECOND, status) != 123 ||
@@ -1110,7 +1120,11 @@ CalendarTest::TestAddRollExtensive()
         status = U_ZERO_ERROR;
         for (i = 0; i < limit; i++) {
             temp->add(e, 1, status);
-            if (U_FAILURE(status)) { limit = i; status = U_ZERO_ERROR; }
+            if (U_FAILURE(status)) {
+                limit = i;
+                status = U_ZERO_ERROR;
+                break;      // Suppress compile warning. Shouldn't be necessary, but it is.
+            }
         }
         for (i = 0; i < limit; i++) {
             temp->add(e, -1, status);
@@ -1718,7 +1732,7 @@ void
 CalendarTest::marchByDelta(Calendar* cal, int32_t delta)
 {
     UErrorCode status = U_ZERO_ERROR;
-    Calendar *cur = (Calendar*) cal->clone();
+    Calendar *cur = cal->clone();
     int32_t initialDOW = cur->get(UCAL_DAY_OF_WEEK, status);
     if (U_FAILURE(status)) { errln("Calendar::get failed"); return; }
     int32_t DOW, newDOW = initialDOW;
@@ -1743,11 +1757,12 @@ CalendarTest::marchByDelta(Calendar* cal, int32_t delta)
     delete cur;
 }
 
-#define CHECK(status, msg) \
+#define CHECK(status, msg) UPRV_BLOCK_MACRO_BEGIN { \
     if (U_FAILURE(status)) { \
         errcheckln(status, msg); \
         return; \
-    }
+    } \
+} UPRV_BLOCK_MACRO_END
 
 void CalendarTest::TestWOY(void) {
     /*
@@ -2169,7 +2184,7 @@ int32_t CalendarTest::testLocaleCount()
   if(gLocaleCount < 0) {
     int32_t i;
     for(i=0;testLocaleID(i) != NULL;i++) {
-      ;
+      // do nothing
     }
     gLocaleCount = i;
   }