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

Collapse All | Expand All

(-)src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java (-3 / +3 lines)
Lines 11-19 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.STextHandler;
14
import org.eclipse.equinox.bidi.STextProcessorFactory;
15
import org.eclipse.equinox.bidi.STextProcessorFactory;
15
16
import org.eclipse.equinox.bidi.STextEngine;
17
import org.eclipse.equinox.bidi.custom.STextProcessor;
16
import org.eclipse.equinox.bidi.custom.STextProcessor;
18
17
19
/**
18
/**
Lines 51-57 Link Here
51
		data = "ABC.DEF:HOST-COM=HELLO";
50
		data = "ABC.DEF:HOST-COM=HELLO";
52
		lean = toUT16(data);
51
		lean = toUT16(data);
53
		processor = STextProcessorFactory.getProcessor("test");
52
		processor = STextProcessorFactory.getProcessor("test");
54
		full = STextEngine.leanToFullText(processor, null, lean, null);
53
		STextHandler handler = new STextHandler(processor);
54
		full = handler.leanToFullText(null, lean);
55
		model = "ABC@.DEF@:HOST@-COM@=HELLO";
55
		model = "ABC@.DEF@:HOST@-COM@=HELLO";
56
		assertEquals("Test 'test' plugin", model, toPseudo(full));
56
		assertEquals("Test 'test' plugin", model, toPseudo(full));
57
	}
57
	}
(-)src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java (-16 / +35 lines)
Lines 12-17 Link Here
12
package org.eclipse.equinox.bidi.internal.tests;
12
package org.eclipse.equinox.bidi.internal.tests;
13
13
14
import org.eclipse.equinox.bidi.*;
14
import org.eclipse.equinox.bidi.*;
15
import org.eclipse.equinox.bidi.custom.STextCharTypes;
15
import org.eclipse.equinox.bidi.custom.STextProcessor;
16
import org.eclipse.equinox.bidi.custom.STextProcessor;
16
17
17
/**
18
/**
Lines 25-60 Link Here
25
	STextEnvironment envHebrew = new STextEnvironment("he", false, STextEnvironment.ORIENT_LTR);
26
	STextEnvironment envHebrew = new STextEnvironment("he", false, STextEnvironment.ORIENT_LTR);
26
27
27
	STextProcessor processor;
28
	STextProcessor processor;
28
	int[] state = new int[1];
29
	STextHandler handler;
29
30
30
	private void doTest1(String label, String data, String result) {
31
	private void doTest1(String label, String data, String result) {
31
		String full;
32
		String full;
32
		full = STextEngine.leanToFullText(processor, env, toUT16(data), state);
33
		full = handler.leanToFullText(env, toUT16(data));
33
		assertEquals(label + " data = " + data, result, toPseudo(full));
34
		assertEquals(label + " data = " + data, result, toPseudo(full));
34
	}
35
	}
35
36
36
	private void doTest2(String label, String data, String result) {
37
	private void doTest2(String label, String data, String result) {
37
		String full;
38
		String full;
38
		full = STextEngine.leanToFullText(processor, env, data, state);
39
		full = handler.leanToFullText(env, data);
39
		assertEquals(label + " data = " + data, result, toPseudo(full));
40
		assertEquals(label + " data = " + data, result, toPseudo(full));
40
	}
41
	}
41
42
42
	private void doTest3(String label, String data, String result) {
43
	private void doTest3(String label, String data, String result) {
43
		String full;
44
		String full;
44
		full = STextEngine.leanToFullText(processor, env, toUT16(data), state);
45
		full = handler.leanToFullText(env, toUT16(data));
45
		assertEquals(label + " data = " + data, result, toPseudo(full));
46
		assertEquals(label + " data = " + data, result, toPseudo(full));
47
	}
48
49
	private void doTestGetDirection() {
50
		STextEnvironment envRTL = new STextEnvironment("ar", false, STextEnvironment.ORIENT_RTL);
51
		String[] types = STextProcessorFactory.getAllProcessorIDs();
52
		assertNotNull(types);
53
		assertTrue(types.length > 0);
54
		String text = "\u0644\u0645 \u05d0\u05d1";
55
		STextCharTypes dirProps = new STextCharTypes(text);
56
		for (int i = 0; i < types.length; i++) {
57
			processor = STextProcessorFactory.getProcessor(types[i]);
58
			assertNotNull(processor);
59
			int dir1 = processor.getDirection(envRTL, text);
60
			int dir2 = processor.getDirection(envRTL, text, dirProps);
61
			assertEquals("getDirection: comparing " + dir1 + "  with " + dir2, dir1, dir2);
62
		}
46
	}
63
	}
47
64
48
	public void testExtensions() {
65
	public void testExtensions() {
49
66
50
		String data;
67
		String data;
51
		processor = STextProcessorFactory.PROC_COMMA_DELIMITED;
68
		processor = STextProcessorFactory.PROC_COMMA_DELIMITED;
52
		state[0] = STextEngine.STATE_INITIAL;
69
		handler = new STextHandler(processor);
53
70
54
		doTest1("Comma #1", "ab,cd, AB, CD, EFG", "ab,cd, AB@, CD@, EFG");
71
		doTest1("Comma #1", "ab,cd, AB, CD, EFG", "ab,cd, AB@, CD@, EFG");
55
72
56
		processor = STextProcessorFactory.PROC_EMAIL;
73
		processor = STextProcessorFactory.PROC_EMAIL;
57
		state[0] = STextEngine.STATE_INITIAL;
74
		handler.setProcessor(processor);
58
		doTest1("Email #1", "abc.DEF:GHI", "abc.DEF@:GHI");
75
		doTest1("Email #1", "abc.DEF:GHI", "abc.DEF@:GHI");
59
		doTest1("Email #2", "DEF.GHI \"A.B\":JK ", "DEF@.GHI @\"A.B\"@:JK ");
76
		doTest1("Email #2", "DEF.GHI \"A.B\":JK ", "DEF@.GHI @\"A.B\"@:JK ");
60
		doTest1("Email #3", "DEF,GHI (A,B);JK ", "DEF@,GHI @(A,B)@;JK ");
77
		doTest1("Email #3", "DEF,GHI (A,B);JK ", "DEF@,GHI @(A,B)@;JK ");
Lines 70-80 Link Here
70
		doTest2("Email #9", data, "peter.pan@DEF@.GHI");
87
		doTest2("Email #9", data, "peter.pan@DEF@.GHI");
71
88
72
		processor = STextProcessorFactory.PROC_FILE;
89
		processor = STextProcessorFactory.PROC_FILE;
73
		state[0] = STextEngine.STATE_INITIAL;
90
		handler.setProcessor(processor);
74
		doTest1("File #1", "c:\\A\\B\\FILE.EXT", "c:\\A@\\B@\\FILE@.EXT");
91
		doTest1("File #1", "c:\\A\\B\\FILE.EXT", "c:\\A@\\B@\\FILE@.EXT");
75
92
76
		processor = STextProcessorFactory.PROC_JAVA;
93
		processor = STextProcessorFactory.PROC_JAVA;
77
		state[0] = STextEngine.STATE_INITIAL;
94
		handler.setProcessor(processor);
78
		doTest1("Java #1", "A = B + C;", "A@ = B@ + C;");
95
		doTest1("Java #1", "A = B + C;", "A@ = B@ + C;");
79
		doTest1("Java #2", "A   = B + C;", "A@   = B@ + C;");
96
		doTest1("Java #2", "A   = B + C;", "A@   = B@ + C;");
80
		doTest1("Java #3", "A = \"B+C\"+D;", "A@ = \"B+C\"@+D;");
97
		doTest1("Java #3", "A = \"B+C\"+D;", "A@ = \"B+C\"@+D;");
Lines 87-99 Link Here
87
		doTest1("Java #10", "A = //B+C`|D+E;", "A@ = //B+C`|D@+E;");
104
		doTest1("Java #10", "A = //B+C`|D+E;", "A@ = //B+C`|D@+E;");
88
105
89
		processor = STextProcessorFactory.PROC_PROPERTY;
106
		processor = STextProcessorFactory.PROC_PROPERTY;
90
		state[0] = STextEngine.STATE_INITIAL;
107
		handler.setProcessor(processor);
91
		doTest1("Property #0", "NAME,VAL1,VAL2", "NAME,VAL1,VAL2");
108
		doTest1("Property #0", "NAME,VAL1,VAL2", "NAME,VAL1,VAL2");
92
		doTest1("Property #1", "NAME=VAL1,VAL2", "NAME@=VAL1,VAL2");
109
		doTest1("Property #1", "NAME=VAL1,VAL2", "NAME@=VAL1,VAL2");
93
		doTest1("Property #2", "NAME=VAL1,VAL2=VAL3", "NAME@=VAL1,VAL2=VAL3");
110
		doTest1("Property #2", "NAME=VAL1,VAL2=VAL3", "NAME@=VAL1,VAL2=VAL3");
94
111
95
		processor = STextProcessorFactory.PROC_REGEXP;
112
		processor = STextProcessorFactory.PROC_REGEXP;
96
		state[0] = STextEngine.STATE_INITIAL;
113
		handler.setProcessor(processor);
97
		data = toUT16("ABC(?") + "#" + toUT16("DEF)GHI");
114
		data = toUT16("ABC(?") + "#" + toUT16("DEF)GHI");
98
		doTest2("Regex #0.0", data, "A@B@C@(?#DEF)@G@H@I");
115
		doTest2("Regex #0.0", data, "A@B@C@(?#DEF)@G@H@I");
99
		data = toUT16("ABC(?") + "#" + toUT16("DEF");
116
		data = toUT16("ABC(?") + "#" + toUT16("DEF");
Lines 177-183 Link Here
177
		env = envHebrew;
194
		env = envHebrew;
178
195
179
		processor = STextProcessorFactory.PROC_SQL;
196
		processor = STextProcessorFactory.PROC_SQL;
180
		state[0] = STextEngine.STATE_INITIAL;
197
		handler.setProcessor(processor);
181
		doTest1("SQL #0", "abc GHI", "abc GHI");
198
		doTest1("SQL #0", "abc GHI", "abc GHI");
182
		doTest1("SQL #1", "abc DEF   GHI", "abc DEF@   GHI");
199
		doTest1("SQL #1", "abc DEF   GHI", "abc DEF@   GHI");
183
		doTest1("SQL #2", "ABC, DEF,   GHI", "ABC@, DEF@,   GHI");
200
		doTest1("SQL #2", "ABC, DEF,   GHI", "ABC@, DEF@,   GHI");
Lines 196-221 Link Here
196
		doTest1("SQL #13", "ABC--DEF GHI`|JKL MN", "ABC@--DEF GHI`|JKL@ MN");
213
		doTest1("SQL #13", "ABC--DEF GHI`|JKL MN", "ABC@--DEF GHI`|JKL@ MN");
197
214
198
		processor = STextProcessorFactory.PROC_SYSTEM_USER;
215
		processor = STextProcessorFactory.PROC_SYSTEM_USER;
199
		state[0] = STextEngine.STATE_INITIAL;
216
		handler.setProcessor(processor);
200
		doTest1("System #1", "HOST(JACK)", "HOST@(JACK)");
217
		doTest1("System #1", "HOST(JACK)", "HOST@(JACK)");
201
218
202
		processor = STextProcessorFactory.PROC_UNDERSCORE;
219
		processor = STextProcessorFactory.PROC_UNDERSCORE;
203
		state[0] = STextEngine.STATE_INITIAL;
220
		handler.setProcessor(processor);
204
		doTest1("Underscore #1", "A_B_C_d_e_F_G", "A@_B@_C_d_e_F@_G");
221
		doTest1("Underscore #1", "A_B_C_d_e_F_G", "A@_B@_C_d_e_F@_G");
205
222
206
		processor = STextProcessorFactory.PROC_URL;
223
		processor = STextProcessorFactory.PROC_URL;
207
		state[0] = STextEngine.STATE_INITIAL;
224
		handler.setProcessor(processor);
208
		doTest1("URL #1", "WWW.DOMAIN.COM/DIR1/DIR2/dir3/DIR4", "WWW@.DOMAIN@.COM@/DIR1@/DIR2/dir3/DIR4");
225
		doTest1("URL #1", "WWW.DOMAIN.COM/DIR1/DIR2/dir3/DIR4", "WWW@.DOMAIN@.COM@/DIR1@/DIR2/dir3/DIR4");
209
226
210
		processor = STextProcessorFactory.PROC_XPATH;
227
		processor = STextProcessorFactory.PROC_XPATH;
211
		state[0] = STextEngine.STATE_INITIAL;
228
		handler.setProcessor(processor);
212
		doTest1("Xpath #1", "abc(DEF)GHI", "abc(DEF@)GHI");
229
		doTest1("Xpath #1", "abc(DEF)GHI", "abc(DEF@)GHI");
213
		doTest1("Xpath #2", "DEF.GHI \"A.B\":JK ", "DEF@.GHI@ \"A.B\"@:JK ");
230
		doTest1("Xpath #2", "DEF.GHI \"A.B\":JK ", "DEF@.GHI@ \"A.B\"@:JK ");
214
		doTest1("Xpath #3", "DEF!GHI 'A!B'=JK ", "DEF@!GHI@ 'A!B'@=JK ");
231
		doTest1("Xpath #3", "DEF!GHI 'A!B'=JK ", "DEF@!GHI@ 'A!B'@=JK ");
215
		doTest1("Xpath #4", "DEF.GHI 'A.B :JK ", "DEF@.GHI@ 'A.B :JK ");
232
		doTest1("Xpath #4", "DEF.GHI 'A.B :JK ", "DEF@.GHI@ 'A.B :JK ");
216
233
217
		processor = STextProcessorFactory.PROC_EMAIL;
234
		processor = STextProcessorFactory.PROC_EMAIL;
218
		state[0] = STextEngine.STATE_INITIAL;
235
		handler.setProcessor(processor);
219
		assertEquals("<>.:,;@", processor.getSeparators(null));
236
		assertEquals("<>.:,;@", processor.getSeparators(null));
220
		doTest3("DelimsEsc #1", "abc.DEF.GHI", "abc.DEF@.GHI");
237
		doTest3("DelimsEsc #1", "abc.DEF.GHI", "abc.DEF@.GHI");
221
		doTest3("DelimsEsc #2", "DEF.GHI (A:B);JK ", "DEF@.GHI @(A:B)@;JK ");
238
		doTest3("DelimsEsc #2", "DEF.GHI (A:B);JK ", "DEF@.GHI @(A:B)@;JK ");
Lines 224-228 Link Here
224
		doTest3("DelimsEsc #5", "DEF.GHI (A\\\\\\):C) ;JK ", "DEF@.GHI @(A\\\\\\):C) @;JK ");
241
		doTest3("DelimsEsc #5", "DEF.GHI (A\\\\\\):C) ;JK ", "DEF@.GHI @(A\\\\\\):C) @;JK ");
225
		doTest3("DelimsEsc #6", "DEF.GHI (A\\\\):C ;JK ", "DEF@.GHI @(A\\\\)@:C @;JK ");
242
		doTest3("DelimsEsc #6", "DEF.GHI (A\\\\):C ;JK ", "DEF@.GHI @(A\\\\)@:C @;JK ");
226
		doTest3("DelimsEsc #7", "DEF.GHI (A\\):C ;JK ", "DEF@.GHI @(A\\):C ;JK ");
243
		doTest3("DelimsEsc #7", "DEF.GHI (A\\):C ;JK ", "DEF@.GHI @(A\\):C ;JK ");
244
245
		doTestGetDirection();
227
	}
246
	}
228
}
247
}
(-)src/org/eclipse/equinox/bidi/internal/tests/STextFullToLeanTest.java (-27 / +39 lines)
Lines 24-101 Link Here
24
	static final STextEnvironment envRTL = new STextEnvironment(null, false, STextEnvironment.ORIENT_RTL);
24
	static final STextEnvironment envRTL = new STextEnvironment(null, false, STextEnvironment.ORIENT_RTL);
25
25
26
	STextProcessor processor;
26
	STextProcessor processor;
27
	STextHandler handler = new STextHandler(null);
27
28
28
	private void doTest1(String msg, String data, String leanLTR, String fullLTR, int[] l2fMapLTR, int[] f2lMapLTR, String leanRTL, String fullRTL, int[] l2fMapRTL, int[] f2lMapRTL) {
29
	private void doTest1(String msg, String data, String leanLTR, String fullLTR, int[] l2fMapLTR, int[] f2lMapLTR, String leanRTL, String fullRTL, int[] l2fMapRTL, int[] f2lMapRTL) {
29
		String text, full, lean, label;
30
		String text, full, lean, label;
30
		int[] map;
31
		int[] map;
31
32
32
		text = toUT16(data);
33
		text = toUT16(data);
33
		lean = STextEngine.fullToLeanText(processor, envLTR, text, null);
34
		lean = handler.fullToLeanText(envLTR, text);
34
		assertEquals(msg + "LTR lean", leanLTR, toPseudo(lean));
35
		assertEquals(msg + "LTR lean", leanLTR, toPseudo(lean));
35
		full = STextEngine.leanToFullText(processor, envLTR, lean, null);
36
		full = handler.leanToFullText(envLTR, lean);
36
		assertEquals(msg + "LTR full", fullLTR, toPseudo(full));
37
		assertEquals(msg + "LTR full", fullLTR, toPseudo(full));
37
		map = STextEngine.leanToFullMap(processor, envLTR, lean, null);
38
		map = handler.leanToFullMap(envLTR, lean);
38
		label = msg + "leanToFullMap() LTR";
39
		label = msg + "leanToFullMap() LTR";
39
		assertEquals(label, array_display(l2fMapLTR), array_display(map));
40
		assertEquals(label, array_display(l2fMapLTR), array_display(map));
40
		map = STextEngine.fullToLeanMap(processor, envLTR, text, null);
41
		map = handler.fullToLeanMap(envLTR, text);
41
		label = msg + "fullToLeanMap() LTR";
42
		label = msg + "fullToLeanMap() LTR";
42
		assertEquals(label, array_display(f2lMapLTR), array_display(map));
43
		assertEquals(label, array_display(f2lMapLTR), array_display(map));
43
44
44
		lean = STextEngine.fullToLeanText(processor, envRTL, text, null);
45
		lean = handler.fullToLeanText(envRTL, text);
45
		assertEquals(msg + "RTL lean", leanRTL, toPseudo(lean));
46
		assertEquals(msg + "RTL lean", leanRTL, toPseudo(lean));
46
		full = STextEngine.leanToFullText(processor, envRTL, lean, null);
47
		full = handler.leanToFullText(envRTL, lean);
47
		assertEquals(msg + "RTL full", fullRTL, toPseudo(full));
48
		assertEquals(msg + "RTL full", fullRTL, toPseudo(full));
48
		map = STextEngine.leanToFullMap(processor, envRTL, lean, null);
49
		map = handler.leanToFullMap(envRTL, lean);
49
		label = msg + "leanToFullMap() RTL";
50
		label = msg + "leanToFullMap() RTL";
50
		assertEquals(label, array_display(l2fMapRTL), array_display(map));
51
		assertEquals(label, array_display(l2fMapRTL), array_display(map));
51
		map = STextEngine.fullToLeanMap(processor, envRTL, text, null);
52
		map = handler.fullToLeanMap(envRTL, text);
52
		label = msg + "fullToLeanMap() RTL";
53
		label = msg + "fullToLeanMap() RTL";
53
		assertEquals(label, array_display(f2lMapRTL), array_display(map));
54
		assertEquals(label, array_display(f2lMapRTL), array_display(map));
54
	}
55
	}
55
56
56
	private void doTest2(String msg) {
57
	private void doTest2(String msg) {
57
		String text, data, full, lean, model;
58
		String text, data, full, lean, model;
58
		int[] state = new int[1];
59
		int state;
59
		int state1, state2, state3;
60
		int state1, state2, state3;
60
61
61
		data = "update \"AB_CDE\" set \"COL1\"@='01', \"COL2\"@='02' /* GH IJK";
62
		data = "update \"AB_CDE\" set \"COL1\"@='01', \"COL2\"@='02' /* GH IJK";
62
		text = toUT16(data);
63
		text = toUT16(data);
63
		state[0] = -1;
64
		state = -1;
64
		lean = STextEngine.fullToLeanText(processor, envLTR, text, state);
65
		handler.setState(state);
65
		state1 = state[0];
66
		lean = handler.fullToLeanText(envLTR, text);
67
		state1 = handler.getState();
66
		model = "update \"AB_CDE\" set \"COL1\"='01', \"COL2\"='02' /* GH IJK";
68
		model = "update \"AB_CDE\" set \"COL1\"='01', \"COL2\"='02' /* GH IJK";
67
		assertEquals(msg + "LTR lean", model, toPseudo(lean));
69
		assertEquals(msg + "LTR lean", model, toPseudo(lean));
68
		state[0] = -1;
70
		state = -1;
69
		full = STextEngine.leanToFullText(processor, envLTR, lean, state);
71
		handler.setState(state);
72
		full = handler.leanToFullText(envLTR, lean);
70
		assertEquals(msg + "LTR full", data, toPseudo(full));
73
		assertEquals(msg + "LTR full", data, toPseudo(full));
71
		assertEquals(msg + "state from leanToFullText", state1, state[0]);
74
		state = handler.getState();
75
		assertEquals(msg + "state from leanToFullText", state1, state);
72
		data = "THIS IS A COMMENT LINE";
76
		data = "THIS IS A COMMENT LINE";
73
		text = toUT16(data);
77
		text = toUT16(data);
74
		state[0] = state1;
78
		state = state1;
75
		lean = STextEngine.fullToLeanText(processor, envLTR, text, state);
79
		handler.setState(state);
76
		state2 = state[0];
80
		lean = handler.fullToLeanText(envLTR, text);
81
		state2 = handler.getState();
77
		model = "THIS IS A COMMENT LINE";
82
		model = "THIS IS A COMMENT LINE";
78
		assertEquals(msg + "LTR lean2", model, toPseudo(lean));
83
		assertEquals(msg + "LTR lean2", model, toPseudo(lean));
79
		state[0] = state1;
84
		state = state1;
80
		full = STextEngine.leanToFullText(processor, envLTR, lean, state);
85
		handler.setState(state);
86
		full = handler.leanToFullText(envLTR, lean);
87
		state = handler.getState();
81
		assertEquals(msg + "LTR full2", data, toPseudo(full));
88
		assertEquals(msg + "LTR full2", data, toPseudo(full));
82
		assertEquals(msg + "state from leanToFullText2", state2, state[0]);
89
		assertEquals(msg + "state from leanToFullText2", state2, state);
83
		data = "SOME MORE */ where \"COL3\"@=123";
