-
Notifications
You must be signed in to change notification settings - Fork 21.2k
Expand file tree
/
Copy pathJacobsthalNumberTest.java
More file actions
34 lines (28 loc) · 1.13 KB
/
Copy pathJacobsthalNumberTest.java
File metadata and controls
34 lines (28 loc) · 1.13 KB
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
package com.thealgorithms.maths;
// author: Vraj Prajapati @Rosander0
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
public class JacobsthalNumberTest {
@Test
public void testBaseCases() {
assertEquals(0, JacobsthalNumber.jacobsthal(0));
assertEquals(1, JacobsthalNumber.jacobsthal(1));
}
@Test
public void testKnownValues() {
assertEquals(1, JacobsthalNumber.jacobsthal(2));
assertEquals(3, JacobsthalNumber.jacobsthal(3));
assertEquals(5, JacobsthalNumber.jacobsthal(4));
assertEquals(11, JacobsthalNumber.jacobsthal(5));
assertEquals(21, JacobsthalNumber.jacobsthal(6));
assertEquals(43, JacobsthalNumber.jacobsthal(7));
assertEquals(85, JacobsthalNumber.jacobsthal(8));
assertEquals(171, JacobsthalNumber.jacobsthal(9));
assertEquals(341, JacobsthalNumber.jacobsthal(10));
}
@Test
public void testInvalidInput() {
assertThrows(IllegalArgumentException.class, () -> JacobsthalNumber.jacobsthal(-1));
}
}