]> granicus.if.org Git - icu/commitdiff
ICU-13692 add test for slow RBBI word boundaries in very long words.
authorAndy Heninger <andy.heninger@gmail.com>
Mon, 9 Apr 2018 21:42:14 +0000 (21:42 +0000)
committerAndy Heninger <andy.heninger@gmail.com>
Mon, 9 Apr 2018 21:42:14 +0000 (21:42 +0000)
X-SVN-Rev: 41213

icu4c/source/test/intltest/rbbitst.cpp
icu4c/source/test/intltest/rbbitst.h

index 655b2dec73dc828c5bdb3395dc6f8af3c56359c7..4dd712c4bbd451b8d6dffd92a0e764c4abbae3c8 100644 (file)
@@ -113,6 +113,7 @@ void RBBITest::runIndexedTest( int32_t index, UBool exec, const char* &name, cha
     TESTCASE_AUTO(TestTableRedundancies);
     TESTCASE_AUTO(TestBug13447);
     TESTCASE_AUTO(TestReverse);
+    TESTCASE_AUTO(TestBug13692);
     TESTCASE_AUTO_END;
 }
 
@@ -4544,6 +4545,24 @@ void RBBITest::TestReverse(std::unique_ptr<RuleBasedBreakIterator>bi) {
 }
 
 
+// Ticket 13692 - finding word boundaries in very large numbers or words could
+//                be very time consuming. When the problem was present, this void test
+//                would run more than fifteen minutes, which is to say, the failure was noticeale.
+
+void RBBITest::TestBug13692() {
+    UErrorCode status = U_ZERO_ERROR;
+    LocalPointer<RuleBasedBreakIterator> bi ((RuleBasedBreakIterator *)
+            BreakIterator::createWordInstance(Locale::getEnglish(), status), status);
+    constexpr int32_t LENGTH = 1000000;
+    UnicodeString longNumber(LENGTH, (UChar32)u'3', LENGTH);
+    for (int i=0; i<20; i+=2) {
+        longNumber.setCharAt(i, u' ');
+    }
+    bi->setText(longNumber);
+    assertFalse(WHERE, bi->isBoundary(LENGTH-5));
+    assertSuccess(WHERE, status);
+}
+
 //
 //  TestDebug    -  A place-holder test for debugging purposes.
 //                  For putting in fragments of other tests that can be invoked
index 20774cc8ea27e4c17725a8099bc5c98961b8b303..cfaf688ac1f61c5e48762c1547b09d930e6ef445 100644 (file)
@@ -81,6 +81,7 @@ public:
     void TestBug13447();
     void TestReverse();
     void TestReverse(std::unique_ptr<RuleBasedBreakIterator>bi);
+    void TestBug13692();
 
     void TestDebug();
     void TestProperties();