Skip to main content
summaryrefslogtreecommitdiffstats
blob: bb7e6790fc5751c8c3d213826982fd6803e62d45 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
/*******************************************************************************
 * Copyright (c) 2015 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.wst.jsdt.core.tests.search;

import org.eclipse.wst.jsdt.core.compiler.CharOperation;
import org.eclipse.wst.jsdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.wst.jsdt.internal.core.search.indexing.IIndexConstants;
import org.eclipse.wst.jsdt.internal.core.search.matching.MethodPattern;

import junit.framework.TestCase;

/**
 * <p>Tests for MethodPattern.</p>
 * 
 * @see MethodPattern
 */
public class TestMethodPattern extends TestCase {
	
	public void testCreateIndexKey_0() {
		runCreateIndexKeyTest("myFunction/////", "myFunction".toCharArray(), null, null, null, null, 0);
	}
	
	public void testCreateIndexKey_1() {
		runCreateIndexKeyTest("myFunction/////", "myFunction".toCharArray(), null, null, null, null, 0);
	}
	
	public void testCreateIndexKey_2() {
		runCreateIndexKeyTest("myFunction///String//",
				"myFunction".toCharArray(), null, null, null, "String".toCharArray(), 0);
	}
	
	public void testCreateIndexKey_3() {
		runCreateIndexKeyTest("myFunction////foo.bar.Type/",
				"myFunction".toCharArray(), null, null, "foo.bar.Type".toCharArray(), null, ClassFileConstants.AccStatic);
	}
	
	public void testCreateIndexKey_4() {
		runCreateIndexKeyTest("myFunction///String/foo.bar.Type/",
				"myFunction".toCharArray(), null, null, "foo.bar.Type".toCharArray(), "String".toCharArray(), ClassFileConstants.AccStatic);
	}
	
	public void testCreateIndexKey_5() {
		runCreateIndexKeyTest("myFunction//param1,param2///",
				"myFunction".toCharArray(), null, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, null, 0);
	}
	
	public void testCreateIndexKey_6() {
		runCreateIndexKeyTest("myFunction//param1,param2/String//",
				"myFunction".toCharArray(), null, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, "String".toCharArray(), 0);
	}
	
