mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
add test
This commit is contained in:
parent
b2e5edb990
commit
6b60aef692
@ -1599,7 +1599,7 @@ public class ArrayUtil extends PrimitiveArrayUtil {
|
||||
* @return 变更后的原数组
|
||||
* @since 3.0.9
|
||||
*/
|
||||
public static <T> T[] reverse(final T[] array, final int startIndexInclusive, final int endIndexExclusive) {
|
||||
public static <T> T[] reverse(final T[] array, final int startIndexInclusive, final int endIndexExclusive) {
|
||||
if (isEmpty(array)) {
|
||||
return array;
|
||||
}
|
||||
|
@ -21,8 +21,7 @@ import org.junit.jupiter.api.Test;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* {@link ArrayUtil} 数组工具单元测试
|
||||
@ -555,7 +554,7 @@ public class ArrayUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reverseTest2s() {
|
||||
public void reverseTest2() {
|
||||
final Object[] a = {"1", '2', "3", 4};
|
||||
final Object[] reverse = ArrayUtil.reverse(a);
|
||||
assertArrayEquals(new Object[]{4, "3", '2', "1"}, reverse);
|
||||
@ -1071,4 +1070,12 @@ public class ArrayUtilTest {
|
||||
assertEquals(5, resizedArray.length);
|
||||
assertArrayEquals(new Integer[]{1, 2, 3, null, null}, resizedArray);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testShuffleNotSameAsOriginal() {
|
||||
final Integer[] initialArray = new Integer[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
final Integer[] shuffledArray = ArrayUtil.shuffle(initialArray.clone());
|
||||
|
||||
assertNotEquals(Arrays.toString(initialArray), Arrays.toString(shuffledArray));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user