View | Details | Raw Unified | Return to bug 183164 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.xml (-1 / +1 lines)
Lines 5-11 Link Here
5
         id="id2"
5
         id="id2"
6
         point="org.eclipse.equinox.bidi.bidiTypes">
6
         point="org.eclipse.equinox.bidi.bidiTypes">
7
      <typeDescription
7
      <typeDescription
8
            class="org.eclipse.equinox.bidi.internal.tests.ComplExpTest"
8
            class="org.eclipse.equinox.bidi.internal.tests.CxpTest"
9
            description="Test"
9
            description="Test"
10
            type="test">
10
            type="test">
11
      </typeDescription>
11
      </typeDescription>
(-)src/org/eclipse/equinox/bidi/internal/tests/ComplExpMathTest.java (-55 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.equinox.bidi.internal.tests;
13
14
import org.eclipse.equinox.bidi.complexp.IBiDiProcessor;
15
import org.eclipse.equinox.bidi.complexp.IComplExpProcessor;
16
import org.eclipse.equinox.bidi.complexp.StringProcessor;
17
18
/**
19
 * Tests RTL arithmetic
20
 */
21
public class ComplExpMathTest extends ComplExpTestBase {
22
23
	private IComplExpProcessor processor;
24
25
	protected void setUp() throws Exception {
26
		super.setUp();
27
		processor = StringProcessor.getProcessor(IBiDiProcessor.RTL_ARITHMETIC);
28
	}
29
30
	private void verifyOneLine(String msg, String data, String resLTR,
31
			String resRTL) {
32
		String lean = toUT16(data);
33
		processor.assumeOrientation(IComplExpProcessor.ORIENT_LTR);
34
		String fullLTR = processor.leanToFullText(lean);
35
		assertEquals(msg + " LTR - ", resLTR, toPseudo(fullLTR));
36
37
		processor.assumeOrientation(IComplExpProcessor.ORIENT_RTL);
38
		String fullRTL = processor.leanToFullText(lean);
39
		assertEquals(msg + " RTL - ", resRTL, toPseudo(fullRTL));
40
	}
41
42
	public void testRTLarithmetic() {
43
		verifyOneLine("Math #0", "", "", "");
44
		verifyOneLine("Math #1", "1+abc", "<&1+abc&^", "1+abc");
45
		verifyOneLine("Math #2", "2+abc-def", "<&2+abc&-def&^", "2+abc&-def");
46
		verifyOneLine("Math #3", "a+3*bc/def", "<&a&+3*bc&/def&^",
47
				"a&+3*bc&/def");
48
		verifyOneLine("Math #4", "4+abc/def", "<&4+abc&/def&^", "4+abc&/def");
49
		verifyOneLine("Math #5", "13ABC", "<&13ABC&^", "13ABC");
50
		verifyOneLine("Math #6", "14ABC-DE", "<&14ABC-DE&^", "14ABC-DE");
51
		verifyOneLine("Math #7", "15ABC+DE", "<&15ABC+DE&^", "15ABC+DE");
52
		verifyOneLine("Math #8", "16ABC*DE", "<&16ABC*DE&^", "16ABC*DE");
53
		verifyOneLine("Math #9", "17ABC/DE", "<&17ABC/DE&^", "17ABC/DE");
54
	}
55
}
(-)src/org/eclipse/equinox/bidi/internal/tests/ComplExpTest.java (-136 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.equinox.bidi.internal.tests;
12
13
import org.eclipse.equinox.bidi.complexp.IComplExpProcessor;
14
15
public class ComplExpTest implements IComplExpProcessor {
16
17
	private static final int[] EMPTY_INT_ARRAY = new int[0];
18
	private static final int[][] ALL_LTR = new int[][] {
19
			{ DIRECTION_LTR, DIRECTION_LTR }, { DIRECTION_LTR, DIRECTION_LTR } };
20
21
	public ComplExpTest() {
22
		return;
23
	}
24
25
	public void setOperators(String operators) {
26
		// empty
27
	}
28
29
	public String getOperators() {
30
		return "";
31
	}
32
33
	public void selectBidiScript(boolean arabic, boolean hebrew) {
34
		// empty
35
	}
36
37
	public boolean handlesArabicScript() {
38
		return false;
39
	}
40
41
	public boolean handlesHebrewScript() {
42
		return false;
43
	}
44
45
	public String leanToFullText(String text) {
46
		return text;
47
	}
48
49
	public String leanToFullText(String text, int initState) {
50
		return text;
51
	}
52
53
	public int[] leanBidiCharOffsets(String text) {
54
		return EMPTY_INT_ARRAY;
55
	}
56
57
	public int[] leanBidiCharOffsets(String text, int initState) {
58
		return EMPTY_INT_ARRAY;
59
	}
60
61
	public int[] leanBidiCharOffsets() {
62
		return EMPTY_INT_ARRAY;
63
	}
64
65
	public int[] fullBidiCharOffsets() {
66
		return EMPTY_INT_ARRAY;
67
	}
68
69
	public String fullToLeanText(String text) {
70
		return text;
71
	}
72
73
	public String fullToLeanText(String text, int initState) {
74
		return text;
75
	}
76
77
	public int getFinalState() {
78
		return STATE_NOTHING_GOING;
79
	}
80
81
	public int leanToFullPos(int pos) {
82
		return pos;
83
	}
84
85
	public int fullToLeanPos(int pos) {
86
		return pos;
87
	}
88
89
	public void assumeMirrored(boolean mirrored) {
90
		// empty
91
	}
92
93
	public boolean isMirrored() {
94
		return false;
95
	}
96
97
	public void assumeOrientation(int orientation) {
98
		// empty
99
	}
100
101
	public int recallOrientation() {
102
		return ORIENT_LTR;
103
	}
104
105
	public void setArabicDirection(int not_mirrored, int mirrored) {
106
		// empty
107
	}
108
109
	public void setArabicDirection(int direction) {
110
		// empty
111
	}
112
113
	public void setHebrewDirection(int not_mirrored, int mirrored) {
114
		// empty
115
	}
116
117
	public void setHebrewDirection(int direction) {
118
		// empty
119
	}
120
121
	public void setDirection(int not_mirrored, int mirrored) {
122
		// empty
123
	}
124
125
	public void setDirection(int direction) {
126
		// empty
127
	}
128
129
	public int[][] getDirection() {
130
		return ALL_LTR;
131
	}
132
133
	public int getCurDirection() {
134
		return DIRECTION_LTR;
135
	}
136
}
(-)src/org/eclipse/equinox/bidi/internal/tests/ComplExpTestBase.java (-156 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.equinox.bidi.internal.tests;
13
14
import junit.framework.TestCase;
15
16
/**
17
 * Base functionality for the processor tests.
18
 */
19
public class ComplExpTestBase extends TestCase {
20
21
	static final private char LRM = 0x200E;
22
	static final private char RLM = 0x200F;
23
	static final private char LRE = 0x202A;
24
	static final private char RLE = 0x202B;
25
	static final private char PDF = 0x202C;
26
27
	protected String toPseudo(String text) {
28
		char[] chars = text.toCharArray();
29
		int len = chars.length;
30
31
		for (int i = 0; i < len; i++) {
32
			char c = chars[i];
33
			if (c >= 'A' && c <= 'Z')
34
				chars[i] = (char) (c + 'a' - 'A');
35
			else if (c >= 0x05D0 && c < 0x05EA)
36
				chars[i] = (char) (c + 'A' - 0x05D0);
37
			else if (c == 0x05EA)
38
				chars[i] = '~';
39
			else if (c == 0x0644)
40
				chars[i] = '#';
41
			else if (c >= 0x0665 && c <= 0x0669)
42
				chars[i] = (char) (c + '5' - 0x0665);
43
			else if (c == LRM)
44
				chars[i] = '@';
45
			else if (c == RLM)
46
				chars[i] = '&';
47
			else if (c == LRE)
48
				chars[i] = '>';
49
			else if (c == RLE)
50
				chars[i] = '<';
51
			else if (c == PDF)
52
				chars[i] = '^';
53
			else if (c == '\n')
54
				chars[i] = '|';
55
			else if (c == '\r')
56
				chars[i] = '`';
57
		}
58
		return new String(chars);
59
	}
60
61
	protected String toUT16(String text) {
62
		char[] chars = text.toCharArray();
63
		int len = chars.length;
64
65
		for (int i = 0; i < len; i++) {
66
			char c = chars[i];
67
			if (c >= '5' && c <= '9')
68
				chars[i] = (char) (0x0665 + c - '5');
69
			else if (c >= 'A' && c <= 'Z')
70
				chars[i] = (char) (0x05D0 + c - 'A');
71
			else if (c == '~')
72
				chars[i] = (char) (0x05EA);
73
			else if (c == '#')
74
				chars[i] = (char) (0x0644);
75
			else if (c == '@')
76
				chars[i] = LRM;
77
			else if (c == '&')
78
				chars[i] = RLM;
79
			else if (c == '>')
80
				chars[i] = LRE;
81
			else if (c == '<')
82
				chars[i] = RLE;
83
			else if (c == '^')
84
				chars[i] = PDF;
85
			else if (c == '|')
86
				chars[i] = '\n';
87
			else if (c == '`')
88
				chars[i] = '\r';
89
		}
90
		return new String(chars);
91
	}
92
93
	static String array_display(int[] array) {
94
		if (array == null) {
95
			return "null";
96
		}
97
		StringBuffer sb = new StringBuffer(50);
98
		int len = array.length;
99
		for (int i = 0; i < len; i++) {
100
			sb.append(array[i]);
101
			sb.append(' ');
102
		}
103
		return sb.toString();
104
	}
105
106
	static boolean arrays_equal(int[] one, int[] two) {
107
		int len = one.length;
108
		if (len != two.length) {
109
			return false;
110
		}
111
		for (int i = 0; i < len; i++) {
112
			if (one[i] != two[i]) {
113
				return false;
114
			}
115
		}
116
		return true;
117
	}
118
119
	static boolean arrays2_equal(int[][] one, int[][] two) {
120
		int dim1, dim2;
121
		dim1 = one.length;
122
		if (dim1 != two.length) {
123
			return false;
124
		}
125
		for (int i = 0; i < dim1; i++) {
126
			dim2 = one[i].length;
127
			if (dim2 != two[i].length) {
128
				return false;
129
			}
130
			for (int j = 0; j < dim2; j++) {
131
				if (one[i][j] != two[i][j]) {
132
					return false;
133
				}
134
			}
135
		}
136
		return true;
137
	}
138
139
	static String array2_display(int[][] array) {
140
		int dim1, dim2;
141
		if (array == null) {
142
			return "null";
143
		}
144
		StringBuffer sb = new StringBuffer(50);
145
		dim1 = array.length;
146
		for (int i = 0; i < dim1; i++) {
147
			dim2 = array[i].length;
148
			for (int j = 0; j < dim2; j++) {
149
				sb.append(array[i][j]);
150
				sb.append(' ');
151
			}
152
		}
153
		return sb.toString();
154
	}
155
156
}
(-)src/org/eclipse/equinox/bidi/internal/tests/ComplExpUtilTest.java (-131 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.equinox.bidi.internal.tests;
13
14
import org.eclipse.equinox.bidi.complexp.*;
15
import java.util.Locale;
16
17
/**
18
 * Tests methods in ComplExpUtil
19
 */
20
21
public class ComplExpUtilTest extends ComplExpTestBase {
22
23
	private static final String HEBREW = "iw";
24
	private static final String HEBREW2 = "he";
25
	private static final String ARABIC = "ar";
26
	private static final String FARSI = "fa";
27
	private static final String URDU = "ur";
28
	private Locale locale;
29
30
	protected void setUp() throws Exception {
31
		super.setUp();
32
		locale = Locale.getDefault();
33
	}
34
35
	protected void tearDown() {
36
		Locale.setDefault(locale);
37
	}
38
39
	private void doTest1(String data, String result) {
40
		Locale.setDefault(Locale.ENGLISH);
41
		String full = ComplExpUtil.process(toUT16(data));
42
		assertEquals("Util #1 full EN - ", data, toPseudo(full));
43
		Locale.setDefault(new Locale(HEBREW2));
44
		full = ComplExpUtil.process(toUT16(data));
45
		assertEquals("Util #1 full HE - ", result, toPseudo(full));
46
		Locale.setDefault(new Locale(ARABIC));
47
		full = ComplExpUtil.process(toUT16(data));
48
		assertEquals("Util #1 full AR - ", result, toPseudo(full));
49
		Locale.setDefault(new Locale(FARSI));
50
		full = ComplExpUtil.process(toUT16(data));
51
		assertEquals("Util #1 full FA - ", result, toPseudo(full));
52
		Locale.setDefault(new Locale(URDU));
53
		full = ComplExpUtil.process(toUT16(data));
54
		assertEquals("Util #1 full UR - ", result, toPseudo(full));
55
		Locale.setDefault(new Locale(HEBREW));
56
		full = ComplExpUtil.process(toUT16(data));
57
		String ful2 = ComplExpUtil.process(toUT16(data), null);
58
		assertEquals("Util #1 full - ", result, toPseudo(full));
59
		assertEquals("Util #1 ful2 - ", result, toPseudo(ful2));
60
		String lean = ComplExpUtil.deprocess(full);
61
		assertEquals("Util #1 lean - ", data, toPseudo(lean));
62
	}
63
64
	private void doTest2(String msg, String data, String result) {
65
		doTest2(msg, data, result, data);
66
	}
67
68
	private void doTest2(String msg, String data, String result, String resLean) {
69
		String full = ComplExpUtil.process(toUT16(data), "*");
70
		assertEquals(msg + "full", result, toPseudo(full));
71
		String lean = ComplExpUtil.deprocess(full);
72
		assertEquals(msg + "lean", resLean, toPseudo(lean));
73
	}
74
75
	private void doTest3(String msg, String data, String result) {
76
		doTest3(msg, data, result, data);
77
	}
78
79
	private void doTest3(String msg, String data, String result, String resLean) {
80
		String full = ComplExpUtil.processTyped(toUT16(data),
81
				IBiDiProcessor.COMMA_DELIMITED);
82
		assertEquals(msg + "full", result, toPseudo(full));
83
		String lean = ComplExpUtil.deprocess(full,
84
				IBiDiProcessor.COMMA_DELIMITED);
85
		assertEquals(msg + "lean", resLean, toPseudo(lean));
86
	}
87
88
	private void doTest4(String msg, String data, int[] offsets, int direction,
89
			boolean affix, String result) {
90
		String txt = msg + "text=" + data + "\n    offsets="
91
				+ array_display(offsets) + "\n    direction=" + direction
92
				+ "\n    affix=" + affix;
93
		String lean = toUT16(data);
94
		String full = ComplExpUtil.insertMarks(lean, offsets, direction, affix);
95
		assertEquals(txt, result, toPseudo(full));
96
	}
97
98
	public void testComplExpUtil() {
99
100
		// Test process() and deprocess() with default delimiters
101
		doTest1("ABC/DEF/G", ">@ABC@/DEF@/G@^");
102
		// Test process() and deprocess() with specified delimiters
103
		doTest2("Util #2.1 - ", "", "");
104
		doTest2("Util #2.2 - ", ">@ABC@^", ">@ABC@^", "ABC");
105
		doTest2("Util #2.3 - ", "abc", "abc");
106
		doTest2("Util #2.4 - ", "!abc", ">@!abc@^");
107
		doTest2("Util #2.5 - ", "abc!", ">@abc!@^");
108
		doTest2("Util #2.6 - ", "ABC*DEF*G", ">@ABC@*DEF@*G@^");
109
		// Test process() and deprocess() with specified expression type
110
		doTest3("Util #3.1 - ", "ABC,DEF,G", ">@ABC@,DEF@,G@^");
111
		doTest3("Util #3.2 - ", "", "");
112
		doTest3("Util #3.3 - ", ">@DEF@^", ">@DEF@^", "DEF");
113
		String str = ComplExpUtil.deprocess(toUT16("ABC,DE"), "wrong_type");
114
		assertEquals("deprocess(9999)", "ABC,DE", toPseudo(str));
115
		str = ComplExpUtil.process("abc", "wrong_type");
116
		assertEquals("invalid type", "abc", toPseudo(str));
117
		// Test insertMarks()
118
		doTest4("Util #4.1 - ", "ABCDEFG", new int[] { 3, 6 }, 0, false,
119
				"ABC@DEF@G");
120
		doTest4("Util #4.2 - ", "ABCDEFG", new int[] { 3, 6 }, 0, true,
121
				">@ABC@DEF@G@^");
122
		doTest4("Util #4.3 - ", "ABCDEFG", new int[] { 3, 6 }, 1, false,
123
				"ABC&DEF&G");
124
		doTest4("Util #4.4 - ", "ABCDEFG", new int[] { 3, 6 }, 1, true,
125
				"<&ABC&DEF&G&^");
126
		doTest4("Util #4.5 - ", "", new int[] { 3, 6 }, 0, false, "");
127
		doTest4("Util #4.6 - ", "", new int[] { 3, 6 }, 0, true, "");
128
		doTest4("Util #4.7 - ", "ABCDEFG", null, 1, false, "ABCDEFG");
129
		doTest4("Util #4.8 - ", "ABCDEFG", null, 1, true, "<&ABCDEFG&^");
130
	}
131
}
(-)src/org/eclipse/equinox/bidi/internal/tests/CxpMathTest.java (+55 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.equinox.bidi.internal.tests;
13
14
import org.eclipse.equinox.bidi.complexp.*;
15
16
/**
17
 * Tests RTL arithmetic
18
 */
19
public class CxpMathTest extends CxpTestBase {
20
21
    static final CxpEnv envLTR = new CxpEnv(null, false, CxpEnv.ORIENT_LTR);
22
    static final CxpEnv envRTL = new CxpEnv(null, false, CxpEnv.ORIENT_RTL);
23
	private CxpHelper helper;
24
25
	protected void setUp() throws Exception {
26
		super.setUp();
27
		helper = new CxpHelper(IProcessorTypes.RTL_ARITHMETIC);
28
	}
29
30
	private void verifyOneLine(String msg, String data, String resLTR,
31
			String resRTL) {
32
		String lean = toUT16(data);
33
		helper.setEnvironment(envLTR);
34
		String fullLTR = helper.leanToFullText(lean);
35
		assertEquals(msg + " LTR - ", resLTR, toPseudo(fullLTR));
36
37
        helper.setEnvironment(envRTL);
38
		String fullRTL = helper.leanToFullText(lean);
39
		assertEquals(msg + " RTL - ", resRTL, toPseudo(fullRTL));
40
	}
41
42
	public void testRTLarithmetic() {
43
		verifyOneLine("Math #0", "", "", "");
44
		verifyOneLine("Math #1", "1+abc", "<&1+abc&^", "1+abc");
45
		verifyOneLine("Math #2", "2+abc-def", "<&2+abc&-def&^", "2+abc&-def");
46
		verifyOneLine("Math #3", "a+3*bc/def", "<&a&+3*bc&/def&^",
47
				"a&+3*bc&/def");
48
		verifyOneLine("Math #4", "4+abc/def", "<&4+abc&/def&^", "4+abc&/def");
49
		verifyOneLine("Math #5", "13ABC", "<&13ABC&^", "13ABC");
50
		verifyOneLine("Math #6", "14ABC-DE", "<&14ABC-DE&^", "14ABC-DE");
51
		verifyOneLine("Math #7", "15ABC+DE", "<&15ABC+DE&^", "15ABC+DE");
52
		verifyOneLine("Math #8", "16ABC*DE", "<&16ABC*DE&^", "16ABC*DE");
53
		verifyOneLine("Math #9", "17ABC/DE", "<&17ABC/DE&^", "17ABC/DE");
54
	}
55
}
(-)src/org/eclipse/equinox/bidi/internal/tests/CxpTest.java (+35 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.equinox.bidi.internal.tests;
12
13
import org.eclipse.equinox.bidi.complexp.*;
14
15
public class CxpTest implements ICxpProcessor {
16
17
    static final CxpFeatures FEATURES = new CxpFeatures("-=.:", 0,  -1, -1, false, false);
18
19
    public CxpFeatures init(CxpHelper ceh, CxpEnv env) {
20
        return FEATURES;
21
    }
22
    
23
    public CxpFeatures init2(CxpHelper ceh, CxpEnv env) {
24
        return FEATURES;
25
    }
26
    
27
    public int indexOfSpecial(CxpHelper ceh, int whichSpecial, String srcText, int fromIndex) {
28
        throw new IllegalStateException();
29
    }
30
    
31
    public int processSpecial(CxpHelper ceh, int whichSpecial, String srcText, int operLocation) {
32
        throw new IllegalStateException();
33
    }
34
35
}
(-)src/org/eclipse/equinox/bidi/internal/tests/CxpTestBase.java (+119 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.equinox.bidi.internal.tests;
13
14
import junit.framework.TestCase;
15
16
/**
17
 * Base functionality for the processor tests.
18
 */
19
public class CxpTestBase extends TestCase {
20
21
    static final private char LRM = 0x200E;
22
    static final private char RLM = 0x200F;
23
    static final private char LRE = 0x202A;
24
    static final private char RLE = 0x202B;
25
    static final private char PDF = 0x202C;
26
27
    public static String toPseudo(String text) {
28
        char[] chars = text.toCharArray();
29
        int len = chars.length;
30
31
        for (int i = 0; i < len; i++) {
32
            char c = chars[i];
33
            if (c >= 'A' && c <= 'Z')
34
                chars[i] = (char) (c + 'a' - 'A');
35
            else if (c >= 0x05D0 && c < 0x05EA)
36
                chars[i] = (char) (c + 'A' - 0x05D0);
37
            else if (c == 0x05EA)
38
                chars[i] = '~';
39
            else if (c == 0x0644)
40
                chars[i] = '#';
41
            else if (c >= 0x0665 && c <= 0x0669)
42
                chars[i] = (char) (c + '5' - 0x0665);
43
            else if (c == LRM)
44
                chars[i] = '@';
45
            else if (c == RLM)
46
                chars[i] = '&';
47
            else if (c == LRE)
48
                chars[i] = '>';
49
            else if (c == RLE)
50
                chars[i] = '<';
51
            else if (c == PDF)
52
                chars[i] = '^';
53
            else if (c == '\n')
54
                chars[i] = '|';
55
            else if (c == '\r')
56
                chars[i] = '`';
57
        }
58
        return new String(chars);
59
    }
60
61
    public static String toUT16(String text) {
62
        char[] chars = text.toCharArray();
63
        int len = chars.length;
64
65
        for (int i = 0; i < len; i++) {
66
            char c = chars[i];
67
            if (c >= '5' && c <= '9')
68
                chars[i] = (char) (0x0665 + c - '5');
69
            else if (c >= 'A' && c <= 'Z')
70
                chars[i] = (char) (0x05D0 + c - 'A');
71
            else if (c == '~')
72
                chars[i] = (char) (0x05EA);
73
            else if (c == '#')
74
                chars[i] = (char) (0x0644);
75
            else if (c == '@')
76
                chars[i] = LRM;
77
            else if (c == '&')
78
                chars[i] = RLM;
79
            else if (c == '>')
80
                chars[i] = LRE;
81
            else if (c == '<')
82
                chars[i] = RLE;
83
            else if (c == '^')
84
                chars[i] = PDF;
85
            else if (c == '|')
86
                chars[i] = '\n';
87
            else if (c == '`')
88
                chars[i] = '\r';
89
        }
90
        return new String(chars);
91
    }
92
93
    static String array_display(int[] array) {
94
        if (array == null) {
95
            return "null";
96
        }
97
        StringBuffer sb = new StringBuffer(50);
98
        int len = array.length;
99
        for (int i = 0; i < len; i++) {
100
            sb.append(array[i]);
101
            sb.append(' ');
102
        }
103
        return sb.toString();
104
    }
105
106
    static boolean arrays_equal(int[] one, int[] two) {
107
        int len = one.length;
108
        if (len != two.length) {
109
            return false;
110
        }
111
        for (int i = 0; i < len; i++) {
112
            if (one[i] != two[i]) {
113
                return false;
114
            }
115
        }
116
        return true;
117
    }
118
119
}
(-)src/org/eclipse/equinox/bidi/internal/tests/CxpUtilTest.java (+141 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.equinox.bidi.internal.tests;
13
14
import org.eclipse.equinox.bidi.complexp.*;
15
import java.util.Locale;
16
17
/**
18
 * Tests methods in CxpUtil
19
 */
20
21
public class CxpUtilTest extends CxpTestBase {
22
23
	private static final String HEBREW = "iw";
24
	private static final String HEBREW2 = "he";
25
	private static final String ARABIC = "ar";
26
	private static final String FARSI = "fa";
27
	private static final String URDU = "ur";
28
	private Locale locale;
29
30
	protected void setUp() throws Exception {
31
		super.setUp();
32
		locale = Locale.getDefault();
33
	}
34
35
	protected void tearDown() {
36
		Locale.setDefault(locale);
37
	}
38
39
	private void doTest1(String data, String result) {
40
		Locale.setDefault(Locale.ENGLISH);
41
		String full = CxpUtil.process(toUT16(data));
42
		assertEquals("Util #1 full EN - ", data, toPseudo(full));
43
		Locale.setDefault(new Locale(HEBREW2));
44
		full = CxpUtil.process(toUT16(data));
45
		assertEquals("Util #1 full HE - ", result, toPseudo(full));
46
		Locale.setDefault(new Locale(ARABIC));
47
		full = CxpUtil.process(toUT16(data));
48
		assertEquals("Util #1 full AR - ", result, toPseudo(full));
49
		Locale.setDefault(new Locale(FARSI));
50
		full = CxpUtil.process(toUT16(data));
51
		assertEquals("Util #1 full FA - ", result, toPseudo(full));
52
		Locale.setDefault(new Locale(URDU));
53
		full = CxpUtil.process(toUT16(data));
54
		assertEquals("Util #1 full UR - ", result, toPseudo(full));
55
		Locale.setDefault(new Locale(HEBREW));
56
		full = CxpUtil.process(toUT16(data));
57
		String ful2 = CxpUtil.process(toUT16(data), null);
58
		assertEquals("Util #1 full - ", result, toPseudo(full));
59
		assertEquals("Util #1 ful2 - ", result, toPseudo(ful2));
60
		String lean = CxpUtil.deprocess(full);
61
		assertEquals("Util #1 lean - ", data, toPseudo(lean));
62
	}
63
64
	private void doTest2(String msg, String data, String result) {
65
		doTest2(msg, data, result, data);
66
	}
67
68
	private void doTest2(String msg, String data, String result, String resLean) {
69
		String full = CxpUtil.process(toUT16(data), "*");
70
		assertEquals(msg + "full", result, toPseudo(full));
71
		String lean = CxpUtil.deprocess(full);
72
		assertEquals(msg + "lean", resLean, toPseudo(lean));
73
	}
74
75
	private void doTest3(String msg, String data, String result) {
76
		doTest3(msg, data, result, data);
77
	}
78
79
	private void doTest3(String msg, String data, String result, String resLean) {
80
		String full = CxpUtil.processTyped(toUT16(data),
81
				IProcessorTypes.COMMA_DELIMITED);
82
		assertEquals(msg + "full", result, toPseudo(full));
83
		String lean = CxpUtil.deprocess(full,
84
				IProcessorTypes.COMMA_DELIMITED);
85
		assertEquals(msg + "lean", resLean, toPseudo(lean));
86
	}
87
88
	private void doTest4(String msg, String data, int[] offsets, int direction,
89
			boolean affix, String result) {
90
		String txt = msg + "text=" + data + "\n    offsets="
91
				+ array_display(offsets) + "\n    direction=" + direction
92
				+ "\n    affix=" + affix;
93
		String lean = toUT16(data);
94
		String full = CxpUtil.insertMarks(lean, offsets, direction, affix);
95
		assertEquals(txt, result, toPseudo(full));
96
	}
97
98
	public void testCxpUtil() {
99
100
		// Test process() and deprocess() with default delimiters
101
		doTest1("ABC/DEF/G", ">@ABC@/DEF@/G@^");
102
		// Test process() and deprocess() with specified delimiters
103
		doTest2("Util #2.1 - ", "", "");
104
		doTest2("Util #2.2 - ", ">@ABC@^", ">@ABC@^", "ABC");
105
		doTest2("Util #2.3 - ", "abc", "abc");
106
		doTest2("Util #2.4 - ", "!abc", ">@!abc@^");
107
		doTest2("Util #2.5 - ", "abc!", ">@abc!@^");
108
		doTest2("Util #2.6 - ", "ABC*DEF*G", ">@ABC@*DEF@*G@^");
109
		// Test process() and deprocess() with specified expression type
110
		doTest3("Util #3.1 - ", "ABC,DEF,G", ">@ABC@,DEF@,G@^");
111
		doTest3("Util #3.2 - ", "", "");
112
		doTest3("Util #3.3 - ", ">@DEF@^", ">@DEF@^", "DEF");
113
		boolean catchFlag = false;
114
		try {
115
		    CxpUtil.deprocess(toUT16("ABC,DE"), "wrong_type");
116
		} catch(IllegalArgumentException e) {
117
		    catchFlag = true;
118
		}
119
		assertTrue("Catch invalid type on deprocess", catchFlag);
120
		catchFlag = false;
121
		try {
122
		    CxpUtil.processTyped("abc", "wrong_type");
123
        } catch(IllegalArgumentException e) {
124
            catchFlag = true;
125
        }
126
        assertTrue("Catch invalid type on process", catchFlag);
127
		// Test insertMarks()
128
		doTest4("Util #4.1 - ", "ABCDEFG", new int[] { 3, 6 }, 0, false,
129
				"ABC@DEF@G");
130
		doTest4("Util #4.2 - ", "ABCDEFG", new int[] { 3, 6 }, 0, true,
131
				">@ABC@DEF@G@^");
132
		doTest4("Util #4.3 - ", "ABCDEFG", new int[] { 3, 6 }, 1, false,
133
				"ABC&DEF&G");
134
		doTest4("Util #4.4 - ", "ABCDEFG", new int[] { 3, 6 }, 1, true,
135
				"<&ABC&DEF&G&^");
136
		doTest4("Util #4.5 - ", "", new int[] { 3, 6 }, 0, false, "");
137
		doTest4("Util #4.6 - ", "", new int[] { 3, 6 }, 0, true, "");
138
		doTest4("Util #4.7 - ", "ABCDEFG", null, 1, false, "ABCDEFG");
139
		doTest4("Util #4.8 - ", "ABCDEFG", null, 1, true, "<&ABCDEFG&^");
140
	}
141
}
(-)src/org/eclipse/equinox/bidi/internal/tests/ExtensibilityTest.java (-36 / +44 lines)
Lines 11-55 Link Here
11
11
12
package org.eclipse.equinox.bidi.internal.tests;
12
package org.eclipse.equinox.bidi.internal.tests;
13
13
14
import junit.framework.TestCase;
14
import org.eclipse.equinox.bidi.complexp.*;
15
16
import org.eclipse.equinox.bidi.complexp.IComplExpProcessor;
17
import org.eclipse.equinox.bidi.complexp.StringProcessor;
18
15
19
/**
16
/**
20
 * Tests contribution of BiDi processors.
17
 * Tests contribution of BiDi processors.
21
 */
18
 */
22
public class ExtensibilityTest extends TestCase {
19
public class ExtensibilityTest extends CxpTestBase {
23
20
24
	public void testBaseContributions() {
21
    public void testBaseContributions() {
25
		String[] types = StringProcessor.getKnownTypes();
22
        String[] types = StringProcessor.getKnownTypes();
26
		assertNotNull(types);
23
        assertNotNull(types);
27
		assertTrue(types.length > 0);
24
        assertTrue(types.length > 0);
28
25
29
		// check one of the types that we know should be there
26
        // check one of the types that we know should be there
30
		assertTrue(isTypePresent(types, "regex"));
27
        assertTrue(isTypePresent(types, "regex"));
31
28
32
		IComplExpProcessor processor = StringProcessor.getProcessor("regex");
29
        ICxpProcessor processor = StringProcessor.getProcessor("regex");
33
		assertNotNull(processor);
30
        assertNotNull(processor);
34
	}
31
    }
35
32
36
	public void testOtherContributions() {
33
    public void testOtherContributions() {
37
		String[] types = StringProcessor.getKnownTypes();
34
        String[] types = StringProcessor.getKnownTypes();
38
		assertNotNull(types);
35
        assertNotNull(types);
39
		assertTrue(types.length > 0);
36
        assertTrue(types.length > 0);
40
37
41
		// check the type added by the test bundle
38
        // check the type added by the test bundle
42
		assertTrue(isTypePresent(types, "test"));
39
        assertTrue(isTypePresent(types, "test"));
43
40
44
		IComplExpProcessor processor = StringProcessor.getProcessor("test");
41
        ICxpProcessor processor = StringProcessor.getProcessor("test");
45
		assertNotNull(processor);
42
        assertNotNull(processor);
46
	}
43
47
44
        processor = StringProcessor.getProcessor("badtest");
48
	private boolean isTypePresent(String[] types, String type) {
45
        assertNull(processor);
49
		for (int i = 0; i < types.length; i++) {
46
50
			if (type.equalsIgnoreCase(types[i]))
47
        CxpHelper helper = new CxpHelper("test");
51
				return true;
48
        String data, lean, full, model;
52
		}
49
        data = "ABC.DEF:HOST-COM=HELLO";
53
		return false;
50
        lean = toUT16(data);
54
	}
51
        full = helper.leanToFullText(lean);
52
        model = "ABC@.DEF@:HOST@-COM@=HELLO";
53
        assertEquals("Test 'test' plugin", model, toPseudo(full));
54
     }
55
56
    private boolean isTypePresent(String[] types, String type) {
57
        for (int i = 0; i < types.length; i++) {
58
            if (type.equalsIgnoreCase(types[i]))
59
                return true;
60
        }
61
        return false;
62
    }
55
}
63
}
(-)src/org/eclipse/equinox/bidi/internal/tests/ExtensionsTest.java (-144 / +132 lines)
Lines 11-29 Link Here
11
11
12
package org.eclipse.equinox.bidi.internal.tests;
12
package org.eclipse.equinox.bidi.internal.tests;
13
13
14
import org.eclipse.equinox.bidi.complexp.IComplExpProcessor;
14
import org.eclipse.equinox.bidi.complexp.*;
15
import org.eclipse.equinox.bidi.complexp.StringProcessor;
16
import org.eclipse.equinox.bidi.complexp.IBiDiProcessor;
17
15
18
/**
16
/**
19
 * Tests all plug-in extensions
17
 * Tests all plug-in extensions
20
 */
18
 */
21
19
22
public class ExtensionsTest extends ComplExpTestBase {
20
public class ExtensionsTest extends CxpTestBase {
23
21
24
	static int state = IComplExpProcessor.STATE_NOTHING_GOING;
22
	static int state = CxpHelper.STATE_NOTHING_GOING;
25
23
26
	private void doTest1(IComplExpProcessor complexp, String label,
24
	private void doTest1(CxpHelper complexp, String label,
27
			String data, String result) {
25
			String data, String result) {
28
		String full;
26
		String full;
29
		full = complexp.leanToFullText(toUT16(data), state);
27
		full = complexp.leanToFullText(toUT16(data), state);
Lines 31-37 Link Here
31
		assertEquals(label + " data = " + data, result, toPseudo(full));
29
		assertEquals(label + " data = " + data, result, toPseudo(full));
32
	}
30
	}
33
31
34
	private void doTest2(IComplExpProcessor complexp, String label,
32
	private void doTest2(CxpHelper complexp, String label,
35
			String data, String result) {
33
			String data, String result) {
36
		String full;
34
		String full;
37
		full = complexp.leanToFullText(data, state);
35
		full = complexp.leanToFullText(data, state);
Lines 41-210 Link Here
41
39
42
	public void testExtensions() {
40
	public void testExtensions() {
43
41
44
		IComplExpProcessor ce;
42
		CxpHelper ceh;
45
43
46
		ce = StringProcessor.getProcessor(IBiDiProcessor.COMMA_DELIMITED);
44
		ceh = new CxpHelper(IProcessorTypes.COMMA_DELIMITED);
47
		assertNotNull(ce);
45
		assertNotNull(ceh);
48
		ce.assumeOrientation(IComplExpProcessor.ORIENT_LTR);
46
		state = CxpHelper.STATE_NOTHING_GOING;
49
		state = IComplExpProcessor.STATE_NOTHING_GOING;
47
		doTest1(ceh, "Comma #1", "ab,cd, AB, CD, EFG", "ab,cd, AB@, CD@, EFG");
50
		doTest1(ce, "Comma #1", "ab,cd, AB, CD, EFG", "ab,cd, AB@, CD@, EFG");
48
51
49
		ceh = new CxpHelper(IProcessorTypes.EMAIL);
52
		ce = StringProcessor.getProcessor(IBiDiProcessor.EMAIL);
50
		assertNotNull(ceh);
53
		assertNotNull(ce);
51
		state = CxpHelper.STATE_NOTHING_GOING;
54
		ce.assumeOrientation(IComplExpProcessor.ORIENT_LTR);
52
		doTest1(ceh, "Email #1", "abc.DEF:GHI", "abc.DEF@:GHI");
55
		state = IComplExpProcessor.STATE_NOTHING_GOING;
53
		doTest1(ceh, "Email #2", "DEF.GHI \"A.B\":JK ", "DEF@.GHI @\"A.B\"@:JK ");
56
		doTest1(ce, "Email #1", "abc.DEF:GHI", "abc.DEF@:GHI");
54
		doTest1(ceh, "Email #3", "DEF,GHI (A,B);JK ", "DEF@,GHI @(A,B)@;JK ");
57
		doTest1(ce, "Email #2", "DEF.GHI \"A.B\":JK ", "DEF@.GHI @\"A.B\"@:JK ");
55
		doTest1(ceh, "Email #4", "DEF.GHI (A.B :JK ", "DEF@.GHI @(A.B :JK ");
58
		doTest1(ce, "Email #3", "DEF,GHI (A,B);JK ", "DEF@,GHI @(A,B)@;JK ");
56
59
		doTest1(ce, "Email #4", "DEF.GHI (A.B :JK ", "DEF@.GHI @(A.B :JK ");
57
		ceh = new CxpHelper(IProcessorTypes.FILE);
60
58
		assertNotNull(ceh);
61
		ce = StringProcessor.getProcessor(IBiDiProcessor.FILE);
59
		state = CxpHelper.STATE_NOTHING_GOING;
62
		assertNotNull(ce);
60
		doTest1(ceh, "File #1", "c:\\A\\B\\FILE.EXT", "c:\\A@\\B@\\FILE@.EXT");
63
		ce.assumeOrientation(IComplExpProcessor.ORIENT_LTR);
61
64
		state = IComplExpProcessor.STATE_NOTHING_GOING;
62
		ceh = new CxpHelper(IProcessorTypes.JAVA);
65
		doTest1(ce, "File #1", "c:\\A\\B\\FILE.EXT", "c:\\A@\\B@\\FILE@.EXT");
63
		assertNotNull(ceh);
66
64
		state = CxpHelper.STATE_NOTHING_GOING;
67
		ce = StringProcessor.getProcessor(IBiDiProcessor.JAVA);
65
		doTest1(ceh, "Java #1", "A = B + C;", "A@ = B@ + C;");
68
		assertNotNull(ce);
66
		doTest1(ceh, "Java #2", "A   = B + C;", "A@   = B@ + C;");
69
		ce.assumeOrientation(IComplExpProcessor.ORIENT_LTR);
67
		doTest1(ceh, "Java #3", "A = \"B+C\"+D;", "A@ = \"B+C\"@+D;");
70
		state = IComplExpProcessor.STATE_NOTHING_GOING;
68
		doTest1(ceh, "Java #4", "A = \"B+C+D;", "A@ = \"B+C+D;");
71
		doTest1(ce, "Java #1", "A = B + C;", "A@ = B@ + C;");
69
		doTest1(ceh, "Java #5", "A = \"B\\\"C\"+D;", "A@ = \"B\\\"C\"@+D;");
72
		doTest1(ce, "Java #2", "A   = B + C;", "A@   = B@ + C;");
70
		doTest1(ceh, "Java #6", "A = /*B+C*/ D;", "A@ = /*B+C*/@ D;");
73
		doTest1(ce, "Java #3", "A = \"B+C\"+D;", "A@ = \"B+C\"@+D;");
71
		doTest1(ceh, "Java #7", "A = /*B+C* D;", "A@ = /*B+C* D;");
74
		doTest1(ce, "Java #4", "A = \"B+C+D;", "A@ = \"B+C+D;");
72
		doTest1(ceh, "Java #8", "X+Y+Z */ B;  ", "X+Y+Z */@ B;  ");
75
		doTest1(ce, "Java #5", "A = \"B\\\"C\"+D;", "A@ = \"B\\\"C\"@+D;");
73
		doTest1(ceh, "Java #9", "A = //B+C* D;", "A@ = //B+C* D;");
76
		doTest1(ce, "Java #6", "A = /*B+C*/ D;", "A@ = /*B+C*/@ D;");
74
		doTest1(ceh, "Java #10", "A = //B+C`|D+E;", "A@ = //B+C`|D@+E;");
77
		doTest1(ce, "Java #7", "A = /*B+C* D;", "A@ = /*B+C* D;");
75
78
		doTest1(ce, "Java #8", "X+Y+Z */ B;  ", "X+Y+Z */@ B;  ");
76
		ceh = new CxpHelper(IProcessorTypes.PROPERTY);
79
		doTest1(ce, "Java #9", "A = //B+C* D;", "A@ = //B+C* D;");
77
		assertNotNull(ceh);
80
		doTest1(ce, "Java #10", "A = //B+C`|D+E;", "A@ = //B+C`|D@+E;");
78
		state = CxpHelper.STATE_NOTHING_GOING;
81
79
		doTest1(ceh, "Property #0", "NAME,VAL1,VAL2", "NAME,VAL1,VAL2");
82
		ce = StringProcessor.getProcessor(IBiDiProcessor.PROPERTY);
80
		doTest1(ceh, "Property #1", "NAME=VAL1,VAL2", "NAME@=VAL1,VAL2");
83
		assertNotNull(ce);
81
		doTest1(ceh, "Property #2", "NAME=VAL1,VAL2=VAL3",
84
		ce.assumeOrientation(IComplExpProcessor.ORIENT_LTR);
85
		state = IComplExpProcessor.STATE_NOTHING_GOING;
86
		doTest1(ce, "Property #0", "NAME,VAL1,VAL2", "NAME,VAL1,VAL2");
87
		doTest1(ce, "Property #1", "NAME=VAL1,VAL2", "NAME@=VAL1,VAL2");
88
		doTest1(ce, "Property #2", "NAME=VAL1,VAL2=VAL3",
89
				"NAME@=VAL1,VAL2=VAL3");
82
				"NAME@=VAL1,VAL2=VAL3");
90
83
91
		String data;
84
		String data;
92
		ce = StringProcessor.getProcessor(IBiDiProcessor.REGEXP);
85
		ceh = new CxpHelper(IProcessorTypes.REGEXP);
93
		assertNotNull(ce);
86
		assertNotNull(ceh);
94
		ce.assumeOrientation(IComplExpProcessor.ORIENT_LTR);
87
		state = CxpHelper.STATE_NOTHING_GOING;
95
		state = IComplExpProcessor.STATE_NOTHING_GOING;
96
		data = toUT16("ABC(?") + "#" + toUT16("DEF)GHI");
88
		data = toUT16("ABC(?") + "#" + toUT16("DEF)GHI");
97
		doTest2(ce, "Regex #0.0", data, "A@B@C@(?#DEF)@G@H@I");
89
		doTest2(ceh, "Regex #0.0", data, "A@B@C@(?#DEF)@G@H@I");
98
		data = toUT16("ABC(?") + "#" + toUT16("DEF");
90
		data = toUT16("ABC(?") + "#" + toUT16("DEF");
99
		doTest2(ce, "Regex #0.1", data, "A@B@C@(?#DEF");
91
		doTest2(ceh, "Regex #0.1", data, "A@B@C@(?#DEF");
100
		doTest1(ce, "Regex #0.2", "GHI)JKL", "GHI)@J@K@L");
92
		doTest1(ceh, "Regex #0.2", "GHI)JKL", "GHI)@J@K@L");
101
		data = toUT16("ABC(?") + "<" + toUT16("DEF") + ">" + toUT16("GHI");
93
		data = toUT16("ABC(?") + "<" + toUT16("DEF") + ">" + toUT16("GHI");
102
		doTest2(ce, "Regex #1", data, "A@B@C@(?<DEF>@G@H@I");
94
		doTest2(ceh, "Regex #1", data, "A@B@C@(?<DEF>@G@H@I");
103
		doTest1(ce, "Regex #2.0", "ABC(?'DEF'GHI", "A@B@C@(?'DEF'@G@H@I");
95
		doTest1(ceh, "Regex #2.0", "ABC(?'DEF'GHI", "A@B@C@(?'DEF'@G@H@I");
104
		doTest1(ce, "Regex #2.1", "ABC(?'DEFGHI", "A@B@C@(?'DEFGHI");
96
		doTest1(ceh, "Regex #2.1", "ABC(?'DEFGHI", "A@B@C@(?'DEFGHI");
105
		data = toUT16("ABC(?(") + "<" + toUT16("DEF") + ">" + toUT16(")GHI");
97
		data = toUT16("ABC(?(") + "<" + toUT16("DEF") + ">" + toUT16(")GHI");
106
		doTest2(ce, "Regex #3", data, "A@B@C@(?(<DEF>)@G@H@I");
98
		doTest2(ceh, "Regex #3", data, "A@B@C@(?(<DEF>)@G@H@I");
107
		doTest1(ce, "Regex #4", "ABC(?('DEF')GHI", "A@B@C@(?('DEF')@G@H@I");
99
		doTest1(ceh, "Regex #4", "ABC(?('DEF')GHI", "A@B@C@(?('DEF')@G@H@I");
108
		doTest1(ce, "Regex #5", "ABC(?(DEF)GHI", "A@B@C@(?(DEF)@G@H@I");
100
		doTest1(ceh, "Regex #5", "ABC(?(DEF)GHI", "A@B@C@(?(DEF)@G@H@I");
109
		data = toUT16("ABC(?") + "&" + toUT16("DEF)GHI");
101
		data = toUT16("ABC(?") + "&" + toUT16("DEF)GHI");
110
		doTest2(ce, "Regex #6", data, "A@B@C@(?&DEF)@G@H@I");
102
		doTest2(ceh, "Regex #6", data, "A@B@C@(?&DEF)@G@H@I");
111
		data = toUT16("ABC(?") + "P<" + toUT16("DEF") + ">" + toUT16("GHI");
103
		data = toUT16("ABC(?") + "P<" + toUT16("DEF") + ">" + toUT16("GHI");
112
		doTest2(ce, "Regex #7", data, "A@B@C(?p<DEF>@G@H@I");
104
		doTest2(ceh, "Regex #7", data, "A@B@C(?p<DEF>@G@H@I");
113
		data = toUT16("ABC\\k") + "<" + toUT16("DEF") + ">" + toUT16("GHI");
105
		data = toUT16("ABC\\k") + "<" + toUT16("DEF") + ">" + toUT16("GHI");
114
		doTest2(ce, "Regex #8", data, "A@B@C\\k<DEF>@G@H@I");
106
		doTest2(ceh, "Regex #8", data, "A@B@C\\k<DEF>@G@H@I");
115
		doTest1(ce, "Regex #9", "ABC\\k'DEF'GHI", "A@B@C\\k'DEF'@G@H@I");
107
		doTest1(ceh, "Regex #9", "ABC\\k'DEF'GHI", "A@B@C\\k'DEF'@G@H@I");
116
		doTest1(ce, "Regex #10", "ABC\\k{DEF}GHI", "A@B@C\\k{DEF}@G@H@I");
108
		doTest1(ceh, "Regex #10", "ABC\\k{DEF}GHI", "A@B@C\\k{DEF}@G@H@I");
117
		data = toUT16("ABC(?") + "P=" + toUT16("DEF)GHI");
109
		data = toUT16("ABC(?") + "P=" + toUT16("DEF)GHI");
118
		doTest2(ce, "Regex #11", data, "A@B@C(?p=DEF)@G@H@I");
110
		doTest2(ceh, "Regex #11", data, "A@B@C(?p=DEF)@G@H@I");
119
		doTest1(ce, "Regex #12", "ABC\\g{DEF}GHI", "A@B@C\\g{DEF}@G@H@I");
111
		doTest1(ceh, "Regex #12", "ABC\\g{DEF}GHI", "A@B@C\\g{DEF}@G@H@I");
120
		data = toUT16("ABC\\g") + "<" + toUT16("DEF") + ">" + toUT16("GHI");
112
		data = toUT16("ABC\\g") + "<" + toUT16("DEF") + ">" + toUT16("GHI");
121
		doTest2(ce, "Regex #13", data, "A@B@C\\g<DEF>@G@H@I");
113
		doTest2(ceh, "Regex #13", data, "A@B@C\\g<DEF>@G@H@I");
122
		doTest1(ce, "Regex #14", "ABC\\g'DEF'GHI", "A@B@C\\g'DEF'@G@H@I");
114
		doTest1(ceh, "Regex #14", "ABC\\g'DEF'GHI", "A@B@C\\g'DEF'@G@H@I");
123
		data = toUT16("ABC(?(") + "R&" + toUT16("DEF)GHI");
115
		data = toUT16("ABC(?(") + "R&" + toUT16("DEF)GHI");
124
		doTest2(ce, "Regex #15", data, "A@B@C(?(r&DEF)@G@H@I");
116
		doTest2(ceh, "Regex #15", data, "A@B@C(?(r&DEF)@G@H@I");
125
		data = toUT16("ABC") + "\\Q" + toUT16("DEF") + "\\E" + toUT16("GHI");
117
		data = toUT16("ABC") + "\\Q" + toUT16("DEF") + "\\E" + toUT16("GHI");
126
		doTest2(ce, "Regex #16.0", data, "A@B@C\\qDEF\\eG@H@I");
118
		doTest2(ceh, "Regex #16.0", data, "A@B@C\\qDEF\\eG@H@I");
127
		data = toUT16("ABC") + "\\Q" + toUT16("DEF");
119
		data = toUT16("ABC") + "\\Q" + toUT16("DEF");
128
		doTest2(ce, "Regex #16.1", data, "A@B@C\\qDEF");
120
		doTest2(ceh, "Regex #16.1", data, "A@B@C\\qDEF");
129
		data = toUT16("GHI") + "\\E" + toUT16("JKL");
121
		data = toUT16("GHI") + "\\E" + toUT16("JKL");
130
		doTest2(ce, "Regex #16.2", data, "GHI\\eJ@K@L");
122
		doTest2(ceh, "Regex #16.2", data, "GHI\\eJ@K@L");
131
		doTest1(ce, "Regex #17.0", "abc[d-h]ijk", "abc[d-h]ijk");
123
		doTest1(ceh, "Regex #17.0", "abc[d-h]ijk", "abc[d-h]ijk");
132
		doTest1(ce, "Regex #17.1", "aBc[d-H]iJk", "aBc[d-H]iJk");
124
		doTest1(ceh, "Regex #17.1", "aBc[d-H]iJk", "aBc[d-H]iJk");
133
		doTest1(ce, "Regex #17.2", "aB*[!-H]iJ2", "aB*[!-@H]iJ@2");
125
		doTest1(ceh, "Regex #17.2", "aB*[!-H]iJ2", "aB*[!-@H]iJ@2");
134
		doTest1(ce, "Regex #17.3", "aB*[1-2]J3", "aB*[@1-2]J@3");
126
		doTest1(ceh, "Regex #17.3", "aB*[1-2]J3", "aB*[@1-2]J@3");
135
		doTest1(ce, "Regex #17.4", "aB*[5-6]J3", "aB*[@5-@6]@J@3");
127
		doTest1(ceh, "Regex #17.4", "aB*[5-6]J3", "aB*[@5-@6]@J@3");
136
		doTest1(ce, "Regex #17.5", "a*[5-6]J3", "a*[5-@6]@J@3");
128
		doTest1(ceh, "Regex #17.5", "a*[5-6]J3", "a*[5-@6]@J@3");
137
		doTest1(ce, "Regex #17.6", "aB*123", "aB*@123");
129
		doTest1(ceh, "Regex #17.6", "aB*123", "aB*@123");
138
		doTest1(ce, "Regex #17.7", "aB*567", "aB*@567");
130
		doTest1(ceh, "Regex #17.7", "aB*567", "aB*@567");
139
131
140
		ce = StringProcessor.getProcessor(IBiDiProcessor.SQL);
132
		ceh = new CxpHelper(IProcessorTypes.SQL);
141
		assertNotNull(ce);
133
		assertNotNull(ceh);
142
		ce.assumeOrientation(IComplExpProcessor.ORIENT_LTR);
134
		state = CxpHelper.STATE_NOTHING_GOING;
143
		state = IComplExpProcessor.STATE_NOTHING_GOING;
135
		doTest1(ceh, "SQL #0", "abc GHI", "abc GHI");
144
		doTest1(ce, "SQL #0", "abc GHI", "abc GHI");
136
		doTest1(ceh, "SQL #1", "abc DEF   GHI", "abc DEF@   GHI");
145
		doTest1(ce, "SQL #1", "abc DEF   GHI", "abc DEF@   GHI");
137
		doTest1(ceh, "SQL #2", "ABC, DEF,   GHI", "ABC@, DEF@,   GHI");
146
		doTest1(ce, "SQL #2", "ABC, DEF,   GHI", "ABC@, DEF@,   GHI");
138
		doTest1(ceh, "SQL #3", "ABC'DEF GHI' JKL,MN", "ABC@'DEF GHI'@ JKL@,MN");
147
		doTest1(ce, "SQL #3", "ABC'DEF GHI' JKL,MN", "ABC@'DEF GHI'@ JKL@,MN");
139
		doTest1(ceh, "SQL #4.0", "ABC'DEF GHI JKL", "ABC@'DEF GHI JKL");
148
		doTest1(ce, "SQL #4.0", "ABC'DEF GHI JKL", "ABC@'DEF GHI JKL");
140
		doTest1(ceh, "SQL #4.1", "MNO PQ' RS,TUV", "MNO PQ'@ RS@,TUV");
149
		doTest1(ce, "SQL #4.1", "MNO PQ' RS,TUV", "MNO PQ'@ RS@,TUV");
141
		doTest1(ceh, "SQL #5", "ABC\"DEF GHI\" JKL,MN",
150
		doTest1(ce, "SQL #5", "ABC\"DEF GHI\" JKL,MN",
151
				"ABC@\"DEF GHI\"@ JKL@,MN");
142
				"ABC@\"DEF GHI\"@ JKL@,MN");
152
		doTest1(ce, "SQL #6", "ABC\"DEF GHI JKL", "ABC@\"DEF GHI JKL");
143
		doTest1(ceh, "SQL #6", "ABC\"DEF GHI JKL", "ABC@\"DEF GHI JKL");
153
		doTest1(ce, "SQL #7", "ABC/*DEF GHI*/ JKL,MN",
144
		doTest1(ceh, "SQL #7", "ABC/*DEF GHI*/ JKL,MN",
154
				"ABC@/*DEF GHI@*/ JKL@,MN");
145
				"ABC@/*DEF GHI@*/ JKL@,MN");
155
		doTest1(ce, "SQL #8.0", "ABC/*DEF GHI JKL", "ABC@/*DEF GHI JKL");
146
		doTest1(ceh, "SQL #8.0", "ABC/*DEF GHI JKL", "ABC@/*DEF GHI JKL");
156
		doTest1(ce, "SQL #8.1", "MNO PQ*/RS,TUV", "MNO PQ@*/RS@,TUV");
147
		doTest1(ceh, "SQL #8.1", "MNO PQ*/RS,TUV", "MNO PQ@*/RS@,TUV");
157
		doTest1(ce, "SQL #9", "ABC--DEF GHI JKL", "ABC@--DEF GHI JKL");
148
		doTest1(ceh, "SQL #9", "ABC--DEF GHI JKL", "ABC@--DEF GHI JKL");
158
		doTest1(ce, "SQL #10", "ABC--DEF--GHI,JKL", "ABC@--DEF--GHI,JKL");
149
		doTest1(ceh, "SQL #10", "ABC--DEF--GHI,JKL", "ABC@--DEF--GHI,JKL");
159
		doTest1(ce, "SQL #11", "ABC'DEF '' G I' JKL,MN",
150
		doTest1(ceh, "SQL #11", "ABC'DEF '' G I' JKL,MN",
160
				"ABC@'DEF '' G I'@ JKL@,MN");
151
				"ABC@'DEF '' G I'@ JKL@,MN");
161
		doTest1(ce, "SQL #12", "ABC\"DEF \"\" G I\" JKL,MN",
152
		doTest1(ceh, "SQL #12", "ABC\"DEF \"\" G I\" JKL,MN",
162
				"ABC@\"DEF \"\" G I\"@ JKL@,MN");
153
				"ABC@\"DEF \"\" G I\"@ JKL@,MN");
163
		doTest1(ce, "SQL #13", "ABC--DEF GHI`|JKL MN", "ABC@--DEF GHI`|JKL@ MN");
154
		doTest1(ceh, "SQL #13", "ABC--DEF GHI`|JKL MN", "ABC@--DEF GHI`|JKL@ MN");
164
155
165
		ce = StringProcessor.getProcessor(IBiDiProcessor.SYSTEM_USER);
156
		ceh = new CxpHelper(IProcessorTypes.SYSTEM_USER);
166
		assertNotNull(ce);
157
		assertNotNull(ceh);
167
		ce.assumeOrientation(IComplExpProcessor.ORIENT_LTR);
158
		state = CxpHelper.STATE_NOTHING_GOING;
168
		state = IComplExpProcessor.STATE_NOTHING_GOING;
159
		doTest1(ceh, "System #1", "HOST(JACK)", "HOST@(JACK)");
169
		doTest1(ce, "System #1", "HOST(JACK)", "HOST@(JACK)");
160
170
161
		ceh = new CxpHelper(IProcessorTypes.UNDERSCORE);
171
		ce = StringProcessor.getProcessor(IBiDiProcessor.UNDERSCORE);
162
		assertNotNull(ceh);
172
		assertNotNull(ce);
163
		state = CxpHelper.STATE_NOTHING_GOING;
173
		ce.assumeOrientation(IComplExpProcessor.ORIENT_LTR);
164
		doTest1(ceh, "Underscore #1", "A_B_C_d_e_F_G", "A@_B@_C_d_e_F@_G");
174
		state = IComplExpProcessor.STATE_NOTHING_GOING;
165
175
		doTest1(ce, "Underscore #1", "A_B_C_d_e_F_G", "A@_B@_C_d_e_F@_G");
166
		ceh = new CxpHelper(IProcessorTypes.URL);
176
167
		assertNotNull(ceh);
177
		ce = StringProcessor.getProcessor(IBiDiProcessor.URL);
168
		state = CxpHelper.STATE_NOTHING_GOING;
178
		assertNotNull(ce);
169
		doTest1(ceh, "URL #1", "WWW.DOMAIN.COM/DIR1/DIR2/dir3/DIR4",
179
		state = IComplExpProcessor.STATE_NOTHING_GOING;
180
		ce.assumeOrientation(IComplExpProcessor.ORIENT_LTR);
181
		doTest1(ce, "URL #1", "WWW.DOMAIN.COM/DIR1/DIR2/dir3/DIR4",
182
				"WWW@.DOMAIN@.COM@/DIR1@/DIR2/dir3/DIR4");
170
				"WWW@.DOMAIN@.COM@/DIR1@/DIR2/dir3/DIR4");
183
171
184
		ce = StringProcessor.getProcessor(IBiDiProcessor.XPATH);
172
		ceh = new CxpHelper(IProcessorTypes.XPATH);
185
		assertNotNull(ce);
173
		assertNotNull(ceh);
186
		ce.assumeOrientation(IComplExpProcessor.ORIENT_LTR);
174
		state = CxpHelper.STATE_NOTHING_GOING;
187
		state = IComplExpProcessor.STATE_NOTHING_GOING;
175
		doTest1(ceh, "Xpath #1", "abc(DEF)GHI", "abc(DEF@)GHI");
188
		doTest1(ce, "Xpath #1", "abc(DEF)GHI", "abc(DEF@)GHI");
176
		doTest1(ceh, "Xpath #2", "DEF.GHI \"A.B\":JK ", "DEF@.GHI@ \"A.B\"@:JK ");
189
		doTest1(ce, "Xpath #2", "DEF.GHI \"A.B\":JK ", "DEF@.GHI@ \"A.B\"@:JK ");
177
		doTest1(ceh, "Xpath #3", "DEF!GHI 'A!B'=JK ", "DEF@!GHI@ 'A!B'@=JK ");
190
		doTest1(ce, "Xpath #3", "DEF!GHI 'A!B'=JK ", "DEF@!GHI@ 'A!B'@=JK ");
178
		doTest1(ceh, "Xpath #4", "DEF.GHI 'A.B :JK ", "DEF@.GHI@ 'A.B :JK ");
191
		doTest1(ce, "Xpath #4", "DEF.GHI 'A.B :JK ", "DEF@.GHI@ 'A.B :JK ");
179
192
180
		ceh = new CxpHelper(IProcessorTypes.EMAIL);
193
		ce = StringProcessor.getProcessor(IBiDiProcessor.EMAIL);
181
		state = CxpHelper.STATE_NOTHING_GOING;
194
		state = IComplExpProcessor.STATE_NOTHING_GOING;
182
		CxpFeatures f1 = ceh.getFeatures();
195
		String operators = ce.getOperators();
183
		assertEquals("<>.:,;@", f1.operators);
196
		assertEquals("<>.:,;@", operators);
184
		CxpFeatures f2 = new CxpFeatures("+-*/", f1.specialsCount, f1.dirArabic, f1.dirHebrew, f1.ignoreArabic, f1.ignoreHebrew);
197
		ce.setOperators("+-*/");
185
		ceh.setFeatures(f2);
198
		doTest1(ce, "DelimsEsc #1", "abc+DEF-GHI", "abc+DEF@-GHI");
186
		doTest1(ceh, "DelimsEsc #1", "abc+DEF-GHI", "abc+DEF@-GHI");
199
		doTest1(ce, "DelimsEsc #2", "DEF-GHI (A*B)/JK ", "DEF@-GHI @(A*B)@/JK ");
187
		doTest1(ceh, "DelimsEsc #2", "DEF-GHI (A*B)/JK ", "DEF@-GHI @(A*B)@/JK ");
200
		doTest1(ce, "DelimsEsc #3", "DEF-GHI (A*B)/JK ", "DEF@-GHI @(A*B)@/JK ");
188
		doTest1(ceh, "DelimsEsc #3", "DEF-GHI (A*B)/JK ", "DEF@-GHI @(A*B)@/JK ");
201
		doTest1(ce, "DelimsEsc #4", "DEF-GHI (A*B\\)*C) /JK ",
189
		doTest1(ceh, "DelimsEsc #4", "DEF-GHI (A*B\\)*C) /JK ",
202
				"DEF@-GHI @(A*B\\)*C) @/JK ");
190
				"DEF@-GHI @(A*B\\)*C) @/JK ");
203
		doTest1(ce, "DelimsEsc #5", "DEF-GHI (A\\\\\\)*C) /JK ",
191
		doTest1(ceh, "DelimsEsc #5", "DEF-GHI (A\\\\\\)*C) /JK ",
204
				"DEF@-GHI @(A\\\\\\)*C) @/JK ");
192
				"DEF@-GHI @(A\\\\\\)*C) @/JK ");
205
		doTest1(ce, "DelimsEsc #6", "DEF-GHI (A\\\\)*C /JK ",
193
		doTest1(ceh, "DelimsEsc #6", "DEF-GHI (A\\\\)*C /JK ",
206
				"DEF@-GHI @(A\\\\)@*C @/JK ");
194
				"DEF@-GHI @(A\\\\)@*C @/JK ");
207
		doTest1(ce, "DelimsEsc #7", "DEF-GHI (A\\)*C /JK ",
195
		doTest1(ceh, "DelimsEsc #7", "DEF-GHI (A\\)*C /JK ",
208
				"DEF@-GHI @(A\\)*C /JK ");
196
				"DEF@-GHI @(A\\)*C /JK ");
209
	}
197
	}
210
}
198
}
(-)src/org/eclipse/equinox/bidi/internal/tests/FullToLeanTest.java (-32 / +31 lines)
Lines 11-35 Link Here
11
11
12
package org.eclipse.equinox.bidi.internal.tests;
12
package org.eclipse.equinox.bidi.internal.tests;
13
13
14
import org.eclipse.equinox.bidi.complexp.IComplExpProcessor;
14
import org.eclipse.equinox.bidi.complexp.*;
15
import org.eclipse.equinox.bidi.complexp.StringProcessor;
16
import org.eclipse.equinox.bidi.complexp.IBiDiProcessor;
17
15
18
/**
16
/**
19
 * Tests fullToLean method
17
 * Tests fullToLean method
20
 */
18
 */
21
19
22
public class FullToLeanTest extends ComplExpTestBase {
20
public class FullToLeanTest extends CxpTestBase {
23
21
24
	private IComplExpProcessor processor;
22
    static final CxpEnv envLTR = new CxpEnv(null, false, CxpEnv.ORIENT_LTR);
23
    static final CxpEnv envRTL = new CxpEnv(null, false, CxpEnv.ORIENT_RTL);
24
    private CxpHelper helper;
25
25
26
	protected void setUp() throws Exception {
26
	protected void setUp() throws Exception {
27
		super.setUp();
27
		super.setUp();
28
		processor = StringProcessor
28
		helper = new CxpHelper(IProcessorTypes.COMMA_DELIMITED);
29
				.getProcessor(IBiDiProcessor.COMMA_DELIMITED);
30
	}
29
	}
31
30
32
	static int[] getpos(IComplExpProcessor complexp, boolean leanToFull) {
31
	static int[] getpos(CxpHelper complexp, boolean leanToFull) {
33
		int[] pos = new int[5];
32
		int[] pos = new int[5];
34
33
35
		if (leanToFull) {
34
		if (leanToFull) {
Lines 55-83 Link Here
55
		int[] pos;
54
		int[] pos;
56
55
57
		text = toUT16(data);
56
		text = toUT16(data);
58
		processor.assumeOrientation(IComplExpProcessor.ORIENT_LTR);
57
		helper.setEnvironment(envLTR);
59
		lean = processor.fullToLeanText(text);
58
		lean = helper.fullToLeanText(text);
60
		assertEquals(msg + "LTR lean", leanLTR, toPseudo(lean));
59
		assertEquals(msg + "LTR lean", leanLTR, toPseudo(lean));
61
		full = processor.leanToFullText(lean);
60
		full = helper.leanToFullText(lean);
62
		assertEquals(msg + "LTR full", fullLTR, toPseudo(full));
61
		assertEquals(msg + "LTR full", fullLTR, toPseudo(full));
63
		pos = getpos(processor, true);
62
		pos = getpos(helper, true);
64
		label = msg + "leanToFullPos() LTR, expected="
63
		label = msg + "leanToFullPos() LTR, expected="
65
				+ array_display(l2fPosLTR) + " result=" + array_display(pos);
64
				+ array_display(l2fPosLTR) + " result=" + array_display(pos);
66
		assertTrue(label, arrays_equal(l2fPosLTR, pos));
65
		assertTrue(label, arrays_equal(l2fPosLTR, pos));
67
		pos = getpos(processor, false);
66
		pos = getpos(helper, false);
68
		label = msg + "fullToLeanPos() LTR, expected="
67
		label = msg + "fullToLeanPos() LTR, expected="
69
				+ array_display(f2lPosLTR) + " result=" + array_display(pos);
68
				+ array_display(f2lPosLTR) + " result=" + array_display(pos);
70
		assertTrue(label, arrays_equal(f2lPosLTR, pos));
69
		assertTrue(label, arrays_equal(f2lPosLTR, pos));
71
		processor.assumeOrientation(IComplExpProcessor.ORIENT_RTL);
70
		helper.setEnvironment(envRTL);
72
		lean = processor.fullToLeanText(text);
71
		lean = helper.fullToLeanText(text);
73
		assertEquals(msg + "RTL lean", leanRTL, toPseudo(lean));
72
		assertEquals(msg + "RTL lean", leanRTL, toPseudo(lean));
74
		full = processor.leanToFullText(lean);
73
		full = helper.leanToFullText(lean);
75
		assertEquals(msg + "RTL full", fullRTL, toPseudo(full));
74
		assertEquals(msg + "RTL full", fullRTL, toPseudo(full));
76
		pos = getpos(processor, true);
75
		pos = getpos(helper, true);
77
		label = msg + "leanToFullPos() RTL, expected="
76
		label = msg + "leanToFullPos() RTL, expected="
78
				+ array_display(l2fPosRTL) + " result=" + array_display(pos);
77
				+ array_display(l2fPosRTL) + " result=" + array_display(pos);
79
		assertTrue(label, arrays_equal(l2fPosRTL, pos));
78
		assertTrue(label, arrays_equal(l2fPosRTL, pos));
80
		pos = getpos(processor, false);
79
		pos = getpos(helper, false);
81
		label = msg + "fullToLeanPos() RTL, expected="
80
		label = msg + "fullToLeanPos() RTL, expected="
82
				+ array_display(f2lPosRTL) + " result=" + array_display(pos);
81
				+ array_display(f2lPosRTL) + " result=" + array_display(pos);
83
		assertTrue(label, arrays_equal(f2lPosRTL, pos));
82
		assertTrue(label, arrays_equal(f2lPosRTL, pos));
Lines 87-123 Link Here
87
		String text, data, full, lean, model;
86
		String text, data, full, lean, model;
88
		int state, state2, state3;
87
		int state, state2, state3;
89
88
90
		processor = StringProcessor.getProcessor(IBiDiProcessor.SQL);
89
		helper = new CxpHelper(IProcessorTypes.SQL);
91
		processor.assumeOrientation(IComplExpProcessor.ORIENT_LTR);
90
		helper.setEnvironment(envLTR);
92
		data = "update \"AB_CDE\" set \"COL1\"@='01', \"COL2\"@='02' /* GH IJK";
91
		data = "update \"AB_CDE\" set \"COL1\"@='01', \"COL2\"@='02' /* GH IJK";
93
		text = toUT16(data);
92
		text = toUT16(data);
94
		lean = processor.fullToLeanText(text);
93
		lean = helper.fullToLeanText(text);
95
		state = processor.getFinalState();
94
		state = helper.getFinalState();
96
		model = "update \"AB_CDE\" set \"COL1\"='01', \"COL2\"='02' /* GH IJK";
95
		model = "update \"AB_CDE\" set \"COL1\"='01', \"COL2\"='02' /* GH IJK";
97
		assertEquals(msg + "LTR lean", model, toPseudo(lean));
96
		assertEquals(msg + "LTR lean", model, toPseudo(lean));
98
		full = processor.leanToFullText(lean);
97
		full = helper.leanToFullText(lean);
99
		assertEquals(msg + "LTR full", data, toPseudo(full));
98
		assertEquals(msg + "LTR full", data, toPseudo(full));
100
		assertEquals(msg + "state from leanToFullText", processor
99
		assertEquals(msg + "state from leanToFullText", helper
101
				.getFinalState(), state);
100
				.getFinalState(), state);
102
		data = "THIS IS A COMMENT LINE";
101
		data = "THIS IS A COMMENT LINE";
103
		text = toUT16(data);
102
		text = toUT16(data);
104
		lean = processor.fullToLeanText(text, state);
103
		lean = helper.fullToLeanText(text, state);
105
		state2 = processor.getFinalState();
104
		state2 = helper.getFinalState();
106
		model = "THIS IS A COMMENT LINE";
105
		model = "THIS IS A COMMENT LINE";
107
		assertEquals(msg + "LTR lean2", model, toPseudo(lean));
106
		assertEquals(msg + "LTR lean2", model, toPseudo(lean));
108
		full = processor.leanToFullText(lean, state);
107
		full = helper.leanToFullText(lean, state);
109
		assertEquals(msg + "LTR full2", data, toPseudo(full));
108
		assertEquals(msg + "LTR full2", data, toPseudo(full));
110
		assertEquals(msg + "state from leanToFullText2", processor
109
		assertEquals(msg + "state from leanToFullText2", helper
111
				.getFinalState(), state2);
110
				.getFinalState(), state2);
112
		data = "SOME MORE */ where \"COL3\"@=123";
111
		data = "SOME MORE */ where \"COL3\"@=123";
113
		text = toUT16(data);
112
		text = toUT16(data);
114
		lean = processor.fullToLeanText(text, state2);
113
		lean = helper.fullToLeanText(text, state2);
115
		state3 = processor.getFinalState();
114
		state3 = helper.getFinalState();
116
		model = "SOME MORE */ where \"COL3\"=123";
115
		model = "SOME MORE */ where \"COL3\"=123";
117
		assertEquals(msg + "LTR lean3", model, toPseudo(lean));
116
		assertEquals(msg + "LTR lean3", model, toPseudo(lean));
118
		full = processor.leanToFullText(lean, state2);
117
		full = helper.leanToFullText(lean, state2);
119
		assertEquals(msg + "LTR full3", data, toPseudo(full));
118
		assertEquals(msg + "LTR full3", data, toPseudo(full));
120
		assertEquals(msg + "state from leanToFullText3", processor
119
		assertEquals(msg + "state from leanToFullText3", helper
121
				.getFinalState(), state3);
120
				.getFinalState(), state3);
122
	}
121
	}
123
122
(-)src/org/eclipse/equinox/bidi/internal/tests/MethodsTest.java (-419 / +357 lines)
Lines 11-438 Link Here
11
11
12
package org.eclipse.equinox.bidi.internal.tests;
12
package org.eclipse.equinox.bidi.internal.tests;
13
13
14
import org.eclipse.equinox.bidi.complexp.IComplExpProcessor;
14
import org.eclipse.equinox.bidi.complexp.*;
15
import org.eclipse.equinox.bidi.complexp.IBiDiProcessor;
16
import org.eclipse.equinox.bidi.complexp.StringProcessor;
17
import org.eclipse.equinox.bidi.complexp.ComplExpUtil;
18
15
19
/**
16
/**
20
 * Tests most public methods of ComplExpBasic
17
 * Tests most public methods of CxpHelper
21
 */
18
 */
22
19
23
public class MethodsTest extends ComplExpTestBase {
20
public class MethodsTest extends CxpTestBase {
24
21
25
	final static int LTR = IComplExpProcessor.DIRECTION_LTR;
22
    final static int LTR = CxpFeatures.DIR_LTR;
26
	final static int RTL = IComplExpProcessor.DIRECTION_RTL;
23
    final static int RTL = CxpFeatures.DIR_RTL;
27
24
    final static CxpEnv envLTR = new CxpEnv(null, false, CxpEnv.ORIENT_LTR);
28
	IComplExpProcessor processor;
25
    final static CxpEnv envRTL = new CxpEnv(null, false, CxpEnv.ORIENT_RTL);
29
26
    final static CxpEnv envRTLMIR = new CxpEnv(null, true, CxpEnv.ORIENT_RTL);
30
	private void doTestTools() {
27
    final static CxpEnv envIGN = new CxpEnv(null, false, CxpEnv.ORIENT_IGNORE);
31
28
    final static CxpEnv envCLR = new CxpEnv(null, false, CxpEnv.ORIENT_CONTEXTUAL_LTR);
32
		// This method tests utility methods used by the JUnits
29
    final static CxpEnv envCRL = new CxpEnv(null, false, CxpEnv.ORIENT_CONTEXTUAL_RTL);
33
		String data = "56789ABCDEFGHIJKLMNOPQRSTUVWXYZ~#@&><^|`";
30
    final static CxpEnv envERR = new CxpEnv(null, false, 9999);
34
		String text = toUT16(data);
31
35
		String dat2 = toPseudo(text);
32
    CxpHelper helper;
36
		assertEquals(data, dat2);
33
37
34
    private void doTestTools() {
38
		text = toPseudo(data);
35
39
		assertEquals("56789abcdefghijklmnopqrstuvwxyz~#@&><^|`", text);
36
        // This method tests utility methods used by the JUnits
40
37
        String data = "56789ABCDEFGHIJKLMNOPQRSTUVWXYZ~#@&><^|`";
41
		int[] arA = new int[] { 1, 2 };
38
        String text = toUT16(data);
42
		int[] arB = new int[] { 3, 4, 5 };
39
        String dat2 = toPseudo(text);
43
		assertFalse(arrays_equal(arA, arB));
40
        assertEquals(data, dat2);
44
41
45
		assertTrue(arrays_equal(arA, arA));
42
        text = toPseudo(data);
46
43
        assertEquals("56789abcdefghijklmnopqrstuvwxyz~#@&><^|`", text);
47
		arB = new int[] { 3, 4 };
44
48
		assertFalse(arrays_equal(arA, arB));
45
        int[] arA = new int[] { 1, 2 };
49
46
        int[] arB = new int[] { 3, 4, 5 };
50
		int[][] ar2A = new int[][] { { 1 }, { 1, 2 }, { 1, 2, 3 } };
47
        assertFalse(arrays_equal(arA, arB));
51
		int[][] ar2B = new int[][] { { 1 }, { 1, 2 } };
48
52
		assertTrue(arrays2_equal(ar2A, ar2A));
49
        assertTrue(arrays_equal(arA, arA));
53
50
54
		assertFalse(arrays2_equal(ar2A, ar2B));
51
        arB = new int[] { 3, 4 };
55
52
        assertFalse(arrays_equal(arA, arB));
56
		ar2B = new int[][] { { 1 }, { 1, 2 }, { 1, 2, 3, 4 } };
53
57
		assertFalse(arrays2_equal(ar2A, ar2B));
54
        text = array_display(null);
58
55
        assertEquals("null", text);
59
		ar2B = new int[][] { { 1 }, { 1, 2 }, { 1, 2, 4 } };
56
    }
60
		assertFalse(arrays2_equal(ar2A, ar2B));
57
61
58
    private void doTestState() {
62
		text = array_display(null);
59
        String data, lean, full, model;
63
		assertEquals("null", text);
60
        int state;
64
61
65
		text = array2_display(null);
62
        data = "A=B+C;/* D=E+F;";
66
		assertEquals("null", text);
63
        lean = toUT16(data);
67
	}
64
        full = helper.leanToFullText(lean);
68
65
        model = "A@=B@+C@;/* D=E+F;";
69
	private void doTestState() {
66
        assertEquals("full1", model, toPseudo(full));
70
		String data, lean, full, model;
67
        state = helper.getFinalState();
71
		int state;
68
        data = "A=B+C; D=E+F;";
72
69
        lean = toUT16(data);
73
		data = "A=B+C;/* D=E+F;";
70
        full = helper.leanToFullText(lean, state);
74
		lean = toUT16(data);
71
        model = "A=B+C; D=E+F;";
75
		full = processor.leanToFullText(lean);
72
        assertEquals("full2", model, toPseudo(full));
76
		model = "A@=B@+C@;/* D=E+F;";
73
        state = helper.getFinalState();
77
		assertEquals("full1", model, toPseudo(full));
74
        data = "A=B+C;*/ D=E+F;";
78
		state = processor.getFinalState();
75
        lean = toUT16(data);
79
		data = "A=B+C; D=E+F;";
76
        full = helper.leanToFullText(lean, state);
80
		lean = toUT16(data);
77
        model = "A=B+C;*/@ D@=E@+F;";
81
		full = processor.leanToFullText(lean, state);
78
        assertEquals("full3", model, toPseudo(full));
82
		model = "A=B+C; D=E+F;";
79
    }
83
		assertEquals("full2", model, toPseudo(full));
80
84
		state = processor.getFinalState();
81
    private void doTestOrientation() {
85
		data = "A=B+C;*/ D=E+F;";
82
        int orient;
86
		lean = toUT16(data);
83
87
		full = processor.leanToFullText(lean, state);
84
        helper = new CxpHelper(IProcessorTypes.COMMA_DELIMITED);
88
		model = "A=B+C;*/@ D@=E@+F;";
85
        orient = helper.getEnvironment().orientation;
89
		assertEquals("full3", model, toPseudo(full));
86
        assertEquals("orient #1", CxpEnv.ORIENT_LTR, orient);
90
	}
87
91
88
        helper.setEnvironment(envIGN);
92
	private void doTestOrientation() {
89
        orient = helper.getEnvironment().orientation;
93
		int orient;
90
        assertEquals("orient #2", CxpEnv.ORIENT_IGNORE, orient);
94
91
95
		processor = StringProcessor
92
        helper.setEnvironment(envCRL);
96
				.getProcessor(IBiDiProcessor.COMMA_DELIMITED);
93
        orient = helper.getEnvironment().orientation;
97
		orient = processor.recallOrientation();
94
        helper.leanToFullText("--!**");
98
		// TBD: the following test cannot succeed with the current
95
        assertEquals("orient #3", CxpEnv.ORIENT_CONTEXTUAL_RTL, orient);
99
		// implementation.
96
100
		// it will need allocating separate data for each processor use.
97
        helper.setEnvironment(envERR);
101
		// assertEquals("orient #1", IComplExpProcessor.ORIENT_LTR, orient);
98
        orient = helper.getEnvironment().orientation;
102
99
        helper.leanToFullText("--!**");
103
		processor.assumeOrientation(IComplExpProcessor.ORIENT_IGNORE);
100
        assertEquals("orient #4", CxpEnv.ORIENT_UNKNOWN, orient);
104
		orient = processor.recallOrientation();
101
    }
105
		assertEquals("orient #2", IComplExpProcessor.ORIENT_IGNORE, orient);
102
106
103
    private void doTestOrient(CxpFeatures f, String label, String data, String resLTR,
107
		processor.assumeOrientation(IComplExpProcessor.ORIENT_CONTEXTUAL_RTL);
104
            String resRTL, String resCon) {
108
		orient = processor.recallOrientation();
105
        String full, lean;
109
		processor.leanToFullText("--!**");
106
110
		assertEquals("orient #3", IComplExpProcessor.ORIENT_CONTEXTUAL_RTL,
107
        lean = toUT16(data);
111
				orient);
108
        helper.setEnvironment(envLTR);
112
109
        helper.setFeatures(f);
113
		processor.assumeOrientation(9999);
110
        full = helper.leanToFullText(lean);
114
		orient = processor.recallOrientation();
111
        assertEquals(label + "LTR full", resLTR, toPseudo(full));
115
		processor.leanToFullText("--!**");
112
        helper.setEnvironment(envRTL);
116
		assertEquals("orient #4", IComplExpProcessor.ORIENT_UNKNOWN, orient);
113
        helper.setFeatures(f);
117
	}
114
        full = helper.leanToFullText(lean);
118
115
        assertEquals("label + RTL full", resRTL, toPseudo(full));
119
	private void doTestOrient(String label, String data, String resLTR,
116
        helper.setEnvironment(envCRL);
120
			String resRTL, String resCon) {
117
        helper.setFeatures(f);
121
		String full, lean;
118
        full = helper.leanToFullText(lean);
122
119
        assertEquals(label + "CON full", resCon, toPseudo(full));
123
		lean = toUT16(data);
120
    }
124
		processor.assumeOrientation(IComplExpProcessor.ORIENT_LTR);
121
125
		full = processor.leanToFullText(lean);
122
    private void doTestScripts() {
126
		assertEquals(label + "LTR full", resLTR, toPseudo(full));
123
        CxpFeatures f2, f1 = helper.getFeatures();
127
		processor.assumeOrientation(IComplExpProcessor.ORIENT_RTL);
124
        boolean flag;
128
		full = processor.leanToFullText(lean);
125
        flag = f1.ignoreArabic;
129
		assertEquals("label + RTL full", resRTL, toPseudo(full));
126
        assertFalse("Ignores Arabic 1", flag);
130
		processor.assumeOrientation(IComplExpProcessor.ORIENT_CONTEXTUAL_RTL);
127
        flag = f1.ignoreHebrew;
131
		full = processor.leanToFullText(lean);
128
        assertFalse("Ignores Hebrew 1", flag);
132
		assertEquals(label + "CON full", resCon, toPseudo(full));
129
133
	}
130
        f2 = new CxpFeatures(f1.operators, 0, -1, -1, true, true);
134
131
        flag = f2.ignoreArabic;
135
	private void doTestScripts() {
132
        assertTrue("Ignores Arabic 2", flag);
136
		boolean flag;
133
        flag = f2.ignoreHebrew;
137
		flag = processor.handlesArabicScript();
134
        assertTrue("Ignores Hebrew 2", flag);
138
		assertTrue("Handles Arabic 1", flag);
135
        doTestOrient(f2, "Scripts #1 ", "BCD,EF", "BCD,EF", ">@BCD,EF@^", "@BCD,EF");
139
		flag = processor.handlesHebrewScript();
136
        f2 = new CxpFeatures(f1.operators, 0, -1, -1, false, true);
140
		assertTrue("Handles Hebrew 1", flag);
137
        flag = f2.ignoreArabic;
141
138
        assertFalse("Ignores Arabic 3", flag);
142
		processor.selectBidiScript(false, false);
139
        flag = f2.ignoreHebrew;
143
		flag = processor.handlesArabicScript();
140
        assertTrue("Ignores Hebrew 3", flag);
144
		assertFalse("Handles Arabic 2", flag);
141
        doTestOrient(f2, "Scripts #2 ", "d,EF", "d,EF", ">@d,EF@^", "d,EF");
145
		flag = processor.handlesHebrewScript();
142
        doTestOrient(f2, "Scripts #3 ", "#,eF", "#,eF", ">@#,eF@^", "@#,eF");
146
		assertFalse("Handles Hebrew 2", flag);
143
        doTestOrient(f2, "Scripts #4 ", "#,12", "#@,12", ">@#@,12@^", "@#@,12");
147
		doTestOrient("Scripts #1 ", "BCD,EF", "BCD,EF", ">@BCD,EF@^", "@BCD,EF");
144
        doTestOrient(f2, "Scripts #5 ", "#,##", "#@,##", ">@#@,##@^", "@#@,##");
148
		processor.selectBidiScript(true, false);
145
        doTestOrient(f2, "Scripts #6 ", "#,89", "#@,89", ">@#@,89@^", "@#@,89");
149
		flag = processor.handlesArabicScript();
146
        doTestOrient(f2, "Scripts #7 ", "#,ef", "#,ef", ">@#,ef@^", "@#,ef");
150
		assertTrue("Handles Arabic 3", flag);
147
        doTestOrient(f2, "Scripts #8 ", "#,", "#,", ">@#,@^", "@#,");
151
		flag = processor.handlesHebrewScript();
148
        doTestOrient(f2, "Scripts #9 ", "9,ef", "9,ef", ">@9,ef@^", "9,ef");
152
		assertFalse("Handles Hebrew 3", flag);
149
        doTestOrient(f2, "Scripts #10 ", "9,##", "9@,##", ">@9@,##@^", "9@,##");
153
		doTestOrient("Scripts #2 ", "d,EF", "d,EF", ">@d,EF@^", "d,EF");
150
        doTestOrient(f2, "Scripts #11 ", "7,89", "7@,89", ">@7@,89@^", "7@,89");
154
		doTestOrient("Scripts #3 ", "#,eF", "#,eF", ">@#,eF@^", "@#,eF");
151
        doTestOrient(f2, "Scripts #12 ", "7,EF", "7,EF", ">@7,EF@^", "@7,EF");
155
		doTestOrient("Scripts #4 ", "#,12", "#@,12", ">@#@,12@^", "@#@,12");
152
        doTestOrient(f2, "Scripts #13 ", "BCD,EF", "BCD,EF", ">@BCD,EF@^",
156
		doTestOrient("Scripts #5 ", "#,##", "#@,##", ">@#@,##@^", "@#@,##");
153
                "@BCD,EF");
157
		doTestOrient("Scripts #6 ", "#,89", "#@,89", ">@#@,89@^", "@#@,89");
154
158
		doTestOrient("Scripts #7 ", "#,ef", "#,ef", ">@#,ef@^", "@#,ef");
155
        f2 = new CxpFeatures(f1.operators, 0, -1, -1, true, false);
159
		doTestOrient("Scripts #8 ", "#,", "#,", ">@#,@^", "@#,");
156
        flag = f2.ignoreArabic;
160
		doTestOrient("Scripts #9 ", "9,ef", "9,ef", ">@9,ef@^", "9,ef");
157
        assertTrue("Ignores Arabic 4", flag);
161
		doTestOrient("Scripts #10 ", "9,##", "9@,##", ">@9@,##@^", "9@,##");
158
        flag = f2.ignoreHebrew;
162
		doTestOrient("Scripts #11 ", "7,89", "7@,89", ">@7@,89@^", "7@,89");
159
        assertFalse("Ignores Hebrew 4", flag);
163
		doTestOrient("Scripts #12 ", "7,EF", "7,EF", ">@7,EF@^", "@7,EF");
160
        doTestOrient(f2, "Scripts #14 ", "BCd,EF", "BCd,EF", ">@BCd,EF@^",
164
		doTestOrient("Scripts #13 ", "BCD,EF", "BCD,EF", ">@BCD,EF@^",
161
                "@BCd,EF");
165
				"@BCD,EF");
162
        doTestOrient(f2, "Scripts #15 ", "BCD,eF", "BCD,eF", ">@BCD,eF@^",
166
163
                "@BCD,eF");
167
		processor.selectBidiScript(false, true);
164
        doTestOrient(f2, "Scripts #16 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^",
168
		flag = processor.handlesArabicScript();
165
                "@BCD@,EF");
169
		assertFalse("Handles Arabic 4", flag);
166
        doTestOrient(f2, "Scripts #17 ", "BCD,12", "BCD@,12", ">@BCD@,12@^",
170
		flag = processor.handlesHebrewScript();
167
                "@BCD@,12");
171
		assertTrue("Handles Hebrew 4", flag);
168
        doTestOrient(f2, "Scripts #18 ", "BCD,", "BCD,", ">@BCD,@^", "@BCD,");
172
		doTestOrient("Scripts #14 ", "BCd,EF", "BCd,EF", ">@BCd,EF@^",
169
173
				"@BCd,EF");
170
        f2 = new CxpFeatures(f1.operators, 0, -1, -1, false, false);
174
		doTestOrient("Scripts #15 ", "BCD,eF", "BCD,eF", ">@BCD,eF@^",
171
        doTestOrient(f2, "Scripts #19 ", "123,45|67", "123,45|67", ">@123,45|67@^",
175
				"@BCD,eF");
172
                "@123,45|67");
176
		doTestOrient("Scripts #16 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^",
173
        doTestOrient(f2, "Scripts #20 ", "5,e", "5,e", ">@5,e@^", "5,e");
177
				"@BCD@,EF");
174
        doTestOrient(f2, "Scripts #21 ", "5,#", "5@,#", ">@5@,#@^", "5@,#");
178
		doTestOrient("Scripts #17 ", "BCD,12", "BCD@,12", ">@BCD@,12@^",
175
        doTestOrient(f2, "Scripts #22 ", "5,6", "5@,6", ">@5@,6@^", "5@,6");
179
				"@BCD@,12");
176
        doTestOrient(f2, "Scripts #23 ", "5,D", "5@,D", ">@5@,D@^", "5@,D");
180
		doTestOrient("Scripts #18 ", "BCD,", "BCD,", ">@BCD,@^", "@BCD,");
177
        doTestOrient(f2, "Scripts #24 ", "5,--", "5,--", ">@5,--@^", "@5,--");
181
178
    }
182
		processor.selectBidiScript(true, true);
179
183
		doTestOrient("Scripts #19 ", "123,45|67", "123,45|67", ">@123,45|67@^",
180
    private void doTestLeanOffsets() {
184
				"@123,45|67");
181
        String lean, data, label;
185
		doTestOrient("Scripts #20 ", "5,e", "5,e", ">@5,e@^", "5,e");
182
        int state;
186
		doTestOrient("Scripts #21 ", "5,#", "5@,#", ">@5@,#@^", "5@,#");
183
        int[] offsets;
187
		doTestOrient("Scripts #22 ", "5,6", "5@,6", ">@5@,6@^", "5@,6");
184
        int[] model;
188
		doTestOrient("Scripts #23 ", "5,D", "5@,D", ">@5@,D@^", "5@,D");
185
189
		doTestOrient("Scripts #24 ", "5,--", "5,--", ">@5,--@^", "@5,--");
186
        data = "A=B+C;/* D=E+F;";
190
	}
187
        lean = toUT16(data);
191
188
        helper.leanToFullText(lean);
192
	private void doTestLeanOffsets() {
189
        offsets = helper.leanBidiCharOffsets();
193
		String lean, data, label;
190
        model = new int[] { 1, 3, 5 };
194
		int state;
191
        label = "leanBidiCharOffsets() #1 expected=" + array_display(model)
195
		int[] offsets;
192
                + " result=" + array_display(offsets);
196
		int[] model;
193
        assertTrue(label, arrays_equal(model, offsets));
197
194
        state = helper.getFinalState();
198
		data = "A=B+C;/* D=E+F;";
195
        data = "A=B+C;*/ D=E+F;";
199
		lean = toUT16(data);
196
        lean = toUT16(data);
200
		offsets = processor.leanBidiCharOffsets(lean);
197
        helper.leanToFullText(lean, state);
201
		model = new int[] { 1, 3, 5 };
198
        offsets = helper.leanBidiCharOffsets();
202
		label = "leanBidiCharOffsets() #1 expected=" + array_display(model)
199
        model = new int[] { 8, 10, 12 };
203
				+ " result=" + array_display(offsets);
200
        label = "leanBidiCharOffsets() #2 expected=" + array_display(model)
204
		assertTrue(label, arrays_equal(model, offsets));
201
                + " result=" + array_display(offsets);
205
		state = processor.getFinalState();
202
        assertTrue(label, arrays_equal(model, offsets));
206
		data = "A=B+C;*/ D=E+F;";
203
        offsets = helper.leanBidiCharOffsets();
207
		lean = toUT16(data);
204
        model = new int[] { 8, 10, 12 };
208
		offsets = processor.leanBidiCharOffsets(lean, state);
205
        label = "leanBidiCharOffsets() #3 expected=" + array_display(model)
209
		model = new int[] { 8, 10, 12 };
206
                + " result=" + array_display(offsets);
210
		label = "leanBidiCharOffsets() #2 expected=" + array_display(model)
207
        assertTrue(label, arrays_equal(model, offsets));
211
				+ " result=" + array_display(offsets);
208
    }
212
		assertTrue(label, arrays_equal(model, offsets));
209
213
		offsets = processor.leanBidiCharOffsets();
210
    private void doTestFullOffsets(String label, String data, int[] resLTR,
214
		model = new int[] { 8, 10, 12 };
211
            int[] resRTL, int[] resCon) {
215
		label = "leanBidiCharOffsets() #3 expected=" + array_display(model)
212
        String full, lean, msg;
216
				+ " result=" + array_display(offsets);
213
        int[] offsets;
217
		assertTrue(label, arrays_equal(model, offsets));
214
218
	}
215
        lean = toUT16(data);
219
216
        helper.setEnvironment(envLTR);
220
	private void doTestFullOffsets(String label, String data, int[] resLTR,
217
        full = helper.leanToFullText(lean);
221
			int[] resRTL, int[] resCon) {
218
        // the following line avoids a compiler warning about full never being
222
		String full, lean, msg;
219
        // read
223
		int[] offsets;
220
        full += "";
224
221
        offsets = helper.fullBidiCharOffsets();
225
		lean = toUT16(data);
222
        msg = label + "LTR expected=" + array_display(resLTR) + " result="
226
		processor.assumeOrientation(IComplExpProcessor.ORIENT_LTR);
223
                + array_display(offsets);
227
		full = processor.leanToFullText(lean);
224
        assertTrue(msg, arrays_equal(resLTR, offsets));
228
		// the following line avoids a compiler warning about full never being
225
        helper.setEnvironment(envRTL);
229
		// read
226
        full = helper.leanToFullText(lean);
230
		full += "";
227
        offsets = helper.fullBidiCharOffsets();
231
		offsets = processor.fullBidiCharOffsets();
228
        msg = label + "RTL expected=" + array_display(resRTL) + " result="
232
		msg = label + "LTR expected=" + array_display(resLTR) + " result="
229
                + array_display(offsets);
233
				+ array_display(offsets);
230
        assertTrue(msg, arrays_equal(resRTL, offsets));
234
		assertTrue(msg, arrays_equal(resLTR, offsets));
231
        helper.setEnvironment(envCLR);
235
		processor.assumeOrientation(IComplExpProcessor.ORIENT_RTL);
232
        full = helper.leanToFullText(lean);
236
		full = processor.leanToFullText(lean);
233
        offsets = helper.fullBidiCharOffsets();
237
		offsets = processor.fullBidiCharOffsets();
234
        msg = label + "CON expected=" + array_display(resCon) + " result="
238
		msg = label + "RTL expected=" + array_display(resRTL) + " result="
235
                + array_display(offsets);
239
				+ array_display(offsets);
236
        assertTrue(msg, arrays_equal(resCon, offsets));
240
		assertTrue(msg, arrays_equal(resRTL, offsets));
237
    }
241
		processor.assumeOrientation(IComplExpProcessor.ORIENT_CONTEXTUAL_LTR);
238
242
		full = processor.leanToFullText(lean);
239
    private void doTestMirrored() {
243
		offsets = processor.fullBidiCharOffsets();
240
        boolean mirrored;
244
		msg = label + "CON expected=" + array_display(resCon) + " result="
241
245
				+ array_display(offsets);
242
        helper = new CxpHelper(IProcessorTypes.COMMA_DELIMITED);
246
		assertTrue(msg, arrays_equal(resCon, offsets));
243
        mirrored = helper.getEnvironment().mirrored;
247
	}
244
        assertFalse("mirrored #1", mirrored);
248
245
        CxpEnv env = new CxpEnv(null, true, CxpEnv.ORIENT_LTR);
249
	private void doTestMirrored() {
246
        helper = new CxpHelper(IProcessorTypes.COMMA_DELIMITED, env);
250
		boolean mirrored;
247
        mirrored = helper.getEnvironment().mirrored;
251
248
        assertTrue("mirrored #2", mirrored);
252
		mirrored = ComplExpUtil.isMirroredDefault();
249
    }
253
		assertFalse("mirrored #1", mirrored);
250
254
		processor = StringProcessor
251
    private void doTestDirection() {
255
				.getProcessor(IBiDiProcessor.COMMA_DELIMITED);
252
        String data, lean, full, model, msg;
256
		mirrored = processor.isMirrored();
253
257
		assertFalse("mirrored #2", mirrored);
254
        helper = new CxpHelper(IProcessorTypes.COMMA_DELIMITED);
258
		ComplExpUtil.assumeMirroredDefault(true);
255
        CxpFeatures f1 = helper.getFeatures();
259
		mirrored = ComplExpUtil.isMirroredDefault();
256
        msg = "TestDirection #1";
260
		assertTrue("mirrored #3", mirrored);
257
        assertTrue(msg, f1.dirArabic == LTR && f1.dirHebrew == LTR);
261
		processor = StringProcessor
258
262
				.getProcessor(IBiDiProcessor.COMMA_DELIMITED);
259
        CxpFeatures f2 = new CxpFeatures(f1.operators, 0, RTL, RTL, false, false);
263
		mirrored = processor.isMirrored();
260
        helper.setFeatures(f2);
264
		// TBD: the following test cannot succeed with the current
261
        f1 = helper.getFeatures();
265
		// implementation.
262
        msg = "TestDirection #2";
266
		// it will need allocating separate data for each processor use.
263
        assertTrue(msg, f1.dirArabic == RTL && f1.dirHebrew == RTL);
267
		// assertTrue("mirrored #4", mirrored);
264
268
		processor.assumeMirrored(false);
265
        CxpEnv env = new CxpEnv(null, false, CxpEnv.ORIENT_LTR);
269
		mirrored = processor.isMirrored();
266
        helper = new CxpHelper(IProcessorTypes.EMAIL, env);
270
		assertFalse("mirrored #5", mirrored);
267
        f1 = helper.getFeatures();
271
	}
268
        msg = "TestDirection #3";
272
269
        assertTrue(msg, f1.dirArabic == LTR && f1.dirHebrew == LTR);
273
	private void doTestDirection() {
270
        data = "#ABC.#DEF:HOST.com";
274
		int[][] dir;
271
        lean = toUT16(data);
275
		int[][] modir;
272
        full = helper.leanToFullText(lean);
276
		String data, lean, full, model, msg;
273
        model = "#ABC@.#DEF@:HOST.com";
277
274
        assertEquals("TestDirection #9 full", model, toPseudo(full));
278
		processor = StringProcessor
275
279
				.getProcessor(IBiDiProcessor.COMMA_DELIMITED);
276
        data = "ABC.DEF:HOST.com";
280
		dir = processor.getDirection();
277
        lean = toUT16(data);
281
		modir = new int[][] { { LTR, LTR }, { LTR, LTR } };
278
        full = helper.leanToFullText(lean);
282
		msg = "TestDirection #1 expected=" + array2_display(modir) + " result="
279
        model = "ABC@.DEF@:HOST.com";
283
				+ array2_display(dir);
280
        assertEquals("TestDirection #10 full", model, toPseudo(full));
284
		assertTrue(msg, arrays2_equal(modir, dir));
281
285
282
        env = new CxpEnv(null, true, CxpEnv.ORIENT_LTR);
286
		processor.setDirection(RTL);
283
        helper.setEnvironment(env);
287
		dir = processor.getDirection();
284
        f1 = helper.getFeatures();
288
		modir = new int[][] { { RTL, RTL }, { RTL, RTL } };
285
        msg = "TestDirection #10.5";
289
		msg = "TestDirection #2 expected=" + array2_display(modir) + " result="
286
        assertTrue(msg, f1.dirArabic == RTL && f1.dirHebrew == LTR);
290
				+ array2_display(dir);
287
        data = "#ABC.#DEF:HOST.com";
291
		assertTrue(msg, arrays2_equal(modir, dir));
288
        lean = toUT16(data);
292
289
        full = helper.leanToFullText(lean);
293
		processor.setDirection(LTR, RTL);
290
        model = "<&#ABC.#DEF:HOST.com&^";
294
		dir = processor.getDirection();
291
        assertEquals("TestDirection #11 full", model, toPseudo(full));
295
		modir = new int[][] { { LTR, RTL }, { LTR, RTL } };
292
296
		msg = "TestDirection #3 expected=" + array2_display(modir) + " result="
293
        data = "#ABc.#DEF:HOSt.COM";
297
				+ array2_display(dir);
294
        lean = toUT16(data);
298
		assertTrue(msg, arrays2_equal(modir, dir));
295
        full = helper.leanToFullText(lean);
299
296
        model = "<&#ABc.#DEF:HOSt.COM&^";
300
		processor.setArabicDirection(RTL);
297
        assertEquals("TestDirection #12 full", model, toPseudo(full));
301
		dir = processor.getDirection();
298
302
		modir = new int[][] { { RTL, RTL }, { LTR, RTL } };
299
        data = "#ABc.#DEF:HOSt.";
303
		msg = "TestDirection #4 expected=" + array2_display(modir) + " result="
300
        lean = toUT16(data);
304
				+ array2_display(dir);
301
        full = helper.leanToFullText(lean);
305
		assertTrue(msg, arrays2_equal(modir, dir));
302
        model = "<&#ABc.#DEF:HOSt.&^";
306
303
        assertEquals("TestDirection #13 full", model, toPseudo(full));
307
		processor.setArabicDirection(RTL, LTR);
304
308
		dir = processor.getDirection();
305
        data = "ABC.DEF:HOST.com";
309
		modir = new int[][] { { RTL, LTR }, { LTR, RTL } };
306
        lean = toUT16(data);
310
		msg = "TestDirection #5 expected=" + array2_display(modir) + " result="
307
        full = helper.leanToFullText(lean);
311
				+ array2_display(dir);
308
        model = "ABC@.DEF@:HOST.com";
312
		assertTrue(msg, arrays2_equal(modir, dir));
309
        assertEquals("TestDirection #14 full", model, toPseudo(full));
313
310
314
		processor.setHebrewDirection(RTL);
311
        data = "--.---:----";
315
		dir = processor.getDirection();
312
        lean = toUT16(data);
316
		modir = new int[][] { { RTL, LTR }, { RTL, RTL } };
313
        full = helper.leanToFullText(lean);
317
		msg = "TestDirection #6 expected=" + array2_display(modir) + " result="
314
        model = "--.---:----";
318
				+ array2_display(dir);
315
        assertEquals("TestDirection #15 full", model, toPseudo(full));
319
		assertTrue(msg, arrays2_equal(modir, dir));
316
320
317
        data = "ABC.|DEF:HOST.com";
321
		processor.setHebrewDirection(RTL, LTR);
318
        lean = toUT16(data);
322
		dir = processor.getDirection();
319
        full = helper.leanToFullText(lean);
323
		modir = new int[][] { { RTL, LTR }, { RTL, LTR } };
320
        model = "ABC.|DEF@:HOST.com";
324
		msg = "TestDirection #7 expected=" + array2_display(modir) + " result="
321
        assertEquals("TestDirection #16 full", model, toPseudo(full));
325
				+ array2_display(dir);
322
326
		assertTrue(msg, arrays2_equal(modir, dir));
323
        helper.setEnvironment(envRTLMIR);
327
324
        data = "#ABc.|#DEF:HOST.com";
328
		processor = StringProcessor.getProcessor(IBiDiProcessor.EMAIL);
325
        lean = toUT16(data);
329
		processor.assumeMirrored(false);
326
        full = helper.leanToFullText(lean);
330
		processor.setArabicDirection(LTR, RTL);
327
        model = "#ABc.|#DEF:HOST.com";
331
		processor.setHebrewDirection(LTR, LTR);
328
        assertEquals("TestDirection #17 full", model, toPseudo(full));
332
		data = "#ABC.#DEF:HOST.com";
329
        assertEquals("Test curDirection", RTL, helper.getCurDirection());
333
		lean = toUT16(data);
330
    }
334
		full = processor.leanToFullText(lean);
331
335
		model = "#ABC@.#DEF@:HOST.com";
332
    public void testMethods() {
336
		assertEquals("TestDirection #9 full", model, toPseudo(full));
333
337
334
        doTestTools();
338
		data = "ABC.DEF:HOST.com";
335
339
		lean = toUT16(data);
336
        helper = new CxpHelper(IProcessorTypes.JAVA);
340
		full = processor.leanToFullText(lean);
337
        doTestState();
341
		model = "ABC@.DEF@:HOST.com";
338
342
		assertEquals("TestDirection #10 full", model, toPseudo(full));
339
        doTestOrientation();
343
340
344
		processor.assumeMirrored(true);
341
        helper = new CxpHelper(IProcessorTypes.COMMA_DELIMITED);
345
		data = "#ABC.#DEF:HOST.com";
342
        CxpFeatures f2 = helper.getFeatures();
346
		lean = toUT16(data);
343
        doTestOrient(f2, "Methods #1 ", "", "", "", "");
347
		full = processor.leanToFullText(lean);
344
        doTestOrient(f2, "Methods #2 ", "abc", "abc", ">@abc@^", "abc");
348
		model = "<&#ABC.#DEF:HOST.com&^";
345
        doTestOrient(f2, "Methods #3 ", "ABC", "ABC", ">@ABC@^", "@ABC");
349
		assertEquals("TestDirection #11 full", model, toPseudo(full));
346
        doTestOrient(f2, "Methods #4 ", "bcd,ef", "bcd,ef", ">@bcd,ef@^", "bcd,ef");
350
347
        doTestOrient(f2, "Methods #5 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^",
351
		data = "#ABc.#DEF:HOSt.COM";
348
                "@BCD@,EF");
352
		lean = toUT16(data);
349
        doTestOrient(f2, "Methods #6 ", "cde,FG", "cde,FG", ">@cde,FG@^", "cde,FG");
353
		full = processor.leanToFullText(lean);
350
        doTestOrient(f2, "Methods #7 ", "CDE,fg", "CDE,fg", ">@CDE,fg@^", "@CDE,fg");
354
		model = "<&#ABc.#DEF:HOSt.COM&^";
351
        doTestOrient(f2, "Methods #8 ", "12..def,GH", "12..def,GH",
355
		assertEquals("TestDirection #12 full", model, toPseudo(full));
352
                ">@12..def,GH@^", "12..def,GH");
356
353
        doTestOrient(f2, "Methods #9 ", "34..DEF,gh", "34..DEF,gh",
357
		data = "#ABc.#DEF:HOSt.";
354
                ">@34..DEF,gh@^", "@34..DEF,gh");
358
		lean = toUT16(data);
355
359
		full = processor.leanToFullText(lean);
356
        doTestScripts();
360
		model = "<&#ABc.#DEF:HOSt.&^";
357
361
		assertEquals("TestDirection #13 full", model, toPseudo(full));
358
        helper = new CxpHelper(IProcessorTypes.JAVA);
362
359
        doTestLeanOffsets();
363
		data = "ABC.DEF:HOST.com";
360
364
		lean = toUT16(data);
361
        helper = new CxpHelper(IProcessorTypes.COMMA_DELIMITED);
365
		full = processor.leanToFullText(lean);
362
        doTestFullOffsets("TestFullOffsets ", "BCD,EF,G", new int[] { 3, 7 },
366
		model = "ABC@.DEF@:HOST.com";
363
                new int[] { 0, 1, 5, 9, 12, 13 }, new int[] { 0, 4, 8 });
367
		assertEquals("TestDirection #14 full", model, toPseudo(full));
364
368
365
        doTestMirrored();
369
		data = "--.---:----";
366
370
		lean = toUT16(data);
367
        doTestDirection();
371
		full = processor.leanToFullText(lean);
368
372
		model = "--.---:----";
369
        helper = new CxpHelper(IProcessorTypes.COMMA_DELIMITED);
373
		assertEquals("TestDirection #15 full", model, toPseudo(full));
370
        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";
374
371
        String lean = toUT16(data);
375
		data = "ABC.|DEF:HOST.com";
372
        String full = helper.leanToFullText(lean);
376
		lean = toUT16(data);
373
        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";
377
		full = processor.leanToFullText(lean);
374
        assertEquals("many inserts", model, toPseudo(full));
378
		model = "ABC.|DEF@:HOST.com";
375
    }
379
		assertEquals("TestDirection #16 full", model, toPseudo(full));
380
381
		processor.assumeOrientation(IComplExpProcessor.ORIENT_RTL);
382
		data = "#ABc.|#DEF:HOST.com";
383
		lean = toUT16(data);
384
		full = processor.leanToFullText(lean);
385
		model = "#ABc.|#DEF:HOST.com";
386
		assertEquals("TestDirection #17 full", model, toPseudo(full));
387
	}
388
389
	public void testMethods() {
390
391
		doTestTools();
392
393
		processor = StringProcessor.getProcessor(IBiDiProcessor.JAVA);
394
		doTestState();
395
396
		doTestOrientation();
397
398
		processor = StringProcessor
399
				.getProcessor(IBiDiProcessor.COMMA_DELIMITED);
400
		doTestOrient("Methods #1 ", "", "", "", "");
401
		doTestOrient("Methods #2 ", "abc", "abc", ">@abc@^", "abc");
402
		doTestOrient("Methods #3 ", "ABC", "ABC", ">@ABC@^", "@ABC");
403
		doTestOrient("Methods #4 ", "bcd,ef", "bcd,ef", ">@bcd,ef@^", "bcd,ef");
404
		doTestOrient("Methods #5 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^",
405
				"@BCD@,EF");
406
		doTestOrient("Methods #6 ", "cde,FG", "cde,FG", ">@cde,FG@^", "cde,FG");
407
		doTestOrient("Methods #7 ", "CDE,fg", "CDE,fg", ">@CDE,fg@^", "@CDE,fg");
408
		doTestOrient("Methods #8 ", "12..def,GH", "12..def,GH",
409
				">@12..def,GH@^", "12..def,GH");
410
		doTestOrient("Methods #9 ", "34..DEF,gh", "34..DEF,gh",
411
				">@34..DEF,gh@^", "@34..DEF,gh");
412
413
		doTestScripts();
414
415
		processor = StringProcessor.getProcessor(IBiDiProcessor.JAVA);
416
		doTestLeanOffsets();
417
418
		processor = StringProcessor
419
				.getProcessor(IBiDiProcessor.COMMA_DELIMITED);
420
		doTestFullOffsets("TestFullOffsets ", "BCD,EF,G", new int[] { 3, 7 },
421
				new int[] { 0, 1, 5, 9, 12, 13 }, new int[] { 0, 4, 8 });
422
423
		doTestMirrored();
424
425
		doTestDirection();
426
427
		processor = StringProcessor
428
				.getProcessor(IBiDiProcessor.COMMA_DELIMITED);
429
		processor.assumeOrientation(IComplExpProcessor.ORIENT_LTR);
430
		processor.setDirection(LTR);
431
		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";
432
		String lean = toUT16(data);
433
		String full = processor.leanToFullText(lean);
434
		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";
435
		assertEquals("many inserts", model, toPseudo(full));
436
437
	}
438
}
376
}
(-)src/org/eclipse/equinox/bidi/internal/tests/NullProcessorTest.java (+60 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.equinox.bidi.internal.tests;
13
14
import org.eclipse.equinox.bidi.complexp.*;
15
16
/**
17
 * Tests RTL arithmetic
18
 */
19
public class NullProcessorTest extends CxpTestBase {
20
21
    static final int[] EMPTY_INT_ARRAY = new int[0];
22
23
    private CxpHelper helper;
24
25
    protected void setUp() throws Exception {
26
        super.setUp();
27
        helper = new CxpHelper();
28
    }
29
30
    public void testNullProcessor() {
31
        String full = helper.leanToFullText("abc");
32
        assertEquals("leanToFullText", "abc", full);
33
        full = helper.leanToFullText("abc", 3);
34
        assertEquals("leanToFullText with state", "abc", full);
35
        int[] offsets = helper.leanBidiCharOffsets();
36
        assertTrue("leanBidiCharOffsets", arrays_equal(offsets, EMPTY_INT_ARRAY));
37
        offsets = helper.fullBidiCharOffsets();
38
        assertTrue("fullBidiCharOffsets", arrays_equal(offsets, EMPTY_INT_ARRAY));
39
        String lean = helper.fullToLeanText("abc");
40
        assertEquals("fullToLeanText", "abc", lean);
41
        lean = helper.fullToLeanText("abc", 3);
42
        assertEquals("fullToLeanText with state", "abc", lean);
43
        int state = helper.getFinalState();
44
        assertEquals("getFinalState", CxpHelper.STATE_NOTHING_GOING, state);
45
        int pos = helper.leanToFullPos(13);
46
        assertEquals("leanToFullPos", 13, pos);
47
        pos = helper.fullToLeanPos(15);
48
        assertEquals("fullToLeanPos", 15, pos);
49
        assertEquals("getDirProp", Character.DIRECTIONALITY_UNDEFINED,
50
                     helper.getDirProp(123));
51
        int direction = helper.getCurDirection();
52
        assertEquals("getCurDirection", CxpFeatures.DIR_LTR, direction);
53
        CxpEnv env = helper.getEnvironment();
54
        assertEquals("getEnvironment", CxpEnv.DEFAULT, env);
55
        helper.setEnvironment(env);
56
        CxpFeatures features = helper.getFeatures();
57
        assertEquals("getFeatures", CxpFeatures.DEFAULT, features);
58
        helper.setFeatures(features);
59
    }
60
}
(-)src/org/eclipse/equinox/bidi/internal/tests/SomeMoreTest.java (+93 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.equinox.bidi.internal.tests;
13
14
import org.eclipse.equinox.bidi.complexp.*;
15
16
/**
17
 * Tests some weird cases
18
 */
19
20
public class SomeMoreTest extends CxpTestBase {
21
22
    final static CxpEnv env1 = new CxpEnv("en_US", false, CxpEnv.ORIENT_LTR);
23
    final static CxpEnv env2 = new CxpEnv("he", false, CxpEnv.ORIENT_LTR);
24
    final static CxpFeatures features1 = new CxpFeatures(null, 1, -1, -1, false, false);
25
26
    CxpHelper helper;
27
28
    class Proc1 extends CxpProcessor {
29
30
        public CxpFeatures init(CxpHelper ceh, CxpEnv env) {
31
            return features1;
32
        }
33
        public int indexOfSpecial(CxpHelper ceh, int whichSpecial, String srcText, int fromIndex) {
34
            return fromIndex;
35
        }
36
        public int processSpecial(CxpHelper ceh, int whichSpecial, String srcText, int operLocation) {
37
            int len = srcText.length();
38
            for (int i = len - 1; i >= 0; i--) {
39
                ceh.insertMark(i);
40
                ceh.insertMark(i);
41
            }
42
            return len;
43
        }
44
    }
45
46
    class Proc2 extends CxpProcessor {
47
48
        public CxpFeatures init(CxpHelper ceh, CxpEnv env) {
49
            return features1;
50
        }
51
    }
52
53
    class Proc3 extends CxpProcessor {
54
55
        public CxpFeatures init(CxpHelper ceh, CxpEnv env) {
56
            return features1;
57
        }
58
        public int indexOfSpecial(CxpHelper ceh, int whichSpecial, String srcText, int fromIndex) {
59
            return 0;
60
        }
61
    }
62
63
    public void testSomeMore() {
64
        assertFalse(env1.isBidi());
65
        assertTrue(env2.isBidi());
66
67
        ICxpProcessor proc = new Proc1();
68
        helper = new CxpHelper(proc, env1);
69
        String full = toPseudo(helper.leanToFullText("abcd"));
70
        assertEquals("@a@b@c@d", full);
71
72
        proc = new Proc2();
73
        helper = new CxpHelper(proc, env1);
74
        boolean catchFlag = false;
75
        try {
76
            full = toPseudo(helper.leanToFullText("abcd"));
77
        } catch(IllegalStateException e) {
78
            catchFlag = true;
79
        }
80
        assertTrue("Catch missing indexOfSpecial", catchFlag);
81
82
        proc = new Proc3();
83
        helper = new CxpHelper(proc, env1);
84
        catchFlag = false;
85
        try {
86
            full = toPseudo(helper.leanToFullText("abcd"));
87
        } catch(IllegalStateException e) {
88
            catchFlag = true;
89
        }
90
        assertTrue("Catch missing processSpecial", catchFlag);
91
    }
92
93
}
(-)src/org/eclipse/equinox/bidi/tests/BiDiTestSuite.java (-34 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.equinox.bidi.tests;
13
14
import org.eclipse.equinox.bidi.internal.tests.*;
15
16
import junit.framework.Test;
17
import junit.framework.TestSuite;
18
19
public class BiDiTestSuite extends TestSuite {
20
	public static Test suite() {
21
		return new BiDiTestSuite();
22
	}
23
24
	public BiDiTestSuite() {
25
		addTestSuite(ExtensibilityTest.class);
26
		addTestSuite(MethodsTest.class);
27
		// addTestSuite(TestDoNothing.class);
28
		addTestSuite(FullToLeanTest.class);
29
		addTestSuite(ComplExpMathTest.class);
30
		// TBD: TestSubclass
31
		addTestSuite(ExtensionsTest.class);
32
		addTestSuite(ComplExpUtilTest.class);
33
	}
34
}
(-)src/org/eclipse/equinox/bidi/tests/CxpTestSuite.java (+34 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.equinox.bidi.tests;
13
14
import org.eclipse.equinox.bidi.internal.tests.*;
15
16
import junit.framework.Test;
17
import junit.framework.TestSuite;
18
19
public class CxpTestSuite extends TestSuite {
20
	public static Test suite() {
21
		return new CxpTestSuite();
22
	}
23
24
	public CxpTestSuite() {
25
		addTestSuite(ExtensibilityTest.class);
26
		addTestSuite(MethodsTest.class);
27
		addTestSuite(NullProcessorTest.class);
28
		addTestSuite(FullToLeanTest.class);
29
        addTestSuite(ExtensionsTest.class);
30
		addTestSuite(CxpMathTest.class);
31
        addTestSuite(SomeMoreTest.class);
32
		addTestSuite(CxpUtilTest.class);
33
	}
34
}

Return to bug 183164