Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2f82a7f

Browse files
add tests for 215
1 parent7b28e84 commit2f82a7f

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
importstaticorg.junit.Assert.assertEquals;
88

9-
/**
10-
* Created by fishercoder on 5/9/17.
11-
*/
129
publicclass_215Test {
10+
privatestatic_215.Solution1solution1;
1311
privatestatic_215.Solution2solution2;
12+
privatestatic_215.Solution3solution3;
1413
privatestaticintk;
1514
privatestaticint[]nums;
16-
privatestaticintactual;
1715
privatestaticintexpected;
1816

1917
@BeforeClass
2018
publicstaticvoidsetup() {
19+
solution1 =new_215.Solution1();
2120
solution2 =new_215.Solution2();
21+
solution3 =new_215.Solution3();
2222
}
2323

2424
@Test
2525
publicvoidtest1() {
2626
k =2;
2727
nums =newint[]{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+
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));
3152
}
3253
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp