diff --git a/src/test/java/com/thealgorithms/maths/FindMaxTest.java b/src/test/java/com/thealgorithms/maths/FindMaxTest.java index 17f8d454..a863a2c8 100644 --- a/src/test/java/com/thealgorithms/maths/FindMaxTest.java +++ b/src/test/java/com/thealgorithms/maths/FindMaxTest.java @@ -1,25 +1,24 @@ package com.thealgorithms.maths; -import static org.junit.jupiter.api.Assertions.assertEquals; 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 FindMaxTest { - @Test - public void testFindMax0() { - assertEquals(10, FindMax.findMax(new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10})); + @ParameterizedTest + @MethodSource("inputStream") + void numberTests(int expected, int[] input) { + Assertions.assertEquals(expected, FindMax.findMax(input)); } - @Test - public void testFindMax1() { - assertEquals(7, FindMax.findMax(new int[] {6, 3, 5, 1, 7, 4, 1})); - } - - @Test - public void testFindMax2() { - assertEquals(10, FindMax.findMax(new int[] {10, 0})); + private static Stream inputStream() { + 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})); } @Test