forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFibonacciNumberGoldenRationTest.java
More file actions
29 lines (23 loc) · 1020 Bytes
/
FibonacciNumberGoldenRationTest.java
File metadata and controls
29 lines (23 loc) · 1020 Bytes
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
package com.thealgorithms.maths;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.math.BigInteger;
import org.junit.jupiter.api.Test;
public class FibonacciNumberGoldenRationTest {
@Test
public void returnsCorrectValues() {
for (int n = 0; n <= FibonacciNumberGoldenRation.MAX_ARG; ++n) {
final var actual = FibonacciNumberGoldenRation.compute(n);
final var expected = FibonacciLoop.compute(n);
assertEquals(expected, BigInteger.valueOf(actual));
}
}
@Test
public void throwsIllegalArgumentExceptionForNegativeInput() {
assertThrows(IllegalArgumentException.class, () -> { FibonacciNumberGoldenRation.compute(-1); });
}
@Test
public void throwsIllegalArgumentExceptionForLargeInput() {
assertThrows(IllegalArgumentException.class, () -> { FibonacciNumberGoldenRation.compute(FibonacciNumberGoldenRation.MAX_ARG + 1); });
}
}