|
11 | 11 | public class FindKthNumberTest {
|
12 | 12 | @Test
|
13 | 13 | public void testFindKthMaxTypicalCases() {
|
14 |
| - int[] array1 = { 3, 2, 1, 4, 5 }; |
| 14 | + int[] array1 = {3, 2, 1, 4, 5}; |
15 | 15 | assertEquals(3, FindKthNumber.findKthMax(array1, 3));
|
16 | 16 | assertEquals(4, FindKthNumber.findKthMax(array1, 2));
|
17 | 17 | assertEquals(5, FindKthNumber.findKthMax(array1, 1));
|
18 | 18 |
|
19 |
| - int[] array2 = { 7, 5, 8, 2, 1, 6 }; |
| 19 | + int[] array2 = {7, 5, 8, 2, 1, 6}; |
20 | 20 | assertEquals(5, FindKthNumber.findKthMax(array2, 4));
|
21 | 21 | assertEquals(6, FindKthNumber.findKthMax(array2, 3));
|
22 | 22 | assertEquals(8, FindKthNumber.findKthMax(array2, 1));
|
23 | 23 | }
|
24 | 24 |
|
25 | 25 | @Test
|
26 | 26 | public void testFindKthMaxEdgeCases() {
|
27 |
| - int[] array1 = { 1 }; |
| 27 | + int[] array1 = {1}; |
28 | 28 | assertEquals(1, FindKthNumber.findKthMax(array1, 1));
|
29 | 29 |
|
30 |
| - int[] array2 = { 5, 3 }; |
| 30 | + int[] array2 = {5, 3}; |
31 | 31 | assertEquals(5, FindKthNumber.findKthMax(array2, 1));
|
32 | 32 | assertEquals(3, FindKthNumber.findKthMax(array2, 2));
|
33 | 33 | }
|
34 | 34 |
|
35 | 35 | @Test
|
36 | 36 | public void testFindKthMaxInvalidK() {
|
37 |
| - int[] array = { 1, 2, 3, 4, 5 }; |
38 |
| - assertThrows(IllegalArgumentException.class, () -> { |
39 |
| - FindKthNumber.findKthMax(array, 0); |
40 |
| - }); |
41 |
| - assertThrows(IllegalArgumentException.class, () -> { |
42 |
| - FindKthNumber.findKthMax(array, 6); |
43 |
| - }); |
| 37 | + int[] array = {1, 2, 3, 4, 5}; |
| 38 | + assertThrows(IllegalArgumentException.class, () -> FindKthNumber.findKthMax(array, 0)); |
| 39 | + assertThrows(IllegalArgumentException.class, () -> FindKthNumber.findKthMax(array, 6)); |
44 | 40 | }
|
45 | 41 |
|
46 | 42 | @Test
|
|
0 commit comments