From 2f06ce3799a30c4cddae684d98e9104ea40d7a2b Mon Sep 17 00:00:00 2001 From: Andy Heninger Date: Mon, 9 Apr 2018 21:42:14 +0000 Subject: [PATCH] ICU-13692 add test for slow RBBI word boundaries in very long words. X-SVN-Rev: 41213 --- icu4c/source/test/intltest/rbbitst.cpp | 19 +++++++++++++++++++ icu4c/source/test/intltest/rbbitst.h | 1 + 2 files changed, 20 insertions(+) diff --git a/icu4c/source/test/intltest/rbbitst.cpp b/icu4c/source/test/intltest/rbbitst.cpp index 655b2dec73d..4dd712c4bbd 100644 --- a/icu4c/source/test/intltest/rbbitst.cpp +++ b/icu4c/source/test/intltest/rbbitst.cpp @@ -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_ptrbi) { } +// 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 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 diff --git a/icu4c/source/test/intltest/rbbitst.h b/icu4c/source/test/intltest/rbbitst.h index 20774cc8ea2..cfaf688ac1f 100644 --- a/icu4c/source/test/intltest/rbbitst.h +++ b/icu4c/source/test/intltest/rbbitst.h @@ -81,6 +81,7 @@ public: void TestBug13447(); void TestReverse(); void TestReverse(std::unique_ptrbi); + void TestBug13692(); void TestDebug(); void TestProperties(); -- 2.40.0