mirror of
https://github.com/Threnklyn/advent-of-code-go.git
synced 2026-06-07 12:45:10 +02:00
2018-day15: lots of code for elf vs goblin battles
This commit is contained in:
+45
-20
@@ -1,6 +1,10 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alexchao26/advent-of-code-go/util"
|
||||
)
|
||||
|
||||
var exampleInput1 = `#######
|
||||
#.G...#
|
||||
@@ -9,6 +13,8 @@ var exampleInput1 = `#######
|
||||
#..G#E#
|
||||
#.....#
|
||||
#######`
|
||||
|
||||
// this example is in part 1 but not part 2 -shrug-
|
||||
var exampleInput2 = `#######
|
||||
#G..#E#
|
||||
#E#E.E#
|
||||
@@ -58,7 +64,7 @@ var tests1 = []struct {
|
||||
{"example4", exampleInput4, 27755},
|
||||
{"example5", exampleInput5, 28944},
|
||||
{"example6", exampleInput6, 18740},
|
||||
// {"actual", ACTUAL_ANSWER, util.ReadFile("input.txt")},
|
||||
{"actual", util.ReadFile("input.txt"), 183300},
|
||||
}
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
@@ -72,22 +78,41 @@ func TestPart1(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// var tests2 = []struct {
|
||||
// name string
|
||||
// want int
|
||||
// input string
|
||||
// // add extra args if needed
|
||||
// }{
|
||||
// // {"actual", ACTUAL_ANSWER, util.ReadFile("input.txt")},
|
||||
// }
|
||||
var reddit1 = `#######
|
||||
#######
|
||||
#.E..G#
|
||||
#.#####
|
||||
#G#####
|
||||
#######
|
||||
#######`
|
||||
|
||||
// func TestPart2(t *testing.T) {
|
||||
// for _, test := range tests2 {
|
||||
// t.Run(test.name, func(*testing.T) {
|
||||
// got := part2(test.input)
|
||||
// if got != test.want {
|
||||
// t.Errorf("got %v, want %v", got, test.want)
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
// used a sample test from a reddit thread where I was failing this specific issue
|
||||
// https://www.reddit.com/r/adventofcode/comments/a6r6kg/2018_day_15_part_1_what_am_i_missing/ebxjjuo?utm_source=share&utm_medium=web2x&context=3
|
||||
func TestMovement(t *testing.T) {
|
||||
t.Log("Expect Elf's first move to go RIGHT")
|
||||
part1(reddit1)
|
||||
}
|
||||
|
||||
var tests2 = []struct {
|
||||
name string
|
||||
input string
|
||||
want int
|
||||
}{
|
||||
{"example1", exampleInput1, 4988},
|
||||
{"example3", exampleInput3, 31284},
|
||||
{"example4", exampleInput4, 3478},
|
||||
{"example5", exampleInput5, 6474},
|
||||
{"example6", exampleInput6, 1140},
|
||||
{"actual", util.ReadFile("input.txt"), 40625},
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
for _, test := range tests2 {
|
||||
t.Run(test.name, func(*testing.T) {
|
||||
got := part2(test.input)
|
||||
if got != test.want {
|
||||
t.Errorf("got %v, want %v", got, test.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user