|
6 | 6 |
|
7 | 7 | importstaticorg.junit.Assert.assertEquals;
|
8 | 8 |
|
9 |
| -/** |
10 |
| - * Created by fishercoder on 5/9/17. |
11 |
| - */ |
12 | 9 | publicclass_215Test {
|
| 10 | +privatestatic_215.Solution1solution1; |
13 | 11 | privatestatic_215.Solution2solution2;
|
| 12 | +privatestatic_215.Solution3solution3; |
14 | 13 | privatestaticintk;
|
15 | 14 | privatestaticint[]nums;
|
16 |
| -privatestaticintactual; |
17 | 15 | privatestaticintexpected;
|
18 | 16 |
|
19 | 17 | @BeforeClass
|
20 | 18 | publicstaticvoidsetup() {
|
| 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 | publicvoidtest1() {
|
26 | 26 | k =2;
|
27 | 27 | nums =newint[]{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 | +publicvoidtest2() { |
| 36 | +k =1; |
| 37 | +nums =newint[]{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 | +publicvoidtest3() { |
| 46 | +k =2; |
| 47 | +nums =newint[]{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 | }
|