- Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathFibonacciNumberGoldenRationTest.java
29 lines (23 loc) · 1020 Bytes
/
FibonacciNumberGoldenRationTest.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
packagecom.thealgorithms.maths;
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
importstaticorg.junit.jupiter.api.Assertions.assertThrows;
importjava.math.BigInteger;
importorg.junit.jupiter.api.Test;
publicclassFibonacciNumberGoldenRationTest {
@Test
publicvoidreturnsCorrectValues() {
for (intn = 0; n <= FibonacciNumberGoldenRation.MAX_ARG; ++n) {
finalvaractual = FibonacciNumberGoldenRation.compute(n);
finalvarexpected = FibonacciLoop.compute(n);
assertEquals(expected, BigInteger.valueOf(actual));
}
}
@Test
publicvoidthrowsIllegalArgumentExceptionForNegativeInput() {
assertThrows(IllegalArgumentException.class, () -> { FibonacciNumberGoldenRation.compute(-1); });
}
@Test
publicvoidthrowsIllegalArgumentExceptionForLargeInput() {
assertThrows(IllegalArgumentException.class, () -> { FibonacciNumberGoldenRation.compute(FibonacciNumberGoldenRation.MAX_ARG + 1); });
}
}