mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix code
This commit is contained in:
parent
8ae9387336
commit
074ead4f17
@ -478,7 +478,7 @@ public class ArrayUtil extends PrimitiveArrayUtil {
|
||||
}
|
||||
|
||||
// 已有数组的元素类型
|
||||
Class<?> originComponentType = array.getClass().getComponentType();
|
||||
final Class<?> originComponentType = array.getClass().getComponentType();
|
||||
Object newEleArr = newElements;
|
||||
// 如果 已有数组的元素类型是 原始类型,则需要转换 新元素数组 为该类型,避免ArrayStoreException
|
||||
if (originComponentType.isPrimitive()) {
|
||||
|
@ -579,7 +579,9 @@ public class ArrayUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInsertPrimitive() {
|
||||
public void insertPrimitiveTest() {
|
||||
// https://gitee.com/dromara/hutool/pulls/874
|
||||
|
||||
final boolean[] booleans = new boolean[10];
|
||||
final byte[] bytes = new byte[10];
|
||||
final char[] chars = new char[10];
|
||||
@ -589,13 +591,21 @@ public class ArrayUtilTest {
|
||||
final float[] floats = new float[10];
|
||||
final double[] doubles = new double[10];
|
||||
|
||||
boolean[] insert1 = ArrayUtil.insert(booleans, 0, 0, 1, 2);
|
||||
byte[] insert2 = ArrayUtil.insert(bytes, 0, 1, 2, 3);
|
||||
char[] insert3 = ArrayUtil.insert(chars, 0, 1, 2, 3);
|
||||
short[] insert4 = ArrayUtil.insert(shorts, 0, 1, 2, 3);
|
||||
int[] insert5 = ArrayUtil.insert(ints, 0, 1, 2, 3);
|
||||
long[] insert6 = ArrayUtil.insert(longs, 0, 1, 2, 3);
|
||||
float[] insert7 = ArrayUtil.insert(floats, 0, 1, 2, 3);
|
||||
double[] insert8 = ArrayUtil.insert(doubles, 0, 1, 2, 3);
|
||||
final boolean[] insert1 = ArrayUtil.insert(booleans, 0, 0, 1, 2);
|
||||
Assert.assertNotNull(insert1);
|
||||
final byte[] insert2 = ArrayUtil.insert(bytes, 0, 1, 2, 3);
|
||||
Assert.assertNotNull(insert2);
|
||||
final char[] insert3 = ArrayUtil.insert(chars, 0, 1, 2, 3);
|
||||
Assert.assertNotNull(insert3);
|
||||
final short[] insert4 = ArrayUtil.insert(shorts, 0, 1, 2, 3);
|
||||
Assert.assertNotNull(insert4);
|
||||
final int[] insert5 = ArrayUtil.insert(ints, 0, 1, 2, 3);
|
||||
Assert.assertNotNull(insert5);
|
||||
final long[] insert6 = ArrayUtil.insert(longs, 0, 1, 2, 3);
|
||||
Assert.assertNotNull(insert6);
|
||||
final float[] insert7 = ArrayUtil.insert(floats, 0, 1, 2, 3);
|
||||
Assert.assertNotNull(insert7);
|
||||
final double[] insert8 = ArrayUtil.insert(doubles, 0, 1, 2, 3);
|
||||
Assert.assertNotNull(insert8);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user