-
Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathFindMinRecursionTest.java
28 lines (22 loc) · 1.06 KB
/
FindMinRecursionTest.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
package com.thealgorithms.maths;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.stream.Stream;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
public class FindMinRecursionTest {
@ParameterizedTest
@MethodSource("inputStream")
void numberTests(int expected, int[] input) {
Assertions.assertEquals(expected, FindMinRecursion.min(input));
}
private static Stream<Arguments> inputStream() {
return Stream.of(Arguments.of(5, new int[] {5, 5, 5, 5, 5}), Arguments.of(-1, new int[] {-1, 0}), Arguments.of(-10, new int[] {-10, -9, -8, -7, -6, -5, -4, -3, -2, -1}), Arguments.of(-4, new int[] {3, -2, 3, 9, -4, -4, 8}), Arguments.of(3, new int[] {3}));
}
@Test
public void testFindMaxThrowsExceptionForEmptyInput() {
assertThrows(IllegalArgumentException.class, () -> FindMinRecursion.min(new int[] {}));
}
}