mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-29 19:56:44 +08:00
add test
This commit is contained in:
parent
8f62647519
commit
c054d025dd
@ -1832,7 +1832,7 @@ public class ArrayUtil extends PrimitiveArrayUtil {
|
||||
* 按照指定规则,将一种类型的数组转换为另一种类型
|
||||
*
|
||||
* @param array 被转换的数组
|
||||
* @param targetComponentType 目标的元素类型
|
||||
* @param targetComponentType 目标的元素类型,只能为包装类型
|
||||
* @param func 转换规则函数
|
||||
* @param <R> 目标数组类型
|
||||
* @return 转换后的数组
|
||||
|
@ -1011,4 +1011,18 @@ public class ArrayUtilTest {
|
||||
final String[] 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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user