forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenericRootTest.java
26 lines (21 loc) · 970 Bytes
/
GenericRootTest.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
package com.thealgorithms.maths;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.stream.Stream;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
public class GenericRootTest {
@ParameterizedTest
@MethodSource("tcStream")
public void testGenericRoot(final int input, final int expected) {
assertEquals(expected, GenericRoot.genericRoot(input));
}
@ParameterizedTest
@MethodSource("tcStream")
public void testGenericRootWithNegativeInputs(final int input, final int expected) {
assertEquals(expected, GenericRoot.genericRoot(-input));
}
private static Stream<Arguments> tcStream() {
return Stream.of(Arguments.of(0, 0), Arguments.of(1, 1), Arguments.of(12345, 6), Arguments.of(123, 6), Arguments.of(15937, 7), Arguments.of(222222, 3), Arguments.of(99999, 9));
}
}