diff --git a/src/test/java/org/cactoos/iterable/SkippedTest.java b/src/test/java/org/cactoos/iterable/SkippedTest.java index 7e26505d28..9c30d804fe 100644 --- a/src/test/java/org/cactoos/iterable/SkippedTest.java +++ b/src/test/java/org/cactoos/iterable/SkippedTest.java @@ -23,9 +23,11 @@ */ package org.cactoos.iterable; -import org.hamcrest.MatcherAssert; -import org.hamcrest.Matchers; +import org.cactoos.list.ListOf; +import org.hamcrest.collection.IsEmptyIterable; +import org.hamcrest.core.IsEqual; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; /** * Test Case for {@link Skipped}. @@ -33,21 +35,101 @@ * @since 0.34 * @checkstyle JavadocMethodCheck (500 lines) */ +@SuppressWarnings("PMD.AvoidDuplicateLiterals") public final class SkippedTest { @Test - @SuppressWarnings("PMD.AvoidDuplicateLiterals") public void skipIterable() { - MatcherAssert.assertThat( - "Can't skip elements in iterable", + new Assertion<>( + "Must skip elements in iterable", + new Skipped<>( + 2, + new IterableOf<>("one", "two", "three", "four") + ), + new IsEqual<>( + new IterableOf<>( + "three", + "four" + ) + ) + ).affirm(); + } + + @Test + public void skipArray() { + new Assertion<>( + "Must skip elements in array", + new Skipped<>( + 2, + "one", "two", "three", "four" + ), + new IsEqual<>( + new IterableOf<>( + "three", + "four" + ) + ) + ).affirm(); + } + + @Test + public void skipCollection() { + new Assertion<>( + "Must skip elements in collection", + new Skipped<>( + 2, + new ListOf<>("one", "two", "three", "four") + ), + new IsEqual<>( + new IterableOf<>( + "three", + "four" + ) + ) + ).affirm(); + } + + @Test + public void skippedAllElements() { + new Assertion<>( + "Must skip all elements", new Skipped<>( 2, + "one", "two" + ), + new IsEmptyIterable<>() + ).affirm(); + } + + @Test + public void skippedMoreThanExists() { + new Assertion<>( + "Can't skip more than exists", + new Skipped<>( + Integer.MAX_VALUE, + "one", "two" + ), + new IsEmptyIterable<>() + ).affirm(); + } + + @Test + @SuppressWarnings("PMD.AvoidDuplicateLiterals") + public void skippedNegativeSize() { + new Assertion<>( + "Must process negative skipped size", + new Skipped<>( + -1, "one", "two", "three", "four" ), - Matchers.contains( - "three", - "four" + new IsEqual<>( + new IterableOf<>( + "one", + "two", + "three", + "four" + ) ) - ); + ).affirm(); } }