]> granicus.if.org Git - icu/commitdiff
ICU-12914 Better loop control in test
authorPeter Edberg <pedberg@unicode.org>
Wed, 1 Feb 2017 07:52:19 +0000 (07:52 +0000)
committerPeter Edberg <pedberg@unicode.org>
Wed, 1 Feb 2017 07:52:19 +0000 (07:52 +0000)
X-SVN-Rev: 39628

icu4c/source/test/cintltst/cbiapts.c

index 83c9a7150a945b28cfbfb81dc4d17e756915a193..1b58e1051c389508578926066824243714fe2b5b 100644 (file)
@@ -605,15 +605,17 @@ static void TestBreakIteratorRules() {
                 if (U_FAILURE(status)) {
                     log_err("FAIL: ubrk_openBinaryRules err: %s", u_errorName(status));
                 } else {
+                    int32_t maxCount = sizeof(breaks); /* fail-safe test limit */
                     int32_t pos2 = ubrk_first(bi2);
                     pos = ubrk_first(bi);
-                    for (i=0; i<sizeof(breaks); i++) {
+                    do {
                         if (pos2 != pos) {
                             log_err("FAIL: interator from ubrk_openBinaryRules does not match original, get pos = %d instead of %d", pos2, pos);
                         }
                         pos2 = ubrk_next(bi2);
                         pos = ubrk_next(bi);
-                    }
+                    } while ((pos != UBRK_DONE || pos2 != UBRK_DONE) && maxCount-- > 0);
+                    
                     ubrk_close(bi2);
                 }
             }