Skip to content

Commit 2f82a7f

Browse files
add tests for 215
1 parent 7b28e84 commit 2f82a7f

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

src/test/java/com/fishercoder/_215Test.java

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,48 @@
66

77
import static org.junit.Assert.assertEquals;
88

9-
/**
10-
* Created by fishercoder on 5/9/17.
11-
*/
129
public class _215Test {
10+
private static _215.Solution1 solution1;
1311
private static _215.Solution2 solution2;
12+
private static _215.Solution3 solution3;
1413
private static int k;
1514
private static int[] nums;
16-
private static int actual;
1715
private static int expected;
1816

1917
@BeforeClass
2018
public static void setup() {
19+
solution1 = new _215.Solution1();
2120
solution2 = new _215.Solution2();
21+
solution3 = new _215.Solution3();
2222
}
2323

2424
@Test
2525
public void test1() {
2626
k = 2;
2727
nums = new int[]{3, 2, 1, 5, 6, 4};
28-
actual = solution2.findKthLargest(nums, k);
2928
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));
3152
}
3253
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy