Skip to content

Commit 01157f2

Browse files
authored
Add negative FindMinTest (TheAlgorithms#4388)
1 parent 9d8a0f3 commit 01157f2

1 file changed

Lines changed: 11 additions & 17 deletions

File tree

src/test/java/com/thealgorithms/maths/FindMinTest.java

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
11
package com.thealgorithms.maths;
22

3-
import static org.junit.jupiter.api.Assertions.assertEquals;
43
import static org.junit.jupiter.api.Assertions.assertThrows;
54

5+
import java.util.stream.Stream;
6+
import org.junit.jupiter.api.Assertions;
67
import org.junit.jupiter.api.Test;
8+
import org.junit.jupiter.params.ParameterizedTest;
9+
import org.junit.jupiter.params.provider.Arguments;
10+
import org.junit.jupiter.params.provider.MethodSource;
711

812
public class FindMinTest {
913

10-
@Test
11-
public void testFindMinValue() {
12-
assertEquals(1, FindMin.findMin(new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}));
13-
}
14-
15-
@Test
16-
public void test1() {
17-
assertEquals(1, FindMin.findMin(new int[] {1, 3, 5, 7, 9}));
14+
@ParameterizedTest
15+
@MethodSource("provideStringsForIsBlank")
16+
void numberTests(int expected, int[] input) {
17+
Assertions.assertEquals(expected, FindMin.findMin(input));
1818
}
1919

20-
@Test
21-
public void test2() {
22-
assertEquals(0, FindMin.findMin(new int[] {0, 192, 384, 576}));
23-
}
24-
25-
@Test
26-
public void test3() {
27-
assertEquals(0, FindMin.findMin(new int[] {10, 10, 0, 10}));
20+
private static Stream<Arguments> provideStringsForIsBlank() {
21+
return Stream.of(Arguments.of(1, new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}), Arguments.of(5, new int[] {5, 5, 5, 5, 5}), Arguments.of(0, new int[] {0, 192, 384, 576}), Arguments.of(-1, new int[] {-1, 2, 5, 10}), Arguments.of(-10, new int[] {-10, -9, -8, -7, -6, -5, -4, -3, -2, -1}));
2822
}
2923

3024
@Test

0 commit comments

Comments
 (0)