90
		data = "SOME MORE */ where \"COL3\"@=123";
84
		text = toUT16(data);
91
		text = toUT16(data);
85
		state[0] = state2;
92
		state = state2;
86
		lean = STextEngine.fullToLeanText(processor, envLTR, text, state);
93
		handler.setState(state);
87
		state3 = state[0];
94
		lean = handler.fullToLeanText(envLTR, text);
95
		state3 = handler.getState();
88
		model = "SOME MORE */ where \"COL3\"=123";
96
		model = "SOME MORE */ where \"COL3\"=123";
89
		assertEquals(msg + "LTR lean3", model, toPseudo(lean));
97
		assertEquals(msg + "LTR lean3", model, toPseudo(lean));
90
		state[0] = state2;
98
		state = state2;
91
		full = STextEngine.leanToFullText(processor, envLTR, lean, state);
99
		handler.setState(state);
100
		full = handler.leanToFullText(envLTR, lean);
101
		state = handler.getState();
92
		assertEquals(msg + "LTR full3", data, toPseudo(full));
102
		assertEquals(msg + "LTR full3", data, toPseudo(full));
93
		assertEquals(msg + "state from leanToFullText3", state3, state[0]);
103
		assertEquals(msg + "state from leanToFullText3", state3, state);
94
	}
