This commit is contained in:
Gary Gregory 2024-05-12 15:59:21 -04:00
parent 7c1788334a
commit 5e36226a06

View File

@ -36,6 +36,7 @@
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import java.util.function.Function;
import java.util.function.Supplier; import java.util.function.Supplier;
import org.apache.commons.lang3.function.Suppliers; import org.apache.commons.lang3.function.Suppliers;
@ -72,7 +73,15 @@ private void assertIsEquals(final Object array1, final Object array2, final Obje
} }
@Test @Test
public void testArraycopy() { public void testArraycopyFunction() {
String[] arr = { "a", "b" };
assertThrows(NullPointerException.class, () -> ArrayUtils.arraycopy(null, 0, 0, 1, i -> new String[3]));
assertThrows(NullPointerException.class, () -> ArrayUtils.arraycopy(arr, 0, 0, 1, i -> null));
assertThrows(NullPointerException.class, () -> ArrayUtils.arraycopy(arr, 0, 0, 1, (Function<Integer, String[]>) null));
}
@Test
public void testArraycopySupplier() {
String[] arr = { "a", "b" }; String[] arr = { "a", "b" };
assertThrows(NullPointerException.class, () -> ArrayUtils.arraycopy(null, 0, 0, 1, () -> new String[3])); assertThrows(NullPointerException.class, () -> ArrayUtils.arraycopy(null, 0, 0, 1, () -> new String[3]));
assertThrows(NullPointerException.class, () -> ArrayUtils.arraycopy(arr, 0, 0, 1, Suppliers.nul())); assertThrows(NullPointerException.class, () -> ArrayUtils.arraycopy(arr, 0, 0, 1, Suppliers.nul()));