use of org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList in project eclipse-collections by eclipse.
the class AbstractRichIterableTestCase method collectFloatWithTarget.
@Test
public void collectFloatWithTarget() {
MutableFloatCollection target = new FloatArrayList();
FloatIterable result = this.newWith(1, 2, 3, 4).collectFloat(PrimitiveFunctions.unboxIntegerToFloat(), target);
Assert.assertSame("Target list sent as parameter not returned", target, result);
Assert.assertEquals(FloatHashBag.newBagWith(1.0f, 2.0f, 3.0f, 4.0f), result.toBag());
}
use of org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList in project eclipse-collections by eclipse.
the class ArrayIterateTest method collectFloatWithTarget.
@Test
public void collectFloatWithTarget() {
Integer[] objectArray = { -1, 0, 42 };
FloatArrayList target = new FloatArrayList();
FloatArrayList result = ArrayIterate.collectFloat(objectArray, PrimitiveFunctions.unboxIntegerToFloat(), target);
Assert.assertEquals(this.getExpectedFloatResults(), result);
Assert.assertSame("Target List not returned as result", target, result);
}
use of org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList in project eclipse-collections by eclipse.
the class ArrayListIterateTest method collectFloatWithTargetOverOptimizeLimit.
@Test
public void collectFloatWithTargetOverOptimizeLimit() {
ArrayList<Integer> list = new ArrayList<>(Interval.zeroTo(OVER_OPTIMIZED_LIMIT));
MutableFloatList target = new FloatArrayList();
MutableFloatList actual = ArrayListIterate.collectFloat(list, PrimitiveFunctions.unboxIntegerToFloat(), target);
FloatArrayList expected = new FloatArrayList(list.size());
for (int i = 0; i <= OVER_OPTIMIZED_LIMIT; i++) {
expected.add((float) 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.FloatArrayList in project eclipse-collections by eclipse.
the class ArrayListIterateTest method collectFloatOverOptimizeLimit.
@Test
public void collectFloatOverOptimizeLimit() {
ArrayList<Integer> list = new ArrayList<>(Interval.zeroTo(OVER_OPTIMIZED_LIMIT));
MutableFloatList actual = ArrayListIterate.collectFloat(list, PrimitiveFunctions.unboxIntegerToFloat());
FloatArrayList expected = new FloatArrayList(list.size());
for (int i = 0; i <= OVER_OPTIMIZED_LIMIT; i++) {
expected.add((float) i);
}
Assert.assertEquals(expected, actual);
}
use of org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList in project eclipse-collections by eclipse.
the class IterateTest method collectFloatWithTarget.
@Test
public void collectFloatWithTarget() {
this.iterables.each(each -> {
MutableFloatCollection expected = new FloatArrayList();
MutableFloatCollection actual = Iterate.collectFloat(each, PrimitiveFunctions.unboxIntegerToFloat(), expected);
Assert.assertTrue(actual.containsAll(1.0f, 2.0f, 3.0f, 4.0f, 5.0f));
Assert.assertSame("Target list sent as parameter not returned", expected, actual);
});
Verify.assertThrows(IllegalArgumentException.class, () -> Iterate.collectFloat(null, PrimitiveFunctions.unboxIntegerToFloat(), new FloatArrayList()));
}
Aggregations