use of org.eclipse.collections.api.list.primitive.MutableShortList in project eclipse-collections by eclipse.
the class ArrayListIterateTest method collectShortWithTarget.
@Test
public void collectShortWithTarget() {
ArrayList<Integer> list = this.createIntegerList();
MutableShortList target = new ShortArrayList();
MutableShortList actual = ArrayListIterate.collectShort(list, PrimitiveFunctions.unboxIntegerToShort(), target);
Assert.assertSame("Target list sent as parameter not returned", target, actual);
Assert.assertEquals(ShortArrayList.newListWith((short) -1, (short) 0, (short) 4), actual);
}
use of org.eclipse.collections.api.list.primitive.MutableShortList in project eclipse-collections by eclipse.
the class ArrayListIterateTest method collectShortWithTargetOverOptimizeLimit.
@Test
public void collectShortWithTargetOverOptimizeLimit() {
ArrayList<Integer> list = new ArrayList<>(Interval.zeroTo(OVER_OPTIMIZED_LIMIT));
MutableShortList target = new ShortArrayList();
MutableShortList actual = ArrayListIterate.collectShort(list, PrimitiveFunctions.unboxIntegerToShort(), target);
ShortArrayList expected = new ShortArrayList(list.size());
for (int i = 0; i <= OVER_OPTIMIZED_LIMIT; i++) {
expected.add((short) i);
}
Assert.assertEquals(expected, actual);
Assert.assertSame("Target sent as parameter was not returned as result", target, actual);
}
use of org.eclipse.collections.api.list.primitive.MutableShortList in project eclipse-collections by eclipse.
the class ArrayListIterateTest method collectShort.
@Test
public void collectShort() {
ArrayList<Integer> list = this.createIntegerList();
MutableShortList actual = ArrayListIterate.collectShort(list, PrimitiveFunctions.unboxIntegerToShort());
Assert.assertEquals(ShortArrayList.newListWith((short) -1, (short) 0, (short) 4), actual);
}
use of org.eclipse.collections.api.list.primitive.MutableShortList in project eclipse-collections by eclipse.
the class ArrayListIterateTest method collectShortOverOptimizeLimit.
@Test
public void collectShortOverOptimizeLimit() {
ArrayList<Integer> list = new ArrayList<>(Interval.zeroTo(OVER_OPTIMIZED_LIMIT));
MutableShortList actual = ArrayListIterate.collectShort(list, PrimitiveFunctions.unboxIntegerToShort());
ShortArrayList expected = new ShortArrayList(list.size());
for (int i = 0; i <= OVER_OPTIMIZED_LIMIT; i++) {
expected.add((short) i);
}
Assert.assertEquals(expected, actual);
}
use of org.eclipse.collections.api.list.primitive.MutableShortList in project eclipse-collections by eclipse.
the class AbstractListTestCase method collectShort.
@Override
public void collectShort() {
super.collectShort();
MutableShortList result = this.newWith(1, 2, 3, 4).collectShort(PrimitiveFunctions.unboxIntegerToShort());
Assert.assertEquals(ShortLists.mutable.of((short) 1, (short) 2, (short) 3, (short) 4), result);
}
Aggregations