X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fdatamodel%2FAllColsIteratorTest.java;h=3394794cbf0f4045e30ddaf556b37b7eace1e55f;hb=56d72101b0584635cf539d5413db27abc8deb575;hp=fbb20be2c5f6de109067f1752588fac273e82c45;hpb=536a4a9c407a4c07b71e86e75135eaa2ba5e8850;p=jalview.git diff --git a/test/jalview/datamodel/AllColsIteratorTest.java b/test/jalview/datamodel/AllColsIteratorTest.java index fbb20be..3394794 100644 --- a/test/jalview/datamodel/AllColsIteratorTest.java +++ b/test/jalview/datamodel/AllColsIteratorTest.java @@ -30,14 +30,13 @@ import org.testng.annotations.Test; public class AllColsIteratorTest { HiddenColumns hiddenCols; - - @BeforeClass + + @BeforeClass(alwaysRun = true) public void setup() { hiddenCols = new HiddenColumns(); - hiddenCols.hideColumns(2,4); + hiddenCols.hideColumns(2, 4); } - /* * Test iterator iterates through collection correctly @@ -59,8 +58,10 @@ public class AllColsIteratorTest * Test iterator throws NoSuchElementException at end of iteration */ @Test( - groups = { "Functional" }, - expectedExceptions = { NoSuchElementException.class }) + groups = + { "Functional" }, + expectedExceptions = + { NoSuchElementException.class }) public void testLastNext() throws NoSuchElementException { AllColsIterator it = new AllColsIterator(0, 3, hiddenCols); @@ -75,11 +76,30 @@ public class AllColsIteratorTest * Test iterator throws UnsupportedOperationException on call to remove */ @Test( - groups = { "Functional" }, - expectedExceptions = { UnsupportedOperationException.class }) + groups = + { "Functional" }, + expectedExceptions = + { UnsupportedOperationException.class }) public void testRemove() throws UnsupportedOperationException { AllColsIterator it = new AllColsIterator(0, 3, hiddenCols); it.remove(); } + + /* + * Test iterator behaves correctly when there is only one element in the collection + */ + @Test(groups = { "Functional" }) + public void testOneElement() + { + HiddenColumns hidden = new HiddenColumns(); + AllColsIterator it = new AllColsIterator(0, 0, hidden); + int count = 0; + while (it.hasNext()) + { + it.next(); + count++; + } + assertTrue(count == 1, "hasNext() is false after 1 iteration"); + } }