-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay2KtTest.kt
51 lines (40 loc) · 1.49 KB
/
Day2KtTest.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
package aoc2020.day02
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Assertions.*
internal class Day2KtTest {
private val abcde = "abcde"
private val aaaaa = "aaaaa"
private val aabcd = "aabcd"
private val testPath = "src/main/kotlin/aoc2020/day02/input0"
private val path = "src/main/kotlin/aoc2020/day02/input"
@Test
fun testIsValidPassword() {
assertTrue(isValidPassword(1, 3, 'a', abcde))
assertTrue(isValidPassword(1, 1, 'b', abcde))
assertFalse(isValidPassword(1, 3, 'a', aaaaa))
assertFalse(isValidPassword(1, 1, 'a', aabcd))
}
@Test
fun testCountValidPasswords() {
val input0 = readInputFileToList(testPath)
val input = readInputFileToList(path)
assertEquals(2, countValidPasswords(input0, ::isValidPassword))
assertEquals(569, countValidPasswords(input, ::isValidPassword))
}
@Test
fun testIsValidPassword2() {
assertTrue(isValidPassword2(1, 3, 'a', abcde))
assertTrue(isValidPassword2(1, 2, 'b', abcde))
assertFalse(isValidPassword2(1, 3, 'a', aaaaa))
assertFalse(isValidPassword2(1, 2, 'a', aabcd))
}
@Test
fun testCountValidPasswords2() {
assertEquals(1, countValidPasswords(readInputFileToList(testPath), ::isValidPassword2))
assertEquals(346, countValidPasswords(readInputFileToList(path), ::isValidPassword2))
}
@Test
fun testReadInputToList() {
println(readInputFileToList(testPath))
}
}