- Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathModeTest.java
21 lines (17 loc) · 946 Bytes
/
ModeTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
packagecom.thealgorithms.maths;
importstaticorg.junit.jupiter.api.Assertions.assertArrayEquals;
importjava.util.stream.Stream;
importorg.junit.jupiter.params.ParameterizedTest;
importorg.junit.jupiter.params.provider.Arguments;
importorg.junit.jupiter.params.provider.MethodSource;
publicclassModeTest {
@ParameterizedTest
@MethodSource("tcStream")
voidbasicTest(finalint[] expected, finalint[] numbers) {
assertArrayEquals(expected, Mode.mode(numbers));
}
privatestaticStream<Arguments> tcStream() {
returnStream.of(Arguments.of(null, newint[] {}), Arguments.of(newint[] {5}, newint[] {5}), Arguments.of(newint[] {1, 2, 3, 4, 5}, newint[] {1, 2, 3, 4, 5}), Arguments.of(newint[] {1, 2, 3, 4, 5}, newint[] {5, 4, 3, 2, 1}),
Arguments.of(newint[] {7}, newint[] {7, 9, 9, 4, 5, 6, 7, 7, 8}), Arguments.of(newint[] {7, 9}, newint[] {7, 9, 9, 4, 5, 6, 7, 7, 9}));
}
}