private void DoTests(Bidi bidi, Bidi bidiLine, bool countRunsFirst) { int testNumber; String str0; int lineStart; sbyte paraLevel; int bidiTestCount = IBM.ICU.Charset.TestData.TestCount(); for (testNumber = 0; testNumber < bidiTestCount; ++testNumber) { TestData test = IBM.ICU.Charset.TestData.GetTestData(testNumber); str0 = GetStringFromDirProps(test.dirProps); paraLevel = test.paraLevel; try { bidi.SetPara(str0, paraLevel, null); Logln("Bidi.setPara(tests[" + testNumber + "] OK, direction " + bidi.GetDirection() + " paraLevel " + paraLevel); } catch (Exception e) { Errln("Bidi.setPara(tests[" + testNumber + "] failed, direction " + bidi.GetDirection() + " paraLevel " + paraLevel); } lineStart = test.lineStart; if (lineStart == -1) { DoTest(bidi, testNumber, test, 0, countRunsFirst); } else { try { bidiLine = bidi.SetLine(lineStart, test.lineLimit); Logln("Bidi.setLine(" + lineStart + ", " + test.lineLimit + "), in tests[" + testNumber + "] OK, direction " + bidiLine.GetDirection() + " paraLevel " + bidiLine.GetBaseLevel()); DoTest(bidiLine, testNumber, test, lineStart, countRunsFirst); } catch (Exception e_0) { Errln("Bidi.setLine(" + lineStart + ", " + test.lineLimit + "), in runAll test[" + testNumber + "] failed"); } /* do it again using createLineBidi instead of setLine */ try { bidiLine = bidi.CreateLineBidi(lineStart, test.lineLimit); Logln("Bidi.createLineBidi(" + lineStart + ", " + test.lineLimit + "), in tests[" + testNumber + "] OK, direction " + bidiLine.GetDirection() + " paraLevel " + bidiLine.GetBaseLevel()); DoTest(bidiLine, testNumber, test, lineStart, countRunsFirst); } catch (Exception e_1) { Errln("Bidi.createLineBidi(" + lineStart + ", " + test.lineLimit + "), in runAll test[" + testNumber + "] failed"); } } } }
internal void CompareBidi(Bidi bidi, Bidi jbidi) { sbyte paraLevel = bidi.GetParaLevel(); if (bidi.BaseIsLeftToRight() != jbidi.BaseIsLeftToRight()) { Errln("Discrepancy in baseIsLeftToRight for case " + "(level=" + paraLevel + "): " + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString()) + "\n bidi: " + bidi.BaseIsLeftToRight() + "\n jbidi: " + jbidi.BaseIsLeftToRight()); } if (bidi.GetBaseLevel() != jbidi.GetBaseLevel()) { Errln("Discrepancy in getBaseLevel for case " + "(level=" + paraLevel + "): " + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString()) + "\n bidi: " + bidi.GetBaseLevel() + "\n jbidi: " + jbidi.GetBaseLevel()); } if (bidi.GetLength() != jbidi.GetLength()) { Errln("Discrepancy in getLength for case " + "(level=" + paraLevel + "): " + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString()) + "\n bidi: " + bidi.GetLength() + "\n jbidi: " + jbidi.GetLength()); } int len = bidi.GetLength(); for (int i = 0; i < len; i++) { if (bidi.GetLevelAt(i) != jbidi.GetLevelAt(i)) { Errln("Discrepancy in getLevelAt for offset " + i + " of case " + "(level=" + paraLevel + "): " + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString()) + "\n bidi: " + bidi.GetLevelAt(i) + "\n jbidi: " + jbidi.GetLevelAt(i)); } } if (bidi.GetRunCount() != jbidi.GetRunCount()) { if (!(len == 0 && jbidi.GetRunCount() == 1)) { Errln("Discrepancy in getRunCount for case " + "(level=" + paraLevel + "): " + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString()) + "\n bidi: " + bidi.GetRunCount() + "\n jbidi: " + jbidi.GetRunCount()); } } int runCount = bidi.GetRunCount(); for (int i_0 = 0; i_0 < runCount; i_0++) { if (bidi.GetRunLevel(i_0) != jbidi.GetRunLevel(i_0)) { Errln("Discrepancy in getRunLevel for run " + i_0 + " of case " + "(level=" + paraLevel + "): " + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString()) + "\n bidi: " + bidi.GetRunLevel(i_0) + "\n jbidi: " + jbidi.GetRunLevel(i_0)); } if (bidi.GetRunLimit(i_0) != jbidi.GetRunLimit(i_0)) { Errln("Discrepancy in getRunLimit for run " + i_0 + " of case " + "(level=" + paraLevel + "): " + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString()) + "\n bidi: " + bidi.GetRunLimit(i_0) + "\n jbidi: " + jbidi.GetRunLimit(i_0)); } if (bidi.GetRunStart(i_0) != jbidi.GetRunStart(i_0)) { Errln("Discrepancy in getRunStart for run " + i_0 + " of case " + "(level=" + paraLevel + "): " + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString()) + "\n bidi: " + bidi.GetRunStart(i_0) + "\n jbidi: " + jbidi.GetRunStart(i_0)); } } if (bidi.IsLeftToRight() != jbidi.IsLeftToRight()) { Errln("Discrepancy in isLeftToRight for case " + "(level=" + paraLevel + "): " + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString()) + "\n bidi: " + bidi.IsLeftToRight() + "\n jbidi: " + jbidi.IsLeftToRight()); } if (bidi.IsMixed() != jbidi.IsMixed()) { Errln("Discrepancy in isMixed for case " + "(level=" + paraLevel + "): " + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString()) + "\n bidi: " + bidi.IsMixed() + "\n jbidi: " + jbidi.IsMixed()); } if (bidi.IsRightToLeft() != jbidi.IsRightToLeft()) { Errln("Discrepancy in isRightToLeft for case " + "(level=" + paraLevel + "): " + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString()) + "\n bidi: " + bidi.IsRightToLeft() + "\n jbidi: " + jbidi.IsRightToLeft()); } char[] text = bidi.GetText(); if (IBM.ICU.Text.Bidi.RequiresBidi(text, 0, text.Length) != Bidi .RequiresBidi(text, 0, text.Length)) { Errln("Discrepancy in requiresBidi for case " + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString()) + "\n bidi: " + IBM.ICU.Text.Bidi.RequiresBidi(text, 0, text.Length) + "\n jbidi: " + Bidi.RequiresBidi(text, 0, text.Length)); } /* * skip the next test, since the toString implementation are not * compatible if (!bidi.toString().equals(jbidi.toString())) { * errln("Discrepancy in toString for case " + "(level=" + paraLevel + * "): " + u16ToPseudo(bidi.getTextAsString() + "\n bidi: " + * bidi.toString() + "\n jbidi: " + jbidi.toString())); } */ }