1280N/A/*
2362N/A * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
1280N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1280N/A *
1280N/A * This code is free software; you can redistribute it and/or modify it
1280N/A * under the terms of the GNU General Public License version 2 only, as
1280N/A * published by the Free Software Foundation.
1280N/A *
1280N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1280N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1280N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1280N/A * version 2 for more details (a copy is included in the LICENSE file that
1280N/A * accompanied this code).
1280N/A *
1280N/A * You should have received a copy of the GNU General Public License version
1280N/A * 2 along with this work; if not, write to the Free Software Foundation,
1280N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1280N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
1280N/A */
1280N/A
1280N/A/*
1280N/A * @test
1280N/A * @bug 6850113
1280N/A * @summary confirm the behavior of new Bidi implementation. (Backward compatibility)
1280N/A */
1280N/A
1280N/Aimport java.awt.font.NumericShaper;
1280N/Aimport java.awt.font.TextAttribute;
1280N/Aimport java.text.AttributedString;
1280N/Aimport java.text.Bidi;
1280N/Aimport java.util.Arrays;
1280N/A
1280N/Apublic class BidiConformance {
1280N/A
1280N/A /* internal flags */
1280N/A private static boolean error = false;
1280N/A private static boolean verbose = false;
1280N/A private static boolean abort = false;
1280N/A
1280N/A public static void main(String[] args) {
1280N/A for (int i = 0; i < args.length; i++) {
1280N/A String arg = args[i];
1280N/A if (arg.equals("-verbose")) {
1280N/A verbose = true;
1280N/A } else if (arg.equals("-abort")) {
1280N/A abort = true;
1280N/A }
1280N/A }
1280N/A
1280N/A BidiConformance bc = new BidiConformance();
1280N/A bc.test();
1280N/A
1280N/A if (error) {
1280N/A throw new RuntimeException("Failed.");
1280N/A } else {
1280N/A System.out.println("Passed.");
1280N/A }
1280N/A }
1280N/A
1280N/A private void test() {
1280N/A testConstants();
1280N/A testConstructors();
1280N/A testMethods();
1280N/A
1280N/A testMethods4Constructor1(); // Bidi(AttributedCharacterIterator)
1280N/A testMethods4Constructor2(); // Bidi(String, int)
1280N/A testMethods4Constructor3(); // Bidi(char[], ...)
1280N/A }
1280N/A
1280N/A private void testConstants() {
1280N/A System.out.println("*** Test constants");
1280N/A
1280N/A checkResult("Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT",
1280N/A -2, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
1280N/A checkResult("Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT",
1280N/A -1, Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
1280N/A checkResult("Bidi.DIRECTION_LEFT_TO_RIGHT",
1280N/A 0, Bidi.DIRECTION_LEFT_TO_RIGHT);
1280N/A checkResult("Bidi.DIRECTION_RIGHT_TO_LEFT",
1280N/A 1, Bidi.DIRECTION_RIGHT_TO_LEFT);
1280N/A }
1280N/A
1280N/A private void testConstructors() {
1280N/A System.out.println("*** Test constructors");
1280N/A
1280N/A testConstructor1(); // Bidi(AttributedCharacterIterator)
1280N/A testConstructor2(); // Bidi(String, int)
1280N/A testConstructor3(); // Bidi(char[], ...)
1280N/A }
1280N/A
1280N/A private void testMethods() {
1280N/A System.out.println("*** Test methods");
1280N/A
1280N/A testMethod_createLineBidi1();
1280N/A testMethod_createLineBidi2();
1280N/A testMethod_getLevelAt();
1280N/A testMethod_getRunLevel();
1280N/A testMethod_getRunLimit();
1280N/A testMethod_getRunStart();
1280N/A testMethod_reorderVisually1();
1280N/A testMethod_reorderVisually2();
1280N/A testMethod_requiresBidi();
1280N/A }
1280N/A
1280N/A private void testMethods4Constructor1() {
1280N/A System.out.println("*** Test methods for constructor 1");
1280N/A
1280N/A String paragraph;
1280N/A Bidi bidi;
1280N/A NumericShaper ns = NumericShaper.getShaper(NumericShaper.ARABIC);
1280N/A
1280N/A for (int textNo = 0; textNo < data4Constructor1.length; textNo++) {
1280N/A paragraph = data4Constructor1[textNo][0];
1280N/A int start = paragraph.indexOf('<')+1;
1280N/A int limit = paragraph.indexOf('>');
1280N/A int testNo;
1280N/A
1280N/A System.out.println("*** Test textNo=" + textNo +
1280N/A ": Bidi(AttributedCharacterIterator\"" +
1280N/A toReadableString(paragraph) + "\") " +
1280N/A " start=" + start + ", limit=" + limit);
1280N/A
1280N/A // Test 0
1280N/A testNo = 0;
1280N/A System.out.println(" Test#" + testNo +": RUN_DIRECTION_LTR");
1280N/A AttributedString astr = new AttributedString(paragraph);
1280N/A astr.addAttribute(TextAttribute.RUN_DIRECTION,
1280N/A TextAttribute.RUN_DIRECTION_LTR);
1280N/A bidi = new Bidi(astr.getIterator());
1280N/A
1280N/A callTestEachMethod4Constructor1(textNo, testNo, bidi);
1280N/A
1280N/A // Test 1
1280N/A ++testNo;
1280N/A System.out.println(" Test#" + testNo +
1280N/A ": RUN_DIRECTION_LTR, BIDI_EMBEDDING(1)");
1280N/A astr = new AttributedString(paragraph);
1280N/A astr.addAttribute(TextAttribute.RUN_DIRECTION,
1280N/A TextAttribute.RUN_DIRECTION_LTR);
1280N/A astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(1),
1280N/A start, limit);
1280N/A bidi = new Bidi(astr.getIterator());
1280N/A callTestEachMethod4Constructor1(textNo, testNo, bidi);
1280N/A
1280N/A // Test 2
1280N/A ++testNo;
1280N/A System.out.println(" Test#" + testNo +
1280N/A ": RUN_DIERCTION_LTR, BIDI_EMBEDDING(2)");
1280N/A astr = new AttributedString(paragraph);
1280N/A astr.addAttribute(TextAttribute.RUN_DIRECTION,
1280N/A TextAttribute.RUN_DIRECTION_LTR);
1280N/A astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(2),
1280N/A start, limit);
1280N/A bidi = new Bidi(astr.getIterator());
1280N/A callTestEachMethod4Constructor1(textNo, testNo, bidi);
1280N/A
1280N/A // Test 3
1280N/A ++testNo;
1280N/A System.out.println(" Test#" + testNo +
1280N/A ": RUN_DIRECTIOIN_LTR, BIDI_EMBEDDING(-3)");
1280N/A astr = new AttributedString(paragraph);
1280N/A astr.addAttribute(TextAttribute.RUN_DIRECTION,
1280N/A TextAttribute.RUN_DIRECTION_LTR);
1280N/A astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(-3),
1280N/A start, limit);
1280N/A bidi = new Bidi(astr.getIterator());
1280N/A callTestEachMethod4Constructor1(textNo, testNo, bidi);
1280N/A
1280N/A // Test 4
1280N/A ++testNo;
1280N/A System.out.println(" Test#" + testNo +
1280N/A ": RUN_DIRECTION_LTR, BIDI_EMBEDDING(-4)");
1280N/A astr = new AttributedString(paragraph);
1280N/A astr.addAttribute(TextAttribute.RUN_DIRECTION,
1280N/A TextAttribute.RUN_DIRECTION_LTR);
1280N/A astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(-4),
1280N/A start, limit);
1280N/A bidi = new Bidi(astr.getIterator());
1280N/A callTestEachMethod4Constructor1(textNo, testNo, bidi);
1280N/A
1280N/A // Test 5
1280N/A ++testNo;
1280N/A System.out.println(" Test#" + testNo + ": RUN_DIRECTION_RTL");
1280N/A astr = new AttributedString(paragraph);
1280N/A astr.addAttribute(TextAttribute.RUN_DIRECTION,
1280N/A TextAttribute.RUN_DIRECTION_RTL);
1280N/A bidi = new Bidi(astr.getIterator());
1280N/A callTestEachMethod4Constructor1(textNo, testNo, bidi);
1280N/A
1280N/A // Test 6
1280N/A ++testNo;
1280N/A System.out.println(" Test#" + testNo +
1280N/A ": RUN_DIRECTION_RTL, BIDI_EMBEDDING(1)");
1280N/A astr = new AttributedString(paragraph);
1280N/A astr.addAttribute(TextAttribute.RUN_DIRECTION,
1280N/A TextAttribute.RUN_DIRECTION_RTL);
1280N/A astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(1),
1280N/A start, limit);
1280N/A try {
1280N/A bidi = new Bidi(astr.getIterator());
1280N/A callTestEachMethod4Constructor1(textNo, testNo, bidi);
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A errorHandling(" Unexpected exception: " + e);
1280N/A }
1280N/A
1280N/A // Test 7
1280N/A ++testNo;
1280N/A System.out.println(" Test#" + testNo +
1280N/A ": RUN_DIRECTION_RTL, BIDI_EMBEDDING(2)");
1280N/A astr = new AttributedString(paragraph);
1280N/A astr.addAttribute(TextAttribute.RUN_DIRECTION,
1280N/A TextAttribute.RUN_DIRECTION_RTL);
1280N/A astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(2),
1280N/A start, limit);
1280N/A try {
1280N/A bidi = new Bidi(astr.getIterator());
1280N/A callTestEachMethod4Constructor1(textNo, testNo, bidi);
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A errorHandling(" Unexpected exception: " + e);
1280N/A }
1280N/A
1280N/A // Test 8
1280N/A ++testNo;
1280N/A System.out.println(" Test#" + testNo +
1280N/A ": RUN_DIRECTION_RTL, BIDI_EMBEDDING(-3)");
1280N/A astr = new AttributedString(paragraph);
1280N/A astr.addAttribute(TextAttribute.RUN_DIRECTION,
1280N/A TextAttribute.RUN_DIRECTION_RTL);
1280N/A astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(-3),
1280N/A start, limit);
1280N/A try {
1280N/A bidi = new Bidi(astr.getIterator());
1280N/A callTestEachMethod4Constructor1(textNo, testNo, bidi);
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A errorHandling(" Unexpected exception: " + e);
1280N/A }
1280N/A
1280N/A // Test 9
1280N/A ++testNo;
1280N/A System.out.println(" Test#" + testNo +
1280N/A ": RUN_DIRECTION_RTL, BIDI_EMBEDDING(-4)");
1280N/A astr = new AttributedString(paragraph);
1280N/A astr.addAttribute(TextAttribute.RUN_DIRECTION,
1280N/A TextAttribute.RUN_DIRECTION_RTL);
1280N/A astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(-4),
1280N/A start, limit);
1280N/A try {
1280N/A bidi = new Bidi(astr.getIterator());
1280N/A callTestEachMethod4Constructor1(textNo, testNo, bidi);
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A errorHandling(" Unexpected exception: " + e);
1280N/A }
1280N/A
1280N/A // Test 10
1280N/A ++testNo;
1280N/A System.out.println(" Test#" + testNo +
1280N/A ": TextAttribute not specified");
1280N/A astr = new AttributedString(paragraph);
1280N/A bidi = new Bidi(astr.getIterator());
1280N/A callTestEachMethod4Constructor1(textNo, testNo, bidi);
1280N/A
1280N/A // Test 11
1280N/A ++testNo;
1280N/A System.out.println(" Test#" + testNo +
1280N/A ": RUN_DIRECTION_LTR, NUMERIC_SHAPING(ARABIC)");
1280N/A astr = new AttributedString(paragraph);
1280N/A astr.addAttribute(TextAttribute.RUN_DIRECTION,
1280N/A TextAttribute.RUN_DIRECTION_LTR);
1280N/A astr.addAttribute(TextAttribute.NUMERIC_SHAPING, ns);
1280N/A bidi = new Bidi(astr.getIterator());
1280N/A callTestEachMethod4Constructor1(textNo, testNo, bidi);
1280N/A
1280N/A // Test 12
1280N/A ++testNo;
1280N/A System.out.println(" Test#" + testNo +
1280N/A ": RUN_DIRECTION_RTL, NUMERIC_SHAPING(ARABIC)");
1280N/A astr = new AttributedString(paragraph);
1280N/A astr.addAttribute(TextAttribute.RUN_DIRECTION,
1280N/A TextAttribute.RUN_DIRECTION_RTL);
1280N/A astr.addAttribute(TextAttribute.NUMERIC_SHAPING, ns);
1280N/A bidi = new Bidi(astr.getIterator());
1280N/A callTestEachMethod4Constructor1(textNo, testNo, bidi);
1280N/A }
1280N/A }
1280N/A
1280N/A private void testMethods4Constructor2() {
1280N/A System.out.println("*** Test methods for constructor 2");
1280N/A
1280N/A String paragraph;
1280N/A Bidi bidi;
1280N/A
1280N/A for (int textNo = 0; textNo < data4Constructor2.length; textNo++) {
1280N/A paragraph = data4Constructor2[textNo][0];
1280N/A for (int flagNo = 0; flagNo < FLAGS.length; flagNo++) {
1280N/A int flag = FLAGS[flagNo];
1280N/A
1280N/A System.out.println("*** Test textNo=" + textNo +
1280N/A ": Bidi(\"" + toReadableString(paragraph) +
1280N/A "\", " + getFlagName(flag) + ")");
1280N/A
1280N/A bidi = new Bidi(paragraph, flag);
1280N/A callTestEachMethod4Constructor2(textNo, flagNo, bidi);
1280N/A }
1280N/A }
1280N/A }
1280N/A
1280N/A private void testMethods4Constructor3() {
1280N/A System.out.println("*** Test methods for constructor 3");
1280N/A
1280N/A String paragraph;
1280N/A Bidi bidi;
1280N/A
1280N/A for (int textNo = 0; textNo < data4Constructor3.length; textNo++) {
1280N/A paragraph = data4Constructor3[textNo][0];
1280N/A char[] c = paragraph.toCharArray();
1280N/A int start = paragraph.indexOf('<')+1;
1280N/A byte[][] embeddings = (c.length < emb4Constructor3[1][0].length) ?
1280N/A emb4Constructor3[0] : emb4Constructor3[1];
1280N/A for (int flagNo = 0; flagNo < FLAGS.length; flagNo++) {
1280N/A int flag = FLAGS[flagNo];
1280N/A for (int embNo = 0; embNo < embeddings.length; embNo++) {
1280N/A int dataNo = flagNo * FLAGS.length + embNo;
1280N/A
1280N/A System.out.println("*** Test textNo=" + textNo +
1280N/A ": Bidi(char[]\"" + toReadableString(paragraph) +
1280N/A "\", 0, embeddings={" + toString(embeddings[embNo]) +
1280N/A "}, " + c.length + ", " +
1280N/A getFlagName(flag) + ")" + " dataNo=" + dataNo);
1280N/A
1280N/A try {
1280N/A bidi = new Bidi(c, 0, embeddings[embNo], 0,
1280N/A c.length, flag);
1280N/A callTestEachMethod4Constructor3(textNo, dataNo, bidi);
1280N/A }
1280N/A catch (Exception e) {
1280N/A errorHandling(" Unexpected exception: " + e);
1280N/A }
1280N/A }
1280N/A }
1280N/A }
1280N/A }
1280N/A
1280N/A private void testConstructor1() {
1280N/A Bidi bidi;
1280N/A
1280N/A try {
1280N/A bidi = new Bidi(null);
1280N/A errorHandling("Bidi((AttributedCharacterIterator)null) " +
1280N/A "should throw an IAE.");
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A }
1280N/A catch (NullPointerException e) {
1280N/A errorHandling("Bidi((AttributedCharacterIterator)null) " +
1280N/A "should not throw an NPE but an IAE.");
1280N/A }
1280N/A
1280N/A String paragraph = data4Constructor1[1][0];
1280N/A int start = paragraph.indexOf('<')+1;
1280N/A int limit = paragraph.indexOf('>');
1280N/A AttributedString astr = new AttributedString(paragraph);
1280N/A astr.addAttribute(TextAttribute.RUN_DIRECTION,
1280N/A TextAttribute.RUN_DIRECTION_RTL);
1280N/A astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(-61),
1280N/A start, limit);
1280N/A try {
1280N/A bidi = new Bidi(astr.getIterator());
1280N/A for (int i = start; i < limit; i++) {
1280N/A if (bidi.getLevelAt(i) != 61) {
1280N/A errorHandling("Bidi(AttributedCharacterIterator).getLevelAt(" +
1280N/A i + ") should not be " + bidi.getLevelAt(i) +
1280N/A " but 60 when BIDI_EMBEDDING is -61.");
1280N/A }
1280N/A }
1280N/A }
1280N/A catch (Exception e) {
1280N/A errorHandling(" Unexpected exception: " + e);
1280N/A }
1280N/A
1280N/A astr = new AttributedString(paragraph);
1280N/A astr.addAttribute(TextAttribute.RUN_DIRECTION,
1280N/A TextAttribute.RUN_DIRECTION_RTL);
1280N/A astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(-62),
1280N/A start, limit);
1280N/A try {
1280N/A bidi = new Bidi(astr.getIterator());
1280N/A for (int i = start; i < limit; i++) {
1280N/A if (bidi.getLevelAt(i) != 1) {
1280N/A errorHandling("Bidi(AttributedCharacterIterator).getLevelAt() " +
1280N/A "should be 1 when BIDI_EMBEDDING is -62.");
1280N/A }
1280N/A }
1280N/A }
1280N/A catch (Exception e) {
1280N/A errorHandling(" Unexpected exception: " + e);
1280N/A }
1280N/A
1280N/A astr = new AttributedString(paragraph);
1280N/A astr.addAttribute(TextAttribute.RUN_DIRECTION,
1280N/A TextAttribute.RUN_DIRECTION_RTL);
1280N/A astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(60),
1280N/A start, limit);
1280N/A try {
1280N/A bidi = new Bidi(astr.getIterator());
1280N/A for (int i = start; i < limit; i++) {
1280N/A if (bidi.getLevelAt(i) != 61) {
1280N/A errorHandling("Bidi(AttributedCharacterIterator).getLevelAt() " +
1280N/A "should be 61 when BIDI_EMBEDDING is 60.");
1280N/A }
1280N/A }
1280N/A }
1280N/A catch (Exception e) {
1280N/A errorHandling(" Unexpected exception: " + e);
1280N/A }
1280N/A
1280N/A astr = new AttributedString(paragraph);
1280N/A astr.addAttribute(TextAttribute.RUN_DIRECTION,
1280N/A TextAttribute.RUN_DIRECTION_RTL);
1280N/A astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(61),
1280N/A start, limit);
1280N/A try {
1280N/A bidi = new Bidi(astr.getIterator());
1280N/A for (int i = start; i < limit; i++) {
1280N/A if (bidi.getLevelAt(i) != 61) {
1280N/A errorHandling("Bidi(AttributedCharacterIterator).getLevelAt(" +
1280N/A i + ") should not be " + bidi.getLevelAt(i) +
1280N/A " but 61 when BIDI_EMBEDDING is 61.");
1280N/A }
1280N/A }
1280N/A }
1280N/A catch (Exception e) {
1280N/A errorHandling(" Unexpected exception: " + e);
1280N/A }
1280N/A
1280N/A astr = new AttributedString(paragraph);
1280N/A astr.addAttribute(TextAttribute.RUN_DIRECTION,
1280N/A TextAttribute.RUN_DIRECTION_RTL);
1280N/A astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(62),
1280N/A start, limit);
1280N/A try {
1280N/A bidi = new Bidi(astr.getIterator());
1280N/A for (int i = start; i < limit; i++) {
1280N/A if (bidi.getLevelAt(i) != 1) {
1280N/A errorHandling("Bidi(AttributedCharacterIterator).getLevelAt()" +
1280N/A " should not be " + bidi.getLevelAt(i) +
1280N/A " but 1 when BIDI_EMBEDDING is 62.");
1280N/A }
1280N/A }
1280N/A }
1280N/A catch (Exception e) {
1280N/A errorHandling(" Unexpected exception: " + e);
1280N/A }
1280N/A }
1280N/A
1280N/A private void testConstructor2() {
1280N/A Bidi bidi;
1280N/A
1280N/A try {
1280N/A bidi = new Bidi(null, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
1280N/A errorHandling("Bidi((String)null, DIRECTION_DEFAULT_LEFT_TO_RIGHT)" +
1280N/A " should throw an IAE.");
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A }
1280N/A catch (NullPointerException e) {
1280N/A errorHandling("Bidi((String)null, DIRECTION_DEFAULT_LEFT_TO_RIGHT) " +
1280N/A "should not throw an NPE but an IAE.");
1280N/A }
1280N/A
1280N/A try {
1280N/A bidi = new Bidi("abc", -3);
1280N/A }
1280N/A catch (Exception e) {
1280N/A errorHandling("Bidi(\"abc\", -3) should not throw an exception: " +
1280N/A e);
1280N/A }
1280N/A
1280N/A try {
1280N/A bidi = new Bidi("abc", 2);
1280N/A }
1280N/A catch (Exception e) {
1280N/A errorHandling("Bidi(\"abc\", 2) should not throw an exception: " +
1280N/A e);
1280N/A }
1280N/A }
1280N/A
1280N/A private void testConstructor3() {
1280N/A char[] text = {'a', 'b', 'c', 'd', 'e'};
1280N/A byte[] embeddings = {0, 0, 0, 0, 0};
1280N/A Bidi bidi;
1280N/A
1280N/A try {
1280N/A bidi = new Bidi(null, 0, embeddings, 0, 5,
1280N/A Bidi.DIRECTION_LEFT_TO_RIGHT);
1280N/A errorHandling("Bidi(char[], ...) should throw an IAE " +
1280N/A "when text=null.");
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A }
1280N/A catch (NullPointerException e) {
1280N/A errorHandling("Bidi(char[], ...) should not throw an NPE " +
1280N/A "but an IAE when text=null.");
1280N/A }
1280N/A
1280N/A try {
1280N/A bidi = new Bidi(text, -1, embeddings, 0, 5,
1280N/A Bidi.DIRECTION_LEFT_TO_RIGHT);
1280N/A errorHandling("Bidi(char[], ...) should throw an IAE " +
1280N/A "when textStart is incorrect(-1: too small).");
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A }
1280N/A catch (ArrayIndexOutOfBoundsException e) {
1280N/A errorHandling("Bidi(char[], ...) should not throw an NPE " +
1280N/A "but an IAE when textStart is incorrect(-1: too small).");
1280N/A }
1280N/A
1280N/A try {
1280N/A bidi = new Bidi(text, 4, embeddings, 0, 2,
1280N/A Bidi.DIRECTION_LEFT_TO_RIGHT);
1280N/A errorHandling("Bidi(char[], ...) should throw an IAE " +
1280N/A "when textStart is incorrect(4: too large).");
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A }
1280N/A catch (ArrayIndexOutOfBoundsException e) {
1280N/A errorHandling("Bidi(char[], ...) should not throw an NPE " +
1280N/A "but an IAE when textStart is incorrect(4: too large).");
1280N/A }
1280N/A
1280N/A byte[] actualLevels = new byte[text.length];
1280N/A byte[] validEmbeddings1 = {0, -61, -60, -2, -1};
1280N/A byte[] expectedLevels1 = {0, 61, 60, 2, 1};
1280N/A try {
1280N/A bidi = new Bidi(text, 0, validEmbeddings1, 0, 5,
1280N/A Bidi.DIRECTION_LEFT_TO_RIGHT);
1280N/A for (int i = 0; i < text.length; i++) {
1280N/A actualLevels[i] = (byte)bidi.getLevelAt(i);
1280N/A }
1280N/A if (!Arrays.equals(expectedLevels1, actualLevels)) {
1280N/A errorHandling("Bidi(char[], ...).getLevelAt()" +
1280N/A " should be {" + toString(actualLevels) +
1280N/A "} when embeddings are {" +
1280N/A toString(expectedLevels1) + "}.");
1280N/A }
1280N/A }
1280N/A catch (Exception e) {
1280N/A errorHandling("Bidi(char[], ...) should not throw an exception " +
1280N/A "when embeddings is valid(-61).");
1280N/A }
1280N/A
1280N/A byte[] validEmbeddings2 = {0, 61, 60, 2, 1};
1280N/A byte[] expectedLevels2 = {0, 62, 60, 2, 2};
1280N/A try {
1280N/A bidi = new Bidi(text, 0, validEmbeddings2, 0, 5,
1280N/A Bidi.DIRECTION_LEFT_TO_RIGHT);
1280N/A for (int i = 0; i < text.length; i++) {
1280N/A actualLevels[i] = (byte)bidi.getLevelAt(i);
1280N/A }
1280N/A if (!Arrays.equals(expectedLevels2, actualLevels)) {
1280N/A errorHandling("Bidi(char[], ...).getLevelAt()" +
1280N/A " should be {" + toString(actualLevels) +
1280N/A "} when embeddings are {" +
1280N/A toString(expectedLevels2) + "}.");
1280N/A }
1280N/A }
1280N/A catch (Exception e) {
1280N/A errorHandling("Bidi(char[], ...) should not throw an exception " +
1280N/A "when embeddings is valid(61).");
1280N/A }
1280N/A
1280N/A byte[] invalidEmbeddings1 = {0, -62, 0, 0, 0};
1280N/A try {
1280N/A bidi = new Bidi(text, 0, invalidEmbeddings1, 0, 5,
1280N/A Bidi.DIRECTION_LEFT_TO_RIGHT);
1280N/A if (bidi.getLevelAt(1) != 0) {
1280N/A errorHandling("Bidi(char[], ...).getLevelAt(1) should be 0 " +
1280N/A "when embeddings[1] is -62.");
1280N/A }
1280N/A }
1280N/A catch (Exception e) {
1280N/A errorHandling("Bidi(char[], ...) should not throw an exception " +
1280N/A "even when embeddings includes -62.");
1280N/A }
1280N/A
1280N/A byte[] invalidEmbeddings2 = {0, 62, 0, 0, 0};
1280N/A try {
1280N/A bidi = new Bidi(text, 0, invalidEmbeddings2, 0, 5,
1280N/A Bidi.DIRECTION_LEFT_TO_RIGHT);
1280N/A if (bidi.getLevelAt(1) != 0) {
1280N/A errorHandling("Bidi(char[], ...).getLevelAt(1) should be 0 " +
1280N/A "when embeddings[1] is 62.");
1280N/A }
1280N/A }
1280N/A catch (Exception e) {
1280N/A errorHandling("Bidi(char[], ...) should not throw an exception " +
1280N/A "even when embeddings includes 62.");
1280N/A }
1280N/A
1280N/A try {
1280N/A bidi = new Bidi(text, 0, embeddings, 0, -1,
1280N/A Bidi.DIRECTION_LEFT_TO_RIGHT);
1280N/A errorHandling("Bidi(char[], ...) should throw an IAE " +
1280N/A "when paragraphLength=-1(too small).");
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A }
1280N/A catch (NegativeArraySizeException e) {
1280N/A errorHandling("Bidi(char[], ...) should not throw an NASE " +
1280N/A "but an IAE when paragraphLength=-1(too small).");
1280N/A }
1280N/A
1280N/A try {
1280N/A bidi = new Bidi(text, 0, embeddings, 0, 6,
1280N/A Bidi.DIRECTION_LEFT_TO_RIGHT);
1280N/A errorHandling("Bidi(char[], ...) should throw an IAE " +
1280N/A "when paragraphLength=6(too large).");
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A }
1280N/A catch (ArrayIndexOutOfBoundsException e) {
1280N/A errorHandling("Bidi(char[], ...) should not throw an AIOoBE " +
1280N/A "but an IAE when paragraphLength=6(too large).");
1280N/A }
1280N/A
1280N/A try {
1280N/A bidi = new Bidi(text, 0, embeddings, 0, 4, -3);
1280N/A }
1280N/A catch (Exception e) {
1280N/A errorHandling("Bidi(char[], ...) should not throw an exception " +
1280N/A "even when flag=-3(too small).");
1280N/A }
1280N/A
1280N/A try {
1280N/A bidi = new Bidi(text, 0, embeddings, 0, 5, 2);
1280N/A }
1280N/A catch (Exception e) {
1280N/A errorHandling("Bidi(char[], ...) should not throw an exception " +
1280N/A "even when flag=2(too large).");
1280N/A }
1280N/A }
1280N/A
1280N/A private void callTestEachMethod4Constructor1(int textNo,
1280N/A int testNo,
1280N/A Bidi bidi) {
1280N/A testEachMethod(bidi,
1280N/A data4Constructor1[textNo][0],
1280N/A data4Constructor1[textNo][testNo+1],
1280N/A baseIsLTR4Constructor1[textNo][testNo],
1280N/A isLTR_isRTL4Constructor1[textNo][0][testNo],
1280N/A isLTR_isRTL4Constructor1[textNo][1][testNo]);
1280N/A }
1280N/A
1280N/A private void callTestEachMethod4Constructor2(int textNo,
1280N/A int flagNo,
1280N/A Bidi bidi) {
1280N/A testEachMethod(bidi,
1280N/A data4Constructor2[textNo][0],
1280N/A data4Constructor2[textNo][flagNo+1],
1280N/A baseIsLTR4Constructor2[textNo][flagNo],
1280N/A isLTR_isRTL4Constructor2[textNo][0][flagNo],
1280N/A isLTR_isRTL4Constructor2[textNo][1][flagNo]);
1280N/A }
1280N/A
1280N/A private void callTestEachMethod4Constructor3(int textNo,
1280N/A int dataNo,
1280N/A Bidi bidi) {
1280N/A testEachMethod(bidi,
1280N/A data4Constructor3[textNo][0],
1280N/A data4Constructor3[textNo][dataNo+1],
1280N/A baseIsLTR4Constructor3[textNo][dataNo],
1280N/A isLTR_isRTL4Constructor3[textNo][0][dataNo],
1280N/A isLTR_isRTL4Constructor3[textNo][1][dataNo]);
1280N/A }
1280N/A
1280N/A private StringBuilder sb = new StringBuilder();
1280N/A private void testEachMethod(Bidi bidi,
1280N/A String text,
1280N/A String expectedLevels,
1280N/A boolean expectedBaseIsLTR,
1280N/A boolean expectedIsLTR,
1280N/A boolean expectedIsRTL
1280N/A ) {
1280N/A /* Test baseIsLeftToRight() */
1280N/A boolean actualBoolean = bidi.baseIsLeftToRight();
1280N/A checkResult("baseIsLeftToRight()", expectedBaseIsLTR, actualBoolean);
1280N/A
1280N/A /* Test getBaseLevel() */
1280N/A int expectedInt = (expectedBaseIsLTR) ? 0 : 1;
1280N/A int actualInt = bidi.getBaseLevel();
1280N/A checkResult("getBaseLevel()", expectedInt, actualInt);
1280N/A
1280N/A /* Test getLength() */
1280N/A expectedInt = text.length();
1280N/A actualInt = bidi.getLength();
1280N/A checkResult("getLength()", expectedInt, actualInt);
1280N/A
1280N/A /* Test getLevelAt() */
1280N/A sb.setLength(0);
1280N/A for (int i = 0; i < text.length(); i++) {
1280N/A sb.append(bidi.getLevelAt(i));
1280N/A }
1280N/A checkResult("getLevelAt()", expectedLevels, sb.toString());
1280N/A
1280N/A /* Test getRunCount() */
1280N/A expectedInt = getRunCount(expectedLevels);
1280N/A actualInt = bidi.getRunCount();
1280N/A checkResult("getRunCount()", expectedInt, actualInt);
1280N/A
1280N/A /* Test getRunLevel(), getRunLimit() and getRunStart() */
1280N/A if (expectedInt == actualInt) {
1280N/A int runCount = expectedInt;
1280N/A int[] expectedRunLevels = getRunLevels_int(runCount, expectedLevels);
1280N/A int[] expectedRunLimits = getRunLimits(runCount, expectedLevels);
1280N/A int[] expectedRunStarts = getRunStarts(runCount, expectedLevels);
1280N/A int[] actualRunLevels = new int[runCount];
1280N/A int[] actualRunLimits = new int[runCount];
1280N/A int[] actualRunStarts = new int[runCount];
1280N/A
1280N/A for (int k = 0; k < runCount; k++) {
1280N/A actualRunLevels[k] = bidi.getRunLevel(k);
1280N/A actualRunLimits[k] = bidi.getRunLimit(k);
1280N/A actualRunStarts[k] = bidi.getRunStart(k);
1280N/A }
1280N/A
1280N/A checkResult("getRunLevel()", expectedRunLevels, actualRunLevels);
1280N/A checkResult("getRunStart()", expectedRunStarts, actualRunStarts);
1280N/A checkResult("getRunLimit()", expectedRunLimits, actualRunLimits);
1280N/A }
1280N/A
1280N/A /* Test isLeftToRight() */
1280N/A boolean expectedBoolean = expectedIsLTR;
1280N/A actualBoolean = bidi.isLeftToRight();
1280N/A checkResult("isLeftToRight()", expectedBoolean, actualBoolean);
1280N/A
1280N/A /* Test isMixed() */
1280N/A expectedBoolean = !(expectedIsLTR || expectedIsRTL);
1280N/A actualBoolean = bidi.isMixed();
1280N/A checkResult("isMixed()", expectedBoolean, actualBoolean);
1280N/A
1280N/A /* Test isRightToLeft() */
1280N/A expectedBoolean = expectedIsRTL;
1280N/A actualBoolean = bidi.isRightToLeft();
1280N/A checkResult("isRightToLeft()", expectedBoolean, actualBoolean);
1280N/A }
1280N/A
1280N/A private int getRunCount(String levels) {
1280N/A int len = levels.length();
1280N/A char c = levels.charAt(0);
1280N/A int runCount = 1;
1280N/A
1280N/A for (int index = 1; index < len; index++) {
1280N/A if (levels.charAt(index) != c) {
1280N/A runCount++;
1280N/A c = levels.charAt(index);
1280N/A }
1280N/A }
1280N/A
1280N/A return runCount;
1280N/A }
1280N/A
1280N/A private int[] getRunLevels_int(int runCount, String levels) {
1280N/A int[] array = new int[runCount];
1280N/A int len = levels.length();
1280N/A char c = levels.charAt(0);
1280N/A int i = 0;
1280N/A array[i++] = c - '0';
1280N/A
1280N/A for (int index = 1; index < len; index++) {
1280N/A if (levels.charAt(index) != c) {
1280N/A c = levels.charAt(index);
1280N/A array[i++] = c - '0';
1280N/A }
1280N/A }
1280N/A
1280N/A return array;
1280N/A }
1280N/A
1280N/A private byte[] getRunLevels_byte(int runCount, String levels) {
1280N/A byte[] array = new byte[runCount];
1280N/A int len = levels.length();
1280N/A char c = levels.charAt(0);
1280N/A int i = 0;
1280N/A array[i++] = (byte)(c - '0');
1280N/A
1280N/A for (int index = 1; index < len; index++) {
1280N/A if (levels.charAt(index) != c) {
1280N/A c = levels.charAt(index);
1280N/A array[i++] = (byte)(c - '0');
1280N/A }
1280N/A }
1280N/A
1280N/A return array;
1280N/A }
1280N/A
1280N/A private int[] getRunLimits(int runCount, String levels) {
1280N/A int[] array = new int[runCount];
1280N/A int len = levels.length();
1280N/A char c = levels.charAt(0);
1280N/A int i = 0;
1280N/A
1280N/A for (int index = 1; index < len; index++) {
1280N/A if (levels.charAt(index) != c) {
1280N/A c = levels.charAt(index);
1280N/A array[i++] = index;
1280N/A }
1280N/A }
1280N/A array[i] = len;
1280N/A
1280N/A return array;
1280N/A }
1280N/A
1280N/A private int[] getRunStarts(int runCount, String levels) {
1280N/A int[] array = new int[runCount];
1280N/A int len = levels.length();
1280N/A char c = levels.charAt(0);
1280N/A int i = 1;
1280N/A
1280N/A for (int index = 1; index < len; index++) {
1280N/A if (levels.charAt(index) != c) {
1280N/A c = levels.charAt(index);
1280N/A array[i++] = index;
1280N/A }
1280N/A }
1280N/A
1280N/A return array;
1280N/A }
1280N/A
1280N/A private String[] getObjects(int runCount, String text, String levels) {
1280N/A String[] array = new String[runCount];
1280N/A int[] runLimits = getRunLimits(runCount, levels);
1280N/A int runStart = 0;
1280N/A
1280N/A for (int i = 0; i < runCount; i++) {
1280N/A array[i] = text.substring(runStart, runLimits[i]);
1280N/A runStart = runLimits[i];
1280N/A }
1280N/A
1280N/A return array;
1280N/A }
1280N/A
1280N/A private void testMethod_createLineBidi1() {
1280N/A System.out.println("*** Test createLineBidi() 1");
1280N/A
1280N/A String str = " ABC 123. " + HebrewABC + " " + NKo123 + ". ABC 123";
1280N/A
1280N/A int lineStart = str.indexOf('.') + 2;
1280N/A int lineLimit = str.lastIndexOf('.') + 2;
1280N/A Bidi bidi = new Bidi(str, FLAGS[0]);
1280N/A Bidi lineBidi = bidi.createLineBidi(lineStart, lineLimit);
1280N/A
1280N/A checkResult("getBaseLevel()",
1280N/A bidi.getBaseLevel(), lineBidi.getBaseLevel());
1280N/A checkResult("getLevelAt(5)",
1280N/A bidi.getLevelAt(lineStart+5), lineBidi.getLevelAt(5));
1280N/A }
1280N/A
1280N/A private void testMethod_createLineBidi2() {
1280N/A System.out.println("*** Test createLineBidi() 2");
1280N/A
1280N/A Bidi bidi = new Bidi(data4Constructor1[0][0], FLAGS[0]);
1280N/A int len = data4Constructor1[0][0].length();
1280N/A
1280N/A try {
1280N/A Bidi lineBidi = bidi.createLineBidi(0, len);
1280N/A }
1280N/A catch (Exception e) {
1280N/A errorHandling("createLineBidi(0, textLength)" +
1280N/A " should not throw an exception.");
1280N/A }
1280N/A
1280N/A try {
1280N/A Bidi lineBidi = bidi.createLineBidi(-1, len);
1280N/A errorHandling("createLineBidi(-1, textLength)" +
1280N/A " should throw an IAE.");
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A }
1280N/A
1280N/A try {
1280N/A Bidi lineBidi = bidi.createLineBidi(0, len+1);
1280N/A errorHandling("createLineBidi(0, textLength+1)" +
1280N/A " should throw an IAE.");
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A }
1280N/A }
1280N/A
1280N/A /*
1280N/A * Confirm that getLevelAt() doesn't throw an exception for invalid offset
1280N/A * unlike ICU4J.
1280N/A */
1280N/A private void testMethod_getLevelAt() {
1280N/A System.out.println("*** Test getLevelAt()");
1280N/A
1280N/A Bidi bidi = new Bidi(data4Constructor1[1][0], FLAGS[0]);
1280N/A int len = data4Constructor1[1][0].length();
1280N/A
1280N/A try {
1280N/A int level = bidi.getLevelAt(-1);
1280N/A if (level != bidi.getBaseLevel()) {
1280N/A errorHandling("getLevelAt(-1) returned a wrong level." +
1280N/A " Expected=" + bidi.getBaseLevel() + ", got=" + level);
1280N/A }
1280N/A }
1280N/A catch (Exception e) {
1280N/A errorHandling("getLevelAt(-1) should not throw an exception.");
1280N/A }
1280N/A
1280N/A try {
1280N/A int level = bidi.getLevelAt(len+1);
1280N/A if (level != bidi.getBaseLevel()) {
1280N/A errorHandling("getLevelAt(textLength+1)" +
1280N/A " returned a wrong level." +
1280N/A " Expected=" + bidi.getBaseLevel() + ", got=" + level);
1280N/A }
1280N/A }
1280N/A catch (Exception e) {
1280N/A errorHandling("getLevelAt(-1) should not throw an exception.");
1280N/A }
1280N/A }
1280N/A
1280N/A private void testMethod_getRunLevel() {
1280N/A System.out.println("*** Test getRunLevel()");
1280N/A
1280N/A String str = "ABC 123";
1280N/A Bidi bidi = new Bidi(str, Bidi.DIRECTION_LEFT_TO_RIGHT);
1280N/A try {
5621N/A if (bidi.getRunLevel(-1) != 0 || // runCount - 2 (out of range)
1280N/A bidi.getRunLevel(0) != 0 || // runCount - 1
5621N/A bidi.getRunLevel(1) != 0 || // runCount (out of range)
5621N/A bidi.getRunLevel(2) != 0) { // runCount + 1 (out of range)
5621N/A errorHandling("Incorrect getRunLevel() value(s).");
1280N/A }
1280N/A }
1280N/A catch (Exception e) {
5621N/A errorHandling("getRunLevel() should not throw an exception: " + e);
1280N/A }
1280N/A
1280N/A str = "ABC " + HebrewABC + " 123";
1280N/A bidi = new Bidi(str, Bidi.DIRECTION_LEFT_TO_RIGHT);
5621N/A try {
5621N/A if (bidi.getRunLevel(-1) != 0 || // runCount - 4 (out of range)
5621N/A bidi.getRunLevel(0) != 0 || // runCount - 3
5621N/A bidi.getRunLevel(1) != 1 || // runCount - 2
5621N/A bidi.getRunLevel(2) != 2 || // runCount - 1
5621N/A bidi.getRunLevel(3) != 0 || // runCount (out of range)
5621N/A bidi.getRunLevel(4) != 0) { // runCount + 1 (out of range)
5621N/A errorHandling("Incorrect getRunLevel() value(s).");
5621N/A }
5621N/A }
5621N/A catch (Exception e) {
5621N/A errorHandling("getRunLevel() should not throw an exception: " + e);
5621N/A }
1280N/A
5621N/A str = "ABC";
5621N/A bidi = new Bidi(str, Bidi.DIRECTION_LEFT_TO_RIGHT);
1280N/A try {
5621N/A if (bidi.getRunLevel(-1) != 0 || // runCount - 2 (out of range)
5621N/A bidi.getRunLevel(0) != 0 || // runCount - 1
5621N/A bidi.getRunLevel(1) != 0 || // runCount (out of range)
5621N/A bidi.getRunLevel(2) != 0) { // runCount + 1 (out of range)
5621N/A errorHandling("Incorrect getRunLevel() value(s).");
5621N/A }
5621N/A }
5621N/A catch (Exception e) {
5621N/A errorHandling("getRunLevel() should not throw an exception: " + e);
1280N/A }
5621N/A
5621N/A str = "ABC";
5621N/A bidi = new Bidi(str, Bidi.DIRECTION_RIGHT_TO_LEFT);
5621N/A try {
5621N/A if (bidi.getRunLevel(-1) != 1 || // runCount - 2 (out of range)
5621N/A bidi.getRunLevel(0) != 2 || // runCount - 1
5621N/A bidi.getRunLevel(1) != 1 || // runCount (out of range)
5621N/A bidi.getRunLevel(2) != 1) { // runCount + 1 (out of range)
5621N/A errorHandling("Incorrect getRunLevel() value(s).");
5621N/A }
5621N/A }
5621N/A catch (Exception e) {
5621N/A errorHandling("getRunLevel() should not throw an exception: " + e);
1280N/A }
5621N/A
5621N/A str = "ABC";
5621N/A bidi = new Bidi(str, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
5621N/A try {
5621N/A if (bidi.getRunLevel(-1) != 0 || // runCount - 2 (out of range)
5621N/A bidi.getRunLevel(0) != 0 || // runCount - 1
5621N/A bidi.getRunLevel(1) != 0 || // runCount (out of range)
5621N/A bidi.getRunLevel(2) != 0) { // runCount + 1 (out of range)
5621N/A errorHandling("Incorrect getRunLevel() value(s).");
5621N/A }
5621N/A }
5621N/A catch (Exception e) {
5621N/A errorHandling("getRunLevel() should not throw an exception: " + e);
1280N/A }
1280N/A
5621N/A str = "ABC";
5621N/A bidi = new Bidi(str, Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
1280N/A try {
5621N/A if (bidi.getRunLevel(-1) != 0 || // runCount - 2 (out of range)
5621N/A bidi.getRunLevel(0) != 0 || // runCount - 1
5621N/A bidi.getRunLevel(1) != 0 || // runCount (out of range)
5621N/A bidi.getRunLevel(2) != 0) { // runCount + 1 (out of range)
5621N/A errorHandling("Incorrect getRunLevel() value(s).");
5621N/A }
1280N/A }
1280N/A catch (Exception e) {
5621N/A errorHandling("getRunLevel() should not throw an exception: " + e);
5621N/A }
5621N/A
5621N/A str = HebrewABC;
5621N/A bidi = new Bidi(str, Bidi.DIRECTION_LEFT_TO_RIGHT);
5621N/A try {
5621N/A if (bidi.getRunLevel(-1) != 0 || // runCount - 2 (out of range)
5621N/A bidi.getRunLevel(0) != 1 || // runCount - 1
5621N/A bidi.getRunLevel(1) != 0 || // runCount (out of range)
5621N/A bidi.getRunLevel(2) != 0) { // runCount + 1 (out of range)
5621N/A errorHandling("Incorrect getRunLevel() value(s).");
5621N/A }
5621N/A }
5621N/A catch (Exception e) {
5621N/A errorHandling("getRunLevel() should not throw an exception: " + e);
1280N/A }
1280N/A
5621N/A str = HebrewABC;
5621N/A bidi = new Bidi(str, Bidi.DIRECTION_RIGHT_TO_LEFT);
1280N/A try {
5621N/A if (bidi.getRunLevel(-1) != 1 || // runCount - 2 (out of range)
5621N/A bidi.getRunLevel(0) != 1 || // runCount - 1
5621N/A bidi.getRunLevel(1) != 1 || // runCount (out of range)
5621N/A bidi.getRunLevel(2) != 1) { // runCount + 1 (out of range)
5621N/A errorHandling("Incorrect getRunLevel() value(s).");
5621N/A }
5621N/A }
5621N/A catch (Exception e) {
5621N/A errorHandling("getRunLevel() should not throw an exception: " + e);
1280N/A }
5621N/A
5621N/A str = HebrewABC;
5621N/A bidi = new Bidi(str, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
5621N/A try {
5621N/A if (bidi.getRunLevel(-1) != 1 || // runCount - 2 (out of range)
5621N/A bidi.getRunLevel(0) != 1 || // runCount - 1
5621N/A bidi.getRunLevel(1) != 1 || // runCount (out of range)
5621N/A bidi.getRunLevel(2) != 1) { // runCount + 1 (out of range)
5621N/A errorHandling("Incorrect getRunLevel() value(s).");
5621N/A }
5621N/A }
5621N/A catch (Exception e) {
5621N/A errorHandling("getRunLevel() should not throw an exception: " + e);
1280N/A }
5621N/A
5621N/A str = HebrewABC;
5621N/A bidi = new Bidi(str, Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
5621N/A try {
5621N/A if (bidi.getRunLevel(-1) != 1 || // runCount - 2 (out of range)
5621N/A bidi.getRunLevel(0) != 1 || // runCount - 1
5621N/A bidi.getRunLevel(1) != 1 || // runCount (out of range)
5621N/A bidi.getRunLevel(2) != 1) { // runCount + 1 (out of range)
5621N/A errorHandling("Incorrect getRunLevel() value(s).");
5621N/A }
5621N/A }
5621N/A catch (Exception e) {
5621N/A errorHandling("getRunLevel() should not throw an exception: " + e);
1280N/A }
1280N/A }
1280N/A
1280N/A private void testMethod_getRunLimit() {
1280N/A System.out.println("*** Test getRunLimit()");
1280N/A
1280N/A String str = "ABC 123";
1280N/A int length = str.length();
1280N/A Bidi bidi = new Bidi(str, Bidi.DIRECTION_LEFT_TO_RIGHT);
1280N/A
1280N/A try {
1280N/A if (bidi.getRunLimit(-1) != length || // runCount - 2
1280N/A bidi.getRunLimit(0) != length || // runCount - 1
1280N/A bidi.getRunLimit(1) != length || // runCount
1280N/A bidi.getRunLimit(2) != length) { // runCount + 1
1280N/A errorHandling("getRunLimit() should return " + length +
1280N/A " when getRunCount() is 1.");
1280N/A }
1280N/A }
1280N/A catch (Exception e) {
1280N/A errorHandling("getRunLimit() should not throw an exception " +
1280N/A "when getRunCount() is 1.");
1280N/A }
1280N/A
1280N/A str = "ABC " + ArabicABC + " 123";
1280N/A length = str.length();
1280N/A bidi = new Bidi(str, Bidi.DIRECTION_LEFT_TO_RIGHT);
1280N/A
1280N/A try {
1280N/A bidi.getRunLimit(-1);
1280N/A errorHandling("getRunLimit() should throw an AIOoBE " +
1280N/A "when run is -1(too small).");
1280N/A }
1280N/A catch (ArrayIndexOutOfBoundsException e) {
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A errorHandling("getRunLimit() should not throw an IAE " +
1280N/A "but an AIOoBE when run is -1(too small).");
1280N/A }
1280N/A
1280N/A try {
1280N/A bidi.getRunLimit(0);
1280N/A bidi.getRunLimit(1);
1280N/A bidi.getRunLimit(2);
1280N/A }
1280N/A catch (ArrayIndexOutOfBoundsException e) {
1280N/A errorHandling("getRunLimit() should not throw an AIOOBE " +
1280N/A "when run is from 0 to 2(runCount-1).");
1280N/A }
1280N/A
1280N/A try {
1280N/A bidi.getRunLimit(3);
1280N/A errorHandling("getRunLimit() should throw an AIOoBE " +
1280N/A "when run is 3(same as runCount).");
1280N/A }
1280N/A catch (ArrayIndexOutOfBoundsException e) {
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A errorHandling("getRunLimit() should not throw an IAE " +
1280N/A "but an AIOoBE when run is 3(same as runCount).");
1280N/A }
1280N/A }
1280N/A
1280N/A private void testMethod_getRunStart() {
1280N/A System.out.println("*** Test getRunStart()");
1280N/A
1280N/A String str = "ABC 123";
1280N/A int length = str.length();
1280N/A Bidi bidi = new Bidi(str, Bidi.DIRECTION_LEFT_TO_RIGHT);
1280N/A
1280N/A try {
1280N/A if (bidi.getRunStart(-1) != 0 || // runCount - 2
1280N/A bidi.getRunStart(0) != 0 || // runCount - 1
1280N/A bidi.getRunStart(1) != 0 || // runCount
1280N/A bidi.getRunStart(2) != 0) { // runCount + 1
1280N/A errorHandling("getRunStart() should return 0" +
1280N/A " when getRunCount() is 1.");
1280N/A }
1280N/A }
1280N/A catch (Exception e) {
1280N/A errorHandling("getRunLimit() should not throw an exception" +
1280N/A " when getRunCount() is 1.");
1280N/A }
1280N/A
1280N/A str = "ABC " + NKoABC + " 123";
1280N/A length = str.length();
1280N/A bidi = new Bidi(str, Bidi.DIRECTION_LEFT_TO_RIGHT);
1280N/A
1280N/A try {
1280N/A bidi.getRunStart(-1);
1280N/A errorHandling("getRunStart() should throw an AIOoBE" +
1280N/A " when run is -1(too small).");
1280N/A }
1280N/A catch (ArrayIndexOutOfBoundsException e) {
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A errorHandling("getRunStart() should not throw an IAE " +
1280N/A "but an AIOoBE when run is -1(too small).");
1280N/A }
1280N/A
1280N/A try {
1280N/A bidi.getRunStart(0);
1280N/A bidi.getRunStart(1);
1280N/A bidi.getRunStart(2);
1280N/A }
1280N/A catch (ArrayIndexOutOfBoundsException e) {
1280N/A errorHandling("getRunStart() should not throw an AIOOBE " +
1280N/A "when run is from 0 to 2(runCount-1).");
1280N/A }
1280N/A
1280N/A try {
1280N/A if (bidi.getRunStart(3) != length) {
1280N/A errorHandling("getRunStart() should return " + length +
1280N/A " when run is 3(same as runCount).");
1280N/A }
1280N/A }
1280N/A catch (Exception e) {
1280N/A errorHandling("getRunStart() should not throw an exception " +
1280N/A "when run is 3(same as runCount).");
1280N/A }
1280N/A
1280N/A try {
1280N/A bidi.getRunStart(4);
1280N/A errorHandling("getRunStart() should throw an AIOoBE " +
1280N/A "when run is runCount+1(too large).");
1280N/A }
1280N/A catch (ArrayIndexOutOfBoundsException e) {
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A errorHandling("getRunStart() should not throw an IAE " +
1280N/A "but an AIOoBE when run is runCount+1(too large).");
1280N/A }
1280N/A }
1280N/A
1280N/A private void testMethod_reorderVisually1() {
1280N/A System.out.println("*** Test reorderVisually() 1");
1280N/A
1280N/A for (int textNo = 0; textNo < data4reorderVisually.length; textNo++) {
1280N/A Object[] objects = data4reorderVisually[textNo][0];
1280N/A byte[] levels = getLevels(data4reorderVisually[textNo]);
1280N/A Object[] expectedObjects = data4reorderVisually[textNo][2];
1280N/A
1280N/A Bidi.reorderVisually(levels, 0, objects, 0, objects.length);
1280N/A
1280N/A checkResult("textNo=" + textNo + ": reorderVisually(levels=[" +
1280N/A toString(levels) + "], objects=[" + toString(objects) + "])",
1280N/A expectedObjects, objects);
1280N/A }
1280N/A }
1280N/A
1280N/A private void testMethod_reorderVisually2() {
1280N/A System.out.println("*** Test reorderVisually() 2");
1280N/A
1280N/A Object[] objects = data4reorderVisually[0][0];
1280N/A byte[] levels = getLevels(data4reorderVisually[0]);
1280N/A int count = objects.length;
1280N/A int llen = levels.length;
1280N/A int olen = objects.length;
1280N/A
1280N/A try {
1280N/A Bidi.reorderVisually(null, 0, objects, 0, count);
1280N/A errorHandling("reorderVisually() should throw a NPE " +
1280N/A "when levels is null.");
1280N/A }
1280N/A catch (NullPointerException e) {
1280N/A }
1280N/A
1280N/A try {
1280N/A Bidi.reorderVisually(levels, -1, objects, 0, count);
1280N/A errorHandling("reorderVisually() should throw an IAE " +
1280N/A "when levelStart is -1.");
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A }
1280N/A catch (ArrayIndexOutOfBoundsException e) {
1280N/A errorHandling("reorderVisually() should not throw an AIOoBE " +
1280N/A "but an IAE when levelStart is -1.");
1280N/A }
1280N/A
1280N/A try {
1280N/A Bidi.reorderVisually(levels, llen, objects, 0, count);
1280N/A errorHandling("reorderVisually() should throw an IAE " +
1280N/A "when levelStart is 6(levels.length).");
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A }
1280N/A catch (ArrayIndexOutOfBoundsException e) {
1280N/A errorHandling("reorderVisually() should not throw an AIOoBE " +
1280N/A "but an IAE when levelStart is 6(levels.length).");
1280N/A }
1280N/A
1280N/A try {
1280N/A Bidi.reorderVisually(levels, 0, null, 0, count);
1280N/A errorHandling("reorderVisually() should throw a NPE" +
1280N/A " when objects is null.");
1280N/A }
1280N/A catch (NullPointerException e) {
1280N/A }
1280N/A
1280N/A try {
1280N/A Bidi.reorderVisually(levels, 0, objects, -1, count);
1280N/A errorHandling("reorderVisually() should throw an IAE" +
1280N/A " when objectStart is -1.");
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A }
1280N/A catch (ArrayIndexOutOfBoundsException e) {
1280N/A errorHandling("reorderVisually() should not throw an AIOoBE " +
1280N/A "but an IAE when objectStart is -1.");
1280N/A }
1280N/A
1280N/A try {
1280N/A Bidi.reorderVisually(levels, 0, objects, 6, objects.length);
1280N/A errorHandling("reorderVisually() should throw an IAE " +
1280N/A "when objectStart is 6(objects.length).");
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A }
1280N/A
1280N/A try {
1280N/A Bidi.reorderVisually(levels, 0, objects, 0, -1);
1280N/A errorHandling("reorderVisually() should throw an IAE " +
1280N/A "when count is -1.");
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A }
1280N/A catch (NegativeArraySizeException e) {
1280N/A errorHandling("reorderVisually() should not throw an NASE " +
1280N/A "but an IAE when count is -1.");
1280N/A }
1280N/A
1280N/A try {
1280N/A Bidi.reorderVisually(levels, 0, objects, 0, count+1);
1280N/A errorHandling("reorderVisually() should throw an IAE " +
1280N/A "when count is 7(objects.length+1).");
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A }
1280N/A catch (ArrayIndexOutOfBoundsException e) {
1280N/A errorHandling("reorderVisually() should not throw an AIOoBE " +
1280N/A "but an IAE when count is 7(objects.length+1).");
1280N/A }
1280N/A
1280N/A try {
1280N/A Bidi.reorderVisually(levels, 0, objects, 0, 0);
1280N/A checkResult("reorderVisually(count=0)",
1280N/A data4reorderVisually[0][0], objects);
1280N/A }
1280N/A catch (Exception e) {
1280N/A errorHandling("reorderVisually() should not throw an exception" +
1280N/A " when count is 0.");
1280N/A }
1280N/A }
1280N/A
1280N/A private void testMethod_requiresBidi() {
1280N/A System.out.println("*** Test requiresBidi()");
1280N/A
1280N/A String paragraph;
1280N/A char[] text;
1280N/A Bidi bidi;
1280N/A
1280N/A for (int textNo = 0; textNo < data4Constructor2.length; textNo++) {
1280N/A paragraph = data4Constructor2[textNo][0];
1280N/A text = paragraph.toCharArray();
1280N/A boolean rBidi = Bidi.requiresBidi(text, 0, text.length);
1280N/A if (rBidi != requiresBidi4Constructor2[textNo]) {
1280N/A error = true;
1280N/A System.err.println("Unexpected requiresBidi() value" +
1280N/A " for requiresBidi(\"" + paragraph + "\", " + 0 + ", " +
1280N/A text.length + ")." +
1280N/A "\n Expected: " + requiresBidi4Constructor2[textNo] +
1280N/A "\n Got : " + rBidi);
1280N/A } else if (verbose) {
1280N/A System.out.println(" Okay : requiresBidi() for" +
1280N/A " requiresBidi(\"" + paragraph + "\", " + 0 + ", " +
1280N/A text.length + ") Got: " + rBidi);
1280N/A }
1280N/A }
1280N/A
1280N/A char[] txt = {'A', 'B', 'C', 'D', 'E'};
1280N/A int textLength = txt.length;
1280N/A
1280N/A try {
1280N/A Bidi.requiresBidi(txt, -1, textLength);
1280N/A errorHandling("requiresBidi() should throw an IAE" +
1280N/A " when start is -1(too small).");
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A }
1280N/A catch (ArrayIndexOutOfBoundsException e) {
1280N/A errorHandling("requiresBidi() should not throw an AIOoBE " +
1280N/A "but an IAE when start is -1(too small).");
1280N/A }
1280N/A
1280N/A try {
1280N/A Bidi.requiresBidi(txt, textLength, textLength);
1280N/A }
1280N/A catch (Exception e) {
1280N/A errorHandling("requiresBidi() should not throw an exception " +
1280N/A "when start is textLength.");
1280N/A }
1280N/A
1280N/A try {
1280N/A Bidi.requiresBidi(txt, textLength+1, textLength);
1280N/A errorHandling("requiresBidi() should throw an IAE" +
1280N/A " when start is textLength+1(too large).");
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A }
1280N/A
1280N/A try {
1280N/A Bidi.requiresBidi(txt, 0, -1);
1280N/A errorHandling("requiresBidi() should throw an IAE" +
1280N/A " when limit is -1(too small).");
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A }
1280N/A
1280N/A try {
1280N/A Bidi.requiresBidi(txt, 0, textLength+1);
1280N/A errorHandling("requiresBidi() should throw an IAE" +
1280N/A " when limit is textLength+1(too large).");
1280N/A }
1280N/A catch (IllegalArgumentException e) {
1280N/A }
1280N/A catch (ArrayIndexOutOfBoundsException e) {
1280N/A errorHandling("requiresBidi() should not throw an AIOoBE " +
1280N/A "but an IAE when limit is textLength+1(too large).");
1280N/A }
1280N/A }
1280N/A
1280N/A private void checkResult(String name,
1280N/A int expectedValue,
1280N/A int actualValue) {
1280N/A if (expectedValue != actualValue) {
1280N/A errorHandling("Unexpected " + name + " value." +
1280N/A " Expected: " + expectedValue + " Got: " + actualValue);
1280N/A } else if (verbose) {
1280N/A System.out.println(" Okay : " + name + " = " + actualValue);
1280N/A }
1280N/A }
1280N/A
1280N/A private void checkResult(String name,
1280N/A boolean expectedValue,
1280N/A boolean actualValue) {
1280N/A if (expectedValue != actualValue) {
1280N/A errorHandling("Unexpected " + name + " value." +
1280N/A " Expected: " + expectedValue + " Got: " + actualValue);
1280N/A } else if (verbose) {
1280N/A System.out.println(" Okay : " + name + " = " + actualValue);
1280N/A }
1280N/A }
1280N/A
1280N/A private void checkResult(String name,
1280N/A String expectedValue,
1280N/A String actualValue) {
1280N/A if (!expectedValue.equals(actualValue)) {
1280N/A errorHandling("Unexpected " + name + " value." +
1280N/A "\n\tExpected: \"" + expectedValue + "\"" +
1280N/A "\n\tGot: \"" + actualValue + "\"");
1280N/A } else if (verbose) {
1280N/A System.out.println(" Okay : " + name + " = \"" +
1280N/A actualValue + "\"");
1280N/A }
1280N/A }
1280N/A
1280N/A private void checkResult(String name,
1280N/A int[] expectedValues,
1280N/A int[] actualValues) {
1280N/A if (!Arrays.equals(expectedValues, actualValues)) {
1280N/A errorHandling("Unexpected " + name + " value." +
1280N/A "\n\tExpected: " + toString(expectedValues) + "" +
1280N/A "\n\tGot: " + toString(actualValues) + "");
1280N/A } else if (verbose) {
1280N/A System.out.println(" Okay : " + name + " = " +
1280N/A toString(actualValues));
1280N/A }
1280N/A }
1280N/A
1280N/A private void checkResult(String name,
1280N/A Object[] expectedValues,
1280N/A Object[] actualValues) {
1280N/A if (!Arrays.equals(expectedValues, actualValues)) {
1280N/A errorHandling("Unexpected " + name + " value." +
1280N/A "\n\tExpected: [" + toString(expectedValues) +
1280N/A "]\n\tGot: [" + toString(actualValues) + "]");
1280N/A } else if (verbose) {
1280N/A System.out.println(" Okay : " + name + " Reordered objects = [" +
1280N/A toString(actualValues) + "]");
1280N/A }
1280N/A }
1280N/A
1280N/A private void errorHandling(String msg) {
1280N/A if (abort) {
1280N/A throw new RuntimeException("Error: " + msg);
1280N/A } else {
1280N/A error = true;
1280N/A System.err.println("**Error:" + msg);
1280N/A }
1280N/A }
1280N/A
1280N/A private String toString(int[] values) {
1280N/A StringBuilder sb = new StringBuilder();
1280N/A for (int i = 0; i < values.length-1; i++) {
1280N/A sb.append((int)values[i]);
1280N/A sb.append(' ');
1280N/A }
1280N/A sb.append((int)values[values.length-1]);
1280N/A
1280N/A return sb.toString();
1280N/A }
1280N/A
1280N/A private String toString(byte[] values) {
1280N/A StringBuilder sb = new StringBuilder();
1280N/A for (int i = 0; i < values.length-1; i++) {
1280N/A sb.append((byte)values[i]);
1280N/A sb.append(' ');
1280N/A }
1280N/A sb.append((byte)values[values.length-1]);
1280N/A
1280N/A return sb.toString();
1280N/A }
1280N/A
1280N/A private String toString(Object[] values) {
1280N/A StringBuilder sb = new StringBuilder();
1280N/A String name;
1280N/A
1280N/A for (int i = 0; i < values.length-1; i++) {
1280N/A if ((name = getStringName((String)values[i])) != null) {
1280N/A sb.append(name);
1280N/A sb.append(", ");
1280N/A } else {
1280N/A sb.append('"');
1280N/A sb.append((String)values[i]);
1280N/A sb.append("\", ");
1280N/A }
1280N/A }
1280N/A if ((name = getStringName((String)values[values.length-1])) != null) {
1280N/A sb.append(name);
1280N/A } else {
1280N/A sb.append('"');
1280N/A sb.append((String)values[values.length-1]);
1280N/A sb.append('\"');
1280N/A }
1280N/A
1280N/A return sb.toString();
1280N/A }
1280N/A
1280N/A private String getStringName(String str) {
1280N/A if (ArabicABC.equals(str)) return "ArabicABC";
1280N/A else if (Arabic123.equals(str)) return "Arabic123";
1280N/A else if (PArabicABC.equals(str)) return "ArabicABC(Presentation form)";
1280N/A else if (HebrewABC.equals(str)) return "HebrewABC";
1280N/A else if (KharoshthiABC.equals(str)) return "KharoshthiABC(RTL)";
1280N/A else if (Kharoshthi123.equals(str)) return "Kharoshthi123(RTL)";
1280N/A else if (NKoABC.equals(str)) return "NKoABC(RTL)";
1280N/A else if (NKo123.equals(str)) return "NKo123(RTL)";
1280N/A else if (OsmanyaABC.equals(str)) return "OsmanyaABC(LTR)";
1280N/A else if (Osmanya123.equals(str)) return "Osmanya123(LTR)";
1280N/A else return null;
1280N/A }
1280N/A
1280N/A private String getFlagName(int flag) {
1280N/A if (flag == -2 || flag == 0x7e) return FLAGNAMES[0];
1280N/A else if (flag == -1 || flag == 0x7f) return FLAGNAMES[1];
1280N/A else if (flag == 0) return FLAGNAMES[2];
1280N/A else if (flag == 1) return FLAGNAMES[3];
1280N/A else return "Unknown(0x" + Integer.toHexString(flag) + ")";
1280N/A }
1280N/A
1280N/A private String toReadableString(String str) {
1280N/A String s = str;
1280N/A
1280N/A s = s.replaceAll(ArabicABC, "ArabicABC");
1280N/A s = s.replaceAll(Arabic123, "Arabic123");
1280N/A s = s.replaceAll(PArabicABC, "ArabicABC(Presentation form)");
1280N/A s = s.replaceAll(HebrewABC, "HebrewABC");
1280N/A s = s.replaceAll(KharoshthiABC, "KharoshthiABC");
1280N/A s = s.replaceAll(Kharoshthi123, "Kharoshthi123");
1280N/A s = s.replaceAll(NKoABC, "NKoABC");
1280N/A s = s.replaceAll(NKo123, "NKo123");
1280N/A s = s.replaceAll(OsmanyaABC, "OsmanyaABC");
1280N/A s = s.replaceAll(Osmanya123, "Osmanya123");
1280N/A
1280N/A return s;
1280N/A }
1280N/A
1280N/A private byte[] getLevels(Object[][] data) {
1280N/A int levelLength = data[0].length;
1280N/A byte[] array = new byte[levelLength];
1280N/A int textIndex = 0;
1280N/A
1280N/A for (int i = 0; i < levelLength; i++) {
1280N/A array[i] = (byte)(((String)data[1][0]).charAt(textIndex) - '0');
1280N/A textIndex += ((String)data[0][i]).length();
1280N/A }
1280N/A
1280N/A return array;
1280N/A }
1280N/A
1280N/A
1280N/A /* Bidi pubilc constants */
1280N/A private static final int[] FLAGS = {
1280N/A Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT, // -2 (0x7e in ICU4J)
1280N/A Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT, // -1 (0x7f in ICU4J)
1280N/A Bidi.DIRECTION_LEFT_TO_RIGHT, // 0
1280N/A Bidi.DIRECTION_RIGHT_TO_LEFT // 1
1280N/A };
1280N/A
1280N/A /* Bidi pubilc constants names */
1280N/A private static final String[] FLAGNAMES = {
1280N/A "DIRECTION_DEFAULT_LEFT_TO_RIGHT", // -2
1280N/A "DIRECTION_DEFAULT_RIGHT_TO_LEFT", // -1
1280N/A "DIRECTION_LEFT_TO_RIGHT", // 0
1280N/A "DIRECTION_RIGHT_TO_LEFT", // 1
1280N/A };
1280N/A
1280N/A /* Bidirectional Character Types */
1280N/A private static final char L = '\u200E';
1280N/A private static final char R = '\u202F';
1280N/A private static final char LRE = '\u202A';
1280N/A private static final char RLE = '\u202B';
1280N/A private static final char PDF = '\u202C';
1280N/A private static final char LRO = '\u202D';
1280N/A private static final char RLO = '\u202E';
1280N/A
1280N/A /*
1280N/A * 0x05D0-0x05EA: [R] Hewbrew letters (Strong)
1280N/A * 0x0627-0x063A: [AL] Arabic letters (Strong)
1280N/A * 0x0660-0x0669: [AN] Arabic-Indic digits (Weak)
1280N/A * 0x07CA-0x07E7: [R] NKo letters (Strong)
1280N/A * 0x07C0-0x07C9: [R] NKo digits (Strong)
1280N/A * 0xFE50-0xFEFF: [AL] Arabic presentaion form (Strong)
1280N/A * 0x10480-0x1049D: [L] Osmanya letters (Strong)
1280N/A * 0x104A0-0x104A9: [L] Osmanya digits (Strong)
1280N/A * 0x10A10-0x10A33: [R] Kharoshthi letters (Strong)
1280N/A * 0x10A40-0x10A43: [R] Kharoshthi digits (Strong)
1280N/A *
1280N/A * 0x200E: [L] Left-to-right mark (Implicit, Strong)
1280N/A * 0x200F: [R] Right-to-left mark (Implicit, Strong)
1280N/A * 0x202A: [LRE] Left-to-right embedding (Explicit, Strong)
1280N/A * 0x202B: [RLE] Right-to-left embedding (Explicit, Strong)
1280N/A * 0x202C: [PDF] Pop directional formatting (Explicit, Weak)
1280N/A * 0x202D: [LRO] Left-to-right override (Explicit, Strong)
1280N/A * 0x202E: [RLO] Right-to-left override (Explicit, Strong)
1280N/A */
1280N/A
1280N/A /* Right-to-left */
1280N/A private static String ArabicABC = "\u0627\u0628\u0629";
1280N/A private static String Arabic123 = "\u0661\u0662\u0663";
1280N/A private static String PArabicABC = "\uFE97\uFE92\uFE8E";
1280N/A private static String HebrewABC = "\u05D0\u05D1\u05D2";
1280N/A private static String KharoshthiABC =
1280N/A new String(Character.toChars(0x10A10)) +
1280N/A new String(Character.toChars(0x10A11)) +
1280N/A new String(Character.toChars(0x10A12));
1280N/A private static String Kharoshthi123 =
1280N/A new String(Character.toChars(0x10A40)) +
1280N/A new String(Character.toChars(0x10A41)) +
1280N/A new String(Character.toChars(0x10A42));
1280N/A private static String NKoABC = "\u07CA\u07CB\u07CC";
1280N/A private static String NKo123 = "\u07C1\u07C2\u07C3";
1280N/A
1280N/A /* Left-to-right */
1280N/A private static String OsmanyaABC =
1280N/A new String(Character.toChars(0x10480)) +
1280N/A new String(Character.toChars(0x10481)) +
1280N/A new String(Character.toChars(0x10482));
1280N/A private static String Osmanya123 =
1280N/A new String(Character.toChars(0x104A0)) +
1280N/A new String(Character.toChars(0x104A1)) +
1280N/A new String(Character.toChars(0x104A2));
1280N/A
1280N/A /* --------------------------------------------------------------------- */
1280N/A
1280N/A /*
1280N/A * Test data for Bidi(char[], ...) constructor and methods
1280N/A */
1280N/A
1280N/A /* Text for Bidi processing and its levels */
1280N/A private static String[][] data4Constructor1 = {
1280N/A /* For Text #0 */
1280N/A {"abc <ABC XYZ> xyz.",
1280N/A "000000000000000000", "000002222222000000", "000000000000000000",
1280N/A "000003333333000000", "000000000000000000",
1280N/A "222222222222222221", "222222222222222221", "222222222222222221",
1280N/A "222113333333112221", "222224444444222221",
1280N/A "000000000000000000", "000000000000000000", "222222222222222221"},
1280N/A
1280N/A /* For Text #1 */
1280N/A {"ABC <" + HebrewABC + " " + NKo123 + "> XYZ.",
1280N/A "000001111111000000", "000001111111000000", "000003333333000000",
1280N/A "000003333333000000", "000000000000000000",
1280N/A "222111111111112221", "222111111111112221", "222223333333222221",
1280N/A "222113333333112221", "222224444444222221",
1280N/A "000001111111000000", "000001111111000000", "222111111111112221"},
1280N/A
1280N/A /* For Text #2 */
1280N/A {NKoABC + " <ABC XYZ> " + NKo123 + ".",
1280N/A "111000000000001110", "111112222222111110", "111002222222001110",
1280N/A "111113333333111110", "111004444444001110",
1280N/A "111112222222111111", "111112222222111111", "111112222222111111",
1280N/A "111111111111111111", "111114444444111111",
1280N/A "111112222222111111", "111000000000001110", "111112222222111111"},
1280N/A
1280N/A /* For Text #3 */
1280N/A {HebrewABC + " <" + ArabicABC + " " + Arabic123 + "> " + NKo123 + ".",
1280N/A "111111111222111110", "111111111222111110", "111003333444001110",
1280N/A "111113333333111110", "111004444444001110",
1280N/A "111111111222111111", "111111111222111111", "111113333444111111",
1280N/A "111111111111111111", "111114444444111111",
1280N/A "111111111222111111", "111111111222111110", "111111111222111111"},
1280N/A
1280N/A /* For Text #4 */
1280N/A {"abc <" + NKoABC + " 123> xyz.",
1280N/A "000001111222000000", "000001111222000000", "000003333444000000",
1280N/A "000003333333000000", "000000000000000000",
1280N/A "222111111222112221", "222111111222112221", "222223333444222221",
1280N/A "222113333333112221", "222224444444222221",
1280N/A "000001111222000000", "000001111222000000", "222111111222112221"},
1280N/A
1280N/A /* For Text #5 */
1280N/A {"abc <ABC " + NKo123 + "> xyz.",
1280N/A "000000000111000000", "000002221111000000", "000002222333000000",
1280N/A "000003333333000000", "000000000000000000",
1280N/A "222222221111112221", "222222221111112221", "222222222333222221",
1280N/A "222113333333112221", "222224444444222221",
1280N/A "000000000111000000", "000000000111000000", "222222221111112221"},
1280N/A
1280N/A /* For Text #6 */
1280N/A {ArabicABC + " <" + NKoABC + " 123" + "> " + Arabic123 + ".",
1280N/A "111111111222112220", "111111111222112220", "111003333444002220",
1280N/A "111113333333112220", "111004444444002220",
1280N/A "111111111222112221", "111111111222112221", "111113333444112221",
1280N/A "111113333333112221", "111114444444112221",
1280N/A "111111111222112221", "111111111222112220", "111111111222112221"},
1280N/A
1280N/A /* For Text #7 */
1280N/A {ArabicABC + " <XYZ " + NKoABC + "> " + Arabic123 + ".",
1280N/A "111000000111112220", "111112221111112220", "111002222333002220",
1280N/A "111113333333112220", "111004444444002220",
1280N/A "111112221111112221", "111112221111112221", "111112222333112221",
1280N/A "111113333333112221", "111114444444112221",
1280N/A "111112221111112221", "111000000111112220", "111112221111112221"},
1280N/A
1280N/A /* For Text #8 */
1280N/A {OsmanyaABC + " <" + KharoshthiABC + " " + Kharoshthi123 + "> " +
1280N/A Osmanya123 + ".",
1280N/A "000000001111111111111000000000", "000000001111111111111000000000",
1280N/A "000000003333333333333000000000", "000000003333333333333000000000",
1280N/A "000000000000000000000000000000",
1280N/A "222222111111111111111112222221", "222222111111111111111112222221",
1280N/A "222222223333333333333222222221", "222222113333333333333112222221",
1280N/A "222222224444444444444222222221",
1280N/A "000000001111111111111000000000", "000000001111111111111000000000",
1280N/A "222222111111111111111112222221"},
1280N/A
1280N/A /* For Text #9 */
1280N/A {KharoshthiABC + " <" + OsmanyaABC + " " + Osmanya123 + "> " +
1280N/A Kharoshthi123 + ".",
1280N/A "111111000000000000000001111110", "111111112222222222222111111110",
1280N/A "111111002222222222222001111110", "111111113333333333333111111110",
1280N/A "111111004444444444444001111110",
1280N/A "111111112222222222222111111111", "111111112222222222222111111111",
1280N/A "111111112222222222222111111111", "111111111111111111111111111111",
1280N/A "111111114444444444444111111111",
1280N/A "111111112222222222222111111111", "111111000000000000000001111110",
1280N/A "111111112222222222222111111111"},
1280N/A };
1280N/A
1280N/A /* Golden data for baseIsLeftToRight() results */
1280N/A private static boolean[][] baseIsLTR4Constructor1 = {
1280N/A /* For Text #0 */
1280N/A {true, true, true, true, true,
1280N/A false, false, false, false, false,
1280N/A true, true, false},
1280N/A
1280N/A /* For Text #1 */
1280N/A {true, true, true, true, true,
1280N/A false, false, false, false, false,
1280N/A true, true, false},
1280N/A
1280N/A /* For Text #2 */
1280N/A {true, true, true, true, true,
1280N/A false, false, false, false, false,
1280N/A false, true, false},
1280N/A
1280N/A /* For Text #3 */
1280N/A {true, true, true, true, true,
1280N/A false, false, false, false, false,
1280N/A false, true, false},
1280N/A
1280N/A /* For Text #4 */
1280N/A {true, true, true, true, true,
1280N/A false, false, false, false, false,
1280N/A true, true, false},
1280N/A
1280N/A /* For Text #5 */
1280N/A {true, true, true, true, true,
1280N/A false, false, false, false, false,
1280N/A true, true, false},
1280N/A
1280N/A /* For Text #6 */
1280N/A {true, true, true, true, true,
1280N/A false, false, false, false, false,
1280N/A false, true, false},
1280N/A
1280N/A /* For Text #7 */
1280N/A {true, true, true, true, true,
1280N/A false, false, false, false, false,
1280N/A false, true, false},
1280N/A
1280N/A /* For Text #8 */
1280N/A {true, true, true, true, true,
1280N/A false, false, false, false, false,
1280N/A true, true, false},
1280N/A
1280N/A /* For Text #9 */
1280N/A {true, true, true, true, true,
1280N/A false, false, false, false, false,
1280N/A false, true, false},
1280N/A };
1280N/A
1280N/A /* Golden data for isLeftToRight() & isRightToLeft() results */
1280N/A private static boolean[][][] isLTR_isRTL4Constructor1 = {
1280N/A /* For Text #0 */
1280N/A /* isLeftToRight() results */
1280N/A {{true, false, true, false, true,
1280N/A false, false, false, false, false,
1280N/A true, true, false},
1280N/A /* isRightToLeft() results */
1280N/A {false, false, false, false, false,
1280N/A false, false, false, false, false,
1280N/A false, false, false}},
1280N/A
1280N/A /* For Text #1 */
1280N/A /* isLeftToRight() results */
1280N/A {{false, false, false, false, true,
1280N/A false, false, false, false, false,
1280N/A false, false, false},
1280N/A /* isRightToLeft() results */
1280N/A {false, false, false, false, false,
1280N/A false, false, false, false, false,
1280N/A false, false, false}},
1280N/A
1280N/A /* For Text #2 */
1280N/A /* isLeftToRight() results */
1280N/A {{false, false, false, false, false,
1280N/A false, false, false, false, false,
1280N/A false, false, false},
1280N/A /* isRightToLeft() results */
1280N/A {false, false, false, false, false,
1280N/A false, false, false, true, false,
1280N/A false, false, false}},
1280N/A
1280N/A /* For Text #3 */
1280N/A /* isLeftToRight() results */
1280N/A {{false, false, false, false, false,
1280N/A false, false, false, false, false,
1280N/A false, false, false},
1280N/A /* isRightToLeft() results */
1280N/A {false, false, false, false, false,
1280N/A false, false, false, true, false,
1280N/A false, false, false}},
1280N/A
1280N/A /* For Text #4 */
1280N/A /* isLeftToRight() results */
1280N/A {{false, false, false, false, true,
1280N/A false, false, false, false, false,
1280N/A false, false, false},
1280N/A /* isRightToLeft() results */
1280N/A {false, false, false, false, false,
1280N/A false, false, false, false, false,
1280N/A false, false, false}},
1280N/A
1280N/A /* For Text #5 */
1280N/A /* isLeftToRight() results */
1280N/A {{false, false, false, false, true,
1280N/A false, false, false, false, false,
1280N/A false, false, false},
1280N/A /* isRightToLeft() results */
1280N/A {false, false, false, false, false,
1280N/A false, false, false, false, false,
1280N/A false, false, false}},
1280N/A
1280N/A /* For Text #6 */
1280N/A /* isLeftToRight() results */
1280N/A {{false, false, false, false, false,
1280N/A false, false, false, false, false,
1280N/A false, false, false},
1280N/A /* isRightToLeft() results */
1280N/A {false, false, false, false, false,
1280N/A false, false, false, false, false,
1280N/A false, false, false}},
1280N/A
1280N/A /* For Text #7 */
1280N/A /* isLeftToRight() results */
1280N/A {{false, false, false, false, false,
1280N/A false, false, false, false, false,
1280N/A false, false, false},
1280N/A /* isRightToLeft() results */
1280N/A {false, false, false, false, false,
1280N/A false, false, false, false, false,
1280N/A false, false, false}},
1280N/A
1280N/A /* For Text #8 */
1280N/A /* isLeftToRight() results */
1280N/A {{false, false, false, false, true,
1280N/A false, false, false, false, false,
1280N/A false, false, false},
1280N/A /* isRightToLeft() results */
1280N/A {false, false, false, false, false,
1280N/A false, false, false, false, false,
1280N/A false, false, false}},
1280N/A
1280N/A /* For Text #9 */
1280N/A /* isLeftToRight() results */
1280N/A {{false, false, false, false, false,
1280N/A false, false, false, false, false,
1280N/A false, false, false},
1280N/A /* isRightToLeft() results */
1280N/A {false, false, false, false, false,
1280N/A false, false, false, true, false,
1280N/A false, false, false}},
1280N/A };
1280N/A
1280N/A /* --------------------------------------------------------------------- */
1280N/A
1280N/A /*
1280N/A * Test data for Bidi(String, int) constructor and methods
1280N/A */
1280N/A
1280N/A /* Text for Bidi processing and its levels */
1280N/A private static String[][] data4Constructor2 = {
1280N/A /* For Text #0 */
1280N/A {" ABC 123.",
1280N/A "000000000", "000000000", "000000000", "122222221"},
1280N/A
1280N/A /* For Text #1 */
1280N/A {" ABC " + HebrewABC + " " + NKo123 + " 123.",
1280N/A "00000111111112220", "00000111111112220", "00000111111112220",
1280N/A "12221111111112221"},
1280N/A
1280N/A /* For Text #2 */
1280N/A {" ABC " + ArabicABC + " " + Arabic123 + " 123.",
1280N/A "00000111122212220", "00000111122212220", "00000111122212220",
1280N/A "12221111122212221"},
1280N/A
1280N/A /* For Text #3 */
1280N/A {" " + NKoABC + " ABC 123 " + NKo123 + ".",
1280N/A "11111222222211111", "11111222222211111", "01110000000001110",
1280N/A "11111222222211111"},
1280N/A
1280N/A /* For Text #4 */
1280N/A {" " + ArabicABC + " ABC 123 " + Arabic123 + ".",
1280N/A "11111222222212221", "11111222222212221", "01110000000002220",
1280N/A "11111222222212221"},
1280N/A
1280N/A /* For Text #5 */
1280N/A {" " + HebrewABC + " " + NKo123 + ".",
1280N/A "111111111", "111111111", "011111110", "111111111"},
1280N/A
1280N/A /* For Text #6 */
1280N/A {" " + ArabicABC + " " + Arabic123 + ".",
1280N/A "111112221", "111112221", "011112220", "111112221"},
1280N/A
1280N/A /* For Text #7 */
1280N/A {" " + KharoshthiABC + " " + Kharoshthi123 + ".",
1280N/A "111111111111111", "111111111111111", "011111111111110",
1280N/A "111111111111111"},
1280N/A
1280N/A /* For Text #8 */
1280N/A {L + HebrewABC + " " + NKo123 + ".",
1280N/A "011111110", "011111110", "011111110", "211111111"},
1280N/A
1280N/A /* For Text #9 */
1280N/A {R + "ABC " + Osmanya123 + ".",
1280N/A "000000000000", "000000000000", "000000000000", "122222222221"},
1280N/A
1280N/A /* For Text #10 */
1280N/A {"ABC " + PArabicABC + " " + PArabicABC + " 123",
1280N/A "000011111111222", "000011111111222", "000011111111222",
1280N/A "222111111111222"},
1280N/A
1280N/A /* For Text #11 */
1280N/A {RLE + "ABC " + HebrewABC + " " + NKo123 + "." + PDF,
1280N/A "22221111111110", "22221111111110", "22221111111110",
1280N/A "44443333333331"},
1280N/A
1280N/A /* For Text #12 */
1280N/A {"He said \"" + RLE + "ABC " + HebrewABC + " " + NKo123 + PDF + ".\"",
1280N/A "000000000222211111111000", "000000000222211111111000",
1280N/A "000000000222211111111000", "222222211444433333333111"},
1280N/A
1280N/A /* For Text #13 */
1280N/A {LRO + "He said \"" + RLE + "ABC " + NKoABC + " " + NKo123 + PDF +
1280N/A ".\"" + PDF,
1280N/A "22222222224444333333332220", "22222222224444333333332220",
1280N/A "22222222224444333333332220", "22222222224444333333332221"},
1280N/A
1280N/A /* For Text #14 */
1280N/A {LRO + "He said \"" + RLE + "ABC " + HebrewABC + " " + NKo123 + PDF +
1280N/A ".\"", // PDF missing
1280N/A "2222222222444433333333222", "2222222222444433333333222",
1280N/A "2222222222444433333333222", "2222222222444433333333222"},
1280N/A
1280N/A /* For Text #15 */
1280N/A {"Did you say '" + LRE + "he said \"" + RLE + "ABC " + HebrewABC +
1280N/A " " + NKo123 + PDF + "\"" + PDF + "'?",
1280N/A "0000000000000222222222244443333333322000",
1280N/A "0000000000000222222222244443333333322000",
1280N/A "0000000000000222222222244443333333322000",
1280N/A "2222222222222222222222244443333333322111"},
1280N/A
1280N/A /* For Text #16 */
1280N/A {RLO + "Did you say '" + LRE + "he said \"" + RLE + "ABC " +
1280N/A HebrewABC + " " + NKo123 + PDF + "\"" + PDF + "'?" + PDF,
1280N/A "111111111111112222222222444433333333221110",
1280N/A "111111111111112222222222444433333333221110",
1280N/A "111111111111112222222222444433333333221110",
1280N/A "333333333333334444444444666655555555443331"},
1280N/A
1280N/A /* For Text #17 */
1280N/A {RLO + "Did you say '" + LRE + "he said \"" + RLE + "ABC " +
1280N/A HebrewABC + " " + NKo123 + PDF + "\"" + PDF + "'?", // PDF missing
1280N/A "11111111111111222222222244443333333322111",
1280N/A "11111111111111222222222244443333333322111",
1280N/A "11111111111111222222222244443333333322111",
1280N/A "33333333333333444444444466665555555544333"},
1280N/A
1280N/A /* For Text #18 */
1280N/A {" ABC (" + ArabicABC + " " + Arabic123 + ") 123.",
1280N/A "0000001111222112220", "0000001111222112220",
1280N/A "0000001111222112220", "1222111111222112221"},
1280N/A
1280N/A /* For Text #19 */
1280N/A {" " + HebrewABC + " (ABC 123) " + NKo123 + ".",
1280N/A "1111112222222111111", "1111112222222111111",
1280N/A "0111000000000001110", "1111112222222111111"},
1280N/A
1280N/A /* For Text #20 */
1280N/A {" He said \"" + RLE + "ABC " + NKoABC + " " + NKo123 + PDF + ".\" ",
1280N/A "00000000002222111111110000", "00000000002222111111110000",
1280N/A "00000000002222111111110000", "12222222114444333333331111"},
1280N/A
1280N/A /* For Text #21 */
1280N/A {" Did you say '" + LRE + "he said \"" + RLE + "ABC " + HebrewABC +
1280N/A " " + NKo123 + PDF + "\"" + PDF + "'? ",
1280N/A "000000000000002222222222444433333333220000",
1280N/A "000000000000002222222222444433333333220000",
1280N/A "000000000000002222222222444433333333220000",
1280N/A "122222222222222222222222444433333333221111"},
1280N/A
1280N/A /* For Text #22 */
1280N/A {RLE + OsmanyaABC + " " + KharoshthiABC + " " + Kharoshthi123 + "." +
1280N/A PDF,
1280N/A "22222221111111111111110", "22222221111111111111110",
1280N/A "22222221111111111111110", "44444443333333333333331"},
1280N/A };
1280N/A
1280N/A /* Golden data for baseIsLeftToRight() results */
1280N/A private static boolean[][] baseIsLTR4Constructor2 = {
1280N/A /* For Text #0 - $4 */
1280N/A {true, true, true, false},
1280N/A {true, true, true, false},
1280N/A {true, true, true, false},
1280N/A {false, false, true, false},
1280N/A {false, false, true, false},
1280N/A
1280N/A /* For Text #5 - $9 */
1280N/A {false, false, true, false},
1280N/A {false, false, true, false},
1280N/A {false, false, true, false},
1280N/A {true, true, true, false},
1280N/A {true, true, true, false},
1280N/A
1280N/A /* For Text #10 - $14 */
1280N/A {true, true, true, false},
1280N/A {true, true, true, false},
1280N/A {true, true, true, false},
1280N/A {true, true, true, false},
1280N/A {true, true, true, false},
1280N/A
1280N/A /* For Text #15 - $19 */
1280N/A {true, true, true, false},
1280N/A {true, true, true, false},
1280N/A {true, true, true, false},
1280N/A {true, true, true, false},
1280N/A {false, false, true, false},
1280N/A
1280N/A /* For Text #20 - $22 */
1280N/A {true, true, true, false},
1280N/A {true, true, true, false},
1280N/A {true, true, true, false},
1280N/A };
1280N/A
1280N/A /* Golden data for isLeftToRight() & isRightToLeft() results */
1280N/A private static boolean[][][] isLTR_isRTL4Constructor2 = {
1280N/A /* isLeftToRight() results & isRightToLeft() results */
1280N/A /* For Text #0 - $4 */
1280N/A {{true, true, true, false}, {false, false, false, false}},
1280N/A {{false, false, false, false}, {false, false, false, false}},
1280N/A {{false, false, false, false}, {false, false, false, false}},
1280N/A {{false, false, false, false}, {false, false, false, false}},
1280N/A {{false, false, false, false}, {false, false, false, false}},
1280N/A
1280N/A /* For Text #5 - $9 */
1280N/A {{false, false, false, false}, {true, true, false, true }},
1280N/A {{false, false, false, false}, {false, false, false, false}},
1280N/A {{false, false, false, false}, {true, true, false, true }},
1280N/A {{false, false, false, false}, {false, false, false, false}},
1280N/A {{true, true, true, false}, {false, false, false, false}},
1280N/A
1280N/A /* For Text #10 - $14 */
1280N/A {{false, false, false, false}, {false, false, false, false}},
1280N/A {{false, false, false, false}, {false, false, false, false}},
1280N/A {{false, false, false, false}, {false, false, false, false}},
1280N/A {{false, false, false, false}, {false, false, false, false}},
1280N/A {{false, false, false, false}, {false, false, false, false}},
1280N/A
1280N/A /* For Text #15 - $19 */
1280N/A {{false, false, false, false}, {false, false, false, false}},
1280N/A {{false, false, false, false}, {false, false, false, false}},
1280N/A {{false, false, false, false}, {false, false, false, false}},
1280N/A {{false, false, false, false}, {false, false, false, false}},
1280N/A {{false, false, false, false}, {false, false, false, false}},
1280N/A
1280N/A /* For Text #20 - $22 */
1280N/A {{false, false, false, false}, {false, false, false, false}},
1280N/A {{false, false, false, false}, {false, false, false, false}},
1280N/A {{false, false, false, false}, {false, false, false, false}},
1280N/A };
1280N/A
1280N/A /* Golden data for requiresBidi() results */
1280N/A private static boolean[] requiresBidi4Constructor2 = {
1280N/A /* For Text #0 - $9 */
1280N/A false, true, true, true, true,
1280N/A true, true, true, true, false,
1280N/A
1280N/A /* For Text #10 - $19 */
1280N/A true, true, true, true, true,
1280N/A true, true, true, true, true,
1280N/A
1280N/A /* For Text #20 - $22 */
1280N/A true, true, true,
1280N/A };
1280N/A
1280N/A /* --------------------------------------------------------------------- */
1280N/A
1280N/A /*
1280N/A * Test data for Bidi(char[], ...) constructor and methods
1280N/A */
1280N/A
1280N/A /* Enbeddings */
1280N/A private static byte[][][] emb4Constructor3 = {
1280N/A /* Embeddings for paragraphs which don't include surrogate pairs. */
1280N/A {{0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0},
1280N/A {0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0},
1280N/A {0, 0, 0, 0, 0, -3, -3, -3, -3, -3, -3, -3, 0, 0, 0, 0, 0, 0},
1280N/A {0, 0, 0, 0, 0, -4, -4, -4, -4, -4, -4, -4, 0, 0, 0, 0, 0, 0}},
1280N/A
1280N/A /* Embeddings for paragraphs which include surrogate pairs. */
1280N/A {{ 0, 0, 0, 0, 0, 0, 0, 0,
1280N/A 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1280N/A 0, 0, 0, 0, 0, 0, 0, 0, 0},
1280N/A { 0, 0, 0, 0, 0, 0, 0, 0,
1280N/A 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1280N/A 0, 0, 0, 0, 0, 0, 0, 0, 0},
1280N/A { 0, 0, 0, 0, 0, 0, 0, 0,
1280N/A -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
1280N/A 0, 0, 0, 0, 0, 0, 0, 0, 0},
1280N/A { 0, 0, 0, 0, 0, 0, 0, 0,
1280N/A -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
1280N/A 0, 0, 0, 0, 0, 0, 0, 0, 0}},
1280N/A };
1280N/A
1280N/A /* Text for Bidi processing and its levels */
1280N/A private static String[][] data4Constructor3 = {
1280N/A /* For Text #0 */
1280N/A {"abc <ABC XYZ> xyz.",
1280N/A /* DIRECTION_DEFAULT_LEFT_TO_RIGHT */
1280N/A "000002222222000000", "000000000000000000",
1280N/A "000003333333000000", "000000000000000000",
1280N/A /* DIRECTION_DEFAULT_RIGHT_TO_LEFT */
1280N/A "222222222222222221", "222222222222222221",
1280N/A "222113333333112221", "222224444444222221",
1280N/A /* DIRECTION_LEFT_TO_RIGHT */
1280N/A "000002222222000000", "000000000000000000",
1280N/A "000003333333000000", "000000000000000000",
1280N/A /* DIRECTION_RIGHT_TO_LEFT */
1280N/A "222222222222222221", "222222222222222221",
1280N/A "222113333333112221", "222224444444222221"},
1280N/A
1280N/A /* For Text #1 */
1280N/A {"ABC <" + HebrewABC + " " + NKo123 + "> XYZ.",
1280N/A /* DIRECTION_DEFAULT_LEFT_TO_RIGHT */
1280N/A "000001111111000000", "000003333333000000",
1280N/A "000003333333000000", "000000000000000000",
1280N/A /* DIRECTION_DEFAULT_RIGHT_TO_LEFT */
1280N/A "222111111111112221", "222223333333222221",
1280N/A "222113333333112221", "222224444444222221",
1280N/A /* DIRECTION_LEFT_TO_RIGHT */
1280N/A "000001111111000000", "000003333333000000",
1280N/A "000003333333000000", "000000000000000000",
1280N/A /* DIRECTION_RIGHT_TO_LEFT */
1280N/A "222111111111112221", "222223333333222221",
1280N/A "222113333333112221", "222224444444222221"},
1280N/A
1280N/A /* For Text #2 */
1280N/A {NKoABC + " <ABC XYZ> " + NKo123 + ".",
1280N/A /* DIRECTION_DEFAULT_LEFT_TO_RIGHT */
1280N/A "111112222222111111", "111112222222111111",
1280N/A "111111111111111111", "111114444444111111",
1280N/A /* DIRECTION_DEFAULT_RIGHT_TO_LEFT */
1280N/A "111112222222111111", "111112222222111111",
1280N/A "111111111111111111", "111114444444111111",
1280N/A /* DIRECTION_LEFT_TO_RIGHT */
1280N/A "111112222222111110", "111002222222001110",
1280N/A "111113333333111110", "111004444444001110",
1280N/A /* DIRECTION_RIGHT_TO_LEFT */
1280N/A "111112222222111111", "111112222222111111",
1280N/A "111111111111111111", "111114444444111111"},
1280N/A
1280N/A /* For Text #3 */
1280N/A {HebrewABC + " <" + ArabicABC + " " + Arabic123 + "> " + NKo123 + ".",
1280N/A /* DIRECTION_DEFAULT_LEFT_TO_RIGHT */
1280N/A "111111111222111111", "111113333444111111",
1280N/A "111111111111111111", "111114444444111111",
1280N/A /* DIRECTION_DEFAULT_RIGHT_TO_LEFT */
1280N/A "111111111222111111", "111113333444111111",
1280N/A "111111111111111111", "111114444444111111",
1280N/A /* DIRECTION_LEFT_TO_RIGHT */
1280N/A "111111111222111110", "111003333444001110",
1280N/A "111113333333111110", "111004444444001110",
1280N/A /* DIRECTION_RIGHT_TO_LEFT */
1280N/A "111111111222111111", "111113333444111111",
1280N/A "111111111111111111", "111114444444111111"},
1280N/A
1280N/A /* For Text #4 */
1280N/A {"abc <123 456> xyz.",
1280N/A /* DIRECTION_DEFAULT_LEFT_TO_RIGHT */
1280N/A "000002221222000000", "000000000000000000",
1280N/A "000003333333000000", "000000000000000000",
1280N/A /* DIRECTION_DEFAULT_RIGHT_TO_LEFT */
1280N/A "222222222222222221", "222222222222222221",
1280N/A "222113333333112221", "222224444444222221",
1280N/A /* DIRECTION_LEFT_TO_RIGHT */
1280N/A "000002221222000000", "000000000000000000",
1280N/A "000003333333000000", "000000000000000000",
1280N/A /* DIRECTION_RIGHT_TO_LEFT */
1280N/A "222222222222222221", "222222222222222221",
1280N/A "222113333333112221", "222224444444222221"},
1280N/A
1280N/A /* For Text #5 */
1280N/A {OsmanyaABC + " <" + KharoshthiABC + " " + Kharoshthi123 + "> " +
1280N/A Osmanya123 + ".",
1280N/A /* DIRECTION_DEFAULT_LEFT_TO_RIGHT */
1280N/A "000000001111111111111000000000", "000000003333333333333000000000",
1280N/A "000000003333333333333000000000", "000000000000000000000000000000",
1280N/A /* DIRECTION_DEFAULT_RIGHT_TO_LEFT */
1280N/A "222222111111111111111112222221", "222222223333333333333222222221",
1280N/A "222222113333333333333112222221", "222222224444444444444222222221",
1280N/A /* DIRECTION_LEFT_TO_RIGHT */
1280N/A "000000001111111111111000000000", "000000003333333333333000000000",
1280N/A "000000003333333333333000000000", "000000000000000000000000000000",
1280N/A /* DIRECTION_RIGHT_TO_LEFT */
1280N/A "222222111111111111111112222221", "222222223333333333333222222221",
1280N/A "222222113333333333333112222221", "222222224444444444444222222221"},
1280N/A
1280N/A /* For Text #6 */
1280N/A {KharoshthiABC + " <" + OsmanyaABC + " " + Osmanya123 + "> " +
1280N/A Kharoshthi123 + ".",
1280N/A /* DIRECTION_DEFAULT_LEFT_TO_RIGHT */
1280N/A "111111112222222222222111111111", "111111112222222222222111111111",
1280N/A "111111111111111111111111111111", "111111114444444444444111111111",
1280N/A /* DIRECTION_DEFAULT_RIGHT_TO_LEFT */
1280N/A "111111112222222222222111111111", "111111112222222222222111111111",
1280N/A "111111111111111111111111111111", "111111114444444444444111111111",
1280N/A /* DIRECTION_LEFT_TO_RIGHT */
1280N/A "111111112222222222222111111110", "111111002222222222222001111110",
1280N/A "111111113333333333333111111110", "111111004444444444444001111110",
1280N/A /* DIRECTION_RIGHT_TO_LEFT */
1280N/A "111111112222222222222111111111", "111111112222222222222111111111",
1280N/A "111111111111111111111111111111", "111111114444444444444111111111"},
1280N/A };
1280N/A
1280N/A /* Golden data for baseIsLeftToRight() results */
1280N/A private static boolean[][] baseIsLTR4Constructor3 = {
1280N/A /* For Text #0 */
1280N/A {true, true, true, true, // DIRECTION_DEFAULT_LEFT_TO_RIGHT
1280N/A true, true, true, true, // DIRECTION_DEFAULT_RIGHT_TO_LEFT
1280N/A true, true, true, true, // DIRECTION_LEFT_TO_RIGHT
1280N/A false, false, false, false}, // DIRECTION_RIGHT_TO_LEFT
1280N/A
1280N/A /* For Text #1 */
1280N/A {true, true, true, true,
1280N/A true, true, true, true,
1280N/A true, true, true, true,
1280N/A false, false, false, false},
1280N/A
1280N/A /* For Text #2 */
1280N/A {false, false, false, false,
1280N/A false, false, false, false,
1280N/A true, true, true, true,
1280N/A false, false, false, false},
1280N/A
1280N/A /* For Text #3 */
1280N/A {false, false, false, false,
1280N/A false, false, false, false,
1280N/A true, true, true, true,
1280N/A false, false, false, false},
1280N/A
1280N/A /* For Text #4 */
1280N/A {true, true, true, true,
1280N/A true, true, true, true,
1280N/A true, true, true, true,
1280N/A false, false, false, false},
1280N/A
1280N/A /* For Text #5 */
1280N/A {true, true, true, true,
1280N/A true, true, true, true,
1280N/A true, true, true, true,
1280N/A false, false, false, false},
1280N/A
1280N/A /* For Text #6 */
1280N/A {false, false, false, false,
1280N/A false, false, false, false,
1280N/A true, true, true, true,
1280N/A false, false, false, false},
1280N/A };
1280N/A
1280N/A /* Golden data for isLeftToRight() & isRightToLeft() results */
1280N/A private static boolean[][][] isLTR_isRTL4Constructor3 = {
1280N/A /* For Text #0 */
1280N/A /* isLeftToRight() results */
1280N/A {{false, true, false, true, // DIRECTION_DEFAULT_LEFT_TO_RIGHT
1280N/A false, false, false, false, // DIRECTION_DEFAULT_RIGHT_TO_LEFT
1280N/A false, true, false, true, // DIRECTION_LEFT_TO_RIGHT
1280N/A false, false, false, false}, // DIRECTION_RIGHT_TO_LEFT
1280N/A /* isRightToLeft() results */
1280N/A {false, false, false, false, // DIRECTION_DEFAULT_LEFT_TO_RIGHT
1280N/A false, false, false, false, // DIRECTION_DEFAULT_RIGHT_TO_LEFT
1280N/A false, false, false, false, // DIRECTION_LEFT_TO_RIGHT
1280N/A false, false, false, false}}, // DIRECTION_RIGHT_TO_LEFTT
1280N/A
1280N/A /* For Text #1 */
1280N/A /* isLeftToRight() results */
1280N/A {{false, false, false, true,
1280N/A false, false, false, false,
1280N/A false, false, false, true,
1280N/A false, false, false, false},
1280N/A /* isRightToLeft() results */
1280N/A {false, false, false, false,
1280N/A false, false, false, false,
1280N/A false, false, false, false,
1280N/A false, false, false, false}},
1280N/A
1280N/A /* For Text #2 */
1280N/A /* isLeftToRight() results */
1280N/A {{false, false, false, false,
1280N/A false, false, false, false,
1280N/A false, false, false, false,
1280N/A false, false, false, false},
1280N/A /* isRightToLeft() results */
1280N/A {false, false, true, false,
1280N/A false, false, true, false,
1280N/A false, false, false, false,
1280N/A false, false, true, false}},
1280N/A
1280N/A /* For Text #3 */
1280N/A /* isLeftToRight() results */
1280N/A {{false, false, false, false,
1280N/A false, false, false, false,
1280N/A false, false, false, false,
1280N/A false, false, false, false},
1280N/A /* isRightToLeft() results */
1280N/A {false, false, true, false,
1280N/A false, false, true, false,
1280N/A false, false, false, false,
1280N/A false, false, true, false}},
1280N/A
1280N/A /* For Text #4 */
1280N/A /* isLeftToRight() results */
1280N/A {{false, true, false, true,
1280N/A false, false, false, false,
1280N/A false, true, false, true,
1280N/A false, false, false, false },
1280N/A /* isRightToLeft() results */
1280N/A {false, false, false, false,
1280N/A false, false, false, false,
1280N/A false, false, false, false,
1280N/A false, false, false, false}},
1280N/A
1280N/A /* For Text #5 */
1280N/A /* isLeftToRight() results */
1280N/A {{false, false, false, true,
1280N/A false, false, false, false,
1280N/A false, false, false, true,
1280N/A false, false, false, false},
1280N/A /* isRightToLeft() results */
1280N/A {false, false, false, false,
1280N/A false, false, false, false,
1280N/A false, false, false, false,
1280N/A false, false, false, false}},
1280N/A
1280N/A /* For Text #6 */
1280N/A /* isLeftToRight() results */
1280N/A {{false, false, false, false,
1280N/A false, false, false, false,
1280N/A false, false, false, false,
1280N/A false, false, false, false},
1280N/A /* isRightToLeft() results */
1280N/A {false, false, true, false,
1280N/A false, false, true, false,
1280N/A false, false, false, false,
1280N/A false, false, true, false}},
1280N/A };
1280N/A
1280N/A /* --------------------------------------------------------------------- */
1280N/A
1280N/A /*
1280N/A * Test data for reorderVisually() methods
1280N/A */
1280N/A
1280N/A private static Object[][][] data4reorderVisually = {
1280N/A {{"ABC", " ", "abc", " ", ArabicABC, "."}, // Original text
1280N/A {"000000001110"}, // levels
1280N/A {"ABC", " ", "abc", " ", ArabicABC, "."}}, // Reordered text
1280N/A
1280N/A {{"ABC", " ", HebrewABC, " ", NKoABC, "."},
1280N/A {"222111111111"},
1280N/A {".", NKoABC, " ", HebrewABC, " ", "ABC"}},
1280N/A
1280N/A {{OsmanyaABC, " ", HebrewABC, " ", KharoshthiABC, "."},
1280N/A {"222222111111111111"},
1280N/A {".", KharoshthiABC, " ", HebrewABC, " ", OsmanyaABC,}},
1280N/A
1280N/A {{"ABC", " ", Osmanya123, " ", "\"", OsmanyaABC, " ", Kharoshthi123,
1280N/A " ", KharoshthiABC, ".", "\""},
1280N/A {"0000000000002222221111111111111100"},
1280N/A {"ABC", " ", Osmanya123, " ", "\"", KharoshthiABC, " ", Kharoshthi123,
1280N/A " ", OsmanyaABC, ".", "\""}},
1280N/A };
1280N/A
1280N/A}