- Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathFibonacciLoopTest.java
36 lines (29 loc) · 984 Bytes
/
FibonacciLoopTest.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
34
35
36
packagecom.thealgorithms.maths;
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
importstaticorg.junit.jupiter.api.Assertions.assertThrows;
importjava.math.BigInteger;
importorg.junit.jupiter.api.Test;
publicclassFibonacciLoopTest {
@Test
publicvoidcheckValueAtZero() {
assertEquals(BigInteger.ZERO, FibonacciLoop.compute(0));
}
@Test
publicvoidcheckValueAtOne() {
assertEquals(BigInteger.ONE, FibonacciLoop.compute(1));
}
@Test
publicvoidcheckValueAtTwo() {
assertEquals(BigInteger.ONE, FibonacciLoop.compute(2));
}
@Test
publicvoidcheckRecurrenceRelation() {
for (inti = 0; i < 100; ++i) {
assertEquals(FibonacciLoop.compute(i + 2), FibonacciLoop.compute(i + 1).add(FibonacciLoop.compute(i)));
}
}
@Test
publicvoidcheckNegativeInput() {
assertThrows(IllegalArgumentException.class, () -> { FibonacciLoop.compute(-1); });
}
}