- Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathEulersFunctionTest.java
33 lines (26 loc) · 1.37 KB
/
EulersFunctionTest.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
32
33
packagecom.thealgorithms.maths;
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
importstaticorg.junit.jupiter.api.Assertions.assertThrows;
importjava.util.stream.Stream;
importorg.junit.jupiter.params.ParameterizedTest;
importorg.junit.jupiter.params.provider.Arguments;
importorg.junit.jupiter.params.provider.MethodSource;
classEulersFunctionTest {
@ParameterizedTest
@MethodSource("provideNumbersForGetEuler")
voidtestGetEuler(intinput, intexpected) {
assertEquals(expected, EulersFunction.getEuler(input));
}
@ParameterizedTest
@MethodSource("provideInvalidNumbersForGetEuler")
voidtestGetEulerThrowsExceptionForNonPositiveInput(intinput) {
assertThrows(IllegalArgumentException.class, () -> EulersFunction.getEuler(input));
}
privatestaticStream<Arguments> provideNumbersForGetEuler() {
returnStream.of(Arguments.of(1, 1), Arguments.of(2, 1), Arguments.of(3, 2), Arguments.of(4, 2), Arguments.of(5, 4), Arguments.of(6, 2), Arguments.of(10, 4), Arguments.of(21, 12), Arguments.of(69, 44), Arguments.of(47, 46), Arguments.of(46, 22), Arguments.of(55, 40), Arguments.of(34, 16),
Arguments.of(20, 8), Arguments.of(1024, 512));
}
privatestaticStream<Arguments> provideInvalidNumbersForGetEuler() {
returnStream.of(Arguments.of(0), Arguments.of(-1), Arguments.of(-10));
}
}