	public void testCreateIndexKey_7() {
		runCreateIndexKeyTest("myFunction//param1,param2//foo.bar.Type/",
				"myFunction".toCharArray(), null, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), null, ClassFileConstants.AccStatic);
	}
	
	public void testCreateIndexKey_8() {
		runCreateIndexKeyTest("myFunction//param1,param2/String/foo.bar.Type/",
				"myFunction".toCharArray(), null, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), "String".toCharArray(), ClassFileConstants.AccStatic);
	}
	
	public void testCreateIndexKey_9() {
		runCreateIndexKeyTest("myFunction/String,Number/param1,param2///",
				"myFunction".toCharArray(), new char[][] { "String".toCharArray(), "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, null, 0);
	}
	
	public void testCreateIndexKey_10() {
		runCreateIndexKeyTest("myFunction/String,Number/param1,param2/String//",
				"myFunction".toCharArray(), new char[][] { "String".toCharArray(), "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, "String".toCharArray(), 0);
	}
	
	public void testCreateIndexKey_11() {
		runCreateIndexKeyTest("myFunction/String,Number/param1,param2//foo.bar.Type/",
				"myFunction".toCharArray(), new char[][] { "String".toCharArray(), "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), null, ClassFileConstants.AccStatic);
	}
	
	public void testCreateIndexKey_12() {
		runCreateIndexKeyTest("myFunction/String,Number/param1,param2/String/foo.bar.Type/",
				"myFunction".toCharArray(), new char[][] { "String".toCharArray(), "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), "String".toCharArray(), ClassFileConstants.AccStatic);
	}
	
	public void testCreateIndexKey_13() {
		runCreateIndexKeyTest("myFunction/,Number/param1,param2///",
				"myFunction".toCharArray(), new char[][] { null, "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, null, 0);
	}
	
	public void testCreateIndexKey_14() {
		runCreateIndexKeyTest("myFunction/,Number/param1,param2/String//",
				"myFunction".toCharArray(), new char[][] { null, "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, "String".toCharArray(), 0);
	}
	
	public void testCreateIndexKey_15() {
		runCreateIndexKeyTest("myFunction/,Number/param1,param2//foo.bar.Type/",
				"myFunction".toCharArray(), new char[][] { null, "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), null, ClassFileConstants.AccStatic);
	}
	
	public void testCreateIndexKey_16() {
		runCreateIndexKeyTest("myFunction/,Number/param1,param2/String/foo.bar.Type/",
				"myFunction".toCharArray(), new char[][] { null, "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), "String".toCharArray(), ClassFileConstants.AccStatic);
	}
	
	public void testCreateIndexKey_17() {
		runCreateIndexKeyTest("myFunction/,Number/param1,param2///",
				"myFunction".toCharArray(), new char[][] { new char[0], "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, null, 0);
	}
	
	public void testCreateIndexKey_18() {
		runCreateIndexKeyTest("myFunction/,Number/param1,param2/String//",
				"myFunction".toCharArray(), new char[][] { new char[0], "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, "String".toCharArray(), 0);
	}
	
	public void testCreateIndexKey_19() {
		runCreateIndexKeyTest("myFunction/,Number/param1,param2//foo.bar.Type/",
				"myFunction".toCharArray(), new char[][] { new char[0], "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), null, ClassFileConstants.AccStatic);
	}
	
	public void testCreateIndexKey_20() {
		runCreateIndexKeyTest("myFunction/,Number/param1,param2/String/foo.bar.Type/",
				"myFunction".toCharArray(), new char[][] { new char[0], "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), "String".toCharArray(), ClassFileConstants.AccStatic);
	}
	
	public void testCreateIndexKey_21() {
		runCreateIndexKeyTest("myFunction/String,/param1,param2///",
				"myFunction".toCharArray(), new char[][] {"String".toCharArray(), null}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, null, 0);
	}
	
	public void testCreateIndexKey_22() {
		runCreateIndexKeyTest("myFunction/String,/param1,param2/String//",
				"myFunction".toCharArray(), new char[][] {"String".toCharArray(), null}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, "String".toCharArray(), 0);
	}
	
	public void testCreateIndexKey_23() {
		runCreateIndexKeyTest("myFunction/String,/param1,param2//foo.bar.Type/",
				"myFunction".toCharArray(), new char[][] {"String".toCharArray(), null}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), null, ClassFileConstants.AccStatic);
	}
	
	public void testCreateIndexKey_24() {
		runCreateIndexKeyTest("myFunction/String,/param1,param2/String/foo.bar.Type/",
				"myFunction".toCharArray(), new char[][] {"String".toCharArray(), null}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), "String".toCharArray(), ClassFileConstants.AccStatic);
	}
	
	public void testCreateIndexKey_25() {
		runCreateIndexKeyTest("myFunction/String,/param1,param2///",
				"myFunction".toCharArray(), new char[][] {"String".toCharArray(), new char[0]}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, null, 0);
	}
	
	public void testCreateIndexKey_26() {
		runCreateIndexKeyTest("myFunction/String,/param1,param2/String//",
				"myFunction".toCharArray(), new char[][] {"String".toCharArray(), new char[0]}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, "String".toCharArray(), 0);
	}
	
	public void testCreateIndexKey_27() {
		runCreateIndexKeyTest("myFunction/String,/param1,param2//foo.bar.Type/",
				"myFunction".toCharArray(), new char[][] {"String".toCharArray(), new char[0]}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), null, ClassFileConstants.AccStatic);
	}
	
	public void testCreateIndexKey_28() {
		runCreateIndexKeyTest("myFunction/String,/param1,param2/String/foo.bar.Type/", "myFunction".toCharArray(), new char[][] {"String".toCharArray(), new char[0]}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), "String".toCharArray(), ClassFileConstants.AccStatic);
	}
	
	public void testCreateIndexKey_29() {
		char[] keyChars = MethodPattern.createIndexKey("".toCharArray(), new char[][] {"String".toCharArray(), new char[0]}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), "String".toCharArray(), ClassFileConstants.AccStatic);
		
		String key = null;
		if(keyChars != null) {
			key = new String(keyChars);
		}
		
		assertNull("If selector is empty the key should be null.\nWAS:\n" + key, key);
	}
	
	public void testCreateIndexKey_30() {
		char[] keyChars = MethodPattern.createIndexKey(null, new char[][] {"String".toCharArray(), new char[0]}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), "String".toCharArray(), ClassFileConstants.AccStatic);
		
		String key = null;
		if(keyChars != null) {
			key = new String(keyChars);
		}
		
		assertNull("If selector is empty the key should be null.\nWAS:\n" + key, key);
	}
	
	public void testDecodeIndexKey_0() {
		runDecodeIndexKeyTest("myFunction////", "myFunction", null, null, null,null, null, null, null, 0);
	}
	
	public void testDecodeIndexKey_2() {
		runDecodeIndexKeyTest("myFunction///String/", "myFunction", null, null, null,null, "String", null, null, 0);
	}
	
	public void testDecodeIndexKey_3() {
		runDecodeIndexKeyTest("myFunction////foo.bar.Type", "myFunction", null, null, null,null, null, "foo.bar", "Type", 0);
	}
	
	public void testDecodeIndexKey_4() {
		runDecodeIndexKeyTest("myFunction///String/foo.bar.Type", "myFunction", null, null, null,null, "String", "foo.bar", "Type", 0);
	}
	
	public void testDecodeIndexKey_5() {
		runDecodeIndexKeyTest("myFunction//param1,param2//", "myFunction", new String[2], new String[2], new String[] {"param1", "param2"},null, null, null, null, 0);
	}
	
	public void testDecodeIndexKey_6() {
		runDecodeIndexKeyTest("myFunction//param1,param2/String/", "myFunction", new String[2], new String[2], new String[] {"param1", "param2"},null, "String", null, null, 0);
	}
	
	public void testDecodeIndexKey_7() {
		runDecodeIndexKeyTest("myFunction//param1,param2//foo.bar.Type", "myFunction", new String[2], new String[2], new String[] {"param1", "param2"},null, null, "foo.bar", "Type", 0);
	}
	
	public void testDecodeIndexKey_8() {
		runDecodeIndexKeyTest("myFunction//param1,param2/String/foo.bar.Type", "myFunction", new String[2], new String[2], new String[] {"param1", "param2"},null, "String", "foo.bar", "Type", 0);
	}
	
	public void testDecodeIndexKey_9() {
		runDecodeIndexKeyTest("myFunction/String,Number/param1,param2//", "myFunction", new String[]{null, null}, new String[]{"String", "Number"}, new String[] {"param1", "param2"},null, null, null, null, 0);
	}
	
	public void testDecodeIndexKey_10() {
		runDecodeIndexKeyTest("myFunction/String,Number/param1,param2/String/", "myFunction", new String[]{null, null}, new String[]{"String", "Number"}, new String[] {"param1", "param2"},null, "String", null, null, 0);
	}
	
	public void testDecodeIndexKey_11() {
		runDecodeIndexKeyTest("myFunction/String,Number/param1,param2//foo.bar.Type", "myFunction", new String[]{null, null}, new String[]{"String", "Number"}, new String[] {"param1", "param2"},null, null, "foo.bar", "Type", 0);
	}
	
	public void testDecodeIndexKey_12() {
		runDecodeIndexKeyTest("myFunction/String,Number/param1,param2/String/foo.bar.Type", "myFunction", new String[]{null, null}, new String[]{"String", "Number"}, new String[] {"param1", "param2"},null, "String", "foo.bar", "Type", 0);
	}
	
	public void testDecodeIndexKey_13() {
		runDecodeIndexKeyTest("myFunction/,Number/param1,param2//", "myFunction", new String[]{null, null}, new String[]{null, "Number"}, new String[] {"param1", "param2"},null, null, null, null, 0);
	}
	
	public void testDecodeIndexKey_14() {
		runDecodeIndexKeyTest("myFunction/,Number/param1,param2/String/", "myFunction", new String[]{null, null}, new String[]{null, "Number"}, new String[] {"param1", "param2"},null, "String", null, null, 0);
	}
	
	public void testDecodeIndexKey_15() {
		runDecodeIndexKeyTest("myFunction/,Number/param1,param2//foo.bar.Type", "myFunction", new String[]{null, null}, new String[]{null, "Number"}, new String[] {"param1", "param2"},null, null, "foo.bar", "Type", 0);
	}
	
	public void testDecodeIndexKey_16() {
		runDecodeIndexKeyTest("myFunction/,Number/param1,param2/String/foo.bar.Type", "myFunction", new String[]{null, null}, new String[]{null, "Number"}, new String[] {"param1", "param2"},null, "String", "foo.bar", "Type", 0);
	}
	
	public void testDecodeIndexKey_17() {
		runDecodeIndexKeyTest("myFunction/String,/param1,param2//", "myFunction", new String[]{null, null}, new String[]{"String", null}, new String[] {"param1", "param2"},null, null, null, null, 0);
	}
	
	public void testDecodeIndexKey_18() {
		runDecodeIndexKeyTest("myFunction/String,/param1,param2/String/", "myFunction", new String[]{null, null}, new String[]{"String", null}, new String[] {"param1", "param2"},null, "String", null, null, 0);
	}
	
	public void testDecodeIndexKey_19() {
		runDecodeIndexKeyTest("myFunction/String,/param1,param2//foo.bar.Type", "myFunction", new String[]{null, null}, new String[]{"String", null}, new String[] {"param1", "param2"},null, null, "foo.bar", "Type", 0);
	}
	
	public void testDecodeIndexKey_20() {
		runDecodeIndexKeyTest("myFunction/String,/param1,param2/String/foo.bar.Type", "myFunction", new String[]{null, null}, new String[]{"String", null}, new String[] {"param1", "param2"},null, "String", "foo.bar", "Type", 0);
	}
	
	public void testDecodeIndexKey_21() {
		runDecodeIndexKeyTest("myFunction/bar.foo.String,neto.crazy.Number/param1,param2//", "myFunction", new String[]{"bar.foo", "neto.crazy"}, new String[]{"String", "Number"}, new String[] {"param1", "param2"},null, null, null, null, 0);
	}
	
	public void testDecodeIndexKey_22() {
		runDecodeIndexKeyTest("myFunction/bar.foo.String,neto.crazy.Number/param1,param2/String/", "myFunction", new String[]{"bar.foo", "neto.crazy"}, new String[]{"String", "Number"}, new String[] {"param1", "param2"},null, "String", null, null, 0);
	}
	
	public void testDecodeIndexKey_23() {
		runDecodeIndexKeyTest("myFunction/bar.foo.String,neto.crazy.Number/param1,param2//foo.bar.Type", "myFunction", new String[]{"bar.foo", "neto.crazy"}, new String[]{"String", "Number"}, new String[] {"param1", "param2"},null, null, "foo.bar", "Type", 0);
	}
	
	public void testDecodeIndexKey_24() {
		runDecodeIndexKeyTest("myFunction/bar.foo.String,neto.crazy.Number/param1,param2/String/foo.bar.Type", "myFunction", new String[]{"bar.foo", "neto.crazy"}, new String[]{"String", "Number"}, new String[] {"param1", "param2"},null, "String", "foo.bar", "Type", 0);
	}
	
	public void testDecodeIndexKey_25() {
		runDecodeIndexKeyTest("myFunction/,neto.crazy.Number/param1,param2//", "myFunction", new String[]{null, "neto.crazy"}, new String[]{null, "Number"}, new String[] {"param1", "param2"},null, null, null, null, 0);
	}
	
	public void testDecodeIndexKey_26() {
		runDecodeIndexKeyTest("myFunction/,neto.crazy.Number/param1,param2/String/", "myFunction", new String[]{null, "neto.crazy"}, new String[]{null, "Number"}, new String[] {"param1", "param2"},null, "String", null, null, 0);
	}
	
	public void testDecodeIndexKey_27() {
		runDecodeIndexKeyTest("myFunction/,neto.crazy.Number/param1,param2//foo.bar.Type", "myFunction", new String[]{null, "neto.crazy"}, new String[]{null, "Number"}, new String[] {"param1", "param2"},null, null, "foo.bar", "Type", 0);
	}
	
	public void testDecodeIndexKey_28() {
		runDecodeIndexKeyTest("myFunction/,neto.crazy.Number/param1,param2/String/foo.bar.Type", "myFunction", new String[]{null, "neto.crazy"}, new String[]{null, "Number"}, new String[] {"param1", "param2"},null, "String", "foo.bar", "Type", 0);
	}
	
	public void testDecodeIndexKey_29() {
		runDecodeIndexKeyTest("myFunction/bar.foo.String,/param1,param2//", "myFunction", new String[]{"bar.foo", null}, new String[]{"String", null}, new String[] {"param1", "param2"},null, null, null, null, 0);
	}
	
	public void testDecodeIndexKey_30() {
		runDecodeIndexKeyTest("myFunction/bar.foo.String,/param1,param2/String/", "myFunction", new String[]{"bar.foo", null}, new String[]{"String", null}, new String[] {"param1", "param2"},null, "String", null, null, 0);
	}
	
	public void testDecodeIndexKey_31() {
		runDecodeIndexKeyTest("myFunction/bar.foo.String,/param1,param2//foo.bar.Type", "myFunction", new String[]{"bar.foo", null}, new String[]{"String", null}, new String[] {"param1", "param2"},null, null, "foo.bar", "Type", 0);
	}
	
	public void testDecodeIndexKey_32() {
		runDecodeIndexKeyTest("myFunction/bar.foo.String,/param1,param2/String/foo.bar.Type", "myFunction", new String[]{"bar.foo", null}, new String[]{"String", null}, new String[] {"param1", "param2"},null, "String", "foo.bar", "Type", 0);
	}
	
	/**
	 * <p>Runs the asserts for a single create index key test.</p>
	 * 
	 * @param expected
	 * @param selector
	 * @param parameterCount
	 * @param parameterFullTypeNames
	 * @param parameterNames
	 * @param declaringFullTypeName
	 * @param returnFullTypeName
	 * @param modifiers
	 */
	private static void runCreateIndexKeyTest(String expected,
			char[] selector,
			char[][] parameterFullTypeNames,
			char[][] parameterNames,
			char[] declaringFullTypeName,
			char[] returnFullTypeName,
			int modifiers) {
		
		char[] indexKey = MethodPattern.createIndexKey(selector, parameterFullTypeNames, parameterNames, declaringFullTypeName, returnFullTypeName, modifiers);
		
		String expectedWithModifiers = expected + (char) modifiers + (char) (modifiers>>16);
		
		assertNotNull("The created index key should not be null.\nEXPECTED:\n" + expectedWithModifiers, indexKey);
		
		assertTrue("The expected index key does not match the generated index key.\nWAS:\n" + new String(indexKey) + "\nEXPECTED:\n" + expected,
				CharOperation.equals(indexKey, expectedWithModifiers.toCharArray()));
	}
	
	/**
	 * <p>Runs a single decode index key test</p>
	 * 
	 * @param key
	 * @param selector
	 * @param parameterCount
	 * @param parameterQualifications
	 * @param parameterSimpleNames
	 * @param parameterNames
	 * @param returnQualification
	 * @param returnSimpleName
	 * @param declaringQualification
	 * @param declaringSimpleName
	 * @param modifiers
	 */
	private static void runDecodeIndexKeyTest(String key,
			String selector,
			String[] parameterQualifications,
			String[] parameterSimpleNames,
			String[] parameterNames,
			String returnQualification,
			String returnSimpleName,
			String declaringQualification,
			String declaringSimpleName,
			int modifiers) {
		
		char[] keyWithModifiers = new char[key.length() + 3];
		System.arraycopy(key.toCharArray(), 0, keyWithModifiers, 0, key.length());
		keyWithModifiers[keyWithModifiers.length-3] = '/';
		keyWithModifiers[keyWithModifiers.length-2] = (char) modifiers;
		keyWithModifiers[keyWithModifiers.length-1] = (char) (modifiers>>16);
		
		MethodPattern pattern = new MethodPattern(false, false, false, null, 0);
		pattern = (MethodPattern)pattern.getBlankPattern();
		pattern.decodeIndexKey(keyWithModifiers);
		
		assertEquals("Expected selector does not equal decoded selector.", selector, pattern.selector);
		assertEquals("Expected parameter qualifications does not equal decoded parameter qualifications.", parameterQualifications, pattern.parameterQualifications);
		assertEquals("Expected parameter simple names does not equal decoded parameter simple names.", parameterSimpleNames, pattern.parameterSimpleNames);
		assertEquals("Expected parameter names does not equal decoded parameter names.", parameterNames, pattern.parameterNames);
		assertEquals("Expected return qualification does not equal decoded return wualification.", returnQualification, pattern.returnQualification);
		assertEquals("Expected return simple name does not equal decoded return simple name.", returnSimpleName, pattern.returnSimpleName);
		assertEquals("Expected declaring qualification does not equal decoded declaring qualification.", declaringQualification, pattern.getDeclaringQualification());
		assertEquals("Expected declaring simple name does not equal decoded declaring simple name.", declaringSimpleName, pattern.getDeclaringSimpleName());
	}
	
	private static void assertEquals(String message, String expected, char[] chars) {
		String actual = null;
		if(chars != null) {
			actual = new String(chars);
		}
		
		assertEquals(message, expected, actual);
	}
	
	private static void assertEquals(String message, String[] expected, char[][] actual) {
		
		String actualColappsed = null;
		if(actual != null) {
			char[] actualColappsedChars = CharOperation.concatWith(actual, IIndexConstants.PARAMETER_SEPARATOR, false);
			if(actualColappsedChars != null) {
				actualColappsed = new String(actualColappsedChars);
			}
		}
		
		String expectedColappsed = null;
		if(expected != null) {
			StringBuilder expectedColappsedBuilder = new StringBuilder();
			for(int i = 0; i < expected.length; ++i) {
				if(i > 0) {
					expectedColappsedBuilder.append(',');
				}
				
				if(expected[i] != null) {
					expectedColappsedBuilder.append(expected[i]);
				}
			}
			expectedColappsed = expectedColappsedBuilder.toString();
		}
		
		assertEquals(message, expectedColappsed, actualColappsed);
	}
}

Back to the top