mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add test
This commit is contained in:
@@ -1832,7 +1832,7 @@ public class ArrayUtil extends PrimitiveArrayUtil {
|
|||||||
* 按照指定规则,将一种类型的数组转换为另一种类型
|
* 按照指定规则,将一种类型的数组转换为另一种类型
|
||||||
*
|
*
|
||||||
* @param array 被转换的数组
|
* @param array 被转换的数组
|
||||||
* @param targetComponentType 目标的元素类型
|
* @param targetComponentType 目标的元素类型,只能为包装类型
|
||||||
* @param func 转换规则函数
|
* @param func 转换规则函数
|
||||||
* @param <R> 目标数组类型
|
* @param <R> 目标数组类型
|
||||||
* @return 转换后的数组
|
* @return 转换后的数组
|
||||||
|
@@ -1011,4 +1011,18 @@ public class ArrayUtilTest {
|
|||||||
final String[] a = {" ", " ", ""};
|
final String[] a = {" ", " ", ""};
|
||||||
Assertions.assertTrue(ArrayUtil.isAllBlank(a));
|
Assertions.assertTrue(ArrayUtil.isAllBlank(a));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void firstMatchShouldReturnFirstMatch() {
|
||||||
|
final Integer[] array = {5, 10, 15, 20, 25};
|
||||||
|
final Integer result = ArrayUtil.firstMatch(value -> value > 15, array);
|
||||||
|
assertEquals(20, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testMatchIndexWithMatchingFirstElement() {
|
||||||
|
final Integer[] array = {1, 2, 3, 4, 5};
|
||||||
|
final int index = ArrayUtil.matchIndex(value -> value == 3, array);
|
||||||
|
assertEquals(2, index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user