Open mpi opened 11 years ago
IterableAssert.startsWith checks size of actual iterable: if (sizeOf(actual) < sequenceSize) {
this causes infinite loop for inifinite iterables. Test case:
public void shouldNotEvaluateAllCollection() throws Exception { Iterable<Integer> list = infiniteListOfNumbers(); assertThat(list).startsWith(1, 2, 3, 4, 5); } private Iterable<Integer> infiniteListOfNumbers() { return new Iterable<Integer>() { int number = 1; @Override public Iterator<Integer> iterator() { return new Iterator<Integer>() { @Override public boolean hasNext() { return true; } @Override public Integer next() { return number++; } @Override public void remove() { } }; } }; }
IterableAssert.startsWith checks size of actual iterable: if (sizeOf(actual) < sequenceSize) {
this causes infinite loop for inifinite iterables. Test case: