JAL-2050 JAL-1722 new getSelectedRange() method to quickly hide selected columns
[jalview.git] / test / jalview / datamodel / ColumnSelectionTest.java
index 0f08ceb..0245b15 100644 (file)
@@ -244,6 +244,32 @@ public class ColumnSelectionTest
   }
 
   /**
+   * Test the method that gets runs of selected columns ordered by column. If
+   * this fails, HideSelectedColumns may also fail
+   */
+  @Test(groups = { "Functional" })
+  public void testgetSelectedRanges()
+  {
+    ColumnSelection cs = new ColumnSelection();
+    int[] sel = { 2, 3, 4, 7, 8, 9, 20, 21, 22 };
+    for (int col : sel)
+    {
+      cs.addElement(col);
+    }
+    List<int[]> range;
+    range = cs.getSelectedRanges();
+    assertEquals(3, range.size());
+    assertEquals("[2, 4]", Arrays.toString(range.get(0)));
+    assertEquals("[7, 9]", Arrays.toString(range.get(1)));
+    assertEquals("[20, 22]", Arrays.toString(range.get(2)));
+    cs.addElement(0);
+    cs.addElement(1);
+    range = cs.getSelectedRanges();
+    assertEquals(3, range.size());
+    assertEquals("[0, 4]", Arrays.toString(range.get(0)));
+  }
+
+  /**
    * Test the method that reveals a range of hidden columns given the start
    * column of the range
    */