summaryrefslogtreecommitdiff
path: root/src/test/java/bjc/data/CircularIteratorTest.java
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2019-07-02 18:32:37 -0400
committerbculkin2442 <bjculkin@mix.wvu.edu>2019-07-02 18:32:37 -0400
commit4d0a59a0023f2b4fca144a089a3f75acb4ebd62b (patch)
treeeed89369ceda7dd1b356dd5055ada9287738b092 /src/test/java/bjc/data/CircularIteratorTest.java
parent3a56e3ee3f2f6069de5cf8d2bee81052bbf346e6 (diff)
Move tests to new package
Diffstat (limited to 'src/test/java/bjc/data/CircularIteratorTest.java')
-rw-r--r--src/test/java/bjc/data/CircularIteratorTest.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/test/java/bjc/data/CircularIteratorTest.java b/src/test/java/bjc/data/CircularIteratorTest.java
new file mode 100644
index 0000000..82a08c6
--- /dev/null
+++ b/src/test/java/bjc/data/CircularIteratorTest.java
@@ -0,0 +1,49 @@
+package bjc.data;
+
+import static bjc.TestUtils.*;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+
+import bjc.data.CircularIterator;
+/**
+ * Test for circular iterators.,
+ *
+ * @author bjculkin
+ *
+ */
+public class CircularIteratorTest {
+ /**
+ * Test regular repetition of the entire iterator.
+ */
+ @Test
+ public void testRegular() {
+ List<String> lst = Arrays.asList("a", "b", "c");
+
+ CircularIterator<String> itr = new CircularIterator<>(lst);
+
+ // Check we get initial values correctly, and have more remaining
+ assertIteratorEquals(true, itr, "a", "b", "c");
+
+ // Check we repeat correctly, and can still repeat
+ assertIteratorEquals(true, itr, "a", "b", "c");
+ }
+
+ /**
+ * Test that the last element repeats correctly.
+ */
+ @Test
+ public void testRepLast() {
+ List<String> lst = Arrays.asList("a", "b", "c");
+
+ CircularIterator<String> itr = new CircularIterator<>(lst, false);
+
+ // Check we get initial values correctly, and have more remaining
+ assertIteratorEquals(true, itr, "a", "b", "c");
+
+ // Check we repeat correctly, and can still repeat
+ assertIteratorEquals(true, itr, "c", "c", "c");
+ }
+}