104
	}
95
105
96
	public void testFullToLean() {
106
	public void testFullToLean() {
97
107
98
		processor = STextProcessorFactory.PROC_COMMA_DELIMITED;
108
		processor = STextProcessorFactory.PROC_COMMA_DELIMITED;
109
		handler.setProcessor(processor);
99
		doTest1("testFullToLean #1 - ", "", "", "", new int[0], new int[0], "", "", new int[0], new int[0]);
110
		doTest1("testFullToLean #1 - ", "", "", "", new int[0], new int[0], "", "", new int[0], new int[0]);
100
		int[] map1 = new int[] {0, 1, 2, 3, 4};
111
		int[] map1 = new int[] {0, 1, 2, 3, 4};
101
		int[] map2 = new int[] {2, 3, 4, 5, 6};
112
		int[] map2 = new int[] {2, 3, 4, 5, 6};
Lines 243-248 Link Here
243
254
244
		// test fullToLeanText with initial state
255
		// test fullToLeanText with initial state
245
		processor = STextProcessorFactory.PROC_SQL;
256
		processor = STextProcessorFactory.PROC_SQL;
257
		handler.setProcessor(processor);
246
		doTest2("testFullToLean #38 - ");
258
		doTest2("testFullToLean #38 - ");
247
	}
259
	}
