diff options
| author | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2018-10-16 06:11:39 -0300 |
|---|---|---|
| committer | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2018-10-16 06:11:39 -0300 |
| commit | d2be5b73d7a5653ad5c8273c17284346baa6f1c7 (patch) | |
| tree | 9d3c6adb193f53588bd5d004fdf80c0381685351 /base/src/test/java/bjc/utils/data/CircularIteratorTest.java | |
| parent | 0308029629a12711b849ea7765639b9b1f9e03d2 (diff) | |
| parent | d1d01769e7c55f7f62dc01cadf420d5f63424584 (diff) | |
Merge branch 'master' of github.com:bculkin2442/bjc-utils2
Diffstat (limited to 'base/src/test/java/bjc/utils/data/CircularIteratorTest.java')
| -rw-r--r-- | base/src/test/java/bjc/utils/data/CircularIteratorTest.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/base/src/test/java/bjc/utils/data/CircularIteratorTest.java b/base/src/test/java/bjc/utils/data/CircularIteratorTest.java new file mode 100644 index 0000000..c08bbb1 --- /dev/null +++ b/base/src/test/java/bjc/utils/data/CircularIteratorTest.java @@ -0,0 +1,50 @@ +package bjc.utils.data; + +import static org.junit.Assert.*; +import static bjc.utils.funcutils.TestUtils.*; + +import java.util.Arrays; +import java.util.List; + +import org.junit.Test; + +/** + * 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(itr, true, "a", "b", "c"); + + // Check we repeat correctly, and can still repeat + assertIteratorEquals(itr, true, "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(itr, true, "a", "b", "c"); + + // Check we repeat correctly, and can still repeat + assertIteratorEquals(itr, true, "c", "c", "c"); + } +} |
