- Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathFindMinTest.java
29 lines (23 loc) · 1.13 KB
/
FindMinTest.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
packagecom.thealgorithms.maths;
importstaticorg.junit.jupiter.api.Assertions.assertThrows;
importjava.util.stream.Stream;
importorg.junit.jupiter.api.Assertions;
importorg.junit.jupiter.api.Test;
importorg.junit.jupiter.params.ParameterizedTest;
importorg.junit.jupiter.params.provider.Arguments;
importorg.junit.jupiter.params.provider.MethodSource;
publicclassFindMinTest {
@ParameterizedTest
@MethodSource("inputStream")
voidnumberTests(intexpected, int[] input) {
Assertions.assertEquals(expected, FindMin.findMin(input));
}
privatestaticStream<Arguments> inputStream() {
returnStream.of(Arguments.of(1, newint[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}), Arguments.of(5, newint[] {5, 5, 5, 5, 5}), Arguments.of(0, newint[] {0, 192, 384, 576}), Arguments.of(-1, newint[] {-1, 2, 5, 10}), Arguments.of(-10, newint[] {-10, -9, -8, -7, -6, -5, -4, -3, -2, -1}),
Arguments.of(-4, newint[] {4, -3, 8, 9, -4, -4, 10}));
}
@Test
publicvoidtestFindMinThrowsExceptionForEmptyInput() {
assertThrows(IllegalArgumentException.class, () -> FindMin.findMin(newint[] {}));
}
}