use of java.text.Bidi in project robovm by robovm.
the class OldBidiTest method testCreateLineBidi_AndroidFailure.
public void testCreateLineBidi_AndroidFailure() {
// This is a difference between ICU4C and the RI. ICU4C insists that 'limit' is strictly
// greater than 'start'. We have to paper over this in our Java code.
Bidi bidi = new Bidi("str", Bidi.DIRECTION_RIGHT_TO_LEFT);
bidi.createLineBidi(2, 2);
}
use of java.text.Bidi in project robovm by robovm.
the class OldBidiTest method testGetRunLevelLInt.
public void testGetRunLevelLInt() {
bd = new Bidi("text", Bidi.DIRECTION_LEFT_TO_RIGHT);
try {
assertEquals(0, bd.getRunLevel(0));
assertEquals(0, bd.getRunLevel(bd.getRunCount()));
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
bd = new Bidi("text", Bidi.DIRECTION_RIGHT_TO_LEFT);
try {
assertEquals(2, bd.getRunLevel(0));
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
bd = new Bidi("text", Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
try {
assertEquals(0, bd.getRunLevel(0));
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
}
use of java.text.Bidi in project jdk8u_jdk by JetBrains.
the class BidiConformance method testMethods4Constructor2.
private void testMethods4Constructor2() {
System.out.println("*** Test methods for constructor 2");
String paragraph;
Bidi bidi;
for (int textNo = 0; textNo < data4Constructor2.length; textNo++) {
paragraph = data4Constructor2[textNo][0];
for (int flagNo = 0; flagNo < FLAGS.length; flagNo++) {
int flag = FLAGS[flagNo];
System.out.println("*** Test textNo=" + textNo + ": Bidi(\"" + toReadableString(paragraph) + "\", " + getFlagName(flag) + ")");
bidi = new Bidi(paragraph, flag);
callTestEachMethod4Constructor2(textNo, flagNo, bidi);
}
}
}
use of java.text.Bidi in project jdk8u_jdk by JetBrains.
the class BidiConformance method testMethod_createLineBidi2.
private void testMethod_createLineBidi2() {
System.out.println("*** Test createLineBidi() 2");
Bidi bidi = new Bidi(data4Constructor1[0][0], FLAGS[0]);
int len = data4Constructor1[0][0].length();
try {
Bidi lineBidi = bidi.createLineBidi(0, len);
} catch (Exception e) {
errorHandling("createLineBidi(0, textLength)" + " should not throw an exception.");
}
try {
Bidi lineBidi = bidi.createLineBidi(-1, len);
errorHandling("createLineBidi(-1, textLength)" + " should throw an IAE.");
} catch (IllegalArgumentException e) {
}
try {
Bidi lineBidi = bidi.createLineBidi(0, len + 1);
errorHandling("createLineBidi(0, textLength+1)" + " should throw an IAE.");
} catch (IllegalArgumentException e) {
}
}
use of java.text.Bidi in project jdk8u_jdk by JetBrains.
the class BidiEmbeddingTest method test2.
// make sure BIDI_EMBEDDING values of 0 are mapped to base run direction, instead of flagging an error.
static void test2() {
String target = "BACK WARDS";
String str = "If this text is >" + target + "< the test passed.";
int length = str.length();
int start = str.indexOf(target);
int limit = start + target.length();
System.out.println("start: " + start + " limit: " + limit);
AttributedString astr = new AttributedString(str);
astr.addAttribute(TextAttribute.RUN_DIRECTION, TextAttribute.RUN_DIRECTION_RTL);
astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(-3), start, limit);
Bidi bidi = new Bidi(astr.getIterator());
for (int i = 0; i < bidi.getRunCount(); ++i) {
System.out.println("run " + i + " from " + bidi.getRunStart(i) + " to " + bidi.getRunLimit(i) + " at level " + bidi.getRunLevel(i));
}
System.out.println(bidi + "\n");
if (bidi.getRunCount() != 6) {
// runs of spaces and angles at embedding bound,s and final period, each get level 1
throw new Error("Bidi embedding processing failed");
} else {
System.out.println("test2() passed.\n");
}
}
Aggregations