mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 22:44:49 +00:00
ICU-21747 Add check for expectedBreakCount in Java
This commit is contained in:
parent
08dbf093ce
commit
e2fe1aa8b7
1 changed files with 7 additions and 0 deletions
|
@ -553,6 +553,8 @@ public class RBBIMonkeyTest extends TestFmwk {
|
|||
fRuleForPosition = new int[fString.length()+1];
|
||||
f2ndRuleForPos = new int[fString.length()+1];
|
||||
|
||||
int expectedBreakCount = 0;
|
||||
|
||||
// Apply reference rules to find the expected breaks.
|
||||
|
||||
fExpectedBreaks[0] = true; // Force an expected break before the start of the text.
|
||||
|
@ -619,6 +621,7 @@ public class RBBIMonkeyTest extends TestFmwk {
|
|||
if (hasBreak) {
|
||||
int breakPos = strIdx + BreakGroupStart(matchingRule.fRuleMatcher);
|
||||
fExpectedBreaks[breakPos] = true;
|
||||
expectedBreakCount++;
|
||||
// System.out.printf("recording break at %d\n", breakPos);
|
||||
// For the next iteration, pick up applying rules immediately after the break,
|
||||
// which may differ from end of the match. The matching rule may have included
|
||||
|
@ -639,6 +642,10 @@ public class RBBIMonkeyTest extends TestFmwk {
|
|||
initialMatch = false;
|
||||
}
|
||||
}
|
||||
if (expectedBreakCount >= fString.length()) {
|
||||
throw new IllegalArgumentException(String.format("expectedBreakCount (%d) should be less than the test string length (%d).",
|
||||
expectedBreakCount, fString.length()));
|
||||
}
|
||||
};
|
||||
|
||||
// Helper function to find the starting index of a match of the "BreakPosition" named capture group.
|
||||
|
|
Loading…
Add table
Reference in a new issue