-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day02Spec.scala
62 lines (46 loc) · 1.75 KB
/
Day02Spec.scala
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
package com.kensai.aoc.aoc2020
import Day02._
import com.kensai.aoc.lib.Lib.readInputLines
import org.junit.runner.RunWith
import org.scalatest._
import org.scalatest.flatspec._
import org.scalatest.matchers.should.Matchers._
import org.scalatestplus.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
class Day02Spec extends AnyFlatSpec with GivenWhenThen with Day02Fixtures {
private lazy val puzzleInputs = readInputLines(
"src/test/resources/2020/Day02.input"
)
"validPasswordCount for rows from specs" should "return 2 for Part1" in {
Given(s"Input is List(Row1, Row2, Row3)")
val inputs = List(Row1, Row2, Row3)
When("validPasswordCount(inputs)(isPasswordValidPart1)")
val result = validPasswordCount(inputs)(isPasswordValidPart1)
Then(s"Result is 2")
result shouldBe 2
}
"validPasswordCount" should "return solution for Part1" in {
Given(s"Puzzle input")
val inputs = parse(puzzleInputs)
When("validPasswordCount(inputs)(isPasswordValidPart1)")
val result = validPasswordCount(inputs)(isPasswordValidPart1)
Then(s"Solution is 556")
result shouldBe 556
}
"validPasswordCount for rows from specs" should "return 1 for Part2" in {
Given(s"Input is List(Row1, Row2, Row3)")
val inputs = List(Row1, Row2, Row3)
When("validPasswordCount(inputs)(isPasswordValidPart2)")
val result = validPasswordCount(inputs)(isPasswordValidPart2)
Then(s"Result is 1")
result shouldBe 1
}
"validPasswordCount" should "return solution for Part2" in {
Given(s"Puzzle input")
val inputs = parse(puzzleInputs)
When("validPasswordCount(inputs)(isPasswordValidPart2)")
val result = validPasswordCount(inputs)(isPasswordValidPart2)
Then(s"Result is 605")
result shouldBe 605
}
}