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