-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day08Spec.scala
61 lines (45 loc) · 1.54 KB
/
Day08Spec.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
package com.kensai.aoc.aoc2020
import Day08._
import com.kensai.aoc.lib.Lib.readInputLines
import org.junit.runner.RunWith
import org.scalatest.GivenWhenThen
import org.scalatest.flatspec._
import org.scalatest.matchers.should.Matchers._
import org.scalatestplus.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
class Day08Spec extends AnyFlatSpec with GivenWhenThen {
private lazy val puzzleInputs = readInputLines(
"src/test/resources/2020/Day08.input"
)
private lazy val specInputs = readInputLines(
"src/test/resources/2020/Day08Spec.input"
)
"accumulatorBeforeLoop for spec" should "return 5" in {
Given(s"Input is spec")
When(s"accumulatorBeforeLoop(input)")
val result = accumulatorBeforeLoop(specInputs)
Then(s"Result is 5")
result shouldBe 5
}
"accumulatorBeforeLoop for puzzle" should "return solution" in {
Given(s"Puzzle input")
When(s"accumulatorBeforeLoop(input)")
val result = accumulatorBeforeLoop(puzzleInputs)
Then(s"Result is 2003")
result shouldBe 2003
}
"accumulatorAfterFixingInputs for spec" should "return 8" in {
Given(s"Input is spec")
When(s"accumulatorAfterFixingInputs(input)")
val result = accumulatorAfterFixingInputs(specInputs)
Then(s"Result is 8")
result shouldBe 8
}
"accumulatorAfterFixingInputs for puzzle" should "return solution" in {
Given(s"Puzzle solution")
When(s"accumulatorAfterFixingInputs(input)")
val result = accumulatorAfterFixingInputs(puzzleInputs)
Then(s"Result is 1984")
result shouldBe 1984
}
}