|
6 | 6 |
|
7 | 7 | import static org.junit.Assert.assertEquals;
|
8 | 8 |
|
9 |
| -/** |
10 |
| - * Created by fishercoder on 5/9/17. |
11 |
| - */ |
12 | 9 | public class _215Test {
|
| 10 | + private static _215.Solution1 solution1; |
13 | 11 | private static _215.Solution2 solution2;
|
| 12 | + private static _215.Solution3 solution3; |
14 | 13 | private static int k;
|
15 | 14 | private static int[] nums;
|
16 |
| - private static int actual; |
17 | 15 | private static int expected;
|
18 | 16 |
|
19 | 17 | @BeforeClass
|
20 | 18 | public static void setup() {
|
| 19 | + solution1 = new _215.Solution1(); |
21 | 20 | solution2 = new _215.Solution2();
|
| 21 | + solution3 = new _215.Solution3(); |
22 | 22 | }
|
23 | 23 |
|
24 | 24 | @Test
|
25 | 25 | public void test1() {
|
26 | 26 | k = 2;
|
27 | 27 | nums = new int[]{3, 2, 1, 5, 6, 4};
|
28 |
| - actual = solution2.findKthLargest(nums, k); |
29 | 28 | expected = 5;
|
30 |
| - assertEquals(expected, actual); |
| 29 | + assertEquals(expected, solution1.findKthLargest(nums, k)); |
| 30 | + assertEquals(expected, solution2.findKthLargest(nums, k)); |
| 31 | + assertEquals(expected, solution3.findKthLargest(nums, k)); |
| 32 | + } |
| 33 | + |
| 34 | + @Test |
| 35 | + public void test2() { |
| 36 | + k = 1; |
| 37 | + nums = new int[]{1}; |
| 38 | + expected = 1; |
| 39 | + assertEquals(expected, solution1.findKthLargest(nums, k)); |
| 40 | + assertEquals(expected, solution2.findKthLargest(nums, k)); |
| 41 | + assertEquals(expected, solution3.findKthLargest(nums, k)); |
| 42 | + } |
| 43 | + |
| 44 | + @Test |
| 45 | + public void test3() { |
| 46 | + k = 2; |
| 47 | + nums = new int[]{2, 1}; |
| 48 | + expected = 1; |
| 49 | + assertEquals(expected, solution1.findKthLargest(nums, k)); |
| 50 | + assertEquals(expected, solution2.findKthLargest(nums, k)); |
| 51 | + assertEquals(expected, solution3.findKthLargest(nums, k)); |
31 | 52 | }
|
32 | 53 | }
|
0 commit comments