248
}
260
}
(-)src/org/eclipse/equinox/bidi/internal/tests/STextMathTest.java (-2 / +3 lines)
Lines 23-34 Link Here
23
	static final STextEnvironment envRTL = new STextEnvironment("ar", false, STextEnvironment.ORIENT_RTL);
23
	static final STextEnvironment envRTL = new STextEnvironment("ar", false, STextEnvironment.ORIENT_RTL);
24
24
25
	STextProcessor processor = STextProcessorFactory.PROC_RTL_ARITHMETIC;
25
	STextProcessor processor = STextProcessorFactory.PROC_RTL_ARITHMETIC;
26
	STextHandler handler = new STextHandler(processor);
26
27
27
	private void verifyOneLine(String msg, String data, String resLTR, String resRTL) {
28
	private void verifyOneLine(String msg, String data, String resLTR, String resRTL) {
28
		String lean = toUT16(data);
29
		String lean = toUT16(data);
29
		String fullLTR = STextEngine.leanToFullText(processor, envLTR, lean, null);
30
		String fullLTR = handler.leanToFullText(envLTR, lean);
30
		assertEquals(msg + " LTR - ", resLTR, toPseudo(fullLTR));
31
		assertEquals(msg + " LTR - ", resLTR, toPseudo(fullLTR));
31
		String fullRTL = STextEngine.leanToFullText(processor, envRTL, lean, null);
32
		String fullRTL = handler.leanToFullText(envRTL, lean);
32
		assertEquals(msg + " RTL - ", resRTL, toPseudo(fullRTL));
33
		assertEquals(msg + " RTL - ", resRTL, toPseudo(fullRTL));
33
	}
34
	}
