mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix bug
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
package cn.hutool.core.util;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Editor;
|
||||
import cn.hutool.core.lang.Filter;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* {@link ArrayUtil} 数组工具单元测试
|
||||
@@ -20,8 +23,10 @@ public class ArrayUtilTest {
|
||||
Assert.assertTrue(ArrayUtil.isEmpty(a));
|
||||
Assert.assertTrue(ArrayUtil.isEmpty((Object) a));
|
||||
int[] b = null;
|
||||
//noinspection ConstantConditions
|
||||
Assert.assertTrue(ArrayUtil.isEmpty(b));
|
||||
Object c = null;
|
||||
//noinspection ConstantConditions
|
||||
Assert.assertTrue(ArrayUtil.isEmpty(c));
|
||||
|
||||
Object d = new Object[]{"1", "2", 3, 4D};
|
||||
@@ -31,7 +36,9 @@ public class ArrayUtilTest {
|
||||
isEmpty = ArrayUtil.isEmpty(d);
|
||||
Assert.assertTrue(isEmpty);
|
||||
d = null;
|
||||
//noinspection ConstantConditions
|
||||
isEmpty = ArrayUtil.isEmpty(d);
|
||||
//noinspection ConstantConditions
|
||||
Assert.assertTrue(isEmpty);
|
||||
}
|
||||
|
||||
@@ -117,7 +124,7 @@ public class ArrayUtilTest {
|
||||
String[] keys = {"a", "b", "c"};
|
||||
Integer[] values = {1, 2, 3};
|
||||
Map<String, Integer> map = ArrayUtil.zip(keys, values, true);
|
||||
Assert.assertEquals(map.toString(), "{a=1, b=2, c=3}");
|
||||
Assert.assertEquals(Objects.requireNonNull(map).toString(), "{a=1, b=2, c=3}");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -248,4 +255,14 @@ public class ArrayUtilTest {
|
||||
String[] array = {"aa", "bb", "cc", "dd", "bb", "dd"};
|
||||
Assert.assertEquals("[aa, bb, cc, dd, bb, dd]", ArrayUtil.toString(array));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toArrayTest(){
|
||||
final ArrayList<String> list = CollUtil.newArrayList("A", "B", "C", "D");
|
||||
final String[] array = ArrayUtil.toArray(list, String.class);
|
||||
Assert.assertEquals("A", array[0]);
|
||||
Assert.assertEquals("B", array[1]);
|
||||
Assert.assertEquals("C", array[2]);
|
||||
Assert.assertEquals("D", array[3]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user