ICU-10142 implement Unicode 6.3 bidi algorithm additions: merge icu4j/branches/mati/uba63 into trunk, merge new test for BidiCharacterTest.txt into BiDiConformanceTest.java

X-SVN-Rev: 34149
This commit is contained in:
Markus Scherer 2013-08-30 19:50:39 +00:00
parent 90b538ae3f
commit 748e8c9cc6
11 changed files with 97667 additions and 659 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2001-2011, International Business Machines
* Copyright (C) 2001-2013, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
@ -93,13 +93,13 @@ final class BidiLine {
level of B chars from 0 to paraLevel in getLevels when
orderParagraphsLTR==TRUE
*/
if (Bidi.NoContextRTL(dirProps[start - 1]) == Bidi.B) {
if (dirProps[start - 1] == Bidi.B) {
bidi.trailingWSStart = start; /* currently == bidi.length */
return;
}
/* go backwards across all WS, BN, explicit codes */
while (start > 0 &&
(Bidi.DirPropFlagNC(dirProps[start - 1]) & Bidi.MASK_WS) != 0) {
(Bidi.DirPropFlag(Bidi.PureDirProp(dirProps[start - 1])) & Bidi.MASK_WS) != 0) {
--start;
}
@ -490,7 +490,7 @@ final class BidiLine {
int length = bidi.length, limit;
byte[] levels = bidi.levels;
int i, runCount;
byte level = Bidi.LEVEL_DEFAULT_LTR; /* initialize with no valid level */
byte level = -1; /* initialize with no valid level */
/*
* If there are WS characters at the end of the line
* and the run preceding them has a level different from
@ -639,7 +639,10 @@ final class BidiLine {
maxLevel = 0;
for (start = levels.length; start>0; ) {
level = levels[--start];
if (level > Bidi.MAX_EXPLICIT_LEVEL + 1) {
if (level < 0) {
return null;
}
if (level > (Bidi.MAX_EXPLICIT_LEVEL + 1)) {
return null;
}
if (level < minLevel) {

File diff suppressed because it is too large Load diff

View file

@ -17,7 +17,7 @@ import com.ibm.icu.text.BidiClassifier;
/**
* @author Markus W. Scherer
* BiDi conformance test, using the Unicode BidiTest.txt file.
* BiDi conformance test, using the Unicode BidiTest.txt and BidiCharacterTest.txt files.
* Ported from ICU4C intltest/bidiconf.cpp .
*/
public class BiDiConformanceTest extends TestFmwk {
@ -27,11 +27,6 @@ public class BiDiConformanceTest extends TestFmwk {
public BiDiConformanceTest() {}
public void TestBidiTest() throws IOException {
if(logKnownIssue("10142",
"Update the ICU BiDi code to implement the additions in the " +
"Unicode 6.3 BiDi Algorithm, and reenable the BiDi conformance test.")) {
return;
}
BufferedReader bidiTestFile=TestUtil.getDataReader("unicode/BidiTest.txt");
Bidi ubidi=new Bidi();
ubidi.setCustomClassifier(new ConfTestBidiClassifier());
@ -55,10 +50,10 @@ outerLoop:
++lineIndex;
if(line.startsWith("Levels:", lineIndex)) {
lineIndex+=7;
parseLevels();
if(!parseLevels(line.substring(lineIndex))) { break; }
} else if(line.startsWith("Reorder:", lineIndex)) {
lineIndex+=8;
parseOrdering();
if(!parseOrdering(line.substring(lineIndex))) { break; }
}
// Skip unknown @Xyz: ...
} else {
@ -73,10 +68,11 @@ outerLoop:
if((bitset&(1<<i))!=0) {
ubidi.setPara(inputString, paraLevels[i], null);
byte actualLevels[]=ubidi.getLevels();
if(!checkLevels(actualLevels, paraLevelNames[i])) {
paraLevelName=paraLevelNames[i];
if(!checkLevels(actualLevels)) {
continue outerLoop;
}
if(!checkOrdering(ubidi, paraLevelNames[i])) {
if(!checkOrdering(ubidi)) {
continue outerLoop;
}
}
@ -84,6 +80,179 @@ outerLoop:
}
}
}
/*
*******************************************************************************
*
* created on: 2013jul01
* created by: Matitiahu Allouche
This function performs a conformance test for implementations of the
Unicode Bidirectional Algorithm, specified in UAX #9: Unicode
Bidirectional Algorithm, at http://www.unicode.org/unicode/reports/tr9/
Each test case is represented in a single line which is read from a file
named BidiCharacter.txt. Empty, blank and comment lines may also appear
in this file.
The format of the test data is specified below. Note that each test
case constitutes a single line of text; reordering is applied within a
single line and independently of a rendering engine, and rules L3 and L4
are out of scope.
The number sign '#' is the comment character: everything is ignored from
the occurrence of '#' until the end of the line,
Empty lines and lines containing only spaces and/or comments are ignored.
Lines which represent test cases consist of 4 or 5 fields separated by a
semicolon. Each field consists of tokens separated by whitespace (space
or Tab). Whitespace before and after semicolons is optional.
Field 0: A sequence of hexadecimal code point values separated by space
Field 1: A value representing the paragraph direction, as follows:
- 0 represents left-to-right
- 1 represents right-to-left
- 2 represents auto-LTR according to rules P2 and P3 of the algorithm
- 3 represents auto-RTL according to rules P2 and P3 of the algorithm
- a negative number whose absolute value is taken as paragraph level;
this may be useful to test cases where the embedding level approaches
or exceeds the maximum embedding level.
Field 2: The resolved paragraph embedding level. If the input (field 0)
includes more than one paragraph, this field represents the
resolved level of the first paragraph.
Field 3: An ordered list of resulting levels for each token in field 0
(each token represents one source character).
The UBA does not assign levels to certain characters (e.g. LRO);
characters removed in rule X9 are indicated with an 'x'.
Field 4: An ordered list of indices showing the resulting visual ordering
from left to right; characters with a resolved level of 'x' are
skipped. The number are zero-based. Each index corresponds to
a character in the reordered (visual) string. It represents the
index of the source character in the input (field 0).
This field is optional. When it is absent, the visual ordering
is not verified.
Examples:
# This is a comment line.
L L ON R ; 0 ; 0 ; 0 0 0 1 ; 0 1 2 3
L L ON R;0;0;0 0 0 1;0 1 2 3
# Note: in the next line, 'B' represents a block separator, not the letter 'B'.
LRE A B C PDF;2;0;x 2 0 0 x;1 2 3
# Note: in the next line, 'b' represents the letter 'b', not a block separator.
a b c 05d0 05d1 x ; 0 ; 0 ; 0 0 0 1 1 0 ; 0 1 2 4 3 5
a R R x ; 1 ; 1 ; 2 1 1 2
L L R R R B R R L L L B ON ON ; 3 ; 0 ; 0 0 1 1 1 0 1 1 2 2 2 1 1 1
*
*******************************************************************************
*/
public void TestBidiCharacterTest() throws IOException {
BufferedReader bidiTestFile=TestUtil.getDataReader("unicode/BidiCharacterTest.txt");
Bidi ubidi=new Bidi();
lineNumber=0;
levelsCount=0;
orderingCount=0;
errorCount=0;
outerLoop:
while(errorCount<20 && (line=bidiTestFile.readLine())!=null) {
++lineNumber;
paraLevelName="N/A";
inputString="N/A";
lineIndex=0;
// Remove trailing comments and whitespace.
int commentStart=line.indexOf('#');
if(commentStart>=0) {
line=line.substring(0, commentStart);
}
if(!skipWhitespace()) {
continue; // Skip empty and comment-only lines.
}
String[] parts=line.split(";");
if(parts.length<4) {
errorCount++;
errln(" on line " + lineNumber + ": Missing ; separator on line: " + line);
continue;
}
// Parse the code point string in field 0.
try {
inputStringBuilder.delete(0, inputStringBuilder.length());
for(String cp : parts[0].trim().split("[ \t]+")) {
inputStringBuilder.appendCodePoint(Integer.parseInt(cp, 16));
}
inputString=inputStringBuilder.toString();
} catch(Exception e) {
errln(" ------------ Invalid string in field 0 on line '"+line+"'");
++errorCount;
continue;
}
int paraDirection=intFromString(parts[1].trim());
byte paraLevel;
if(paraDirection==0) {
paraLevel=0;
paraLevelName="LTR";
}
else if(paraDirection==1) {
paraLevel=1;
paraLevelName="RTL";
}
else if(paraDirection==2) {
paraLevel=Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT;
paraLevelName="Auto/LTR";
}
else if(paraDirection==3) {
paraLevel=Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT;
paraLevelName="Auto/RTL";
}
else if(paraDirection<0 && -paraDirection<=(Bidi.MAX_EXPLICIT_LEVEL+1)) {
paraLevel=(byte)(-paraDirection);
paraLevelName=Byte.toString(paraLevel);
}
else {
errorCount++;
errln(" on line " + lineNumber + ": Input paragraph direction incorrect at " + line);
continue;
}
int resolvedParaLevel=intFromString(parts[2].trim());
if(resolvedParaLevel<0 || resolvedParaLevel>(Bidi.MAX_EXPLICIT_LEVEL+1)) {
errorCount++;
errln(" on line " + lineNumber + ": Resolved paragraph level incorrect at " + line);
continue;
}
if(!parseLevels(parts[3])) {
continue;
}
if(parts.length>4) {
if(!parseOrdering(parts[4]))
continue;
}
else
orderingCount=-1;
ubidi.setPara(inputString, paraLevel, null);
byte actualParaLevel=ubidi.getParaLevel();
if(actualParaLevel!=resolvedParaLevel) {
errln(" ------------ Wrong resolved paragraph level; expected "
+resolvedParaLevel+" actual "
+actualParaLevel);
printErrorLine();
}
byte[] actualLevels=ubidi.getLevels();
if(!checkLevels(actualLevels)) {
continue outerLoop;
}
if(!checkOrdering(ubidi)) {
continue outerLoop;
}
}
}
private static final byte paraLevels[]={
Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT,
0,
@ -92,39 +261,57 @@ outerLoop:
};
private static final String paraLevelNames[]={ "auto/LTR", "LTR", "RTL", "auto/RTL" };
private void parseLevels() {
directionBits=0;
levelsCount=0;
if(skipWhitespace()) {
String[] levelStrings=line.substring(lineIndex).split("[ \t]+");
for(String levelString: levelStrings) {
if(levelString.equals("x")) {
levels[levelsCount++]=Bidi.LEVEL_DEFAULT_LTR;
} else {
int value=Integer.parseInt(levelString);
if(value<0 || value>(Bidi.MAX_EXPLICIT_LEVEL+1)) {
throw new IllegalArgumentException(
"@Levels: parse error at "+levelString+" in "+line);
}
levels[levelsCount++]=(byte)value;
directionBits|=(1<<(value&1));
}
}
private int intFromString(String str) {
try {
return Integer.parseInt(str);
} catch (Exception e) {
return -9999;
}
}
private void parseOrdering() {
orderingCount=0;
if(skipWhitespace()) {
String[] orderingStrings=line.substring(lineIndex).split("[ \t]+");
for(String orderingString: orderingStrings) {
int value=Integer.parseInt(orderingString);
if(value>=1000) {
throw new IllegalArgumentException(
"@Reorder: parse error at "+orderingString+" in "+line);
private boolean parseLevels(String s) {
directionBits=0;
levelsCount=0;
String[] levelStrings=s.trim().split("[ \t]+");
for(String levelString: levelStrings) {
if(levelString.length()==0) { continue; }
if(levelString.equals("x")) {
levels[levelsCount++]=-1;
} else {
try {
int value=Integer.parseInt(levelString);
if(0<=value && value<=(Bidi.MAX_EXPLICIT_LEVEL+1)) {
levels[levelsCount++]=(byte)value;
directionBits|=(1<<(value&1));
continue;
}
} catch(Exception e) {
}
ordering[orderingCount++]=value;
errln(" ------------ Levels parse error at '"+levelString+"'");
printErrorLine();
return false;
}
}
return true;
}
private boolean parseOrdering(String s) {
orderingCount=0;
String[] orderingStrings=s.trim().split("[ \t]+");
for(String orderingString: orderingStrings) {
if(orderingString.length()==0) { continue; }
try {
int value=Integer.parseInt(orderingString);
if(value<1000) {
ordering[orderingCount++]=value;
continue;
}
} catch(Exception e) {
}
errln(" ------------ Reorder parse error at '"+orderingString+"'");
printErrorLine();
return false;
}
return true;
}
private static char charFromBiDiClass[]={
0x6c, // 'l' for L
@ -186,9 +373,10 @@ outerLoop:
// a complete, short BiDi class name.
if(c0=='L') {
if((lineIndex+2)<line.length() && line.charAt(lineIndex+1)=='R') {
if((c2=line.charAt(lineIndex+2))=='E') {
c2=line.charAt(lineIndex+2);
if(c2=='E') {
biDiClass=UCharacterDirection.LEFT_TO_RIGHT_EMBEDDING;
} else if(line.charAt(lineIndex+2)=='I') {
} else if(c2=='I') {
biDiClass=UCharacterDirection.LEFT_TO_RIGHT_ISOLATE;
} else if(c2=='O') {
biDiClass=UCharacterDirection.LEFT_TO_RIGHT_OVERRIDE;
@ -198,9 +386,10 @@ outerLoop:
}
} else if(c0=='R') {
if((lineIndex+2)<line.length() && line.charAt(lineIndex+1)=='L') {
if((c2=line.charAt(lineIndex+2))=='E') {
c2=line.charAt(lineIndex+2);
if(c2=='E') {
biDiClass=UCharacterDirection.RIGHT_TO_LEFT_EMBEDDING;
} else if(line.charAt(lineIndex+2)=='I') {
} else if(c2=='I') {
biDiClass=UCharacterDirection.RIGHT_TO_LEFT_ISOLATE;
} else if(c2=='O') {
biDiClass=UCharacterDirection.RIGHT_TO_LEFT_OVERRIDE;
@ -272,10 +461,10 @@ outerLoop:
}
private static char printLevel(byte level) {
if(level<Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT) {
return (char)('0'+level);
} else {
if(level<0) {
return 'x';
} else {
return (char)('0'+level);
}
}
@ -286,14 +475,14 @@ outerLoop:
}
return actualDirectionBits;
}
private boolean checkLevels(byte actualLevels[], String paraLevelName) {
private boolean checkLevels(byte actualLevels[]) {
boolean isOk=true;
if(levelsCount!=actualLevels.length) {
errln("Wrong number of level values; expected "+levelsCount+" actual "+actualLevels.length);
errln(" ------------ Wrong number of level values; expected "+levelsCount+" actual "+actualLevels.length);
isOk=false;
} else {
for(int i=0; i<actualLevels.length; ++i) {
if(levels[i]!=actualLevels[i] && levels[i]<Bidi.LEVEL_DEFAULT_LTR) {
if(levels[i]!=actualLevels[i] && levels[i]>=0) {
if(directionBits!=3 && directionBits==getDirectionBits(actualLevels)) {
// ICU used a shortcut:
// Since the text is unidirectional, it did not store the resolved
@ -301,7 +490,7 @@ outerLoop:
// The reordering result is the same, so this is fine.
break;
} else {
errln("Wrong level value at index "+i+"; expected levels[i] actual "+actualLevels[i]);
errln(" ------------ Wrong level value at index "+i+"; expected "+levels[i]+" actual "+actualLevels[i]);
isOk=false;
break;
}
@ -309,7 +498,7 @@ outerLoop:
}
}
if(!isOk) {
printErrorLine(paraLevelName);
printErrorLine();
StringBuilder els=new StringBuilder("Expected levels: ");
int i;
for(i=0; i<levelsCount; ++i) {
@ -330,7 +519,9 @@ outerLoop:
// and anyway also removes LRM/RLM/ZWJ/ZWNJ which is not desirable here.
// Therefore we just skip the indexes for BiDi controls while comparing
// with the expected ordering that has them omitted.
private boolean checkOrdering(Bidi ubidi, String paraLevelName) {
private boolean checkOrdering(Bidi ubidi) {
if(orderingCount<0)
return true;
boolean isOk=true;
int resultLength=ubidi.getResultLength(); // visual length including BiDi controls
int i, visualIndex;
@ -338,11 +529,11 @@ outerLoop:
// and loop over each run's indexes, but that seems unnecessary for this test code.
for(i=visualIndex=0; i<resultLength; ++i) {
int logicalIndex=ubidi.getLogicalIndex(i);
if(levels[logicalIndex]>=Bidi.LEVEL_DEFAULT_LTR) {
if(levels[logicalIndex]<0) {
continue; // BiDi control, omitted from expected ordering.
}
if(visualIndex<orderingCount && logicalIndex!=ordering[visualIndex]) {
errln("Wrong ordering value at visual index "+visualIndex+"; expected "+
errln(" ------------ Wrong ordering value at visual index "+visualIndex+"; expected "+
ordering[visualIndex]+" actual "+logicalIndex);
isOk=false;
break;
@ -352,11 +543,11 @@ outerLoop:
// visualIndex is now the visual length minus the BiDi controls,
// which should match the length of the BidiTest.txt ordering.
if(isOk && orderingCount!=visualIndex) {
errln("Wrong number of ordering values; expected "+orderingCount+" actual "+visualIndex);
errln(" ------------ Wrong number of ordering values; expected "+orderingCount+" actual "+visualIndex);
isOk=false;
}
if(!isOk) {
printErrorLine(paraLevelName);
printErrorLine();
StringBuilder eord=new StringBuilder("Expected ordering: ");
for(i=0; i<orderingCount; ++i) {
eord.append(' ').append((char)('0'+ordering[i]));
@ -374,7 +565,7 @@ outerLoop:
return isOk;
}
private void printErrorLine(String paraLevelName) {
private void printErrorLine() {
++errorCount;
errln(String.format("Input line %5d: %s", lineNumber, line));
errln("Input string: "+inputString);
@ -408,5 +599,6 @@ outerLoop:
private int orderingCount;
private int errorCount;
private String inputString;
private String paraLevelName;
private StringBuilder inputStringBuilder=new StringBuilder();
}

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2007-2010, International Business Machines
* Copyright (C) 2007-2013, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
@ -436,13 +436,15 @@ public class TestBidi extends BidiTest {
int[] map = Bidi.reorderLogical(null);
assertTrue("\nWe should have got a null map #1", map == null);
map = Bidi.reorderLogical(new byte[] {0,99,99});
map = Bidi.reorderLogical(new byte[] {0,126, 127});
assertTrue("\nWe should have got a null map #2", map == null);
map = Bidi.reorderVisual(null);
assertTrue("\nWe should have got a null map #3", map == null);
map = Bidi.reorderVisual(new byte[] {0, -1, 4});
assertTrue("\nWe should have got a null map #4", map == null);
map = Bidi.invertMap(null);
assertTrue("\nWe should have got a null map #4", map == null);
assertTrue("\nWe should have got a null map #5", map == null);
map = Bidi.invertMap(new int[] {0,1,-1,5,4});
assertTrue("\nUnexpected inverted Map",
Arrays.equals(map, new int[] {0,1,-1,-1,4,3}));
@ -513,7 +515,7 @@ public class TestBidi extends BidiTest {
/* check exceeding para level */
bidi = new Bidi();
bidi.setPara("A\u202a\u05d0\u202aC\u202c\u05d1\u202cE", (byte)(Bidi.MAX_EXPLICIT_LEVEL - 1), null);
assertEquals("\nWrong level at index 2", 61, bidi.getLevelAt(2));
assertEquals("\nWrong level at index 2", Bidi.MAX_EXPLICIT_LEVEL, bidi.getLevelAt(2));
/* check 1-char runs with RUNS_ONLY */
bidi.setReorderingMode(Bidi.REORDER_RUNS_ONLY);

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2007, International Business Machines
* Copyright (C) 2007-2013, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
@ -79,7 +79,7 @@ public class TestClassOverride extends BidiTest {
errln("Bidi classifier is not yet set, but reported as not null");
}
} else {
Class expectedClass = this.classifier.getClass();
Class<?> expectedClass = this.classifier.getClass();
assertTrue("null Bidi classifier", actualClassifier != null);
if (actualClassifier == null) {
return;

View file

@ -56,12 +56,16 @@ public class TestData {
{ AL, R, AL, WS, EN, CS, WS, EN, CS, EN, WS, R, R, WS, L, L }, // 4
{ R, EN, NSM, ET }, // 5
{ RLE, WS, R, R, R, WS, PDF, WS, B }, // 6
{ LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE,
LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE,
LRE, LRE, LRE, AN, RLO, NSM, LRE, PDF, RLE, ES, EN, ON }, // 7
{ LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE,
LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE,
LRE, LRE, LRE, LRE, BN, CS, RLO, S, PDF, EN, LRO, AN, ES }, // 8
{
LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, /* 15 entries */
LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, /* 15 entries */
AN, RLO, NSM, LRE, PDF, RLE, ES, EN, ON /* 9 entries */
}, //7
{
LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, /* 15 entries */
LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, LRE, /* 15 entries */
LRE, BN, CS, RLO, S, PDF, EN, LRO, AN, ES /* 10 entries */
}, // 8
{ S, WS, NSM, RLE, WS, L, L, L, WS, LRO, WS, R, R, R, WS, RLO, WS, L, L,
L, WS, LRE, WS, R, R, R, WS, PDF, WS, L, L, L, WS, PDF, WS, AL, AL,
AL, WS, PDF, WS, L, L, L, WS, PDF, WS, L, L, L, WS, PDF, ON, PDF,
@ -107,12 +111,16 @@ public class TestData {
{ 1, 1, 1, 1, 2, 1, 1, 2, 2, 2, 1, 1, 1, 1, 2, 2 }, // 4
{ 1, 2, 2, 2 }, // 5
{ 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // 6
{ 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 61, 61,
61, 61, 61, 61, 61, 61 }, // 7
{ 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 0,
0, 62, 62, 62, 62, 60 }, // 8
{
126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, /* 15 entries */
126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, /* 15 entries */
126, 125, 125, 125, 125, 125, 125, 125, 125 /* 9 entries */
}, // 7
{
124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, /* 15 entries */
124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, /* 15 entries */
124, 124, 124, 64, 64, 124, 124, 126, 126, 124 /* 10 entries */
}, // 8
{ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4,
5, 5, 5, 4, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // 9
@ -154,9 +162,11 @@ public class TestData {
{ 15, 14, 13, 12, 11, 10, 9, 6, 7, 8, 5, 4, 3, 2, 0, 1 }, // 4
{ 3, 0, 1, 2 }, // 5
{ 8, 7, 6, 5, 4, 3, 2, 1, 0 }, // 6
{ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 7, 6, 5, 4, 3,
2, 1, 0 }, // 7
{
8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, /* 15 entries */
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, /* 15 entries */
38, 7, 6, 5, 4, 3, 2, 1, 0 /* 9 entries */
}, // 7
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
37, 38, 39 }, // 8
@ -197,7 +207,7 @@ public class TestData {
protected static final byte[] testParaLevels = {
Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR,
Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR,
Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR,
Bidi.LEVEL_DEFAULT_LTR, 64, 64,
Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_RTL,
2, 5, Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR,
Bidi.LEVEL_DEFAULT_LTR, Bidi.LEVEL_DEFAULT_LTR, Bidi.RTL, Bidi.LTR, Bidi.RTL,
@ -213,7 +223,7 @@ public class TestData {
protected static final byte[] testResultLevels = new byte[] {
Bidi.LTR, Bidi.RTL, Bidi.LTR, Bidi.LTR, Bidi.RTL, Bidi.RTL, Bidi.RTL,
Bidi.LTR, Bidi.LTR, Bidi.LTR, Bidi.LTR, Bidi.LTR, 2, 5, Bidi.LTR,
64, 64 , Bidi.LTR, Bidi.LTR, Bidi.LTR, 2, 5, Bidi.LTR,
Bidi.LTR, Bidi.LTR, Bidi.RTL, 2, Bidi.RTL, Bidi.LTR, Bidi.RTL, Bidi.LTR
};

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2007, International Business Machines
* Copyright (C) 2007-2013, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
@ -21,13 +21,15 @@ public class TestFailureRecovery extends BidiTest {
{
logln("\nEntering TestFailureRecovery\n");
Bidi bidi = new Bidi();
try {
bidi.setPara("abc", (byte)(Bidi.LEVEL_DEFAULT_LTR - 1), null);
errln("Bidi.setPara did not fail when passed too big para level");
} catch (IllegalArgumentException e) {
logln("OK: Got exception for bidi.setPara(..., Bidi.LEVEL_DEFAULT_LTR - 1, ...)"
+ " as expected: " + e.getMessage());
}
// Skip the following test since there are no invalid values
// between MAX_EXPLICIT_LEVEL+1 and LEVEL_DEFAULT_LTR
//try {
// bidi.setPara("abc", (byte)(Bidi.LEVEL_DEFAULT_LTR - 1), null);
// errln("Bidi.setPara did not fail when passed too big para level");
//} catch (IllegalArgumentException e) {
// logln("OK: Got exception for bidi.setPara(..., Bidi.LEVEL_DEFAULT_LTR - 1, ...)"
// + " as expected: " + e.getMessage());
//}
try {
bidi.setPara("abc", (byte)(-1), null);
errln("Bidi.setPara did not fail when passed negative para level");

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2001-2010, International Business Machines
* Copyright (C) 2001-2013, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
@ -164,7 +164,9 @@ public class TestInverse extends BidiTest {
printUnicode(visualDest.toCharArray(), null);
log("\n");
} catch (Exception e) {
errln("inverse Bidi: *** failed");
errln("\ninverse Bidi: *** failed");
errln(" error message: " + e.getMessage());
e.printStackTrace();
visualDest = null;
}

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2001-2007, International Business Machines
* Copyright (C) 2001-2013, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
@ -36,8 +36,8 @@ public class TestReorder extends BidiTest {
private static final String[] visualOrder = {
"del(CK)add(&.C.K)",
"del(TVDQ) add(LDVB)",
"del(QP)add(&.U(T(.S.R",
"del(VL)add(&.V.L (.V.L",
"del(QP)add(S.R.)&.U(T", /* updated for Unicode 6.3 matching brackets */
"del(VL)add(V.L.) &.V.L", /* updated for Unicode 6.3 matching brackets */
"day 0 RVRHDPD R dayabbr",
"day 1 ADHDPHPD H dayabbr",
"day 2 ADNELBPD L dayabbr",
@ -51,8 +51,8 @@ public class TestReorder extends BidiTest {
private static final String[] visualOrder1 = {
")K.C.&(dda)KC(led",
")BVDL(dda )QDVT(led",
"R.S.(T(U.&(dda)PQ(led",
"L.V.( L.V.&(dda)LV(led",
"T(U.&).R.S(dda)PQ(led", /* updated for Unicode 6.3 matching brackets */
"L.V.& ).L.V(dda)LV(led", /* updated for Unicode 6.3 matching brackets */
"rbbayad R DPDHRVR 0 yad",
"rbbayad H DPHPDHDA 1 yad",
"rbbayad L DPBLENDA 2 yad",

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2001-2007, International Business Machines
* Copyright (C) 2001-2013, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
@ -44,23 +44,23 @@ public class TestStreaming extends BidiTest {
"02468\r" +
"ghi",
6, new int[] { 6, 6 },
new int[][] {{ 6, 4, 6, 1, 6, 3}, { 4, 6, 6, 1, 6, 3 }},
new String[] {"6, 4, 6, 1, 6, 3", "4, 6, 6, 1, 6, 3"}
new int[][] {{ 4, 6, 6, 1, 6, 3}, { 4, 6, 6, 1, 6, 3 }},
new String[] {"4, 6, 6, 1, 6, 3", "4, 6, 6, 1, 6, 3"}
),
new TestCase("abcd\nfgh\r12345\n456",
6, new int[] { 4, 4 },
new int[][] {{ 6, 3, 6, 3 }, { 5, 4, 6, 3 }},
new String[] {"6, 3, 6, 3", "5, 4, 6, 3"}
new int[][] {{ 5, 4, 6, 3 }, { 5, 4, 6, 3 }},
new String[] {"5, 4, 6, 3", "5, 4, 6, 3"}
),
new TestCase("abcd\nfgh\r12345\n45\r",
6, new int[] { 4, 4 },
new int[][] {{ 6, 3, 6, 3 }, { 5, 4, 6, 3 }},
new String[] {"6, 3, 6, 3", "5, 4, 6, 3"}
new int[][] {{ 5, 4, 6, 3 }, { 5, 4, 6, 3 }},
new String[] {"5, 4, 6, 3", "5, 4, 6, 3"}
),
new TestCase("abcde\nfghi",
10, new int[] { 1, 2 },
new int[][] {{ 10 }, { 6, 4 }},
new String[] {"10", "6, 4"}
10, new int[] { 2, 2 },
new int[][] {{ 6, 4 }, { 6, 4 }},
new String[] {"6, 4", "6, 4"}
)
};
static final int MAXLOOPS = 20;