34
35
(-)src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java (-35 / +38 lines)
Lines 12-19 Link Here
12
package org.eclipse.equinox.bidi.internal.tests;
12
package org.eclipse.equinox.bidi.internal.tests;
13
13
14
import org.eclipse.equinox.bidi.*;
14
import org.eclipse.equinox.bidi.*;
15
import org.eclipse.equinox.bidi.custom.STextCharTypes;
15
import org.eclipse.equinox.bidi.custom.*;
16
import org.eclipse.equinox.bidi.custom.STextProcessor;
17
16
18
/**
17
/**
19
 * Tests most public methods of BidiComplexEngine
18
 * Tests most public methods of BidiComplexEngine
Lines 21-28 Link Here
21
20
22
public class STextMethodsTest extends STextTestBase {
21
public class STextMethodsTest extends STextTestBase {
23
22
24
	final static int LTR = STextEngine.DIR_LTR;
23
	final static int LTR = STextHandler.DIR_LTR;
25
	final static int RTL = STextEngine.DIR_RTL;
24
	final static int RTL = STextHandler.DIR_RTL;
26
	final static STextEnvironment envLTR = new STextEnvironment(null, false, STextEnvironment.ORIENT_LTR);
25
	final static STextEnvironment envLTR = new STextEnvironment(null, false, STextEnvironment.ORIENT_LTR);
27
	final static STextEnvironment envRTL = new STextEnvironment(null, false, STextEnvironment.ORIENT_RTL);
26
	final static STextEnvironment envRTL = new STextEnvironment(null, false, STextEnvironment.ORIENT_RTL);
28
	final static STextEnvironment envRTLMIR = new STextEnvironment(null, true, STextEnvironment.ORIENT_RTL);
27
	final static STextEnvironment envRTLMIR = new STextEnvironment(null, true, STextEnvironment.ORIENT_RTL);
Lines 39-46 Link Here
39
			return ","; //$NON-NLS-1$
38
			return ","; //$NON-NLS-1$
40
		}
39
		}
41
40
42
		public boolean skipProcessing(STextEnvironment environment, String text, STextCharTypes dirProps) {
41
		public boolean skipProcessing(STextProcessorData procData) {
43
			byte dirProp = dirProps.getBidiTypeAt(0);
42
			byte dirProp = procData.dirProps.getBidiTypeAt(0);
44
			if (dirProp == AL)
43
			if (dirProp == AL)
45
				return true;
44
				return true;
46
			return false;
45
			return false;
Lines 61-66 Link Here
61
	}
60
	}
62
61
63
	STextProcessor processor;
62
	STextProcessor processor;
63
	STextHandler handler = new STextHandler(null);
64
64
65
	private void doTestTools() {
65
	private void doTestTools() {
66
66
Lines 79-100 Link Here
79
79
80
	private void doTestState() {
80
	private void doTestState() {
81
		String data, lean, full, model;
81
		String data, lean, full, model;
82
		int[] state = new int[1];
83
		state[0] = -1;
84
		processor = STextProcessorFactory.PROC_JAVA;
82
		processor = STextProcessorFactory.PROC_JAVA;
83
		handler.setProcessor(processor);
85
		data = "A=B+C;/* D=E+F;";
84
		data = "A=B+C;/* D=E+F;";
86
		lean = toUT16(data);
85
		lean = toUT16(data);
87
		full = STextEngine.leanToFullText(processor, null, lean, state);
86
		full = handler.leanToFullText(null, lean);
88
		model = "A@=B@+C@;/* D=E+F;";
87
		model = "A@=B@+C@;/* D=E+F;";
89
		assertEquals("full1", model, toPseudo(full));
88
		assertEquals("full1", model, toPseudo(full));
90
		data = "A=B+C; D=E+F;";
89
		data = "A=B+C; D=E+F;";
91
		lean = toUT16(data);
90
		lean = toUT16(data);
92
		full = STextEngine.leanToFullText(processor, null, lean, state);
91
		full = handler.leanToFullText(null, lean);
93
		model = "A=B+C; D=E+F;";
92
		model = "A=B+C; D=E+F;";
94
		assertEquals("full2", model, toPseudo(full));
93
		assertEquals("full2", model, toPseudo(full));
95
		data = "A=B+C;*/ D=E+F;";
94
		data = "A=B+C;*/ D=E+F;";
96
		lean = toUT16(data);
95
		lean = toUT16(data);
97
		full = STextEngine.leanToFullText(processor, null, lean, state);
96
		full = handler.leanToFullText(null, lean);
98
		model = "A=B+C;@*/ D@=E@+F;";
97
		model = "A=B+C;@*/ D@=E@+F;";
99
		assertEquals("full3", model, toPseudo(full));
98
		assertEquals("full3", model, toPseudo(full));
100
	}
99
	}
Lines 118-154 Link Here
118
		String full, lean;
117
		String full, lean;
119
118
120
		lean = toUT16(data);
119
		lean = toUT16(data);
121
		full = STextEngine.leanToFullText(processor, envLTR, lean, null);
120
		full = handler.leanToFullText(envLTR, lean);
122
		assertEquals(label + "LTR full", resLTR, toPseudo(full));
121
		assertEquals(label + "LTR full", resLTR, toPseudo(full));
123
		full = STextEngine.leanToFullText(processor, envRTL, lean, null);
122
		full = handler.leanToFullText(envRTL, lean);
124
		assertEquals("label + RTL full", resRTL, toPseudo(full));
123
		assertEquals("label + RTL full", resRTL, toPseudo(full));
125
		full = STextEngine.leanToFullText(processor, envCRL, lean, null);
124
		full = handler.leanToFullText(envCRL, lean);
126
		assertEquals(label + "CON full", resCon, toPseudo(full));
125
		assertEquals(label + "CON full", resCon, toPseudo(full));
127
	}
126
	}
