1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.datamodel; |
22 |
|
|
23 |
|
import static org.testng.Assert.assertNull; |
24 |
|
import static org.testng.AssertJUnit.assertEquals; |
25 |
|
import static org.testng.AssertJUnit.assertFalse; |
26 |
|
import static org.testng.AssertJUnit.assertTrue; |
27 |
|
|
28 |
|
import jalview.analysis.AlignmentGenerator; |
29 |
|
|
30 |
|
import java.util.Arrays; |
31 |
|
import java.util.BitSet; |
32 |
|
import java.util.Iterator; |
33 |
|
|
34 |
|
import org.testng.annotations.Test; |
35 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (787) |
Complexity: 29 |
Complexity Density: 0.04 |
|
36 |
|
public class HiddenColumnsTest |
37 |
|
{ |
38 |
|
|
39 |
|
|
40 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
41 |
1 |
@Test(groups = { "Functional" })... |
42 |
|
public void testGetSize() |
43 |
|
{ |
44 |
1 |
HiddenColumns hidden = new HiddenColumns(); |
45 |
1 |
assertEquals(0, hidden.getSize()); |
46 |
|
|
47 |
1 |
hidden.hideColumns(3, 5); |
48 |
1 |
assertEquals(3, hidden.getSize()); |
49 |
|
|
50 |
1 |
hidden.hideColumns(8, 8); |
51 |
1 |
assertEquals(4, hidden.getSize()); |
52 |
|
|
53 |
1 |
hidden.hideColumns(9, 14); |
54 |
1 |
assertEquals(10, hidden.getSize()); |
55 |
|
|
56 |
1 |
ColumnSelection cs = new ColumnSelection(); |
57 |
1 |
hidden.revealAllHiddenColumns(cs); |
58 |
1 |
assertEquals(0, hidden.getSize()); |
59 |
|
} |
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
65 |
1 |
@Test(groups = { "Functional" })... |
66 |
|
public void testFindColumnPosition() |
67 |
|
{ |
68 |
1 |
HiddenColumns cs = new HiddenColumns(); |
69 |
1 |
assertEquals(5, cs.absoluteToVisibleColumn(5)); |
70 |
|
|
71 |
|
|
72 |
1 |
cs.hideColumns(6, 6); |
73 |
1 |
assertEquals(5, cs.absoluteToVisibleColumn(5)); |
74 |
|
|
75 |
|
|
76 |
1 |
cs.hideColumns(4, 4); |
77 |
1 |
assertEquals(4, cs.absoluteToVisibleColumn(5)); |
78 |
|
|
79 |
|
|
80 |
1 |
assertEquals(3, cs.absoluteToVisibleColumn(4)); |
81 |
|
|
82 |
|
|
83 |
1 |
cs.hideColumns(1, 2); |
84 |
1 |
assertEquals(2, cs.absoluteToVisibleColumn(5)); |
85 |
|
|
86 |
|
|
87 |
|
|
88 |
1 |
HiddenColumns cs2 = new HiddenColumns(); |
89 |
1 |
cs2.hideColumns(5, 10); |
90 |
1 |
cs2.hideColumns(20, 27); |
91 |
1 |
cs2.hideColumns(40, 44); |
92 |
|
|
93 |
|
|
94 |
1 |
assertEquals(4, cs2.absoluteToVisibleColumn(8)); |
95 |
|
|
96 |
|
|
97 |
1 |
assertEquals(13, cs2.absoluteToVisibleColumn(24)); |
98 |
|
|
99 |
|
|
100 |
1 |
assertEquals(14, cs2.absoluteToVisibleColumn(28)); |
101 |
|
|
102 |
|
|
103 |
1 |
assertEquals(25, cs2.absoluteToVisibleColumn(40)); |
104 |
|
|
105 |
|
|
106 |
|
|
107 |
1 |
HiddenColumns cs3 = new HiddenColumns(); |
108 |
1 |
cs3.hideColumns(0, 4); |
109 |
1 |
assertEquals(0, cs3.absoluteToVisibleColumn(2)); |
110 |
|
|
111 |
|
|
112 |
1 |
assertEquals(46, cs2.absoluteToVisibleColumn(65)); |
113 |
|
} |
114 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (38) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
115 |
1 |
@Test(groups = { "Functional" })... |
116 |
|
public void testVisibleContigsIterator() |
117 |
|
{ |
118 |
1 |
HiddenColumns cs = new HiddenColumns(); |
119 |
|
|
120 |
1 |
Iterator<int[]> visible = cs.getVisContigsIterator(3, 10, false); |
121 |
1 |
int[] region = visible.next(); |
122 |
1 |
assertEquals("[3, 9]", Arrays.toString(region)); |
123 |
1 |
assertFalse(visible.hasNext()); |
124 |
|
|
125 |
1 |
cs.hideColumns(3, 6); |
126 |
1 |
cs.hideColumns(8, 9); |
127 |
1 |
cs.hideColumns(12, 12); |
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
1 |
visible = cs.getVisContigsIterator(1, 13, false); |
133 |
1 |
region = visible.next(); |
134 |
1 |
assertEquals("[1, 2]", Arrays.toString(region)); |
135 |
1 |
region = visible.next(); |
136 |
1 |
assertEquals("[7, 7]", Arrays.toString(region)); |
137 |
1 |
region = visible.next(); |
138 |
1 |
assertEquals("[10, 11]", Arrays.toString(region)); |
139 |
1 |
assertFalse(visible.hasNext()); |
140 |
|
|
141 |
|
|
142 |
1 |
visible = cs.getVisContigsIterator(4, 14, false); |
143 |
1 |
region = visible.next(); |
144 |
1 |
assertEquals("[7, 7]", Arrays.toString(region)); |
145 |
1 |
region = visible.next(); |
146 |
1 |
assertEquals("[10, 11]", Arrays.toString(region)); |
147 |
1 |
region = visible.next(); |
148 |
1 |
assertEquals("[13, 13]", Arrays.toString(region)); |
149 |
1 |
assertFalse(visible.hasNext()); |
150 |
|
|
151 |
|
|
152 |
1 |
visible = cs.getVisContigsIterator(3, 10, false); |
153 |
1 |
region = visible.next(); |
154 |
1 |
assertEquals("[7, 7]", Arrays.toString(region)); |
155 |
1 |
assertFalse(visible.hasNext()); |
156 |
|
|
157 |
|
|
158 |
1 |
visible = cs.getVisContigsIterator(0, 13, false); |
159 |
1 |
region = visible.next(); |
160 |
1 |
assertEquals("[0, 2]", Arrays.toString(region)); |
161 |
1 |
region = visible.next(); |
162 |
1 |
assertEquals("[7, 7]", Arrays.toString(region)); |
163 |
1 |
region = visible.next(); |
164 |
1 |
assertEquals("[10, 11]", Arrays.toString(region)); |
165 |
1 |
assertFalse(visible.hasNext()); |
166 |
|
|
167 |
|
|
168 |
1 |
visible = cs.getVisContigsIterator(4, 6, false); |
169 |
1 |
assertFalse(visible.hasNext()); |
170 |
|
} |
171 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
172 |
1 |
@Test(groups = { "Functional" })... |
173 |
|
public void testEquals() |
174 |
|
{ |
175 |
1 |
HiddenColumns cs = new HiddenColumns(); |
176 |
1 |
cs.hideColumns(5, 9); |
177 |
|
|
178 |
|
|
179 |
1 |
HiddenColumns cs2 = new HiddenColumns(); |
180 |
|
|
181 |
|
|
182 |
1 |
assertFalse(cs.equals(cs2)); |
183 |
1 |
assertFalse(cs2.equals(cs)); |
184 |
|
|
185 |
|
|
186 |
1 |
assertFalse(cs.equals(new HiddenColumnsCursor())); |
187 |
|
|
188 |
|
|
189 |
1 |
HiddenColumns cs3 = new HiddenColumns(); |
190 |
1 |
cs3.hideColumns(2, 3); |
191 |
1 |
assertFalse(cs.equals(cs3)); |
192 |
|
|
193 |
|
|
194 |
1 |
cs2.hideColumns(6, 9); |
195 |
1 |
assertFalse(cs.equals(cs2)); |
196 |
1 |
assertFalse(cs2.equals(cs)); |
197 |
|
|
198 |
1 |
cs2.hideColumns(5, 8); |
199 |
|
|
200 |
1 |
assertTrue(cs.equals(cs2)); |
201 |
1 |
assertTrue(cs.equals(cs)); |
202 |
1 |
assertTrue(cs2.equals(cs)); |
203 |
1 |
assertTrue(cs2.equals(cs2)); |
204 |
|
|
205 |
|
|
206 |
1 |
cs.hideColumns(10, 12); |
207 |
1 |
cs2.hideColumns(10, 15); |
208 |
1 |
assertFalse(cs.equals(cs2)); |
209 |
|
|
210 |
|
} |
211 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
212 |
1 |
@Test(groups = "Functional")... |
213 |
|
public void testCopyConstructor() |
214 |
|
{ |
215 |
1 |
HiddenColumns cs = new HiddenColumns(); |
216 |
1 |
cs.hideColumns(10, 11); |
217 |
1 |
cs.hideColumns(5, 7); |
218 |
1 |
Iterator<int[]> regions = cs.iterator(); |
219 |
1 |
assertEquals("[5, 7]", Arrays.toString(regions.next())); |
220 |
|
|
221 |
1 |
HiddenColumns cs2 = new HiddenColumns(cs); |
222 |
1 |
regions = cs2.iterator(); |
223 |
1 |
assertTrue(cs2.hasHiddenColumns()); |
224 |
1 |
assertEquals(2, cs2.getNumberOfRegions()); |
225 |
|
|
226 |
1 |
assertEquals("[5, 7]", Arrays.toString(regions.next())); |
227 |
1 |
assertEquals("[10, 11]", Arrays.toString(regions.next())); |
228 |
|
} |
229 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
230 |
1 |
@Test(groups = "Functional")... |
231 |
|
public void testCopyConstructor2() |
232 |
|
{ |
233 |
1 |
HiddenColumns cs = new HiddenColumns(); |
234 |
1 |
cs.hideColumns(10, 11); |
235 |
1 |
cs.hideColumns(5, 7); |
236 |
|
|
237 |
1 |
HiddenColumns cs2 = new HiddenColumns(cs, 3, 9, 1); |
238 |
1 |
assertTrue(cs2.hasHiddenColumns()); |
239 |
1 |
Iterator<int[]> regions = cs2.iterator(); |
240 |
|
|
241 |
|
|
242 |
1 |
assertEquals("[4, 6]", Arrays.toString(regions.next())); |
243 |
1 |
assertEquals(3, cs2.getSize()); |
244 |
|
|
245 |
1 |
cs2 = new HiddenColumns(cs, 8, 15, 4); |
246 |
1 |
regions = cs2.iterator(); |
247 |
1 |
assertTrue(cs2.hasHiddenColumns()); |
248 |
|
|
249 |
|
|
250 |
1 |
assertEquals("[6, 7]", Arrays.toString(regions.next())); |
251 |
1 |
assertEquals(2, cs2.getSize()); |
252 |
|
|
253 |
1 |
cs2 = new HiddenColumns(cs, 6, 10, 4); |
254 |
1 |
assertFalse(cs2.hasHiddenColumns()); |
255 |
|
} |
256 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (79) |
Complexity: 1 |
Complexity Density: 0.01 |
1PASS
|
|
257 |
1 |
@Test(groups = { "Functional" })... |
258 |
|
public void testHideColumns() |
259 |
|
{ |
260 |
|
|
261 |
1 |
AlignmentGenerator gen = new AlignmentGenerator(false); |
262 |
1 |
AlignmentI al = gen.generate(50, 20, 123, 5, 5); |
263 |
|
|
264 |
1 |
ColumnSelection colsel = new ColumnSelection(); |
265 |
1 |
HiddenColumns cs = al.getHiddenColumns(); |
266 |
1 |
colsel.hideSelectedColumns(5, al.getHiddenColumns()); |
267 |
1 |
Iterator<int[]> regions = cs.iterator(); |
268 |
1 |
assertEquals(1, cs.getNumberOfRegions()); |
269 |
1 |
assertEquals("[5, 5]", Arrays.toString(regions.next())); |
270 |
1 |
assertEquals(cs.getSize(), 1); |
271 |
|
|
272 |
1 |
colsel.hideSelectedColumns(3, al.getHiddenColumns()); |
273 |
1 |
regions = cs.iterator(); |
274 |
1 |
assertEquals(2, cs.getNumberOfRegions()); |
275 |
|
|
276 |
1 |
assertEquals("[3, 3]", Arrays.toString(regions.next())); |
277 |
1 |
assertEquals("[5, 5]", Arrays.toString(regions.next())); |
278 |
1 |
assertEquals(cs.getSize(), 2); |
279 |
|
|
280 |
|
|
281 |
|
|
282 |
1 |
colsel.hideSelectedColumns(4, al.getHiddenColumns()); |
283 |
1 |
regions = cs.iterator(); |
284 |
1 |
assertEquals(1, cs.getNumberOfRegions()); |
285 |
1 |
assertEquals("[3, 5]", Arrays.toString(regions.next())); |
286 |
1 |
assertEquals(cs.getSize(), 3); |
287 |
|
|
288 |
|
|
289 |
1 |
cs.revealAllHiddenColumns(colsel); |
290 |
|
|
291 |
1 |
assertEquals(0, cs.getNumberOfRegions()); |
292 |
1 |
assertEquals(cs.getSize(), 0); |
293 |
|
|
294 |
1 |
cs.hideColumns(3, 6); |
295 |
1 |
regions = cs.iterator(); |
296 |
1 |
int[] firstHiddenRange = regions.next(); |
297 |
1 |
assertEquals("[3, 6]", Arrays.toString(firstHiddenRange)); |
298 |
1 |
assertEquals(cs.getSize(), 4); |
299 |
|
|
300 |
|
|
301 |
1 |
cs.hideColumns(4, 5); |
302 |
1 |
regions = cs.iterator(); |
303 |
1 |
assertEquals(1, cs.getNumberOfRegions()); |
304 |
1 |
assertEquals("[3, 6]", Arrays.toString(regions.next())); |
305 |
1 |
assertEquals(cs.getSize(), 4); |
306 |
1 |
cs.hideColumns(3, 5); |
307 |
1 |
regions = cs.iterator(); |
308 |
1 |
assertEquals(1, cs.getNumberOfRegions()); |
309 |
1 |
assertEquals("[3, 6]", Arrays.toString(regions.next())); |
310 |
1 |
assertEquals(cs.getSize(), 4); |
311 |
1 |
cs.hideColumns(4, 6); |
312 |
1 |
regions = cs.iterator(); |
313 |
1 |
assertEquals(1, cs.getNumberOfRegions()); |
314 |
1 |
assertEquals("[3, 6]", Arrays.toString(regions.next())); |
315 |
1 |
assertEquals(cs.getSize(), 4); |
316 |
1 |
cs.hideColumns(3, 6); |
317 |
1 |
regions = cs.iterator(); |
318 |
1 |
assertEquals(1, cs.getNumberOfRegions()); |
319 |
1 |
assertEquals("[3, 6]", Arrays.toString(regions.next())); |
320 |
1 |
assertEquals(cs.getSize(), 4); |
321 |
|
|
322 |
1 |
cs.revealAllHiddenColumns(colsel); |
323 |
1 |
cs.hideColumns(2, 4); |
324 |
1 |
regions = cs.iterator(); |
325 |
1 |
assertEquals(1, cs.getNumberOfRegions()); |
326 |
1 |
assertEquals("[2, 4]", Arrays.toString(regions.next())); |
327 |
1 |
assertEquals(cs.getSize(), 3); |
328 |
|
|
329 |
|
|
330 |
1 |
cs.hideColumns(3, 5); |
331 |
1 |
regions = cs.iterator(); |
332 |
1 |
assertEquals(1, cs.getNumberOfRegions()); |
333 |
1 |
assertEquals("[2, 5]", Arrays.toString(regions.next())); |
334 |
1 |
assertEquals(cs.getSize(), 4); |
335 |
|
|
336 |
|
|
337 |
1 |
cs.hideColumns(5, 6); |
338 |
1 |
regions = cs.iterator(); |
339 |
1 |
assertEquals(1, cs.getNumberOfRegions()); |
340 |
1 |
assertEquals("[2, 6]", Arrays.toString(regions.next())); |
341 |
1 |
assertEquals(cs.getSize(), 5); |
342 |
|
|
343 |
|
|
344 |
1 |
cs.hideColumns(1, 7); |
345 |
1 |
regions = cs.iterator(); |
346 |
1 |
assertEquals(1, cs.getNumberOfRegions()); |
347 |
1 |
assertEquals("[1, 7]", Arrays.toString(regions.next())); |
348 |
1 |
assertEquals(cs.getSize(), 7); |
349 |
|
|
350 |
1 |
cs.revealAllHiddenColumns(colsel); |
351 |
1 |
cs.hideColumns(15, 18); |
352 |
1 |
cs.hideColumns(2, 4); |
353 |
1 |
cs.hideColumns(7, 9); |
354 |
1 |
regions = cs.iterator(); |
355 |
1 |
assertEquals(3, cs.getNumberOfRegions()); |
356 |
1 |
assertEquals("[2, 4]", Arrays.toString(regions.next())); |
357 |
1 |
assertEquals("[7, 9]", Arrays.toString(regions.next())); |
358 |
1 |
assertEquals("[15, 18]", Arrays.toString(regions.next())); |
359 |
1 |
assertEquals(cs.getSize(), 10); |
360 |
|
} |
361 |
|
|
362 |
|
|
363 |
|
|
364 |
|
|
365 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (25) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
366 |
1 |
@Test(groups = { "Functional" })... |
367 |
|
public void testRevealHiddenColumns() |
368 |
|
{ |
369 |
1 |
ColumnSelection colsel = new ColumnSelection(); |
370 |
1 |
HiddenColumns cs = new HiddenColumns(); |
371 |
|
|
372 |
|
|
373 |
1 |
cs.revealHiddenColumns(5, colsel); |
374 |
1 |
assertTrue(colsel.getSelected().isEmpty()); |
375 |
|
|
376 |
1 |
cs.hideColumns(5, 8); |
377 |
1 |
colsel.addElement(10); |
378 |
1 |
cs.revealHiddenColumns(5, colsel); |
379 |
|
|
380 |
|
|
381 |
1 |
assertEquals(0, cs.getSize()); |
382 |
|
|
383 |
|
|
384 |
1 |
assertEquals("[10, 5, 6, 7, 8]", colsel.getSelected().toString()); |
385 |
|
|
386 |
|
|
387 |
1 |
colsel = new ColumnSelection(); |
388 |
1 |
cs = new HiddenColumns(); |
389 |
1 |
cs.hideColumns(5, 8); |
390 |
|
|
391 |
1 |
int prevSize = cs.getSize(); |
392 |
1 |
cs.revealHiddenColumns(6, colsel); |
393 |
1 |
assertEquals(prevSize, cs.getSize()); |
394 |
1 |
assertTrue(colsel.getSelected().isEmpty()); |
395 |
|
|
396 |
|
|
397 |
1 |
cs.hideColumns(20, 23); |
398 |
|
|
399 |
1 |
assertEquals(2, cs.getNumberOfRegions()); |
400 |
|
|
401 |
1 |
cs.revealHiddenColumns(20, colsel); |
402 |
|
|
403 |
|
|
404 |
1 |
assertEquals(1, cs.getNumberOfRegions()); |
405 |
|
|
406 |
|
|
407 |
1 |
assertEquals("[20, 21, 22, 23]", colsel.getSelected().toString()); |
408 |
|
|
409 |
|
|
410 |
1 |
colsel.clear(); |
411 |
1 |
cs.revealHiddenColumns(20, colsel); |
412 |
|
|
413 |
1 |
assertEquals(1, cs.getNumberOfRegions()); |
414 |
1 |
assertTrue(colsel.getSelected().isEmpty()); |
415 |
|
} |
416 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
417 |
1 |
@Test(groups = { "Functional" })... |
418 |
|
public void testRevealAllHiddenColumns() |
419 |
|
{ |
420 |
1 |
HiddenColumns hidden = new HiddenColumns(); |
421 |
1 |
ColumnSelection colsel = new ColumnSelection(); |
422 |
|
|
423 |
|
|
424 |
1 |
hidden.revealAllHiddenColumns(colsel); |
425 |
1 |
assertTrue(colsel.getSelected().isEmpty()); |
426 |
|
|
427 |
1 |
hidden.hideColumns(5, 8); |
428 |
1 |
hidden.hideColumns(2, 3); |
429 |
1 |
colsel.addElement(11); |
430 |
1 |
colsel.addElement(1); |
431 |
1 |
hidden.revealAllHiddenColumns(colsel); |
432 |
|
|
433 |
|
|
434 |
|
|
435 |
|
|
436 |
|
|
437 |
|
|
438 |
|
|
439 |
1 |
assertEquals(0, hidden.getSize()); |
440 |
|
|
441 |
1 |
assertEquals("[11, 1, 2, 3, 5, 6, 7, 8]", |
442 |
|
colsel.getSelected().toString()); |
443 |
|
} |
444 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
445 |
1 |
@Test(groups = { "Functional" })... |
446 |
|
public void testIsVisible() |
447 |
|
{ |
448 |
1 |
HiddenColumns cs = new HiddenColumns(); |
449 |
1 |
assertTrue(cs.isVisible(5)); |
450 |
|
|
451 |
1 |
cs.hideColumns(2, 4); |
452 |
1 |
cs.hideColumns(6, 7); |
453 |
1 |
assertTrue(cs.isVisible(0)); |
454 |
1 |
assertTrue(cs.isVisible(-99)); |
455 |
1 |
assertTrue(cs.isVisible(1)); |
456 |
1 |
assertFalse(cs.isVisible(2)); |
457 |
1 |
assertFalse(cs.isVisible(3)); |
458 |
1 |
assertFalse(cs.isVisible(4)); |
459 |
1 |
assertTrue(cs.isVisible(5)); |
460 |
1 |
assertFalse(cs.isVisible(6)); |
461 |
1 |
assertFalse(cs.isVisible(7)); |
462 |
1 |
assertTrue(cs.isVisible(8)); |
463 |
|
} |
464 |
|
|
465 |
|
|
466 |
|
|
467 |
|
|
468 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (34) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
469 |
1 |
@Test(groups = { "Functional" })... |
470 |
|
public void testHideColumns_subsumingHidden() |
471 |
|
{ |
472 |
|
|
473 |
|
|
474 |
|
|
475 |
|
|
476 |
1 |
HiddenColumns cs = new HiddenColumns(); |
477 |
1 |
cs.hideColumns(49, 59); |
478 |
1 |
cs.hideColumns(69, 79); |
479 |
1 |
Iterator<int[]> regions = cs.iterator(); |
480 |
1 |
assertEquals(2, cs.getNumberOfRegions()); |
481 |
1 |
assertEquals("[49, 59]", Arrays.toString(regions.next())); |
482 |
1 |
assertEquals("[69, 79]", Arrays.toString(regions.next())); |
483 |
1 |
assertEquals(22, cs.getSize()); |
484 |
|
|
485 |
1 |
cs.hideColumns(48, 80); |
486 |
1 |
regions = cs.iterator(); |
487 |
1 |
assertEquals(1, cs.getNumberOfRegions()); |
488 |
1 |
assertEquals("[48, 80]", Arrays.toString(regions.next())); |
489 |
1 |
assertEquals(33, cs.getSize()); |
490 |
|
|
491 |
|
|
492 |
|
|
493 |
|
|
494 |
1 |
cs = new HiddenColumns(); |
495 |
1 |
cs.hideColumns(10, 20); |
496 |
1 |
cs.hideColumns(30, 40); |
497 |
1 |
cs.hideColumns(50, 60); |
498 |
|
|
499 |
1 |
cs.hideColumns(21, 49); |
500 |
1 |
regions = cs.iterator(); |
501 |
1 |
assertEquals(1, cs.getNumberOfRegions()); |
502 |
1 |
assertEquals("[10, 60]", Arrays.toString(regions.next())); |
503 |
1 |
assertEquals(51, cs.getSize()); |
504 |
|
|
505 |
|
|
506 |
|
|
507 |
|
|
508 |
|
|
509 |
1 |
cs = new HiddenColumns(); |
510 |
1 |
cs.hideColumns(10, 20); |
511 |
1 |
cs.hideColumns(10, 20); |
512 |
1 |
cs.hideColumns(30, 35); |
513 |
1 |
cs.hideColumns(40, 50); |
514 |
1 |
cs.hideColumns(60, 70); |
515 |
|
|
516 |
1 |
cs.hideColumns(15, 45); |
517 |
1 |
regions = cs.iterator(); |
518 |
1 |
assertEquals(2, cs.getNumberOfRegions()); |
519 |
1 |
assertEquals("[10, 50]", Arrays.toString(regions.next())); |
520 |
1 |
assertEquals("[60, 70]", Arrays.toString(regions.next())); |
521 |
1 |
assertEquals(52, cs.getSize()); |
522 |
|
} |
523 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (34) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
524 |
1 |
@Test(groups = { "Functional" })... |
525 |
|
public void testHideColumns_BitSet() |
526 |
|
{ |
527 |
1 |
HiddenColumns cs; |
528 |
|
|
529 |
1 |
BitSet one = new BitSet(); |
530 |
|
|
531 |
|
|
532 |
1 |
one.set(1); |
533 |
1 |
cs = new HiddenColumns(); |
534 |
1 |
cs.hideColumns(one); |
535 |
1 |
assertEquals(1, cs.getNumberOfRegions()); |
536 |
1 |
assertEquals(1, cs.getSize()); |
537 |
|
|
538 |
1 |
one.set(2); |
539 |
1 |
cs = new HiddenColumns(); |
540 |
1 |
cs.hideColumns(one); |
541 |
1 |
assertEquals(1, cs.getNumberOfRegions()); |
542 |
1 |
assertEquals(2, cs.getSize()); |
543 |
|
|
544 |
1 |
one.set(3); |
545 |
1 |
cs = new HiddenColumns(); |
546 |
1 |
cs.hideColumns(one); |
547 |
1 |
assertEquals(1, cs.getNumberOfRegions()); |
548 |
1 |
assertEquals(3, cs.getSize()); |
549 |
|
|
550 |
|
|
551 |
1 |
one.clear(2); |
552 |
1 |
cs = new HiddenColumns(); |
553 |
1 |
cs.hideColumns(one); |
554 |
1 |
assertEquals(2, cs.getNumberOfRegions()); |
555 |
1 |
assertEquals(2, cs.getSize()); |
556 |
|
|
557 |
1 |
assertEquals(0, cs.visibleToAbsoluteColumn(0)); |
558 |
1 |
assertEquals(2, cs.visibleToAbsoluteColumn(1)); |
559 |
1 |
assertEquals(4, cs.visibleToAbsoluteColumn(2)); |
560 |
|
|
561 |
|
|
562 |
1 |
one.clear(1); |
563 |
1 |
cs = new HiddenColumns(); |
564 |
1 |
cs.hideColumns(one); |
565 |
1 |
assertEquals(1, cs.getSize()); |
566 |
|
|
567 |
1 |
assertEquals(1, cs.getNumberOfRegions()); |
568 |
|
|
569 |
1 |
assertEquals(0, cs.visibleToAbsoluteColumn(0)); |
570 |
1 |
assertEquals(1, cs.visibleToAbsoluteColumn(1)); |
571 |
1 |
assertEquals(2, cs.visibleToAbsoluteColumn(2)); |
572 |
1 |
assertEquals(4, cs.visibleToAbsoluteColumn(3)); |
573 |
|
} |
574 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
575 |
1 |
@Test(groups = { "Functional" })... |
576 |
|
public void testRegionsToString() |
577 |
|
{ |
578 |
1 |
HiddenColumns hc = new HiddenColumns(); |
579 |
|
|
580 |
1 |
String result = hc.regionsToString(",", "--"); |
581 |
1 |
assertEquals("", result); |
582 |
|
|
583 |
1 |
hc.hideColumns(3, 7); |
584 |
1 |
hc.hideColumns(10, 10); |
585 |
1 |
hc.hideColumns(14, 15); |
586 |
|
|
587 |
1 |
result = hc.regionsToString(",", "--"); |
588 |
1 |
assertEquals("3--7,10--10,14--15", result); |
589 |
|
} |
590 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (25) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
591 |
1 |
@Test(groups = "Functional")... |
592 |
|
public void testGetVisibleStartAndEndIndex() |
593 |
|
{ |
594 |
1 |
Sequence seq = new Sequence("testSeq", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); |
595 |
1 |
AlignmentI align = new Alignment(new SequenceI[] { seq }); |
596 |
1 |
HiddenColumns hc = new HiddenColumns(); |
597 |
|
|
598 |
1 |
int[] startEnd = hc.getVisibleStartAndEndIndex(align.getWidth()); |
599 |
1 |
assertEquals(0, startEnd[0]); |
600 |
1 |
assertEquals(25, startEnd[1]); |
601 |
|
|
602 |
1 |
hc.hideColumns(0, 0); |
603 |
1 |
startEnd = hc.getVisibleStartAndEndIndex(align.getWidth()); |
604 |
1 |
assertEquals(1, startEnd[0]); |
605 |
1 |
assertEquals(25, startEnd[1]); |
606 |
|
|
607 |
1 |
hc.hideColumns(6, 9); |
608 |
1 |
hc.hideColumns(11, 12); |
609 |
1 |
startEnd = hc.getVisibleStartAndEndIndex(align.getWidth()); |
610 |
1 |
assertEquals(1, startEnd[0]); |
611 |
1 |
assertEquals(25, startEnd[1]); |
612 |
|
|
613 |
1 |
hc.hideColumns(24, 25); |
614 |
1 |
startEnd = hc.getVisibleStartAndEndIndex(align.getWidth()); |
615 |
1 |
System.out.println(startEnd[0] + " : " + startEnd[1]); |
616 |
1 |
assertEquals(1, startEnd[0]); |
617 |
1 |
assertEquals(23, startEnd[1]); |
618 |
|
|
619 |
|
|
620 |
1 |
hc = new HiddenColumns(); |
621 |
1 |
hc.hideColumns(3, 4); |
622 |
1 |
startEnd = hc.getVisibleStartAndEndIndex(align.getWidth()); |
623 |
1 |
assertEquals(0, startEnd[0]); |
624 |
1 |
assertEquals(25, startEnd[1]); |
625 |
|
} |
626 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (27) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
627 |
1 |
@Test(groups = "Functional")... |
628 |
|
public void testGetRegionWithEdgeAtRes() |
629 |
|
{ |
630 |
1 |
HiddenColumns hc = new HiddenColumns(); |
631 |
|
|
632 |
1 |
int[] result = hc.getRegionWithEdgeAtRes(5); |
633 |
1 |
assertNull(result); |
634 |
|
|
635 |
1 |
hc.hideColumns(3, 7); |
636 |
1 |
hc.hideColumns(10, 10); |
637 |
1 |
hc.hideColumns(14, 15); |
638 |
|
|
639 |
1 |
result = hc.getRegionWithEdgeAtRes(2); |
640 |
1 |
assertEquals(3, result[0]); |
641 |
1 |
assertEquals(7, result[1]); |
642 |
|
|
643 |
1 |
result = hc.getRegionWithEdgeAtRes(4); |
644 |
1 |
assertEquals(10, result[0]); |
645 |
1 |
assertEquals(10, result[1]); |
646 |
|
|
647 |
1 |
result = hc.getRegionWithEdgeAtRes(5); |
648 |
1 |
assertEquals(10, result[0]); |
649 |
1 |
assertEquals(10, result[1]); |
650 |
|
|
651 |
1 |
result = hc.getRegionWithEdgeAtRes(6); |
652 |
1 |
assertNull(result); |
653 |
|
|
654 |
1 |
result = hc.getRegionWithEdgeAtRes(0); |
655 |
1 |
assertNull(result); |
656 |
|
|
657 |
1 |
result = hc.getRegionWithEdgeAtRes(7); |
658 |
1 |
assertEquals(14, result[0]); |
659 |
1 |
assertEquals(15, result[1]); |
660 |
|
|
661 |
1 |
result = hc.getRegionWithEdgeAtRes(8); |
662 |
1 |
assertEquals(14, result[0]); |
663 |
1 |
assertEquals(15, result[1]); |
664 |
|
|
665 |
1 |
result = hc.getRegionWithEdgeAtRes(16); |
666 |
1 |
assertNull(result); |
667 |
|
} |
668 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
669 |
1 |
@Test(groups = "Functional")... |
670 |
|
public void testHasHiddenColumns() |
671 |
|
{ |
672 |
1 |
HiddenColumns h = new HiddenColumns(); |
673 |
|
|
674 |
|
|
675 |
1 |
assertFalse(h.hasHiddenColumns()); |
676 |
|
|
677 |
|
|
678 |
1 |
h.hideColumns(5, 10); |
679 |
1 |
assertTrue(h.hasHiddenColumns()); |
680 |
|
|
681 |
|
|
682 |
1 |
ColumnSelection sel = new ColumnSelection(); |
683 |
1 |
h.revealAllHiddenColumns(sel); |
684 |
1 |
assertFalse(h.hasHiddenColumns()); |
685 |
|
} |
686 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
687 |
1 |
@Test(groups = "Functional")... |
688 |
|
public void testHasManyHiddenColumns() |
689 |
|
{ |
690 |
1 |
HiddenColumns h = new HiddenColumns(); |
691 |
|
|
692 |
|
|
693 |
1 |
assertFalse(h.hasMultiHiddenColumnRegions()); |
694 |
|
|
695 |
|
|
696 |
1 |
h.hideColumns(5, 10); |
697 |
1 |
assertFalse(h.hasMultiHiddenColumnRegions()); |
698 |
|
|
699 |
|
|
700 |
1 |
h.hideColumns(15, 17); |
701 |
1 |
assertTrue(h.hasMultiHiddenColumnRegions()); |
702 |
|
|
703 |
|
|
704 |
1 |
h.hideColumns(11, 14); |
705 |
1 |
assertFalse(h.hasMultiHiddenColumnRegions()); |
706 |
|
} |
707 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
708 |
1 |
@Test(groups = "Functional")... |
709 |
|
public void testAdjustForHiddenColumns() |
710 |
|
{ |
711 |
1 |
HiddenColumns h = new HiddenColumns(); |
712 |
|
|
713 |
1 |
assertEquals(10, h.visibleToAbsoluteColumn(10)); |
714 |
|
|
715 |
1 |
h.hideColumns(20, 30); |
716 |
1 |
assertEquals(10, h.visibleToAbsoluteColumn(10)); |
717 |
1 |
assertEquals(20 + 11, h.visibleToAbsoluteColumn(20)); |
718 |
1 |
assertEquals(35 + 11, h.visibleToAbsoluteColumn(35)); |
719 |
|
|
720 |
1 |
h.hideColumns(5, 7); |
721 |
1 |
assertEquals(10 + 3, h.visibleToAbsoluteColumn(10)); |
722 |
1 |
assertEquals(20 + 14, h.visibleToAbsoluteColumn(20)); |
723 |
1 |
assertEquals(35 + 14, h.visibleToAbsoluteColumn(35)); |
724 |
|
|
725 |
1 |
ColumnSelection sel = new ColumnSelection(); |
726 |
1 |
h.revealAllHiddenColumns(sel); |
727 |
1 |
h.hideColumns(0, 1); |
728 |
1 |
assertEquals(4, h.visibleToAbsoluteColumn(2)); |
729 |
|
} |
730 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
731 |
1 |
@Test(groups = "Functional")... |
732 |
|
public void testGetNextHiddenBoundary_Left() |
733 |
|
{ |
734 |
1 |
HiddenColumns h = new HiddenColumns(); |
735 |
|
|
736 |
|
|
737 |
1 |
assertEquals(3, h.getNextHiddenBoundary(true, 3)); |
738 |
|
|
739 |
1 |
h.hideColumns(5, 10); |
740 |
1 |
assertEquals(10, h.getNextHiddenBoundary(true, 15)); |
741 |
1 |
assertEquals(3, h.getNextHiddenBoundary(true, 3)); |
742 |
1 |
assertEquals(7, h.getNextHiddenBoundary(true, 7)); |
743 |
|
|
744 |
1 |
h.hideColumns(15, 20); |
745 |
1 |
assertEquals(10, h.getNextHiddenBoundary(true, 15)); |
746 |
1 |
assertEquals(20, h.getNextHiddenBoundary(true, 21)); |
747 |
|
} |
748 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
749 |
1 |
@Test(groups = "Functional")... |
750 |
|
public void testGetNextHiddenBoundary_Right() |
751 |
|
{ |
752 |
1 |
HiddenColumns h = new HiddenColumns(); |
753 |
|
|
754 |
|
|
755 |
1 |
assertEquals(3, h.getNextHiddenBoundary(false, 3)); |
756 |
|
|
757 |
1 |
h.hideColumns(5, 10); |
758 |
1 |
assertEquals(5, h.getNextHiddenBoundary(false, 3)); |
759 |
1 |
assertEquals(15, h.getNextHiddenBoundary(false, 15)); |
760 |
1 |
assertEquals(7, h.getNextHiddenBoundary(false, 7)); |
761 |
|
|
762 |
1 |
h.hideColumns(15, 20); |
763 |
1 |
assertEquals(15, h.getNextHiddenBoundary(false, 7)); |
764 |
1 |
assertEquals(15, h.getNextHiddenBoundary(false, 14)); |
765 |
|
|
766 |
|
|
767 |
1 |
assertEquals(22, h.getNextHiddenBoundary(false, 22)); |
768 |
|
} |
769 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (26) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
770 |
1 |
@Test(groups = "Functional")... |
771 |
|
public void testIterator() |
772 |
|
{ |
773 |
1 |
HiddenColumns h = new HiddenColumns(); |
774 |
1 |
Iterator<int[]> result = h.iterator(); |
775 |
1 |
assertFalse(result.hasNext()); |
776 |
|
|
777 |
1 |
h.hideColumns(5, 10); |
778 |
1 |
result = h.iterator(); |
779 |
1 |
int[] next = result.next(); |
780 |
1 |
assertEquals(5, next[0]); |
781 |
1 |
assertEquals(10, next[1]); |
782 |
1 |
assertFalse(result.hasNext()); |
783 |
|
|
784 |
1 |
h.hideColumns(22, 23); |
785 |
1 |
result = h.iterator(); |
786 |
1 |
next = result.next(); |
787 |
1 |
assertEquals(5, next[0]); |
788 |
1 |
assertEquals(10, next[1]); |
789 |
1 |
next = result.next(); |
790 |
1 |
assertEquals(22, next[0]); |
791 |
1 |
assertEquals(23, next[1]); |
792 |
1 |
assertFalse(result.hasNext()); |
793 |
|
|
794 |
|
|
795 |
1 |
ColumnSelection sel = new ColumnSelection(); |
796 |
1 |
h.revealAllHiddenColumns(sel); |
797 |
1 |
h.hideColumns(0, 1); |
798 |
1 |
result = h.iterator(); |
799 |
1 |
next = result.next(); |
800 |
1 |
assertEquals(0, next[0]); |
801 |
1 |
assertEquals(1, next[1]); |
802 |
1 |
assertFalse(result.hasNext()); |
803 |
|
} |
804 |
|
|
805 |
|
|
806 |
|
|
807 |
|
|
808 |
|
|
809 |
|
|
810 |
|
|
811 |
|
|
812 |
|
|
813 |
|
|
814 |
|
|
815 |
|
|
816 |
|
|
817 |
|
|
818 |
|
|
819 |
|
|
820 |
|
|
821 |
|
|
822 |
|
|
823 |
|
|
824 |
|
|
825 |
|
|
826 |
|
|
827 |
|
|
828 |
|
|
829 |
|
|
830 |
|
|
831 |
|
|
832 |
|
|
833 |
|
|
834 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
835 |
1 |
@Test(groups = "Functional")... |
836 |
|
public void testHideInsertionsFor() |
837 |
|
{ |
838 |
1 |
HiddenColumns h = new HiddenColumns(); |
839 |
1 |
HiddenColumns h2 = new HiddenColumns(); |
840 |
1 |
SequenceI seq1 = new Sequence("TEST1", "GAL---MFW-KQESPVICY--HRNDT"); |
841 |
1 |
SequenceI seq2 = new Sequence("TEST1", "GALMFWKQESPVICYHRNDT"); |
842 |
|
|
843 |
1 |
h.hideList(seq2.getInsertions()); |
844 |
1 |
assertTrue(h.equals(h2)); |
845 |
1 |
assertEquals(0, h.getSize()); |
846 |
|
|
847 |
1 |
h.hideList(seq1.getInsertions()); |
848 |
1 |
h2.hideColumns(3, 5); |
849 |
1 |
h2.hideColumns(9, 9); |
850 |
1 |
h2.hideColumns(19, 20); |
851 |
1 |
assertTrue(h.equals(h2)); |
852 |
1 |
assertEquals(6, h.getSize()); |
853 |
|
} |
854 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (61) |
Complexity: 1 |
Complexity Density: 0.02 |
1PASS
|
|
855 |
1 |
@Test(groups = "Functional")... |
856 |
|
public void testHideColumns_BitSet_range() |
857 |
|
{ |
858 |
1 |
HiddenColumns h = new HiddenColumns(); |
859 |
1 |
HiddenColumns h2 = new HiddenColumns(); |
860 |
|
|
861 |
1 |
BitSet tohide = new BitSet(25); |
862 |
1 |
h.hideColumns(tohide); |
863 |
1 |
assertTrue(h.equals(h2)); |
864 |
|
|
865 |
|
|
866 |
1 |
tohide.set(3, 6); |
867 |
1 |
tohide.set(9); |
868 |
1 |
tohide.set(15, 21); |
869 |
1 |
h.clearAndHideColumns(tohide, 5, 23); |
870 |
|
|
871 |
1 |
h2.hideColumns(5, 5); |
872 |
1 |
h2.hideColumns(9, 9); |
873 |
1 |
h2.hideColumns(15, 20); |
874 |
1 |
assertTrue(h.equals(h2)); |
875 |
1 |
assertEquals(h.getSize(), h2.getSize()); |
876 |
|
|
877 |
1 |
tohide.clear(); |
878 |
1 |
tohide.set(41); |
879 |
1 |
h.clearAndHideColumns(tohide, 23, 30); |
880 |
1 |
assertTrue(h.equals(h2)); |
881 |
1 |
assertEquals(h.getSize(), h2.getSize()); |
882 |
|
|
883 |
1 |
tohide.set(41); |
884 |
1 |
h.clearAndHideColumns(tohide, 30, 45); |
885 |
1 |
h2.hideColumns(41, 41); |
886 |
1 |
assertTrue(h.equals(h2)); |
887 |
1 |
assertEquals(h.getSize(), h2.getSize()); |
888 |
|
|
889 |
1 |
tohide.clear(); |
890 |
1 |
tohide.set(25, 28); |
891 |
1 |
h.clearAndHideColumns(tohide, 17, 50); |
892 |
1 |
h2 = new HiddenColumns(); |
893 |
1 |
h2.hideColumns(5, 5); |
894 |
1 |
h2.hideColumns(9, 9); |
895 |
1 |
h2.hideColumns(15, 16); |
896 |
1 |
h2.hideColumns(25, 27); |
897 |
1 |
assertTrue(h.equals(h2)); |
898 |
1 |
assertEquals(h.getSize(), h2.getSize()); |
899 |
|
|
900 |
1 |
HiddenColumns hc = new HiddenColumns(); |
901 |
1 |
hc.hideColumns(3, 5); |
902 |
1 |
hc.hideColumns(15, 20); |
903 |
1 |
hc.hideColumns(45, 60); |
904 |
|
|
905 |
1 |
tohide = new BitSet(); |
906 |
|
|
907 |
|
|
908 |
1 |
hc.clearAndHideColumns(tohide, 1, 70); |
909 |
1 |
assertTrue(!hc.hasHiddenColumns()); |
910 |
1 |
assertEquals(0, hc.getSize()); |
911 |
|
|
912 |
1 |
hc.hideColumns(3, 5); |
913 |
1 |
hc.hideColumns(15, 20); |
914 |
1 |
hc.hideColumns(45, 60); |
915 |
1 |
assertEquals(25, hc.getSize()); |
916 |
|
|
917 |
|
|
918 |
1 |
hc.clearAndHideColumns(tohide, 23, 40); |
919 |
1 |
assertTrue(hc.hasHiddenColumns()); |
920 |
1 |
assertEquals(25, hc.getSize()); |
921 |
|
|
922 |
|
|
923 |
1 |
hc.clearAndHideColumns(tohide, 1, 17); |
924 |
1 |
Iterator<int[]> it = hc.iterator(); |
925 |
1 |
assertTrue(it.hasNext()); |
926 |
1 |
int[] region = it.next(); |
927 |
|
|
928 |
1 |
assertEquals(18, region[0]); |
929 |
1 |
assertEquals(20, region[1]); |
930 |
|
|
931 |
1 |
assertTrue(it.hasNext()); |
932 |
1 |
region = it.next(); |
933 |
|
|
934 |
1 |
assertEquals(45, region[0]); |
935 |
1 |
assertEquals(60, region[1]); |
936 |
|
|
937 |
1 |
assertFalse(it.hasNext()); |
938 |
1 |
assertEquals(19, hc.getSize()); |
939 |
|
} |
940 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (65) |
Complexity: 1 |
Complexity Density: 0.02 |
1PASS
|
|
941 |
1 |
@Test(groups = "Functional")... |
942 |
|
public void testOffsetByVisibleColumns() |
943 |
|
{ |
944 |
1 |
HiddenColumns h = new HiddenColumns(); |
945 |
1 |
int result = h.offsetByVisibleColumns(-1, 10); |
946 |
1 |
assertEquals(9, result); |
947 |
|
|
948 |
1 |
h.hideColumns(7, 9); |
949 |
1 |
result = h.offsetByVisibleColumns(-4, 10); |
950 |
1 |
assertEquals(3, result); |
951 |
|
|
952 |
1 |
h.hideColumns(14, 15); |
953 |
1 |
result = h.offsetByVisibleColumns(-4, 10); |
954 |
1 |
assertEquals(3, result); |
955 |
|
|
956 |
1 |
result = h.offsetByVisibleColumns(-10, 17); |
957 |
1 |
assertEquals(2, result); |
958 |
|
|
959 |
1 |
result = h.offsetByVisibleColumns(-1, 7); |
960 |
1 |
assertEquals(5, result); |
961 |
|
|
962 |
1 |
result = h.offsetByVisibleColumns(-1, 8); |
963 |
1 |
assertEquals(5, result); |
964 |
|
|
965 |
1 |
result = h.offsetByVisibleColumns(-3, 15); |
966 |
1 |
assertEquals(10, result); |
967 |
|
|
968 |
1 |
ColumnSelection sel = new ColumnSelection(); |
969 |
1 |
h.revealAllHiddenColumns(sel); |
970 |
1 |
h.hideColumns(0, 30); |
971 |
1 |
result = h.offsetByVisibleColumns(-31, 0); |
972 |
1 |
assertEquals(-31, result); |
973 |
|
|
974 |
1 |
HiddenColumns cs = new HiddenColumns(); |
975 |
|
|
976 |
|
|
977 |
|
|
978 |
1 |
long pos = cs.offsetByVisibleColumns(-3, 10); |
979 |
1 |
assertEquals(7, pos); |
980 |
|
|
981 |
|
|
982 |
1 |
pos = cs.offsetByVisibleColumns(0, 10); |
983 |
1 |
assertEquals(10, pos); |
984 |
|
|
985 |
|
|
986 |
1 |
pos = cs.offsetByVisibleColumns(-3, 0); |
987 |
1 |
assertEquals(-3, pos); |
988 |
|
|
989 |
|
|
990 |
|
|
991 |
1 |
cs.hideColumns(1, 3); |
992 |
|
|
993 |
|
|
994 |
1 |
pos = cs.offsetByVisibleColumns(-3, 10); |
995 |
1 |
assertEquals(7, pos); |
996 |
|
|
997 |
|
|
998 |
1 |
pos = cs.offsetByVisibleColumns(0, 10); |
999 |
1 |
assertEquals(10, pos); |
1000 |
|
|
1001 |
|
|
1002 |
1 |
cs.hideColumns(12, 15); |
1003 |
1 |
pos = cs.offsetByVisibleColumns(-8, 17); |
1004 |
1 |
assertEquals(5, pos); |
1005 |
|
|
1006 |
|
|
1007 |
1 |
cs.hideColumns(20, 21); |
1008 |
1 |
pos = cs.offsetByVisibleColumns(-8, 23); |
1009 |
1 |
assertEquals(9, pos); |
1010 |
|
|
1011 |
|
|
1012 |
1 |
ColumnSelection colsel = new ColumnSelection(); |
1013 |
1 |
cs.revealAllHiddenColumns(colsel); |
1014 |
|
|
1015 |
|
|
1016 |
1 |
cs.hideColumns(12, 15); |
1017 |
1 |
pos = cs.offsetByVisibleColumns(-8, 17); |
1018 |
1 |
assertEquals(5, pos); |
1019 |
|
|
1020 |
|
|
1021 |
1 |
cs.hideColumns(20, 21); |
1022 |
1 |
pos = cs.offsetByVisibleColumns(-8, 23); |
1023 |
1 |
assertEquals(9, pos); |
1024 |
|
|
1025 |
|
|
1026 |
|
|
1027 |
|
|
1028 |
|
|
1029 |
1 |
pos = cs.offsetByVisibleColumns(3, 7); |
1030 |
1 |
assertEquals(10, pos); |
1031 |
|
|
1032 |
|
|
1033 |
|
|
1034 |
1 |
cs.hideColumns(1, 3); |
1035 |
|
|
1036 |
|
|
1037 |
1 |
cs.hideColumns(12, 15); |
1038 |
1 |
pos = cs.offsetByVisibleColumns(8, 5); |
1039 |
1 |
assertEquals(17, pos); |
1040 |
|
|
1041 |
|
|
1042 |
1 |
cs.hideColumns(20, 21); |
1043 |
1 |
pos = cs.offsetByVisibleColumns(8, 9); |
1044 |
1 |
assertEquals(23, pos); |
1045 |
|
|
1046 |
|
|
1047 |
1 |
colsel = new ColumnSelection(); |
1048 |
1 |
cs.revealAllHiddenColumns(colsel); |
1049 |
|
|
1050 |
|
|
1051 |
1 |
cs.hideColumns(12, 15); |
1052 |
1 |
pos = cs.offsetByVisibleColumns(8, 5); |
1053 |
1 |
assertEquals(17, pos); |
1054 |
|
|
1055 |
|
|
1056 |
1 |
cs.hideColumns(20, 21); |
1057 |
1 |
pos = cs.offsetByVisibleColumns(8, 9); |
1058 |
1 |
assertEquals(23, pos); |
1059 |
|
} |
1060 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (38) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
1061 |
1 |
@Test(groups = "Functional")... |
1062 |
|
public void testBoundedIterator() |
1063 |
|
{ |
1064 |
1 |
HiddenColumns h = new HiddenColumns(); |
1065 |
1 |
Iterator<int[]> it = h.getBoundedIterator(0, 10); |
1066 |
|
|
1067 |
|
|
1068 |
1 |
assertFalse(it.hasNext()); |
1069 |
|
|
1070 |
|
|
1071 |
|
|
1072 |
1 |
h.hideColumns(3, 10); |
1073 |
1 |
h.hideColumns(14, 16); |
1074 |
1 |
it = h.getBoundedIterator(0, 20); |
1075 |
1 |
assertTrue(it.hasNext()); |
1076 |
1 |
int[] next = it.next(); |
1077 |
1 |
assertEquals(3, next[0]); |
1078 |
1 |
assertEquals(10, next[1]); |
1079 |
1 |
next = it.next(); |
1080 |
1 |
assertEquals(14, next[0]); |
1081 |
1 |
assertEquals(16, next[1]); |
1082 |
1 |
assertFalse(it.hasNext()); |
1083 |
|
|
1084 |
|
|
1085 |
|
|
1086 |
1 |
it = h.getBoundedIterator(5, 7); |
1087 |
1 |
assertTrue(it.hasNext()); |
1088 |
1 |
next = it.next(); |
1089 |
1 |
assertEquals(3, next[0]); |
1090 |
1 |
assertEquals(10, next[1]); |
1091 |
1 |
assertFalse(it.hasNext()); |
1092 |
|
|
1093 |
|
|
1094 |
|
|
1095 |
1 |
it = h.getBoundedIterator(3, 15); |
1096 |
1 |
assertTrue(it.hasNext()); |
1097 |
1 |
next = it.next(); |
1098 |
1 |
assertEquals(3, next[0]); |
1099 |
1 |
assertEquals(10, next[1]); |
1100 |
1 |
next = it.next(); |
1101 |
1 |
assertEquals(14, next[0]); |
1102 |
1 |
assertEquals(16, next[1]); |
1103 |
1 |
assertFalse(it.hasNext()); |
1104 |
|
|
1105 |
|
|
1106 |
|
|
1107 |
1 |
it = h.getBoundedIterator(4, 20); |
1108 |
1 |
assertTrue(it.hasNext()); |
1109 |
1 |
next = it.next(); |
1110 |
1 |
assertEquals(3, next[0]); |
1111 |
1 |
assertEquals(10, next[1]); |
1112 |
1 |
next = it.next(); |
1113 |
1 |
assertEquals(14, next[0]); |
1114 |
1 |
assertEquals(16, next[1]); |
1115 |
1 |
assertFalse(it.hasNext()); |
1116 |
|
} |
1117 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (26) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
1118 |
1 |
@Test(groups = "Functional")... |
1119 |
|
public void testBoundedStartIterator() |
1120 |
|
{ |
1121 |
1 |
HiddenColumns h = new HiddenColumns(); |
1122 |
1 |
Iterator<Integer> it = h.getStartRegionIterator(0, 10); |
1123 |
|
|
1124 |
|
|
1125 |
1 |
assertFalse(it.hasNext()); |
1126 |
|
|
1127 |
|
|
1128 |
|
|
1129 |
1 |
h.hideColumns(3, 10); |
1130 |
1 |
h.hideColumns(14, 16); |
1131 |
1 |
it = h.getStartRegionIterator(0, 20); |
1132 |
1 |
assertTrue(it.hasNext()); |
1133 |
1 |
int next = it.next(); |
1134 |
1 |
assertEquals(3, next); |
1135 |
1 |
next = it.next(); |
1136 |
1 |
assertEquals(6, next); |
1137 |
1 |
assertFalse(it.hasNext()); |
1138 |
|
|
1139 |
|
|
1140 |
|
|
1141 |
1 |
it = h.getStartRegionIterator(4, 5); |
1142 |
1 |
assertFalse(it.hasNext()); |
1143 |
|
|
1144 |
|
|
1145 |
|
|
1146 |
1 |
it = h.getStartRegionIterator(3, 7); |
1147 |
1 |
assertTrue(it.hasNext()); |
1148 |
1 |
next = it.next(); |
1149 |
1 |
assertEquals(3, next); |
1150 |
1 |
next = it.next(); |
1151 |
1 |
assertEquals(6, next); |
1152 |
1 |
assertFalse(it.hasNext()); |
1153 |
|
|
1154 |
|
|
1155 |
|
|
1156 |
1 |
it = h.getStartRegionIterator(4, 20); |
1157 |
1 |
assertTrue(it.hasNext()); |
1158 |
1 |
next = it.next(); |
1159 |
1 |
assertEquals(6, next); |
1160 |
1 |
assertFalse(it.hasNext()); |
1161 |
|
} |
1162 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (98) |
Complexity: 1 |
Complexity Density: 0.01 |
1PASS
|
|
1163 |
1 |
@Test(groups = "Functional")... |
1164 |
|
public void testVisibleBlocksVisBoundsIterator() |
1165 |
|
{ |
1166 |
1 |
HiddenColumns h = new HiddenColumns(); |
1167 |
1 |
Iterator<int[]> regions = h.getVisContigsIterator(0, 31, true); |
1168 |
|
|
1169 |
|
|
1170 |
1 |
assertTrue(regions.hasNext()); |
1171 |
1 |
int[] region = regions.next(); |
1172 |
1 |
assertEquals(0, region[0]); |
1173 |
1 |
assertEquals(30, region[1]); |
1174 |
1 |
assertFalse(regions.hasNext()); |
1175 |
|
|
1176 |
|
|
1177 |
|
|
1178 |
|
|
1179 |
1 |
h.hideColumns(10, 15); |
1180 |
1 |
regions = h.getVisContigsIterator(0, 31, true); |
1181 |
|
|
1182 |
1 |
assertTrue(regions.hasNext()); |
1183 |
1 |
region = regions.next(); |
1184 |
1 |
assertEquals(0, region[0]); |
1185 |
1 |
assertEquals(9, region[1]); |
1186 |
1 |
region = regions.next(); |
1187 |
1 |
assertEquals(16, region[0]); |
1188 |
1 |
assertEquals(36, region[1]); |
1189 |
1 |
assertFalse(regions.hasNext()); |
1190 |
|
|
1191 |
|
|
1192 |
1 |
h = new HiddenColumns(); |
1193 |
1 |
h.hideColumns(0, 5); |
1194 |
1 |
regions = h.getVisContigsIterator(0, 31, true); |
1195 |
|
|
1196 |
1 |
assertTrue(regions.hasNext()); |
1197 |
1 |
region = regions.next(); |
1198 |
1 |
assertEquals(6, region[0]); |
1199 |
1 |
assertEquals(36, region[1]); |
1200 |
1 |
assertFalse(regions.hasNext()); |
1201 |
|
|
1202 |
|
|
1203 |
1 |
h = new HiddenColumns(); |
1204 |
1 |
h.hideColumns(27, 30); |
1205 |
1 |
regions = h.getVisContigsIterator(0, 31, true); |
1206 |
|
|
1207 |
1 |
assertTrue(regions.hasNext()); |
1208 |
1 |
region = regions.next(); |
1209 |
1 |
assertEquals(0, region[0]); |
1210 |
1 |
assertEquals(26, region[1]); |
1211 |
1 |
region = regions.next(); |
1212 |
1 |
assertEquals(31, region[0]); |
1213 |
1 |
assertEquals(34, region[1]); |
1214 |
1 |
assertFalse(regions.hasNext()); |
1215 |
|
|
1216 |
|
|
1217 |
1 |
h = new HiddenColumns(); |
1218 |
1 |
h.hideColumns(0, 5); |
1219 |
1 |
h.hideColumns(23, 25); |
1220 |
1 |
regions = h.getVisContigsIterator(0, 31, true); |
1221 |
|
|
1222 |
1 |
assertTrue(regions.hasNext()); |
1223 |
1 |
region = regions.next(); |
1224 |
1 |
assertEquals(6, region[0]); |
1225 |
1 |
assertEquals(22, region[1]); |
1226 |
1 |
region = regions.next(); |
1227 |
1 |
assertEquals(26, region[0]); |
1228 |
1 |
assertEquals(39, region[1]); |
1229 |
1 |
assertFalse(regions.hasNext()); |
1230 |
|
|
1231 |
|
|
1232 |
1 |
h = new HiddenColumns(); |
1233 |
1 |
h.hideColumns(27, 30); |
1234 |
1 |
h.hideColumns(11, 14); |
1235 |
1 |
regions = h.getVisContigsIterator(0, 31, true); |
1236 |
|
|
1237 |
1 |
assertTrue(regions.hasNext()); |
1238 |
1 |
region = regions.next(); |
1239 |
1 |
assertEquals(0, region[0]); |
1240 |
1 |
assertEquals(10, region[1]); |
1241 |
1 |
region = regions.next(); |
1242 |
1 |
assertEquals(15, region[0]); |
1243 |
1 |
assertEquals(26, region[1]); |
1244 |
1 |
region = regions.next(); |
1245 |
1 |
assertEquals(31, region[0]); |
1246 |
1 |
assertEquals(38, region[1]); |
1247 |
1 |
assertFalse(regions.hasNext()); |
1248 |
|
|
1249 |
|
|
1250 |
1 |
h = new HiddenColumns(); |
1251 |
1 |
h.hideColumns(27, 35); |
1252 |
1 |
h.hideColumns(0, 4); |
1253 |
1 |
regions = h.getVisContigsIterator(0, 31, true); |
1254 |
|
|
1255 |
1 |
assertTrue(regions.hasNext()); |
1256 |
1 |
region = regions.next(); |
1257 |
1 |
assertEquals(5, region[0]); |
1258 |
1 |
assertEquals(26, region[1]); |
1259 |
1 |
region = regions.next(); |
1260 |
1 |
assertEquals(36, region[0]); |
1261 |
1 |
assertEquals(44, region[1]); |
1262 |
1 |
assertFalse(regions.hasNext()); |
1263 |
|
|
1264 |
|
|
1265 |
1 |
h = new HiddenColumns(); |
1266 |
1 |
h.hideColumns(1, 1); |
1267 |
1 |
h.hideColumns(3, 5); |
1268 |
1 |
h.hideColumns(9, 11); |
1269 |
1 |
h.hideColumns(22, 26); |
1270 |
|
|
1271 |
1 |
regions = h.getVisContigsIterator(0, 31, true); |
1272 |
|
|
1273 |
1 |
assertTrue(regions.hasNext()); |
1274 |
1 |
region = regions.next(); |
1275 |
1 |
assertEquals(0, region[0]); |
1276 |
1 |
assertEquals(0, region[1]); |
1277 |
1 |
region = regions.next(); |
1278 |
1 |
assertEquals(2, region[0]); |
1279 |
1 |
assertEquals(2, region[1]); |
1280 |
1 |
region = regions.next(); |
1281 |
1 |
assertEquals(6, region[0]); |
1282 |
1 |
assertEquals(8, region[1]); |
1283 |
1 |
region = regions.next(); |
1284 |
1 |
assertEquals(12, region[0]); |
1285 |
1 |
assertEquals(21, region[1]); |
1286 |
1 |
region = regions.next(); |
1287 |
1 |
assertEquals(27, region[0]); |
1288 |
1 |
assertEquals(42, region[1]); |
1289 |
1 |
assertFalse(regions.hasNext()); |
1290 |
|
} |
1291 |
|
|
1292 |
|
|
1293 |
|
|
1294 |
|
|
1295 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
1296 |
1 |
@Test(groups = "Functional")... |
1297 |
|
public void testGetVisibleColsIterator() |
1298 |
|
{ |
1299 |
1 |
HiddenColumns h = new HiddenColumns(); |
1300 |
1 |
Iterator<Integer> it = h.getVisibleColsIterator(0, 10); |
1301 |
|
|
1302 |
1 |
assertTrue(it instanceof RangeElementsIterator); |
1303 |
|
} |
1304 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
1305 |
1 |
@Test(groups = "Functional")... |
1306 |
|
public void testHashCode() |
1307 |
|
{ |
1308 |
1 |
HiddenColumns h = new HiddenColumns(); |
1309 |
1 |
h.hideColumns(0, 25); |
1310 |
|
|
1311 |
1 |
int result = h.hashCode(); |
1312 |
1 |
assertTrue(result > 0); |
1313 |
|
|
1314 |
1 |
h.hideColumns(30, 50); |
1315 |
1 |
assertTrue(h.hashCode() > 0); |
1316 |
1 |
assertTrue(result != h.hashCode()); |
1317 |
|
} |
1318 |
|
} |