advent-of-code/aoc2024/day03/main_test.go
xuu 6a17669107
Some checks failed
Go Test / build (pull_request) Failing after 57s
feat(aoc2024): complete day 3 part 2
2024-12-03 16:15:53 -07:00

46 lines
767 B
Go

package main
import (
"bytes"
"testing"
_ "embed"
"github.com/matryer/is"
)
//go:embed example.txt
var example []byte
//go:embed example2.txt
var example2 []byte
//go:embed input.txt
var input []byte
func TestExample(t *testing.T) {
is := is.New(t)
result, err := run(bytes.NewReader(example))
is.NoErr(err)
t.Log(result)
is.Equal(result.valuePT1, 161)
result, err = run(bytes.NewReader(example2))
is.NoErr(err)
is.Equal(result.valuePT1, 161)
is.Equal(result.valuePT2, 48)
}
func TestSolution(t *testing.T) {
is := is.New(t)
result, err := run(bytes.NewReader(input))
is.NoErr(err)
t.Log(result)
is.True(result.valuePT1 < 186942148) // first attempt too high
is.Equal(result.valuePT1, 184122457)
is.Equal(result.valuePT2, 107862689)
}