package jalview.datamodel; import static org.junit.Assert.assertEquals; import java.util.List; import org.junit.Test; public class ColumnSelectionTest { @Test public void testAddElement() { ColumnSelection cs = new ColumnSelection(); cs.addElement(2); cs.addElement(5); List sel = cs.getSelected(); assertEquals(2, sel.size()); assertEquals(new Integer(2), sel.get(0)); assertEquals(new Integer(5), sel.get(1)); } /** * Test the remove method - in particular to verify that remove(int i) removes * the element whose value is i, _NOT_ the i'th element. */ @Test public void testRemoveElement() { ColumnSelection cs = new ColumnSelection(); cs.addElement(2); cs.addElement(5); // removing elements not in the list has no effect cs.removeElement(0); cs.removeElement(1); List sel = cs.getSelected(); assertEquals(2, sel.size()); assertEquals(new Integer(2), sel.get(0)); assertEquals(new Integer(5), sel.get(1)); // removing an element in the list removes it cs.removeElement(2); assertEquals(1, sel.size()); assertEquals(new Integer(5), sel.get(0)); } }