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
79ef7de544
commit
f368a0a0d2
@ -990,11 +990,9 @@ public class ArrayUtil extends PrimitiveArrayUtil {
|
||||
final Class<?> componentType = obj.getClass().getComponentType();
|
||||
// 原始类型
|
||||
if (componentType.isPrimitive()) {
|
||||
int length = Array.getLength(obj);
|
||||
final int length = Array.getLength(obj);
|
||||
result = Array.newInstance(componentType, length);
|
||||
while (length-- > 0) {
|
||||
Array.set(result, length, Array.get(obj, length));
|
||||
}
|
||||
copy(obj, result, length);
|
||||
} else {
|
||||
result = ((Object[]) obj).clone();
|
||||
}
|
||||
|
@ -90,6 +90,9 @@ public class ArrayUtilTest {
|
||||
final int[] a = {1, 2, 3};
|
||||
final int[] clone = ArrayUtil.clone(a);
|
||||
Assertions.assertArrayEquals(a, clone);
|
||||
|
||||
final int[] clone1 = a.clone();
|
||||
Assertions.assertArrayEquals(a, clone1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -606,10 +609,16 @@ public class ArrayUtilTest {
|
||||
void setOrPaddingTest2(){
|
||||
final String[] arr = new String[0];
|
||||
final String[] newArr = ArrayUtil.setOrPadding(arr, 2, "Good");
|
||||
Console.log(newArr);
|
||||
Assertions.assertArrayEquals(new String[]{null, null, "Good"}, newArr);
|
||||
}
|
||||
|
||||
@Test
|
||||
void setOrPaddingTest3(){
|
||||
final String[] arr = new String[0];
|
||||
final String[] newArr = ArrayUtil.setOrPadding(arr, 2, "Good", "pad");
|
||||
Assertions.assertArrayEquals(new String[]{"pad", "pad", "Good"}, newArr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAnyTest() {
|
||||
final String[] a = {"a", "b", "c", "d", "e"};
|
||||
|
Loading…
x
Reference in New Issue
Block a user