128
127
129
	private void doTestSkipProcessing() {
128
	private void doTestSkipProcessing() {
130
		processor = new MyComma();
129
		processor = new MyComma();
130
		handler.setProcessor(processor);
131
		doTestOrient("Skip #1 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF");
131
		doTestOrient("Skip #1 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF");
132
		doTestOrient("Skip #2 ", "#CD,EF", "#CD,EF", ">@#CD,EF@^", "@#CD,EF");
132
		doTestOrient("Skip #2 ", "#CD,EF", "#CD,EF", ">@#CD,EF@^", "@#CD,EF");
133
	}
133
	}
134
134
135
	private void doTestLeanOffsets() {
135
	private void doTestLeanOffsets() {
136
		String lean, data, label;
136
		String lean, data, label;
137
		int[] state = new int[1];
138
		processor = STextProcessorFactory.PROC_JAVA;
137
		processor = STextProcessorFactory.PROC_JAVA;
138
		handler.setProcessor(processor);
139
		int[] offsets;
139
		int[] offsets;
140
		int[] model;
140
		int[] model;
141
141
142
		data = "A=B+C;/* D=E+F;";
142
		data = "A=B+C;/* D=E+F;";
143
		lean = toUT16(data);
143
		lean = toUT16(data);
144
		state[0] = -1;
144
		offsets = handler.leanBidiCharOffsets(null, lean);
145
		offsets = STextEngine.leanBidiCharOffsets(processor, null, lean, state);
146
		model = new int[] {1, 3, 5};
145
		model = new int[] {1, 3, 5};
147
		label = "leanBidiCharOffsets() #1 ";
146
		label = "leanBidiCharOffsets() #1 ";
148
		assertEquals(label, array_display(model), array_display(offsets));
147
		assertEquals(label, array_display(model), array_display(offsets));
149
		data = "A=B+C;*/ D=E+F;";
148
		data = "A=B+C;*/ D=E+F;";
150
		lean = toUT16(data);
149
		lean = toUT16(data);
151
		offsets = STextEngine.leanBidiCharOffsets(processor, null, lean, state);
150
		offsets = handler.leanBidiCharOffsets(null, lean);
152
		model = new int[] {6, 10, 12};
151
		model = new int[] {6, 10, 12};
153
		label = "leanBidiCharOffsets() #2 ";
152
		label = "leanBidiCharOffsets() #2 ";
154
		assertEquals(label, array_display(model), array_display(offsets));
153
		assertEquals(label, array_display(model), array_display(offsets));
Lines 158-175 Link Here
158
		String full, lean, msg;
157
		String full, lean, msg;
159
		int[] offsets;
158
		int[] offsets;
160
		processor = STextProcessorFactory.PROC_COMMA_DELIMITED;
159
		processor = STextProcessorFactory.PROC_COMMA_DELIMITED;
160
		handler.setProcessor(processor);
161
161
162
		lean = toUT16(data);
162
		lean = toUT16(data);
163
		full = STextEngine.leanToFullText(processor, envLTR, lean, null);
163
		full = handler.leanToFullText(envLTR, lean);
164
		offsets = STextEngine.fullBidiCharOffsets(processor, envLTR, full, null);
164
		offsets = handler.fullBidiCharOffsets(envLTR, full);
165
		msg = label + "LTR ";
165
		msg = label + "LTR ";
166
		assertEquals(msg, array_display(resLTR), array_display(offsets));
166
		assertEquals(msg, array_display(resLTR), array_display(offsets));
167
		full = STextEngine.leanToFullText(processor, envRTL, lean, null);
167
		full = handler.leanToFullText(envRTL, lean);
168
		offsets = STextEngine.fullBidiCharOffsets(processor, envRTL, full, null);
168
		offsets = handler.fullBidiCharOffsets(envRTL, full);
169
		msg = label + "RTL ";
169
		msg = label + "RTL ";
170
		assertEquals(msg, array_display(resRTL), array_display(offsets));
170
		assertEquals(msg, array_display(resRTL), array_display(offsets));
171
		full = STextEngine.leanToFullText(processor, envCLR, lean, null);
171
		full = handler.leanToFullText(envCLR, lean);
172
		offsets = STextEngine.fullBidiCharOffsets(processor, envCLR, full, null);
172
		offsets = handler.fullBidiCharOffsets(envCLR, full);
173
		msg = label + "CON ";
173
		msg = label + "CON ";
174
		assertEquals(msg, array_display(resCon), array_display(offsets));
174
		assertEquals(msg, array_display(resCon), array_display(offsets));
175
	}
175
	}
Lines 187-192 Link Here
187
		String data, lean, full, model, msg;
187
		String data, lean, full, model, msg;
188
		int dirA, dirH;
188
		int dirA, dirH;
189
		processor = new MyComma();
189
		processor = new MyComma();
190
		handler.setProcessor(processor);
190
		dirArabic = RTL;
191
		dirArabic = RTL;
191
		dirHebrew = LTR;
192
		dirHebrew = LTR;
192
		msg = "TestDirection #1";
193
		msg = "TestDirection #1";
Lines 209-221 Link Here
209
		msg = "TestDirection #3";
210
		msg = "TestDirection #3";
210
		data = "ABC,#DEF,HOST,com";
211
		data = "ABC,#DEF,HOST,com";
211
		lean = toUT16(data);
212
		lean = toUT16(data);
212
		full = STextEngine.leanToFullText(processor, null, lean, null);
213
		full = handler.leanToFullText(null, lean);
213
		model = "ABC@,#DEF@,HOST,com";
214
		model = "ABC@,#DEF@,HOST,com";
214
		assertEquals("TestDirection #9 full", model, toPseudo(full));
215
		assertEquals("TestDirection #9 full", model, toPseudo(full));
215
216
216
		data = "ABC,DEF,HOST,com";
217
		data = "ABC,DEF,HOST,com";
217
		lean = toUT16(data);
218
		lean = toUT16(data);
218
		full = STextEngine.leanToFullText(processor, null, lean, null);
219
		full = handler.leanToFullText(null, lean);
219
		model = "ABC@,DEF@,HOST,com";
220
		model = "ABC@,DEF@,HOST,com";
220
		assertEquals("TestDirection #10 full", model, toPseudo(full));
221
		assertEquals("TestDirection #10 full", model, toPseudo(full));
221
222
Lines 229-274 Link Here
229
		STextEnvironment environment = new STextEnvironment(null, true, STextEnvironment.ORIENT_LTR);
230
		STextEnvironment environment = new STextEnvironment(null, true, STextEnvironment.ORIENT_LTR);
230
		data = "ABC,#DEF,HOST,com";
231
		data = "ABC,#DEF,HOST,com";
231
		lean = toUT16(data);
232
		lean = toUT16(data);
232
		full = STextEngine.leanToFullText(processor, environment, lean, null);
233
		full = handler.leanToFullText(environment, lean);
233
		model = "<&ABC,#DEF,HOST,com&^";
