Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce typecasting in OrderedIterableTestCase. #1586

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@

public interface OrderedIterableTestCase extends RichIterableTestCase
{
@Override
<T> OrderedIterable<T> newWith(T... elements);

/**
* @since 9.1.
*/
@Test
default void OrderedIterable_collectWithIndex()
{
RichIterable<ObjectIntPair<Integer>> pairs = ((OrderedIterable<Integer>) this.newWith(3, 2, 1, 0))
RichIterable<ObjectIntPair<Integer>> pairs = this.newWith(3, 2, 1, 0)
.collectWithIndex(PrimitiveTuples::pair);
Assert.assertEquals(
IntLists.mutable.with(0, 1, 2, 3),
Expand All @@ -56,7 +59,7 @@ default void OrderedIterable_collectWithIndex()
@Test
default void OrderedIterable_collectWithIndexWithTarget()
{
RichIterable<ObjectIntPair<Integer>> pairs = ((OrderedIterable<Integer>) this.newWith(3, 2, 1, 0))
RichIterable<ObjectIntPair<Integer>> pairs = this.newWith(3, 2, 1, 0)
.collectWithIndex(PrimitiveTuples::pair, Lists.mutable.empty());
Assert.assertEquals(
IntLists.mutable.with(0, 1, 2, 3),
Expand All @@ -65,7 +68,7 @@ default void OrderedIterable_collectWithIndexWithTarget()
Lists.mutable.with(3, 2, 1, 0),
pairs.collect(ObjectIntPair::getOne, Lists.mutable.empty()));

RichIterable<ObjectIntPair<Integer>> setOfPairs = ((OrderedIterable<Integer>) this.newWith(3, 2, 1, 0))
RichIterable<ObjectIntPair<Integer>> setOfPairs = this.newWith(3, 2, 1, 0)
.collectWithIndex(PrimitiveTuples::pair, Lists.mutable.empty());
Assert.assertEquals(
IntSets.mutable.with(0, 1, 2, 3),
Expand All @@ -84,19 +87,19 @@ default void OrderedIterable_getFirst()
@Test
default void OrderedIterable_getFirstOptional_empty()
{
assertSame(Optional.empty(), ((OrderedIterable<?>) this.newWith()).getFirstOptional());
assertSame(Optional.empty(), this.newWith().getFirstOptional());
}

@Test
default void OrderedIterable_getFirstOptional()
{
assertEquals(Optional.of(Integer.valueOf(3)), ((OrderedIterable<?>) this.newWith(3, 3, 3, 2, 2, 1)).getFirstOptional());
assertEquals(Optional.of(Integer.valueOf(3)), this.newWith(3, 3, 3, 2, 2, 1).getFirstOptional());
}

@Test
default void OrderedIterable_getFirstOptional_null_element()
{
assertThrows(NullPointerException.class, () -> ((OrderedIterable<?>) this.newWith(new Object[]{null})).getFirstOptional());
assertThrows(NullPointerException.class, () -> this.newWith(new Object[]{null}).getFirstOptional());
}

@Test
Expand All @@ -108,19 +111,19 @@ default void OrderedIterable_getLast()
@Test
default void OrderedIterable_getLastOptional_empty()
{
assertSame(Optional.empty(), ((OrderedIterable<?>) this.newWith()).getLastOptional());
assertSame(Optional.empty(), this.newWith().getLastOptional());
}

@Test
default void OrderedIterable_getLastOptional()
{
assertEquals(Optional.of(Integer.valueOf(1)), ((OrderedIterable<?>) this.newWith(3, 3, 3, 2, 2, 1)).getLastOptional());
assertEquals(Optional.of(Integer.valueOf(1)), this.newWith(3, 3, 3, 2, 2, 1).getLastOptional());
}

@Test(expected = NullPointerException.class)
default void OrderedIterable_getLastOptional_null_element()
{
((OrderedIterable<?>) this.newWith(new Object[]{null})).getLastOptional();
this.newWith(new Object[]{null}).getLastOptional();
}

@Test
Expand Down
Loading