Skip to content

Commit

Permalink
(yegor256#1303) Added more tests to iterable's Skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
victornoel committed Mar 15, 2020
1 parent a5f70f4 commit a9a10c3
Showing 1 changed file with 91 additions and 9 deletions.
100 changes: 91 additions & 9 deletions src/test/java/org/cactoos/iterable/SkippedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,113 @@
*/
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}.
*
* @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();
}
}

0 comments on commit a9a10c3

Please sign in to comment.