blob: df44e7ae86e5f0b7398e396783315485d13c116c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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());
}
}
|