234
		model = "<&ABC,#DEF,HOST,com&^";
234
		assertEquals("TestDirection #11 full", model, toPseudo(full));
235
		assertEquals("TestDirection #11 full", model, toPseudo(full));
235
236
236
		data = "ABc,#DEF,HOSt,COM";
237
		data = "ABc,#DEF,HOSt,COM";
237
		lean = toUT16(data);
238
		lean = toUT16(data);
238
		full = STextEngine.leanToFullText(processor, environment, lean, null);
239
		full = handler.leanToFullText(environment, lean);
239
		model = "<&ABc,#DEF,HOSt,COM&^";
240
		model = "<&ABc,#DEF,HOSt,COM&^";
240
		assertEquals("TestDirection #12 full", model, toPseudo(full));
241
		assertEquals("TestDirection #12 full", model, toPseudo(full));
241
242
242
		data = "ABc,#DEF,HOSt,";
243
		data = "ABc,#DEF,HOSt,";
243
		lean = toUT16(data);
244
		lean = toUT16(data);
244
		full = STextEngine.leanToFullText(processor, environment, lean, null);
245
		full = handler.leanToFullText(environment, lean);
245
		model = "<&ABc,#DEF,HOSt,&^";
246
		model = "<&ABc,#DEF,HOSt,&^";
246
		assertEquals("TestDirection #13 full", model, toPseudo(full));
247
		assertEquals("TestDirection #13 full", model, toPseudo(full));
247
248
248
		data = "ABC,DEF,HOST,com";
249
		data = "ABC,DEF,HOST,com";
249
		lean = toUT16(data);
250
		lean = toUT16(data);
250
		full = STextEngine.leanToFullText(processor, environment, lean, null);
251
		full = handler.leanToFullText(environment, lean);
251
		model = "ABC@,DEF@,HOST,com";
252
		model = "ABC@,DEF@,HOST,com";
252
		assertEquals("TestDirection #14 full", model, toPseudo(full));
253
		assertEquals("TestDirection #14 full", model, toPseudo(full));
253
254
254
		data = "--,---,----";
255
		data = "--,---,----";
255
		lean = toUT16(data);
256
		lean = toUT16(data);
256
		full = STextEngine.leanToFullText(processor, environment, lean, null);
257
		full = handler.leanToFullText(environment, lean);
257
		model = "--,---,----";
258
		model = "--,---,----";
258
		assertEquals("TestDirection #15 full", model, toPseudo(full));
259
		assertEquals("TestDirection #15 full", model, toPseudo(full));
259
260
260
		data = "ABC,|DEF,HOST,com";
261
		data = "ABC,|DEF,HOST,com";
261
		lean = toUT16(data);
262
		lean = toUT16(data);
262
		full = STextEngine.leanToFullText(processor, environment, lean, null);
263
		full = handler.leanToFullText(environment, lean);
263
		model = "ABC,|DEF@,HOST,com";
264
		model = "ABC,|DEF@,HOST,com";
264
		assertEquals("TestDirection #16 full", model, toPseudo(full));
265
		assertEquals("TestDirection #16 full", model, toPseudo(full));
265
266
266
		data = "ABc,|#DEF,HOST,com";
267
		data = "ABc,|#DEF,HOST,com";
267
		lean = toUT16(data);
268
		lean = toUT16(data);
268
		full = STextEngine.leanToFullText(processor, envRTLMIR, lean, null);
269
		full = handler.leanToFullText(envRTLMIR, lean);
269
		model = "ABc,|#DEF,HOST,com";
270
		model = "ABc,|#DEF,HOST,com";
270
		assertEquals("TestDirection #17 full", model, toPseudo(full));
271
		assertEquals("TestDirection #17 full", model, toPseudo(full));
271
		assertEquals("Test curDirection", RTL, STextEngine.getCurDirection(processor, envRTLMIR, lean));
272
		assertEquals("Test curDirection", RTL, handler.getCurDirection(envRTLMIR, lean));
272
	}
273
	}
273
274
274
	public void testMethods() {
275
	public void testMethods() {
Lines 280-285 Link Here
280
		doTestOrientation();
281
		doTestOrientation();
281
282
282
		processor = STextProcessorFactory.PROC_COMMA_DELIMITED;
283
		processor = STextProcessorFactory.PROC_COMMA_DELIMITED;
284
		handler.setProcessor(processor);
283
		doTestOrient("Methods #1 ", "", "", "", "");
285
		doTestOrient("Methods #1 ", "", "", "", "");
284
		doTestOrient("Methods #2 ", "abc", "abc", ">@abc@^", "abc");
286
		doTestOrient("Methods #2 ", "abc", "abc", ">@abc@^", "abc");
285
		doTestOrient("Methods #3 ", "ABC", "ABC", ">@ABC@^", "@ABC");
287
		doTestOrient("Methods #3 ", "ABC", "ABC", ">@ABC@^", "@ABC");
Lines 301-309 Link Here
301
		doTestDirection();
303
		doTestDirection();
302
304
303
		processor = STextProcessorFactory.PROC_COMMA_DELIMITED;
305
		processor = STextProcessorFactory.PROC_COMMA_DELIMITED;
306
		handler.setProcessor(processor);
304
		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";
307
		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";
305
		String lean = toUT16(data);
308
		String lean = toUT16(data);
306
		String full = STextEngine.leanToFullText(processor, null, lean, null);
309
		String full = handler.leanToFullText(null, lean);
307
		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";
310
		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";
308
		assertEquals("many inserts", model, toPseudo(full));
311
		assertEquals("many inserts", model, toPseudo(full));
309
	}
312
	}
