|
|
@@ -0,0 +1,42 @@
|
|
|
+package leetcode.p121;
|
|
|
+
|
|
|
+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.assertEquals;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @ProjectName: LeetCode
|
|
|
+ * @FileName: SolutionTest
|
|
|
+ * @Author: 杨逸
|
|
|
+ * @Data:2026/3/23 22:49
|
|
|
+ * @Description:
|
|
|
+ */
|
|
|
+@RunWith(Parameterized.class)
|
|
|
+public class SolutionTest {
|
|
|
+ public static final Solution solution = new Solution();
|
|
|
+ private int[] prices;
|
|
|
+ private int expected;
|
|
|
+
|
|
|
+ public SolutionTest(int[] prices, int expected) {
|
|
|
+ this.prices = prices;
|
|
|
+ this.expected = expected;
|
|
|
+ }
|
|
|
+ @Parameterized.Parameters
|
|
|
+ public static Collection<Object[]> data(){
|
|
|
+ return Arrays.asList(new Object[][]{
|
|
|
+ {new int[]{7,1,5,3,6,4},5},
|
|
|
+ {new int[]{7,6,4,3,1},0},
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void maxProfit() {
|
|
|
+ assertEquals(expected,solution.maxProfit(prices));
|
|
|
+ }
|
|
|
+}
|