-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStoreTest.kt
More file actions
86 lines (66 loc) · 1.65 KB
/
StoreTest.kt
File metadata and controls
86 lines (66 loc) · 1.65 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
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package storage
import model.Cell
import model.Pizza
import org.hamcrest.core.Is.`is`
import org.junit.Assert.assertThat
import org.junit.Test
/**
3 4 1 5
TMMM
MMMM
TTTM
*/
class StoreShould {
private fun pizza(): Pizza {
val store = Store()
val pizza = store.read("src/test.in")
return pizza
}
@Test
fun `read a pizza row information`() {
val pizza = pizza()
assertThat(pizza.R, `is`(3))
}
@Test
fun `read a pizza column information`() {
val pizza = pizza()
assertThat(pizza.C, `is`(4))
}
@Test
fun `read a pizza min ingredients per slice information`() {
val pizza = pizza()
assertThat(pizza.L, `is`(1))
}
@Test
fun `read a pizza max ingredients per slice information`() {
val pizza = pizza()
assertThat(pizza.H, `is`(5))
}
@Test
fun `read a pizza table information`() {
val pizza = pizza().table
val expectedPizza = Array(3) { index ->
getExpectedPizzaRow(index)
}
assertThat(pizza.size, `is`(expectedPizza.size))
assertThat(pizza, `is`(expectedPizza))
}
/**
* TMMM
* MMMM
* TTTM
*/
private fun getExpectedPizzaRow(index: Int): Array<Cell> {
val firstRow = arrayOf(T(), M(), M(), M())
val secondRow = arrayOf(M(), M(), M(), M())
val thirdRow = arrayOf(T(), T(), T(), M())
return when (index) {
0 -> firstRow
1 -> secondRow
2 -> thirdRow
else -> firstRow
}
}
private fun M() = Cell("M", false)
private fun T() = Cell("T", false)
}