@Test public void testForEachWithIndexToArrayUsingFixedArrayList() { Integer[] array = new Integer[10]; List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); Assert.assertTrue(ArrayIterate.allSatisfy(array, Predicates.isNull())); ParallelIterate.forEachWithIndex(list, (each, index) -> array[index] = each, 1, 2); Assert.assertArrayEquals(array, list.toArray(new Integer[list.size()])); }
@Test public void testForEachWithIndexToArrayUsingArrayList() { Integer[] array = new Integer[200]; List<Integer> list = new ArrayList<>(Interval.oneTo(200)); Assert.assertTrue(ArrayIterate.allSatisfy(array, Predicates.isNull())); ParallelIterate.forEachWithIndex(list, (each, index) -> array[index] = each, 10, 10); Assert.assertArrayEquals(array, list.toArray(new Integer[] {})); }
@Test public void testForEachWithIndexException() { Verify.assertThrows( RuntimeException.class, () -> ParallelIterate.forEachWithIndex( ParallelIterateAcceptanceTest.createIntegerList(5), new PassThruObjectIntProcedureFactory<>(EXCEPTION_OBJECT_INT_PROCEDURE), new PassThruCombiner<>(), 1, 5)); }