look at this ugly function with 9 params :)

This commit is contained in:
alexchao26
2020-12-27 19:40:02 -05:00
parent 666518f507
commit c6c4131c4e
2 changed files with 163 additions and 45 deletions
+19 -22
View File
@@ -2,38 +2,35 @@ package main
import (
"testing"
"github.com/alexchao26/advent-of-code-go/util"
)
func Test_part1(t *testing.T) {
type args struct {
input string
myHP int
myMana int
part int
}
tests := []struct {
name string
input string
want int
name string
args args
want int
}{
// {"actual", util.ReadFile("input.txt"), ACTUAL_ANSWER},
{
name: "example",
args: args{"Hit Points: 13\nDamage: 8", 10, 250, 1},
want: spellsMap["Poison"].cost + spellsMap["Magic Missile"].cost,
},
{"actual", args{util.ReadFile("input.txt"), 50, 500, 1}, 953},
{"actual", args{util.ReadFile("input.txt"), 50, 500, 2}, 1289},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := part1(tt.input); got != tt.want {
if got := part1(tt.args.input, tt.args.myHP, tt.args.myMana, tt.args.part); got != tt.want {
t.Errorf("part1() = %v, want %v", got, tt.want)
}
})
}
}
func Test_part2(t *testing.T) {
tests := []struct {
name string
input string
want int
}{
// {"actual", util.ReadFile("input.txt"), ACTUAL_ANSWER},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := part2(tt.input); got != tt.want {
t.Errorf("part2() = %v, want %v", got, tt.want)
}
})
}
}