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/main/java/bjc/utils/funcutils/TestUtils.java | |
| parent | 0308029629a12711b849ea7765639b9b1f9e03d2 (diff) | |
| parent | d1d01769e7c55f7f62dc01cadf420d5f63424584 (diff) | |
Merge branch 'master' of github.com:bculkin2442/bjc-utils2
Diffstat (limited to 'base/src/main/java/bjc/utils/funcutils/TestUtils.java')
| -rw-r--r-- | base/src/main/java/bjc/utils/funcutils/TestUtils.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/base/src/main/java/bjc/utils/funcutils/TestUtils.java b/base/src/main/java/bjc/utils/funcutils/TestUtils.java new file mode 100644 index 0000000..df44e7a --- /dev/null +++ b/base/src/main/java/bjc/utils/funcutils/TestUtils.java @@ -0,0 +1,44 @@ +package bjc.utils.funcutils; + +import static org.junit.Assert.assertEquals; + +import java.util.Collection; +import java.util.Iterator; + +/** + * Utilities for testing. + * + * @author bjculkin + * + */ +public class TestUtils { + /** + * Assert an iterator provides a particular sequence of values. + * + * @param src + * The iterator to pull values from. + * @param vals + * The values to expect from the iterator. + */ + public static <T> void assertIteratorEquals(Iterator<T> src, T... vals) { + for (T val : vals) { + assertEquals(val, src.next()); + } + } + + /** + * Assert an iterator provides a particular sequence of values. + * + * @param src + * The iterator to pull values from. + * @param hasMore + * The expected value of hasNext for the iterator. + * @param vals + * The values to expect from the iterator. + */ + public static <T> void assertIteratorEquals(Iterator<T> src, boolean hasMore, T... vals) { + assertIteratorEquals(src, vals); + + assertEquals(hasMore, src.hasNext()); + } +} |
