chore: add tests for day 4

This commit is contained in:
xuu 2023-12-05 08:02:09 -07:00
parent 2c9e57ef76
commit c4d292fb84
Signed by: xuu
GPG Key ID: 8B3B0604F164E04F
4 changed files with 37 additions and 0 deletions

View File

@ -3,3 +3,4 @@ Card 2: 13 32 20 16 61 | 61 30 68 82 17 32 24 19
Card 3: 1 21 53 59 44 | 69 82 63 72 16 21 14 1
Card 4: 41 92 73 84 69 | 59 84 76 51 58 5 54 83
Card 5: 87 83 26 28 32 | 88 30 70 12 93 22 82 36
Card 6: 31 18 13 56 72 | 74 77 10 23 35 67 36 11

32
day04/main_test.go Normal file
View File

@ -0,0 +1,32 @@
package main
import (
"bufio"
"bytes"
"testing"
_ "embed"
"github.com/matryer/is"
)
//go:embed example.txt
var example []byte
func TestExample(t *testing.T) {
is := is.New(t)
scan := bufio.NewScanner(bytes.NewReader(example))
points, cards := run(scan)
is.Equal(points, 13)
is.Equal(cards, 30)
}
func TestSolution(t *testing.T) {
is := is.New(t)
scan := bufio.NewScanner(bytes.NewReader(input))
points, cards := run(scan)
is.Equal(points, 23235)
is.Equal(cards, 5920640)
}

2
go.mod
View File

@ -1,3 +1,5 @@
module go.sour.is/advent-of-code-2023
go 1.21.3
require github.com/matryer/is v1.4.1

2
go.sum Normal file
View File

@ -0,0 +1,2 @@
github.com/matryer/is v1.4.1 h1:55ehd8zaGABKLXQUe2awZ99BD/PTc2ls+KV/dXphgEQ=
github.com/matryer/is v1.4.1/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=