]> granicus.if.org Git - icu/commitdiff
ICU-20601 Wrap ICU test compound macros in do { } while.
authorFredrik Roubert <roubert@google.com>
Wed, 14 Aug 2019 21:06:44 +0000 (23:06 +0200)
committerFredrik Roubert <fredrik@roubert.name>
Thu, 15 Aug 2019 20:01:42 +0000 (22:01 +0200)
This does the same for the ICU test code as was done for the
public ICU API in commit 480bec3ea652886f46d4afad0d7446542d2fbf05.

45 files changed:
icu4c/source/test/cintltst/bocu1tst.c
icu4c/source/test/cintltst/cbiapts.c
icu4c/source/test/cintltst/cbiditst.c
icu4c/source/test/cintltst/crestst.c
icu4c/source/test/cintltst/creststn.c
icu4c/source/test/cintltst/hpmufn.c
icu4c/source/test/cintltst/reapits.c
icu4c/source/test/cintltst/spooftest.c
icu4c/source/test/cintltst/tracetst.c
icu4c/source/test/cintltst/usrchtst.c
icu4c/source/test/cintltst/utexttst.c
icu4c/source/test/cintltst/utf8tst.c
icu4c/source/test/intltest/alphaindextst.cpp
icu4c/source/test/intltest/astrotst.cpp
icu4c/source/test/intltest/caltest.cpp
icu4c/source/test/intltest/csdetest.cpp
icu4c/source/test/intltest/dcfmapts.cpp
icu4c/source/test/intltest/dcfmtest.cpp
icu4c/source/test/intltest/dtfmttst.cpp
icu4c/source/test/intltest/incaltst.cpp
icu4c/source/test/intltest/intltest.h
icu4c/source/test/intltest/itspoof.cpp
icu4c/source/test/intltest/locnmtst.cpp
icu4c/source/test/intltest/loctest.cpp
icu4c/source/test/intltest/numbertest_api.cpp
icu4c/source/test/intltest/numfmtst.cpp
icu4c/source/test/intltest/numrgts.cpp
icu4c/source/test/intltest/rbbiapts.cpp
icu4c/source/test/intltest/rbbimonkeytest.cpp
icu4c/source/test/intltest/rbbitst.cpp
icu4c/source/test/intltest/regextst.cpp
icu4c/source/test/intltest/restest.cpp
icu4c/source/test/intltest/restsnew.cpp
icu4c/source/test/intltest/selfmts.cpp
icu4c/source/test/intltest/ssearch.cpp
icu4c/source/test/intltest/transapi.cpp
icu4c/source/test/intltest/transrt.cpp
icu4c/source/test/intltest/transtst.cpp
icu4c/source/test/intltest/uobjtest.cpp
icu4c/source/test/intltest/usettest.cpp
icu4c/source/test/intltest/utxttest.cpp
icu4c/source/test/intltest/uvectest.cpp
icu4c/source/test/intltest/v32test.cpp
icu4c/source/test/iotest/filetst.c
icu4c/source/test/iotest/strtst.c

index a8edc18014db1f7c2a8e5a39264f092929141787..edfe65002a63ad8d842bb501985ca92c94f87493 100644 (file)
@@ -212,14 +212,14 @@ bocu1TrailToByte[BOCU1_TRAIL_CONTROLS_COUNT]={
  * @param d Divisor.
  * @param m Output variable for the rest (modulo result).
  */
-#define NEGDIVMOD(n, d, m) { \
+#define NEGDIVMOD(n, d, m) UPRV_BLOCK_MACRO_BEGIN { \
     (m)=(n)%(d); \
     (n)/=(d); \
     if((m)<0) { \
         --(n); \
         (m)+=(d); \
     } \
-}
+} UPRV_BLOCK_MACRO_END
 
 /* State for BOCU-1 decoder function. */
 struct Bocu1Rx {
index c3464f2ae6906718eb0e70ece2e536708f5be5da..2e7404a356edd0d5ce87bb87404c9222e7227592 100644 (file)
 #include "cbiapts.h"
 #include "cmemory.h"
 
-#define TEST_ASSERT_SUCCESS(status) {if (U_FAILURE(status)) { \
-log_data_err("Failure at file %s, line %d, error = %s (Are you missing data?)\n", __FILE__, __LINE__, u_errorName(status));}}
-
-#define TEST_ASSERT(expr) {if ((expr)==FALSE) { \
-log_data_err("Test Failure at file %s, line %d (Are you missing data?)\n", __FILE__, __LINE__);}}
+#define TEST_ASSERT_SUCCESS(status) UPRV_BLOCK_MACRO_BEGIN { \
+    if (U_FAILURE(status)) { \
+        log_data_err("Failure at file %s, line %d, error = %s (Are you missing data?)\n", __FILE__, __LINE__, u_errorName(status)); \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define TEST_ASSERT(expr) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((expr)==FALSE) { \
+        log_data_err("Test Failure at file %s, line %d (Are you missing data?)\n", __FILE__, __LINE__); \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 #if !UCONFIG_NO_FILE_IO
 static void TestBreakIteratorSafeClone(void);
index 558f2a3636374abefe18e8ba553799916fb70f25..e183b913000b28a57e203b584c444abc7f73d8e7 100644 (file)
@@ -1287,11 +1287,12 @@ _testReordering(UBiDi *pBiDi, int testNumber) {
     }
 }
 
-#define RETURN_IF_BAD_ERRCODE(x)    \
+#define RETURN_IF_BAD_ERRCODE(x) UPRV_BLOCK_MACRO_BEGIN { \
     if (U_FAILURE(errorCode)) {      \
         log_err("\nbad errorCode %d at %s\n", errorCode, (x));  \
         return;     \
     }               \
+} UPRV_BLOCK_MACRO_END
 
 #define STRING_TEST_CASE(s) { (s), UPRV_LENGTHOF(s) }
 
index ab35e40e9edd27e1bcd9e13c88e53897337240b7..b7af6eacd7f049b786e37abf8e4637e7f8fea390 100644 (file)
@@ -55,9 +55,23 @@ enum E_Where
 typedef enum E_Where E_Where;
 /*****************************************************************************/
 
-#define CONFIRM_EQ(actual,expected) if (u_strcmp(expected,actual)==0){ record_pass(); } else { record_fail(); log_err("%s  returned  %s  instead of %s\n", action, austrdup(actual), austrdup(expected)); }
-
-#define CONFIRM_ErrorCode(actual,expected) if ((expected)==(actual)) { record_pass(); } else { record_fail();  log_err("%s returned  %s  instead of %s\n", action, myErrorName(actual), myErrorName(expected)); }
+#define CONFIRM_EQ(actual,expected) UPRV_BLOCK_MACRO_BEGIN { \
+    if (u_strcmp(expected,actual)==0) { \
+        record_pass(); \
+    } else { \
+        record_fail(); \
+        log_err("%s  returned  %s  instead of %s\n", action, austrdup(actual), austrdup(expected)); \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define CONFIRM_ErrorCode(actual,expected) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((expected)==(actual)) { \
+        record_pass(); \
+    } else { \
+        record_fail(); \
+        log_err("%s returned  %s  instead of %s\n", action, myErrorName(actual), myErrorName(expected)); \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 
 /* Array of our test objects */
index e56c91da9d4604dab6a9d15d7ac321965b2f7860..23a6fe8ccf06ff28c86d5ca242f25ce7b23b786b 100644 (file)
@@ -132,10 +132,38 @@ enum E_Where
 typedef enum E_Where E_Where;
 /*****************************************************************************/
 
-#define CONFIRM_EQ(actual,expected) if (u_strcmp(expected,actual)==0){ record_pass(); } else { record_fail(); log_err("%s  returned  %s  instead of %s\n", action, austrdup(actual), austrdup(expected)); }
-#define CONFIRM_INT_EQ(actual,expected) if ((expected)==(actual)) { record_pass(); } else { record_fail(); log_err("%s returned %d instead of %d\n",  action, actual, expected); }
-#define CONFIRM_INT_GE(actual,expected) if ((actual)>=(expected)) { record_pass(); } else { record_fail(); log_err("%s returned %d instead of x >= %d\n",  action, actual, expected); }
-#define CONFIRM_INT_NE(actual,expected) if ((expected)!=(actual)) { record_pass(); } else { record_fail(); log_err("%s returned %d instead of x != %d\n",  action, actual, expected); }
+#define CONFIRM_EQ(actual,expected) UPRV_BLOCK_MACRO_BEGIN { \
+    if (u_strcmp(expected,actual)==0) { \
+        record_pass(); \
+    } else { \
+        record_fail(); \
+        log_err("%s  returned  %s  instead of %s\n", action, austrdup(actual), austrdup(expected)); \
+    } \
+} UPRV_BLOCK_MACRO_END
+#define CONFIRM_INT_EQ(actual,expected) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((expected)==(actual)) { \
+        record_pass(); \
+    } else { \
+        record_fail(); \
+        log_err("%s returned %d instead of %d\n",  action, actual, expected); \
+    } \
+} UPRV_BLOCK_MACRO_END
+#define CONFIRM_INT_GE(actual,expected) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((actual)>=(expected)) { \
+        record_pass(); \
+    } else { \
+        record_fail(); \
+        log_err("%s returned %d instead of x >= %d\n",  action, actual, expected); \
+    } \
+} UPRV_BLOCK_MACRO_END
+#define CONFIRM_INT_NE(actual,expected) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((expected)!=(actual)) { \
+        record_pass(); \
+    } else { \
+        record_fail(); \
+        log_err("%s returned %d instead of x != %d\n",  action, actual, expected); \
+    } \
+} UPRV_BLOCK_MACRO_END
 /*#define CONFIRM_ErrorCode(actual,expected) if ((expected)==(actual)) { record_pass(); } else { record_fail();  log_err("%s returned  %s  instead of %s\n", action, myErrorName(actual), myErrorName(expected)); } */
 static void 
 CONFIRM_ErrorCode(UErrorCode actual,UErrorCode expected) 
