forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFactorialTest.java
More file actions
29 lines (23 loc) · 785 Bytes
/
FactorialTest.java
File metadata and controls
29 lines (23 loc) · 785 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
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
public class FactorialTest {
@Test
public void testFactorialOfOne() {
assertEquals(1, Factorial.factorial(1));
}
@Test
public void testFactorialOfPositiveNumbers() {
assertEquals(120, Factorial.factorial(5));
assertEquals(720, Factorial.factorial(6));
assertEquals(5040, Factorial.factorial(7));
}
@Test
public void testFactorialOfTen() {
assertEquals(3628800, Factorial.factorial(10));
}
@Test
public void testNegativeNumberThrowsException() {
assertThrows(IllegalArgumentException.class, () -> Factorial.factorial(-1));
}
}