-
Notifications
You must be signed in to change notification settings - Fork 27
/
TailTest.java
60 lines (45 loc) · 1.33 KB
/
TailTest.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import static org.junit.Assert.*;
import java.math.BigInteger;
import org.junit.Test;
public class TailTest {
@Test
public void streamFactorial_should_work_with_1() {
assertEquals(BigInteger.valueOf(1), Tail.streamFactorial(1));
}
@Test
public void streamFactorial_should_work_with_2() {
assertEquals(BigInteger.valueOf(2), Tail.streamFactorial(2));
}
@Test
public void streamFactorial_should_work_with_3() {
assertEquals(BigInteger.valueOf(6), Tail.streamFactorial(3));
}
@Test
public void stackFactorial_should_work_with_1() {
assertEquals(BigInteger.valueOf(1), Tail.stackFactorial(1));
}
@Test
public void stackFactorial_should_work_with_2() {
assertEquals(BigInteger.valueOf(2), Tail.stackFactorial(2));
}
@Test
public void stackFactorial_should_work_with_3() {
assertEquals(BigInteger.valueOf(6), Tail.stackFactorial(3));
}
@Test
public void should_have_equal_factorials_of_555() {
assertEquals(Tail.streamFactorial(555), Tail.stackFactorial(555));
}
@Test
public void should_have_equal_factorials_of_1234() {
assertEquals(Tail.streamFactorial(1234), Tail.stackFactorial(1234));
}
@Test(expected=StackOverflowError.class)
public void should_throw_stack_overflow() {
Tail.stackFactorial(56789);
}
@Test
public void should_not_throw_stack_overflow() {
Tail.streamFactorial(56789);
}
}