MCPcopy Create free account
hub / github.com/TheAlgorithms/Java / BFPRTTest

Class BFPRTTest

src/test/java/com/thealgorithms/others/BFPRTTest.java:11–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9import org.junit.jupiter.params.provider.MethodSource;
10
11class BFPRTTest {
12
13 @ParameterizedTest
14 @MethodSource("minKNumsTestData")
15 void testGetMinKNumsByBFPRT(int[] arr, int k, int[] expected) {
16 int[] result = BFPRT.getMinKNumsByBFPRT(arr, k);
17 assertArrayEquals(expected, result);
18 }
19
20 private static Stream<Arguments> minKNumsTestData() {
21 return Stream.of(Arguments.of(new int[] {11, 9, 1, 3, 9, 2, 2, 5, 6, 5, 3, 5, 9, 7, 2, 5, 5, 1, 9}, 5, new int[] {1, 1, 2, 2, 2}), Arguments.of(new int[] {3, 2, 1}, 2, new int[] {1, 2}), Arguments.of(new int[] {7, 5, 9, 1, 3, 8, 2, 4, 6}, 3, new int[] {1, 2, 3}));
22 }
23
24 @ParameterizedTest
25 @MethodSource("minKthTestData")
26 void testGetMinKthByBFPRT(int[] arr, int k, int expected) {
27 int result = BFPRT.getMinKthByBFPRT(arr, k);
28 assertEquals(expected, result);
29 }
30
31 private static Stream<Arguments> minKthTestData() {
32 return Stream.of(Arguments.of(new int[] {3, 2, 1}, 2, 2), Arguments.of(new int[] {7, 5, 9, 1, 3, 8, 2, 4, 6}, 3, 3), Arguments.of(new int[] {5, 8, 6, 3, 2, 7, 1, 4}, 4, 4));
33 }
34}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected