-
Notifications
You must be signed in to change notification settings - Fork 1
/
MayanCalculationTest.kt
84 lines (73 loc) · 3.05 KB
/
MayanCalculationTest.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
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
import MayanCalculation.MayanDigit
import MayanCalculation.MayanNumber
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import java.math.BigInteger
import java.util.*
internal class MayanCalculationTest {
private val mayanCalculation = MayanCalculation(
Scanner(
"4 4\n" +
".oo.o...oo..ooo.oooo....o...oo..ooo.oooo....o...oo..ooo.oooo....o...oo..ooo.oooo\n" +
"o..o................____________________________________________________________\n" +
".oo.....................................________________________________________\n" +
"............................................................____________________\n" +
"4\n" +
"o...\n" +
"....\n" +
"....\n" +
"....\n" +
"4\n" +
"o...\n" +
"....\n" +
"....\n" +
"....\n" +
"+"
)
).read()
private val digitZero = MayanDigit(listOf(".oo.", "o..o", ".oo.", "...."))
private val numberZero = MayanNumber(listOf(mayanCalculation.game.alphabet.get(digitZero)))
private val digitOne = MayanDigit(listOf("o...", "....", "....", "...."))
private val digitTwo = MayanDigit(listOf("oo..", "....", "....", "...."))
private val numberTwenty = MayanNumber(
listOf(
mayanCalculation.game.alphabet.get(digitTwo),
mayanCalculation.game.alphabet.get(digitZero)
)
)
private val numberTwentyOne = MayanNumber(
listOf(
mayanCalculation.game.alphabet.get(digitTwo),
mayanCalculation.game.alphabet.get(digitOne)
)
)
@Test
fun testAlphabet() {
assertEquals(20, mayanCalculation.game.alphabet.alphabet.size)
assertEquals(4, mayanCalculation.game.alphabet.height)
}
@Test
fun testConvertDigitToInt() {
assertEquals(BigInteger.ONE, mayanCalculation.game.alphabet.get(digitOne).value)
assertEquals(BigInteger.valueOf(2L), mayanCalculation.game.alphabet.get(digitTwo).value)
}
@Test
fun testConvertIntToDigit() {
assertEquals(digitOne, mayanCalculation.game.alphabet.get(BigInteger.ONE).digit)
assertEquals(digitTwo, mayanCalculation.game.alphabet.get(BigInteger.valueOf(2L)).digit)
}
@Test
fun testConvertNumberToInt() {
assertEquals(BigInteger.valueOf(20 * 2 + 1), numberTwentyOne.integer)
}
@Test
fun testConvertIntToNumber() {
assertEquals(numberTwentyOne, mayanCalculation.game.alphabet.getNumberForInt(BigInteger.valueOf(20 * 2 + 1)))
}
@Test
fun testZero() {
assertEquals(digitZero, mayanCalculation.game.alphabet.get(BigInteger.ZERO).digit)
assertEquals(numberZero, mayanCalculation.game.alphabet.getNumberForInt(BigInteger.valueOf(0)))
assertEquals(numberTwenty, mayanCalculation.game.alphabet.getNumberForInt(BigInteger.valueOf(40)))
}
}