use of org.eclipse.collections.api.block.procedure.Procedure2 in project eclipse-collections by eclipse.
the class DropIterableTest method forEachWith.
@Test
public void forEachWith() {
Procedure2<Integer, Sum> sumAdditionProcedure = (each, sum) -> sum.add(each);
Sum sum1 = new IntegerSum(0);
this.dropIterable.forEachWith(sumAdditionProcedure, sum1);
Assert.assertEquals(12, sum1.getValue().intValue());
Sum sum2 = new IntegerSum(0);
this.emptyListDropIterable.forEachWith(sumAdditionProcedure, sum2);
Assert.assertEquals(0, sum2.getValue().intValue());
Sum sum3 = new IntegerSum(0);
this.zeroCountDropIterable.forEachWith(sumAdditionProcedure, sum3);
Assert.assertEquals(15, sum3.getValue().intValue());
Sum sum5 = new IntegerSum(0);
this.nearCountDropIterable.forEachWith(sumAdditionProcedure, sum5);
Assert.assertEquals(5, sum5.getValue().intValue());
Sum sum6 = new IntegerSum(0);
this.sameCountDropIterable.forEachWith(sumAdditionProcedure, sum6);
Assert.assertEquals(0, sum6.getValue().intValue());
Sum sum7 = new IntegerSum(0);
this.higherCountDropIterable.forEachWith(sumAdditionProcedure, sum7);
Assert.assertEquals(0, sum7.getValue().intValue());
}
use of org.eclipse.collections.api.block.procedure.Procedure2 in project eclipse-collections by eclipse.
the class DropWhileIterableTest method forEachWith.
@Test
public void forEachWith() {
Procedure2<Integer, Sum> sumAdditionProcedure = (each, sum) -> sum.add(each);
Sum sum1 = new IntegerSum(0);
this.dropWhileIterable.forEachWith(sumAdditionProcedure, sum1);
Assert.assertEquals(12, sum1.getValue().intValue());
Sum sum2 = new IntegerSum(0);
this.emptyListDropWhileIterable.forEachWith(sumAdditionProcedure, sum2);
Assert.assertEquals(0, sum2.getValue().intValue());
Sum sum3 = new IntegerSum(0);
this.alwaysFalseDropWhileIterable.forEachWith(sumAdditionProcedure, sum3);
Assert.assertEquals(15, sum3.getValue().intValue());
Sum sum5 = new IntegerSum(0);
this.mostlyFalseDropWhileIterable.forEachWith(sumAdditionProcedure, sum5);
Assert.assertEquals(5, sum5.getValue().intValue());
Sum sum6 = new IntegerSum(0);
this.alwaysTrueDropWhileIterable.forEachWith(sumAdditionProcedure, sum6);
Assert.assertEquals(0, sum6.getValue().intValue());
}
use of org.eclipse.collections.api.block.procedure.Procedure2 in project eclipse-collections by eclipse.
the class TakeIterableTest method forEachWith.
@Test
public void forEachWith() {
Procedure2<Integer, Sum> sumAdditionProcedure = (each, sum) -> sum.add(each);
Sum sum1 = new IntegerSum(0);
this.takeIterable.forEachWith(sumAdditionProcedure, sum1);
Assert.assertEquals(3, sum1.getValue().intValue());
Sum sum2 = new IntegerSum(0);
this.emptyListTakeIterable.forEachWith(sumAdditionProcedure, sum2);
Assert.assertEquals(0, sum2.getValue().intValue());
Sum sum3 = new IntegerSum(0);
this.zeroCountTakeIterable.forEachWith(sumAdditionProcedure, sum3);
Assert.assertEquals(0, sum3.getValue().intValue());
Sum sum5 = new IntegerSum(0);
this.sameCountTakeIterable.forEachWith(sumAdditionProcedure, sum5);
Assert.assertEquals(15, sum5.getValue().intValue());
Sum sum6 = new IntegerSum(0);
this.higherCountTakeIterable.forEachWith(sumAdditionProcedure, sum6);
Assert.assertEquals(15, sum6.getValue().intValue());
}
use of org.eclipse.collections.api.block.procedure.Procedure2 in project eclipse-collections by eclipse.
the class TakeWhileIterableTest method forEachWith.
@Test
public void forEachWith() {
Procedure2<Integer, Sum> sumAdditionProcedure = (each, sum) -> sum.add(each);
Sum sum1 = new IntegerSum(0);
this.takeWhileIterable.forEachWith(sumAdditionProcedure, sum1);
Assert.assertEquals(3, sum1.getValue().intValue());
Sum sum2 = new IntegerSum(0);
this.emptyListTakeWhileIterable.forEachWith(sumAdditionProcedure, sum2);
Assert.assertEquals(0, sum2.getValue().intValue());
Sum sum3 = new IntegerSum(0);
this.alwaysFalseTakeWhileIterable.forEachWith(sumAdditionProcedure, sum3);
Assert.assertEquals(0, sum3.getValue().intValue());
Sum sum5 = new IntegerSum(0);
this.alwaysTrueTakeWhileIterable.forEachWith(sumAdditionProcedure, sum5);
Assert.assertEquals(15, sum5.getValue().intValue());
}
Aggregations