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.assertEquals; |
24 |
|
import static org.testng.AssertJUnit.assertFalse; |
25 |
|
import static org.testng.AssertJUnit.assertTrue; |
26 |
|
|
27 |
|
import java.util.ArrayList; |
28 |
|
import java.util.List; |
29 |
|
|
30 |
|
import org.testng.annotations.Test; |
31 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (141) |
Complexity: 3 |
Complexity Density: 0.02 |
|
32 |
|
public class VisibleContigsIteratorTest |
33 |
|
{ |
34 |
|
|
35 |
|
|
36 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (47) |
Complexity: 1 |
Complexity Density: 0.02 |
1PASS
|
|
37 |
1 |
@Test(groups = { "Functional" })... |
38 |
|
public void testSimpleVisibleRegions() |
39 |
|
{ |
40 |
1 |
List<int[]> hiddenColumns = null; |
41 |
|
|
42 |
|
|
43 |
1 |
VisibleContigsIterator it = new VisibleContigsIterator(3, 10, |
44 |
|
hiddenColumns); |
45 |
1 |
assertTrue(it.hasNext()); |
46 |
1 |
assertFalse(it.endsAtHidden()); |
47 |
1 |
int[] result = it.next(); |
48 |
1 |
assertEquals(3, result[0]); |
49 |
1 |
assertEquals(9, result[1]); |
50 |
1 |
assertFalse(it.hasNext()); |
51 |
1 |
assertFalse(it.endsAtHidden()); |
52 |
|
|
53 |
1 |
hiddenColumns = new ArrayList<>(); |
54 |
|
|
55 |
|
|
56 |
1 |
it = new VisibleContigsIterator(3, 10, hiddenColumns); |
57 |
1 |
assertTrue(it.hasNext()); |
58 |
1 |
assertFalse(it.endsAtHidden()); |
59 |
1 |
result = it.next(); |
60 |
1 |
assertEquals(3, result[0]); |
61 |
1 |
assertEquals(9, result[1]); |
62 |
1 |
assertFalse(it.hasNext()); |
63 |
1 |
assertFalse(it.endsAtHidden()); |
64 |
|
|
65 |
|
|
66 |
1 |
hiddenColumns.add(new int[] { 5, 10 }); |
67 |
1 |
hiddenColumns.add(new int[] { 25, 40 }); |
68 |
|
|
69 |
1 |
it = new VisibleContigsIterator(2, 3, hiddenColumns); |
70 |
1 |
assertTrue(it.hasNext()); |
71 |
1 |
assertFalse(it.endsAtHidden()); |
72 |
1 |
result = it.next(); |
73 |
1 |
assertEquals(2, result[0]); |
74 |
1 |
assertEquals(2, result[1]); |
75 |
1 |
assertFalse(it.hasNext()); |
76 |
1 |
assertFalse(it.endsAtHidden()); |
77 |
|
|
78 |
1 |
it = new VisibleContigsIterator(5, 7, hiddenColumns); |
79 |
1 |
assertFalse(it.hasNext()); |
80 |
1 |
assertFalse(it.endsAtHidden()); |
81 |
|
|
82 |
1 |
it = new VisibleContigsIterator(11, 15, hiddenColumns); |
83 |
1 |
assertTrue(it.hasNext()); |
84 |
1 |
assertFalse(it.endsAtHidden()); |
85 |
1 |
result = it.next(); |
86 |
1 |
assertEquals(11, result[0]); |
87 |
1 |
assertEquals(14, result[1]); |
88 |
1 |
assertFalse(it.hasNext()); |
89 |
1 |
assertFalse(it.endsAtHidden()); |
90 |
|
|
91 |
1 |
it = new VisibleContigsIterator(50, 60, hiddenColumns); |
92 |
1 |
assertTrue(it.hasNext()); |
93 |
1 |
assertFalse(it.endsAtHidden()); |
94 |
1 |
result = it.next(); |
95 |
1 |
assertEquals(50, result[0]); |
96 |
1 |
assertEquals(59, result[1]); |
97 |
1 |
assertFalse(it.hasNext()); |
98 |
1 |
assertFalse(it.endsAtHidden()); |
99 |
|
} |
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
104 |
1 |
@Test(groups = { "Functional" })... |
105 |
|
public void testMultipleVisibleRegions() |
106 |
|
{ |
107 |
1 |
List<int[]> hiddenColumns = new ArrayList<>(); |
108 |
1 |
hiddenColumns.add(new int[] { 5, 10 }); |
109 |
1 |
hiddenColumns.add(new int[] { 25, 40 }); |
110 |
|
|
111 |
|
|
112 |
1 |
VisibleContigsIterator it = new VisibleContigsIterator(3, 50, |
113 |
|
hiddenColumns); |
114 |
1 |
assertTrue(it.hasNext()); |
115 |
1 |
assertFalse(it.endsAtHidden()); |
116 |
1 |
int[] result = it.next(); |
117 |
1 |
assertEquals(3, result[0]); |
118 |
1 |
assertEquals(4, result[1]); |
119 |
|
|
120 |
1 |
assertTrue(it.hasNext()); |
121 |
1 |
assertFalse(it.endsAtHidden()); |
122 |
1 |
result = it.next(); |
123 |
1 |
assertEquals(11, result[0]); |
124 |
1 |
assertEquals(24, result[1]); |
125 |
|
|
126 |
1 |
assertTrue(it.hasNext()); |
127 |
1 |
assertFalse(it.endsAtHidden()); |
128 |
1 |
result = it.next(); |
129 |
1 |
assertEquals(41, result[0]); |
130 |
1 |
assertEquals(49, result[1]); |
131 |
|
|
132 |
1 |
assertFalse(it.hasNext()); |
133 |
1 |
assertFalse(it.endsAtHidden()); |
134 |
|
} |
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (70) |
Complexity: 1 |
Complexity Density: 0.01 |
1PASS
|
|
139 |
1 |
@Test(groups = { "Functional" })... |
140 |
|
public void testVisibleRegionsAtHiddenEdges() |
141 |
|
{ |
142 |
1 |
List<int[]> hiddenColumns = new ArrayList<>(); |
143 |
1 |
hiddenColumns.add(new int[] { 5, 10 }); |
144 |
1 |
hiddenColumns.add(new int[] { 25, 40 }); |
145 |
|
|
146 |
1 |
VisibleContigsIterator it = new VisibleContigsIterator(0, 10, |
147 |
|
hiddenColumns); |
148 |
1 |
assertTrue(it.hasNext()); |
149 |
1 |
assertTrue(it.endsAtHidden()); |
150 |
1 |
int[] result = it.next(); |
151 |
1 |
assertEquals(0, result[0]); |
152 |
1 |
assertEquals(4, result[1]); |
153 |
1 |
assertFalse(it.hasNext()); |
154 |
1 |
assertTrue(it.endsAtHidden()); |
155 |
|
|
156 |
1 |
it = new VisibleContigsIterator(2, 11, hiddenColumns); |
157 |
1 |
assertTrue(it.hasNext()); |
158 |
1 |
assertTrue(it.endsAtHidden()); |
159 |
1 |
result = it.next(); |
160 |
1 |
assertEquals(2, result[0]); |
161 |
1 |
assertEquals(4, result[1]); |
162 |
1 |
assertFalse(it.hasNext()); |
163 |
1 |
assertTrue(it.endsAtHidden()); |
164 |
|
|
165 |
1 |
it = new VisibleContigsIterator(2, 12, hiddenColumns); |
166 |
1 |
assertTrue(it.hasNext()); |
167 |
1 |
assertFalse(it.endsAtHidden()); |
168 |
1 |
result = it.next(); |
169 |
1 |
assertEquals(2, result[0]); |
170 |
1 |
assertEquals(4, result[1]); |
171 |
1 |
assertTrue(it.hasNext()); |
172 |
1 |
assertFalse(it.endsAtHidden()); |
173 |
1 |
result = it.next(); |
174 |
1 |
assertEquals(11, result[0]); |
175 |
1 |
assertEquals(11, result[1]); |
176 |
1 |
assertFalse(it.hasNext()); |
177 |
1 |
assertFalse(it.endsAtHidden()); |
178 |
|
|
179 |
1 |
it = new VisibleContigsIterator(13, 25, hiddenColumns); |
180 |
1 |
assertTrue(it.hasNext()); |
181 |
1 |
assertFalse(it.endsAtHidden()); |
182 |
1 |
result = it.next(); |
183 |
1 |
assertEquals(13, result[0]); |
184 |
1 |
assertEquals(24, result[1]); |
185 |
1 |
assertFalse(it.hasNext()); |
186 |
|
|
187 |
1 |
it = new VisibleContigsIterator(13, 26, hiddenColumns); |
188 |
1 |
assertTrue(it.hasNext()); |
189 |
1 |
assertTrue(it.endsAtHidden()); |
190 |
1 |
result = it.next(); |
191 |
1 |
assertEquals(13, result[0]); |
192 |
1 |
assertEquals(24, result[1]); |
193 |
1 |
assertFalse(it.hasNext()); |
194 |
|
|
195 |
1 |
it = new VisibleContigsIterator(13, 27, hiddenColumns); |
196 |
1 |
assertTrue(it.hasNext()); |
197 |
1 |
assertTrue(it.endsAtHidden()); |
198 |
1 |
result = it.next(); |
199 |
1 |
assertEquals(13, result[0]); |
200 |
1 |
assertEquals(24, result[1]); |
201 |
1 |
assertFalse(it.hasNext()); |
202 |
|
|
203 |
1 |
it = new VisibleContigsIterator(13, 41, hiddenColumns); |
204 |
1 |
assertTrue(it.hasNext()); |
205 |
1 |
assertTrue(it.endsAtHidden()); |
206 |
1 |
result = it.next(); |
207 |
1 |
assertEquals(13, result[0]); |
208 |
1 |
assertEquals(24, result[1]); |
209 |
1 |
assertFalse(it.hasNext()); |
210 |
|
|
211 |
1 |
it = new VisibleContigsIterator(13, 42, hiddenColumns); |
212 |
1 |
assertTrue(it.hasNext()); |
213 |
1 |
assertFalse(it.endsAtHidden()); |
214 |
1 |
result = it.next(); |
215 |
1 |
assertEquals(13, result[0]); |
216 |
1 |
assertEquals(24, result[1]); |
217 |
1 |
assertTrue(it.hasNext()); |
218 |
1 |
result = it.next(); |
219 |
1 |
assertEquals(41, result[0]); |
220 |
1 |
assertEquals(41, result[1]); |
221 |
|
} |
222 |
|
} |