-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02_test.go
53 lines (47 loc) · 1.01 KB
/
02_test.go
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
package main
import (
"strings"
"testing"
)
func TestAOC202202(t *testing.T) {
var tests = []struct {
input string
points int
score int
target string
}{
{
input: "A Y",
points: 2,
score: 6,
target: "X",
},
{
input: "B X",
points: 1,
score: 0,
target: "X",
},
{
input: "C Z",
points: 3,
score: 3,
target: "X",
},
}
for _, test := range tests {
inputParts := strings.Split(test.input, " ")
got := AOC202202Win(inputParts[0], inputParts[1])
if test.score != got {
t.Errorf("AOC202202Win() missmatch:\nwant: %d\ngot: %d", test.score, got)
}
got = AOC202202Points(inputParts[1])
if test.points != got {
t.Errorf("AOC202202Points() missmatch:\nwant: %s->%d\ngot: %s->%d", inputParts[0], test.points, inputParts[1], got)
}
target := AOC202202Lookup(inputParts[0], inputParts[1])
if test.target != target {
t.Errorf("AOC202202Points() missmatch:\nwant: %s->%s\ngot: %s->%s", inputParts[0], test.target, inputParts[1], target)
}
}
}