chore: add tests for day 4
This commit is contained in:
parent
2c9e57ef76
commit
c4d292fb84
@ -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 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 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 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
32
day04/main_test.go
Normal 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
2
go.mod
@ -1,3 +1,5 @@
|
|||||||
module go.sour.is/advent-of-code-2023
|
module go.sour.is/advent-of-code-2023
|
||||||
|
|
||||||
go 1.21.3
|
go 1.21.3
|
||||||
|
|
||||||
|
require github.com/matryer/is v1.4.1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user