use of org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList in project eclipse-collections by eclipse.
the class AbstractRichIterableTestCase method collectByteWithTarget.
@Test
public void collectByteWithTarget() {
MutableByteCollection target = new ByteArrayList();
ByteIterable result = this.newWith(1, 2, 3, 4).collectByte(PrimitiveFunctions.unboxIntegerToByte(), target);
Assert.assertSame("Target list sent as parameter not returned", target, result);
Assert.assertEquals(ByteHashBag.newBagWith((byte) 1, (byte) 2, (byte) 3, (byte) 4), result.toBag());
}
use of org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList in project eclipse-collections by eclipse.
the class ArrayListIterateTest method collectByteOverOptimizeLimit.
@Test
public void collectByteOverOptimizeLimit() {
ArrayList<Integer> list = new ArrayList<>(Interval.zeroTo(OVER_OPTIMIZED_LIMIT));
MutableByteList actual = ArrayListIterate.collectByte(list, PrimitiveFunctions.unboxIntegerToByte());
ByteArrayList expected = new ByteArrayList(list.size());
for (int i = 0; i <= OVER_OPTIMIZED_LIMIT; i++) {
expected.add((byte) i);
}
Assert.assertEquals(expected, actual);
}
use of org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList in project eclipse-collections by eclipse.
the class ArrayListIterateTest method collectByteWithTargetOverOptimizeLimit.
@Test
public void collectByteWithTargetOverOptimizeLimit() {
ArrayList<Integer> list = new ArrayList<>(Interval.zeroTo(OVER_OPTIMIZED_LIMIT));
MutableByteList target = new ByteArrayList();
MutableByteList actual = ArrayListIterate.collectByte(list, PrimitiveFunctions.unboxIntegerToByte(), target);
ByteArrayList expected = new ByteArrayList(list.size());
for (int i = 0; i <= OVER_OPTIMIZED_LIMIT; i++) {
expected.add((byte) i);
}
Assert.assertEquals(expected, actual);
Assert.assertSame("Target sent as parameter was not returned as result", target, actual);
}
use of org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList in project eclipse-collections by eclipse.
the class IterateTest method collectByteWithTarget.
@Test
public void collectByteWithTarget() {
this.iterables.each(each -> {
MutableByteCollection expected = new ByteArrayList();
MutableByteCollection actual = Iterate.collectByte(each, PrimitiveFunctions.unboxIntegerToByte(), expected);
Assert.assertTrue(actual.containsAll((byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5));
Assert.assertSame("Target list sent as parameter not returned", expected, actual);
});
Verify.assertThrows(IllegalArgumentException.class, () -> Iterate.collectByte(null, PrimitiveFunctions.unboxIntegerToByte(), new ByteArrayList()));
}
use of org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList in project eclipse-collections by eclipse.
the class ImmutableEmptySortedBagTest method collectByte.
@Override
@Test
public void collectByte() {
ImmutableSortedBag<Integer> bag = this.classUnderTest();
Assert.assertEquals(new ByteArrayList(), bag.collectByte(PrimitiveFunctions.unboxIntegerToByte()));
}
Aggregations