|
@@ -0,0 +1,41 @@
|
|
|
|
|
+package leetcode.p238;
|
|
|
|
|
+
|
|
|
|
|
+import org.junit.Test;
|
|
|
|
|
+import org.junit.runner.RunWith;
|
|
|
|
|
+import org.junit.runners.Parameterized;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.Arrays;
|
|
|
|
|
+import java.util.Collection;
|
|
|
|
|
+
|
|
|
|
|
+import static org.junit.Assert.assertArrayEquals;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * @ProjectName: LeetCode
|
|
|
|
|
+ * @FileName: SolutionTest
|
|
|
|
|
+ * @Author: 杨逸
|
|
|
|
|
+ * @Data:2026/3/24 19:03
|
|
|
|
|
+ * @Description:
|
|
|
|
|
+ */
|
|
|
|
|
+@RunWith(Parameterized.class)
|
|
|
|
|
+public class SolutionTest {
|
|
|
|
|
+ public static final Solution solution = new Solution();
|
|
|
|
|
+ private final int[] nums;
|
|
|
|
|
+ private final int[] expected;
|
|
|
|
|
+
|
|
|
|
|
+ public SolutionTest(int[] nums, int[] expected) {
|
|
|
|
|
+ this.nums = nums;
|
|
|
|
|
+ this.expected = expected;
|
|
|
|
|
+ }
|
|
|
|
|
+ @Parameterized.Parameters
|
|
|
|
|
+ public static Collection<Object[]> data(){
|
|
|
|
|
+ return Arrays.asList(new Object[][]{
|
|
|
|
|
+ {new int[]{1,2,3,4},new int[]{24,12,8,6}},
|
|
|
|
|
+ {new int[]{-1,1,0,-3,3},new int[]{0,0,9,0,0}},
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void productExceptSelf() {
|
|
|
|
|
+ assertArrayEquals(expected,solution.productExceptSelf(nums));
|
|
|
|
|
+ }
|
|
|
|
|
+}
|