Skip to content

Commit

Permalink
test: use testify assert for assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
kylehoehns committed Nov 20, 2023
1 parent 546e9b2 commit fae2fa4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
module github.com/kylehoehns/aoc-2023-go

go 1.21

require github.com/stretchr/testify v1.8.4

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
17 changes: 8 additions & 9 deletions puzzles/day00/main_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package main

import "testing"
import (
"github.com/stretchr/testify/assert"
"testing"
)

func TestPart1(t *testing.T) {

t.Run("Part 1", func(t *testing.T) {

expenses := []int{1721, 979, 366, 299, 675, 1456}
actual := part1(expenses)
expected := 514579
if actual != expected {
t.Errorf("Expected %d but actual was %d", expected, actual)
}
actual := part1(expenses)
assert.Equal(t, expected, actual)
})

}
Expand All @@ -21,11 +22,9 @@ func TestPart2(t *testing.T) {
t.Run("Part 2", func(t *testing.T) {

expenses := []int{1721, 979, 366, 299, 675, 1456}
actual := part2(expenses)
expected := 241861950
if actual != expected {
t.Errorf("Expected %d but actual was %d", expected, actual)
}
actual := part2(expenses)
assert.Equal(t, expected, actual)
})

}

0 comments on commit fae2fa4

Please sign in to comment.