File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
src/test/java/com/thealgorithms/recursion Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .thealgorithms .recursion ;
2+
3+ import static org .junit .jupiter .api .Assertions .assertEquals ;
4+ import static org .junit .jupiter .api .Assertions .assertThrows ;
5+
6+ import org .junit .jupiter .api .Test ;
7+
8+ public class FactorialTest {
9+
10+ @ Test
11+ public void testFactorialOfZero () {
12+ assertEquals (1 , Factorial .factorial (0 ));
13+ }
14+
15+ @ Test
16+ public void testFactorialOfOne () {
17+ assertEquals (1 , Factorial .factorial (1 ));
18+ }
19+
20+ @ Test
21+ public void testFactorialOfPositiveNumbers () {
22+ assertEquals (120 , Factorial .factorial (5 ));
23+ assertEquals (720 , Factorial .factorial (6 ));
24+ assertEquals (5040 , Factorial .factorial (7 ));
25+ }
26+
27+ @ Test
28+ public void testFactorialOfTen () {
29+ assertEquals (3628800 , Factorial .factorial (10 ));
30+ }
31+
32+ @ Test
33+ public void testNegativeNumberThrowsException () {
34+ assertThrows (IllegalArgumentException .class , () -> Factorial .factorial (-1 ));
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments