Clover icon

Coverage Report

  1. Project Clover database Tue Mar 10 2026 14:58:44 GMT
  2. Package jalview.datamodel

File StartRegionIteratorTest.java

 

Code metrics

0
118
3
1
213
143
3
0.03
39.33
3
1

Classes

Class Line # Actions
StartRegionIteratorTest 33 118 3
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
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   
 
33    public class StartRegionIteratorTest
34    {
35    /**
36    * Test the start region iterator
37    */
 
38  0 toggle @Test(groups = { "Functional" })
39    public void testBasicBoundsIterator()
40    {
41  0 List<int[]> hiddenColumns = null;
42   
43    // null hidden columns
44  0 Iterator<Integer> it = new StartRegionIterator(3, 10, hiddenColumns);
45  0 assertFalse(it.hasNext());
46   
47  0 hiddenColumns = new ArrayList<>();
48   
49    // no hidden columns
50  0 it = new StartRegionIterator(3, 10, hiddenColumns);
51  0 assertFalse(it.hasNext());
52   
53    // add some hidden columns
54  0 hiddenColumns.add(new int[] { 5, 10 });
55  0 hiddenColumns.add(new int[] { 25, 40 });
56   
57  0 it = new StartRegionIterator(3, 10, hiddenColumns);
58  0 assertTrue(it.hasNext());
59  0 Integer result = it.next();
60  0 assertEquals(5, (int) result);
61  0 assertFalse(it.hasNext());
62   
63  0 it = new StartRegionIterator(3, 15, hiddenColumns);
64  0 assertTrue(it.hasNext());
65  0 result = it.next();
66  0 assertEquals(5, (int) result);
67  0 assertFalse(it.hasNext());
68   
69  0 it = new StartRegionIterator(3, 18, hiddenColumns);
70  0 assertTrue(it.hasNext());
71  0 result = it.next();
72  0 assertEquals(5, (int) result);
73  0 assertFalse(it.hasNext());
74   
75  0 it = new StartRegionIterator(3, 19, hiddenColumns);
76  0 assertTrue(it.hasNext());
77  0 result = it.next();
78  0 assertEquals(5, (int) result);
79  0 assertTrue(it.hasNext());
80  0 result = it.next();
81  0 assertEquals(19, (int) result);
82  0 assertFalse(it.hasNext());
83   
84  0 hiddenColumns.add(new int[] { 47, 50 });
85   
86  0 it = new StartRegionIterator(15, 60, hiddenColumns);
87  0 assertTrue(it.hasNext());
88  0 result = it.next();
89  0 assertEquals(19, (int) result);
90  0 assertTrue(it.hasNext());
91  0 result = it.next();
92  0 assertEquals(25, (int) result);
93  0 assertFalse(it.hasNext());
94    }
95   
96    /**
97    * Test the start region iterator with null cursor
98    */
 
99  0 toggle @Test(groups = { "Functional" })
100    public void testBoundsIteratorUsingNullCursor()
101    {
102  0 List<int[]> hiddenColumns = null;
103  0 HiddenCursorPosition pos = null;
104   
105    // null hidden columns
106  0 Iterator<Integer> it = new StartRegionIterator(pos, 3, 10,
107    hiddenColumns);
108  0 assertFalse(it.hasNext());
109   
110  0 hiddenColumns = new ArrayList<>();
111   
112    // no hidden columns
113  0 it = new StartRegionIterator(pos, 3, 10, hiddenColumns);
114  0 assertFalse(it.hasNext());
115   
116    // add some hidden columns
117  0 hiddenColumns.add(new int[] { 5, 10 });
118  0 hiddenColumns.add(new int[] { 25, 40 });
119   
120  0 it = new StartRegionIterator(pos, 3, 10, hiddenColumns);
121  0 assertTrue(it.hasNext());
122  0 Integer result = it.next();
123  0 assertEquals(5, (int) result);
124  0 assertFalse(it.hasNext());
125   
126  0 it = new StartRegionIterator(pos, 3, 15, hiddenColumns);
127  0 assertTrue(it.hasNext());
128  0 result = it.next();
129  0 assertEquals(5, (int) result);
130  0 assertFalse(it.hasNext());
131   
132  0 it = new StartRegionIterator(pos, 3, 18, hiddenColumns);
133  0 assertTrue(it.hasNext());
134  0 result = it.next();
135  0 assertEquals(5, (int) result);
136  0 assertFalse(it.hasNext());
137   
138  0 it = new StartRegionIterator(pos, 3, 19, hiddenColumns);
139  0 assertTrue(it.hasNext());
140  0 result = it.next();
141  0 assertEquals(5, (int) result);
142  0 assertTrue(it.hasNext());
143  0 result = it.next();
144  0 assertEquals(19, (int) result);
145  0 assertFalse(it.hasNext());
146   
147  0 hiddenColumns.add(new int[] { 47, 50 });
148   
149  0 it = new StartRegionIterator(pos, 15, 60, hiddenColumns);
150  0 assertTrue(it.hasNext());
151  0 result = it.next();
152  0 assertEquals(19, (int) result);
153  0 assertTrue(it.hasNext());
154  0 result = it.next();
155  0 assertEquals(25, (int) result);
156  0 assertFalse(it.hasNext());
157    }
158   
159    /**
160    * Test the start region iterator with nonnull cursor
161    */
 
162  0 toggle @Test(groups = { "Functional" })
163    public void testBoundsIteratorUsingCursor()
164    {
165  0 List<int[]> hiddenColumns = new ArrayList<>();
166   
167    // add some hidden columns
168  0 hiddenColumns.add(new int[] { 5, 10 });
169  0 hiddenColumns.add(new int[] { 25, 40 });
170   
171  0 HiddenCursorPosition pos = new HiddenCursorPosition(0, 0);
172   
173  0 Iterator<Integer> it = new StartRegionIterator(pos, 3, 10,
174    hiddenColumns);
175  0 assertTrue(it.hasNext());
176  0 Integer result = it.next();
177  0 assertEquals(5, (int) result);
178  0 assertFalse(it.hasNext());
179   
180  0 it = new StartRegionIterator(pos, 3, 15, hiddenColumns);
181  0 assertTrue(it.hasNext());
182  0 result = it.next();
183  0 assertEquals(5, (int) result);
184  0 assertFalse(it.hasNext());
185   
186  0 it = new StartRegionIterator(pos, 3, 18, hiddenColumns);
187  0 assertTrue(it.hasNext());
188  0 result = it.next();
189  0 assertEquals(5, (int) result);
190  0 assertFalse(it.hasNext());
191   
192  0 it = new StartRegionIterator(pos, 3, 19, hiddenColumns);
193  0 assertTrue(it.hasNext());
194  0 result = it.next();
195  0 assertEquals(5, (int) result);
196  0 assertTrue(it.hasNext());
197  0 result = it.next();
198  0 assertEquals(19, (int) result);
199  0 assertFalse(it.hasNext());
200   
201  0 pos = new HiddenCursorPosition(1, 6);
202  0 hiddenColumns.add(new int[] { 47, 50 });
203   
204  0 it = new StartRegionIterator(pos, 15, 60, hiddenColumns);
205  0 assertTrue(it.hasNext());
206  0 result = it.next();
207  0 assertEquals(19, (int) result);
208  0 assertTrue(it.hasNext());
209  0 result = it.next();
210  0 assertEquals(25, (int) result);
211  0 assertFalse(it.hasNext());
212    }
213    }