publicstaticvoid main(String[] args) throws Exception { new Bug4533872().run(args);
}
staticfinal String[] given = { /* Lu Nd Lu Ll */ "XYZ12345 ABCDE abcde", /* Nd Lo Nd Lu Po Lu Ll */ "123\uD800\uDC00345 ABC\uFF61XYZ abc", /* Nd Lo Nd Lu Po Lu Ll */ "123\uD800\uDC00345 ABC\uD800\uDD00XYZ abc", /* Lu Ll Cs Ll Cs Lu Lo Lu */ "ABCabc\uDC00xyz\uD800ABC\uD800\uDC00XYZ",
};
/* *TestforisBoundary(intn)
*/ void TestIsBoundary() {
iter = BreakIterator.getWordInstance(Locale.US);
for (int i = 0; i < given.length; i++) {
iter.setText(given[i]);
start = iter.first();
end = iter.next();
while (end < given[i].length()) { if (!iter.isBoundary(end)) {
errln("Word break failure: isBoundary() This should be a boundary. Index=" +
end + " for " + given[i]);
}
end = iter.next();
}
}
}
/* *Testmainlyfornext()andcurrent()
*/ void TestPrintEachForward() {
iter = BreakIterator.getWordInstance(Locale.US);
for (int i = 0; i < given.length; i++) {
iter.setText(given[i]);
start = iter.first();
// Check current()'s return value - should be same as first()'s.
current = iter.current(); if (start != current) {
errln("Word break failure: printEachForward() Unexpected current value: current()=" +
current + ", expected(=first())=" + start);
}
int j = 0; for (end = iter.next();
end != BreakIterator.DONE;
start = end, end = iter.next(), j++) {
// Check current()'s return value - should be same as next()'s.
current = iter.current(); if (end != current) {
errln("Word break failure: printEachForward() Unexpected current value: current()=" +
current + ", expected(=next())=" + end);
}
/* *Testmainlyforprevious()andcurrent()
*/ void TestPrintEachBackward() {
iter = BreakIterator.getWordInstance(Locale.US);
for (int i = 0; i < given.length; i++) {
iter.setText(given[i]);
end = iter.last();
// Check current()'s return value - should be same as last()'s.
current = iter.current(); if (end != current) {
errln("Word break failure: printEachBackward() Unexpected current value: current()=" +
current + ", expected(=last())=" + end);
}
int j; for (start = iter.previous(), j = expected[i].length-1;
start != BreakIterator.DONE;
end = start, start = iter.previous(), j--) {
// Check current()'s return value - should be same as previous()'s.
current = iter.current(); if (start != current) {
errln("Word break failure: printEachBackward() Unexpected current value: current()=" +
current + ", expected(=previous())=" + start);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.