|
1 |
package org.gvsig.utils.search;
|
|
2 |
|
|
3 |
import java.text.Collator;
|
|
4 |
import java.util.ArrayList;
|
|
5 |
import java.util.Collections;
|
|
6 |
import java.util.Comparator;
|
|
7 |
import java.util.List;
|
|
8 |
import java.util.Locale;
|
|
9 |
import java.util.Vector;
|
|
10 |
|
|
11 |
import org.gvsig.utils.CompareLists;
|
|
12 |
import org.gvsig.utils.StringComparator;
|
|
13 |
import org.gvsig.utils.search.BinarySearchUsingFirstCharacters;
|
|
14 |
|
|
15 |
|
|
16 |
import junit.framework.TestCase;
|
|
17 |
|
|
18 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
|
19 |
*
|
|
20 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
|
21 |
*
|
|
22 |
* This program is free software; you can redistribute it and/or
|
|
23 |
* modify it under the terms of the GNU General Public License
|
|
24 |
* as published by the Free Software Foundation; either version 2
|
|
25 |
* of the License, or (at your option) any later version.
|
|
26 |
*
|
|
27 |
* This program is distributed in the hope that it will be useful,
|
|
28 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
29 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
30 |
* GNU General Public License for more details.
|
|
31 |
*
|
|
32 |
* You should have received a copy of the GNU General Public License
|
|
33 |
* along with this program; if not, write to the Free Software
|
|
34 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
|
35 |
*
|
|
36 |
* For more information, contact:
|
|
37 |
*
|
|
38 |
* Generalitat Valenciana
|
|
39 |
* Conselleria d'Infraestructures i Transport
|
|
40 |
* Av. Blasco Ib??ez, 50
|
|
41 |
* 46010 VALENCIA
|
|
42 |
* SPAIN
|
|
43 |
*
|
|
44 |
* +34 963862235
|
|
45 |
* gvsig@gva.es
|
|
46 |
* www.gvsig.gva.es
|
|
47 |
*
|
|
48 |
* or
|
|
49 |
*
|
|
50 |
* IVER T.I. S.A
|
|
51 |
* Salamanca 50
|
|
52 |
* 46005 Valencia
|
|
53 |
* Spain
|
|
54 |
*
|
|
55 |
* +34 963163400
|
|
56 |
* dac@iver.es
|
|
57 |
*/
|
|
58 |
|
|
59 |
/**
|
|
60 |
* Tests the static methods of BinarySearchUsingFirstCharacters
|
|
61 |
*
|
|
62 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
|
63 |
*/
|
|
64 |
public class TestBinarySearchUsingFirstCharacters extends TestCase {
|
|
65 |
private static String text;
|
|
66 |
private static Vector v1;
|
|
67 |
private static Vector v2;
|
|
68 |
private static List list;
|
|
69 |
private static List results;
|
|
70 |
private static StringComparator stringComparator;
|
|
71 |
// private static StringComparatorForItems stringComparatorForItems;
|
|
72 |
|
|
73 |
/*
|
|
74 |
* (non-Javadoc)
|
|
75 |
* @see junit.framework.TestCase#setUp()
|
|
76 |
*/
|
|
77 |
protected void setUp() throws Exception {
|
|
78 |
super.setUp();
|
|
79 |
|
|
80 |
// Initialize the text
|
|
81 |
text = "";
|
|
82 |
|
|
83 |
// Initialize the StringComparator
|
|
84 |
stringComparator = new StringComparator();
|
|
85 |
|
|
86 |
// Initialize the StringComparatorForItems
|
|
87 |
// stringComparatorForItems = new StringComparatorForItems();
|
|
88 |
|
|
89 |
// Initialize the vector of Items (for test methods without the parameter Comparator)
|
|
90 |
v1 = new Vector();
|
|
91 |
v1.add(new Item("extWMS"));
|
|
92 |
v1.add(new Item("libUI"));
|
|
93 |
v1.add(new Item("extWMS"));
|
|
94 |
v1.add(new Item("libRemoteServices"));
|
|
95 |
v1.add(new Item("extWFS2"));
|
|
96 |
v1.add(new Item("libNomenclatorIGN"));
|
|
97 |
v1.add(new Item("libNomenclatorIGN_GUI"));
|
|
98 |
v1.add(new Item("libIverUtiles"));
|
|
99 |
v1.add(new Item("extWFS2"));
|
|
100 |
v1.add(new Item("EXTWFS2"));
|
|
101 |
v1.add(new Item("extWFS2"));
|
|
102 |
v1.add(new Item("libGDBMS"));
|
|
103 |
v1.add(new Item("libInternationalization"));
|
|
104 |
v1.add(new Item("libFMap"));
|
|
105 |
v1.add(new Item("libuiDownCase"));
|
|
106 |
v1.add(new Item("6"));
|
|
107 |
v1.add(new Item("4"));
|
|
108 |
v1.add(new Item("3"));
|
|
109 |
v1.add(new Item("5"));
|
|
110 |
v1.add(new Item("2"));
|
|
111 |
v1.add(new Item("1"));
|
|
112 |
v1.add(new Item("extWFS2"));
|
|
113 |
v1.add(new Item("libExceptions"));
|
|
114 |
v1.add(new Item("libDriverManager"));
|
|
115 |
v1.add(new Item("libCq CMS for java"));
|
|
116 |
v1.add(new Item("libCorePlugin"));
|
|
117 |
v1.add(new Item("extWFS2"));
|
|
118 |
v1.add(new Item("extAddIDEELayers"));
|
|
119 |
v1.add(new Item("extAlertCClient"));
|
|
120 |
v1.add(new Item("extCAD"));
|
|
121 |
v1.add(new Item("extWFS2"));
|
|
122 |
v1.add(new Item("?and?"));
|
|
123 |
v1.add(new Item("?and?"));
|
|
124 |
v1.add(new Item("extJDBC"));
|
|
125 |
v1.add(new Item("extMyPlugin"));
|
|
126 |
v1.add(new Item("extRasterTools"));
|
|
127 |
v1.add(new Item("extScripting"));
|
|
128 |
v1.add(new Item("extWCS"));
|
|
129 |
v1.add(new Item("extWFS2"));
|
|
130 |
v1.add(new Item("extwfs2"));
|
|
131 |
v1.add(new Item("extWMS"));
|
|
132 |
v1.add(new Item("extWMS"));
|
|
133 |
v1.add(new Item("extWCS"));
|
|
134 |
v1.add(new Item("7"));
|
|
135 |
v1.add(new Item("9"));
|
|
136 |
v1.add(new Item("8"));
|
|
137 |
v1.add(new Item("0"));
|
|
138 |
v1.add(new Item("EXTWCS"));
|
|
139 |
v1.add(new Item("?and?"));
|
|
140 |
v1.add(new Item("extensi?n"));
|
|
141 |
v1.add(new Item("?AND?"));
|
|
142 |
v1.add(new Item("_fwAndami"));
|
|
143 |
v1.add(new Item("abcdefghijklmn?opqrstuvwxyz"));
|
|
144 |
v1.add(new Item("?"));
|
|
145 |
v1.add(new Item("appgvSIG"));
|
|
146 |
v1.add(new Item("la casa"));
|
|
147 |
v1.add(new Item("la monta?a"));
|
|
148 |
v1.add(new Item("la colina"));
|
|
149 |
v1.add(new Item("las abejas"));
|
|
150 |
v1.add(new Item("las nutrias"));
|
|
151 |
v1.add(new Item("las ballenas"));
|
|
152 |
v1.add(new Item("lasa?a"));
|
|
153 |
v1.add(new Item("Vector"));
|
|
154 |
v1.add(new Item("?e"));
|
|
155 |
|
|
156 |
// Initialize the vector of Strings (for test methods with the parameter Comparator)
|
|
157 |
v2 = new Vector();
|
|
158 |
v2.add("extWMS");
|
|
159 |
v2.add("libUI");
|
|
160 |
v2.add("extWMS");
|
|
161 |
v2.add("libRemoteServices");
|
|
162 |
v2.add("extWFS2");
|
|
163 |
v2.add("libNomenclatorIGN");
|
|
164 |
v2.add("libNomenclatorIGN_GUI");
|
|
165 |
v2.add("libIverUtiles");
|
|
166 |
v2.add("extWFS2");
|
|
167 |
v2.add("EXTWFS2");
|
|
168 |
v2.add("extWFS2");
|
|
169 |
v2.add("libGDBMS");
|
|
170 |
v2.add("libInternationalization");
|
|
171 |
v2.add("libFMap");
|
|
172 |
v2.add("libuiDownCase");
|
|
173 |
v2.add("6");
|
|
174 |
v2.add("4");
|
|
175 |
v2.add("3");
|
|
176 |
v2.add("5");
|
|
177 |
v2.add("2");
|
|
178 |
v2.add("1");
|
|
179 |
v2.add("extWFS2");
|
|
180 |
v2.add("libExceptions");
|
|
181 |
v2.add("libDriverManager");
|
|
182 |
v2.add("libCq CMS for java");
|
|
183 |
v2.add("libCorePlugin");
|
|
184 |
v2.add("extWFS2");
|
|
185 |
v2.add("extAddIDEELayers");
|
|
186 |
v2.add("extAlertCClient");
|
|
187 |
v2.add("extCAD");
|
|
188 |
v2.add("extWFS2");
|
|
189 |
v2.add("?and?");
|
|
190 |
v2.add("?and?");
|
|
191 |
v2.add("extJDBC");
|
|
192 |
v2.add("extMyPlugin");
|
|
193 |
v2.add("extRasterTools");
|
|
194 |
v2.add("extScripting");
|
|
195 |
v2.add("extWCS");
|
|
196 |
v2.add("extWFS2");
|
|
197 |
v2.add("extwfs2");
|
|
198 |
v2.add("extWMS");
|
|
199 |
v2.add("extWMS");
|
|
200 |
v2.add("extWCS");
|
|
201 |
v2.add("7");
|
|
202 |
v2.add("9");
|
|
203 |
v2.add("8");
|
|
204 |
v2.add("0");
|
|
205 |
v2.add("EXTWCS");
|
|
206 |
v2.add("?and?");
|
|
207 |
v2.add("extensi?n");
|
|
208 |
v2.add("?AND?");
|
|
209 |
v2.add("_fwAndami");
|
|
210 |
v2.add("abcdefghijklmn?opqrstuvwxyz");
|
|
211 |
v2.add("?");
|
|
212 |
v2.add("appgvSIG");
|
|
213 |
v2.add("la casa");
|
|
214 |
v2.add("la monta?a");
|
|
215 |
v2.add("la colina");
|
|
216 |
v2.add("las abejas");
|
|
217 |
v2.add("las nutrias");
|
|
218 |
v2.add("las ballenas");
|
|
219 |
v2.add("lasa?a");
|
|
220 |
v2.add("Vector");
|
|
221 |
v2.add("?e");
|
|
222 |
|
|
223 |
// Sort items of the two vectors
|
|
224 |
Collator collator = Collator.getInstance(new Locale("es_ES"));
|
|
225 |
// stringComparatorForItems.setLocaleRules(stringComparatorForItems.new LocaleRules(true, collator));
|
|
226 |
// Collections.sort(v1.subList(0, v1.size()), stringComparatorForItems);
|
|
227 |
|
|
228 |
// The algorithm of sort is the default used by Java (that makes some subsets: one for numbers, one for words that starts in big letters,
|
|
229 |
// another that stats in small letters, another with 'special' characters, etc)
|
|
230 |
Collections.sort(v1.subList(0, v1.size()));
|
|
231 |
|
|
232 |
stringComparator.setLocaleRules(stringComparator.new LocaleRules(true, collator));
|
|
233 |
Collections.sort(v2.subList(0, v2.size()), stringComparator);
|
|
234 |
}
|
|
235 |
|
|
236 |
/*
|
|
237 |
* (non-Javadoc)
|
|
238 |
* @see junit.framework.TestCase#tearDown()
|
|
239 |
*/
|
|
240 |
protected void tearDown() throws Exception {
|
|
241 |
super.tearDown();
|
|
242 |
}
|
|
243 |
|
|
244 |
///// TEST OPERATION: doSearchConsideringCaseSensitive(String, Vector) /////
|
|
245 |
|
|
246 |
/**
|
|
247 |
* A test
|
|
248 |
*/
|
|
249 |
public void test1() {
|
|
250 |
try {
|
|
251 |
text = "";
|
|
252 |
list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v1);
|
|
253 |
|
|
254 |
// List of results
|
|
255 |
results = v1.subList(0, v1.size());
|
|
256 |
|
|
257 |
System.out.println("Test 1:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
258 |
|
|
259 |
if (CompareLists.compare(list, results)) {
|
|
260 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
|
|
261 |
} else {
|
|
262 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
|
|
263 |
fail();
|
|
264 |
}
|
|
265 |
} catch (Exception e) {
|
|
266 |
e.printStackTrace();
|
|
267 |
}
|
|
268 |
}
|
|
269 |
|
|
270 |
/**
|
|
271 |
* A test
|
|
272 |
*/
|
|
273 |
public void test2() {
|
|
274 |
try {
|
|
275 |
text = "ext";
|
|
276 |
list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive("ext", v1);
|
|
277 |
|
|
278 |
// List of results
|
|
279 |
results = new ArrayList();
|
|
280 |
results.add(new Item("extAddIDEELayers"));
|
|
281 |
results.add(new Item("extAlertCClient"));
|
|
282 |
results.add(new Item("extCAD"));
|
|
283 |
results.add(new Item("extJDBC"));
|
|
284 |
results.add(new Item("extMyPlugin"));
|
|
285 |
results.add(new Item("extRasterTools"));
|
|
286 |
results.add(new Item("extScripting"));
|
|
287 |
results.add(new Item("extWCS"));
|
|
288 |
results.add(new Item("extWCS"));
|
|
289 |
results.add(new Item("extWFS2"));
|
|
290 |
results.add(new Item("extWFS2"));
|
|
291 |
results.add(new Item("extWFS2"));
|
|
292 |
results.add(new Item("extWFS2"));
|
|
293 |
results.add(new Item("extWFS2"));
|
|
294 |
results.add(new Item("extWFS2"));
|
|
295 |
results.add(new Item("extWFS2"));
|
|
296 |
results.add(new Item("extWMS"));
|
|
297 |
results.add(new Item("extWMS"));
|
|
298 |
results.add(new Item("extWMS"));
|
|
299 |
results.add(new Item("extWMS"));
|
|
300 |
results.add(new Item("extensi?n"));
|
|
301 |
results.add(new Item("extwfs2"));
|
|
302 |
|
|
303 |
System.out.println("\nTest 2:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
304 |
|
|
305 |
if (CompareLists.compare(list, results)) {
|
|
306 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
|
|
307 |
} else {
|
|
308 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
|
|
309 |
fail();
|
|
310 |
}
|
|
311 |
} catch (Exception e) {
|
|
312 |
e.printStackTrace();
|
|
313 |
}
|
|
314 |
}
|
|
315 |
|
|
316 |
/**
|
|
317 |
* A test
|
|
318 |
*/
|
|
319 |
public void test3() {
|
|
320 |
try {
|
|
321 |
text = "libUI";
|
|
322 |
list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v1);
|
|
323 |
|
|
324 |
// List of results
|
|
325 |
results = new ArrayList();
|
|
326 |
results.add(new Item("libUI"));
|
|
327 |
|
|
328 |
System.out.println("\nTest 3:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
329 |
|
|
330 |
if (CompareLists.compare(list, results)) {
|
|
331 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
|
|
332 |
} else {
|
|
333 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
|
|
334 |
fail();
|
|
335 |
}
|
|
336 |
} catch (Exception e) {
|
|
337 |
e.printStackTrace();
|
|
338 |
}
|
|
339 |
}
|
|
340 |
|
|
341 |
/**
|
|
342 |
* A test
|
|
343 |
*/
|
|
344 |
public void test4() {
|
|
345 |
try {
|
|
346 |
text = "extWFS2";
|
|
347 |
list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v1);
|
|
348 |
|
|
349 |
// List 4 of results
|
|
350 |
results = new ArrayList();
|
|
351 |
results.add(new Item("extWFS2"));
|
|
352 |
results.add(new Item("extWFS2"));
|
|
353 |
results.add(new Item("extWFS2"));
|
|
354 |
results.add(new Item("extWFS2"));
|
|
355 |
results.add(new Item("extWFS2"));
|
|
356 |
results.add(new Item("extWFS2"));
|
|
357 |
results.add(new Item("extWFS2"));
|
|
358 |
|
|
359 |
System.out.println("\nTest 4:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
360 |
|
|
361 |
if (CompareLists.compare(list, results)) {
|
|
362 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
|
|
363 |
} else {
|
|
364 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
|
|
365 |
fail();
|
|
366 |
}
|
|
367 |
} catch (Exception e) {
|
|
368 |
e.printStackTrace();
|
|
369 |
}
|
|
370 |
}
|
|
371 |
|
|
372 |
/**
|
|
373 |
* A test
|
|
374 |
*/
|
|
375 |
public void test5() {
|
|
376 |
try {
|
|
377 |
text = "extWFS2a";
|
|
378 |
list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v1);
|
|
379 |
|
|
380 |
// List of results (without elements)
|
|
381 |
results = null;
|
|
382 |
|
|
383 |
System.out.println("\nTest 5:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
384 |
|
|
385 |
if (CompareLists.compare(list, results)) {
|
|
386 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
|
|
387 |
} else {
|
|
388 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
|
|
389 |
fail();
|
|
390 |
}
|
|
391 |
} catch (Exception e) {
|
|
392 |
e.printStackTrace();
|
|
393 |
}
|
|
394 |
}
|
|
395 |
|
|
396 |
/**
|
|
397 |
* A test
|
|
398 |
*/
|
|
399 |
public void test6() {
|
|
400 |
try {
|
|
401 |
text = "?and?";
|
|
402 |
list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v1);
|
|
403 |
|
|
404 |
// List of results
|
|
405 |
results = new ArrayList();
|
|
406 |
results.add(new Item("?and?"));
|
|
407 |
|
|
408 |
System.out.println("\nTest 6:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
409 |
|
|
410 |
if (CompareLists.compare(list, results)) {
|
|
411 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
|
|
412 |
} else {
|
|
413 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
|
|
414 |
fail();
|
|
415 |
}
|
|
416 |
} catch (Exception e) {
|
|
417 |
e.printStackTrace();
|
|
418 |
}
|
|
419 |
}
|
|
420 |
|
|
421 |
/**
|
|
422 |
* A test
|
|
423 |
*/
|
|
424 |
public void test7() {
|
|
425 |
try {
|
|
426 |
text = "?AND?";
|
|
427 |
list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v1);
|
|
428 |
|
|
429 |
// List of results
|
|
430 |
results = new ArrayList();
|
|
431 |
results.add(new Item("?AND?"));
|
|
432 |
|
|
433 |
System.out.println("\nTest 7:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
434 |
|
|
435 |
if (CompareLists.compare(list, results)) {
|
|
436 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
|
|
437 |
} else {
|
|
438 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
|
|
439 |
fail();
|
|
440 |
}
|
|
441 |
} catch (Exception e) {
|
|
442 |
e.printStackTrace();
|
|
443 |
}
|
|
444 |
}
|
|
445 |
|
|
446 |
/**
|
|
447 |
* A test
|
|
448 |
*/
|
|
449 |
public void test8() {
|
|
450 |
try {
|
|
451 |
text = "la ";
|
|
452 |
list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v1);
|
|
453 |
|
|
454 |
// List of results
|
|
455 |
results = new ArrayList();
|
|
456 |
results.add(new Item("la casa"));
|
|
457 |
results.add(new Item("la colina"));
|
|
458 |
results.add(new Item("la monta?a"));
|
|
459 |
|
|
460 |
System.out.println("\nTest 8:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
461 |
|
|
462 |
if (CompareLists.compare(list, results)) {
|
|
463 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
|
|
464 |
} else {
|
|
465 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
|
|
466 |
fail();
|
|
467 |
}
|
|
468 |
} catch (Exception e) {
|
|
469 |
e.printStackTrace();
|
|
470 |
}
|
|
471 |
}
|
|
472 |
|
|
473 |
/**
|
|
474 |
* A test
|
|
475 |
*/
|
|
476 |
public void test9() {
|
|
477 |
try {
|
|
478 |
text = "livUI";
|
|
479 |
list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v1);
|
|
480 |
|
|
481 |
// List of results (without elements)
|
|
482 |
results = null;
|
|
483 |
|
|
484 |
System.out.println("\nTest 9:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
485 |
|
|
486 |
if (CompareLists.compare(list, results)) {
|
|
487 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
|
|
488 |
} else {
|
|
489 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
|
|
490 |
fail();
|
|
491 |
}
|
|
492 |
} catch (Exception e) {
|
|
493 |
e.printStackTrace();
|
|
494 |
}
|
|
495 |
}
|
|
496 |
|
|
497 |
/**
|
|
498 |
* A test
|
|
499 |
*/
|
|
500 |
public void test9_1() {
|
|
501 |
try {
|
|
502 |
text = "libui";
|
|
503 |
list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v1);
|
|
504 |
|
|
505 |
// List of results (without elements)
|
|
506 |
results = new ArrayList();
|
|
507 |
results.add(new Item("libuiDownCase"));
|
|
508 |
|
|
509 |
System.out.println("\nTest 9_1:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
510 |
|
|
511 |
if (CompareLists.compare(list, results)) {
|
|
512 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
|
|
513 |
} else {
|
|
514 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
|
|
515 |
fail();
|
|
516 |
}
|
|
517 |
} catch (Exception e) {
|
|
518 |
e.printStackTrace();
|
|
519 |
}
|
|
520 |
}
|
|
521 |
|
|
522 |
/**
|
|
523 |
* A test
|
|
524 |
*/
|
|
525 |
public void test10() {
|
|
526 |
try {
|
|
527 |
text = "?";
|
|
528 |
list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v1);
|
|
529 |
|
|
530 |
// List of results (without elements)
|
|
531 |
results = new ArrayList();
|
|
532 |
results.add(new Item("?"));
|
|
533 |
|
|
534 |
System.out.println("\nTest 10:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
535 |
|
|
536 |
if (CompareLists.compare(list, results)) {
|
|
537 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
|
|
538 |
} else {
|
|
539 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
|
|
540 |
fail();
|
|
541 |
}
|
|
542 |
} catch (Exception e) {
|
|
543 |
e.printStackTrace();
|
|
544 |
}
|
|
545 |
}
|
|
546 |
///// END TEST OPERATION: doSearchConsideringCaseSensitive(String, Vector) /////
|
|
547 |
|
|
548 |
///// TEST OPERATION: doSearchWithoutConsideringCaseSensitive(String, Vector) /////
|
|
549 |
|
|
550 |
/**
|
|
551 |
* A test
|
|
552 |
*/
|
|
553 |
public void test11() {
|
|
554 |
try {
|
|
555 |
text = "";
|
|
556 |
list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
|
|
557 |
|
|
558 |
// List of results
|
|
559 |
results = v1.subList(0, v1.size());
|
|
560 |
|
|
561 |
System.out.println("\nTest 11:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
562 |
|
|
563 |
if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
|
|
564 |
System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
|
|
565 |
} else {
|
|
566 |
System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
|
|
567 |
fail();
|
|
568 |
}
|
|
569 |
} catch (Exception e) {
|
|
570 |
e.printStackTrace();
|
|
571 |
}
|
|
572 |
}
|
|
573 |
|
|
574 |
/**
|
|
575 |
* A test
|
|
576 |
*/
|
|
577 |
public void test12() {
|
|
578 |
try {
|
|
579 |
text = "ext";
|
|
580 |
list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
|
|
581 |
|
|
582 |
// List of results
|
|
583 |
results = new ArrayList();
|
|
584 |
results.add(new Item("extAddIDEELayers"));
|
|
585 |
results.add(new Item("extAlertCClient"));
|
|
586 |
results.add(new Item("extCAD"));
|
|
587 |
results.add(new Item("extJDBC"));
|
|
588 |
results.add(new Item("extMyPlugin"));
|
|
589 |
results.add(new Item("extRasterTools"));
|
|
590 |
results.add(new Item("extScripting"));
|
|
591 |
results.add(new Item("extWCS"));
|
|
592 |
results.add(new Item("extWCS"));
|
|
593 |
results.add(new Item("extWFS2"));
|
|
594 |
results.add(new Item("extWFS2"));
|
|
595 |
results.add(new Item("extWFS2"));
|
|
596 |
results.add(new Item("extWFS2"));
|
|
597 |
results.add(new Item("extWFS2"));
|
|
598 |
results.add(new Item("extWFS2"));
|
|
599 |
results.add(new Item("extWFS2"));
|
|
600 |
results.add(new Item("extWMS"));
|
|
601 |
results.add(new Item("extWMS"));
|
|
602 |
results.add(new Item("extWMS"));
|
|
603 |
results.add(new Item("extWMS"));
|
|
604 |
results.add(new Item("extensi?n"));
|
|
605 |
results.add(new Item("extwfs2"));
|
|
606 |
|
|
607 |
System.out.println("Test 12:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
608 |
|
|
609 |
if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
|
|
610 |
System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
|
|
611 |
} else {
|
|
612 |
System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
|
|
613 |
fail();
|
|
614 |
}
|
|
615 |
} catch (Exception e) {
|
|
616 |
e.printStackTrace();
|
|
617 |
}
|
|
618 |
}
|
|
619 |
|
|
620 |
/**
|
|
621 |
* A test
|
|
622 |
*/
|
|
623 |
public void test13() {
|
|
624 |
try {
|
|
625 |
text = "libUI";
|
|
626 |
list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
|
|
627 |
|
|
628 |
// List of results
|
|
629 |
results = new ArrayList();
|
|
630 |
results.add(new Item("libUI"));
|
|
631 |
results.add(new Item("libuiDownCase"));
|
|
632 |
|
|
633 |
System.out.println("Test 13:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
634 |
|
|
635 |
if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
|
|
636 |
System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
|
|
637 |
} else {
|
|
638 |
System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
|
|
639 |
fail();
|
|
640 |
}
|
|
641 |
} catch (Exception e) {
|
|
642 |
e.printStackTrace();
|
|
643 |
}
|
|
644 |
}
|
|
645 |
|
|
646 |
/**
|
|
647 |
* A test
|
|
648 |
*/
|
|
649 |
public void test14() {
|
|
650 |
try {
|
|
651 |
text = "extWFS2";
|
|
652 |
list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
|
|
653 |
|
|
654 |
// List of results
|
|
655 |
results = new ArrayList();
|
|
656 |
results.add(new Item("extWFS2"));
|
|
657 |
results.add(new Item("extWFS2"));
|
|
658 |
results.add(new Item("extWFS2"));
|
|
659 |
results.add(new Item("extWFS2"));
|
|
660 |
results.add(new Item("extWFS2"));
|
|
661 |
results.add(new Item("extWFS2"));
|
|
662 |
results.add(new Item("extWFS2"));
|
|
663 |
results.add(new Item("extwfs2"));
|
|
664 |
|
|
665 |
System.out.println("Test 14:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
666 |
|
|
667 |
if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
|
|
668 |
System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
|
|
669 |
} else {
|
|
670 |
System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
|
|
671 |
fail();
|
|
672 |
}
|
|
673 |
} catch (Exception e) {
|
|
674 |
e.printStackTrace();
|
|
675 |
}
|
|
676 |
}
|
|
677 |
|
|
678 |
/**
|
|
679 |
* A test
|
|
680 |
*/
|
|
681 |
public void test15() {
|
|
682 |
try {
|
|
683 |
text = "extWFS2a";
|
|
684 |
list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
|
|
685 |
|
|
686 |
// List of results (without elements)
|
|
687 |
results = null;
|
|
688 |
|
|
689 |
System.out.println("Test 15:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
690 |
|
|
691 |
if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
|
|
692 |
System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
|
|
693 |
} else {
|
|
694 |
System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
|
|
695 |
fail();
|
|
696 |
}
|
|
697 |
} catch (Exception e) {
|
|
698 |
e.printStackTrace();
|
|
699 |
}
|
|
700 |
}
|
|
701 |
|
|
702 |
/**
|
|
703 |
* A test
|
|
704 |
*/
|
|
705 |
public void test16() {
|
|
706 |
try {
|
|
707 |
text = "?";
|
|
708 |
list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
|
|
709 |
|
|
710 |
// List of results
|
|
711 |
results = new ArrayList();
|
|
712 |
results.add(new Item("?e"));
|
|
713 |
results.add(new Item("?"));
|
|
714 |
|
|
715 |
System.out.println("Test 16:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
716 |
|
|
717 |
if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
|
|
718 |
System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
|
|
719 |
} else {
|
|
720 |
System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
|
|
721 |
fail();
|
|
722 |
}
|
|
723 |
} catch (Exception e) {
|
|
724 |
e.printStackTrace();
|
|
725 |
}
|
|
726 |
}
|
|
727 |
|
|
728 |
/**
|
|
729 |
* A test
|
|
730 |
*/
|
|
731 |
public void test17() {
|
|
732 |
try {
|
|
733 |
text = "La ";
|
|
734 |
list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
|
|
735 |
|
|
736 |
// List of results
|
|
737 |
results = new ArrayList();
|
|
738 |
results.add(new Item("la casa"));
|
|
739 |
results.add(new Item("la colina"));
|
|
740 |
results.add(new Item("la monta?a"));
|
|
741 |
|
|
742 |
System.out.println("Test 17:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
743 |
|
|
744 |
if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
|
|
745 |
System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
|
|
746 |
} else {
|
|
747 |
System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
|
|
748 |
fail();
|
|
749 |
}
|
|
750 |
} catch (Exception e) {
|
|
751 |
e.printStackTrace();
|
|
752 |
}
|
|
753 |
}
|
|
754 |
|
|
755 |
/**
|
|
756 |
* A test
|
|
757 |
*/
|
|
758 |
public void test18() {
|
|
759 |
try {
|
|
760 |
text = "livUI";
|
|
761 |
list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
|
|
762 |
|
|
763 |
// List of results
|
|
764 |
results = null;
|
|
765 |
|
|
766 |
System.out.println("Test 18:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
767 |
|
|
768 |
if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
|
|
769 |
System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
|
|
770 |
} else {
|
|
771 |
System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
|
|
772 |
fail();
|
|
773 |
}
|
|
774 |
} catch (Exception e) {
|
|
775 |
e.printStackTrace();
|
|
776 |
}
|
|
777 |
}
|
|
778 |
|
|
779 |
/**
|
|
780 |
* A test
|
|
781 |
*/
|
|
782 |
public void test18_1() {
|
|
783 |
try {
|
|
784 |
text = "libui";
|
|
785 |
list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
|
|
786 |
|
|
787 |
// List of results
|
|
788 |
results = new ArrayList();
|
|
789 |
results.add(new Item("libUI"));
|
|
790 |
results.add(new Item("libuiDownCase"));
|
|
791 |
|
|
792 |
System.out.println("Test 18_1:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
793 |
|
|
794 |
if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
|
|
795 |
System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
|
|
796 |
} else {
|
|
797 |
System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
|
|
798 |
fail();
|
|
799 |
}
|
|
800 |
} catch (Exception e) {
|
|
801 |
e.printStackTrace();
|
|
802 |
}
|
|
803 |
}
|
|
804 |
|
|
805 |
/**
|
|
806 |
* A test
|
|
807 |
*/
|
|
808 |
public void test19() {
|
|
809 |
try {
|
|
810 |
text = "?AND?";
|
|
811 |
list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
|
|
812 |
|
|
813 |
// List of results
|
|
814 |
results = new ArrayList();
|
|
815 |
results.add(new Item("?AND?"));
|
|
816 |
results.add(new Item("?and?"));
|
|
817 |
results.add(new Item("?and?"));
|
|
818 |
results.add(new Item("?and?"));
|
|
819 |
|
|
820 |
System.out.println("Test 19:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
821 |
|
|
822 |
if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
|
|
823 |
System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
|
|
824 |
} else {
|
|
825 |
System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
|
|
826 |
fail();
|
|
827 |
}
|
|
828 |
} catch (Exception e) {
|
|
829 |
e.printStackTrace();
|
|
830 |
}
|
|
831 |
}
|
|
832 |
|
|
833 |
///// END TEST OPERATION: doSearchWithoutConsideringCaseSensitive(String, Vector) /////
|
|
834 |
|
|
835 |
///// TEST OPERATION: doSearchConsideringCaseSensitive(String, Vector, Comparator) /////
|
|
836 |
/**
|
|
837 |
* A test
|
|
838 |
*/
|
|
839 |
public void test21() {
|
|
840 |
try {
|
|
841 |
text = "";
|
|
842 |
stringComparator.setCaseSensitive(true);
|
|
843 |
list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v2, stringComparator);
|
|
844 |
|
|
845 |
// List of results
|
|
846 |
results = v2.subList(0, v2.size());
|
|
847 |
|
|
848 |
System.out.println("Test 21:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
849 |
|
|
850 |
if (CompareLists.compare(list, results, stringComparator)) {
|
|
851 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> OK");
|
|
852 |
} else {
|
|
853 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> FAILED");
|
|
854 |
fail();
|
|
855 |
}
|
|
856 |
} catch (Exception e) {
|
|
857 |
e.printStackTrace();
|
|
858 |
}
|
|
859 |
}
|
|
860 |
|
|
861 |
/**
|
|
862 |
* A test
|
|
863 |
*/
|
|
864 |
public void test22() {
|
|
865 |
try {
|
|
866 |
text = "ext";
|
|
867 |
stringComparator.setCaseSensitive(true);
|
|
868 |
list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v2, stringComparator);
|
|
869 |
|
|
870 |
// List of results
|
|
871 |
results = new ArrayList();
|
|
872 |
results.add("extAddIDEELayers");
|
|
873 |
results.add("extAlertCClient");
|
|
874 |
results.add("extCAD");
|
|
875 |
results.add("extensi?n");
|
|
876 |
results.add("extJDBC");
|
|
877 |
results.add("extMyPlugin");
|
|
878 |
results.add("extRasterTools");
|
|
879 |
results.add("extScripting");
|
|
880 |
results.add("extWCS");
|
|
881 |
results.add("extWCS");
|
|
882 |
results.add("extwfs2");
|
|
883 |
results.add("extWFS2");
|
|
884 |
results.add("extWFS2");
|
|
885 |
results.add("extWFS2");
|
|
886 |
results.add("extWFS2");
|
|
887 |
results.add("extWFS2");
|
|
888 |
results.add("extWFS2");
|
|
889 |
results.add("extWFS2");
|
|
890 |
results.add("extWMS");
|
|
891 |
results.add("extWMS");
|
|
892 |
results.add("extWMS");
|
|
893 |
results.add("extWMS");
|
|
894 |
|
|
895 |
|
|
896 |
System.out.println("\nTest 22:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
897 |
|
|
898 |
if (CompareLists.compare(list, results, stringComparator)) {
|
|
899 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> OK");
|
|
900 |
} else {
|
|
901 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> FAILED");
|
|
902 |
fail();
|
|
903 |
}
|
|
904 |
} catch (Exception e) {
|
|
905 |
e.printStackTrace();
|
|
906 |
}
|
|
907 |
}
|
|
908 |
|
|
909 |
/**
|
|
910 |
* A test
|
|
911 |
*/
|
|
912 |
public void test23() {
|
|
913 |
try {
|
|
914 |
text = "libUI";
|
|
915 |
stringComparator.setCaseSensitive(true);
|
|
916 |
list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v2, stringComparator);
|
|
917 |
|
|
918 |
// List of results
|
|
919 |
results = new ArrayList();
|
|
920 |
results.add("libUI");
|
|
921 |
|
|
922 |
System.out.println("\nTest 23:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
923 |
|
|
924 |
if (CompareLists.compare(list, results, stringComparator)) {
|
|
925 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> OK");
|
|
926 |
} else {
|
|
927 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> FAILED");
|
|
928 |
fail();
|
|
929 |
}
|
|
930 |
} catch (Exception e) {
|
|
931 |
e.printStackTrace();
|
|
932 |
}
|
|
933 |
}
|
|
934 |
|
|
935 |
/**
|
|
936 |
* A test
|
|
937 |
*/
|
|
938 |
public void test24() {
|
|
939 |
try {
|
|
940 |
text = "extWFS2";
|
|
941 |
stringComparator.setCaseSensitive(true);
|
|
942 |
list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v2, stringComparator);
|
|
943 |
|
|
944 |
// List 4 of results
|
|
945 |
results = new ArrayList();
|
|
946 |
results.add("extWFS2");
|
|
947 |
results.add("extWFS2");
|
|
948 |
results.add("extWFS2");
|
|
949 |
results.add("extWFS2");
|
|
950 |
results.add("extWFS2");
|
|
951 |
results.add("extWFS2");
|
|
952 |
results.add("extWFS2");
|
|
953 |
|
|
954 |
System.out.println("\nTest 24:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
955 |
|
|
956 |
if (CompareLists.compare(list, results, stringComparator)) {
|
|
957 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> OK");
|
|
958 |
} else {
|
|
959 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> FAILED");
|
|
960 |
fail();
|
|
961 |
}
|
|
962 |
} catch (Exception e) {
|
|
963 |
e.printStackTrace();
|
|
964 |
}
|
|
965 |
}
|
|
966 |
|
|
967 |
/**
|
|
968 |
* A test
|
|
969 |
*/
|
|
970 |
public void test25() {
|
|
971 |
try {
|
|
972 |
text = "extWFS2a";
|
|
973 |
stringComparator.setCaseSensitive(true);
|
|
974 |
list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v2, stringComparator);
|
|
975 |
|
|
976 |
// List of results (without elements)
|
|
977 |
results = null;
|
|
978 |
|
|
979 |
System.out.println("\nTest 25:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
980 |
|
|
981 |
if (CompareLists.compare(list, results, stringComparator)) {
|
|
982 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> OK");
|
|
983 |
} else {
|
|
984 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> FAILED");
|
|
985 |
fail();
|
|
986 |
}
|
|
987 |
} catch (Exception e) {
|
|
988 |
e.printStackTrace();
|
|
989 |
}
|
|
990 |
}
|
|
991 |
|
|
992 |
/**
|
|
993 |
* A test
|
|
994 |
*/
|
|
995 |
public void test26() {
|
|
996 |
try {
|
|
997 |
text = "?and?";
|
|
998 |
stringComparator.setCaseSensitive(true);
|
|
999 |
list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v2, stringComparator);
|
|
1000 |
|
|
1001 |
// List of results
|
|
1002 |
results = new ArrayList();
|
|
1003 |
results.add("?and?");
|
|
1004 |
|
|
1005 |
System.out.println("\nTest 26:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
1006 |
|
|
1007 |
if (CompareLists.compare(list, results, stringComparator)) {
|
|
1008 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> OK");
|
|
1009 |
} else {
|
|
1010 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> FAILED");
|
|
1011 |
fail();
|
|
1012 |
}
|
|
1013 |
} catch (Exception e) {
|
|
1014 |
e.printStackTrace();
|
|
1015 |
}
|
|
1016 |
}
|
|
1017 |
|
|
1018 |
/**
|
|
1019 |
* A test
|
|
1020 |
*/
|
|
1021 |
public void test27() {
|
|
1022 |
try {
|
|
1023 |
text = "?AND?";
|
|
1024 |
stringComparator.setCaseSensitive(true);
|
|
1025 |
list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v2, stringComparator);
|
|
1026 |
|
|
1027 |
// List of results
|
|
1028 |
results = new ArrayList();
|
|
1029 |
results.add("?AND?");
|
|
1030 |
|
|
1031 |
System.out.println("\nTest 27:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
1032 |
|
|
1033 |
if (CompareLists.compare(list, results, stringComparator)) {
|
|
1034 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> OK");
|
|
1035 |
} else {
|
|
1036 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> FAILED");
|
|
1037 |
fail();
|
|
1038 |
}
|
|
1039 |
} catch (Exception e) {
|
|
1040 |
e.printStackTrace();
|
|
1041 |
}
|
|
1042 |
}
|
|
1043 |
|
|
1044 |
/**
|
|
1045 |
* A test
|
|
1046 |
*/
|
|
1047 |
public void test28() {
|
|
1048 |
try {
|
|
1049 |
text = "la ";
|
|
1050 |
stringComparator.setCaseSensitive(true);
|
|
1051 |
list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v2, stringComparator);
|
|
1052 |
|
|
1053 |
// List of results
|
|
1054 |
results = new ArrayList();
|
|
1055 |
results.add("la casa");
|
|
1056 |
results.add("la colina");
|
|
1057 |
results.add("la monta?a");
|
|
1058 |
|
|
1059 |
System.out.println("\nTest 28:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
1060 |
|
|
1061 |
if (CompareLists.compare(list, results, stringComparator)) {
|
|
1062 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> OK");
|
|
1063 |
} else {
|
|
1064 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> FAILED");
|
|
1065 |
fail();
|
|
1066 |
}
|
|
1067 |
} catch (Exception e) {
|
|
1068 |
e.printStackTrace();
|
|
1069 |
}
|
|
1070 |
}
|
|
1071 |
|
|
1072 |
/**
|
|
1073 |
* A test
|
|
1074 |
*/
|
|
1075 |
public void test29() {
|
|
1076 |
try {
|
|
1077 |
text = "livUI";
|
|
1078 |
stringComparator.setCaseSensitive(true);
|
|
1079 |
list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v2, stringComparator);
|
|
1080 |
|
|
1081 |
// List of results (without elements)
|
|
1082 |
results = null;
|
|
1083 |
|
|
1084 |
System.out.println("\nTest 29:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
1085 |
|
|
1086 |
if (CompareLists.compare(list, results, stringComparator)) {
|
|
1087 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> OK");
|
|
1088 |
} else {
|
|
1089 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> FAILED");
|
|
1090 |
fail();
|
|
1091 |
}
|
|
1092 |
} catch (Exception e) {
|
|
1093 |
e.printStackTrace();
|
|
1094 |
}
|
|
1095 |
}
|
|
1096 |
|
|
1097 |
/**
|
|
1098 |
* A test
|
|
1099 |
*/
|
|
1100 |
public void test29_1() {
|
|
1101 |
try {
|
|
1102 |
text = "libui";
|
|
1103 |
stringComparator.setCaseSensitive(true);
|
|
1104 |
list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v2, stringComparator); //<- Esta b?squeda
|
|
1105 |
|
|
1106 |
// List of results (without elements)
|
|
1107 |
results = new ArrayList();
|
|
1108 |
results.add("libuiDownCase");
|
|
1109 |
|
|
1110 |
System.out.println("\nTest 29_1:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
1111 |
|
|
1112 |
if (CompareLists.compare(list, results, stringComparator)) {
|
|
1113 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> OK");
|
|
1114 |
} else {
|
|
1115 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> FAILED");
|
|
1116 |
fail();
|
|
1117 |
}
|
|
1118 |
} catch (Exception e) {
|
|
1119 |
e.printStackTrace();
|
|
1120 |
}
|
|
1121 |
}
|
|
1122 |
|
|
1123 |
/**
|
|
1124 |
* A test
|
|
1125 |
*/
|
|
1126 |
public void test30() {
|
|
1127 |
try {
|
|
1128 |
text = "?";
|
|
1129 |
stringComparator.setCaseSensitive(true);
|
|
1130 |
list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v2, stringComparator);
|
|
1131 |
|
|
1132 |
// List of results (without elements)
|
|
1133 |
results = new ArrayList();
|
|
1134 |
results.add("?");
|
|
1135 |
|
|
1136 |
System.out.println("\nTest 30:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
1137 |
|
|
1138 |
if (CompareLists.compare(list, results, stringComparator)) {
|
|
1139 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> OK");
|
|
1140 |
} else {
|
|
1141 |
System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> FAILED");
|
|
1142 |
fail();
|
|
1143 |
}
|
|
1144 |
} catch (Exception e) {
|
|
1145 |
e.printStackTrace();
|
|
1146 |
}
|
|
1147 |
}
|
|
1148 |
///// END TEST OPERATION: doSearchConsideringCaseSensitive(String, Vector, Comparator) /////
|
|
1149 |
|
|
1150 |
///// TEST OPERATION: doSearchWithoutConsideringCaseSensitive(String, Vector, Comparator) /////
|
|
1151 |
|
|
1152 |
/**
|
|
1153 |
* A test
|
|
1154 |
*/
|
|
1155 |
public void test31() {
|
|
1156 |
try {
|
|
1157 |
text = "";
|
|
1158 |
stringComparator.setCaseSensitive(false);
|
|
1159 |
list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v2, stringComparator);
|
|
1160 |
|
|
1161 |
// List of results
|
|
1162 |
results = v2.subList(0, v2.size());
|
|
1163 |
|
|
1164 |
System.out.println("\nTest 31:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
1165 |
|
|
1166 |
if (CompareLists.compareIgnoringCaseSensitive(list, results, stringComparator)) {
|
|
1167 |
System.out.println("Op: doSearchWithoutConsideringCaseSensitive(String, Vector, Comparator) -> OK");
|
|
1168 |
} else {
|
|
1169 |
System.out.println("Op: doSearchWithoutConsideringCaseSensitive(String, Vector, Comparator) -> FAILED");
|
|
1170 |
fail();
|
|
1171 |
}
|
|
1172 |
} catch (Exception e) {
|
|
1173 |
e.printStackTrace();
|
|
1174 |
}
|
|
1175 |
}
|
|
1176 |
|
|
1177 |
/**
|
|
1178 |
* A test
|
|
1179 |
*/
|
|
1180 |
public void test32() {
|
|
1181 |
try {
|
|
1182 |
text = "ext";
|
|
1183 |
stringComparator.setCaseSensitive(false);
|
|
1184 |
list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v2, stringComparator);
|
|
1185 |
|
|
1186 |
// List of results
|
|
1187 |
results = new ArrayList();
|
|
1188 |
results.add("extAddIDEELayers");
|
|
1189 |
results.add("extAlertCClient");
|
|
1190 |
results.add("extCAD");
|
|
1191 |
results.add("extensi?n");
|
|
1192 |
results.add("extJDBC");
|
|
1193 |
results.add("extMyPlugin");
|
|
1194 |
results.add("extRasterTools");
|
|
1195 |
results.add("extScripting");
|
|
1196 |
results.add("extWCS");
|
|
1197 |
results.add("extWCS");
|
|
1198 |
results.add("EXTWCS");
|
|
1199 |
results.add("extwfs2");
|
|
1200 |
results.add("extWFS2");
|
|
1201 |
results.add("extWFS2");
|
|
1202 |
results.add("extWFS2");
|
|
1203 |
results.add("extWFS2");
|
|
1204 |
results.add("extWFS2");
|
|
1205 |
results.add("extWFS2");
|
|
1206 |
results.add("extWFS2");
|
|
1207 |
results.add("EXTWFS2");
|
|
1208 |
results.add("extWMS");
|
|
1209 |
results.add("extWMS");
|
|
1210 |
results.add("extWMS");
|
|
1211 |
results.add("extWMS");
|
|
1212 |
|
|
1213 |
System.out.println("Test 32:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
1214 |
|
|
1215 |
if (CompareLists.compareIgnoringCaseSensitive(list, results, stringComparator)) {
|
|
1216 |
System.out.println("Op: doSearchWithoutConsideringCaseSensitive(String, Vector, Comparator) -> OK");
|
|
1217 |
} else {
|
|
1218 |
System.out.println("Op: doSearchWithoutConsideringCaseSensitive(String, Vector, Comparator) -> FAILED");
|
|
1219 |
fail();
|
|
1220 |
}
|
|
1221 |
} catch (Exception e) {
|
|
1222 |
e.printStackTrace();
|
|
1223 |
}
|
|
1224 |
}
|
|
1225 |
|
|
1226 |
/**
|
|
1227 |
* A test
|
|
1228 |
*/
|
|
1229 |
public void test33() {
|
|
1230 |
try {
|
|
1231 |
text = "LIBui";
|
|
1232 |
stringComparator.setCaseSensitive(false);
|
|
1233 |
list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v2, stringComparator);
|
|
1234 |
|
|
1235 |
// List of results
|
|
1236 |
results = new ArrayList();
|
|
1237 |
results.add("libUI");
|
|
1238 |
results.add("libuiDownCase");
|
|
1239 |
|
|
1240 |
System.out.println("Test 33:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
1241 |
|
|
1242 |
if (CompareLists.compareIgnoringCaseSensitive(list, results, stringComparator)) {
|
|
1243 |
System.out.println("Op: doSearchWithoutConsideringCaseSensitive(String, Vector, Comparator) -> OK");
|
|
1244 |
} else {
|
|
1245 |
System.out.println("Op: doSearchWithoutConsideringCaseSensitive(String, Vector, Comparator) -> FAILED");
|
|
1246 |
fail();
|
|
1247 |
}
|
|
1248 |
} catch (Exception e) {
|
|
1249 |
e.printStackTrace();
|
|
1250 |
}
|
|
1251 |
}
|
|
1252 |
|
|
1253 |
/**
|
|
1254 |
* A test
|
|
1255 |
*/
|
|
1256 |
public void test34() {
|
|
1257 |
try {
|
|
1258 |
text = "extWFS2";
|
|
1259 |
stringComparator.setCaseSensitive(false);
|
|
1260 |
list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v2, stringComparator);
|
|
1261 |
|
|
1262 |
// List of results
|
|
1263 |
results = new ArrayList();
|
|
1264 |
results.add("extwfs2");
|
|
1265 |
results.add("extWFS2");
|
|
1266 |
results.add("extWFS2");
|
|
1267 |
results.add("extWFS2");
|
|
1268 |
results.add("extWFS2");
|
|
1269 |
results.add("extWFS2");
|
|
1270 |
results.add("extWFS2");
|
|
1271 |
results.add("extWFS2");
|
|
1272 |
results.add("EXTWFS2");
|
|
1273 |
|
|
1274 |
System.out.println("Test 34:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
1275 |
|
|
1276 |
if (CompareLists.compareIgnoringCaseSensitive(list, results, stringComparator)) {
|
|
1277 |
System.out.println("Op: doSearchWithoutConsideringCaseSensitive(String, Vector, Comparator) -> OK");
|
|
1278 |
} else {
|
|
1279 |
System.out.println("Op: doSearchWithoutConsideringCaseSensitive(String, Vector, Comparator) -> FAILED");
|
|
1280 |
fail();
|
|
1281 |
}
|
|
1282 |
} catch (Exception e) {
|
|
1283 |
e.printStackTrace();
|
|
1284 |
}
|
|
1285 |
}
|
|
1286 |
|
|
1287 |
/**
|
|
1288 |
* A test
|
|
1289 |
*/
|
|
1290 |
public void test35() {
|
|
1291 |
try {
|
|
1292 |
text = "extWFS2a";
|
|
1293 |
stringComparator.setCaseSensitive(false);
|
|
1294 |
list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v2, stringComparator);
|
|
1295 |
|
|
1296 |
// List of results (without elements)
|
|
1297 |
results = null;
|
|
1298 |
|
|
1299 |
System.out.println("Test 35:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
|
|
1300 |
|
|
1301 |
if (CompareLists.compareIgnoringCaseSensitive(list, results, stringComparator)) {
|
|
1302 |
System.out.println("Op: doSearchWithoutConsideringCaseSensitive(String, Vector, Comparator) -> OK");
|
|
1303 |
} else {
|
|
1304 |
System.out.println("Op: doSearchWithoutConsideringCaseSensitive(String, Vector, Comparator) -> FAILED");
|
|
1305 |
fail();
|
|
1306 |
}
|
|
1307 |
} catch (Exception e) {
|
|
1308 |
e.printStackTrace();
|
|
1309 |
}
|
|
1310 |
}
|
|
1311 |
|
|
1312 |
/**
|
|
1313 |
* A test
|
|
1314 |
*/
|
|
1315 |
public void test36() {
|
|
1316 |
try {
|
|
1317 |
text = "?aNd?";
|
|
1318 |
stringComparator.setCaseSensitive(false);
|
|
1319 |
list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v2, stringComparator);
|
|
1320 |
|