65 lines
1.1 KiB
Go
65 lines
1.1 KiB
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"strings"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestDay5SeedFertilizer(t *testing.T) {
|
||
|
t.Logf("This is the test suite for Advent of Code - Day 5 - 'If You Give A Seed A Fertilizer'")
|
||
|
|
||
|
testAlmanac := `
|
||
|
seeds: 79 14 55 13
|
||
|
|
||
|
seed-to-soil map:
|
||
|
50 98 2
|
||
|
52 50 48
|
||
|
|
||
|
soil-to-fertilizer map:
|
||
|
0 15 37
|
||
|
37 52 2
|
||
|
39 0 15
|
||
|
|
||
|
fertilizer-to-water map:
|
||
|
49 53 8
|
||
|
0 11 42
|
||
|
42 0 7
|
||
|
57 7 4
|
||
|
|
||
|
water-to-light map:
|
||
|
88 18 7
|
||
|
18 25 70
|
||
|
|
||
|
light-to-temperature map:
|
||
|
45 77 23
|
||
|
81 45 19
|
||
|
68 64 13
|
||
|
|
||
|
temperature-to-humidity map:
|
||
|
0 69 1
|
||
|
1 0 69
|
||
|
|
||
|
humidity-to-location map:
|
||
|
60 56 37
|
||
|
56 93 4
|
||
|
`
|
||
|
|
||
|
almanac := strings.Split(testAlmanac, "\n")
|
||
|
|
||
|
// remove the first and last lines of the test card pack as they are blank lines
|
||
|
almanac = almanac[1 : len(almanac)-1]
|
||
|
|
||
|
t.Run("Test the solution to the food production issue", testSolveFoodProductionIssue(almanac))
|
||
|
}
|
||
|
|
||
|
func testSolveFoodProductionIssue(almanac []string) func(t *testing.T) {
|
||
|
return func(t *testing.T) {
|
||
|
parsed, err := parseAlmanac(almanac)
|
||
|
if err != nil {
|
||
|
t.Fatalf("Unable to parse the almanac; %v", err)
|
||
|
}
|
||
|
t.Logf("%+v", parsed)
|
||
|
t.FailNow()
|
||
|
}
|
||
|
}
|