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