Skip to content

Commit

Permalink
Remove dependency between IteratorOfXXX tests #838
Browse files Browse the repository at this point in the history
  • Loading branch information
victornoel committed May 12, 2018
1 parent 6f726eb commit 6caaae6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
15 changes: 5 additions & 10 deletions src/test/java/org/cactoos/iterator/IteratorOfFloatsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,20 @@ public void emptyIteratorThrowsException() {

@Test
public void nonEmptyIteratorDoesNotHaveNext() {
final IteratorOfFloats iterator = new IteratorOfFloats(1.0f, 2.0f);
iterator.next();
iterator.next();
MatcherAssert.assertThat(
"hasNext is true for fully traversed iterator.",
this.iteratorWithFetchedElements().hasNext(),
iterator.hasNext(),
new IsEqual<>(false)
);
}

@Test(expected = NoSuchElementException.class)
public void nonEmptyIteratorThrowsException() {
this.iteratorWithFetchedElements().next();
}

private IteratorOfFloats iteratorWithFetchedElements() {
final IteratorOfFloats iterator = new IteratorOfFloats(
1.0f, 2.0f, 3.0f
);
iterator.next();
final IteratorOfFloats iterator = new IteratorOfFloats(1.0f);
iterator.next();
iterator.next();
return iterator;
}
}
15 changes: 5 additions & 10 deletions src/test/java/org/cactoos/iterator/IteratorOfIntsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,20 @@ public void emptyIteratorThrowsException() {

@Test
public void nonEmptyIteratorDoesNotHaveNext() {
final IteratorOfInts iterator = new IteratorOfInts(1, 2);
iterator.next();
iterator.next();
MatcherAssert.assertThat(
"hasNext is true for fully traversed iterator.",
this.iteratorWithFetchedElements().hasNext(),
iterator.hasNext(),
new IsEqual<>(false)
);
}

@Test(expected = NoSuchElementException.class)
public void nonEmptyIteratorThrowsException() {
this.iteratorWithFetchedElements().next();
}

private IteratorOfInts iteratorWithFetchedElements() {
final IteratorOfInts iterator = new IteratorOfInts(
1, 2, 3
);
iterator.next();
final IteratorOfInts iterator = new IteratorOfInts(1);
iterator.next();
iterator.next();
return iterator;
}
}

0 comments on commit 6caaae6

Please sign in to comment.