-
-
Notifications
You must be signed in to change notification settings - Fork 199
/
Copy pathPascalsTriangleTest.kt
43 lines (35 loc) · 1.05 KB
/
PascalsTriangleTest.kt
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
import org.junit.Test
import kotlin.test.assertEquals
class PascalsTriangleTest {
@Test
fun triangleWithFourRows() {
val expectedOutput = listOf(
listOf(1),
listOf(1, 1),
listOf(1, 2, 1),
listOf(1, 3, 3, 1)
)
assertEquals(expectedOutput, PascalsTriangle.computeTriangle(4))
}
@Test
fun triangleWithSixRows() {
val expectedOutput = listOf(
listOf(1),
listOf(1, 1),
listOf(1, 2, 1),
listOf(1, 3, 3, 1),
listOf(1, 4, 6, 4, 1),
listOf(1, 5, 10, 10, 5, 1)
)
assertEquals(expectedOutput, PascalsTriangle.computeTriangle(6))
}
@Test
fun expectEmptyTriangle() {
val expectedOutput = emptyList<List<Int>>()
assertEquals(expectedOutput, PascalsTriangle.computeTriangle(0))
}
@Test(expected = IllegalArgumentException::class)
fun validatesNotNegativeRows() {
PascalsTriangle.computeTriangle(-1)
}
}