(-)src/org/eclipse/equinox/bidi/internal/tests/STextNullProcessorTest.java (-13 / +16 lines)
Lines 11-17 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.STextEngine;
14
import org.eclipse.equinox.bidi.STextHandler;
15
15
16
/**
16
/**
17
 * Tests null processor
17
 * Tests null processor
Lines 19-46 Link Here
19
public class STextNullProcessorTest extends STextTestBase {
19
public class STextNullProcessorTest extends STextTestBase {
20
20
21
	static final int[] EMPTY_INT_ARRAY = new int[0];
21
	static final int[] EMPTY_INT_ARRAY = new int[0];
22
23
	STextHandler handler = new STextHandler(null);
22
24
23
	public void testNullProcessor() {
25
	public void testNullProcessor() {
24
		String full = STextEngine.leanToFullText(null, null, "abc", null);
26
		String full = handler.leanToFullText(null, "abc");
25
		assertEquals("leanToFullText", "abc", full);
27
		assertEquals("leanToFullText", "abc", full);
26
		int[] state = new int[1];
28
		handler.setState(3);
27
		state[0] = 3;
29
		full = handler.leanToFullText(null, "abc");
28
		full = STextEngine.leanToFullText(null, null, "abc", state);
29
		assertEquals("leanToFullText with state", "abc", full);
30
		assertEquals("leanToFullText with state", "abc", full);
30
		int[] offsets = STextEngine.leanBidiCharOffsets(null, null, "abc", null);
31
		int[] offsets = handler.leanBidiCharOffsets(null, "abc");
31
		assertEquals("leanBidiCharOffsets", 0, offsets.length);
32
		assertEquals("leanBidiCharOffsets", 0, offsets.length);
32
		offsets = STextEngine.fullBidiCharOffsets(null, null, "abc", null);
33
		offsets = handler.fullBidiCharOffsets(null, "abc");
33
		assertEquals("fullBidiCharOffsets", 0, offsets.length);
34
		assertEquals("fullBidiCharOffsets", 0, offsets.length);
34
		String lean = STextEngine.fullToLeanText(null, null, "abc", null);
35
		String lean = handler.fullToLeanText(null, "abc");
35
		assertEquals("fullToLeanText", "abc", lean);
36
		assertEquals("fullToLeanText", "abc", lean);
36
		lean = STextEngine.fullToLeanText(null, null, "abc", state);
37
		handler.setState(3);
38
		lean = handler.fullToLeanText(null, "abc");
37
		assertEquals("fullToLeanText with state", "abc", lean);
39
		assertEquals("fullToLeanText with state", "abc", lean);
38
		int[] map = STextEngine.leanToFullMap(null, null, "abc", null);
40
		int[] map = handler.leanToFullMap(null, "abc");
39
		int[] model = {0, 1, 2};
41
		int[] model = {0, 1, 2};
40
		assertEquals("leanToFullMap", array_display(model), array_display(map));
42
		assertEquals("leanToFullMap", array_display(model), array_display(map));
41
		map = STextEngine.fullToLeanMap(null, null, "abc", null);
43
		map = handler.fullToLeanMap(null, "abc");
42
		assertEquals("fullToLeanMap", array_display(model), array_display(map));
44
		assertEquals("fullToLeanMap", array_display(model), array_display(map));
43
		int direction = STextEngine.getCurDirection(null, null, "abc");
45
		int direction = handler.getCurDirection(null, "abc");
44
		assertEquals("getCurDirection", STextEngine.DIR_LTR, direction);
46
		assertEquals("getCurDirection", STextHandler.DIR_LTR, direction);
45
	}
47
	}
48
46
}
49
}
(-)src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java (-10 / +14 lines)
Lines 11-20 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.STextEngine;
15
import org.eclipse.equinox.bidi.STextEnvironment;
14
import org.eclipse.equinox.bidi.STextEnvironment;
16
import org.eclipse.equinox.bidi.custom.STextCharTypes;
15
import org.eclipse.equinox.bidi.STextHandler;
17
import org.eclipse.equinox.bidi.custom.STextProcessor;
16
import org.eclipse.equinox.bidi.custom.STextProcessor;
17
import org.eclipse.equinox.bidi.custom.STextProcessorData;
18
18
19
/**
19
/**
20
 * Tests some weird cases
20
 * Tests some weird cases
Lines 31-45 Link Here
31
			return 1;
31
			return 1;
32
		}
32
		}
33
33
34
		public int indexOfSpecial(STextEnvironment env, String text, STextCharTypes dirProps, int[] offsets, int caseNumber, int fromIndex) {
34
		public int indexOfSpecial(STextProcessorData procData, int caseNumber, int fromIndex) {
35
			return fromIndex;
35
			return fromIndex;
36
		}
36
		}
37
37
38
		public int processSpecial(STextEnvironment env, String text, STextCharTypes dirProps, int[] offsets, int[] state, int caseNumber, int separLocation) {
38
		public int processSpecial(STextProcessorData procData, int caseNumber, int separLocation) {
39
			String text = procData.text;
39
			int len = text.length();
40
			int len = text.length();
40
			for (int i = len - 1; i >= 0; i--) {
41
			for (int i = len - 1; i >= 0; i--) {
41
				STextProcessor.insertMark(text, dirProps, offsets, i);
42
				STextProcessor.insertMark(procData, i);
42
				STextProcessor.insertMark(text, dirProps, offsets, i);
43
				STextProcessor.insertMark(procData, i);
43
			}
44
			}
44
			return len;
45
			return len;
45
		}
46
		}
Lines 59-65 Link Here
59
			return 1;
60
			return 1;
60
		}
61
		}
61
62
62
		public int indexOfSpecial(STextEnvironment env, String text, STextCharTypes dirProps, int[] offsets, int caseNumber, int fromIndex) {
63
		public int indexOfSpecial(STextProcessorData procData, int caseNumber, int fromIndex) {
63
			return fromIndex;
64
			return fromIndex;
64
		}
65
		}
65
	}
66
	}
Lines 69-90 Link Here
69
		assertTrue(env2.isProcessingNeeded());
70
		assertTrue(env2.isProcessingNeeded());
70
71
71
		STextProcessor processor = new Processor1();
72
		STextProcessor processor = new Processor1();
72
		String full = STextEngine.leanToFullText(processor, env1, "abcd", null);
73
		STextHandler handler = new STextHandler(processor);
74
		String full = handler.leanToFullText(env1, "abcd");
73
		assertEquals("@a@b@c@d", toPseudo(full));
75
		assertEquals("@a@b@c@d", toPseudo(full));
74
76
75
		processor = new Processor2();
77
		processor = new Processor2();
78
		handler.setProcessor(processor);
76
		boolean catchFlag = false;
79
		boolean catchFlag = false;
77
		try {
80
		try {
78
			full = STextEngine.leanToFullText(processor, env1, "abcd", null);
81
			full = handler.leanToFullText(env1, "abcd");
79
		} catch (IllegalStateException e) {
82
		} catch (IllegalStateException e) {
80
			catchFlag = true;
83
			catchFlag = true;
81
		}
84
		}
82
		assertTrue("Catch missing indexOfSpecial", catchFlag);
85
		assertTrue("Catch missing indexOfSpecial", catchFlag);
83
86
84
		processor = new Processor3();
87
		processor = new Processor3();
88
		handler.setProcessor(processor);
85
		catchFlag = false;
89
		catchFlag = false;
86
		try {
90
		try {
87
			full = STextEngine.leanToFullText(processor, env1, "abcd", null);
91
			full = handler.leanToFullText(env1, "abcd");
88
		} catch (IllegalStateException e) {
92
		} catch (IllegalStateException e) {
89
			catchFlag = true;
93
			catchFlag = true;
90
		}
94
		}

Return to bug 183164