- Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathBFPRTTest.java
34 lines (27 loc) · 1.38 KB
/
BFPRTTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
packagecom.thealgorithms.others;
importstaticorg.junit.jupiter.api.Assertions.assertArrayEquals;
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
importjava.util.stream.Stream;
importorg.junit.jupiter.params.ParameterizedTest;
importorg.junit.jupiter.params.provider.Arguments;
importorg.junit.jupiter.params.provider.MethodSource;
classBFPRTTest {
@ParameterizedTest
@MethodSource("minKNumsTestData")
voidtestGetMinKNumsByBFPRT(int[] arr, intk, int[] expected) {
int[] result = BFPRT.getMinKNumsByBFPRT(arr, k);
assertArrayEquals(expected, result);
}
privatestaticStream<Arguments> minKNumsTestData() {
returnStream.of(Arguments.of(newint[] {11, 9, 1, 3, 9, 2, 2, 5, 6, 5, 3, 5, 9, 7, 2, 5, 5, 1, 9}, 5, newint[] {1, 1, 2, 2, 2}), Arguments.of(newint[] {3, 2, 1}, 2, newint[] {1, 2}), Arguments.of(newint[] {7, 5, 9, 1, 3, 8, 2, 4, 6}, 3, newint[] {1, 2, 3}));
}
@ParameterizedTest
@MethodSource("minKthTestData")
voidtestGetMinKthByBFPRT(int[] arr, intk, intexpected) {
intresult = BFPRT.getMinKthByBFPRT(arr, k);
assertEquals(expected, result);
}
privatestaticStream<Arguments> minKthTestData() {
returnStream.of(Arguments.of(newint[] {3, 2, 1}, 2, 2), Arguments.of(newint[] {7, 5, 9, 1, 3, 8, 2, 4, 6}, 3, 3), Arguments.of(newint[] {5, 8, 6, 3, 2, 7, 1, 4}, 4, 4));
}
}