index f9ecc9b213c240e6126efc3bc4135c6377db9771..15ee5b4120c5fa9bfc27bb1c8646a3164cb01517 100644 (file)
@@ -42,17 +42,20 @@ addHeapMutexTest(TestNode** root)
 
 static int32_t gMutexFailures = 0;
 
-#define TEST_STATUS(status, expected) \
-if (status != expected) { \
-log_err_status(status, "FAIL at  %s:%d. Actual status = \"%s\";  Expected status = \"%s\"\n", \
-  __FILE__, __LINE__, u_errorName(status), u_errorName(expected)); gMutexFailures++; }
-
-
-#define TEST_ASSERT(expr) \
-if (!(expr)) { \
-    log_err("FAILED Assertion \"" #expr "\" at  %s:%d.\n", __FILE__, __LINE__); \
-    gMutexFailures++; \
-}
+#define TEST_STATUS(status, expected) UPRV_BLOCK_MACRO_BEGIN { \
+    if (status != expected) { \
+        log_err_status(status, "FAIL at  %s:%d. Actual status = \"%s\";  Expected status = \"%s\"\n", \
+                       __FILE__, __LINE__, u_errorName(status), u_errorName(expected)); gMutexFailures++; \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+
+#define TEST_ASSERT(expr) UPRV_BLOCK_MACRO_BEGIN { \
+    if (!(expr)) { \
+        log_err("FAILED Assertion \"" #expr "\" at  %s:%d.\n", __FILE__, __LINE__); \
+        gMutexFailures++; \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 
 /*  These tests do cleanup and reinitialize ICU in the course of their operation.
index 0553276c22460f662d9f89d95e27ba634f17aba3..73bc59a00f8cc0d5a0f9725a04f50207d4f80ffa 100644 (file)
 #include "cintltst.h"
 #include "cmemory.h"
 
-#define TEST_ASSERT_SUCCESS(status) {if (U_FAILURE(status)) { \
-log_data_err("Failure at file %s:%d - error = %s (Are you missing data?)\n", __FILE__, __LINE__, u_errorName(status));}}
-
-#define TEST_ASSERT(expr) {if ((expr)==FALSE) { \
-log_err("Test Failure at file %s:%d - ASSERT(%s) failed.\n", __FILE__, __LINE__, #expr);}}
+#define TEST_ASSERT_SUCCESS(status) UPRV_BLOCK_MACRO_BEGIN { \
+    if (U_FAILURE(status)) { \
+        log_data_err("Failure at file %s:%d - error = %s (Are you missing data?)\n", __FILE__, __LINE__, u_errorName(status)); \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define TEST_ASSERT(expr) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((expr)==FALSE) { \
+        log_err("Test Failure at file %s:%d - ASSERT(%s) failed.\n", __FILE__, __LINE__, #expr); \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 /*
  *   TEST_SETUP and TEST_TEARDOWN
@@ -50,7 +56,7 @@ log_err("Test Failure at file %s:%d - ASSERT(%s) failed.\n", __FILE__, __LINE__,
  *         Put arbitrary test code between SETUP and TEARDOWN.
  *         're" is the compiled, ready-to-go  regular expression.
  */
-#define TEST_SETUP(pattern, testString, flags)  \
+#define TEST_SETUP(pattern, testString, flags) UPRV_BLOCK_MACRO_BEGIN { \
     UChar   *srcString = NULL;  \
     status = U_ZERO_ERROR; \
     re = uregex_openC(pattern, flags, NULL, &status);  \
@@ -60,14 +66,15 @@ log_err("Test Failure at file %s:%d - ASSERT(%s) failed.\n", __FILE__, __LINE__,
     u_uastrncpy(srcString, testString, testStringLen + 1); \
     uregex_setText(re, srcString, -1, &status); \
     TEST_ASSERT_SUCCESS(status);  \
-    if (U_SUCCESS(status)) {
-    
+    if (U_SUCCESS(status)) { \
+        UPRV_BLOCK_MACRO_BEGIN {} UPRV_BLOCK_MACRO_END
+
 #define TEST_TEARDOWN  \
     }  \
     TEST_ASSERT_SUCCESS(status);  \
     uregex_close(re);  \
     free(srcString);   \
-    }
+} UPRV_BLOCK_MACRO_END
 
 
 /**
index d5573ba7f0a450a2f1e5ffdbdcf6688e01500e80..c6ddbe09542d3a1adabfb803e6c132cbf57c8e39 100644 (file)
 #include "cintltst.h"
 #include "cmemory.h"
 
-#define TEST_ASSERT_SUCCESS(status) {if (U_FAILURE(status)) { \
-    log_err_status(status, "Failure at file %s, line %d, error = %s\n", __FILE__, __LINE__, u_errorName(status));}}
-
-#define TEST_ASSERT(expr) {if ((expr)==FALSE) { \
-log_err("Test Failure at file %s, line %d: \"%s\" is false.\n", __FILE__, __LINE__, #expr);}}
-
-#define TEST_ASSERT_EQ(a, b) { if ((a) != (b)) { \
-    log_err("Test Failure at file %s, line %d: \"%s\" (%d) != \"%s\" (%d) \n", \
-             __FILE__, __LINE__, #a, (a), #b, (b)); }}
-
-#define TEST_ASSERT_NE(a, b) { if ((a) == (b)) { \
-    log_err("Test Failure at file %s, line %d: \"%s\" (%d) == \"%s\" (%d) \n", \
-             __FILE__, __LINE__, #a, (a), #b, (b)); }}
+#define TEST_ASSERT_SUCCESS(status) UPRV_BLOCK_MACRO_BEGIN { \
+    if (U_FAILURE(status)) { \
+        log_err_status(status, "Failure at file %s, line %d, error = %s\n", __FILE__, __LINE__, u_errorName(status)); \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define TEST_ASSERT(expr) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((expr)==FALSE) { \
+        log_err("Test Failure at file %s, line %d: \"%s\" is false.\n", __FILE__, __LINE__, #expr); \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define TEST_ASSERT_EQ(a, b) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((a) != (b)) { \
+        log_err("Test Failure at file %s, line %d: \"%s\" (%d) != \"%s\" (%d) \n", \
+                __FILE__, __LINE__, #a, (a), #b, (b)); \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define TEST_ASSERT_NE(a, b) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((a) == (b)) { \
+        log_err("Test Failure at file %s, line %d: \"%s\" (%d) == \"%s\" (%d) \n", \
+                __FILE__, __LINE__, #a, (a), #b, (b)); \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 
 /*
@@ -52,7 +64,7 @@ log_err("Test Failure at file %s, line %d: \"%s\" is false.\n", __FILE__, __LINE
  *         Put arbitrary test code between SETUP and TEARDOWN.
  *         "sc" is the ready-to-go  SpoofChecker for use in the tests.
  */
-#define TEST_SETUP  \
+#define TEST_SETUP UPRV_BLOCK_MACRO_BEGIN { \
     UErrorCode status = U_ZERO_ERROR; \
     USpoofChecker *sc;     \
     sc = uspoof_open(&status);  \
@@ -63,7 +75,7 @@ log_err("Test Failure at file %s, line %d: \"%s\" is false.\n", __FILE__, __LINE
     }  \
     TEST_ASSERT_SUCCESS(status);  \
     uspoof_close(sc);  \
-}
+} UPRV_BLOCK_MACRO_END
 
 static void TestOpenFromSource(void);
 static void TestUSpoofCAPI(void);
index 28b9b04e06095b2f33da29a1f5a15e554985ba5a..ed9974245f158efff4f373fb26c9ca28c08d17fd 100644 (file)
@@ -49,10 +49,11 @@ addUTraceTest(TestNode** root)
 /*
  * Macro for assert style tests.
  */
-#define TEST_ASSERT(expr) \
-if (!(expr)) { \
-    log_err("FAILED Assertion \"" #expr "\" at  %s:%d.\n", __FILE__, __LINE__); \
-}
+#define TEST_ASSERT(expr) UPRV_BLOCK_MACRO_BEGIN { \
+    if (!(expr)) { \
+        log_err("FAILED Assertion \"" #expr "\" at  %s:%d.\n", __FILE__, __LINE__); \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 
 /*
index 320001a9fd97e83f2490d31c3c1ca6a3040ce81b..f91aa081ae4e6dcf4e4e59a83d01d9679ab1edd3 100644 (file)
@@ -2506,9 +2506,11 @@ exitTestForwardBackward :
     }
 }
 
-#define TEST_ASSERT(x) \
-   {if (U_FAILURE(x)) {log_err_status(x, "%s:%d: FAIL: test assertion failure \n", __FILE__, __LINE__);\
-   }}
+#define TEST_ASSERT(x) UPRV_BLOCK_MACRO_BEGIN { \
+    if (U_FAILURE(x)) { \
+        log_err_status(x, "%s:%d: FAIL: test assertion failure \n", __FILE__, __LINE__); \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 static void TestSearchForNull(void) {
     UCollator *coll;
index 5707cc1d44ad5052d981246457736b66100377a8..8c70f0e803df95d29ef18a3e58d79dfb41e8ba52 100644 (file)
@@ -34,17 +34,21 @@ addUTextTest(TestNode** root)
 }
 
 
-#define TEST_ASSERT(x) \
-   {if ((x)==FALSE) {log_err("Test failure in file %s at line %d\n", __FILE__, __LINE__);\
-                     gFailed = TRUE;\
-   }}
-
-
-#define TEST_SUCCESS(status) \
-   {if (U_FAILURE(status)) {log_err("Test failure in file %s at line %d. Error = \"%s\"\n", \
-       __FILE__, __LINE__, u_errorName(status)); \
-       gFailed = TRUE;\
-   }}
+#define TEST_ASSERT(x) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((x)==FALSE) { \
+        log_err("Test failure in file %s at line %d\n", __FILE__, __LINE__); \
+        gFailed = TRUE; \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+
+#define TEST_SUCCESS(status) UPRV_BLOCK_MACRO_BEGIN { \
+    if (U_FAILURE(status)) { \
+        log_err("Test failure in file %s at line %d. Error = \"%s\"\n", \
+                __FILE__, __LINE__, u_errorName(status)); \
+        gFailed = TRUE; \
+   } \
+} UPRV_BLOCK_MACRO_END
 
 
 
index 4c1c71c14281a1e5fb294a136cb4895fec1bf484..4884be44c3a9e5305d1cae083bff5a452ca818c7 100644 (file)
@@ -35,7 +35,7 @@
  * the macros below do not attempt to assemble such pairs.
  */
 
-#define L8_NEXT(s, i, length, c) { \
+#define L8_NEXT(s, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \
     (c)=(uint8_t)(s)[(i)++]; \
     if((c)>=0x80) { \
         if(U8_IS_LEAD(c)) { \
@@ -44,9 +44,9 @@
             (c)=U_SENTINEL; \
         } \
     } \
-}
+} UPRV_BLOCK_MACRO_END
 
-#define L8_PREV(s, start, i, c) { \
+#define L8_PREV(s, start, i, c) UPRV_BLOCK_MACRO_BEGIN { \
     (c)=(uint8_t)(s)[--(i)]; \
     if((c)>=0x80) { \
         if((c)<=0xbf) { \
@@ -55,7 +55,7 @@
             (c)=U_SENTINEL; \
         } \
     } \
-}
+} UPRV_BLOCK_MACRO_END
 
 /* -------------------------------------------------------------------------- */
 
index 08e50c732bbe2733cdf2169264a7bddedadd0480..5b1c60633a656c2807fc24a23eff110bd08157d8 100644 (file)
@@ -71,10 +71,19 @@ void AlphabeticIndexTest::runIndexedTest( int32_t index, UBool exec, const char*
     TESTCASE_AUTO_END;
 }
 
-#define TEST_CHECK_STATUS {if (U_FAILURE(status)) {dataerrln("%s:%d: Test failure.  status=%s", \
-                                                              __FILE__, __LINE__, u_errorName(status)); return;}}
-
-#define TEST_ASSERT(expr) {if ((expr)==FALSE) {errln("%s:%d: Test failure \n", __FILE__, __LINE__);}}
+#define TEST_CHECK_STATUS UPRV_BLOCK_MACRO_BEGIN { \
+    if (U_FAILURE(status)) { \
+        dataerrln("%s:%d: Test failure.  status=%s", \
+                  __FILE__, __LINE__, u_errorName(status)); \
+        return; \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define TEST_ASSERT(expr) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((expr)==FALSE) { \
+        errln("%s:%d: Test failure \n", __FILE__, __LINE__); \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 //
 //  APITest.   Invoke every function at least once, and check that it does something.
index 87ae7d2a0d659cd9f039a85292e5a5e511931b1b..3650c0835f012d4a0f4de4c60d92a814883e21dd 100644 (file)
@@ -44,7 +44,12 @@ void AstroTest::runIndexedTest( int32_t index, UBool exec, const char* &name, ch
 
 #undef CASE
 
-#define ASSERT_OK(x)   if(U_FAILURE(x)) { dataerrln("%s:%d: %s\n", __FILE__, __LINE__, u_errorName(x)); return; }
+#define ASSERT_OK(x) UPRV_BLOCK_MACRO_BEGIN { \
+    if(U_FAILURE(x)) { \
+        dataerrln("%s:%d: %s\n", __FILE__, __LINE__, u_errorName(x)); \
+        return; \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 
 void AstroTest::initAstro(UErrorCode &status) {
index 89e35ba01fa13d80ed5f05e3b6a7c85f54785ab9..ac8b067d872b24036c242bb2daf8f79e56521e4f 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
@@ -1747,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) {
     /*
index 4edacad64354f375e5457e622d95f6e99452843a..9058b3ae79eca16c59298ccac5f04360007d40cb 100644 (file)
 #define CH_SPACE 0x0020
 #define CH_SLASH 0x002F
 
-#define TEST_ASSERT(x) {if (!(x)) { \
-    errln("Failure in file %s, line %d", __FILE__, __LINE__);}}
-
-#define TEST_ASSERT_SUCCESS(errcode) { if (U_FAILURE(errcode)) { \
-    errcheckln(errcode, "Failure in file %s, line %d, status = \"%s\"", __FILE__, __LINE__, u_errorName(errcode));\
-    return;}}
+#define TEST_ASSERT(x) UPRV_BLOCK_MACRO_BEGIN { \
+    if (!(x)) { \
+        errln("Failure in file %s, line %d", __FILE__, __LINE__); \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define TEST_ASSERT_SUCCESS(errcode) UPRV_BLOCK_MACRO_BEGIN { \
+    if (U_FAILURE(errcode)) { \
+        errcheckln(errcode, "Failure in file %s, line %d, status = \"%s\"", __FILE__, __LINE__, u_errorName(errcode)); \
+        return; \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 
 //---------------------------------------------------------------------------
index 5973a9eb474f3b4cba4d5fb62ffaf6119cb2fa58..04cd38948dc84f0efd765cb6825b4cdb9a536c05 100644 (file)
@@ -642,14 +642,15 @@ void IntlTestDecimalFormatAPI::TestScale()
 }
 
 
-#define ASSERT_EQUAL(expect, actual) { \
+#define ASSERT_EQUAL(expect, actual) UPRV_BLOCK_MACRO_BEGIN { \
     /* ICU-20080: Use temporary variables to avoid strange compiler behaviour \
        (with the nice side-effect of avoiding repeated function calls too). */ \
     auto lhs = (expect); \
     auto rhs = (actual); \
     char tmp[200]; \
     sprintf(tmp, "(%g==%g)", (double)lhs, (double)rhs); \
-    assertTrue(tmp, (lhs==rhs), FALSE, TRUE, __FILE__, __LINE__); }
+    assertTrue(tmp, (lhs==rhs), FALSE, TRUE, __FILE__, __LINE__); \
+} UPRV_BLOCK_MACRO_END
 
 #if defined(_MSC_VER)
 // Ignore the noisy warning 4805 (comparisons between int and bool) in the function below as we use the ICU TRUE/FALSE macros
index 79dd9c99cef068da32f9749ef7d6ab229a2f832d..0f4c943bf035eed55f7474948a35f136997da1c4 100644 (file)
@@ -79,21 +79,41 @@ void DecimalFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &
 //   Error Checking / Reporting macros used in all of the tests.
 //
 //---------------------------------------------------------------------------
-#define DF_CHECK_STATUS {if (U_FAILURE(status)) \
-    {dataerrln("DecimalFormatTest failure at line %d.  status=%s", \
-    __LINE__, u_errorName(status)); return 0;}}
-
-#define DF_ASSERT(expr) {if ((expr)==FALSE) {errln("DecimalFormatTest failure at line %d.\n", __LINE__);}}
-
-#define DF_ASSERT_FAIL(expr, errcode) {UErrorCode status=U_ZERO_ERROR; (expr);\
-if (status!=errcode) {dataerrln("DecimalFormatTest failure at line %d.  Expected status=%s, got %s", \
-    __LINE__, u_errorName(errcode), u_errorName(status));}}
-
-#define DF_CHECK_STATUS_L(line) {if (U_FAILURE(status)) {errln( \
-    "DecimalFormatTest failure at line %d, from %d.  status=%d\n",__LINE__, (line), status); }}
-
-#define DF_ASSERT_L(expr, line) {if ((expr)==FALSE) { \
-    errln("DecimalFormatTest failure at line %d, from %d.", __LINE__, (line)); return;}}
+#define DF_CHECK_STATUS UPRV_BLOCK_MACRO_BEGIN { \
+    if (U_FAILURE(status)) { \
+        dataerrln("DecimalFormatTest failure at line %d.  status=%s", \
+                  __LINE__, u_errorName(status)); \
+        return 0; \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define DF_ASSERT(expr) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((expr)==FALSE) { \
+        errln("DecimalFormatTest failure at line %d.\n", __LINE__); \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define DF_ASSERT_FAIL(expr, errcode) UPRV_BLOCK_MACRO_BEGIN { \
+    UErrorCode status=U_ZERO_ERROR; \
+    (expr); \
+    if (status!=errcode) { \
+        dataerrln("DecimalFormatTest failure at line %d.  Expected status=%s, got %s", \
+                  __LINE__, u_errorName(errcode), u_errorName(status)); \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define DF_CHECK_STATUS_L(line) UPRV_BLOCK_MACRO_BEGIN { \
+    if (U_FAILURE(status)) { \
+        errln("DecimalFormatTest failure at line %d, from %d.  status=%d\n",__LINE__, (line), status); \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define DF_ASSERT_L(expr, line) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((expr)==FALSE) { \
+        errln("DecimalFormatTest failure at line %d, from %d.", __LINE__, (line)); \
+        return; \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 
 
index 47bdd76c50344a271d8dbcc49e85872716f01e46..4a4d3cc770fdbe48be0442a6e66d0c3037a16c06 100644 (file)
 #include "windttst.h"
 #endif
 
-#define ASSERT_OK(status)  if(U_FAILURE(status)) {errcheckln(status, #status " = %s @ %s:%d", u_errorName(status), __FILE__, __LINE__); return; }
+#define ASSERT_OK(status) UPRV_BLOCK_MACRO_BEGIN { \
+    if(U_FAILURE(status)) { \
+        errcheckln(status, #status " = %s @ %s:%d", u_errorName(status), __FILE__, __LINE__); \
+        return; \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 // *****************************************************************************
 // class DateFormatTest
index 60c699d99ed452ea2a5cdd057410e9c3e4ceb05e..3f11bf86decb762a0de6dafee98c44e1d65c8c82 100644 (file)
 #include <stdio.h>
 #include "caltest.h"
 
-#define CHECK(status, msg) \
+#define CHECK(status, msg) UPRV_BLOCK_MACRO_BEGIN { \
     if (U_FAILURE(status)) { \
-      dataerrln((UnicodeString(u_errorName(status)) + UnicodeString(" : " ) )+ msg); \
+        dataerrln((UnicodeString(u_errorName(status)) + UnicodeString(" : " ) )+ msg); \
         return; \
-    }
+    } \
+} UPRV_BLOCK_MACRO_END
 
 
 static UnicodeString escape( const UnicodeString&src)
index c3e49074abb755f05e2bf2ab465ea4862f5acc86..027ebaa45e3e173d7368ce8d2abdb4ba107f7ef5 100644 (file)
@@ -87,7 +87,7 @@ UnicodeString toString(UBool b);
 //|     TESTCASE_AUTO_END;
 //| }
 #define TESTCASE_AUTO_BEGIN \
-    for(;;) { \
+    do { \
         int32_t testCaseAutoNumber = 0
 
 #define TESTCASE_AUTO(test) \
@@ -99,7 +99,7 @@ UnicodeString toString(UBool b);
                 test(); \
             } \
             break; \
-        }
+        } else (void)0
 
 #define TESTCASE_AUTO_CLASS(TestClass) \
         if (index == testCaseAutoNumber++) { \
@@ -111,7 +111,7 @@ UnicodeString toString(UBool b);
                 callTest(test, par); \
             } \
             break; \
-        }
+        } else (void)0
 
 #define TESTCASE_AUTO_CREATE_CLASS(TestClass) \
         if (index == testCaseAutoNumber++) { \
@@ -123,12 +123,12 @@ UnicodeString toString(UBool b);
                 callTest(*test, par); \
             } \
             break; \
-        }
+        } else (void)0
 
 #define TESTCASE_AUTO_END \
         name = ""; \
         break; \
-    }
+    } while (TRUE)
 
 
 // WHERE Macro yields a literal string of the form "source_file_name:line number "
