Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 196576 Details for
Bug 183164
[Implementation for] Display of Complex Expressions Containing Bidirectional Text
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
tests for new version of package for structured text support
patch_bidi_tests_20110525.txt (text/plain), 138.44 KB, created by
Matitiahu Allouche
on 2011-05-25 12:45:25 EDT
(
hide
)
Description:
tests for new version of package for structured text support
Filename:
MIME Type:
Creator:
Matitiahu Allouche
Created:
2011-05-25 12:45:25 EDT
Size:
138.44 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.equinox.bidi.tests >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/components/bundles/org.eclipse.equinox.bidi.tests/plugin.xml,v >retrieving revision 1.2 >diff -u -r1.2 plugin.xml >--- plugin.xml 9 Feb 2011 21:28:56 -0000 1.2 >+++ plugin.xml 25 May 2011 16:25:00 -0000 >@@ -5,7 +5,7 @@ > id="id2" > point="org.eclipse.equinox.bidi.bidiTypes"> > <typeDescription >- class="org.eclipse.equinox.bidi.internal.tests.BidiComplexTest" >+ class="org.eclipse.equinox.bidi.internal.tests.STextTest" > description="Test" > type="test"> > </typeDescription> >Index: src/org/eclipse/equinox/bidi/internal/tests/BidiComplexExtensibilityTest.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/internal/tests/BidiComplexExtensibilityTest.java >diff -N src/org/eclipse/equinox/bidi/internal/tests/BidiComplexExtensibilityTest.java >--- src/org/eclipse/equinox/bidi/internal/tests/BidiComplexExtensibilityTest.java 27 Apr 2011 14:53:08 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,64 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2010, 2011 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >- >-package org.eclipse.equinox.bidi.internal.tests; >- >-import org.eclipse.equinox.bidi.BidiComplexEngine; >-import org.eclipse.equinox.bidi.custom.BidiComplexStringProcessor; >-import org.eclipse.equinox.bidi.custom.IBidiComplexProcessor; >- >-/** >- * Tests contribution of BiDi processors. >- */ >-public class BidiComplexExtensibilityTest extends BidiComplexTestBase { >- >- public void testBaseContributions() { >- String[] types = BidiComplexStringProcessor.getKnownTypes(); >- assertNotNull(types); >- assertTrue(types.length > 0); >- >- // check one of the types that we know should be there >- assertTrue(isTypePresent(types, "regex")); >- >- IBidiComplexProcessor processor = BidiComplexStringProcessor.getProcessor("regex"); >- assertNotNull(processor); >- } >- >- public void testOtherContributions() { >- String[] types = BidiComplexStringProcessor.getKnownTypes(); >- assertNotNull(types); >- assertTrue(types.length > 0); >- >- // check the type added by the test bundle >- assertTrue(isTypePresent(types, "test")); >- >- IBidiComplexProcessor processor = BidiComplexStringProcessor.getProcessor("test"); >- assertNotNull(processor); >- >- processor = BidiComplexStringProcessor.getProcessor("badtest"); >- assertNull(processor); >- >- String data, lean, full, model; >- data = "ABC.DEF:HOST-COM=HELLO"; >- lean = toUT16(data); >- full = BidiComplexEngine.leanToFullText("test", null, null, lean, null); >- model = "ABC@.DEF@:HOST@-COM@=HELLO"; >- assertEquals("Test 'test' plugin", model, toPseudo(full)); >- } >- >- private boolean isTypePresent(String[] types, String type) { >- for (int i = 0; i < types.length; i++) { >- if (type.equalsIgnoreCase(types[i])) >- return true; >- } >- return false; >- } >-} >Index: src/org/eclipse/equinox/bidi/internal/tests/BidiComplexExtensionsTest.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/internal/tests/BidiComplexExtensionsTest.java >diff -N src/org/eclipse/equinox/bidi/internal/tests/BidiComplexExtensionsTest.java >--- src/org/eclipse/equinox/bidi/internal/tests/BidiComplexExtensionsTest.java 17 May 2011 19:56:16 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,182 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2010, 2011 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >- >-package org.eclipse.equinox.bidi.internal.tests; >- >-import org.eclipse.equinox.bidi.BidiComplexEngine; >-import org.eclipse.equinox.bidi.IBidiComplexExpressionTypes; >-import org.eclipse.equinox.bidi.custom.*; >- >-/** >- * Tests all plug-in extensions >- */ >- >-public class BidiComplexExtensionsTest extends BidiComplexTestBase { >- >- IBidiComplexProcessor processor; >- BidiComplexFeatures f1, f2; >- int[] state = new int[1]; >- String type; >- >- private void doTest1(String label, String data, String result) { >- String full; >- full = BidiComplexEngine.leanToFullText(type, null, null, toUT16(data), state); >- assertEquals(label + " data = " + data, result, toPseudo(full)); >- } >- >- private void doTest2(String label, String data, String result) { >- String full; >- full = BidiComplexEngine.leanToFullText(type, null, null, data, state); >- assertEquals(label + " data = " + data, result, toPseudo(full)); >- } >- >- private void doTest3(String label, String data, String result) { >- String full; >- full = BidiComplexEngine.leanToFullText(processor, f2, null, toUT16(data), state); >- assertEquals(label + " data = " + data, result, toPseudo(full)); >- } >- >- public void testExtensions() { >- >- type = IBidiComplexExpressionTypes.COMMA_DELIMITED; >- state[0] = BidiComplexEngine.STATE_INITIAL; >- doTest1("Comma #1", "ab,cd, AB, CD, EFG", "ab,cd, AB@, CD@, EFG"); >- >- type = IBidiComplexExpressionTypes.EMAIL; >- state[0] = BidiComplexEngine.STATE_INITIAL; >- doTest1("Email #1", "abc.DEF:GHI", "abc.DEF@:GHI"); >- doTest1("Email #2", "DEF.GHI \"A.B\":JK ", "DEF@.GHI @\"A.B\"@:JK "); >- doTest1("Email #3", "DEF,GHI (A,B);JK ", "DEF@,GHI @(A,B)@;JK "); >- doTest1("Email #4", "DEF.GHI (A.B :JK ", "DEF@.GHI @(A.B :JK "); >- >- type = IBidiComplexExpressionTypes.FILE; >- state[0] = BidiComplexEngine.STATE_INITIAL; >- doTest1("File #1", "c:\\A\\B\\FILE.EXT", "c:\\A@\\B@\\FILE@.EXT"); >- >- type = IBidiComplexExpressionTypes.JAVA; >- state[0] = BidiComplexEngine.STATE_INITIAL; >- doTest1("Java #1", "A = B + C;", "A@ = B@ + C;"); >- doTest1("Java #2", "A = B + C;", "A@ = B@ + C;"); >- doTest1("Java #3", "A = \"B+C\"+D;", "A@ = \"B+C\"@+D;"); >- doTest1("Java #4", "A = \"B+C+D;", "A@ = \"B+C+D;"); >- doTest1("Java #5", "A = \"B\\\"C\"+D;", "A@ = \"B\\\"C\"@+D;"); >- doTest1("Java #6", "A = /*B+C*/ D;", "A@ = /*B+C@*/ D;"); >- doTest1("Java #7", "A = /*B+C* D;", "A@ = /*B+C* D;"); >- doTest1("Java #8", "X+Y+Z */ B; ", "X+Y+Z @*/ B; "); >- doTest1("Java #9", "A = //B+C* D;", "A@ = //B+C* D;"); >- doTest1("Java #10", "A = //B+C`|D+E;", "A@ = //B+C`|D@+E;"); >- >- type = IBidiComplexExpressionTypes.PROPERTY; >- state[0] = BidiComplexEngine.STATE_INITIAL; >- doTest1("Property #0", "NAME,VAL1,VAL2", "NAME,VAL1,VAL2"); >- doTest1("Property #1", "NAME=VAL1,VAL2", "NAME@=VAL1,VAL2"); >- doTest1("Property #2", "NAME=VAL1,VAL2=VAL3", "NAME@=VAL1,VAL2=VAL3"); >- >- String data; >- type = IBidiComplexExpressionTypes.REGEXP; >- state[0] = BidiComplexEngine.STATE_INITIAL; >- data = toUT16("ABC(?") + "#" + toUT16("DEF)GHI"); >- doTest2("Regex #0.0", data, "A@B@C@(?#DEF)@G@H@I"); >- data = toUT16("ABC(?") + "#" + toUT16("DEF"); >- doTest2("Regex #0.1", data, "A@B@C@(?#DEF"); >- doTest1("Regex #0.2", "GHI)JKL", "GHI)@J@K@L"); >- data = toUT16("ABC(?") + "<" + toUT16("DEF") + ">" + toUT16("GHI"); >- doTest2("Regex #1", data, "A@B@C@(?<DEF>@G@H@I"); >- doTest1("Regex #2.0", "ABC(?'DEF'GHI", "A@B@C@(?'DEF'@G@H@I"); >- doTest1("Regex #2.1", "ABC(?'DEFGHI", "A@B@C@(?'DEFGHI"); >- data = toUT16("ABC(?(") + "<" + toUT16("DEF") + ">" + toUT16(")GHI"); >- doTest2("Regex #3", data, "A@B@C@(?(<DEF>)@G@H@I"); >- doTest1("Regex #4", "ABC(?('DEF')GHI", "A@B@C@(?('DEF')@G@H@I"); >- doTest1("Regex #5", "ABC(?(DEF)GHI", "A@B@C@(?(DEF)@G@H@I"); >- data = toUT16("ABC(?") + "&" + toUT16("DEF)GHI"); >- doTest2("Regex #6", data, "A@B@C@(?&DEF)@G@H@I"); >- data = toUT16("ABC(?") + "P<" + toUT16("DEF") + ">" + toUT16("GHI"); >- doTest2("Regex #7", data, "A@B@C(?p<DEF>@G@H@I"); >- data = toUT16("ABC\\k") + "<" + toUT16("DEF") + ">" + toUT16("GHI"); >- doTest2("Regex #8", data, "A@B@C\\k<DEF>@G@H@I"); >- doTest1("Regex #9", "ABC\\k'DEF'GHI", "A@B@C\\k'DEF'@G@H@I"); >- doTest1("Regex #10", "ABC\\k{DEF}GHI", "A@B@C\\k{DEF}@G@H@I"); >- data = toUT16("ABC(?") + "P=" + toUT16("DEF)GHI"); >- doTest2("Regex #11", data, "A@B@C(?p=DEF)@G@H@I"); >- doTest1("Regex #12", "ABC\\g{DEF}GHI", "A@B@C\\g{DEF}@G@H@I"); >- data = toUT16("ABC\\g") + "<" + toUT16("DEF") + ">" + toUT16("GHI"); >- doTest2("Regex #13", data, "A@B@C\\g<DEF>@G@H@I"); >- doTest1("Regex #14", "ABC\\g'DEF'GHI", "A@B@C\\g'DEF'@G@H@I"); >- data = toUT16("ABC(?(") + "R&" + toUT16("DEF)GHI"); >- doTest2("Regex #15", data, "A@B@C(?(r&DEF)@G@H@I"); >- data = toUT16("ABC") + "\\Q" + toUT16("DEF") + "\\E" + toUT16("GHI"); >- doTest2("Regex #16.0", data, "A@B@C\\qDEF\\eG@H@I"); >- data = toUT16("ABC") + "\\Q" + toUT16("DEF"); >- doTest2("Regex #16.1", data, "A@B@C\\qDEF"); >- data = toUT16("GHI") + "\\E" + toUT16("JKL"); >- doTest2("Regex #16.2", data, "GHI\\eJ@K@L"); >- doTest1("Regex #17.0", "abc[d-h]ijk", "abc[d-h]ijk"); >- doTest1("Regex #17.1", "aBc[d-H]iJk", "aBc[d-H]iJk"); >- doTest1("Regex #17.2", "aB*[!-H]iJ2", "aB*[!-@H]iJ@2"); >- doTest1("Regex #17.3", "aB*[1-2]J3", "aB*[@1-2]J@3"); >- doTest1("Regex #17.4", "aB*[5-6]J3", "aB*[@5-@6]@J@3"); >- doTest1("Regex #17.5", "a*[5-6]J3", "a*[5-@6]@J@3"); >- doTest1("Regex #17.6", "aB*123", "aB*@123"); >- doTest1("Regex #17.7", "aB*567", "aB*@567"); >- >- type = IBidiComplexExpressionTypes.SQL; >- state[0] = BidiComplexEngine.STATE_INITIAL; >- doTest1("SQL #0", "abc GHI", "abc GHI"); >- doTest1("SQL #1", "abc DEF GHI", "abc DEF@ GHI"); >- doTest1("SQL #2", "ABC, DEF, GHI", "ABC@, DEF@, GHI"); >- doTest1("SQL #3", "ABC'DEF GHI' JKL,MN", "ABC@'DEF GHI'@ JKL@,MN"); >- doTest1("SQL #4.0", "ABC'DEF GHI JKL", "ABC@'DEF GHI JKL"); >- doTest1("SQL #4.1", "MNO PQ' RS,TUV", "MNO PQ'@ RS@,TUV"); >- doTest1("SQL #5", "ABC\"DEF GHI\" JKL,MN", "ABC@\"DEF GHI\"@ JKL@,MN"); >- doTest1("SQL #6", "ABC\"DEF GHI JKL", "ABC@\"DEF GHI JKL"); >- doTest1("SQL #7", "ABC/*DEF GHI*/ JKL,MN", "ABC@/*DEF GHI@*/ JKL@,MN"); >- doTest1("SQL #8.0", "ABC/*DEF GHI JKL", "ABC@/*DEF GHI JKL"); >- doTest1("SQL #8.1", "MNO PQ*/RS,TUV", "MNO PQ@*/RS@,TUV"); >- doTest1("SQL #9", "ABC--DEF GHI JKL", "ABC@--DEF GHI JKL"); >- doTest1("SQL #10", "ABC--DEF--GHI,JKL", "ABC@--DEF--GHI,JKL"); >- doTest1("SQL #11", "ABC'DEF '' G I' JKL,MN", "ABC@'DEF '' G I'@ JKL@,MN"); >- doTest1("SQL #12", "ABC\"DEF \"\" G I\" JKL,MN", "ABC@\"DEF \"\" G I\"@ JKL@,MN"); >- doTest1("SQL #13", "ABC--DEF GHI`|JKL MN", "ABC@--DEF GHI`|JKL@ MN"); >- >- type = IBidiComplexExpressionTypes.SYSTEM_USER; >- state[0] = BidiComplexEngine.STATE_INITIAL; >- doTest1("System #1", "HOST(JACK)", "HOST@(JACK)"); >- >- type = IBidiComplexExpressionTypes.UNDERSCORE; >- state[0] = BidiComplexEngine.STATE_INITIAL; >- doTest1("Underscore #1", "A_B_C_d_e_F_G", "A@_B@_C_d_e_F@_G"); >- >- type = IBidiComplexExpressionTypes.URL; >- state[0] = BidiComplexEngine.STATE_INITIAL; >- doTest1("URL #1", "WWW.DOMAIN.COM/DIR1/DIR2/dir3/DIR4", "WWW@.DOMAIN@.COM@/DIR1@/DIR2/dir3/DIR4"); >- >- type = IBidiComplexExpressionTypes.XPATH; >- state[0] = BidiComplexEngine.STATE_INITIAL; >- doTest1("Xpath #1", "abc(DEF)GHI", "abc(DEF@)GHI"); >- doTest1("Xpath #2", "DEF.GHI \"A.B\":JK ", "DEF@.GHI@ \"A.B\"@:JK "); >- doTest1("Xpath #3", "DEF!GHI 'A!B'=JK ", "DEF@!GHI@ 'A!B'@=JK "); >- doTest1("Xpath #4", "DEF.GHI 'A.B :JK ", "DEF@.GHI@ 'A.B :JK "); >- >- type = IBidiComplexExpressionTypes.EMAIL; >- processor = BidiComplexStringProcessor.getProcessor(type); >- state[0] = BidiComplexEngine.STATE_INITIAL; >- f1 = processor.getFeatures(null); >- assertEquals("<>.:,;@", f1.getSeparators()); >- f2 = new BidiComplexFeatures("+-*/", f1.getSpecialsCount(), f1.getDirArabic(), f1.getDirHebrew(), f1.getIgnoreArabic(), f1.getIgnoreHebrew()); >- doTest3("DelimsEsc #1", "abc+DEF-GHI", "abc+DEF@-GHI"); >- doTest3("DelimsEsc #2", "DEF-GHI (A*B)/JK ", "DEF@-GHI @(A*B)@/JK "); >- doTest3("DelimsEsc #3", "DEF-GHI (A*B)/JK ", "DEF@-GHI @(A*B)@/JK "); >- doTest3("DelimsEsc #4", "DEF-GHI (A*B\\)*C) /JK ", "DEF@-GHI @(A*B\\)*C) @/JK "); >- doTest3("DelimsEsc #5", "DEF-GHI (A\\\\\\)*C) /JK ", "DEF@-GHI @(A\\\\\\)*C) @/JK "); >- doTest3("DelimsEsc #6", "DEF-GHI (A\\\\)*C /JK ", "DEF@-GHI @(A\\\\)@*C @/JK "); >- doTest3("DelimsEsc #7", "DEF-GHI (A\\)*C /JK ", "DEF@-GHI @(A\\)*C /JK "); >- } >-} >Index: src/org/eclipse/equinox/bidi/internal/tests/BidiComplexFullToLeanTest.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/internal/tests/BidiComplexFullToLeanTest.java >diff -N src/org/eclipse/equinox/bidi/internal/tests/BidiComplexFullToLeanTest.java >--- src/org/eclipse/equinox/bidi/internal/tests/BidiComplexFullToLeanTest.java 27 Apr 2011 14:53:08 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,247 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2010, 2011 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >- >-package org.eclipse.equinox.bidi.internal.tests; >- >-import org.eclipse.equinox.bidi.*; >- >-/** >- * Tests fullToLean method >- */ >- >-public class BidiComplexFullToLeanTest extends BidiComplexTestBase { >- >- static final BidiComplexEnvironment envLTR = new BidiComplexEnvironment(null, false, BidiComplexEnvironment.ORIENT_LTR); >- static final BidiComplexEnvironment envRTL = new BidiComplexEnvironment(null, false, BidiComplexEnvironment.ORIENT_RTL); >- >- String type; >- >- private void doTest1(String msg, String data, String leanLTR, String fullLTR, int[] l2fMapLTR, int[] f2lMapLTR, String leanRTL, String fullRTL, int[] l2fMapRTL, int[] f2lMapRTL) { >- String text, full, lean, label; >- int[] map; >- >- text = toUT16(data); >- lean = BidiComplexEngine.fullToLeanText(type, null, envLTR, text, null); >- assertEquals(msg + "LTR lean", leanLTR, toPseudo(lean)); >- full = BidiComplexEngine.leanToFullText(type, null, envLTR, lean, null); >- assertEquals(msg + "LTR full", fullLTR, toPseudo(full)); >- map = BidiComplexEngine.leanToFullMap(type, null, envLTR, lean, null); >- label = msg + "leanToFullMap() LTR"; >- assertEquals(label, array_display(l2fMapLTR), array_display(map)); >- map = BidiComplexEngine.fullToLeanMap(type, null, envLTR, text, null); >- label = msg + "fullToLeanMap() LTR"; >- assertEquals(label, array_display(f2lMapLTR), array_display(map)); >- >- lean = BidiComplexEngine.fullToLeanText(type, null, envRTL, text, null); >- assertEquals(msg + "RTL lean", leanRTL, toPseudo(lean)); >- full = BidiComplexEngine.leanToFullText(type, null, envRTL, lean, null); >- assertEquals(msg + "RTL full", fullRTL, toPseudo(full)); >- map = BidiComplexEngine.leanToFullMap(type, null, envRTL, lean, null); >- label = msg + "leanToFullMap() RTL"; >- assertEquals(label, array_display(l2fMapRTL), array_display(map)); >- map = BidiComplexEngine.fullToLeanMap(type, null, envRTL, text, null); >- label = msg + "fullToLeanMap() RTL"; >- assertEquals(label, array_display(f2lMapRTL), array_display(map)); >- } >- >- private void doTest2(String msg) { >- String text, data, full, lean, model; >- int[] state = new int[1]; >- int state1, state2, state3; >- >- data = "update \"AB_CDE\" set \"COL1\"@='01', \"COL2\"@='02' /* GH IJK"; >- text = toUT16(data); >- state[0] = -1; >- lean = BidiComplexEngine.fullToLeanText(type, null, envLTR, text, state); >- state1 = state[0]; >- model = "update \"AB_CDE\" set \"COL1\"='01', \"COL2\"='02' /* GH IJK"; >- assertEquals(msg + "LTR lean", model, toPseudo(lean)); >- state[0] = -1; >- full = BidiComplexEngine.leanToFullText(type, null, envLTR, lean, state); >- assertEquals(msg + "LTR full", data, toPseudo(full)); >- assertEquals(msg + "state from leanToFullText", state1, state[0]); >- data = "THIS IS A COMMENT LINE"; >- text = toUT16(data); >- state[0] = state1; >- lean = BidiComplexEngine.fullToLeanText(type, null, envLTR, text, state); >- state2 = state[0]; >- model = "THIS IS A COMMENT LINE"; >- assertEquals(msg + "LTR lean2", model, toPseudo(lean)); >- state[0] = state1; >- full = BidiComplexEngine.leanToFullText(type, null, envLTR, lean, state); >- assertEquals(msg + "LTR full2", data, toPseudo(full)); >- assertEquals(msg + "state from leanToFullText2", state2, state[0]); >- data = "SOME MORE */ where \"COL3\"@=123"; >- text = toUT16(data); >- state[0] = state2; >- lean = BidiComplexEngine.fullToLeanText(type, null, envLTR, text, state); >- state3 = state[0]; >- model = "SOME MORE */ where \"COL3\"=123"; >- assertEquals(msg + "LTR lean3", model, toPseudo(lean)); >- state[0] = state2; >- full = BidiComplexEngine.leanToFullText(type, null, envLTR, lean, state); >- assertEquals(msg + "LTR full3", data, toPseudo(full)); >- assertEquals(msg + "state from leanToFullText3", state3, state[0]); >- } >- >- public void testFullToLean() { >- >- type = IBidiComplexExpressionTypes.COMMA_DELIMITED; >- doTest1("testFullToLean #1 - ", "", "", "", new int[0], new int[0], "", "", new int[0], new int[0]); >- int[] map1 = new int[] {0, 1, 2, 3, 4}; >- int[] map2 = new int[] {2, 3, 4, 5, 6}; >- int[] map3; >- doTest1("testFullToLean #01 - ", "1.abc", "1.abc", "1.abc", map1, map1, "1.abc", ">@1.abc@^", map2, map1); >- map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8}; >- map2 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10}; >- doTest1("testFullToLean #02 - ", "2.abc,def", "2.abc,def", "2.abc,def", map1, map1, "2.abc,def", ">@2.abc,def@^", map2, map1); >- map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; >- map2 = new int[] {-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; >- map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; >- doTest1("testFullToLean #03 - ", "@a.3.bc,def", "a.3.bc,def", "a.3.bc,def", map1, map2, "a.3.bc,def", ">@a.3.bc,def@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; >- map2 = new int[] {-1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; >- map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; >- doTest1("testFullToLean #04 - ", "@@a.4.bc,def", "a.4.bc,def", "a.4.bc,def", map1, map2, "a.4.bc,def", ">@a.4.bc,def@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8}; >- map2 = new int[] {-1, 0, 1, 2, 3, 4, 5, 6, 7, 8}; >- map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10}; >- doTest1("testFullToLean #05 - ", "@5.abc,def", "5.abc,def", "5.abc,def", map1, map2, "5.abc,def", ">@5.abc,def@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8}; >- map2 = new int[] {-1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8}; >- map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10}; >- doTest1("testFullToLean #06 - ", "@@6.abc,def", "6.abc,def", "6.abc,def", map1, map2, "6.abc,def", ">@6.abc,def@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8}; >- map2 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10}; >- doTest1("testFullToLean #07 - ", "7abc,@def", "7abc,@def", "7abc,@def", map1, map1, "7abc,@def", ">@7abc,@def@^", map2, map1); >- map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8}; >- map2 = new int[] {0, 1, 2, 3, 4, 5, -1, 6, 7, 8}; >- map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10}; >- doTest1("testFullToLean #08 - ", "8abc,@@def", "8abc,@def", "8abc,@def", map1, map2, "8abc,@def", ">@8abc,@def@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7}; >- map2 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, -1}; >- map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9}; >- doTest1("testFullToLean #09 - ", "9abc,def@", "9abc,def", "9abc,def", map1, map2, "9abc,def", ">@9abc,def@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8}; >- map2 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, -1, -1}; >- map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10}; >- doTest1("testFullToLean #10 - ", "10abc,def@@", "10abc,def", "10abc,def", map1, map2, "10abc,def", ">@10abc,def@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; >- map2 = new int[] {-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1}; >- map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; >- doTest1("testFullToLean #11 - ", "@a.11.bc,@def@", "a.11.bc,@def", "a.11.bc,@def", map1, map2, "a.11.bc,@def", ">@a.11.bc,@def@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; >- map2 = new int[] {-1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, -1, 9, 10, 11, -1, -1}; >- map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; >- doTest1("testFullToLean #12 - ", "@@a.12.bc,@@def@@", "a.12.bc,@def", "a.12.bc,@def", map1, map2, "a.12.bc,@def", ">@a.12.bc,@def@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4}; >- map2 = new int[] {2, 3, 4, 5, 6}; >- doTest1("testFullToLean #13 - ", "13ABC", "13ABC", "13ABC", map1, map1, "13ABC", ">@13ABC@^", map2, map1); >- map1 = new int[] {0, 1, 2, 3, 4, 6, 7, 8}; >- map2 = new int[] {0, 1, 2, 3, 4, 5, 6, 7}; >- map3 = new int[] {2, 3, 4, 5, 6, 8, 9, 10}; >- doTest1("testFullToLean #14 - ", "14ABC,DE", "14ABC,DE", "14ABC@,DE", map1, map2, "14ABC,DE", ">@14ABC@,DE@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 6, 7, 8}; >- map2 = new int[] {0, 1, 2, 3, 4, -1, 5, 6, 7}; >- map3 = new int[] {2, 3, 4, 5, 6, 8, 9, 10}; >- doTest1("testFullToLean #15 - ", "15ABC@,DE", "15ABC,DE", "15ABC@,DE", map1, map2, "15ABC,DE", ">@15ABC@,DE@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 6, 7, 8}; >- map2 = new int[] {0, 1, 2, 3, 4, -1, -1, 5, 6, 7}; >- map3 = new int[] {2, 3, 4, 5, 6, 8, 9, 10}; >- doTest1("testFullToLean #16 - ", "16ABC@@,DE", "16ABC,DE", "16ABC@,DE", map1, map2, "16ABC,DE", ">@16ABC@,DE@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8}; >- map2 = new int[] {0, 1, 2, 3, 4, 5, 6, -1, 7, 8}; >- map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10}; >- doTest1("testFullToLean #17 - ", "17ABC,@@DE", "17ABC,@DE", "17ABC,@DE", map1, map2, "17ABC,@DE", ">@17ABC,@DE@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 6, 7, 8, 10, 11, 12, 13}; >- map2 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; >- map3 = new int[] {2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15}; >- doTest1("testFullToLean #18 - ", "18ABC,DE,FGH", "18ABC,DE,FGH", "18ABC@,DE@,FGH", map1, map2, "18ABC,DE,FGH", ">@18ABC@,DE@,FGH@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 6, 7, 8, 10, 11, 12, 13}; >- map2 = new int[] {0, 1, 2, 3, 4, -1, 5, 6, 7, -1, 8, 9, 10, 11}; >- map3 = new int[] {2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15}; >- doTest1("testFullToLean #19 - ", "19ABC@,DE@,FGH", "19ABC,DE,FGH", "19ABC@,DE@,FGH", map1, map2, "19ABC,DE,FGH", ">@19ABC@,DE@,FGH@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; >- map2 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; >- doTest1("testFullToLean #20 - ", "20ABC,@DE,@FGH", "20ABC,@DE,@FGH", "20ABC,@DE,@FGH", map1, map1, "20ABC,@DE,@FGH", ">@20ABC,@DE,@FGH@^", map2, map1); >- map1 = new int[] {0, 1, 2, 3, 4, 6, 7, 8, 10, 11, 12, 13}; >- map2 = new int[] {0, 1, 2, 3, 4, -1, -1, 5, 6, 7, -1, -1, 8, 9, 10, 11}; >- map3 = new int[] {2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15}; >- doTest1("testFullToLean #21 - ", "21ABC@@,DE@@,FGH", "21ABC,DE,FGH", "21ABC@,DE@,FGH", map1, map2, "21ABC,DE,FGH", ">@21ABC@,DE@,FGH@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; >- map2 = new int[] {0, 1, 2, 3, 4, 5, 6, -1, 7, 8, 9, 10, -1, 11, 12, 13}; >- map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; >- doTest1("testFullToLean #22 - ", "22ABC,@@DE,@@FGH", "22ABC,@DE,@FGH", "22ABC,@DE,@FGH", map1, map2, "22ABC,@DE,@FGH", ">@22ABC,@DE,@FGH@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4}; >- map2 = new int[] {-1, -1, 0, 1, 2, 3, 4, -1, -1}; >- map3 = new int[] {2, 3, 4, 5, 6}; >- doTest1("testFullToLean #23 - ", ">@23abc@^", "23abc", "23abc", map1, map2, "23abc", ">@23abc@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4}; >- map2 = new int[] {0, 1, 2, 3, 4, -1, -1}; >- map3 = new int[] {2, 3, 4, 5, 6}; >- doTest1("testFullToLean #24 - ", "24abc@^", "24abc", "24abc", map1, map2, "24abc", ">@24abc@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4}; >- map2 = new int[] {-1, -1, 0, 1, 2, 3, 4}; >- map3 = new int[] {2, 3, 4, 5, 6}; >- doTest1("testFullToLean #25 - ", ">@25abc", "25abc", "25abc", map1, map2, "25abc", ">@25abc@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15}; >- map2 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; >- map3 = new int[] {2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17}; >- doTest1("testFullToLean #26 - ", "26AB,CD@EF,GHI", "26AB,CD@EF,GHI", "26AB@,CD@EF@,GHI", map1, map2, "26AB,CD@EF,GHI", ">@26AB@,CD@EF@,GHI@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; >- map2 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; >- map3 = new int[] {2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}; >- doTest1("testFullToLean #27 - ", "27AB,CD@123ef,GHI", "27AB,CD@123ef,GHI", "27AB@,CD@123ef,GHI", map1, map2, "27AB,CD@123ef,GHI", ">@27AB@,CD@123ef,GHI@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 6, 7, 8, 10, 11, 12, 13}; >- map2 = new int[] {-1, 0, 1, 2, 3, 4, -1, 5, 6, 7, -1, 8, 9, 10, 11, -1}; >- map3 = new int[] {2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15}; >- doTest1("testFullToLean #28 - ", ">28ABC@,DE@,FGH^", "28ABC,DE,FGH", "28ABC@,DE@,FGH", map1, map2, "28ABC,DE,FGH", ">@28ABC@,DE@,FGH@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 6, 7, 8, 10, 11, 12, 13}; >- map2 = new int[] {-1, -1, 0, 1, 2, 3, 4, -1, 5, 6, 7, -1, 8, 9, 10, 11, -1, -1}; >- map3 = new int[] {2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15}; >- doTest1("testFullToLean #29 - ", ">>29ABC@,DE@,FGH^^", "29ABC,DE,FGH", "29ABC@,DE@,FGH", map1, map2, "29ABC,DE,FGH", ">@29ABC@,DE@,FGH@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15}; >- map2 = new int[] {-1, 0, 1, 2, 3, 4, 5, 6, -1, 7, 8, 9, -1, 10, 11, 12, 13, -1}; >- map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 15, 16, 17}; >- doTest1("testFullToLean #30 - ", ">30AB>C^@,DE@,FGH^", "30AB>C^,DE,FGH", "30AB>C^@,DE@,FGH", map1, map2, "30AB>C^,DE,FGH", ">@30AB>C^@,DE@,FGH@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14}; >- map2 = new int[] {-1, 0, 1, 2, 3, 4, 5, -1, 6, 7, 8, -1, 9, 10, 11, 12, -1, -1}; >- map3 = new int[] {2, 3, 4, 5, 6, 7, 9, 10, 11, 13, 14, 15, 16}; >- doTest1("testFullToLean #31 - ", ">31AB>C@,DE@,FGH^^", "31AB>C,DE,FGH", "31AB>C@,DE@,FGH", map1, map2, "31AB>C,DE,FGH", ">@31AB>C@,DE@,FGH@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 6, 7, 8, 10, 11, 12, 13}; >- map2 = new int[] {-1, -1, 0, 1, 2, 3, 4, -1, 5, 6, 7, -1, 8, 9, 10, 11, -1, -1}; >- map3 = new int[] {2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15}; >- doTest1("testFullToLean #32 - ", ">@32ABC@,DE@,FGH@^", "32ABC,DE,FGH", "32ABC@,DE@,FGH", map1, map2, "32ABC,DE,FGH", ">@32ABC@,DE@,FGH@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 6, 7, 8, 10, 11, 12, 13}; >- map2 = new int[] {-1, 0, 1, 2, 3, 4, -1, 5, 6, 7, -1, 8, 9, 10, 11, -1, -1}; >- map3 = new int[] {2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15}; >- doTest1("testFullToLean #33 - ", "@33ABC@,DE@,FGH@^", "33ABC,DE,FGH", "33ABC@,DE@,FGH", map1, map2, "33ABC,DE,FGH", ">@33ABC@,DE@,FGH@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 6, 7, 8, 10, 11, 12, 13}; >- map2 = new int[] {-1, -1, 0, 1, 2, 3, 4, -1, 5, 6, 7, -1, 8, 9, 10, 11, -1}; >- map3 = new int[] {2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15}; >- doTest1("testFullToLean #34 - ", ">@34ABC@,DE@,FGH@", "34ABC,DE,FGH", "34ABC@,DE@,FGH", map1, map2, "34ABC,DE,FGH", ">@34ABC@,DE@,FGH@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; >- map2 = new int[] {0, 1, 2, 3, 4, 5, -1, 6, 7, 8, -1, -1, 9, 10, -1}; >- map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; >- doTest1("testFullToLean #35 - ", "35ABC@@DE@@@GH@", "35ABC@DE@GH", "35ABC@DE@GH", map1, map2, "35ABC@DE@GH", ">@35ABC@DE@GH@^", map3, map2); >- map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7}; >- map2 = new int[] {0, 1, 2, 3, 4, 5, -1, 6, 7, -1, -1, -1, -1, -1, -1}; >- map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9}; >- doTest1("testFullToLean #36 - ", "36ABC@@DE@@@@@@", "36ABC@DE", "36ABC@DE", map1, map2, "36ABC@DE", ">@36ABC@DE@^", map3, map2); >- map1 = new int[0]; >- map2 = new int[] {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; >- doTest1("testFullToLean #37 - ", ">>>@@@@@^^^", "", "", map1, map2, "", "", map1, map2); >- >- // test fullToLeanText with initial state >- type = IBidiComplexExpressionTypes.SQL; >- doTest2("testFullToLean #38 - "); >- } >-} >Index: src/org/eclipse/equinox/bidi/internal/tests/BidiComplexMathTest.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/internal/tests/BidiComplexMathTest.java >diff -N src/org/eclipse/equinox/bidi/internal/tests/BidiComplexMathTest.java >--- src/org/eclipse/equinox/bidi/internal/tests/BidiComplexMathTest.java 27 Apr 2011 14:53:08 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,46 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2010, 2011 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >- >-package org.eclipse.equinox.bidi.internal.tests; >- >-import org.eclipse.equinox.bidi.*; >- >-/** >- * Tests RTL arithmetic >- */ >-public class BidiComplexMathTest extends BidiComplexTestBase { >- >- static final BidiComplexEnvironment envLTR = new BidiComplexEnvironment(null, false, BidiComplexEnvironment.ORIENT_LTR); >- static final BidiComplexEnvironment envRTL = new BidiComplexEnvironment(null, false, BidiComplexEnvironment.ORIENT_RTL); >- >- String type = IBidiComplexExpressionTypes.RTL_ARITHMETIC; >- >- private void verifyOneLine(String msg, String data, String resLTR, String resRTL) { >- String lean = toUT16(data); >- String fullLTR = BidiComplexEngine.leanToFullText(type, null, envLTR, lean, null); >- assertEquals(msg + " LTR - ", resLTR, toPseudo(fullLTR)); >- String fullRTL = BidiComplexEngine.leanToFullText(type, null, envRTL, lean, null); >- assertEquals(msg + " RTL - ", resRTL, toPseudo(fullRTL)); >- } >- >- public void testRTLarithmetic() { >- verifyOneLine("Math #0", "", "", ""); >- verifyOneLine("Math #1", "1+abc", "<&1+abc&^", "1+abc"); >- verifyOneLine("Math #2", "2+abc-def", "<&2+abc&-def&^", "2+abc&-def"); >- verifyOneLine("Math #3", "a+3*bc/def", "<&a&+3*bc&/def&^", "a&+3*bc&/def"); >- verifyOneLine("Math #4", "4+abc/def", "<&4+abc&/def&^", "4+abc&/def"); >- verifyOneLine("Math #5", "13ABC", "<&13ABC&^", "13ABC"); >- verifyOneLine("Math #6", "14ABC-DE", "<&14ABC-DE&^", "14ABC-DE"); >- verifyOneLine("Math #7", "15ABC+DE", "<&15ABC+DE&^", "15ABC+DE"); >- verifyOneLine("Math #8", "16ABC*DE", "<&16ABC*DE&^", "16ABC*DE"); >- verifyOneLine("Math #9", "17ABC/DE", "<&17ABC/DE&^", "17ABC/DE"); >- } >-} >Index: src/org/eclipse/equinox/bidi/internal/tests/BidiComplexMethodsTest.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/internal/tests/BidiComplexMethodsTest.java >diff -N src/org/eclipse/equinox/bidi/internal/tests/BidiComplexMethodsTest.java >--- src/org/eclipse/equinox/bidi/internal/tests/BidiComplexMethodsTest.java 17 May 2011 19:56:16 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,315 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2010, 2011 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >- >-package org.eclipse.equinox.bidi.internal.tests; >- >-import org.eclipse.equinox.bidi.*; >-import org.eclipse.equinox.bidi.custom.*; >- >-/** >- * Tests most public methods of BidiComplexEngine >- */ >- >-public class BidiComplexMethodsTest extends BidiComplexTestBase { >- >- final static int LTR = BidiComplexFeatures.DIR_LTR; >- final static int RTL = BidiComplexFeatures.DIR_RTL; >- final static BidiComplexEnvironment envLTR = new BidiComplexEnvironment(null, false, BidiComplexEnvironment.ORIENT_LTR); >- final static BidiComplexEnvironment envRTL = new BidiComplexEnvironment(null, false, BidiComplexEnvironment.ORIENT_RTL); >- final static BidiComplexEnvironment envRTLMIR = new BidiComplexEnvironment(null, true, BidiComplexEnvironment.ORIENT_RTL); >- final static BidiComplexEnvironment envIGN = new BidiComplexEnvironment(null, false, BidiComplexEnvironment.ORIENT_IGNORE); >- final static BidiComplexEnvironment envCLR = new BidiComplexEnvironment(null, false, BidiComplexEnvironment.ORIENT_CONTEXTUAL_LTR); >- final static BidiComplexEnvironment envCRL = new BidiComplexEnvironment(null, false, BidiComplexEnvironment.ORIENT_CONTEXTUAL_RTL); >- final static BidiComplexEnvironment envERR = new BidiComplexEnvironment(null, false, 9999); >- >- private void doTestTools() { >- >- // This method tests utility methods used by the JUnits >- String data = "56789ABCDEFGHIJKLMNOPQRSTUVWXYZ~#@&><^|`"; >- String text = toUT16(data); >- String dat2 = toPseudo(text); >- assertEquals(data, dat2); >- >- text = toPseudo(data); >- assertEquals("56789abcdefghijklmnopqrstuvwxyz~#@&><^|`", text); >- >- text = array_display(null); >- assertEquals("null", text); >- } >- >- private void doTestState() { >- String data, lean, full, model; >- int[] state = new int[1]; >- state[0] = -1; >- String type = IBidiComplexExpressionTypes.JAVA; >- data = "A=B+C;/* D=E+F;"; >- lean = toUT16(data); >- full = BidiComplexEngine.leanToFullText(type, null, null, lean, state); >- model = "A@=B@+C@;/* D=E+F;"; >- assertEquals("full1", model, toPseudo(full)); >- data = "A=B+C; D=E+F;"; >- lean = toUT16(data); >- full = BidiComplexEngine.leanToFullText(type, null, null, lean, state); >- model = "A=B+C; D=E+F;"; >- assertEquals("full2", model, toPseudo(full)); >- data = "A=B+C;*/ D=E+F;"; >- lean = toUT16(data); >- full = BidiComplexEngine.leanToFullText(type, null, null, lean, state); >- model = "A=B+C;@*/ D@=E@+F;"; >- assertEquals("full3", model, toPseudo(full)); >- } >- >- private void doTestOrientation() { >- int orient; >- orient = BidiComplexEnvironment.DEFAULT.getOrientation(); >- assertEquals("orient #1", BidiComplexEnvironment.ORIENT_LTR, orient); >- >- orient = envIGN.getOrientation(); >- assertEquals("orient #2", BidiComplexEnvironment.ORIENT_IGNORE, orient); >- >- orient = envCRL.getOrientation(); >- assertEquals("orient #3", BidiComplexEnvironment.ORIENT_CONTEXTUAL_RTL, orient); >- >- orient = envERR.getOrientation(); >- assertEquals("orient #4", BidiComplexEnvironment.ORIENT_UNKNOWN, orient); >- } >- >- private void doTestOrient(BidiComplexFeatures f, String label, String data, String resLTR, String resRTL, String resCon) { >- String full, lean; >- String type = IBidiComplexExpressionTypes.COMMA_DELIMITED; >- >- lean = toUT16(data); >- full = BidiComplexEngine.leanToFullText(type, f, envLTR, lean, null); >- assertEquals(label + "LTR full", resLTR, toPseudo(full)); >- full = BidiComplexEngine.leanToFullText(type, f, envRTL, lean, null); >- assertEquals("label + RTL full", resRTL, toPseudo(full)); >- full = BidiComplexEngine.leanToFullText(type, f, envCRL, lean, null); >- assertEquals(label + "CON full", resCon, toPseudo(full)); >- } >- >- private void doTestScripts(BidiComplexFeatures f1) { >- BidiComplexFeatures f2; >- boolean flag; >- flag = f1.getIgnoreArabic(); >- assertFalse("Ignores Arabic 1", flag); >- flag = f1.getIgnoreHebrew(); >- assertFalse("Ignores Hebrew 1", flag); >- >- f2 = new BidiComplexFeatures(f1.getSeparators(), 0, -1, -1, true, true); >- flag = f2.getIgnoreArabic(); >- assertTrue("Ignores Arabic 2", flag); >- flag = f2.getIgnoreHebrew(); >- assertTrue("Ignores Hebrew 2", flag); >- doTestOrient(f2, "Scripts #1 ", "BCD,EF", "BCD,EF", ">@BCD,EF@^", "@BCD,EF"); >- f2 = new BidiComplexFeatures(f1.getSeparators(), 0, -1, -1, false, true); >- flag = f2.getIgnoreArabic(); >- assertFalse("Ignores Arabic 3", flag); >- flag = f2.getIgnoreHebrew(); >- assertTrue("Ignores Hebrew 3", flag); >- doTestOrient(f2, "Scripts #2 ", "d,EF", "d,EF", ">@d,EF@^", "d,EF"); >- doTestOrient(f2, "Scripts #3 ", "#,eF", "#,eF", ">@#,eF@^", "@#,eF"); >- doTestOrient(f2, "Scripts #4 ", "#,12", "#@,12", ">@#@,12@^", "@#@,12"); >- doTestOrient(f2, "Scripts #5 ", "#,##", "#@,##", ">@#@,##@^", "@#@,##"); >- doTestOrient(f2, "Scripts #6 ", "#,89", "#@,89", ">@#@,89@^", "@#@,89"); >- doTestOrient(f2, "Scripts #7 ", "#,ef", "#,ef", ">@#,ef@^", "@#,ef"); >- doTestOrient(f2, "Scripts #8 ", "#,", "#,", ">@#,@^", "@#,"); >- doTestOrient(f2, "Scripts #9 ", "9,ef", "9,ef", ">@9,ef@^", "9,ef"); >- doTestOrient(f2, "Scripts #10 ", "9,##", "9@,##", ">@9@,##@^", "9@,##"); >- doTestOrient(f2, "Scripts #11 ", "7,89", "7@,89", ">@7@,89@^", "7@,89"); >- doTestOrient(f2, "Scripts #12 ", "7,EF", "7,EF", ">@7,EF@^", "@7,EF"); >- doTestOrient(f2, "Scripts #13 ", "BCD,EF", "BCD,EF", ">@BCD,EF@^", "@BCD,EF"); >- >- f2 = new BidiComplexFeatures(f1.getSeparators(), 0, -1, -1, true, false); >- flag = f2.getIgnoreArabic(); >- assertTrue("Ignores Arabic 4", flag); >- flag = f2.getIgnoreHebrew(); >- assertFalse("Ignores Hebrew 4", flag); >- doTestOrient(f2, "Scripts #14 ", "BCd,EF", "BCd,EF", ">@BCd,EF@^", "@BCd,EF"); >- doTestOrient(f2, "Scripts #15 ", "BCD,eF", "BCD,eF", ">@BCD,eF@^", "@BCD,eF"); >- doTestOrient(f2, "Scripts #16 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF"); >- doTestOrient(f2, "Scripts #17 ", "BCD,12", "BCD@,12", ">@BCD@,12@^", "@BCD@,12"); >- doTestOrient(f2, "Scripts #18 ", "BCD,", "BCD,", ">@BCD,@^", "@BCD,"); >- >- f2 = new BidiComplexFeatures(f1.getSeparators(), 0, -1, -1, false, false); >- doTestOrient(f2, "Scripts #19 ", "123,45|67", "123,45|67", ">@123,45|67@^", "@123,45|67"); >- doTestOrient(f2, "Scripts #20 ", "5,e", "5,e", ">@5,e@^", "5,e"); >- doTestOrient(f2, "Scripts #21 ", "5,#", "5@,#", ">@5@,#@^", "5@,#"); >- doTestOrient(f2, "Scripts #22 ", "5,6", "5@,6", ">@5@,6@^", "5@,6"); >- doTestOrient(f2, "Scripts #23 ", "5,D", "5@,D", ">@5@,D@^", "5@,D"); >- doTestOrient(f2, "Scripts #24 ", "5,--", "5,--", ">@5,--@^", "@5,--"); >- } >- >- private void doTestLeanOffsets() { >- String lean, data, label; >- int[] state = new int[1]; >- String type = IBidiComplexExpressionTypes.JAVA; >- int[] offsets; >- int[] model; >- >- data = "A=B+C;/* D=E+F;"; >- lean = toUT16(data); >- state[0] = -1; >- offsets = BidiComplexEngine.leanBidiCharOffsets(type, null, null, lean, state); >- model = new int[] {1, 3, 5}; >- label = "leanBidiCharOffsets() #1 "; >- assertEquals(label, array_display(model), array_display(offsets)); >- data = "A=B+C;*/ D=E+F;"; >- lean = toUT16(data); >- offsets = BidiComplexEngine.leanBidiCharOffsets(type, null, null, lean, state); >- model = new int[] {6, 10, 12}; >- label = "leanBidiCharOffsets() #2 "; >- assertEquals(label, array_display(model), array_display(offsets)); >- } >- >- private void doTestFullOffsets(String label, String data, int[] resLTR, int[] resRTL, int[] resCon) { >- String full, lean, msg; >- int[] offsets; >- String type = IBidiComplexExpressionTypes.COMMA_DELIMITED; >- >- lean = toUT16(data); >- full = BidiComplexEngine.leanToFullText(type, null, envLTR, lean, null); >- offsets = BidiComplexEngine.fullBidiCharOffsets(type, null, envLTR, full, null); >- msg = label + "LTR "; >- assertEquals(msg, array_display(resLTR), array_display(offsets)); >- full = BidiComplexEngine.leanToFullText(type, null, envRTL, lean, null); >- offsets = BidiComplexEngine.fullBidiCharOffsets(type, null, envRTL, full, null); >- msg = label + "RTL "; >- assertEquals(msg, array_display(resRTL), array_display(offsets)); >- full = BidiComplexEngine.leanToFullText(type, null, envCLR, lean, null); >- offsets = BidiComplexEngine.fullBidiCharOffsets(type, null, envCLR, full, null); >- msg = label + "CON "; >- assertEquals(msg, array_display(resCon), array_display(offsets)); >- } >- >- private void doTestMirrored() { >- boolean mirrored; >- mirrored = BidiComplexEnvironment.DEFAULT.getMirrored(); >- assertFalse("mirrored #1", mirrored); >- BidiComplexEnvironment env = new BidiComplexEnvironment(null, true, BidiComplexEnvironment.ORIENT_LTR); >- mirrored = env.getMirrored(); >- assertTrue("mirrored #2", mirrored); >- } >- >- private void doTestDirection() { >- String data, lean, full, model, msg; >- IBidiComplexProcessor processor = BidiComplexStringProcessor.getProcessor(IBidiComplexExpressionTypes.COMMA_DELIMITED); >- BidiComplexFeatures f1 = processor.getFeatures(null); >- msg = "TestDirection #1"; >- assertTrue(msg, f1.getDirArabic() == LTR && f1.getDirHebrew() == LTR); >- >- BidiComplexFeatures f2 = new BidiComplexFeatures(f1.getSeparators(), 0, RTL, RTL, false, false); >- f1 = f2; >- msg = "TestDirection #2"; >- assertTrue(msg, f1.getDirArabic() == RTL && f1.getDirHebrew() == RTL); >- >- BidiComplexEnvironment environment = new BidiComplexEnvironment(null, false, BidiComplexEnvironment.ORIENT_LTR); >- processor = BidiComplexStringProcessor.getProcessor(IBidiComplexExpressionTypes.EMAIL); >- f1 = processor.getFeatures(environment); >- msg = "TestDirection #3"; >- assertTrue(msg, f1.getDirArabic() == LTR && f1.getDirHebrew() == LTR); >- data = "#ABC.#DEF:HOST.com"; >- lean = toUT16(data); >- full = BidiComplexEngine.leanToFullText(processor, null, environment, lean, null); >- model = "#ABC@.#DEF@:HOST.com"; >- assertEquals("TestDirection #9 full", model, toPseudo(full)); >- >- data = "ABC.DEF:HOST.com"; >- lean = toUT16(data); >- full = BidiComplexEngine.leanToFullText(processor, null, environment, lean, null); >- model = "ABC@.DEF@:HOST.com"; >- assertEquals("TestDirection #10 full", model, toPseudo(full)); >- >- environment = new BidiComplexEnvironment(null, true, BidiComplexEnvironment.ORIENT_LTR); >- f1 = processor.getFeatures(environment); >- msg = "TestDirection #10.5"; >- assertTrue(msg, f1.getDirArabic() == RTL && f1.getDirHebrew() == LTR); >- data = "#ABC.#DEF:HOST.com"; >- lean = toUT16(data); >- full = BidiComplexEngine.leanToFullText(processor, null, environment, lean, null); >- model = "<&#ABC.#DEF:HOST.com&^"; >- assertEquals("TestDirection #11 full", model, toPseudo(full)); >- >- data = "#ABc.#DEF:HOSt.COM"; >- lean = toUT16(data); >- full = BidiComplexEngine.leanToFullText(processor, null, environment, lean, null); >- model = "<&#ABc.#DEF:HOSt.COM&^"; >- assertEquals("TestDirection #12 full", model, toPseudo(full)); >- >- data = "#ABc.#DEF:HOSt."; >- lean = toUT16(data); >- full = BidiComplexEngine.leanToFullText(processor, null, environment, lean, null); >- model = "<&#ABc.#DEF:HOSt.&^"; >- assertEquals("TestDirection #13 full", model, toPseudo(full)); >- >- data = "ABC.DEF:HOST.com"; >- lean = toUT16(data); >- full = BidiComplexEngine.leanToFullText(processor, null, environment, lean, null); >- model = "ABC@.DEF@:HOST.com"; >- assertEquals("TestDirection #14 full", model, toPseudo(full)); >- >- data = "--.---:----"; >- lean = toUT16(data); >- full = BidiComplexEngine.leanToFullText(processor, null, environment, lean, null); >- model = "--.---:----"; >- assertEquals("TestDirection #15 full", model, toPseudo(full)); >- >- data = "ABC.|DEF:HOST.com"; >- lean = toUT16(data); >- full = BidiComplexEngine.leanToFullText(processor, null, environment, lean, null); >- model = "ABC.|DEF@:HOST.com"; >- assertEquals("TestDirection #16 full", model, toPseudo(full)); >- >- data = "#ABc.|#DEF:HOST.com"; >- lean = toUT16(data); >- full = BidiComplexEngine.leanToFullText(processor, null, envRTLMIR, lean, null); >- model = "#ABc.|#DEF:HOST.com"; >- assertEquals("TestDirection #17 full", model, toPseudo(full)); >- assertEquals("Test curDirection", RTL, BidiComplexEngine.getCurDirection(processor, null, envRTLMIR, lean)); >- } >- >- public void testMethods() { >- >- doTestTools(); >- >- doTestState(); >- >- doTestOrientation(); >- >- IBidiComplexProcessor processor = BidiComplexStringProcessor.getProcessor(IBidiComplexExpressionTypes.COMMA_DELIMITED); >- BidiComplexFeatures f = processor.getFeatures(null); >- doTestOrient(f, "Methods #1 ", "", "", "", ""); >- doTestOrient(f, "Methods #2 ", "abc", "abc", ">@abc@^", "abc"); >- doTestOrient(f, "Methods #3 ", "ABC", "ABC", ">@ABC@^", "@ABC"); >- doTestOrient(f, "Methods #4 ", "bcd,ef", "bcd,ef", ">@bcd,ef@^", "bcd,ef"); >- doTestOrient(f, "Methods #5 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF"); >- doTestOrient(f, "Methods #6 ", "cde,FG", "cde,FG", ">@cde,FG@^", "cde,FG"); >- doTestOrient(f, "Methods #7 ", "CDE,fg", "CDE,fg", ">@CDE,fg@^", "@CDE,fg"); >- doTestOrient(f, "Methods #8 ", "12..def,GH", "12..def,GH", ">@12..def,GH@^", "12..def,GH"); >- doTestOrient(f, "Methods #9 ", "34..DEF,gh", "34..DEF,gh", ">@34..DEF,gh@^", "@34..DEF,gh"); >- >- doTestScripts(f); >- >- doTestLeanOffsets(); >- >- doTestFullOffsets("TestFullOffsets ", "BCD,EF,G", new int[] {3, 7}, new int[] {0, 1, 5, 9, 12, 13}, new int[] {0, 4, 8}); >- >- doTestMirrored(); >- >- doTestDirection(); >- >- String type = IBidiComplexExpressionTypes.COMMA_DELIMITED; >- String data = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"; >- String lean = toUT16(data); >- String full = BidiComplexEngine.leanToFullText(type, null, null, lean, null); >- String model = "A@,B@,C@,D@,E@,F@,G@,H@,I@,J@,K@,L@,M@,N@,O@,P@,Q@,R@,S@,T@,U@,V@,W@,X@,Y@,Z"; >- assertEquals("many inserts", model, toPseudo(full)); >- } >-} >Index: src/org/eclipse/equinox/bidi/internal/tests/BidiComplexNullProcessorTest.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/internal/tests/BidiComplexNullProcessorTest.java >diff -N src/org/eclipse/equinox/bidi/internal/tests/BidiComplexNullProcessorTest.java >--- src/org/eclipse/equinox/bidi/internal/tests/BidiComplexNullProcessorTest.java 27 Apr 2011 14:53:08 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,47 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2010, 2011 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >- >-package org.eclipse.equinox.bidi.internal.tests; >- >-import org.eclipse.equinox.bidi.BidiComplexEngine; >-import org.eclipse.equinox.bidi.custom.BidiComplexFeatures; >- >-/** >- * Tests RTL arithmetic >- */ >-public class BidiComplexNullProcessorTest extends BidiComplexTestBase { >- >- static final int[] EMPTY_INT_ARRAY = new int[0]; >- >- public void testNullProcessor() { >- String full = BidiComplexEngine.leanToFullText(null, null, null, "abc", null); >- assertEquals("leanToFullText", "abc", full); >- int[] state = new int[1]; >- state[0] = 3; >- full = BidiComplexEngine.leanToFullText(null, null, null, "abc", state); >- assertEquals("leanToFullText with state", "abc", full); >- int[] offsets = BidiComplexEngine.leanBidiCharOffsets(null, null, null, "abc", null); >- assertEquals("leanBidiCharOffsets", 0, offsets.length); >- offsets = BidiComplexEngine.fullBidiCharOffsets(null, null, null, "abc", null); >- assertEquals("fullBidiCharOffsets", 0, offsets.length); >- String lean = BidiComplexEngine.fullToLeanText(null, null, null, "abc", null); >- assertEquals("fullToLeanText", "abc", lean); >- lean = BidiComplexEngine.fullToLeanText(null, null, null, "abc", state); >- assertEquals("fullToLeanText with state", "abc", lean); >- int[] map = BidiComplexEngine.leanToFullMap(null, null, null, "abc", null); >- int[] model = {0, 1, 2}; >- assertEquals("leanToFullMap", array_display(model), array_display(map)); >- map = BidiComplexEngine.fullToLeanMap(null, null, null, "abc", null); >- assertEquals("fullToLeanMap", array_display(model), array_display(map)); >- int direction = BidiComplexEngine.getCurDirection(null, null, null, "abc"); >- assertEquals("getCurDirection", BidiComplexFeatures.DIR_LTR, direction); >- } >-} >Index: src/org/eclipse/equinox/bidi/internal/tests/BidiComplexSomeMoreTest.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/internal/tests/BidiComplexSomeMoreTest.java >diff -N src/org/eclipse/equinox/bidi/internal/tests/BidiComplexSomeMoreTest.java >--- src/org/eclipse/equinox/bidi/internal/tests/BidiComplexSomeMoreTest.java 17 May 2011 19:56:16 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,93 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2010, 2011 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >- >-package org.eclipse.equinox.bidi.internal.tests; >- >-import org.eclipse.equinox.bidi.BidiComplexEngine; >-import org.eclipse.equinox.bidi.BidiComplexEnvironment; >-import org.eclipse.equinox.bidi.custom.*; >- >-/** >- * Tests some weird cases >- */ >- >-public class BidiComplexSomeMoreTest extends BidiComplexTestBase { >- >- final static BidiComplexEnvironment env1 = new BidiComplexEnvironment("en_US", false, BidiComplexEnvironment.ORIENT_LTR); >- final static BidiComplexEnvironment env2 = new BidiComplexEnvironment("he", false, BidiComplexEnvironment.ORIENT_LTR); >- final static BidiComplexFeatures myFeatures = new BidiComplexFeatures(null, 1, -1, -1, false, false); >- >- class Processor1 extends BidiComplexProcessor { >- >- public BidiComplexFeatures getFeatures(BidiComplexEnvironment env) { >- return myFeatures; >- } >- >- public int indexOfSpecial(BidiComplexFeatures features, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex) { >- return fromIndex; >- } >- >- public int processSpecial(BidiComplexFeatures features, String text, byte[] dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) { >- int len = text.length(); >- for (int i = len - 1; i >= 0; i--) { >- BidiComplexProcessor.insertMark(text, dirProps, offsets, i); >- BidiComplexProcessor.insertMark(text, dirProps, offsets, i); >- } >- return len; >- } >- } >- >- class Processor2 extends BidiComplexProcessor { >- >- public BidiComplexFeatures getFeatures(BidiComplexEnvironment env) { >- return myFeatures; >- } >- } >- >- class Processor3 extends BidiComplexProcessor { >- >- public BidiComplexFeatures getFeatures(BidiComplexEnvironment env) { >- return myFeatures; >- } >- >- public int indexOfSpecial(BidiComplexFeatures features, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex) { >- return 0; >- } >- } >- >- public void testSomeMore() { >- assertFalse(env1.isBidi()); >- assertTrue(env2.isBidi()); >- >- IBidiComplexProcessor processor = new Processor1(); >- String full = BidiComplexEngine.leanToFullText(processor, null, env1, "abcd", null); >- assertEquals("@a@b@c@d", toPseudo(full)); >- >- processor = new Processor2(); >- boolean catchFlag = false; >- try { >- full = BidiComplexEngine.leanToFullText(processor, null, env1, "abcd", null); >- } catch (IllegalStateException e) { >- catchFlag = true; >- } >- assertTrue("Catch missing indexOfSpecial", catchFlag); >- >- processor = new Processor3(); >- catchFlag = false; >- try { >- full = BidiComplexEngine.leanToFullText(processor, null, env1, "abcd", null); >- } catch (IllegalStateException e) { >- catchFlag = true; >- } >- assertTrue("Catch missing processSpecial", catchFlag); >- } >- >-} >Index: src/org/eclipse/equinox/bidi/internal/tests/BidiComplexStringRecordTest.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/internal/tests/BidiComplexStringRecordTest.java >diff -N src/org/eclipse/equinox/bidi/internal/tests/BidiComplexStringRecordTest.java >--- src/org/eclipse/equinox/bidi/internal/tests/BidiComplexStringRecordTest.java 27 Apr 2011 14:53:08 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,119 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2010, 2011 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >- >-package org.eclipse.equinox.bidi.internal.tests; >- >-import org.eclipse.equinox.bidi.BidiComplexStringRecord; >-import org.eclipse.equinox.bidi.custom.BidiComplexStringProcessor; >- >-/** >- * Tests the StringRecord class >- */ >-public class BidiComplexStringRecordTest extends BidiComplexTestBase { >- public void testStringRecord() { >- BidiComplexStringRecord sr; >- boolean catchFlag; >- short[] badTriplet1 = new short[] {0, 0}; >- short[] badTriplet2 = new short[] {0, 0, -1}; >- short[] badTriplet3 = new short[] {0, 0, 999}; >- short[] goodTriplet = new short[] {0, 3, 2}; >- short[] triplets; >- short type; >- String strType; >- // check handling of invalid arguments >- catchFlag = false; >- try { >- sr = new BidiComplexStringRecord(null, badTriplet1); >- } catch (IllegalArgumentException e) { >- catchFlag = true; >- } >- assertTrue("Catch null string argument", catchFlag); >- catchFlag = false; >- try { >- sr = new BidiComplexStringRecord("xxx", null); >- } catch (IllegalArgumentException e) { >- catchFlag = true; >- } >- assertTrue("Catch null triplets argument", catchFlag); >- catchFlag = false; >- try { >- sr = new BidiComplexStringRecord("xxx", badTriplet1); >- } catch (IllegalArgumentException e) { >- catchFlag = true; >- } >- assertTrue("Catch bad triplet #1 argument", catchFlag); >- catchFlag = false; >- try { >- sr = new BidiComplexStringRecord("xxx", badTriplet2); >- } catch (IllegalArgumentException e) { >- catchFlag = true; >- } >- assertTrue("Catch bad triplet #2 argument", catchFlag); >- catchFlag = false; >- try { >- sr = new BidiComplexStringRecord("xxx", badTriplet3); >- } catch (IllegalArgumentException e) { >- catchFlag = true; >- } >- assertTrue("Catch bad triplet #3 argument", catchFlag); >- >- String[] types = BidiComplexStringProcessor.getKnownTypes(); >- for (int i = 0; i < types.length; i++) { >- type = BidiComplexStringRecord.typeStringToShort(types[i]); >- assertFalse(type == -1); >- strType = BidiComplexStringRecord.typeShortToString(type); >- assertEquals(types[i], strType); >- } >- type = BidiComplexStringRecord.typeStringToShort("dummy"); >- assertEquals(-1, type); >- strType = BidiComplexStringRecord.typeShortToString((short) 999); >- assertEquals(null, strType); >- int poolSize = BidiComplexStringRecord.POOLSIZE; >- int lim = poolSize / 2; >- triplets = BidiComplexStringRecord.getTriplets("xxx"); >- assertEquals(null, triplets); >- for (int i = 0; i < lim; i++) { >- String str = Integer.toString(i); >- sr = new BidiComplexStringRecord(str, goodTriplet); >- BidiComplexStringRecord.add(sr); >- } >- triplets = BidiComplexStringRecord.getTriplets(null); >- assertEquals(null, triplets); >- triplets = BidiComplexStringRecord.getTriplets(""); >- assertEquals(null, triplets); >- for (int i = 0; i < poolSize; i++) { >- String str = Integer.toString(i); >- triplets = BidiComplexStringRecord.getTriplets(str); >- if (i < lim) >- assertFalse(null == triplets); >- else >- assertTrue(null == triplets); >- } >- for (int i = lim; i <= poolSize; i++) { >- String str = Integer.toString(i); >- sr = new BidiComplexStringRecord(str, goodTriplet); >- BidiComplexStringRecord.add(sr); >- } >- for (int i = 1; i <= poolSize; i++) { >- String str = Integer.toString(i); >- triplets = BidiComplexStringRecord.getTriplets(str); >- assertFalse(null == triplets); >- } >- triplets = BidiComplexStringRecord.getTriplets("0"); >- assertEquals(null, triplets); >- BidiComplexStringRecord.clear(); >- for (int i = 0; i <= poolSize; i++) { >- String str = Integer.toString(i); >- triplets = BidiComplexStringRecord.getTriplets(str); >- assertEquals(null, triplets); >- } >- } >-} >Index: src/org/eclipse/equinox/bidi/internal/tests/BidiComplexTest.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/internal/tests/BidiComplexTest.java >diff -N src/org/eclipse/equinox/bidi/internal/tests/BidiComplexTest.java >--- src/org/eclipse/equinox/bidi/internal/tests/BidiComplexTest.java 17 May 2011 19:56:16 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,33 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2010, 2011 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >-package org.eclipse.equinox.bidi.internal.tests; >- >-import org.eclipse.equinox.bidi.BidiComplexEnvironment; >-import org.eclipse.equinox.bidi.custom.BidiComplexFeatures; >-import org.eclipse.equinox.bidi.custom.IBidiComplexProcessor; >- >-public class BidiComplexTest implements IBidiComplexProcessor { >- >- static final BidiComplexFeatures FEATURES = new BidiComplexFeatures("-=.:", 0, -1, -1, false, false); >- >- public BidiComplexFeatures getFeatures(BidiComplexEnvironment env) { >- return FEATURES; >- } >- >- public int indexOfSpecial(BidiComplexFeatures features, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex) { >- throw new IllegalStateException(); >- } >- >- public int processSpecial(BidiComplexFeatures features, String text, byte[] dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) { >- throw new IllegalStateException(); >- } >- >-} >Index: src/org/eclipse/equinox/bidi/internal/tests/BidiComplexTestBase.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/internal/tests/BidiComplexTestBase.java >diff -N src/org/eclipse/equinox/bidi/internal/tests/BidiComplexTestBase.java >--- src/org/eclipse/equinox/bidi/internal/tests/BidiComplexTestBase.java 27 Apr 2011 14:53:08 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,110 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2010, 2011 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >- >-package org.eclipse.equinox.bidi.internal.tests; >- >-import junit.framework.TestCase; >- >-/** >- * Base functionality for the processor tests. >- */ >-public class BidiComplexTestBase extends TestCase { >- >- static final private char LRM = 0x200E; >- >- static final private char RLM = 0x200F; >- >- static final private char LRE = 0x202A; >- >- static final private char RLE = 0x202B; >- >- static final private char PDF = 0x202C; >- >- public static String toPseudo(String text) { >- char[] chars = text.toCharArray(); >- int len = chars.length; >- >- for (int i = 0; i < len; i++) { >- char c = chars[i]; >- if (c >= 'A' && c <= 'Z') >- chars[i] = (char) (c + 'a' - 'A'); >- else if (c >= 0x05D0 && c < 0x05EA) >- chars[i] = (char) (c + 'A' - 0x05D0); >- else if (c == 0x05EA) >- chars[i] = '~'; >- else if (c == 0x0644) >- chars[i] = '#'; >- else if (c >= 0x0665 && c <= 0x0669) >- chars[i] = (char) (c + '5' - 0x0665); >- else if (c == LRM) >- chars[i] = '@'; >- else if (c == RLM) >- chars[i] = '&'; >- else if (c == LRE) >- chars[i] = '>'; >- else if (c == RLE) >- chars[i] = '<'; >- else if (c == PDF) >- chars[i] = '^'; >- else if (c == '\n') >- chars[i] = '|'; >- else if (c == '\r') >- chars[i] = '`'; >- } >- return new String(chars); >- } >- >- public static String toUT16(String text) { >- char[] chars = text.toCharArray(); >- int len = chars.length; >- >- for (int i = 0; i < len; i++) { >- char c = chars[i]; >- if (c >= '5' && c <= '9') >- chars[i] = (char) (0x0665 + c - '5'); >- else if (c >= 'A' && c <= 'Z') >- chars[i] = (char) (0x05D0 + c - 'A'); >- else if (c == '~') >- chars[i] = (char) (0x05EA); >- else if (c == '#') >- chars[i] = (char) (0x0644); >- else if (c == '@') >- chars[i] = LRM; >- else if (c == '&') >- chars[i] = RLM; >- else if (c == '>') >- chars[i] = LRE; >- else if (c == '<') >- chars[i] = RLE; >- else if (c == '^') >- chars[i] = PDF; >- else if (c == '|') >- chars[i] = '\n'; >- else if (c == '`') >- chars[i] = '\r'; >- } >- return new String(chars); >- } >- >- static String array_display(int[] array) { >- if (array == null) { >- return "null"; >- } >- StringBuffer sb = new StringBuffer(50); >- int len = array.length; >- for (int i = 0; i < len; i++) { >- sb.append(array[i]); >- sb.append(' '); >- } >- return sb.toString(); >- } >- >-} >Index: src/org/eclipse/equinox/bidi/internal/tests/BidiComplexUtilTest.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/internal/tests/BidiComplexUtilTest.java >diff -N src/org/eclipse/equinox/bidi/internal/tests/BidiComplexUtilTest.java >--- src/org/eclipse/equinox/bidi/internal/tests/BidiComplexUtilTest.java 9 Feb 2011 21:28:56 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,138 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2010, 2011 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >- >-package org.eclipse.equinox.bidi.internal.tests; >- >-import java.util.Locale; >-import org.eclipse.equinox.bidi.BidiComplexUtil; >-import org.eclipse.equinox.bidi.IBidiComplexExpressionTypes; >- >-/** >- * Tests methods in BidiComplexUtil >- */ >- >-public class BidiComplexUtilTest extends BidiComplexTestBase { >- >- private static final String HEBREW = "iw"; >- >- private static final String HEBREW2 = "he"; >- >- private static final String ARABIC = "ar"; >- >- private static final String FARSI = "fa"; >- >- private static final String URDU = "ur"; >- >- private Locale locale; >- >- protected void setUp() throws Exception { >- super.setUp(); >- locale = Locale.getDefault(); >- } >- >- protected void tearDown() { >- Locale.setDefault(locale); >- } >- >- private void doTest1(String data, String result) { >- Locale.setDefault(Locale.ENGLISH); >- String full = BidiComplexUtil.process(toUT16(data)); >- assertEquals("Util #1 full EN - ", data, toPseudo(full)); >- Locale.setDefault(new Locale(HEBREW2)); >- full = BidiComplexUtil.process(toUT16(data)); >- assertEquals("Util #1 full HE - ", result, toPseudo(full)); >- Locale.setDefault(new Locale(ARABIC)); >- full = BidiComplexUtil.process(toUT16(data)); >- assertEquals("Util #1 full AR - ", result, toPseudo(full)); >- Locale.setDefault(new Locale(FARSI)); >- full = BidiComplexUtil.process(toUT16(data)); >- assertEquals("Util #1 full FA - ", result, toPseudo(full)); >- Locale.setDefault(new Locale(URDU)); >- full = BidiComplexUtil.process(toUT16(data)); >- assertEquals("Util #1 full UR - ", result, toPseudo(full)); >- Locale.setDefault(new Locale(HEBREW)); >- full = BidiComplexUtil.process(toUT16(data)); >- String ful2 = BidiComplexUtil.process(toUT16(data), null); >- assertEquals("Util #1 full - ", result, toPseudo(full)); >- assertEquals("Util #1 ful2 - ", result, toPseudo(ful2)); >- String lean = BidiComplexUtil.deprocess(full); >- assertEquals("Util #1 lean - ", data, toPseudo(lean)); >- } >- >- private void doTest2(String msg, String data, String result) { >- doTest2(msg, data, result, data); >- } >- >- private void doTest2(String msg, String data, String result, String resLean) { >- String full = BidiComplexUtil.process(toUT16(data), "*"); >- assertEquals(msg + "full", result, toPseudo(full)); >- String lean = BidiComplexUtil.deprocess(full); >- assertEquals(msg + "lean", resLean, toPseudo(lean)); >- } >- >- private void doTest3(String msg, String data, String result) { >- doTest3(msg, data, result, data); >- } >- >- private void doTest3(String msg, String data, String result, String resLean) { >- String full = BidiComplexUtil.processTyped(toUT16(data), IBidiComplexExpressionTypes.COMMA_DELIMITED); >- assertEquals(msg + "full", result, toPseudo(full)); >- String lean = BidiComplexUtil.deprocess(full, IBidiComplexExpressionTypes.COMMA_DELIMITED); >- assertEquals(msg + "lean", resLean, toPseudo(lean)); >- } >- >- private void doTest4(String msg, String data, int[] offsets, int direction, boolean affix, String result) { >- String txt = msg + "text=" + data + "\n offsets=" + array_display(offsets) + "\n direction=" + direction + "\n affix=" + affix; >- String lean = toUT16(data); >- String full = BidiComplexUtil.insertMarks(lean, offsets, direction, affix); >- assertEquals(txt, result, toPseudo(full)); >- } >- >- public void testBidiComplexUtil() { >- >- // Test process() and deprocess() with default delimiters >- doTest1("ABC/DEF/G", ">@ABC@/DEF@/G@^"); >- // Test process() and deprocess() with specified delimiters >- doTest2("Util #2.1 - ", "", ""); >- doTest2("Util #2.2 - ", ">@ABC@^", ">@ABC@^", "ABC"); >- doTest2("Util #2.3 - ", "abc", "abc"); >- doTest2("Util #2.4 - ", "!abc", ">@!abc@^"); >- doTest2("Util #2.5 - ", "abc!", ">@abc!@^"); >- doTest2("Util #2.6 - ", "ABC*DEF*G", ">@ABC@*DEF@*G@^"); >- // Test process() and deprocess() with specified expression type >- doTest3("Util #3.1 - ", "ABC,DEF,G", ">@ABC@,DEF@,G@^"); >- doTest3("Util #3.2 - ", "", ""); >- doTest3("Util #3.3 - ", ">@DEF@^", ">@DEF@^", "DEF"); >- boolean catchFlag = false; >- try { >- BidiComplexUtil.deprocess(toUT16("ABC,DE"), "wrong_type"); >- } catch (IllegalArgumentException e) { >- catchFlag = true; >- } >- assertTrue("Catch invalid type on deprocess", catchFlag); >- catchFlag = false; >- try { >- BidiComplexUtil.processTyped("abc", "wrong_type"); >- } catch (IllegalArgumentException e) { >- catchFlag = true; >- } >- assertTrue("Catch invalid type on process", catchFlag); >- // Test insertMarks() >- doTest4("Util #4.1 - ", "ABCDEFG", new int[] {3, 6}, 0, false, "ABC@DEF@G"); >- doTest4("Util #4.2 - ", "ABCDEFG", new int[] {3, 6}, 0, true, ">@ABC@DEF@G@^"); >- doTest4("Util #4.3 - ", "ABCDEFG", new int[] {3, 6}, 1, false, "ABC&DEF&G"); >- doTest4("Util #4.4 - ", "ABCDEFG", new int[] {3, 6}, 1, true, "<&ABC&DEF&G&^"); >- doTest4("Util #4.5 - ", "", new int[] {3, 6}, 0, false, ""); >- doTest4("Util #4.6 - ", "", new int[] {3, 6}, 0, true, ""); >- doTest4("Util #4.7 - ", "ABCDEFG", null, 1, false, "ABCDEFG"); >- doTest4("Util #4.8 - ", "ABCDEFG", null, 1, true, "<&ABCDEFG&^"); >- } >-} >Index: src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java >diff -N src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,64 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.equinox.bidi.internal.tests; >+ >+import org.eclipse.equinox.bidi.STextEngine; >+import org.eclipse.equinox.bidi.custom.STextStringProcessor; >+import org.eclipse.equinox.bidi.custom.ISTextProcessor; >+ >+/** >+ * Tests contribution of BiDi processors. >+ */ >+public class STextExtensibilityTest extends STextTestBase { >+ >+ public void testBaseContributions() { >+ String[] types = STextStringProcessor.getKnownTypes(); >+ assertNotNull(types); >+ assertTrue(types.length > 0); >+ >+ // check one of the types that we know should be there >+ assertTrue(isTypePresent(types, "regex")); >+ >+ ISTextProcessor processor = STextStringProcessor.getProcessor("regex"); >+ assertNotNull(processor); >+ } >+ >+ public void testOtherContributions() { >+ String[] types = STextStringProcessor.getKnownTypes(); >+ assertNotNull(types); >+ assertTrue(types.length > 0); >+ >+ // check the type added by the test bundle >+ assertTrue(isTypePresent(types, "test")); >+ >+ ISTextProcessor processor = STextStringProcessor.getProcessor("test"); >+ assertNotNull(processor); >+ >+ processor = STextStringProcessor.getProcessor("badtest"); >+ assertNull(processor); >+ >+ String data, lean, full, model; >+ data = "ABC.DEF:HOST-COM=HELLO"; >+ lean = toUT16(data); >+ full = STextEngine.leanToFullText("test", null, null, lean, null); >+ model = "ABC@.DEF@:HOST@-COM@=HELLO"; >+ assertEquals("Test 'test' plugin", model, toPseudo(full)); >+ } >+ >+ private boolean isTypePresent(String[] types, String type) { >+ for (int i = 0; i < types.length; i++) { >+ if (type.equalsIgnoreCase(types[i])) >+ return true; >+ } >+ return false; >+ } >+} >Index: src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java >diff -N src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,182 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.equinox.bidi.internal.tests; >+ >+import org.eclipse.equinox.bidi.STextEngine; >+import org.eclipse.equinox.bidi.ISTextTypes; >+import org.eclipse.equinox.bidi.custom.*; >+ >+/** >+ * Tests all plug-in extensions >+ */ >+ >+public class STextExtensionsTest extends STextTestBase { >+ >+ ISTextProcessor processor; >+ STextFeatures f1, f2; >+ int[] state = new int[1]; >+ String type; >+ >+ private void doTest1(String label, String data, String result) { >+ String full; >+ full = STextEngine.leanToFullText(type, null, null, toUT16(data), state); >+ assertEquals(label + " data = " + data, result, toPseudo(full)); >+ } >+ >+ private void doTest2(String label, String data, String result) { >+ String full; >+ full = STextEngine.leanToFullText(type, null, null, data, state); >+ assertEquals(label + " data = " + data, result, toPseudo(full)); >+ } >+ >+ private void doTest3(String label, String data, String result) { >+ String full; >+ full = STextEngine.leanToFullText(processor, f2, null, toUT16(data), state); >+ assertEquals(label + " data = " + data, result, toPseudo(full)); >+ } >+ >+ public void testExtensions() { >+ >+ type = ISTextTypes.COMMA_DELIMITED; >+ state[0] = STextEngine.STATE_INITIAL; >+ doTest1("Comma #1", "ab,cd, AB, CD, EFG", "ab,cd, AB@, CD@, EFG"); >+ >+ type = ISTextTypes.EMAIL; >+ state[0] = STextEngine.STATE_INITIAL; >+ doTest1("Email #1", "abc.DEF:GHI", "abc.DEF@:GHI"); >+ doTest1("Email #2", "DEF.GHI \"A.B\":JK ", "DEF@.GHI @\"A.B\"@:JK "); >+ doTest1("Email #3", "DEF,GHI (A,B);JK ", "DEF@,GHI @(A,B)@;JK "); >+ doTest1("Email #4", "DEF.GHI (A.B :JK ", "DEF@.GHI @(A.B :JK "); >+ >+ type = ISTextTypes.FILE; >+ state[0] = STextEngine.STATE_INITIAL; >+ doTest1("File #1", "c:\\A\\B\\FILE.EXT", "c:\\A@\\B@\\FILE@.EXT"); >+ >+ type = ISTextTypes.JAVA; >+ state[0] = STextEngine.STATE_INITIAL; >+ doTest1("Java #1", "A = B + C;", "A@ = B@ + C;"); >+ doTest1("Java #2", "A = B + C;", "A@ = B@ + C;"); >+ doTest1("Java #3", "A = \"B+C\"+D;", "A@ = \"B+C\"@+D;"); >+ doTest1("Java #4", "A = \"B+C+D;", "A@ = \"B+C+D;"); >+ doTest1("Java #5", "A = \"B\\\"C\"+D;", "A@ = \"B\\\"C\"@+D;"); >+ doTest1("Java #6", "A = /*B+C*/ D;", "A@ = /*B+C@*/ D;"); >+ doTest1("Java #7", "A = /*B+C* D;", "A@ = /*B+C* D;"); >+ doTest1("Java #8", "X+Y+Z */ B; ", "X+Y+Z @*/ B; "); >+ doTest1("Java #9", "A = //B+C* D;", "A@ = //B+C* D;"); >+ doTest1("Java #10", "A = //B+C`|D+E;", "A@ = //B+C`|D@+E;"); >+ >+ type = ISTextTypes.PROPERTY; >+ state[0] = STextEngine.STATE_INITIAL; >+ doTest1("Property #0", "NAME,VAL1,VAL2", "NAME,VAL1,VAL2"); >+ doTest1("Property #1", "NAME=VAL1,VAL2", "NAME@=VAL1,VAL2"); >+ doTest1("Property #2", "NAME=VAL1,VAL2=VAL3", "NAME@=VAL1,VAL2=VAL3"); >+ >+ String data; >+ type = ISTextTypes.REGEXP; >+ state[0] = STextEngine.STATE_INITIAL; >+ data = toUT16("ABC(?") + "#" + toUT16("DEF)GHI"); >+ doTest2("Regex #0.0", data, "A@B@C@(?#DEF)@G@H@I"); >+ data = toUT16("ABC(?") + "#" + toUT16("DEF"); >+ doTest2("Regex #0.1", data, "A@B@C@(?#DEF"); >+ doTest1("Regex #0.2", "GHI)JKL", "GHI)@J@K@L"); >+ data = toUT16("ABC(?") + "<" + toUT16("DEF") + ">" + toUT16("GHI"); >+ doTest2("Regex #1", data, "A@B@C@(?<DEF>@G@H@I"); >+ doTest1("Regex #2.0", "ABC(?'DEF'GHI", "A@B@C@(?'DEF'@G@H@I"); >+ doTest1("Regex #2.1", "ABC(?'DEFGHI", "A@B@C@(?'DEFGHI"); >+ data = toUT16("ABC(?(") + "<" + toUT16("DEF") + ">" + toUT16(")GHI"); >+ doTest2("Regex #3", data, "A@B@C@(?(<DEF>)@G@H@I"); >+ doTest1("Regex #4", "ABC(?('DEF')GHI", "A@B@C@(?('DEF')@G@H@I"); >+ doTest1("Regex #5", "ABC(?(DEF)GHI", "A@B@C@(?(DEF)@G@H@I"); >+ data = toUT16("ABC(?") + "&" + toUT16("DEF)GHI"); >+ doTest2("Regex #6", data, "A@B@C@(?&DEF)@G@H@I"); >+ data = toUT16("ABC(?") + "P<" + toUT16("DEF") + ">" + toUT16("GHI"); >+ doTest2("Regex #7", data, "A@B@C(?p<DEF>@G@H@I"); >+ data = toUT16("ABC\\k") + "<" + toUT16("DEF") + ">" + toUT16("GHI"); >+ doTest2("Regex #8", data, "A@B@C\\k<DEF>@G@H@I"); >+ doTest1("Regex #9", "ABC\\k'DEF'GHI", "A@B@C\\k'DEF'@G@H@I"); >+ doTest1("Regex #10", "ABC\\k{DEF}GHI", "A@B@C\\k{DEF}@G@H@I"); >+ data = toUT16("ABC(?") + "P=" + toUT16("DEF)GHI"); >+ doTest2("Regex #11", data, "A@B@C(?p=DEF)@G@H@I"); >+ doTest1("Regex #12", "ABC\\g{DEF}GHI", "A@B@C\\g{DEF}@G@H@I"); >+ data = toUT16("ABC\\g") + "<" + toUT16("DEF") + ">" + toUT16("GHI"); >+ doTest2("Regex #13", data, "A@B@C\\g<DEF>@G@H@I"); >+ doTest1("Regex #14", "ABC\\g'DEF'GHI", "A@B@C\\g'DEF'@G@H@I"); >+ data = toUT16("ABC(?(") + "R&" + toUT16("DEF)GHI"); >+ doTest2("Regex #15", data, "A@B@C(?(r&DEF)@G@H@I"); >+ data = toUT16("ABC") + "\\Q" + toUT16("DEF") + "\\E" + toUT16("GHI"); >+ doTest2("Regex #16.0", data, "A@B@C\\qDEF\\eG@H@I"); >+ data = toUT16("ABC") + "\\Q" + toUT16("DEF"); >+ doTest2("Regex #16.1", data, "A@B@C\\qDEF"); >+ data = toUT16("GHI") + "\\E" + toUT16("JKL"); >+ doTest2("Regex #16.2", data, "GHI\\eJ@K@L"); >+ doTest1("Regex #17.0", "abc[d-h]ijk", "abc[d-h]ijk"); >+ doTest1("Regex #17.1", "aBc[d-H]iJk", "aBc[d-H]iJk"); >+ doTest1("Regex #17.2", "aB*[!-H]iJ2", "aB*[!-@H]iJ@2"); >+ doTest1("Regex #17.3", "aB*[1-2]J3", "aB*[@1-2]J@3"); >+ doTest1("Regex #17.4", "aB*[5-6]J3", "aB*[@5-@6]@J@3"); >+ doTest1("Regex #17.5", "a*[5-6]J3", "a*[5-@6]@J@3"); >+ doTest1("Regex #17.6", "aB*123", "aB*@123"); >+ doTest1("Regex #17.7", "aB*567", "aB*@567"); >+ >+ type = ISTextTypes.SQL; >+ state[0] = STextEngine.STATE_INITIAL; >+ doTest1("SQL #0", "abc GHI", "abc GHI"); >+ doTest1("SQL #1", "abc DEF GHI", "abc DEF@ GHI"); >+ doTest1("SQL #2", "ABC, DEF, GHI", "ABC@, DEF@, GHI"); >+ doTest1("SQL #3", "ABC'DEF GHI' JKL,MN", "ABC@'DEF GHI'@ JKL@,MN"); >+ doTest1("SQL #4.0", "ABC'DEF GHI JKL", "ABC@'DEF GHI JKL"); >+ doTest1("SQL #4.1", "MNO PQ' RS,TUV", "MNO PQ'@ RS@,TUV"); >+ doTest1("SQL #5", "ABC\"DEF GHI\" JKL,MN", "ABC@\"DEF GHI\"@ JKL@,MN"); >+ doTest1("SQL #6", "ABC\"DEF GHI JKL", "ABC@\"DEF GHI JKL"); >+ doTest1("SQL #7", "ABC/*DEF GHI*/ JKL,MN", "ABC@/*DEF GHI@*/ JKL@,MN"); >+ doTest1("SQL #8.0", "ABC/*DEF GHI JKL", "ABC@/*DEF GHI JKL"); >+ doTest1("SQL #8.1", "MNO PQ*/RS,TUV", "MNO PQ@*/RS@,TUV"); >+ doTest1("SQL #9", "ABC--DEF GHI JKL", "ABC@--DEF GHI JKL"); >+ doTest1("SQL #10", "ABC--DEF--GHI,JKL", "ABC@--DEF--GHI,JKL"); >+ doTest1("SQL #11", "ABC'DEF '' G I' JKL,MN", "ABC@'DEF '' G I'@ JKL@,MN"); >+ doTest1("SQL #12", "ABC\"DEF \"\" G I\" JKL,MN", "ABC@\"DEF \"\" G I\"@ JKL@,MN"); >+ doTest1("SQL #13", "ABC--DEF GHI`|JKL MN", "ABC@--DEF GHI`|JKL@ MN"); >+ >+ type = ISTextTypes.SYSTEM_USER; >+ state[0] = STextEngine.STATE_INITIAL; >+ doTest1("System #1", "HOST(JACK)", "HOST@(JACK)"); >+ >+ type = ISTextTypes.UNDERSCORE; >+ state[0] = STextEngine.STATE_INITIAL; >+ doTest1("Underscore #1", "A_B_C_d_e_F_G", "A@_B@_C_d_e_F@_G"); >+ >+ type = ISTextTypes.URL; >+ state[0] = STextEngine.STATE_INITIAL; >+ doTest1("URL #1", "WWW.DOMAIN.COM/DIR1/DIR2/dir3/DIR4", "WWW@.DOMAIN@.COM@/DIR1@/DIR2/dir3/DIR4"); >+ >+ type = ISTextTypes.XPATH; >+ state[0] = STextEngine.STATE_INITIAL; >+ doTest1("Xpath #1", "abc(DEF)GHI", "abc(DEF@)GHI"); >+ doTest1("Xpath #2", "DEF.GHI \"A.B\":JK ", "DEF@.GHI@ \"A.B\"@:JK "); >+ doTest1("Xpath #3", "DEF!GHI 'A!B'=JK ", "DEF@!GHI@ 'A!B'@=JK "); >+ doTest1("Xpath #4", "DEF.GHI 'A.B :JK ", "DEF@.GHI@ 'A.B :JK "); >+ >+ type = ISTextTypes.EMAIL; >+ processor = STextStringProcessor.getProcessor(type); >+ state[0] = STextEngine.STATE_INITIAL; >+ f1 = processor.getFeatures(null); >+ assertEquals("<>.:,;@", f1.getSeparators()); >+ f2 = new STextFeatures("+-*/", f1.getSpecialsCount(), f1.getDirArabic(), f1.getDirHebrew(), f1.getIgnoreArabic(), f1.getIgnoreHebrew()); >+ doTest3("DelimsEsc #1", "abc+DEF-GHI", "abc+DEF@-GHI"); >+ doTest3("DelimsEsc #2", "DEF-GHI (A*B)/JK ", "DEF@-GHI @(A*B)@/JK "); >+ doTest3("DelimsEsc #3", "DEF-GHI (A*B)/JK ", "DEF@-GHI @(A*B)@/JK "); >+ doTest3("DelimsEsc #4", "DEF-GHI (A*B\\)*C) /JK ", "DEF@-GHI @(A*B\\)*C) @/JK "); >+ doTest3("DelimsEsc #5", "DEF-GHI (A\\\\\\)*C) /JK ", "DEF@-GHI @(A\\\\\\)*C) @/JK "); >+ doTest3("DelimsEsc #6", "DEF-GHI (A\\\\)*C /JK ", "DEF@-GHI @(A\\\\)@*C @/JK "); >+ doTest3("DelimsEsc #7", "DEF-GHI (A\\)*C /JK ", "DEF@-GHI @(A\\)*C /JK "); >+ } >+} >Index: src/org/eclipse/equinox/bidi/internal/tests/STextFullToLeanTest.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/internal/tests/STextFullToLeanTest.java >diff -N src/org/eclipse/equinox/bidi/internal/tests/STextFullToLeanTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/bidi/internal/tests/STextFullToLeanTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,247 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.equinox.bidi.internal.tests; >+ >+import org.eclipse.equinox.bidi.*; >+ >+/** >+ * Tests fullToLean method >+ */ >+ >+public class STextFullToLeanTest extends STextTestBase { >+ >+ static final STextEnvironment envLTR = new STextEnvironment(null, false, STextEnvironment.ORIENT_LTR); >+ static final STextEnvironment envRTL = new STextEnvironment(null, false, STextEnvironment.ORIENT_RTL); >+ >+ String type; >+ >+ private void doTest1(String msg, String data, String leanLTR, String fullLTR, int[] l2fMapLTR, int[] f2lMapLTR, String leanRTL, String fullRTL, int[] l2fMapRTL, int[] f2lMapRTL) { >+ String text, full, lean, label; >+ int[] map; >+ >+ text = toUT16(data); >+ lean = STextEngine.fullToLeanText(type, null, envLTR, text, null); >+ assertEquals(msg + "LTR lean", leanLTR, toPseudo(lean)); >+ full = STextEngine.leanToFullText(type, null, envLTR, lean, null); >+ assertEquals(msg + "LTR full", fullLTR, toPseudo(full)); >+ map = STextEngine.leanToFullMap(type, null, envLTR, lean, null); >+ label = msg + "leanToFullMap() LTR"; >+ assertEquals(label, array_display(l2fMapLTR), array_display(map)); >+ map = STextEngine.fullToLeanMap(type, null, envLTR, text, null); >+ label = msg + "fullToLeanMap() LTR"; >+ assertEquals(label, array_display(f2lMapLTR), array_display(map)); >+ >+ lean = STextEngine.fullToLeanText(type, null, envRTL, text, null); >+ assertEquals(msg + "RTL lean", leanRTL, toPseudo(lean)); >+ full = STextEngine.leanToFullText(type, null, envRTL, lean, null); >+ assertEquals(msg + "RTL full", fullRTL, toPseudo(full)); >+ map = STextEngine.leanToFullMap(type, null, envRTL, lean, null); >+ label = msg + "leanToFullMap() RTL"; >+ assertEquals(label, array_display(l2fMapRTL), array_display(map)); >+ map = STextEngine.fullToLeanMap(type, null, envRTL, text, null); >+ label = msg + "fullToLeanMap() RTL"; >+ assertEquals(label, array_display(f2lMapRTL), array_display(map)); >+ } >+ >+ private void doTest2(String msg) { >+ String text, data, full, lean, model; >+ int[] state = new int[1]; >+ int state1, state2, state3; >+ >+ data = "update \"AB_CDE\" set \"COL1\"@='01', \"COL2\"@='02' /* GH IJK"; >+ text = toUT16(data); >+ state[0] = -1; >+ lean = STextEngine.fullToLeanText(type, null, envLTR, text, state); >+ state1 = state[0]; >+ model = "update \"AB_CDE\" set \"COL1\"='01', \"COL2\"='02' /* GH IJK"; >+ assertEquals(msg + "LTR lean", model, toPseudo(lean)); >+ state[0] = -1; >+ full = STextEngine.leanToFullText(type, null, envLTR, lean, state); >+ assertEquals(msg + "LTR full", data, toPseudo(full)); >+ assertEquals(msg + "state from leanToFullText", state1, state[0]); >+ data = "THIS IS A COMMENT LINE"; >+ text = toUT16(data); >+ state[0] = state1; >+ lean = STextEngine.fullToLeanText(type, null, envLTR, text, state); >+ state2 = state[0]; >+ model = "THIS IS A COMMENT LINE"; >+ assertEquals(msg + "LTR lean2", model, toPseudo(lean)); >+ state[0] = state1; >+ full = STextEngine.leanToFullText(type, null, envLTR, lean, state); >+ assertEquals(msg + "LTR full2", data, toPseudo(full)); >+ assertEquals(msg + "state from leanToFullText2", state2, state[0]); >+ data = "SOME MORE */ where \"COL3\"@=123"; >+ text = toUT16(data); >+ state[0] = state2; >+ lean = STextEngine.fullToLeanText(type, null, envLTR, text, state); >+ state3 = state[0]; >+ model = "SOME MORE */ where \"COL3\"=123"; >+ assertEquals(msg + "LTR lean3", model, toPseudo(lean)); >+ state[0] = state2; >+ full = STextEngine.leanToFullText(type, null, envLTR, lean, state); >+ assertEquals(msg + "LTR full3", data, toPseudo(full)); >+ assertEquals(msg + "state from leanToFullText3", state3, state[0]); >+ } >+ >+ public void testFullToLean() { >+ >+ type = ISTextTypes.COMMA_DELIMITED; >+ doTest1("testFullToLean #1 - ", "", "", "", new int[0], new int[0], "", "", new int[0], new int[0]); >+ int[] map1 = new int[] {0, 1, 2, 3, 4}; >+ int[] map2 = new int[] {2, 3, 4, 5, 6}; >+ int[] map3; >+ doTest1("testFullToLean #01 - ", "1.abc", "1.abc", "1.abc", map1, map1, "1.abc", ">@1.abc@^", map2, map1); >+ map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8}; >+ map2 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10}; >+ doTest1("testFullToLean #02 - ", "2.abc,def", "2.abc,def", "2.abc,def", map1, map1, "2.abc,def", ">@2.abc,def@^", map2, map1); >+ map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; >+ map2 = new int[] {-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; >+ map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; >+ doTest1("testFullToLean #03 - ", "@a.3.bc,def", "a.3.bc,def", "a.3.bc,def", map1, map2, "a.3.bc,def", ">@a.3.bc,def@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; >+ map2 = new int[] {-1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; >+ map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; >+ doTest1("testFullToLean #04 - ", "@@a.4.bc,def", "a.4.bc,def", "a.4.bc,def", map1, map2, "a.4.bc,def", ">@a.4.bc,def@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8}; >+ map2 = new int[] {-1, 0, 1, 2, 3, 4, 5, 6, 7, 8}; >+ map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10}; >+ doTest1("testFullToLean #05 - ", "@5.abc,def", "5.abc,def", "5.abc,def", map1, map2, "5.abc,def", ">@5.abc,def@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8}; >+ map2 = new int[] {-1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8}; >+ map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10}; >+ doTest1("testFullToLean #06 - ", "@@6.abc,def", "6.abc,def", "6.abc,def", map1, map2, "6.abc,def", ">@6.abc,def@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8}; >+ map2 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10}; >+ doTest1("testFullToLean #07 - ", "7abc,@def", "7abc,@def", "7abc,@def", map1, map1, "7abc,@def", ">@7abc,@def@^", map2, map1); >+ map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8}; >+ map2 = new int[] {0, 1, 2, 3, 4, 5, -1, 6, 7, 8}; >+ map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10}; >+ doTest1("testFullToLean #08 - ", "8abc,@@def", "8abc,@def", "8abc,@def", map1, map2, "8abc,@def", ">@8abc,@def@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7}; >+ map2 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, -1}; >+ map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9}; >+ doTest1("testFullToLean #09 - ", "9abc,def@", "9abc,def", "9abc,def", map1, map2, "9abc,def", ">@9abc,def@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8}; >+ map2 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, -1, -1}; >+ map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10}; >+ doTest1("testFullToLean #10 - ", "10abc,def@@", "10abc,def", "10abc,def", map1, map2, "10abc,def", ">@10abc,def@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; >+ map2 = new int[] {-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1}; >+ map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; >+ doTest1("testFullToLean #11 - ", "@a.11.bc,@def@", "a.11.bc,@def", "a.11.bc,@def", map1, map2, "a.11.bc,@def", ">@a.11.bc,@def@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; >+ map2 = new int[] {-1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, -1, 9, 10, 11, -1, -1}; >+ map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; >+ doTest1("testFullToLean #12 - ", "@@a.12.bc,@@def@@", "a.12.bc,@def", "a.12.bc,@def", map1, map2, "a.12.bc,@def", ">@a.12.bc,@def@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4}; >+ map2 = new int[] {2, 3, 4, 5, 6}; >+ doTest1("testFullToLean #13 - ", "13ABC", "13ABC", "13ABC", map1, map1, "13ABC", ">@13ABC@^", map2, map1); >+ map1 = new int[] {0, 1, 2, 3, 4, 6, 7, 8}; >+ map2 = new int[] {0, 1, 2, 3, 4, 5, 6, 7}; >+ map3 = new int[] {2, 3, 4, 5, 6, 8, 9, 10}; >+ doTest1("testFullToLean #14 - ", "14ABC,DE", "14ABC,DE", "14ABC@,DE", map1, map2, "14ABC,DE", ">@14ABC@,DE@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 6, 7, 8}; >+ map2 = new int[] {0, 1, 2, 3, 4, -1, 5, 6, 7}; >+ map3 = new int[] {2, 3, 4, 5, 6, 8, 9, 10}; >+ doTest1("testFullToLean #15 - ", "15ABC@,DE", "15ABC,DE", "15ABC@,DE", map1, map2, "15ABC,DE", ">@15ABC@,DE@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 6, 7, 8}; >+ map2 = new int[] {0, 1, 2, 3, 4, -1, -1, 5, 6, 7}; >+ map3 = new int[] {2, 3, 4, 5, 6, 8, 9, 10}; >+ doTest1("testFullToLean #16 - ", "16ABC@@,DE", "16ABC,DE", "16ABC@,DE", map1, map2, "16ABC,DE", ">@16ABC@,DE@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8}; >+ map2 = new int[] {0, 1, 2, 3, 4, 5, 6, -1, 7, 8}; >+ map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10}; >+ doTest1("testFullToLean #17 - ", "17ABC,@@DE", "17ABC,@DE", "17ABC,@DE", map1, map2, "17ABC,@DE", ">@17ABC,@DE@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 6, 7, 8, 10, 11, 12, 13}; >+ map2 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; >+ map3 = new int[] {2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15}; >+ doTest1("testFullToLean #18 - ", "18ABC,DE,FGH", "18ABC,DE,FGH", "18ABC@,DE@,FGH", map1, map2, "18ABC,DE,FGH", ">@18ABC@,DE@,FGH@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 6, 7, 8, 10, 11, 12, 13}; >+ map2 = new int[] {0, 1, 2, 3, 4, -1, 5, 6, 7, -1, 8, 9, 10, 11}; >+ map3 = new int[] {2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15}; >+ doTest1("testFullToLean #19 - ", "19ABC@,DE@,FGH", "19ABC,DE,FGH", "19ABC@,DE@,FGH", map1, map2, "19ABC,DE,FGH", ">@19ABC@,DE@,FGH@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; >+ map2 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; >+ doTest1("testFullToLean #20 - ", "20ABC,@DE,@FGH", "20ABC,@DE,@FGH", "20ABC,@DE,@FGH", map1, map1, "20ABC,@DE,@FGH", ">@20ABC,@DE,@FGH@^", map2, map1); >+ map1 = new int[] {0, 1, 2, 3, 4, 6, 7, 8, 10, 11, 12, 13}; >+ map2 = new int[] {0, 1, 2, 3, 4, -1, -1, 5, 6, 7, -1, -1, 8, 9, 10, 11}; >+ map3 = new int[] {2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15}; >+ doTest1("testFullToLean #21 - ", "21ABC@@,DE@@,FGH", "21ABC,DE,FGH", "21ABC@,DE@,FGH", map1, map2, "21ABC,DE,FGH", ">@21ABC@,DE@,FGH@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; >+ map2 = new int[] {0, 1, 2, 3, 4, 5, 6, -1, 7, 8, 9, 10, -1, 11, 12, 13}; >+ map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; >+ doTest1("testFullToLean #22 - ", "22ABC,@@DE,@@FGH", "22ABC,@DE,@FGH", "22ABC,@DE,@FGH", map1, map2, "22ABC,@DE,@FGH", ">@22ABC,@DE,@FGH@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4}; >+ map2 = new int[] {-1, -1, 0, 1, 2, 3, 4, -1, -1}; >+ map3 = new int[] {2, 3, 4, 5, 6}; >+ doTest1("testFullToLean #23 - ", ">@23abc@^", "23abc", "23abc", map1, map2, "23abc", ">@23abc@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4}; >+ map2 = new int[] {0, 1, 2, 3, 4, -1, -1}; >+ map3 = new int[] {2, 3, 4, 5, 6}; >+ doTest1("testFullToLean #24 - ", "24abc@^", "24abc", "24abc", map1, map2, "24abc", ">@24abc@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4}; >+ map2 = new int[] {-1, -1, 0, 1, 2, 3, 4}; >+ map3 = new int[] {2, 3, 4, 5, 6}; >+ doTest1("testFullToLean #25 - ", ">@25abc", "25abc", "25abc", map1, map2, "25abc", ">@25abc@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15}; >+ map2 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; >+ map3 = new int[] {2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17}; >+ doTest1("testFullToLean #26 - ", "26AB,CD@EF,GHI", "26AB,CD@EF,GHI", "26AB@,CD@EF@,GHI", map1, map2, "26AB,CD@EF,GHI", ">@26AB@,CD@EF@,GHI@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; >+ map2 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; >+ map3 = new int[] {2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}; >+ doTest1("testFullToLean #27 - ", "27AB,CD@123ef,GHI", "27AB,CD@123ef,GHI", "27AB@,CD@123ef,GHI", map1, map2, "27AB,CD@123ef,GHI", ">@27AB@,CD@123ef,GHI@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 6, 7, 8, 10, 11, 12, 13}; >+ map2 = new int[] {-1, 0, 1, 2, 3, 4, -1, 5, 6, 7, -1, 8, 9, 10, 11, -1}; >+ map3 = new int[] {2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15}; >+ doTest1("testFullToLean #28 - ", ">28ABC@,DE@,FGH^", "28ABC,DE,FGH", "28ABC@,DE@,FGH", map1, map2, "28ABC,DE,FGH", ">@28ABC@,DE@,FGH@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 6, 7, 8, 10, 11, 12, 13}; >+ map2 = new int[] {-1, -1, 0, 1, 2, 3, 4, -1, 5, 6, 7, -1, 8, 9, 10, 11, -1, -1}; >+ map3 = new int[] {2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15}; >+ doTest1("testFullToLean #29 - ", ">>29ABC@,DE@,FGH^^", "29ABC,DE,FGH", "29ABC@,DE@,FGH", map1, map2, "29ABC,DE,FGH", ">@29ABC@,DE@,FGH@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15}; >+ map2 = new int[] {-1, 0, 1, 2, 3, 4, 5, 6, -1, 7, 8, 9, -1, 10, 11, 12, 13, -1}; >+ map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 15, 16, 17}; >+ doTest1("testFullToLean #30 - ", ">30AB>C^@,DE@,FGH^", "30AB>C^,DE,FGH", "30AB>C^@,DE@,FGH", map1, map2, "30AB>C^,DE,FGH", ">@30AB>C^@,DE@,FGH@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14}; >+ map2 = new int[] {-1, 0, 1, 2, 3, 4, 5, -1, 6, 7, 8, -1, 9, 10, 11, 12, -1, -1}; >+ map3 = new int[] {2, 3, 4, 5, 6, 7, 9, 10, 11, 13, 14, 15, 16}; >+ doTest1("testFullToLean #31 - ", ">31AB>C@,DE@,FGH^^", "31AB>C,DE,FGH", "31AB>C@,DE@,FGH", map1, map2, "31AB>C,DE,FGH", ">@31AB>C@,DE@,FGH@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 6, 7, 8, 10, 11, 12, 13}; >+ map2 = new int[] {-1, -1, 0, 1, 2, 3, 4, -1, 5, 6, 7, -1, 8, 9, 10, 11, -1, -1}; >+ map3 = new int[] {2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15}; >+ doTest1("testFullToLean #32 - ", ">@32ABC@,DE@,FGH@^", "32ABC,DE,FGH", "32ABC@,DE@,FGH", map1, map2, "32ABC,DE,FGH", ">@32ABC@,DE@,FGH@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 6, 7, 8, 10, 11, 12, 13}; >+ map2 = new int[] {-1, 0, 1, 2, 3, 4, -1, 5, 6, 7, -1, 8, 9, 10, 11, -1, -1}; >+ map3 = new int[] {2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15}; >+ doTest1("testFullToLean #33 - ", "@33ABC@,DE@,FGH@^", "33ABC,DE,FGH", "33ABC@,DE@,FGH", map1, map2, "33ABC,DE,FGH", ">@33ABC@,DE@,FGH@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 6, 7, 8, 10, 11, 12, 13}; >+ map2 = new int[] {-1, -1, 0, 1, 2, 3, 4, -1, 5, 6, 7, -1, 8, 9, 10, 11, -1}; >+ map3 = new int[] {2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15}; >+ doTest1("testFullToLean #34 - ", ">@34ABC@,DE@,FGH@", "34ABC,DE,FGH", "34ABC@,DE@,FGH", map1, map2, "34ABC,DE,FGH", ">@34ABC@,DE@,FGH@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; >+ map2 = new int[] {0, 1, 2, 3, 4, 5, -1, 6, 7, 8, -1, -1, 9, 10, -1}; >+ map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; >+ doTest1("testFullToLean #35 - ", "35ABC@@DE@@@GH@", "35ABC@DE@GH", "35ABC@DE@GH", map1, map2, "35ABC@DE@GH", ">@35ABC@DE@GH@^", map3, map2); >+ map1 = new int[] {0, 1, 2, 3, 4, 5, 6, 7}; >+ map2 = new int[] {0, 1, 2, 3, 4, 5, -1, 6, 7, -1, -1, -1, -1, -1, -1}; >+ map3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9}; >+ doTest1("testFullToLean #36 - ", "36ABC@@DE@@@@@@", "36ABC@DE", "36ABC@DE", map1, map2, "36ABC@DE", ">@36ABC@DE@^", map3, map2); >+ map1 = new int[0]; >+ map2 = new int[] {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; >+ doTest1("testFullToLean #37 - ", ">>>@@@@@^^^", "", "", map1, map2, "", "", map1, map2); >+ >+ // test fullToLeanText with initial state >+ type = ISTextTypes.SQL; >+ doTest2("testFullToLean #38 - "); >+ } >+} >Index: src/org/eclipse/equinox/bidi/internal/tests/STextMathTest.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/internal/tests/STextMathTest.java >diff -N src/org/eclipse/equinox/bidi/internal/tests/STextMathTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/bidi/internal/tests/STextMathTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,46 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.equinox.bidi.internal.tests; >+ >+import org.eclipse.equinox.bidi.*; >+ >+/** >+ * Tests RTL arithmetic >+ */ >+public class STextMathTest extends STextTestBase { >+ >+ static final STextEnvironment envLTR = new STextEnvironment(null, false, STextEnvironment.ORIENT_LTR); >+ static final STextEnvironment envRTL = new STextEnvironment(null, false, STextEnvironment.ORIENT_RTL); >+ >+ String type = ISTextTypes.RTL_ARITHMETIC; >+ >+ private void verifyOneLine(String msg, String data, String resLTR, String resRTL) { >+ String lean = toUT16(data); >+ String fullLTR = STextEngine.leanToFullText(type, null, envLTR, lean, null); >+ assertEquals(msg + " LTR - ", resLTR, toPseudo(fullLTR)); >+ String fullRTL = STextEngine.leanToFullText(type, null, envRTL, lean, null); >+ assertEquals(msg + " RTL - ", resRTL, toPseudo(fullRTL)); >+ } >+ >+ public void testRTLarithmetic() { >+ verifyOneLine("Math #0", "", "", ""); >+ verifyOneLine("Math #1", "1+abc", "<&1+abc&^", "1+abc"); >+ verifyOneLine("Math #2", "2+abc-def", "<&2+abc&-def&^", "2+abc&-def"); >+ verifyOneLine("Math #3", "a+3*bc/def", "<&a&+3*bc&/def&^", "a&+3*bc&/def"); >+ verifyOneLine("Math #4", "4+abc/def", "<&4+abc&/def&^", "4+abc&/def"); >+ verifyOneLine("Math #5", "13ABC", "<&13ABC&^", "13ABC"); >+ verifyOneLine("Math #6", "14ABC-DE", "<&14ABC-DE&^", "14ABC-DE"); >+ verifyOneLine("Math #7", "15ABC+DE", "<&15ABC+DE&^", "15ABC+DE"); >+ verifyOneLine("Math #8", "16ABC*DE", "<&16ABC*DE&^", "16ABC*DE"); >+ verifyOneLine("Math #9", "17ABC/DE", "<&17ABC/DE&^", "17ABC/DE"); >+ } >+} >Index: src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java >diff -N src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,315 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.equinox.bidi.internal.tests; >+ >+import org.eclipse.equinox.bidi.*; >+import org.eclipse.equinox.bidi.custom.*; >+ >+/** >+ * Tests most public methods of BidiComplexEngine >+ */ >+ >+public class STextMethodsTest extends STextTestBase { >+ >+ final static int LTR = STextFeatures.DIR_LTR; >+ final static int RTL = STextFeatures.DIR_RTL; >+ final static STextEnvironment envLTR = new STextEnvironment(null, false, STextEnvironment.ORIENT_LTR); >+ final static STextEnvironment envRTL = new STextEnvironment(null, false, STextEnvironment.ORIENT_RTL); >+ final static STextEnvironment envRTLMIR = new STextEnvironment(null, true, STextEnvironment.ORIENT_RTL); >+ final static STextEnvironment envIGN = new STextEnvironment(null, false, STextEnvironment.ORIENT_IGNORE); >+ final static STextEnvironment envCLR = new STextEnvironment(null, false, STextEnvironment.ORIENT_CONTEXTUAL_LTR); >+ final static STextEnvironment envCRL = new STextEnvironment(null, false, STextEnvironment.ORIENT_CONTEXTUAL_RTL); >+ final static STextEnvironment envERR = new STextEnvironment(null, false, 9999); >+ >+ private void doTestTools() { >+ >+ // This method tests utility methods used by the JUnits >+ String data = "56789ABCDEFGHIJKLMNOPQRSTUVWXYZ~#@&><^|`"; >+ String text = toUT16(data); >+ String dat2 = toPseudo(text); >+ assertEquals(data, dat2); >+ >+ text = toPseudo(data); >+ assertEquals("56789abcdefghijklmnopqrstuvwxyz~#@&><^|`", text); >+ >+ text = array_display(null); >+ assertEquals("null", text); >+ } >+ >+ private void doTestState() { >+ String data, lean, full, model; >+ int[] state = new int[1]; >+ state[0] = -1; >+ String type = ISTextTypes.JAVA; >+ data = "A=B+C;/* D=E+F;"; >+ lean = toUT16(data); >+ full = STextEngine.leanToFullText(type, null, null, lean, state); >+ model = "A@=B@+C@;/* D=E+F;"; >+ assertEquals("full1", model, toPseudo(full)); >+ data = "A=B+C; D=E+F;"; >+ lean = toUT16(data); >+ full = STextEngine.leanToFullText(type, null, null, lean, state); >+ model = "A=B+C; D=E+F;"; >+ assertEquals("full2", model, toPseudo(full)); >+ data = "A=B+C;*/ D=E+F;"; >+ lean = toUT16(data); >+ full = STextEngine.leanToFullText(type, null, null, lean, state); >+ model = "A=B+C;@*/ D@=E@+F;"; >+ assertEquals("full3", model, toPseudo(full)); >+ } >+ >+ private void doTestOrientation() { >+ int orient; >+ orient = STextEnvironment.DEFAULT.getOrientation(); >+ assertEquals("orient #1", STextEnvironment.ORIENT_LTR, orient); >+ >+ orient = envIGN.getOrientation(); >+ assertEquals("orient #2", STextEnvironment.ORIENT_IGNORE, orient); >+ >+ orient = envCRL.getOrientation(); >+ assertEquals("orient #3", STextEnvironment.ORIENT_CONTEXTUAL_RTL, orient); >+ >+ orient = envERR.getOrientation(); >+ assertEquals("orient #4", STextEnvironment.ORIENT_UNKNOWN, orient); >+ } >+ >+ private void doTestOrient(STextFeatures f, String label, String data, String resLTR, String resRTL, String resCon) { >+ String full, lean; >+ String type = ISTextTypes.COMMA_DELIMITED; >+ >+ lean = toUT16(data); >+ full = STextEngine.leanToFullText(type, f, envLTR, lean, null); >+ assertEquals(label + "LTR full", resLTR, toPseudo(full)); >+ full = STextEngine.leanToFullText(type, f, envRTL, lean, null); >+ assertEquals("label + RTL full", resRTL, toPseudo(full)); >+ full = STextEngine.leanToFullText(type, f, envCRL, lean, null); >+ assertEquals(label + "CON full", resCon, toPseudo(full)); >+ } >+ >+ private void doTestScripts(STextFeatures f1) { >+ STextFeatures f2; >+ boolean flag; >+ flag = f1.getIgnoreArabic(); >+ assertFalse("Ignores Arabic 1", flag); >+ flag = f1.getIgnoreHebrew(); >+ assertFalse("Ignores Hebrew 1", flag); >+ >+ f2 = new STextFeatures(f1.getSeparators(), 0, -1, -1, true, true); >+ flag = f2.getIgnoreArabic(); >+ assertTrue("Ignores Arabic 2", flag); >+ flag = f2.getIgnoreHebrew(); >+ assertTrue("Ignores Hebrew 2", flag); >+ doTestOrient(f2, "Scripts #1 ", "BCD,EF", "BCD,EF", ">@BCD,EF@^", "@BCD,EF"); >+ f2 = new STextFeatures(f1.getSeparators(), 0, -1, -1, false, true); >+ flag = f2.getIgnoreArabic(); >+ assertFalse("Ignores Arabic 3", flag); >+ flag = f2.getIgnoreHebrew(); >+ assertTrue("Ignores Hebrew 3", flag); >+ doTestOrient(f2, "Scripts #2 ", "d,EF", "d,EF", ">@d,EF@^", "d,EF"); >+ doTestOrient(f2, "Scripts #3 ", "#,eF", "#,eF", ">@#,eF@^", "@#,eF"); >+ doTestOrient(f2, "Scripts #4 ", "#,12", "#@,12", ">@#@,12@^", "@#@,12"); >+ doTestOrient(f2, "Scripts #5 ", "#,##", "#@,##", ">@#@,##@^", "@#@,##"); >+ doTestOrient(f2, "Scripts #6 ", "#,89", "#@,89", ">@#@,89@^", "@#@,89"); >+ doTestOrient(f2, "Scripts #7 ", "#,ef", "#,ef", ">@#,ef@^", "@#,ef"); >+ doTestOrient(f2, "Scripts #8 ", "#,", "#,", ">@#,@^", "@#,"); >+ doTestOrient(f2, "Scripts #9 ", "9,ef", "9,ef", ">@9,ef@^", "9,ef"); >+ doTestOrient(f2, "Scripts #10 ", "9,##", "9@,##", ">@9@,##@^", "9@,##"); >+ doTestOrient(f2, "Scripts #11 ", "7,89", "7@,89", ">@7@,89@^", "7@,89"); >+ doTestOrient(f2, "Scripts #12 ", "7,EF", "7,EF", ">@7,EF@^", "@7,EF"); >+ doTestOrient(f2, "Scripts #13 ", "BCD,EF", "BCD,EF", ">@BCD,EF@^", "@BCD,EF"); >+ >+ f2 = new STextFeatures(f1.getSeparators(), 0, -1, -1, true, false); >+ flag = f2.getIgnoreArabic(); >+ assertTrue("Ignores Arabic 4", flag); >+ flag = f2.getIgnoreHebrew(); >+ assertFalse("Ignores Hebrew 4", flag); >+ doTestOrient(f2, "Scripts #14 ", "BCd,EF", "BCd,EF", ">@BCd,EF@^", "@BCd,EF"); >+ doTestOrient(f2, "Scripts #15 ", "BCD,eF", "BCD,eF", ">@BCD,eF@^", "@BCD,eF"); >+ doTestOrient(f2, "Scripts #16 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF"); >+ doTestOrient(f2, "Scripts #17 ", "BCD,12", "BCD@,12", ">@BCD@,12@^", "@BCD@,12"); >+ doTestOrient(f2, "Scripts #18 ", "BCD,", "BCD,", ">@BCD,@^", "@BCD,"); >+ >+ f2 = new STextFeatures(f1.getSeparators(), 0, -1, -1, false, false); >+ doTestOrient(f2, "Scripts #19 ", "123,45|67", "123,45|67", ">@123,45|67@^", "@123,45|67"); >+ doTestOrient(f2, "Scripts #20 ", "5,e", "5,e", ">@5,e@^", "5,e"); >+ doTestOrient(f2, "Scripts #21 ", "5,#", "5@,#", ">@5@,#@^", "5@,#"); >+ doTestOrient(f2, "Scripts #22 ", "5,6", "5@,6", ">@5@,6@^", "5@,6"); >+ doTestOrient(f2, "Scripts #23 ", "5,D", "5@,D", ">@5@,D@^", "5@,D"); >+ doTestOrient(f2, "Scripts #24 ", "5,--", "5,--", ">@5,--@^", "@5,--"); >+ } >+ >+ private void doTestLeanOffsets() { >+ String lean, data, label; >+ int[] state = new int[1]; >+ String type = ISTextTypes.JAVA; >+ int[] offsets; >+ int[] model; >+ >+ data = "A=B+C;/* D=E+F;"; >+ lean = toUT16(data); >+ state[0] = -1; >+ offsets = STextEngine.leanBidiCharOffsets(type, null, null, lean, state); >+ model = new int[] {1, 3, 5}; >+ label = "leanBidiCharOffsets() #1 "; >+ assertEquals(label, array_display(model), array_display(offsets)); >+ data = "A=B+C;*/ D=E+F;"; >+ lean = toUT16(data); >+ offsets = STextEngine.leanBidiCharOffsets(type, null, null, lean, state); >+ model = new int[] {6, 10, 12}; >+ label = "leanBidiCharOffsets() #2 "; >+ assertEquals(label, array_display(model), array_display(offsets)); >+ } >+ >+ private void doTestFullOffsets(String label, String data, int[] resLTR, int[] resRTL, int[] resCon) { >+ String full, lean, msg; >+ int[] offsets; >+ String type = ISTextTypes.COMMA_DELIMITED; >+ >+ lean = toUT16(data); >+ full = STextEngine.leanToFullText(type, null, envLTR, lean, null); >+ offsets = STextEngine.fullBidiCharOffsets(type, null, envLTR, full, null); >+ msg = label + "LTR "; >+ assertEquals(msg, array_display(resLTR), array_display(offsets)); >+ full = STextEngine.leanToFullText(type, null, envRTL, lean, null); >+ offsets = STextEngine.fullBidiCharOffsets(type, null, envRTL, full, null); >+ msg = label + "RTL "; >+ assertEquals(msg, array_display(resRTL), array_display(offsets)); >+ full = STextEngine.leanToFullText(type, null, envCLR, lean, null); >+ offsets = STextEngine.fullBidiCharOffsets(type, null, envCLR, full, null); >+ msg = label + "CON "; >+ assertEquals(msg, array_display(resCon), array_display(offsets)); >+ } >+ >+ private void doTestMirrored() { >+ boolean mirrored; >+ mirrored = STextEnvironment.DEFAULT.getMirrored(); >+ assertFalse("mirrored #1", mirrored); >+ STextEnvironment env = new STextEnvironment(null, true, STextEnvironment.ORIENT_LTR); >+ mirrored = env.getMirrored(); >+ assertTrue("mirrored #2", mirrored); >+ } >+ >+ private void doTestDirection() { >+ String data, lean, full, model, msg; >+ ISTextProcessor processor = STextStringProcessor.getProcessor(ISTextTypes.COMMA_DELIMITED); >+ STextFeatures f1 = processor.getFeatures(null); >+ msg = "TestDirection #1"; >+ assertTrue(msg, f1.getDirArabic() == LTR && f1.getDirHebrew() == LTR); >+ >+ STextFeatures f2 = new STextFeatures(f1.getSeparators(), 0, RTL, RTL, false, false); >+ f1 = f2; >+ msg = "TestDirection #2"; >+ assertTrue(msg, f1.getDirArabic() == RTL && f1.getDirHebrew() == RTL); >+ >+ STextEnvironment environment = new STextEnvironment(null, false, STextEnvironment.ORIENT_LTR); >+ processor = STextStringProcessor.getProcessor(ISTextTypes.EMAIL); >+ f1 = processor.getFeatures(environment); >+ msg = "TestDirection #3"; >+ assertTrue(msg, f1.getDirArabic() == LTR && f1.getDirHebrew() == LTR); >+ data = "#ABC.#DEF:HOST.com"; >+ lean = toUT16(data); >+ full = STextEngine.leanToFullText(processor, null, environment, lean, null); >+ model = "#ABC@.#DEF@:HOST.com"; >+ assertEquals("TestDirection #9 full", model, toPseudo(full)); >+ >+ data = "ABC.DEF:HOST.com"; >+ lean = toUT16(data); >+ full = STextEngine.leanToFullText(processor, null, environment, lean, null); >+ model = "ABC@.DEF@:HOST.com"; >+ assertEquals("TestDirection #10 full", model, toPseudo(full)); >+ >+ environment = new STextEnvironment(null, true, STextEnvironment.ORIENT_LTR); >+ f1 = processor.getFeatures(environment); >+ msg = "TestDirection #10.5"; >+ assertTrue(msg, f1.getDirArabic() == RTL && f1.getDirHebrew() == LTR); >+ data = "#ABC.#DEF:HOST.com"; >+ lean = toUT16(data); >+ full = STextEngine.leanToFullText(processor, null, environment, lean, null); >+ model = "<&#ABC.#DEF:HOST.com&^"; >+ assertEquals("TestDirection #11 full", model, toPseudo(full)); >+ >+ data = "#ABc.#DEF:HOSt.COM"; >+ lean = toUT16(data); >+ full = STextEngine.leanToFullText(processor, null, environment, lean, null); >+ model = "<&#ABc.#DEF:HOSt.COM&^"; >+ assertEquals("TestDirection #12 full", model, toPseudo(full)); >+ >+ data = "#ABc.#DEF:HOSt."; >+ lean = toUT16(data); >+ full = STextEngine.leanToFullText(processor, null, environment, lean, null); >+ model = "<&#ABc.#DEF:HOSt.&^"; >+ assertEquals("TestDirection #13 full", model, toPseudo(full)); >+ >+ data = "ABC.DEF:HOST.com"; >+ lean = toUT16(data); >+ full = STextEngine.leanToFullText(processor, null, environment, lean, null); >+ model = "ABC@.DEF@:HOST.com"; >+ assertEquals("TestDirection #14 full", model, toPseudo(full)); >+ >+ data = "--.---:----"; >+ lean = toUT16(data); >+ full = STextEngine.leanToFullText(processor, null, environment, lean, null); >+ model = "--.---:----"; >+ assertEquals("TestDirection #15 full", model, toPseudo(full)); >+ >+ data = "ABC.|DEF:HOST.com"; >+ lean = toUT16(data); >+ full = STextEngine.leanToFullText(processor, null, environment, lean, null); >+ model = "ABC.|DEF@:HOST.com"; >+ assertEquals("TestDirection #16 full", model, toPseudo(full)); >+ >+ data = "#ABc.|#DEF:HOST.com"; >+ lean = toUT16(data); >+ full = STextEngine.leanToFullText(processor, null, envRTLMIR, lean, null); >+ model = "#ABc.|#DEF:HOST.com"; >+ assertEquals("TestDirection #17 full", model, toPseudo(full)); >+ assertEquals("Test curDirection", RTL, STextEngine.getCurDirection(processor, null, envRTLMIR, lean)); >+ } >+ >+ public void testMethods() { >+ >+ doTestTools(); >+ >+ doTestState(); >+ >+ doTestOrientation(); >+ >+ ISTextProcessor processor = STextStringProcessor.getProcessor(ISTextTypes.COMMA_DELIMITED); >+ STextFeatures f = processor.getFeatures(null); >+ doTestOrient(f, "Methods #1 ", "", "", "", ""); >+ doTestOrient(f, "Methods #2 ", "abc", "abc", ">@abc@^", "abc"); >+ doTestOrient(f, "Methods #3 ", "ABC", "ABC", ">@ABC@^", "@ABC"); >+ doTestOrient(f, "Methods #4 ", "bcd,ef", "bcd,ef", ">@bcd,ef@^", "bcd,ef"); >+ doTestOrient(f, "Methods #5 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF"); >+ doTestOrient(f, "Methods #6 ", "cde,FG", "cde,FG", ">@cde,FG@^", "cde,FG"); >+ doTestOrient(f, "Methods #7 ", "CDE,fg", "CDE,fg", ">@CDE,fg@^", "@CDE,fg"); >+ doTestOrient(f, "Methods #8 ", "12..def,GH", "12..def,GH", ">@12..def,GH@^", "12..def,GH"); >+ doTestOrient(f, "Methods #9 ", "34..DEF,gh", "34..DEF,gh", ">@34..DEF,gh@^", "@34..DEF,gh"); >+ >+ doTestScripts(f); >+ >+ doTestLeanOffsets(); >+ >+ doTestFullOffsets("TestFullOffsets ", "BCD,EF,G", new int[] {3, 7}, new int[] {0, 1, 5, 9, 12, 13}, new int[] {0, 4, 8}); >+ >+ doTestMirrored(); >+ >+ doTestDirection(); >+ >+ String type = ISTextTypes.COMMA_DELIMITED; >+ String data = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"; >+ String lean = toUT16(data); >+ String full = STextEngine.leanToFullText(type, null, null, lean, null); >+ String model = "A@,B@,C@,D@,E@,F@,G@,H@,I@,J@,K@,L@,M@,N@,O@,P@,Q@,R@,S@,T@,U@,V@,W@,X@,Y@,Z"; >+ assertEquals("many inserts", model, toPseudo(full)); >+ } >+} >Index: src/org/eclipse/equinox/bidi/internal/tests/STextNullProcessorTest.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/internal/tests/STextNullProcessorTest.java >diff -N src/org/eclipse/equinox/bidi/internal/tests/STextNullProcessorTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/bidi/internal/tests/STextNullProcessorTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,47 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.equinox.bidi.internal.tests; >+ >+import org.eclipse.equinox.bidi.STextEngine; >+import org.eclipse.equinox.bidi.custom.STextFeatures; >+ >+/** >+ * Tests RTL arithmetic >+ */ >+public class STextNullProcessorTest extends STextTestBase { >+ >+ static final int[] EMPTY_INT_ARRAY = new int[0]; >+ >+ public void testNullProcessor() { >+ String full = STextEngine.leanToFullText(null, null, null, "abc", null); >+ assertEquals("leanToFullText", "abc", full); >+ int[] state = new int[1]; >+ state[0] = 3; >+ full = STextEngine.leanToFullText(null, null, null, "abc", state); >+ assertEquals("leanToFullText with state", "abc", full); >+ int[] offsets = STextEngine.leanBidiCharOffsets(null, null, null, "abc", null); >+ assertEquals("leanBidiCharOffsets", 0, offsets.length); >+ offsets = STextEngine.fullBidiCharOffsets(null, null, null, "abc", null); >+ assertEquals("fullBidiCharOffsets", 0, offsets.length); >+ String lean = STextEngine.fullToLeanText(null, null, null, "abc", null); >+ assertEquals("fullToLeanText", "abc", lean); >+ lean = STextEngine.fullToLeanText(null, null, null, "abc", state); >+ assertEquals("fullToLeanText with state", "abc", lean); >+ int[] map = STextEngine.leanToFullMap(null, null, null, "abc", null); >+ int[] model = {0, 1, 2}; >+ assertEquals("leanToFullMap", array_display(model), array_display(map)); >+ map = STextEngine.fullToLeanMap(null, null, null, "abc", null); >+ assertEquals("fullToLeanMap", array_display(model), array_display(map)); >+ int direction = STextEngine.getCurDirection(null, null, null, "abc"); >+ assertEquals("getCurDirection", STextFeatures.DIR_LTR, direction); >+ } >+} >Index: src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java >diff -N src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,93 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.equinox.bidi.internal.tests; >+ >+import org.eclipse.equinox.bidi.STextEngine; >+import org.eclipse.equinox.bidi.STextEnvironment; >+import org.eclipse.equinox.bidi.custom.*; >+ >+/** >+ * Tests some weird cases >+ */ >+ >+public class STextSomeMoreTest extends STextTestBase { >+ >+ final static STextEnvironment env1 = new STextEnvironment("en_US", false, STextEnvironment.ORIENT_LTR); >+ final static STextEnvironment env2 = new STextEnvironment("he", false, STextEnvironment.ORIENT_LTR); >+ final static STextFeatures myFeatures = new STextFeatures(null, 1, -1, -1, false, false); >+ >+ class Processor1 extends STextProcessor { >+ >+ public STextFeatures getFeatures(STextEnvironment env) { >+ return myFeatures; >+ } >+ >+ public int indexOfSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex) { >+ return fromIndex; >+ } >+ >+ public int processSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) { >+ int len = text.length(); >+ for (int i = len - 1; i >= 0; i--) { >+ STextProcessor.insertMark(text, dirProps, offsets, i); >+ STextProcessor.insertMark(text, dirProps, offsets, i); >+ } >+ return len; >+ } >+ } >+ >+ class Processor2 extends STextProcessor { >+ >+ public STextFeatures getFeatures(STextEnvironment env) { >+ return myFeatures; >+ } >+ } >+ >+ class Processor3 extends STextProcessor { >+ >+ public STextFeatures getFeatures(STextEnvironment env) { >+ return myFeatures; >+ } >+ >+ public int indexOfSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex) { >+ return 0; >+ } >+ } >+ >+ public void testSomeMore() { >+ assertFalse(env1.isBidi()); >+ assertTrue(env2.isBidi()); >+ >+ ISTextProcessor processor = new Processor1(); >+ String full = STextEngine.leanToFullText(processor, null, env1, "abcd", null); >+ assertEquals("@a@b@c@d", toPseudo(full)); >+ >+ processor = new Processor2(); >+ boolean catchFlag = false; >+ try { >+ full = STextEngine.leanToFullText(processor, null, env1, "abcd", null); >+ } catch (IllegalStateException e) { >+ catchFlag = true; >+ } >+ assertTrue("Catch missing indexOfSpecial", catchFlag); >+ >+ processor = new Processor3(); >+ catchFlag = false; >+ try { >+ full = STextEngine.leanToFullText(processor, null, env1, "abcd", null); >+ } catch (IllegalStateException e) { >+ catchFlag = true; >+ } >+ assertTrue("Catch missing processSpecial", catchFlag); >+ } >+ >+} >Index: src/org/eclipse/equinox/bidi/internal/tests/STextStringRecordTest.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/internal/tests/STextStringRecordTest.java >diff -N src/org/eclipse/equinox/bidi/internal/tests/STextStringRecordTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/bidi/internal/tests/STextStringRecordTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,119 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.equinox.bidi.internal.tests; >+ >+import org.eclipse.equinox.bidi.STextStringRecord; >+import org.eclipse.equinox.bidi.custom.STextStringProcessor; >+ >+/** >+ * Tests the StringRecord class >+ */ >+public class STextStringRecordTest extends STextTestBase { >+ public void testStringRecord() { >+ STextStringRecord sr; >+ boolean catchFlag; >+ short[] badTriplet1 = new short[] {0, 0}; >+ short[] badTriplet2 = new short[] {0, 0, -1}; >+ short[] badTriplet3 = new short[] {0, 0, 999}; >+ short[] goodTriplet = new short[] {0, 3, 2}; >+ short[] triplets; >+ short type; >+ String strType; >+ // check handling of invalid arguments >+ catchFlag = false; >+ try { >+ sr = new STextStringRecord(null, badTriplet1); >+ } catch (IllegalArgumentException e) { >+ catchFlag = true; >+ } >+ assertTrue("Catch null string argument", catchFlag); >+ catchFlag = false; >+ try { >+ sr = new STextStringRecord("xxx", null); >+ } catch (IllegalArgumentException e) { >+ catchFlag = true; >+ } >+ assertTrue("Catch null triplets argument", catchFlag); >+ catchFlag = false; >+ try { >+ sr = new STextStringRecord("xxx", badTriplet1); >+ } catch (IllegalArgumentException e) { >+ catchFlag = true; >+ } >+ assertTrue("Catch bad triplet #1 argument", catchFlag); >+ catchFlag = false; >+ try { >+ sr = new STextStringRecord("xxx", badTriplet2); >+ } catch (IllegalArgumentException e) { >+ catchFlag = true; >+ } >+ assertTrue("Catch bad triplet #2 argument", catchFlag); >+ catchFlag = false; >+ try { >+ sr = new STextStringRecord("xxx", badTriplet3); >+ } catch (IllegalArgumentException e) { >+ catchFlag = true; >+ } >+ assertTrue("Catch bad triplet #3 argument", catchFlag); >+ >+ String[] types = STextStringProcessor.getKnownTypes(); >+ for (int i = 0; i < types.length; i++) { >+ type = STextStringRecord.typeStringToShort(types[i]); >+ assertFalse(type == -1); >+ strType = STextStringRecord.typeShortToString(type); >+ assertEquals(types[i], strType); >+ } >+ type = STextStringRecord.typeStringToShort("dummy"); >+ assertEquals(-1, type); >+ strType = STextStringRecord.typeShortToString((short) 999); >+ assertEquals(null, strType); >+ int poolSize = STextStringRecord.POOLSIZE; >+ int lim = poolSize / 2; >+ triplets = STextStringRecord.getTriplets("xxx"); >+ assertEquals(null, triplets); >+ for (int i = 0; i < lim; i++) { >+ String str = Integer.toString(i); >+ sr = new STextStringRecord(str, goodTriplet); >+ STextStringRecord.add(sr); >+ } >+ triplets = STextStringRecord.getTriplets(null); >+ assertEquals(null, triplets); >+ triplets = STextStringRecord.getTriplets(""); >+ assertEquals(null, triplets); >+ for (int i = 0; i < poolSize; i++) { >+ String str = Integer.toString(i); >+ triplets = STextStringRecord.getTriplets(str); >+ if (i < lim) >+ assertFalse(null == triplets); >+ else >+ assertTrue(null == triplets); >+ } >+ for (int i = lim; i <= poolSize; i++) { >+ String str = Integer.toString(i); >+ sr = new STextStringRecord(str, goodTriplet); >+ STextStringRecord.add(sr); >+ } >+ for (int i = 1; i <= poolSize; i++) { >+ String str = Integer.toString(i); >+ triplets = STextStringRecord.getTriplets(str); >+ assertFalse(null == triplets); >+ } >+ triplets = STextStringRecord.getTriplets("0"); >+ assertEquals(null, triplets); >+ STextStringRecord.clear(); >+ for (int i = 0; i <= poolSize; i++) { >+ String str = Integer.toString(i); >+ triplets = STextStringRecord.getTriplets(str); >+ assertEquals(null, triplets); >+ } >+ } >+} >Index: src/org/eclipse/equinox/bidi/internal/tests/STextTest.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/internal/tests/STextTest.java >diff -N src/org/eclipse/equinox/bidi/internal/tests/STextTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/bidi/internal/tests/STextTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,33 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.equinox.bidi.internal.tests; >+ >+import org.eclipse.equinox.bidi.STextEnvironment; >+import org.eclipse.equinox.bidi.custom.STextFeatures; >+import org.eclipse.equinox.bidi.custom.ISTextProcessor; >+ >+public class STextTest implements ISTextProcessor { >+ >+ static final STextFeatures FEATURES = new STextFeatures("-=.:", 0, -1, -1, false, false); >+ >+ public STextFeatures getFeatures(STextEnvironment env) { >+ return FEATURES; >+ } >+ >+ public int indexOfSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int caseNumber, int fromIndex) { >+ throw new IllegalStateException(); >+ } >+ >+ public int processSpecial(STextFeatures features, String text, byte[] dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) { >+ throw new IllegalStateException(); >+ } >+ >+} >Index: src/org/eclipse/equinox/bidi/internal/tests/STextTestBase.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/internal/tests/STextTestBase.java >diff -N src/org/eclipse/equinox/bidi/internal/tests/STextTestBase.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/bidi/internal/tests/STextTestBase.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,110 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.equinox.bidi.internal.tests; >+ >+import junit.framework.TestCase; >+ >+/** >+ * Base functionality for the processor tests. >+ */ >+public class STextTestBase extends TestCase { >+ >+ static final private char LRM = 0x200E; >+ >+ static final private char RLM = 0x200F; >+ >+ static final private char LRE = 0x202A; >+ >+ static final private char RLE = 0x202B; >+ >+ static final private char PDF = 0x202C; >+ >+ public static String toPseudo(String text) { >+ char[] chars = text.toCharArray(); >+ int len = chars.length; >+ >+ for (int i = 0; i < len; i++) { >+ char c = chars[i]; >+ if (c >= 'A' && c <= 'Z') >+ chars[i] = (char) (c + 'a' - 'A'); >+ else if (c >= 0x05D0 && c < 0x05EA) >+ chars[i] = (char) (c + 'A' - 0x05D0); >+ else if (c == 0x05EA) >+ chars[i] = '~'; >+ else if (c == 0x0644) >+ chars[i] = '#'; >+ else if (c >= 0x0665 && c <= 0x0669) >+ chars[i] = (char) (c + '5' - 0x0665); >+ else if (c == LRM) >+ chars[i] = '@'; >+ else if (c == RLM) >+ chars[i] = '&'; >+ else if (c == LRE) >+ chars[i] = '>'; >+ else if (c == RLE) >+ chars[i] = '<'; >+ else if (c == PDF) >+ chars[i] = '^'; >+ else if (c == '\n') >+ chars[i] = '|'; >+ else if (c == '\r') >+ chars[i] = '`'; >+ } >+ return new String(chars); >+ } >+ >+ public static String toUT16(String text) { >+ char[] chars = text.toCharArray(); >+ int len = chars.length; >+ >+ for (int i = 0; i < len; i++) { >+ char c = chars[i]; >+ if (c >= '5' && c <= '9') >+ chars[i] = (char) (0x0665 + c - '5'); >+ else if (c >= 'A' && c <= 'Z') >+ chars[i] = (char) (0x05D0 + c - 'A'); >+ else if (c == '~') >+ chars[i] = (char) (0x05EA); >+ else if (c == '#') >+ chars[i] = (char) (0x0644); >+ else if (c == '@') >+ chars[i] = LRM; >+ else if (c == '&') >+ chars[i] = RLM; >+ else if (c == '>') >+ chars[i] = LRE; >+ else if (c == '<') >+ chars[i] = RLE; >+ else if (c == '^') >+ chars[i] = PDF; >+ else if (c == '|') >+ chars[i] = '\n'; >+ else if (c == '`') >+ chars[i] = '\r'; >+ } >+ return new String(chars); >+ } >+ >+ static String array_display(int[] array) { >+ if (array == null) { >+ return "null"; >+ } >+ StringBuffer sb = new StringBuffer(50); >+ int len = array.length; >+ for (int i = 0; i < len; i++) { >+ sb.append(array[i]); >+ sb.append(' '); >+ } >+ return sb.toString(); >+ } >+ >+} >Index: src/org/eclipse/equinox/bidi/internal/tests/STextUtilTest.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/internal/tests/STextUtilTest.java >diff -N src/org/eclipse/equinox/bidi/internal/tests/STextUtilTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/bidi/internal/tests/STextUtilTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,138 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.equinox.bidi.internal.tests; >+ >+import java.util.Locale; >+import org.eclipse.equinox.bidi.STextUtil; >+import org.eclipse.equinox.bidi.ISTextTypes; >+ >+/** >+ * Tests methods in BidiComplexUtil >+ */ >+ >+public class STextUtilTest extends STextTestBase { >+ >+ private static final String HEBREW = "iw"; >+ >+ private static final String HEBREW2 = "he"; >+ >+ private static final String ARABIC = "ar"; >+ >+ private static final String FARSI = "fa"; >+ >+ private static final String URDU = "ur"; >+ >+ private Locale locale; >+ >+ protected void setUp() throws Exception { >+ super.setUp(); >+ locale = Locale.getDefault(); >+ } >+ >+ protected void tearDown() { >+ Locale.setDefault(locale); >+ } >+ >+ private void doTest1(String data, String result) { >+ Locale.setDefault(Locale.ENGLISH); >+ String full = STextUtil.process(toUT16(data)); >+ assertEquals("Util #1 full EN - ", data, toPseudo(full)); >+ Locale.setDefault(new Locale(HEBREW2)); >+ full = STextUtil.process(toUT16(data)); >+ assertEquals("Util #1 full HE - ", result, toPseudo(full)); >+ Locale.setDefault(new Locale(ARABIC)); >+ full = STextUtil.process(toUT16(data)); >+ assertEquals("Util #1 full AR - ", result, toPseudo(full)); >+ Locale.setDefault(new Locale(FARSI)); >+ full = STextUtil.process(toUT16(data)); >+ assertEquals("Util #1 full FA - ", result, toPseudo(full)); >+ Locale.setDefault(new Locale(URDU)); >+ full = STextUtil.process(toUT16(data)); >+ assertEquals("Util #1 full UR - ", result, toPseudo(full)); >+ Locale.setDefault(new Locale(HEBREW)); >+ full = STextUtil.process(toUT16(data)); >+ String ful2 = STextUtil.process(toUT16(data), null); >+ assertEquals("Util #1 full - ", result, toPseudo(full)); >+ assertEquals("Util #1 ful2 - ", result, toPseudo(ful2)); >+ String lean = STextUtil.deprocess(full); >+ assertEquals("Util #1 lean - ", data, toPseudo(lean)); >+ } >+ >+ private void doTest2(String msg, String data, String result) { >+ doTest2(msg, data, result, data); >+ } >+ >+ private void doTest2(String msg, String data, String result, String resLean) { >+ String full = STextUtil.process(toUT16(data), "*"); >+ assertEquals(msg + "full", result, toPseudo(full)); >+ String lean = STextUtil.deprocess(full); >+ assertEquals(msg + "lean", resLean, toPseudo(lean)); >+ } >+ >+ private void doTest3(String msg, String data, String result) { >+ doTest3(msg, data, result, data); >+ } >+ >+ private void doTest3(String msg, String data, String result, String resLean) { >+ String full = STextUtil.processTyped(toUT16(data), ISTextTypes.COMMA_DELIMITED); >+ assertEquals(msg + "full", result, toPseudo(full)); >+ String lean = STextUtil.deprocess(full, ISTextTypes.COMMA_DELIMITED); >+ assertEquals(msg + "lean", resLean, toPseudo(lean)); >+ } >+ >+ private void doTest4(String msg, String data, int[] offsets, int direction, boolean affix, String result) { >+ String txt = msg + "text=" + data + "\n offsets=" + array_display(offsets) + "\n direction=" + direction + "\n affix=" + affix; >+ String lean = toUT16(data); >+ String full = STextUtil.insertMarks(lean, offsets, direction, affix); >+ assertEquals(txt, result, toPseudo(full)); >+ } >+ >+ public void testBidiComplexUtil() { >+ >+ // Test process() and deprocess() with default delimiters >+ doTest1("ABC/DEF/G", ">@ABC@/DEF@/G@^"); >+ // Test process() and deprocess() with specified delimiters >+ doTest2("Util #2.1 - ", "", ""); >+ doTest2("Util #2.2 - ", ">@ABC@^", ">@ABC@^", "ABC"); >+ doTest2("Util #2.3 - ", "abc", "abc"); >+ doTest2("Util #2.4 - ", "!abc", ">@!abc@^"); >+ doTest2("Util #2.5 - ", "abc!", ">@abc!@^"); >+ doTest2("Util #2.6 - ", "ABC*DEF*G", ">@ABC@*DEF@*G@^"); >+ // Test process() and deprocess() with specified expression type >+ doTest3("Util #3.1 - ", "ABC,DEF,G", ">@ABC@,DEF@,G@^"); >+ doTest3("Util #3.2 - ", "", ""); >+ doTest3("Util #3.3 - ", ">@DEF@^", ">@DEF@^", "DEF"); >+ boolean catchFlag = false; >+ try { >+ STextUtil.deprocess(toUT16("ABC,DE"), "wrong_type"); >+ } catch (IllegalArgumentException e) { >+ catchFlag = true; >+ } >+ assertTrue("Catch invalid type on deprocess", catchFlag); >+ catchFlag = false; >+ try { >+ STextUtil.processTyped("abc", "wrong_type"); >+ } catch (IllegalArgumentException e) { >+ catchFlag = true; >+ } >+ assertTrue("Catch invalid type on process", catchFlag); >+ // Test insertMarks() >+ doTest4("Util #4.1 - ", "ABCDEFG", new int[] {3, 6}, 0, false, "ABC@DEF@G"); >+ doTest4("Util #4.2 - ", "ABCDEFG", new int[] {3, 6}, 0, true, ">@ABC@DEF@G@^"); >+ doTest4("Util #4.3 - ", "ABCDEFG", new int[] {3, 6}, 1, false, "ABC&DEF&G"); >+ doTest4("Util #4.4 - ", "ABCDEFG", new int[] {3, 6}, 1, true, "<&ABC&DEF&G&^"); >+ doTest4("Util #4.5 - ", "", new int[] {3, 6}, 0, false, ""); >+ doTest4("Util #4.6 - ", "", new int[] {3, 6}, 0, true, ""); >+ doTest4("Util #4.7 - ", "ABCDEFG", null, 1, false, "ABCDEFG"); >+ doTest4("Util #4.8 - ", "ABCDEFG", null, 1, true, "<&ABCDEFG&^"); >+ } >+} >Index: src/org/eclipse/equinox/bidi/tests/BidiComplexTestSuite.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/tests/BidiComplexTestSuite.java >diff -N src/org/eclipse/equinox/bidi/tests/BidiComplexTestSuite.java >--- src/org/eclipse/equinox/bidi/tests/BidiComplexTestSuite.java 27 Apr 2011 14:53:08 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,34 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2010, 2011 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ******************************************************************************/ >- >-package org.eclipse.equinox.bidi.tests; >- >-import junit.framework.Test; >-import junit.framework.TestSuite; >-import org.eclipse.equinox.bidi.internal.tests.*; >- >-public class BidiComplexTestSuite extends TestSuite { >- public static Test suite() { >- return new BidiComplexTestSuite(); >- } >- >- public BidiComplexTestSuite() { >- addTestSuite(BidiComplexExtensibilityTest.class); >- addTestSuite(BidiComplexMethodsTest.class); >- addTestSuite(BidiComplexNullProcessorTest.class); >- addTestSuite(BidiComplexFullToLeanTest.class); >- addTestSuite(BidiComplexExtensionsTest.class); >- addTestSuite(BidiComplexMathTest.class); >- addTestSuite(BidiComplexSomeMoreTest.class); >- addTestSuite(BidiComplexUtilTest.class); >- addTestSuite(BidiComplexStringRecordTest.class); >- } >-} >\ No newline at end of file >Index: src/org/eclipse/equinox/bidi/tests/STextTestSuite.java >=================================================================== >RCS file: src/org/eclipse/equinox/bidi/tests/STextTestSuite.java >diff -N src/org/eclipse/equinox/bidi/tests/STextTestSuite.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/bidi/tests/STextTestSuite.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,34 @@ >+/******************************************************************************* >+ * Copyright (c) 2010, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.equinox.bidi.tests; >+ >+import junit.framework.Test; >+import junit.framework.TestSuite; >+import org.eclipse.equinox.bidi.internal.tests.*; >+ >+public class STextTestSuite extends TestSuite { >+ public static Test suite() { >+ return new STextTestSuite(); >+ } >+ >+ public STextTestSuite() { >+ addTestSuite(STextExtensibilityTest.class); >+ addTestSuite(STextMethodsTest.class); >+ addTestSuite(STextNullProcessorTest.class); >+ addTestSuite(STextFullToLeanTest.class); >+ addTestSuite(STextExtensionsTest.class); >+ addTestSuite(STextMathTest.class); >+ addTestSuite(STextSomeMoreTest.class); >+ addTestSuite(STextUtilTest.class); >+ addTestSuite(STextStringRecordTest.class); >+ } >+} >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
ob1.eclipse
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 183164
:
148967
|
157821
|
158092
|
158531
|
160015
|
160017
|
160081
|
160698
|
160858
|
162228
|
162229
|
164476
|
186038
|
186054
|
186488
|
186490
|
188406
|
188407
|
188408
|
188627
|
194078
|
194079
|
195082
|
195084
|
196575
| 196576 |
199068
|
199070
|
199113
|
199855
|
200008
|
200389
|
200629
|
200630
|
200631
|
200742
|
200743
|
200803
|
200805
|
200905
|
200907
|
201464
|
201465
|
201467
|
201468
|
201469
|
201470
|
201676
|
201677
|
201785
|
201787
|
202172
|
202173
|
205767
|
205768
|
206588
|
210657