|
7 | 7 | import static junit.framework.Assert.assertEquals;
|
8 | 8 |
|
9 | 9 | public class _121Test {
|
10 |
| - private static _121.Solution1 solution1; |
11 |
| - private static int[] prices; |
12 |
| - |
13 |
| - @BeforeClass |
14 |
| - public static void setup() { |
15 |
| - solution1 = new _121.Solution1(); |
16 |
| - } |
17 |
| - |
18 |
| - @Test |
19 |
| - public void test1() { |
20 |
| - prices = new int[] {7, 1, 5, 3, 6, 4}; |
21 |
| - assertEquals(5, solution1.maxProfit(prices)); |
22 |
| - } |
23 |
| - |
24 |
| - @Test |
25 |
| - public void test2() { |
26 |
| - prices = new int[] {7, 6, 4, 3, 1}; |
27 |
| - assertEquals(0, solution1.maxProfit(prices)); |
28 |
| - } |
29 |
| - |
30 |
| - @Test |
31 |
| - public void test3() { |
32 |
| - prices = new int[] {2, 4, 1}; |
33 |
| - assertEquals(2, solution1.maxProfit(prices)); |
34 |
| - } |
35 |
| - |
36 |
| - @Test |
37 |
| - public void test4() { |
38 |
| - prices = new int[] {1, 2}; |
39 |
| - assertEquals(1, solution1.maxProfit(prices)); |
40 |
| - } |
| 10 | + private static _121.Solution1 solution1; |
| 11 | + private static _121.Solution2 solution2; |
| 12 | + private static int[] prices; |
| 13 | + |
| 14 | + @BeforeClass |
| 15 | + public static void setup() { |
| 16 | + solution1 = new _121.Solution1(); |
| 17 | + solution2 = new _121.Solution2(); |
| 18 | + } |
| 19 | + |
| 20 | + @Test |
| 21 | + public void test1() { |
| 22 | + prices = new int[]{7, 1, 5, 3, 6, 4}; |
| 23 | + assertEquals(5, solution1.maxProfit(prices)); |
| 24 | + assertEquals(5, solution2.maxProfit(prices)); |
| 25 | + } |
| 26 | + |
| 27 | + @Test |
| 28 | + public void test2() { |
| 29 | + prices = new int[]{7, 6, 4, 3, 1}; |
| 30 | + assertEquals(0, solution1.maxProfit(prices)); |
| 31 | + assertEquals(0, solution2.maxProfit(prices)); |
| 32 | + } |
| 33 | + |
| 34 | + @Test |
| 35 | + public void test3() { |
| 36 | + prices = new int[]{2, 4, 1}; |
| 37 | + assertEquals(2, solution1.maxProfit(prices)); |
| 38 | + assertEquals(2, solution2.maxProfit(prices)); |
| 39 | + } |
| 40 | + |
| 41 | + @Test |
| 42 | + public void test4() { |
| 43 | + prices = new int[]{1, 2}; |
| 44 | + assertEquals(1, solution1.maxProfit(prices)); |
| 45 | + assertEquals(1, solution2.maxProfit(prices)); |
| 46 | + } |
41 | 47 | }
|
0 commit comments