Skip to content

Commit 8583ca3

Browse files
lukasb1bvil02
andauthored
Changing MaxFindTest (TheAlgorithms#4406)
* Changing MaxFindTest * Update FindMaxTest.java * Update FindMaxTest.java * Update FindMaxTest.java * Apply suggestions from code review - add test case with unsorted array, - test FindMax --------- Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
1 parent bf777ff commit 8583ca3

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +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 FindMaxTest {
913

10-
@Test
11-
public void testFindMax0() {
12-
assertEquals(10, FindMax.findMax(new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}));
14+
@ParameterizedTest
15+
@MethodSource("inputStream")
16+
void numberTests(int expected, int[] input) {
17+
Assertions.assertEquals(expected, FindMax.findMax(input));
1318
}
1419

15-
@Test
16-
public void testFindMax1() {
17-
assertEquals(7, FindMax.findMax(new int[] {6, 3, 5, 1, 7, 4, 1}));
18-
}
19-
20-
@Test
21-
public void testFindMax2() {
22-
assertEquals(10, FindMax.findMax(new int[] {10, 0}));
20+
private static Stream<Arguments> inputStream() {
21+
return Stream.of(Arguments.of(10, 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[] {-1, 0}), Arguments.of(-1, new int[] {-10, -9, -8, -7, -6, -5, -4, -3, -2, -1}), Arguments.of(9, new int[] {3, -2, 3, 9, -4, -4, 8}));
2322
}
2423

2524
@Test

0 commit comments

Comments
 (0)