BidiConformance.java revision 2362
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6850113
* @summary confirm the behavior of new Bidi implementation. (Backward compatibility)
*/
public class BidiConformance {
/* internal flags */
private static boolean error = false;
private static boolean verbose = false;
private static boolean abort = false;
verbose = true;
abort = true;
}
}
if (error) {
throw new RuntimeException("Failed.");
} else {
}
}
private void test() {
testMethods();
testMethods4Constructor1(); // Bidi(AttributedCharacterIterator)
testMethods4Constructor2(); // Bidi(String, int)
testMethods4Constructor3(); // Bidi(char[], ...)
}
private void testConstants() {
checkResult("Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT",
checkResult("Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT",
checkResult("Bidi.DIRECTION_LEFT_TO_RIGHT",
checkResult("Bidi.DIRECTION_RIGHT_TO_LEFT",
}
private void testConstructors() {
testConstructor1(); // Bidi(AttributedCharacterIterator)
testConstructor2(); // Bidi(String, int)
testConstructor3(); // Bidi(char[], ...)
}
private void testMethods() {
}
private void testMethods4Constructor1() {
int testNo;
": Bidi(AttributedCharacterIterator\"" +
// Test 0
testNo = 0;
// Test 1
++testNo;
": RUN_DIRECTION_LTR, BIDI_EMBEDDING(1)");
// Test 2
++testNo;
": RUN_DIERCTION_LTR, BIDI_EMBEDDING(2)");
// Test 3
++testNo;
": RUN_DIRECTIOIN_LTR, BIDI_EMBEDDING(-3)");
// Test 4
++testNo;
": RUN_DIRECTION_LTR, BIDI_EMBEDDING(-4)");
// Test 5
++testNo;
// Test 6
++testNo;
": RUN_DIRECTION_RTL, BIDI_EMBEDDING(1)");
try {
}
catch (IllegalArgumentException e) {
errorHandling(" Unexpected exception: " + e);
}
// Test 7
++testNo;
": RUN_DIRECTION_RTL, BIDI_EMBEDDING(2)");
try {
}
catch (IllegalArgumentException e) {
errorHandling(" Unexpected exception: " + e);
}
// Test 8
++testNo;
": RUN_DIRECTION_RTL, BIDI_EMBEDDING(-3)");
try {
}
catch (IllegalArgumentException e) {
errorHandling(" Unexpected exception: " + e);
}
// Test 9
++testNo;
": RUN_DIRECTION_RTL, BIDI_EMBEDDING(-4)");
try {
}
catch (IllegalArgumentException e) {
errorHandling(" Unexpected exception: " + e);
}
// Test 10
++testNo;
": TextAttribute not specified");
// Test 11
++testNo;
": RUN_DIRECTION_LTR, NUMERIC_SHAPING(ARABIC)");
// Test 12
++testNo;
": RUN_DIRECTION_RTL, NUMERIC_SHAPING(ARABIC)");
}
}
private void testMethods4Constructor2() {
}
}
}
private void testMethods4Constructor3() {
char[] c = paragraph.toCharArray();
try {
}
catch (Exception e) {
errorHandling(" Unexpected exception: " + e);
}
}
}
}
}
private void testConstructor1() {
try {
errorHandling("Bidi((AttributedCharacterIterator)null) " +
"should throw an IAE.");
}
catch (IllegalArgumentException e) {
}
catch (NullPointerException e) {
errorHandling("Bidi((AttributedCharacterIterator)null) " +
"should not throw an NPE but an IAE.");
}
try {
errorHandling("Bidi(AttributedCharacterIterator).getLevelAt(" +
" but 60 when BIDI_EMBEDDING is -61.");
}
}
}
catch (Exception e) {
errorHandling(" Unexpected exception: " + e);
}
try {
errorHandling("Bidi(AttributedCharacterIterator).getLevelAt() " +
"should be 1 when BIDI_EMBEDDING is -62.");
}
}
}
catch (Exception e) {
errorHandling(" Unexpected exception: " + e);
}
try {
errorHandling("Bidi(AttributedCharacterIterator).getLevelAt() " +
"should be 61 when BIDI_EMBEDDING is 60.");
}
}
}
catch (Exception e) {
errorHandling(" Unexpected exception: " + e);
}
try {
errorHandling("Bidi(AttributedCharacterIterator).getLevelAt(" +
" but 61 when BIDI_EMBEDDING is 61.");
}
}
}
catch (Exception e) {
errorHandling(" Unexpected exception: " + e);
}
try {
errorHandling("Bidi(AttributedCharacterIterator).getLevelAt()" +
" but 1 when BIDI_EMBEDDING is 62.");
}
}
}
catch (Exception e) {
errorHandling(" Unexpected exception: " + e);
}
}
private void testConstructor2() {
try {
errorHandling("Bidi((String)null, DIRECTION_DEFAULT_LEFT_TO_RIGHT)" +
" should throw an IAE.");
}
catch (IllegalArgumentException e) {
}
catch (NullPointerException e) {
errorHandling("Bidi((String)null, DIRECTION_DEFAULT_LEFT_TO_RIGHT) " +
"should not throw an NPE but an IAE.");
}
try {
}
catch (Exception e) {
errorHandling("Bidi(\"abc\", -3) should not throw an exception: " +
e);
}
try {
}
catch (Exception e) {
errorHandling("Bidi(\"abc\", 2) should not throw an exception: " +
e);
}
}
private void testConstructor3() {
try {
errorHandling("Bidi(char[], ...) should throw an IAE " +
"when text=null.");
}
catch (IllegalArgumentException e) {
}
catch (NullPointerException e) {
errorHandling("Bidi(char[], ...) should not throw an NPE " +
"but an IAE when text=null.");
}
try {
errorHandling("Bidi(char[], ...) should throw an IAE " +
"when textStart is incorrect(-1: too small).");
}
catch (IllegalArgumentException e) {
}
catch (ArrayIndexOutOfBoundsException e) {
errorHandling("Bidi(char[], ...) should not throw an NPE " +
"but an IAE when textStart is incorrect(-1: too small).");
}
try {
errorHandling("Bidi(char[], ...) should throw an IAE " +
"when textStart is incorrect(4: too large).");
}
catch (IllegalArgumentException e) {
}
catch (ArrayIndexOutOfBoundsException e) {
errorHandling("Bidi(char[], ...) should not throw an NPE " +
"but an IAE when textStart is incorrect(4: too large).");
}
try {
}
errorHandling("Bidi(char[], ...).getLevelAt()" +
"} when embeddings are {" +
}
}
catch (Exception e) {
errorHandling("Bidi(char[], ...) should not throw an exception " +
"when embeddings is valid(-61).");
}
try {
}
errorHandling("Bidi(char[], ...).getLevelAt()" +
"} when embeddings are {" +
}
}
catch (Exception e) {
errorHandling("Bidi(char[], ...) should not throw an exception " +
"when embeddings is valid(61).");
}
try {
errorHandling("Bidi(char[], ...).getLevelAt(1) should be 0 " +
"when embeddings[1] is -62.");
}
}
catch (Exception e) {
errorHandling("Bidi(char[], ...) should not throw an exception " +
"even when embeddings includes -62.");
}
try {
errorHandling("Bidi(char[], ...).getLevelAt(1) should be 0 " +
"when embeddings[1] is 62.");
}
}
catch (Exception e) {
errorHandling("Bidi(char[], ...) should not throw an exception " +
"even when embeddings includes 62.");
}
try {
errorHandling("Bidi(char[], ...) should throw an IAE " +
"when paragraphLength=-1(too small).");
}
catch (IllegalArgumentException e) {
}
catch (NegativeArraySizeException e) {
errorHandling("Bidi(char[], ...) should not throw an NASE " +
"but an IAE when paragraphLength=-1(too small).");
}
try {
errorHandling("Bidi(char[], ...) should throw an IAE " +
"when paragraphLength=6(too large).");
}
catch (IllegalArgumentException e) {
}
catch (ArrayIndexOutOfBoundsException e) {
errorHandling("Bidi(char[], ...) should not throw an AIOoBE " +
"but an IAE when paragraphLength=6(too large).");
}
try {
}
catch (Exception e) {
errorHandling("Bidi(char[], ...) should not throw an exception " +
"even when flag=-3(too small).");
}
try {
}
catch (Exception e) {
errorHandling("Bidi(char[], ...) should not throw an exception " +
"even when flag=2(too large).");
}
}
private void callTestEachMethod4Constructor1(int textNo,
int testNo,
}
private void callTestEachMethod4Constructor2(int textNo,
int flagNo,
}
private void callTestEachMethod4Constructor3(int textNo,
int dataNo,
}
boolean expectedBaseIsLTR,
boolean expectedIsLTR,
boolean expectedIsRTL
) {
/* Test baseIsLeftToRight() */
/* Test getBaseLevel() */
/* Test getLength() */
/* Test getLevelAt() */
}
/* Test getRunCount() */
/* Test getRunLevel(), getRunLimit() and getRunStart() */
if (expectedInt == actualInt) {
int runCount = expectedInt;
int[] actualRunLevels = new int[runCount];
int[] actualRunLimits = new int[runCount];
int[] actualRunStarts = new int[runCount];
for (int k = 0; k < runCount; k++) {
}
}
/* Test isLeftToRight() */
boolean expectedBoolean = expectedIsLTR;
/* Test isMixed() */
/* Test isRightToLeft() */
}
int runCount = 1;
runCount++;
}
}
return runCount;
}
int i = 0;
array[i++] = c - '0';
array[i++] = c - '0';
}
}
return array;
}
int i = 0;
array[i++] = (byte)(c - '0');
array[i++] = (byte)(c - '0');
}
}
return array;
}
int i = 0;
}
}
return array;
}
int i = 1;
}
}
return array;
}
int runStart = 0;
for (int i = 0; i < runCount; i++) {
}
return array;
}
private void testMethod_createLineBidi1() {
checkResult("getBaseLevel()",
checkResult("getLevelAt(5)",
}
private void testMethod_createLineBidi2() {
try {
}
catch (Exception e) {
errorHandling("createLineBidi(0, textLength)" +
" should not throw an exception.");
}
try {
errorHandling("createLineBidi(-1, textLength)" +
" should throw an IAE.");
}
catch (IllegalArgumentException e) {
}
try {
errorHandling("createLineBidi(0, textLength+1)" +
" should throw an IAE.");
}
catch (IllegalArgumentException e) {
}
}
/*
* Confirm that getLevelAt() doesn't throw an exception for invalid offset
* unlike ICU4J.
*/
private void testMethod_getLevelAt() {
try {
errorHandling("getLevelAt(-1) returned a wrong level." +
}
}
catch (Exception e) {
errorHandling("getLevelAt(-1) should not throw an exception.");
}
try {
errorHandling("getLevelAt(textLength+1)" +
" returned a wrong level." +
}
}
catch (Exception e) {
errorHandling("getLevelAt(-1) should not throw an exception.");
}
}
private void testMethod_getRunLevel() {
try {
errorHandling("getRunLevel() should return 0" +
" when getRunCount() is 1.");
}
}
catch (Exception e) {
errorHandling("getRunLevel() should not throw an exception " +
"when getRunCount() is 1.");
}
try {
errorHandling("getRunLevel() should throw an AIOoBE " +
"when run is -1(too small).");
}
catch (ArrayIndexOutOfBoundsException e) {
}
catch (IllegalArgumentException e) {
errorHandling("getRunLevel() should not throw an IAE " +
"but an AIOoBE when run is -1(too small).");
}
try {
}
catch (Exception e) {
errorHandling("getRunLevel() should not throw an exception" +
" when run is from 0 to 2(runCount-1).");
}
try {
errorHandling("getRunLevel() should throw an AIOoBE" +
" when run is 3(same as runCount).");
}
catch (ArrayIndexOutOfBoundsException e) {
}
catch (IllegalArgumentException e) {
errorHandling("getRunLevel() should not throw an IAE " +
"but an AIOoBE when run is 3(same as runCount).");
}
}
private void testMethod_getRunLimit() {
try {
" when getRunCount() is 1.");
}
}
catch (Exception e) {
errorHandling("getRunLimit() should not throw an exception " +
"when getRunCount() is 1.");
}
try {
errorHandling("getRunLimit() should throw an AIOoBE " +
"when run is -1(too small).");
}
catch (ArrayIndexOutOfBoundsException e) {
}
catch (IllegalArgumentException e) {
errorHandling("getRunLimit() should not throw an IAE " +
"but an AIOoBE when run is -1(too small).");
}
try {
}
catch (ArrayIndexOutOfBoundsException e) {
errorHandling("getRunLimit() should not throw an AIOOBE " +
"when run is from 0 to 2(runCount-1).");
}
try {
errorHandling("getRunLimit() should throw an AIOoBE " +
"when run is 3(same as runCount).");
}
catch (ArrayIndexOutOfBoundsException e) {
}
catch (IllegalArgumentException e) {
errorHandling("getRunLimit() should not throw an IAE " +
"but an AIOoBE when run is 3(same as runCount).");
}
}
private void testMethod_getRunStart() {
try {
errorHandling("getRunStart() should return 0" +
" when getRunCount() is 1.");
}
}
catch (Exception e) {
errorHandling("getRunLimit() should not throw an exception" +
" when getRunCount() is 1.");
}
try {
errorHandling("getRunStart() should throw an AIOoBE" +
" when run is -1(too small).");
}
catch (ArrayIndexOutOfBoundsException e) {
}
catch (IllegalArgumentException e) {
errorHandling("getRunStart() should not throw an IAE " +
"but an AIOoBE when run is -1(too small).");
}
try {
}
catch (ArrayIndexOutOfBoundsException e) {
errorHandling("getRunStart() should not throw an AIOOBE " +
"when run is from 0 to 2(runCount-1).");
}
try {
" when run is 3(same as runCount).");
}
}
catch (Exception e) {
errorHandling("getRunStart() should not throw an exception " +
"when run is 3(same as runCount).");
}
try {
errorHandling("getRunStart() should throw an AIOoBE " +
"when run is runCount+1(too large).");
}
catch (ArrayIndexOutOfBoundsException e) {
}
catch (IllegalArgumentException e) {
errorHandling("getRunStart() should not throw an IAE " +
"but an AIOoBE when run is runCount+1(too large).");
}
}
private void testMethod_reorderVisually1() {
}
}
private void testMethod_reorderVisually2() {
try {
errorHandling("reorderVisually() should throw a NPE " +
"when levels is null.");
}
catch (NullPointerException e) {
}
try {
errorHandling("reorderVisually() should throw an IAE " +
"when levelStart is -1.");
}
catch (IllegalArgumentException e) {
}
catch (ArrayIndexOutOfBoundsException e) {
errorHandling("reorderVisually() should not throw an AIOoBE " +
"but an IAE when levelStart is -1.");
}
try {
errorHandling("reorderVisually() should throw an IAE " +
"when levelStart is 6(levels.length).");
}
catch (IllegalArgumentException e) {
}
catch (ArrayIndexOutOfBoundsException e) {
errorHandling("reorderVisually() should not throw an AIOoBE " +
"but an IAE when levelStart is 6(levels.length).");
}
try {
errorHandling("reorderVisually() should throw a NPE" +
" when objects is null.");
}
catch (NullPointerException e) {
}
try {
errorHandling("reorderVisually() should throw an IAE" +
" when objectStart is -1.");
}
catch (IllegalArgumentException e) {
}
catch (ArrayIndexOutOfBoundsException e) {
errorHandling("reorderVisually() should not throw an AIOoBE " +
"but an IAE when objectStart is -1.");
}
try {
errorHandling("reorderVisually() should throw an IAE " +
"when objectStart is 6(objects.length).");
}
catch (IllegalArgumentException e) {
}
try {
errorHandling("reorderVisually() should throw an IAE " +
"when count is -1.");
}
catch (IllegalArgumentException e) {
}
catch (NegativeArraySizeException e) {
errorHandling("reorderVisually() should not throw an NASE " +
"but an IAE when count is -1.");
}
try {
errorHandling("reorderVisually() should throw an IAE " +
"when count is 7(objects.length+1).");
}
catch (IllegalArgumentException e) {
}
catch (ArrayIndexOutOfBoundsException e) {
errorHandling("reorderVisually() should not throw an AIOoBE " +
"but an IAE when count is 7(objects.length+1).");
}
try {
checkResult("reorderVisually(count=0)",
}
catch (Exception e) {
errorHandling("reorderVisually() should not throw an exception" +
" when count is 0.");
}
}
private void testMethod_requiresBidi() {
char[] text;
error = true;
"\n Got : " + rBidi);
} else if (verbose) {
}
}
try {
errorHandling("requiresBidi() should throw an IAE" +
" when start is -1(too small).");
}
catch (IllegalArgumentException e) {
}
catch (ArrayIndexOutOfBoundsException e) {
errorHandling("requiresBidi() should not throw an AIOoBE " +
"but an IAE when start is -1(too small).");
}
try {
}
catch (Exception e) {
errorHandling("requiresBidi() should not throw an exception " +
"when start is textLength.");
}
try {
errorHandling("requiresBidi() should throw an IAE" +
" when start is textLength+1(too large).");
}
catch (IllegalArgumentException e) {
}
try {
errorHandling("requiresBidi() should throw an IAE" +
" when limit is -1(too small).");
}
catch (IllegalArgumentException e) {
}
try {
errorHandling("requiresBidi() should throw an IAE" +
" when limit is textLength+1(too large).");
}
catch (IllegalArgumentException e) {
}
catch (ArrayIndexOutOfBoundsException e) {
errorHandling("requiresBidi() should not throw an AIOoBE " +
"but an IAE when limit is textLength+1(too large).");
}
}
int expectedValue,
int actualValue) {
if (expectedValue != actualValue) {
} else if (verbose) {
}
}
boolean expectedValue,
boolean actualValue) {
if (expectedValue != actualValue) {
} else if (verbose) {
}
}
} else if (verbose) {
actualValue + "\"");
}
}
int[] expectedValues,
int[] actualValues) {
} else if (verbose) {
}
}
Object[] actualValues) {
} else if (verbose) {
}
}
if (abort) {
} else {
error = true;
}
}
}
}
}
}
} else {
}
}
} else {
}
}
else return null;
}
}
return s;
}
byte[] array = new byte[levelLength];
int textIndex = 0;
for (int i = 0; i < levelLength; i++) {
}
return array;
}
/* Bidi pubilc constants */
private static final int[] FLAGS = {
};
/* Bidi pubilc constants names */
"DIRECTION_DEFAULT_LEFT_TO_RIGHT", // -2
"DIRECTION_DEFAULT_RIGHT_TO_LEFT", // -1
"DIRECTION_LEFT_TO_RIGHT", // 0
"DIRECTION_RIGHT_TO_LEFT", // 1
};
/* Bidirectional Character Types */
private static final char L = '\u200E';
private static final char R = '\u202F';
private static final char LRE = '\u202A';
private static final char RLE = '\u202B';
private static final char PDF = '\u202C';
private static final char LRO = '\u202D';
private static final char RLO = '\u202E';
/*
* 0x05D0-0x05EA: [R] Hewbrew letters (Strong)
* 0x0627-0x063A: [AL] Arabic letters (Strong)
* 0x0660-0x0669: [AN] Arabic-Indic digits (Weak)
* 0x07CA-0x07E7: [R] NKo letters (Strong)
* 0x07C0-0x07C9: [R] NKo digits (Strong)
* 0xFE50-0xFEFF: [AL] Arabic presentaion form (Strong)
* 0x10480-0x1049D: [L] Osmanya letters (Strong)
* 0x104A0-0x104A9: [L] Osmanya digits (Strong)
* 0x10A10-0x10A33: [R] Kharoshthi letters (Strong)
* 0x10A40-0x10A43: [R] Kharoshthi digits (Strong)
*
* 0x200E: [L] Left-to-right mark (Implicit, Strong)
* 0x200F: [R] Right-to-left mark (Implicit, Strong)
* 0x202A: [LRE] Left-to-right embedding (Explicit, Strong)
* 0x202B: [RLE] Right-to-left embedding (Explicit, Strong)
* 0x202C: [PDF] Pop directional formatting (Explicit, Weak)
* 0x202D: [LRO] Left-to-right override (Explicit, Strong)
* 0x202E: [RLO] Right-to-left override (Explicit, Strong)
*/
/* Right-to-left */
private static String KharoshthiABC =
private static String Kharoshthi123 =
/* Left-to-right */
private static String OsmanyaABC =
private static String Osmanya123 =
/* --------------------------------------------------------------------- */
/*
* Test data for Bidi(char[], ...) constructor and methods
*/
/* Text for Bidi processing and its levels */
private static String[][] data4Constructor1 = {
/* For Text #0 */
{"abc <ABC XYZ> xyz.",
"000000000000000000", "000002222222000000", "000000000000000000",
"000003333333000000", "000000000000000000",
"222222222222222221", "222222222222222221", "222222222222222221",
"222113333333112221", "222224444444222221",
"000000000000000000", "000000000000000000", "222222222222222221"},
/* For Text #1 */
"000001111111000000", "000001111111000000", "000003333333000000",
"000003333333000000", "000000000000000000",
"222111111111112221", "222111111111112221", "222223333333222221",
"222113333333112221", "222224444444222221",
"000001111111000000", "000001111111000000", "222111111111112221"},
/* For Text #2 */
"111000000000001110", "111112222222111110", "111002222222001110",
"111113333333111110", "111004444444001110",
"111112222222111111", "111112222222111111", "111112222222111111",
"111111111111111111", "111114444444111111",
"111112222222111111", "111000000000001110", "111112222222111111"},
/* For Text #3 */
"111111111222111110", "111111111222111110", "111003333444001110",
"111113333333111110", "111004444444001110",
"111111111222111111", "111111111222111111", "111113333444111111",
"111111111111111111", "111114444444111111",
"111111111222111111", "111111111222111110", "111111111222111111"},
/* For Text #4 */
"000001111222000000", "000001111222000000", "000003333444000000",
"000003333333000000", "000000000000000000",
"222111111222112221", "222111111222112221", "222223333444222221",
"222113333333112221", "222224444444222221",
"000001111222000000", "000001111222000000", "222111111222112221"},
/* For Text #5 */
"000000000111000000", "000002221111000000", "000002222333000000",
"000003333333000000", "000000000000000000",
"222222221111112221", "222222221111112221", "222222222333222221",
"222113333333112221", "222224444444222221",
"000000000111000000", "000000000111000000", "222222221111112221"},
/* For Text #6 */
"111111111222112220", "111111111222112220", "111003333444002220",
"111113333333112220", "111004444444002220",
"111111111222112221", "111111111222112221", "111113333444112221",
"111113333333112221", "111114444444112221",
"111111111222112221", "111111111222112220", "111111111222112221"},
/* For Text #7 */
"111000000111112220", "111112221111112220", "111002222333002220",
"111113333333112220", "111004444444002220",
"111112221111112221", "111112221111112221", "111112222333112221",
"111113333333112221", "111114444444112221",
"111112221111112221", "111000000111112220", "111112221111112221"},
/* For Text #8 */
Osmanya123 + ".",
"000000001111111111111000000000", "000000001111111111111000000000",
"000000003333333333333000000000", "000000003333333333333000000000",
"000000000000000000000000000000",
"222222111111111111111112222221", "222222111111111111111112222221",
"222222223333333333333222222221", "222222113333333333333112222221",
"222222224444444444444222222221",
"000000001111111111111000000000", "000000001111111111111000000000",
"222222111111111111111112222221"},
/* For Text #9 */
Kharoshthi123 + ".",
"111111000000000000000001111110", "111111112222222222222111111110",
"111111002222222222222001111110", "111111113333333333333111111110",
"111111004444444444444001111110",
"111111112222222222222111111111", "111111112222222222222111111111",
"111111112222222222222111111111", "111111111111111111111111111111",
"111111114444444444444111111111",
"111111112222222222222111111111", "111111000000000000000001111110",
"111111112222222222222111111111"},
};
/* Golden data for baseIsLeftToRight() results */
private static boolean[][] baseIsLTR4Constructor1 = {
/* For Text #0 */
{true, true, true, true, true,
false, false, false, false, false,
true, true, false},
/* For Text #1 */
{true, true, true, true, true,
false, false, false, false, false,
true, true, false},
/* For Text #2 */
{true, true, true, true, true,
false, false, false, false, false,
false, true, false},
/* For Text #3 */
{true, true, true, true, true,
false, false, false, false, false,
false, true, false},
/* For Text #4 */
{true, true, true, true, true,
false, false, false, false, false,
true, true, false},
/* For Text #5 */
{true, true, true, true, true,
false, false, false, false, false,
true, true, false},
/* For Text #6 */
{true, true, true, true, true,
false, false, false, false, false,
false, true, false},
/* For Text #7 */
{true, true, true, true, true,
false, false, false, false, false,
false, true, false},
/* For Text #8 */
{true, true, true, true, true,
false, false, false, false, false,
true, true, false},
/* For Text #9 */
{true, true, true, true, true,
false, false, false, false, false,
false, true, false},
};
/* Golden data for isLeftToRight() & isRightToLeft() results */
private static boolean[][][] isLTR_isRTL4Constructor1 = {
/* For Text #0 */
/* isLeftToRight() results */
{{true, false, true, false, true,
false, false, false, false, false,
true, true, false},
/* isRightToLeft() results */
{false, false, false, false, false,
false, false, false, false, false,
false, false, false}},
/* For Text #1 */
/* isLeftToRight() results */
{{false, false, false, false, true,
false, false, false, false, false,
false, false, false},
/* isRightToLeft() results */
{false, false, false, false, false,
false, false, false, false, false,
false, false, false}},
/* For Text #2 */
/* isLeftToRight() results */
{{false, false, false, false, false,
false, false, false, false, false,
false, false, false},
/* isRightToLeft() results */
{false, false, false, false, false,
false, false, false, true, false,
false, false, false}},
/* For Text #3 */
/* isLeftToRight() results */
{{false, false, false, false, false,
false, false, false, false, false,
false, false, false},
/* isRightToLeft() results */
{false, false, false, false, false,
false, false, false, true, false,
false, false, false}},
/* For Text #4 */
/* isLeftToRight() results */
{{false, false, false, false, true,
false, false, false, false, false,
false, false, false},
/* isRightToLeft() results */
{false, false, false, false, false,
false, false, false, false, false,
false, false, false}},
/* For Text #5 */
/* isLeftToRight() results */
{{false, false, false, false, true,
false, false, false, false, false,
false, false, false},
/* isRightToLeft() results */
{false, false, false, false, false,
false, false, false, false, false,
false, false, false}},
/* For Text #6 */
/* isLeftToRight() results */
{{false, false, false, false, false,
false, false, false, false, false,
false, false, false},
/* isRightToLeft() results */
{false, false, false, false, false,
false, false, false, false, false,
false, false, false}},
/* For Text #7 */
/* isLeftToRight() results */
{{false, false, false, false, false,
false, false, false, false, false,
false, false, false},
/* isRightToLeft() results */
{false, false, false, false, false,
false, false, false, false, false,
false, false, false}},
/* For Text #8 */
/* isLeftToRight() results */
{{false, false, false, false, true,
false, false, false, false, false,
false, false, false},
/* isRightToLeft() results */
{false, false, false, false, false,
false, false, false, false, false,
false, false, false}},
/* For Text #9 */
/* isLeftToRight() results */
{{false, false, false, false, false,
false, false, false, false, false,
false, false, false},
/* isRightToLeft() results */
{false, false, false, false, false,
false, false, false, true, false,
false, false, false}},
};
/* --------------------------------------------------------------------- */
/*
* Test data for Bidi(String, int) constructor and methods
*/
/* Text for Bidi processing and its levels */
private static String[][] data4Constructor2 = {
/* For Text #0 */
{" ABC 123.",
"000000000", "000000000", "000000000", "122222221"},
/* For Text #1 */
"00000111111112220", "00000111111112220", "00000111111112220",
"12221111111112221"},
/* For Text #2 */
"00000111122212220", "00000111122212220", "00000111122212220",
"12221111122212221"},
/* For Text #3 */
"11111222222211111", "11111222222211111", "01110000000001110",
"11111222222211111"},
/* For Text #4 */
"11111222222212221", "11111222222212221", "01110000000002220",
"11111222222212221"},
/* For Text #5 */
"111111111", "111111111", "011111110", "111111111"},
/* For Text #6 */
"111112221", "111112221", "011112220", "111112221"},
/* For Text #7 */
"111111111111111", "111111111111111", "011111111111110",
"111111111111111"},
/* For Text #8 */
"011111110", "011111110", "011111110", "211111111"},
/* For Text #9 */
"000000000000", "000000000000", "000000000000", "122222222221"},
/* For Text #10 */
"000011111111222", "000011111111222", "000011111111222",
"222111111111222"},
/* For Text #11 */
"22221111111110", "22221111111110", "22221111111110",
"44443333333331"},
/* For Text #12 */
"000000000222211111111000", "000000000222211111111000",
"000000000222211111111000", "222222211444433333333111"},
/* For Text #13 */
".\"" + PDF,
"22222222224444333333332220", "22222222224444333333332220",
"22222222224444333333332220", "22222222224444333333332221"},
/* For Text #14 */
".\"", // PDF missing
"2222222222444433333333222", "2222222222444433333333222",
"2222222222444433333333222", "2222222222444433333333222"},
/* For Text #15 */
"0000000000000222222222244443333333322000",
"0000000000000222222222244443333333322000",
"0000000000000222222222244443333333322000",
"2222222222222222222222244443333333322111"},
/* For Text #16 */
"111111111111112222222222444433333333221110",
"111111111111112222222222444433333333221110",
"111111111111112222222222444433333333221110",
"333333333333334444444444666655555555443331"},
/* For Text #17 */
"11111111111111222222222244443333333322111",
"11111111111111222222222244443333333322111",
"11111111111111222222222244443333333322111",
"33333333333333444444444466665555555544333"},
/* For Text #18 */
"0000001111222112220", "0000001111222112220",
"0000001111222112220", "1222111111222112221"},
/* For Text #19 */
"1111112222222111111", "1111112222222111111",
"0111000000000001110", "1111112222222111111"},
/* For Text #20 */
"00000000002222111111110000", "00000000002222111111110000",
"00000000002222111111110000", "12222222114444333333331111"},
/* For Text #21 */
"000000000000002222222222444433333333220000",
"000000000000002222222222444433333333220000",
"000000000000002222222222444433333333220000",
"122222222222222222222222444433333333221111"},
/* For Text #22 */
PDF,
"22222221111111111111110", "22222221111111111111110",
"22222221111111111111110", "44444443333333333333331"},
};
/* Golden data for baseIsLeftToRight() results */
private static boolean[][] baseIsLTR4Constructor2 = {
/* For Text #0 - $4 */
{true, true, true, false},
{true, true, true, false},
{true, true, true, false},
{false, false, true, false},
{false, false, true, false},
/* For Text #5 - $9 */
{false, false, true, false},
{false, false, true, false},
{false, false, true, false},
{true, true, true, false},
{true, true, true, false},
/* For Text #10 - $14 */
{true, true, true, false},
{true, true, true, false},
{true, true, true, false},
{true, true, true, false},
{true, true, true, false},
/* For Text #15 - $19 */
{true, true, true, false},
{true, true, true, false},
{true, true, true, false},
{true, true, true, false},
{false, false, true, false},
/* For Text #20 - $22 */
{true, true, true, false},
{true, true, true, false},
{true, true, true, false},
};
/* Golden data for isLeftToRight() & isRightToLeft() results */
private static boolean[][][] isLTR_isRTL4Constructor2 = {
/* isLeftToRight() results & isRightToLeft() results */
/* For Text #0 - $4 */
{{true, true, true, false}, {false, false, false, false}},
{{false, false, false, false}, {false, false, false, false}},
{{false, false, false, false}, {false, false, false, false}},
{{false, false, false, false}, {false, false, false, false}},
{{false, false, false, false}, {false, false, false, false}},
/* For Text #5 - $9 */
{{false, false, false, false}, {true, true, false, true }},
{{false, false, false, false}, {false, false, false, false}},
{{false, false, false, false}, {true, true, false, true }},
{{false, false, false, false}, {false, false, false, false}},
{{true, true, true, false}, {false, false, false, false}},
/* For Text #10 - $14 */
{{false, false, false, false}, {false, false, false, false}},
{{false, false, false, false}, {false, false, false, false}},
{{false, false, false, false}, {false, false, false, false}},
{{false, false, false, false}, {false, false, false, false}},
{{false, false, false, false}, {false, false, false, false}},
/* For Text #15 - $19 */
{{false, false, false, false}, {false, false, false, false}},
{{false, false, false, false}, {false, false, false, false}},
{{false, false, false, false}, {false, false, false, false}},
{{false, false, false, false}, {false, false, false, false}},
{{false, false, false, false}, {false, false, false, false}},
/* For Text #20 - $22 */
{{false, false, false, false}, {false, false, false, false}},
{{false, false, false, false}, {false, false, false, false}},
{{false, false, false, false}, {false, false, false, false}},
};
/* Golden data for requiresBidi() results */
private static boolean[] requiresBidi4Constructor2 = {
/* For Text #0 - $9 */
false, true, true, true, true,
true, true, true, true, false,
/* For Text #10 - $19 */
true, true, true, true, true,
true, true, true, true, true,
/* For Text #20 - $22 */
true, true, true,
};
/* --------------------------------------------------------------------- */
/*
* Test data for Bidi(char[], ...) constructor and methods
*/
/* Enbeddings */
private static byte[][][] emb4Constructor3 = {
/* Embeddings for paragraphs which don't include surrogate pairs. */
{{0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, -3, -3, -3, -3, -3, -3, -3, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, -4, -4, -4, -4, -4, -4, -4, 0, 0, 0, 0, 0, 0}},
/* Embeddings for paragraphs which include surrogate pairs. */
{{ 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0,
-3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0,
-4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
0, 0, 0, 0, 0, 0, 0, 0, 0}},
};
/* Text for Bidi processing and its levels */
private static String[][] data4Constructor3 = {
/* For Text #0 */
{"abc <ABC XYZ> xyz.",
/* DIRECTION_DEFAULT_LEFT_TO_RIGHT */
"000002222222000000", "000000000000000000",
"000003333333000000", "000000000000000000",
/* DIRECTION_DEFAULT_RIGHT_TO_LEFT */
"222222222222222221", "222222222222222221",
"222113333333112221", "222224444444222221",
/* DIRECTION_LEFT_TO_RIGHT */
"000002222222000000", "000000000000000000",
"000003333333000000", "000000000000000000",
/* DIRECTION_RIGHT_TO_LEFT */
"222222222222222221", "222222222222222221",
"222113333333112221", "222224444444222221"},
/* For Text #1 */
/* DIRECTION_DEFAULT_LEFT_TO_RIGHT */
"000001111111000000", "000003333333000000",
"000003333333000000", "000000000000000000",
/* DIRECTION_DEFAULT_RIGHT_TO_LEFT */
"222111111111112221", "222223333333222221",
"222113333333112221", "222224444444222221",
/* DIRECTION_LEFT_TO_RIGHT */
"000001111111000000", "000003333333000000",
"000003333333000000", "000000000000000000",
/* DIRECTION_RIGHT_TO_LEFT */
"222111111111112221", "222223333333222221",
"222113333333112221", "222224444444222221"},
/* For Text #2 */
/* DIRECTION_DEFAULT_LEFT_TO_RIGHT */
"111112222222111111", "111112222222111111",
"111111111111111111", "111114444444111111",
/* DIRECTION_DEFAULT_RIGHT_TO_LEFT */
"111112222222111111", "111112222222111111",
"111111111111111111", "111114444444111111",
/* DIRECTION_LEFT_TO_RIGHT */
"111112222222111110", "111002222222001110",
"111113333333111110", "111004444444001110",
/* DIRECTION_RIGHT_TO_LEFT */
"111112222222111111", "111112222222111111",
"111111111111111111", "111114444444111111"},
/* For Text #3 */
/* DIRECTION_DEFAULT_LEFT_TO_RIGHT */
"111111111222111111", "111113333444111111",
"111111111111111111", "111114444444111111",
/* DIRECTION_DEFAULT_RIGHT_TO_LEFT */
"111111111222111111", "111113333444111111",
"111111111111111111", "111114444444111111",
/* DIRECTION_LEFT_TO_RIGHT */
"111111111222111110", "111003333444001110",
"111113333333111110", "111004444444001110",
/* DIRECTION_RIGHT_TO_LEFT */
"111111111222111111", "111113333444111111",
"111111111111111111", "111114444444111111"},
/* For Text #4 */
{"abc <123 456> xyz.",
/* DIRECTION_DEFAULT_LEFT_TO_RIGHT */
"000002221222000000", "000000000000000000",
"000003333333000000", "000000000000000000",
/* DIRECTION_DEFAULT_RIGHT_TO_LEFT */
"222222222222222221", "222222222222222221",
"222113333333112221", "222224444444222221",
/* DIRECTION_LEFT_TO_RIGHT */
"000002221222000000", "000000000000000000",
"000003333333000000", "000000000000000000",
/* DIRECTION_RIGHT_TO_LEFT */
"222222222222222221", "222222222222222221",
"222113333333112221", "222224444444222221"},
/* For Text #5 */
Osmanya123 + ".",
/* DIRECTION_DEFAULT_LEFT_TO_RIGHT */
"000000001111111111111000000000", "000000003333333333333000000000",
"000000003333333333333000000000", "000000000000000000000000000000",
/* DIRECTION_DEFAULT_RIGHT_TO_LEFT */
"222222111111111111111112222221", "222222223333333333333222222221",
"222222113333333333333112222221", "222222224444444444444222222221",
/* DIRECTION_LEFT_TO_RIGHT */
"000000001111111111111000000000", "000000003333333333333000000000",
"000000003333333333333000000000", "000000000000000000000000000000",
/* DIRECTION_RIGHT_TO_LEFT */
"222222111111111111111112222221", "222222223333333333333222222221",
"222222113333333333333112222221", "222222224444444444444222222221"},
/* For Text #6 */
Kharoshthi123 + ".",
/* DIRECTION_DEFAULT_LEFT_TO_RIGHT */
"111111112222222222222111111111", "111111112222222222222111111111",
"111111111111111111111111111111", "111111114444444444444111111111",
/* DIRECTION_DEFAULT_RIGHT_TO_LEFT */
"111111112222222222222111111111", "111111112222222222222111111111",
"111111111111111111111111111111", "111111114444444444444111111111",
/* DIRECTION_LEFT_TO_RIGHT */
"111111112222222222222111111110", "111111002222222222222001111110",
"111111113333333333333111111110", "111111004444444444444001111110",
/* DIRECTION_RIGHT_TO_LEFT */
"111111112222222222222111111111", "111111112222222222222111111111",
"111111111111111111111111111111", "111111114444444444444111111111"},
};
/* Golden data for baseIsLeftToRight() results */
private static boolean[][] baseIsLTR4Constructor3 = {
/* For Text #0 */
{true, true, true, true, // DIRECTION_DEFAULT_LEFT_TO_RIGHT
true, true, true, true, // DIRECTION_DEFAULT_RIGHT_TO_LEFT
true, true, true, true, // DIRECTION_LEFT_TO_RIGHT
false, false, false, false}, // DIRECTION_RIGHT_TO_LEFT
/* For Text #1 */
{true, true, true, true,
true, true, true, true,
true, true, true, true,
false, false, false, false},
/* For Text #2 */
{false, false, false, false,
false, false, false, false,
true, true, true, true,
false, false, false, false},
/* For Text #3 */
{false, false, false, false,
false, false, false, false,
true, true, true, true,
false, false, false, false},
/* For Text #4 */
{true, true, true, true,
true, true, true, true,
true, true, true, true,
false, false, false, false},
/* For Text #5 */
{true, true, true, true,
true, true, true, true,
true, true, true, true,
false, false, false, false},
/* For Text #6 */
{false, false, false, false,
false, false, false, false,
true, true, true, true,
false, false, false, false},
};
/* Golden data for isLeftToRight() & isRightToLeft() results */
private static boolean[][][] isLTR_isRTL4Constructor3 = {
/* For Text #0 */
/* isLeftToRight() results */
{{false, true, false, true, // DIRECTION_DEFAULT_LEFT_TO_RIGHT
false, false, false, false, // DIRECTION_DEFAULT_RIGHT_TO_LEFT
false, true, false, true, // DIRECTION_LEFT_TO_RIGHT
false, false, false, false}, // DIRECTION_RIGHT_TO_LEFT
/* isRightToLeft() results */
{false, false, false, false, // DIRECTION_DEFAULT_LEFT_TO_RIGHT
false, false, false, false, // DIRECTION_DEFAULT_RIGHT_TO_LEFT
false, false, false, false, // DIRECTION_LEFT_TO_RIGHT
false, false, false, false}}, // DIRECTION_RIGHT_TO_LEFTT
/* For Text #1 */
/* isLeftToRight() results */
{{false, false, false, true,
false, false, false, false,
false, false, false, true,
false, false, false, false},
/* isRightToLeft() results */
{false, false, false, false,
false, false, false, false,
false, false, false, false,
false, false, false, false}},
/* For Text #2 */
/* isLeftToRight() results */
{{false, false, false, false,
false, false, false, false,
false, false, false, false,
false, false, false, false},
/* isRightToLeft() results */
{false, false, true, false,
false, false, true, false,
false, false, false, false,
false, false, true, false}},
/* For Text #3 */
/* isLeftToRight() results */
{{false, false, false, false,
false, false, false, false,
false, false, false, false,
false, false, false, false},
/* isRightToLeft() results */
{false, false, true, false,
false, false, true, false,
false, false, false, false,
false, false, true, false}},
/* For Text #4 */
/* isLeftToRight() results */
{{false, true, false, true,
false, false, false, false,
false, true, false, true,
false, false, false, false },
/* isRightToLeft() results */
{false, false, false, false,
false, false, false, false,
false, false, false, false,
false, false, false, false}},
/* For Text #5 */
/* isLeftToRight() results */
{{false, false, false, true,
false, false, false, false,
false, false, false, true,
false, false, false, false},
/* isRightToLeft() results */
{false, false, false, false,
false, false, false, false,
false, false, false, false,
false, false, false, false}},
/* For Text #6 */
/* isLeftToRight() results */
{{false, false, false, false,
false, false, false, false,
false, false, false, false,
false, false, false, false},
/* isRightToLeft() results */
{false, false, true, false,
false, false, true, false,
false, false, false, false,
false, false, true, false}},
};
/* --------------------------------------------------------------------- */
/*
* Test data for reorderVisually() methods
*/
private static Object[][][] data4reorderVisually = {
{"000000001110"}, // levels
{"222111111111"},
{"222222111111111111"},
{"0000000000002222221111111111111100"},
};
}