JAL-1705 generalised getLength() to handle [start1, end1, start2,
[jalview.git] / test / jalview / util / MappingUtilsTest.java
index b53d513..3c417c3 100644 (file)
@@ -861,6 +861,10 @@ public class MappingUtilsTest
   public void testGetLength()
   {
     assertEquals(0, MappingUtils.getLength(null));
+
+    /*
+     * [start, end] ranges
+     */
     List<int[]> ranges = new ArrayList<int[]>();
     assertEquals(0, MappingUtils.getLength(ranges));
     ranges.add(new int[] { 1, 1 });
@@ -869,6 +873,15 @@ public class MappingUtilsTest
     assertEquals(10, MappingUtils.getLength(ranges));
     ranges.add(new int[] { 20, 10 });
     assertEquals(21, MappingUtils.getLength(ranges));
+
+    /*
+     * [start, end, start, end...] ranges
+     */
+    ranges.clear();
+    ranges.add(new int[] { 1, 5, 8, 4 });
+    ranges.add(new int[] { 8, 2 });
+    ranges.add(new int[] { 12, 12 });
+    assertEquals(18, MappingUtils.getLength(ranges));
   }
 
   @Test(groups = { "Functional" })