diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2018-10-14 14:07:00 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2018-10-14 14:07:00 -0400 |
| commit | d1d01769e7c55f7f62dc01cadf420d5f63424584 (patch) | |
| tree | 5415f41c405622441840d5dd81b91ea8d7e7de31 /base/src/main/java/bjc/utils/funcutils/TestUtils.java | |
| parent | a78d2f10f8142af6a4e557588c06546e2231eb3f (diff) | |
Testing
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()); + } +} |
