- Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathSumOfDigitsTest.java
31 lines (26 loc) · 1.11 KB
/
SumOfDigitsTest.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
29
30
31
packagecom.thealgorithms.maths;
importjava.util.stream.Stream;
importorg.junit.jupiter.api.Assertions;
importorg.junit.jupiter.params.ParameterizedTest;
importorg.junit.jupiter.params.provider.Arguments;
importorg.junit.jupiter.params.provider.MethodSource;
classSumOfDigitsTest {
@ParameterizedTest
@MethodSource("testCases")
voidsumOfDigitsTest(finalintexpected, finalintinput) {
Assertions.assertEquals(expected, SumOfDigits.sumOfDigits(input));
}
@ParameterizedTest
@MethodSource("testCases")
voidsumOfDigitsRecursionTest(finalintexpected, finalintinput) {
Assertions.assertEquals(expected, SumOfDigits.sumOfDigitsRecursion(input));
}
@ParameterizedTest
@MethodSource("testCases")
voidsumOfDigitsFastTest(finalintexpected, finalintinput) {
Assertions.assertEquals(expected, SumOfDigits.sumOfDigitsFast(input));
}
privatestaticStream<Arguments> testCases() {
returnStream.of(Arguments.of(0, 0), Arguments.of(1, 1), Arguments.of(15, 12345), Arguments.of(6, -123), Arguments.of(1, -100000), Arguments.of(8, 512));
}
}