index d4c6f50b8a2be69f4b3201518da506d84b34735e..13861cc126db18a4e0e812a2f9973b16cf8c2ee4 100644 (file)
 #include <stdlib.h>
 #include <stdio.h>
 
-#define TEST_ASSERT_SUCCESS(status) {if (U_FAILURE(status)) { \
-    errcheckln(status, "Failure at file %s, line %d, error = %s", __FILE__, __LINE__, u_errorName(status));}}
-
-#define TEST_ASSERT(expr) {if ((expr)==FALSE) { \
-    errln("Test Failure at file %s, line %d: \"%s\" is false.", __FILE__, __LINE__, #expr);}}
-
-#define TEST_ASSERT_MSG(expr, msg) {if ((expr)==FALSE) { \
-    dataerrln("Test Failure at file %s, line %d, %s: \"%s\" is false.", __FILE__, __LINE__, msg, #expr);}}
-
-#define TEST_ASSERT_EQ(a, b) { if ((a) != (b)) { \
-    errln("Test Failure at file %s, line %d: \"%s\" (%d) != \"%s\" (%d)", \
-             __FILE__, __LINE__, #a, (a), #b, (b)); }}
-
-#define TEST_ASSERT_NE(a, b) { if ((a) == (b)) { \
-    errln("Test Failure at file %s, line %d: \"%s\" (%d) == \"%s\" (%d)", \
-             __FILE__, __LINE__, #a, (a), #b, (b)); }}
+#define TEST_ASSERT_SUCCESS(status) UPRV_BLOCK_MACRO_BEGIN { \
+    if (U_FAILURE(status)) { \
+        errcheckln(status, "Failure at file %s, line %d, error = %s", __FILE__, __LINE__, u_errorName(status)); \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define TEST_ASSERT(expr) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((expr)==FALSE) { \
+        errln("Test Failure at file %s, line %d: \"%s\" is false.", __FILE__, __LINE__, #expr); \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define TEST_ASSERT_MSG(expr, msg) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((expr)==FALSE) { \
+        dataerrln("Test Failure at file %s, line %d, %s: \"%s\" is false.", __FILE__, __LINE__, msg, #expr); \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define TEST_ASSERT_EQ(a, b) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((a) != (b)) { \
+        errln("Test Failure at file %s, line %d: \"%s\" (%d) != \"%s\" (%d)", \
+              __FILE__, __LINE__, #a, (a), #b, (b)); \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define TEST_ASSERT_NE(a, b) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((a) == (b)) { \
+        errln("Test Failure at file %s, line %d: \"%s\" (%d) == \"%s\" (%d)", \
+              __FILE__, __LINE__, #a, (a), #b, (b)); \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 /*
  *   TEST_SETUP and TEST_TEARDOWN
@@ -52,7 +67,7 @@
  *         Put arbitrary test code between SETUP and TEARDOWN.
  *         "sc" is the ready-to-go  SpoofChecker for use in the tests.
  */
-#define TEST_SETUP  \
+#define TEST_SETUP UPRV_BLOCK_MACRO_BEGIN { \
     UErrorCode status = U_ZERO_ERROR; \
     USpoofChecker *sc;     \
     sc = uspoof_open(&status);  \
@@ -67,7 +82,7 @@
     TEST_ASSERT_SUCCESS(status);  \
     uspoof_closeCheckResult(checkResult); \
     uspoof_close(sc);  \
-}
+} UPRV_BLOCK_MACRO_END
 
 
 
@@ -128,9 +143,9 @@ void IntlTestSpoof::testSpoofAPI() {
 }
 
 
-#define CHECK_SKELETON(type, input, expected) { \
+#define CHECK_SKELETON(type, input, expected) UPRV_BLOCK_MACRO_BEGIN { \
     checkSkeleton(sc, type, input, expected, __LINE__); \
-    }
+} UPRV_BLOCK_MACRO_END
 
 
 // testSkeleton.   Spot check a number of confusable skeleton substitutions from the 
index bbe32aafaf37222f311045ae8704c6282ab1accf..26f730d4bb21d17be33274a29e2f1266a4210209 100644 (file)
    the macro is ugly but makes the tests pretty.
 */
 
-#define test_assert(test) \
-    { \
-        if(!(test)) \
-            errln("FAIL: " #test " was not true. In " __FILE__ " on line %d", __LINE__ ); \
-        else \
-            logln("PASS: asserted " #test); \
-    }
+#define test_assert(test) UPRV_BLOCK_MACRO_BEGIN { \
+    if(!(test)) \
+        errln("FAIL: " #test " was not true. In " __FILE__ " on line %d", __LINE__ ); \
+    else \
+        logln("PASS: asserted " #test); \
+} UPRV_BLOCK_MACRO_END
 
 /*
  Usage:
    the macro is ugly but makes the tests pretty.
 */
 
-#define test_assert_print(test,print) \
-    { \
-        if(!(test)) \
-            errln("FAIL: " #test " was not true. " + UnicodeString(print) ); \
-        else \
-            logln("PASS: asserted " #test "-> " + UnicodeString(print)); \
-    }
+#define test_assert_print(test,print) UPRV_BLOCK_MACRO_BEGIN { \
+    if(!(test)) \
+        errln("FAIL: " #test " was not true. " + UnicodeString(print) ); \
+    else \
+        logln("PASS: asserted " #test "-> " + UnicodeString(print)); \
+} UPRV_BLOCK_MACRO_END
 
-#define test_assert_equal(target,value) \
-  { \
+#define test_assert_equal(target,value) UPRV_BLOCK_MACRO_BEGIN { \
     if (UnicodeString(target)!=(value)) { \
-      logln("unexpected value '" + (value) + "'"); \
-      dataerrln("FAIL: " #target " == " #value " was not true. In " __FILE__ " on line %d", __LINE__); \
+        logln("unexpected value '" + (value) + "'"); \
+        dataerrln("FAIL: " #target " == " #value " was not true. In " __FILE__ " on line %d", __LINE__); \
     } else { \
-      logln("PASS: asserted " #target " == " #value); \
+        logln("PASS: asserted " #target " == " #value); \
     } \
-  }
+} UPRV_BLOCK_MACRO_END
 
-#define test_dumpLocale(l) { logln(#l " = " + UnicodeString(l.getName(), "")); }
+#define test_dumpLocale(l) UPRV_BLOCK_MACRO_BEGIN { \
+    logln(#l " = " + UnicodeString(l.getName(), "")); \
+} UPRV_BLOCK_MACRO_END
 
 LocaleDisplayNamesTest::LocaleDisplayNamesTest() {
 }
index 356ef64850439206ebd3d93e5c2834741a7bbb3d..d4eec23590aaaf15f5741a7063f97990a9882c8a 100644 (file)
@@ -146,13 +146,12 @@ static const char* const rawData[33][8] = {
    the macro is ugly but makes the tests pretty.
 */
 
-#define test_assert(test) \
-    { \
-        if(!(test)) \
-            errln("FAIL: " #test " was not true. In " __FILE__ " on line %d", __LINE__ ); \
-        else \
-            logln("PASS: asserted " #test); \
-    }
+#define test_assert(test) UPRV_BLOCK_MACRO_BEGIN { \
+    if(!(test)) \
+        errln("FAIL: " #test " was not true. In " __FILE__ " on line %d", __LINE__ ); \
+    else \
+        logln("PASS: asserted " #test); \
+} UPRV_BLOCK_MACRO_END
 
 /*
  Usage:
@@ -164,16 +163,17 @@ static const char* const rawData[33][8] = {
    the macro is ugly but makes the tests pretty.
 */
 
-#define test_assert_print(test,print) \
-    { \
-        if(!(test)) \
-            errln("FAIL: " #test " was not true. " + UnicodeString(print) ); \
-        else \
-            logln("PASS: asserted " #test "-> " + UnicodeString(print)); \
-    }
+#define test_assert_print(test,print) UPRV_BLOCK_MACRO_BEGIN { \
+    if(!(test)) \
+        errln("FAIL: " #test " was not true. " + UnicodeString(print) ); \
+    else \
+        logln("PASS: asserted " #test "-> " + UnicodeString(print)); \
+} UPRV_BLOCK_MACRO_END
 
 
-#define test_dumpLocale(l) { logln(#l " = " + UnicodeString(l.getName(), "")); }
+#define test_dumpLocale(l) UPRV_BLOCK_MACRO_BEGIN { \
+    logln(#l " = " + UnicodeString(l.getName(), "")); \
+} UPRV_BLOCK_MACRO_END
 
 LocaleTest::LocaleTest()
 : dataTable(NULL)
index 57b307935da815b8cbdb0d8b883527d52f4a0783..61793e0ff944133592ec2bcbc987854d1763ef98 100644 (file)
@@ -2820,7 +2820,7 @@ void NumberFormatterApiTest::validRanges() {
 
 #define EXPECTED_MAX_INT_FRAC_SIG 999
 
-#define VALID_RANGE_ASSERT(status, method, lowerBound, argument) { \
+#define VALID_RANGE_ASSERT(status, method, lowerBound, argument) UPRV_BLOCK_MACRO_BEGIN { \
     UErrorCode expectedStatus = ((lowerBound <= argument) && (argument <= EXPECTED_MAX_INT_FRAC_SIG)) \
         ? U_ZERO_ERROR \
         : U_NUMBER_ARG_OUTOFBOUNDS_ERROR; \
@@ -2829,17 +2829,17 @@ void NumberFormatterApiTest::validRanges() {
             + Int64ToUnicodeString(argument), \
         expectedStatus, \
         status); \
-}
+} UPRV_BLOCK_MACRO_END
 
-#define VALID_RANGE_ONEARG(setting, method, lowerBound) { \
+#define VALID_RANGE_ONEARG(setting, method, lowerBound) UPRV_BLOCK_MACRO_BEGIN { \
     for (int32_t argument = -2; argument <= EXPECTED_MAX_INT_FRAC_SIG + 2; argument++) { \
         UErrorCode status = U_ZERO_ERROR; \
         NumberFormatter::with().setting(method(argument)).copyErrorTo(status); \
         VALID_RANGE_ASSERT(status, method, lowerBound, argument); \
     } \
-}
+} UPRV_BLOCK_MACRO_END
 
-#define VALID_RANGE_TWOARGS(setting, method, lowerBound) { \
+#define VALID_RANGE_TWOARGS(setting, method, lowerBound) UPRV_BLOCK_MACRO_BEGIN { \
     for (int32_t argument = -2; argument <= EXPECTED_MAX_INT_FRAC_SIG + 2; argument++) { \
         UErrorCode status = U_ZERO_ERROR; \
         /* Pass EXPECTED_MAX_INT_FRAC_SIG as the second argument so arg1 <= arg2 in expected cases */ \
@@ -2855,7 +2855,7 @@ void NumberFormatterApiTest::validRanges() {
             U_NUMBER_ARG_OUTOFBOUNDS_ERROR, \
             status); \
     } \
-}
+} UPRV_BLOCK_MACRO_END
 
     VALID_RANGE_ONEARG(precision, Precision::fixedFraction, 0);
     VALID_RANGE_ONEARG(precision, Precision::minFraction, 0);
index 5ae7c3de80e24d064042f8fef5914befe432df74..c5f7e837f162f51ab952f6335a9182867c10c120 100644 (file)
@@ -81,8 +81,18 @@ static const UChar ISO_CURRENCY_USD[] = {0x55, 0x53, 0x44, 0}; // "USD"
 // class NumberFormatTest
 // *****************************************************************************
 
-#define CHECK(status,str) if (U_FAILURE(status)) { errcheckln(status, UnicodeString("FAIL: ") + str + " - " + u_errorName(status)); return; }
-#define CHECK_DATA(status,str) if (U_FAILURE(status)) { dataerrln(UnicodeString("FAIL: ") + str + " - " + u_errorName(status)); return; }
+#define CHECK(status,str) UPRV_BLOCK_MACRO_BEGIN { \
+    if (U_FAILURE(status)) { \
+        errcheckln(status, UnicodeString("FAIL: ") + str + " - " + u_errorName(status)); \
+        return; \
+    } \
+} UPRV_BLOCK_MACRO_END
+#define CHECK_DATA(status,str) UPRV_BLOCK_MACRO_BEGIN { \
+    if (U_FAILURE(status)) { \
+        dataerrln(UnicodeString("FAIL: ") + str + " - " + u_errorName(status)); \
+        return; \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
 {
@@ -6744,12 +6754,12 @@ const char* attrString(int32_t attrId) {
 //      API test, not a comprehensive test.
 //      See DecimalFormatTest/DataDrivenTests
 //
-#define ASSERT_SUCCESS(status) { \
+#define ASSERT_SUCCESS(status) UPRV_BLOCK_MACRO_BEGIN { \
     assertSuccess(UnicodeString("file ") + __FILE__ + ", line " + __LINE__, (status)); \
-}
-#define ASSERT_EQUALS(expected, actual) { \
+} UPRV_BLOCK_MACRO_END
+#define ASSERT_EQUALS(expected, actual) UPRV_BLOCK_MACRO_BEGIN { \
     assertEquals(UnicodeString("file ") + __FILE__ + ", line " + __LINE__, (expected), (actual)); \
-}
+} UPRV_BLOCK_MACRO_END
 
 void NumberFormatTest::TestDecimal() {
     {
index 3f6c4f14a947c4e2845776ebde1c08a433165665..91f614eb72bbd0b3f23587957a555a7ed7b10ea2 100644 (file)
@@ -2734,27 +2734,28 @@ void NumberFormatRegressionTest::TestJ691(void) {
 //   Error Checking / Reporting macros
 //
 //---------------------------------------------------------------------------
-#define TEST_CHECK_STATUS(status) { \
+#define TEST_CHECK_STATUS(status) UPRV_BLOCK_MACRO_BEGIN { \
     if (U_FAILURE(status)) { \
         if (status == U_MISSING_RESOURCE_ERROR) { \
             dataerrln("File %s, Line %d: status=%s", __FILE__, __LINE__, u_errorName(status)); \
         } else { \
             errln("File %s, Line %d: status=%s", __FILE__, __LINE__, u_errorName(status)); \
         } return; \
-    }}
+    } \
+} UPRV_BLOCK_MACRO_END
 
-#define TEST_ASSERT(expr) \
+#define TEST_ASSERT(expr) UPRV_BLOCK_MACRO_BEGIN { \
     if ((expr)==FALSE) {\
         errln("File %s, line %d: Assertion Failed: " #expr "\n", __FILE__, __LINE__);\
-    }
-#define TEST_ASSERT_EQUALS(x,y)                  \
-    {                                                                     \
+    } \
+} UPRV_BLOCK_MACRO_END
+#define TEST_ASSERT_EQUALS(x,y) UPRV_BLOCK_MACRO_BEGIN { \
       char _msg[1000]; \
       int32_t len = sprintf (_msg,"File %s, line %d: " #x "==" #y, __FILE__, __LINE__); \
       (void)len;                                                         \
       U_ASSERT(len < (int32_t) sizeof(_msg));                            \
       assertEquals((const char*) _msg, x,y);                             \
-    }
+} UPRV_BLOCK_MACRO_END
 
 
 // Ticket 8199:  Parse failure for numbers in the range of 1E10 - 1E18
index f78bfc9069b8b387bef4e25e50b08e2466a1c3d7..fd1fe3df6382eff0029520b08838b50009d36e69 100644 (file)
  */
 
 
-#define TEST_ASSERT_SUCCESS(status) {if (U_FAILURE(status)) {\
-dataerrln("Failure at file %s, line %d, error = %s", __FILE__, __LINE__, u_errorName(status));}}
-
-#define TEST_ASSERT(expr) {if ((expr) == FALSE) { \
-    errln("Test Failure at file %s, line %d: \"%s\" is false.\n", __FILE__, __LINE__, #expr);}}
+#define TEST_ASSERT_SUCCESS(status) UPRV_BLOCK_MACRO_BEGIN { \
+    if (U_FAILURE(status)) { \
+        dataerrln("Failure at file %s, line %d, error = %s", __FILE__, __LINE__, u_errorName(status)); \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define TEST_ASSERT(expr) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((expr) == FALSE) { \
+        errln("Test Failure at file %s, line %d: \"%s\" is false.\n", __FILE__, __LINE__, #expr); \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 void RBBIAPITest::TestCloneEquals()
 {
index 70f989e55c8c1b93eea4f4d2c96e9413ea80d04a..2b91ab38f7338ea5fe5297dbbf9c2d120234a09d 100644 (file)
@@ -660,12 +660,12 @@ void RBBIMonkeyImpl::join() {
 }
 
 
-#define MONKEY_ERROR(msg, index) { \
+#define MONKEY_ERROR(msg, index) UPRV_BLOCK_MACRO_BEGIN { \
     IntlTest::gTest->errln("%s:%d %s at index %d. Parameters to reproduce: @rules=%s,seed=%u,loop=1,verbose ", \
                     __FILE__, __LINE__, msg, index, fRuleFileName, fTestData->fRandomSeed); \
     if (fVerbose) { fTestData->dump(index); } \
     status = U_INVALID_STATE_ERROR;  \
-}
+} UPRV_BLOCK_MACRO_END
 
 void RBBIMonkeyImpl::runTest() {
     UErrorCode status = U_ZERO_ERROR;
index 7504d4d4d54316d497db358ecf8712993beaaf9c..61e4aa8af90ba2b51b43addaa6a7f4df9e704256 100644 (file)
 #include "unicode/filteredbrk.h"
 #endif // !UCONFIG_NO_FILTERED_BREAK_ITERATION
 
-#define TEST_ASSERT(x) {if (!(x)) { \
-    errln("Failure in file %s, line %d", __FILE__, __LINE__);}}
-
-#define TEST_ASSERT_SUCCESS(errcode) { if (U_FAILURE(errcode)) { \
-    errcheckln(errcode, "Failure in file %s, line %d, status = \"%s\"", __FILE__, __LINE__, u_errorName(errcode));}}
+#define TEST_ASSERT(x) UPRV_BLOCK_MACRO_BEGIN { \
+    if (!(x)) { \
+        errln("Failure in file %s, line %d", __FILE__, __LINE__); \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define TEST_ASSERT_SUCCESS(errcode) UPRV_BLOCK_MACRO_BEGIN { \
+    if (U_FAILURE(errcode)) { \
+        errcheckln(errcode, "Failure in file %s, line %d, status = \"%s\"", __FILE__, __LINE__, u_errorName(errcode)); \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 //---------------------------------------------
 // runIndexedTest
index bcb5ce5823d2eaea9d13eb2b815d2ec7a23cf1f0..db660488a9533066126eaf99a799c6c484cca71b 100644 (file)
@@ -177,29 +177,56 @@ const char* RegexTest::extractToAssertBuf(const UnicodeString& message) {
   return ASSERT_BUF;
 }
 
-#define REGEX_VERBOSE_TEXT(text) {char buf[200];utextToPrintable(buf,UPRV_LENGTHOF(buf),text);logln("%s:%d: UText %s=\"%s\"", __FILE__, __LINE__, #text, buf);}
-
-#define REGEX_CHECK_STATUS {if (U_FAILURE(status)) {dataerrln("%s:%d: RegexTest failure.  status=%s", \
-                                                              __FILE__, __LINE__, u_errorName(status)); return;}}
-
-#define REGEX_ASSERT(expr) {if ((expr)==FALSE) {errln("%s:%d: RegexTest failure: REGEX_ASSERT(%s) failed \n", __FILE__, __LINE__, #expr);}}
-
-#define REGEX_ASSERT_FAIL(expr, errcode) {UErrorCode status=U_ZERO_ERROR; (expr);\
-if (status!=errcode) {dataerrln("RegexTest failure at line %d.  Expected status=%s, got %s", \
-    __LINE__, u_errorName(errcode), u_errorName(status));}}
-
-#define REGEX_CHECK_STATUS_L(line) {if (U_FAILURE(status)) {errln( \
-    "RegexTest failure at line %d, from %d.  status=%d\n",__LINE__, (line), status); }}
-
-#define REGEX_ASSERT_L(expr, line) {if ((expr)==FALSE) { \
-    errln("RegexTest failure at line %d, from %d.", __LINE__, (line)); return;}}
+#define REGEX_VERBOSE_TEXT(text) UPRV_BLOCK_MACRO_BEGIN { \
+    char buf[200]; \
+    utextToPrintable(buf,UPRV_LENGTHOF(buf),text); \
+    logln("%s:%d: UText %s=\"%s\"", __FILE__, __LINE__, #text, buf); \
+} UPRV_BLOCK_MACRO_END
+
+#define REGEX_CHECK_STATUS UPRV_BLOCK_MACRO_BEGIN { \
+    if (U_FAILURE(status)) { \
+        dataerrln("%s:%d: RegexTest failure.  status=%s", \
+                  __FILE__, __LINE__, u_errorName(status)); \
+        return; \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define REGEX_ASSERT(expr) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((expr)==FALSE) { \
+        errln("%s:%d: RegexTest failure: REGEX_ASSERT(%s) failed \n", __FILE__, __LINE__, #expr); \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define REGEX_ASSERT_FAIL(expr, errcode) UPRV_BLOCK_MACRO_BEGIN { \
+    UErrorCode status=U_ZERO_ERROR; \
+    (expr); \
+    if (status!=errcode) { \
+        dataerrln("RegexTest failure at line %d.  Expected status=%s, got %s", \
+                  __LINE__, u_errorName(errcode), u_errorName(status)); \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define REGEX_CHECK_STATUS_L(line) UPRV_BLOCK_MACRO_BEGIN { \
+    if (U_FAILURE(status)) { \
+        errln("RegexTest failure at line %d, from %d.  status=%d\n",__LINE__, (line), status); \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define REGEX_ASSERT_L(expr, line) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((expr)==FALSE) { \
+        errln("RegexTest failure at line %d, from %d.", __LINE__, (line)); \
+        return; \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 // expected: const char * , restricted to invariant characters.
 // actual: const UnicodeString &
-#define REGEX_ASSERT_UNISTR(expected, actual) { \
+#define REGEX_ASSERT_UNISTR(expected, actual) UPRV_BLOCK_MACRO_BEGIN { \
     if (UnicodeString(expected, -1, US_INV) != (actual)) { \
         errln("%s:%d: RegexTest failure: REGEX_ASSERT_UNISTR(%s, %s) failed \n",  \
-                __FILE__, __LINE__, expected, extractToAssertBuf(actual));}}
+              __FILE__, __LINE__, expected, extractToAssertBuf(actual)); \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 
 static UBool testUTextEqual(UText *uta, UText *utb) {
@@ -329,7 +356,10 @@ static UText* regextst_openUTF8FromInvariant(UText *ut, const char *inv, int64_t
 //
 //---------------------------------------------------------------------------
 
-#define REGEX_TESTLM(pat, text, looking, match) {doRegexLMTest(pat, text, looking, match, __LINE__);doRegexLMTestUTF8(pat, text, looking, match, __LINE__);}
+#define REGEX_TESTLM(pat, text, looking, match) UPRV_BLOCK_MACRO_BEGIN { \
+    doRegexLMTest(pat, text, looking, match, __LINE__); \
+    doRegexLMTestUTF8(pat, text, looking, match, __LINE__); \
+} UPRV_BLOCK_MACRO_END
 
 UBool RegexTest::doRegexLMTest(const char *pat, const char *text, UBool looking, UBool match, int32_t line) {
     const UnicodeString pattern(pat, -1, US_INV);
index 44a9ac39290e475f7bdb20ad5c878019bfd0afd5..839c5607f21aa4c6ddc1150335c6a71f9f22c442 100644 (file)
@@ -37,11 +37,35 @@ enum E_Where
 
 //***************************************************************************************
 
-#define CONFIRM_EQ(actual, expected, myAction) if ((expected)==(actual)) { record_pass(myAction); } else { record_fail(myAction + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of " + (expected) + "\n");}
-#define CONFIRM_GE(actual, expected, myAction) if ((actual)>=(expected)) { record_pass(myAction); } else { record_fail(myAction + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of x >= " + (expected) + "\n");}
-#define CONFIRM_NE(actual, expected, myAction) if ((expected)!=(actual)) { record_pass(myAction); } else { record_fail(myAction + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of x != " + (expected) + "\n");}
-
-#define CONFIRM_UErrorCode(actual, expected, myAction) if ((expected)==(actual)) { record_pass(myAction); } else { record_fail(myAction + (UnicodeString)" returned " + u_errorName(actual) + " instead of " + u_errorName(expected) + "\n"); }
+#define CONFIRM_EQ(actual, expected, myAction) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((expected)==(actual)) { \
+        record_pass(myAction); \
+    } else { \
+        record_fail(myAction + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of " + (expected) + "\n"); \
+    } \
+} UPRV_BLOCK_MACRO_END
+#define CONFIRM_GE(actual, expected, myAction) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((actual)>=(expected)) { \
+        record_pass(myAction); \
+    } else { \
+        record_fail(myAction + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of x >= " + (expected) + "\n"); \
+    } \
+} UPRV_BLOCK_MACRO_END
+#define CONFIRM_NE(actual, expected, myAction) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((expected)!=(actual)) { \
+        record_pass(myAction); \
+    } else { \
+        record_fail(myAction + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of x != " + (expected) + "\n"); \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define CONFIRM_UErrorCode(actual, expected, myAction) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((expected)==(actual)) { \
+        record_pass(myAction); \
+    } else { \
+        record_fail(myAction + (UnicodeString)" returned " + u_errorName(actual) + " instead of " + u_errorName(expected) + "\n"); \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 //***************************************************************************************
 
index 0a6a121e67b18bc71d6429ca937d49a2468c8dd3..c55f22392256109103518d515717c0b4d7d5e396 100644 (file)
@@ -66,11 +66,39 @@ enum E_Where
 
 //***************************************************************************************
 
-#define CONFIRM_EQ(actual,expected) if ((expected)==(actual)) { record_pass(); } else { record_fail(); errln(action + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of " + (expected)); }
-#define CONFIRM_GE(actual,expected) if ((actual)>=(expected)) { record_pass(); } else { record_fail(); errln(action + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of x >= " + (expected)); }
-#define CONFIRM_NE(actual,expected) if ((expected)!=(actual)) { record_pass(); } else { record_fail(); errln(action + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of x != " + (expected)); }
-
-#define CONFIRM_UErrorCode(actual,expected) if ((expected)==(actual)) { record_pass(); } else { record_fail(); errln(action + (UnicodeString)" returned " + (UnicodeString)u_errorName(actual) + (UnicodeString)" instead of " + (UnicodeString)u_errorName(expected)); }
+#define CONFIRM_EQ(actual,expected) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((expected)==(actual)) { \
+        record_pass(); \
+    } else { \
+        record_fail(); \
+        errln(action + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of " + (expected)); \
+    } \
+} UPRV_BLOCK_MACRO_END
+#define CONFIRM_GE(actual,expected) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((actual)>=(expected)) { \
+        record_pass(); \
+    } else { \
+        record_fail(); \
+        errln(action + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of x >= " + (expected)); \
+    } \
+} UPRV_BLOCK_MACRO_END
+#define CONFIRM_NE(actual,expected) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((expected)!=(actual)) { \
+        record_pass(); \
+    } else { \
+        record_fail(); \
+        errln(action + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of x != " + (expected)); \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define CONFIRM_UErrorCode(actual,expected) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((expected)==(actual)) { \
+        record_pass(); \
+    } else { \
+        record_fail(); \
+        errln(action + (UnicodeString)" returned " + (UnicodeString)u_errorName(actual) + (UnicodeString)" instead of " + (UnicodeString)u_errorName(expected)); \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 //***************************************************************************************
 
@@ -1211,17 +1239,17 @@ NewResourceBundleTest::TestGetByFallback() {
 }
 
 
-#define REQUIRE_SUCCESS(status) { \
+#define REQUIRE_SUCCESS(status) UPRV_BLOCK_MACRO_BEGIN { \
     if (status.errIfFailureAndReset("line %d", __LINE__)) { \
         return; \
     } \
-}
+} UPRV_BLOCK_MACRO_END
 
-#define REQUIRE_ERROR(expected, status) { \
+#define REQUIRE_ERROR(expected, status) UPRV_BLOCK_MACRO_BEGIN { \
     if (!status.expectErrorAndReset(expected, "line %d", __LINE__)) { \
         return; \
     } \
-}
+} UPRV_BLOCK_MACRO_END
 
 /**
  * Tests the --filterDir option in genrb.
index 81b73aec796079937db685d9c6f5b8a6b10b9f52..8f2ca4eabfadb0dc91c8ec002960347afadb71b0 100644 (file)
 #define EXP_FORMAT_RESULT_DATA 12
 #define NUM_OF_FORMAT_ARGS 3
 
-#define VERBOSE_INT(x) {logln("%s:%d:  int %s=%d\n", __FILE__, __LINE__, #x, (x));}
-#define VERBOSE_USTRING(text) {logln("%s:%d: UnicodeString %s(%d) = ", __FILE__, __LINE__, #text, text.length()); logln(UnicodeString(" \"")+text+UnicodeString("\";"));}
+#define VERBOSE_INT(x) UPRV_BLOCK_MACRO_BEGIN { \
+    logln("%s:%d:  int %s=%d\n", __FILE__, __LINE__, #x, (x)); \
+} UPRV_BLOCK_MACRO_END
+#define VERBOSE_USTRING(text) UPRV_BLOCK_MACRO_BEGIN { \
+    logln("%s:%d: UnicodeString %s(%d) = ", __FILE__, __LINE__, #text, text.length()); \
+    logln(UnicodeString(" \"")+text+UnicodeString("\";")); \
+} UPRV_BLOCK_MACRO_END
 
 
 void SelectFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
index 8b5ecd6f8ec9b34097d7571380cf2b2c0f3519c8..41483f5ceeaf139537c73a88ae62d67e82a3cce4 100644 (file)
 
 char testId[100];
 
-#define TEST_ASSERT(x) {if (!(x)) { \
-    errln("Failure in file %s, line %d, test ID = \"%s\"", __FILE__, __LINE__, testId);}}
-
-#define TEST_ASSERT_M(x, m) {if (!(x)) { \
-    dataerrln("Failure in file %s, line %d.   \"%s\"", __FILE__, __LINE__, m);return;}}
-
-#define TEST_ASSERT_SUCCESS(errcode) {if (U_FAILURE(errcode)) { \
-    dataerrln("Failure in file %s, line %d, test ID \"%s\", status = \"%s\"", \
-          __FILE__, __LINE__, testId, u_errorName(errcode));}}
+#define TEST_ASSERT(x) UPRV_BLOCK_MACRO_BEGIN { \
+    if (!(x)) { \
+        errln("Failure in file %s, line %d, test ID = \"%s\"", __FILE__, __LINE__, testId); \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define TEST_ASSERT_M(x, m) UPRV_BLOCK_MACRO_BEGIN { \
+    if (!(x)) { \
+        dataerrln("Failure in file %s, line %d.   \"%s\"", __FILE__, __LINE__, m); \
+        return; \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define TEST_ASSERT_SUCCESS(errcode) UPRV_BLOCK_MACRO_BEGIN { \
+    if (U_FAILURE(errcode)) { \
+        dataerrln("Failure in file %s, line %d, test ID \"%s\", status = \"%s\"", \
+                  __FILE__, __LINE__, testId, u_errorName(errcode)); \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 #define NEW_ARRAY(type, count) (type *) uprv_malloc((count) * sizeof(type))
 #define DELETE_ARRAY(array) uprv_free((void *) (array))
index 48a85e5e1ad1b70437cb1705357f44c7551b1783..f80293849516558ffc7b0d4db071a96f9b469b68 100644 (file)
@@ -915,8 +915,12 @@ void TransliteratorAPITest::doTest(const UnicodeString& message, const UnicodeSt
 //                    transliterator, just to verify that they don't fail in some
 //                    destructive way.
 //
-#define CEASSERT(a) {if (!(a)) { \
-errln("FAIL at line %d from line %d: %s", __LINE__, line, #a);  return; }}
+#define CEASSERT(a) UPRV_BLOCK_MACRO_BEGIN { \
+    if (!(a)) { \
+        errln("FAIL at line %d from line %d: %s", __LINE__, line, #a); \
+        return; \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 void TransliteratorAPITest::callEverything(const Transliterator *tr, int line) {
     Transliterator *clonedTR = tr->clone();
index 76542888e265b08f076bb5f35e2a09bb21c887ea..233afd63355c78fe503dd282478a7a8bdfcb8936 100644 (file)
@@ -1034,11 +1034,14 @@ void TransliteratorRoundTripTest::TestHangul() {
 }
 
 
-#define ASSERT_SUCCESS(status) {if (U_FAILURE(status)) { \
-     errcheckln(status, "error at file %s, line %d, status = %s", __FILE__, __LINE__, \
-         u_errorName(status)); \
-         return;}}
-    
+#define ASSERT_SUCCESS(status) UPRV_BLOCK_MACRO_BEGIN { \
+    if (U_FAILURE(status)) { \
+        errcheckln(status, "error at file %s, line %d, status = %s", __FILE__, __LINE__, \
+                   u_errorName(status)); \
+        return; \
+    } \
+} UPRV_BLOCK_MACRO_END
+
 
 static void writeStringInU8(FILE *out, const UnicodeString &s) {
     int i;
index b2c496db8019a1e7b1e386d2c115d3fd3a018988..06a8a23d317b2250006b2bea6ec3c2d7456fff0e 100644 (file)
@@ -4066,7 +4066,7 @@ void TransliteratorTest::TestAllCodepoints(){
 
 } 
 
-#define TEST_TRANSLIT_ID(id, cls) { \
+#define TEST_TRANSLIT_ID(id, cls) UPRV_BLOCK_MACRO_BEGIN { \
   UErrorCode ec = U_ZERO_ERROR; \
   Transliterator* t = Transliterator::createInstance(id, UTRANS_FORWARD, ec); \
   if (U_FAILURE(ec)) { \
@@ -4078,9 +4078,9 @@ void TransliteratorTest::TestAllCodepoints(){
     /* *t = *t; */ /*can't do this: coverage test for assignment op*/ \
   } \
   delete t; \
-}
+} UPRV_BLOCK_MACRO_END
 
-#define TEST_TRANSLIT_RULE(rule, cls) { \
+#define TEST_TRANSLIT_RULE(rule, cls) UPRV_BLOCK_MACRO_BEGIN { \
   UErrorCode ec = U_ZERO_ERROR; \
   UParseError pe; \
   Transliterator* t = Transliterator::createFromRules("_", rule, UTRANS_FORWARD, pe, ec); \
@@ -4093,7 +4093,7 @@ void TransliteratorTest::TestAllCodepoints(){
     /* *t = *t; */ /*can't do this: coverage test for assignment op*/ \
   } \
   delete t; \
-}
+} UPRV_BLOCK_MACRO_END
 
 void TransliteratorTest::TestBoilerplate() {
     TEST_TRANSLIT_ID("Any-Latin", AnyTransliterator);
index 3792c6ba42313cfd03f321eb78c33ec3e7692d62..3c4abb0dad0c1e80441b85d741989547ba4e5ce6 100644 (file)
 
 #define TESTCLASSID_NONE_DEFAULT(c) \
     delete testClassNoClassID(new c, #c, "new " #c)
-#define TESTCLASSID_NONE_CTOR(c, x) { \
+#define TESTCLASSID_NONE_CTOR(c, x) UPRV_BLOCK_MACRO_BEGIN { \
     delete testClassNoClassID(new c x, #c, "new " #c #x); \
     if(U_FAILURE(status)) { \
         dataerrln(UnicodeString(#c " - new " #x " - got err status ") + UnicodeString(u_errorName(status))); \
         status = U_ZERO_ERROR; \
     } \
-}
-#define TESTCLASSID_NONE_FACTORY(c, f) { \
+} UPRV_BLOCK_MACRO_END
+#define TESTCLASSID_NONE_FACTORY(c, f) UPRV_BLOCK_MACRO_BEGIN { \
     delete testClassNoClassID(f, #c, #f); \
     if(U_FAILURE(status)) { \
         dataerrln(UnicodeString(#c " - " #f " - got err status ") + UnicodeString(u_errorName(status))); \
         status = U_ZERO_ERROR; \
     } \
-}
-#define TESTCLASSID_FACTORY(c, f) { \
+} UPRV_BLOCK_MACRO_END
+#define TESTCLASSID_FACTORY(c, f) UPRV_BLOCK_MACRO_BEGIN { \
     delete testClass(f, #c, #f, c ::getStaticClassID()); \
     if(U_FAILURE(status)) { \
         dataerrln(UnicodeString(#c " - " #f " - got err status ") + UnicodeString(u_errorName(status))); \
         status = U_ZERO_ERROR; \
     } \
-}
-#define TESTCLASSID_TRANSLIT(c, t) { \
+} UPRV_BLOCK_MACRO_END
+#define TESTCLASSID_TRANSLIT(c, t) UPRV_BLOCK_MACRO_BEGIN { \
     delete testClass(Transliterator::createInstance(UnicodeString(t), UTRANS_FORWARD,parseError,status), #c, "Transliterator: " #t, c ::getStaticClassID()); \
     if(U_FAILURE(status)) { \
         dataerrln(UnicodeString(#c " - Transliterator: " #t " - got err status ") + UnicodeString(u_errorName(status))); \
         status = U_ZERO_ERROR; \
     } \
-}
-#define TESTCLASSID_CTOR(c, x) { \
+} UPRV_BLOCK_MACRO_END
+#define TESTCLASSID_CTOR(c, x) UPRV_BLOCK_MACRO_BEGIN { \
     delete testClass(new c x, #c, "new " #c #x, c ::getStaticClassID()); \
     if(U_FAILURE(status)) { \
         dataerrln(UnicodeString(#c " - new " #x " - got err status ") + UnicodeString(u_errorName(status))); \
         status = U_ZERO_ERROR; \
     } \
-}
+} UPRV_BLOCK_MACRO_END
 #define TESTCLASSID_DEFAULT(c) \
     delete testClass(new c, #c, "new " #c , c::getStaticClassID())
 #define TESTCLASSID_ABSTRACT(c) \
     testClass(NULL, #c, NULL, c::getStaticClassID())
-#define TESTCLASSID_FACTORY_HIDDEN(c, f) { \
+#define TESTCLASSID_FACTORY_HIDDEN(c, f) UPRV_BLOCK_MACRO_BEGIN { \
     UObject *objVar = f; \
     delete testClass(objVar, #c, #f, objVar!=NULL? objVar->getDynamicClassID(): NULL); \
     if(U_FAILURE(status)) { \
         dataerrln(UnicodeString(#c " - " #f " - got err status ")  + UnicodeString(u_errorName(status))); \
         status = U_ZERO_ERROR; \
     } \
-}
+} UPRV_BLOCK_MACRO_END
 
 #define MAX_CLASS_ID 200
 
index eafddd191ebea033499dbb98e19f3adad9d80d5f..91806095ad829271dc4357e4e4939561768f2deb 100644 (file)
 #include "cmemory.h"
 #include "hash.h"
 
-#define TEST_ASSERT_SUCCESS(status) {if (U_FAILURE(status)) { \
-    dataerrln("fail in file \"%s\", line %d: \"%s\"", __FILE__, __LINE__, \
-    u_errorName(status));}}
-
-#define TEST_ASSERT(expr) {if (!(expr)) { \
-    dataerrln("fail in file \"%s\", line %d", __FILE__, __LINE__); }}
+#define TEST_ASSERT_SUCCESS(status) UPRV_BLOCK_MACRO_BEGIN { \
+    if (U_FAILURE(status)) { \
+        dataerrln("fail in file \"%s\", line %d: \"%s\"", __FILE__, __LINE__, \
+                  u_errorName(status)); \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+#define TEST_ASSERT(expr) UPRV_BLOCK_MACRO_BEGIN { \
+    if (!(expr)) { \
+        dataerrln("fail in file \"%s\", line %d", __FILE__, __LINE__); \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 UnicodeString operator+(const UnicodeString& left, const UnicodeSet& set) {
     UnicodeString pat;
index feea5847bcd522a0ec538854f28838aab5cb7a56..09e7b602aa66b815b860aae0402a5cd31d2e7cc5 100644 (file)
@@ -29,17 +29,21 @@ static int    gTestNum = 0;
 // Forward decl
 UText *openFragmentedUnicodeString(UText *ut, UnicodeString *s, UErrorCode *status);
 
-#define TEST_ASSERT(x) \
-{ if ((x)==FALSE) {errln("Test #%d failure in file %s at line %d\n", gTestNum, __FILE__, __LINE__);\
-                     gFailed = TRUE;\
-   }}
-
-
-#define TEST_SUCCESS(status) \
-{ if (U_FAILURE(status)) {errln("Test #%d failure in file %s at line %d. Error = \"%s\"\n", \
-       gTestNum, __FILE__, __LINE__, u_errorName(status)); \
-       gFailed = TRUE;\
-   }}
+#define TEST_ASSERT(x) UPRV_BLOCK_MACRO_BEGIN { \
+    if ((x)==FALSE) { \
+        errln("Test #%d failure in file %s at line %d\n", gTestNum, __FILE__, __LINE__); \
+        gFailed = TRUE; \
+    } \
+} UPRV_BLOCK_MACRO_END
+
+
+#define TEST_SUCCESS(status) UPRV_BLOCK_MACRO_BEGIN { \
+    if (U_FAILURE(status)) { \
+        errln("Test #%d failure in file %s at line %d. Error = \"%s\"\n", \
+              gTestNum, __FILE__, __LINE__, u_errorName(status)); \
+        gFailed = TRUE; \
+    } \
+} UPRV_BLOCK_MACRO_END
 
 UTextTest::UTextTest() {
 }
index 4b73b566ad3bb0b7840f7a6aeb1ef3c335606f28..3829ba2668d896b979f943a4450a12c723d9dae2 100644 (file)
@@ -57,16 +57,18 @@ void UVectorTest::runIndexedTest( int32_t index, UBool exec, const char* &name,
 //   Error Checking / Reporting macros used in all of the tests.
 //
 //---------------------------------------------------------------------------
-#define TEST_CHECK_STATUS(status) \
+#define TEST_CHECK_STATUS(status) UPRV_BLOCK_MACRO_BEGIN {\
     if (U_FAILURE(status)) {\
         errln("UVectorTest failure at line %d.  status=%s\n", __LINE__, u_errorName(status));\
         return;\
-    }
+    }\
+} UPRV_BLOCK_MACRO_END
 
-#define TEST_ASSERT(expr) \
+#define TEST_ASSERT(expr) UPRV_BLOCK_MACRO_BEGIN {\
     if ((expr)==FALSE) {\
         errln("UVectorTest failure at line %d.\n", __LINE__);\
-    }
+    }\
+} UPRV_BLOCK_MACRO_END
 
 static int8_t U_CALLCONV
 UVectorTest_compareInt32(UElement key1, UElement key2) {
index 85567c0828ace4bc84dc1303e0bbbed2a16f0b2d..5380bcc0dfe181ad94375484a37101edaed12d69 100644 (file)
@@ -57,16 +57,18 @@ void UVector32Test::runIndexedTest( int32_t index, UBool exec, const char* &name
 //   Error Checking / Reporting macros used in all of the tests.
 //
 //---------------------------------------------------------------------------
-#define TEST_CHECK_STATUS(status) \
+#define TEST_CHECK_STATUS(status) UPRV_BLOCK_MACRO_BEGIN {\
     if (U_FAILURE(status)) {\
         errln("UVector32Test failure at line %d.  status=%s\n", __LINE__, u_errorName(status));\
         return;\
-    }
+    }\
+} UPRV_BLOCK_MACRO_END
 
-#define TEST_ASSERT(expr) \
+#define TEST_ASSERT(expr) UPRV_BLOCK_MACRO_BEGIN {\
     if ((expr)==FALSE) {\
         errln("UVector32Test failure at line %d.\n", __LINE__);\
-    }
+    }\
+} UPRV_BLOCK_MACRO_END
 
 //---------------------------------------------------------------------------
 //
index 3ac6674888f1beefdd182b274006f6acfd23ea0b..e074b9020d88593fbd0ea04163e4a7221b8643ef 100644 (file)
@@ -1120,7 +1120,7 @@ static void TestFilePrintCompatibility(void) {
 }
 #endif
 
-#define TestFPrintFormat(uFormat, uValue, cFormat, cValue) \
+#define TestFPrintFormat(uFormat, uValue, cFormat, cValue) UPRV_BLOCK_MACRO_BEGIN { \
     myFile = u_fopen(STANDARD_TEST_FILE, "w", STANDARD_TEST_LOCALE, NULL);\
     if (myFile == NULL) {\
         log_err("Can't write test file for %s.\n", uFormat);\
@@ -1146,6 +1146,7 @@ static void TestFilePrintCompatibility(void) {
     if (buffer[uNumPrinted+1] != '*') {\
         log_err("%" uFormat " too much stored\n");\
     }\
+} UPRV_BLOCK_MACRO_END
 
 #if !UCONFIG_NO_FORMATTING
 static void TestFprintfFormat(void) {
index 3962bde5d6fabeb592c5f1b8336f3f3d749c5ae5..ee67b4c3ab1c185079df9adc81a5f96a466e41f5 100644 (file)
@@ -313,7 +313,7 @@ static void TestLocalizedString(void) {
 }
 
 #if !UCONFIG_NO_FORMATTING
-#define Test_u_snprintf(limit, format, value, expectedSize, expectedStr) \
+#define Test_u_snprintf(limit, format, value, expectedSize, expectedStr) UPRV_BLOCK_MACRO_BEGIN { \
     u_uastrncpy(testStr, "xxxxxxxxxxxxxx", UPRV_LENGTHOF(testStr));\
     size = u_snprintf(testStr, limit, format, value);\
     u_austrncpy(cTestResult, testStr, UPRV_LENGTHOF(cTestResult));\
@@ -324,6 +324,7 @@ static void TestLocalizedString(void) {
     else {\
         log_verbose("Got: %s\n", cTestResult);\
     }\
+} UPRV_BLOCK_MACRO_END
 
 #endif
 
@@ -358,7 +359,7 @@ static void TestSnprintf(void) {
 #endif
 }
 
-#define TestSPrintFormat(uFormat, uValue, cFormat, cValue) \
+#define TestSPrintFormat(uFormat, uValue, cFormat, cValue) UPRV_BLOCK_MACRO_BEGIN { \
     /* Reinitialize the buffer to verify null termination works. */\
     u_memset(uBuffer, 0x2a, UPRV_LENGTHOF(uBuffer));\
     memset(buffer, '*', UPRV_LENGTHOF(buffer));\
@@ -375,6 +376,7 @@ static void TestSnprintf(void) {
     if (buffer[uNumPrinted+1] != '*') {\
         log_err("%" uFormat " too much stored\n");\
     }\
+} UPRV_BLOCK_MACRO_END
 
 static void TestSprintfFormat(void) {
 #if !UCONFIG_NO_FORMATTING