From 6b60aef692c812cb9d79e55f7b3887fbbf39aa25 Mon Sep 17 00:00:00 2001 From: Looly Date: Fri, 5 Jul 2024 18:18:24 +0800 Subject: [PATCH] add test --- .../org/dromara/hutool/core/array/ArrayUtil.java | 2 +- .../dromara/hutool/core/array/ArrayUtilTest.java | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/hutool-core/src/main/java/org/dromara/hutool/core/array/ArrayUtil.java b/hutool-core/src/main/java/org/dromara/hutool/core/array/ArrayUtil.java index 804995e74..172409fce 100644 --- a/hutool-core/src/main/java/org/dromara/hutool/core/array/ArrayUtil.java +++ b/hutool-core/src/main/java/org/dromara/hutool/core/array/ArrayUtil.java @@ -1599,7 +1599,7 @@ public class ArrayUtil extends PrimitiveArrayUtil { * @return 变更后的原数组 * @since 3.0.9 */ - public static T[] reverse(final T[] array, final int startIndexInclusive, final int endIndexExclusive) { + public static T[] reverse(final T[] array, final int startIndexInclusive, final int endIndexExclusive) { if (isEmpty(array)) { return array; } diff --git a/hutool-core/src/test/java/org/dromara/hutool/core/array/ArrayUtilTest.java b/hutool-core/src/test/java/org/dromara/hutool/core/array/ArrayUtilTest.java index 5c2a4ffd3..98acfc9df 100644 --- a/hutool-core/src/test/java/org/dromara/hutool/core/array/ArrayUtilTest.java +++ b/hutool-core/src/test/java/org/dromara/hutool/core/array/ArrayUtilTest.java @@ -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)); + } }