Skip to content

Commit

Permalink
(yegor256#1169) Improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
andreoss committed Oct 21, 2020
1 parent ce9cadc commit 08038b3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/test/java/org/cactoos/iterator/MappedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@
*/
package org.cactoos.iterator;

import java.util.Iterator;
import java.util.NoSuchElementException;
import org.cactoos.iterable.IterableOf;
import org.junit.jupiter.api.Test;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.HasValues;
import org.llorllale.cactoos.matchers.Throws;

/**
* Tests for {@link org.cactoos.iterator.Mapped}.
Expand All @@ -47,4 +50,18 @@ void iteratatesOver() {
new HasValues<>("1", "2", "0")
).affirm();
}

@Test
void failsIfIteratorExhausted() {
final Iterator<String> iterator = new Mapped<>(
Number::toString,
new IteratorOf<Number>(1)
);
iterator.next();
new Assertion<>(
"must throw NSEE",
iterator::next,
new Throws<>(NoSuchElementException.class)
).affirm();
}
}

0 comments on commit 08038b3

Please sign in to comment.