Skip to content

Commit

Permalink
chore: use github.com/alecthomas/assert for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Jun 7, 2023
1 parent 7ba4f4e commit 56838b2
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 105 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ linters:
- contextcheck
- cyclop
- decorder
- depguard
- dogsled
- dupl
- dupword
Expand Down Expand Up @@ -79,6 +78,7 @@ linters:
- whitespace
- wrapcheck
disable:
- depguard
- exhaustruct
- funlen
- gochecknoglobals
Expand Down
29 changes: 14 additions & 15 deletions context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import (
"strconv"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/alecthomas/assert/v2"

"github.com/twpayne/go-proj/v10"
)
Expand All @@ -15,7 +14,7 @@ func TestContext_NewCRSToCRS(t *testing.T) {
defer runtime.GC()

context := proj.NewContext()
require.NotNil(t, context)
assert.NotZero(t, context)

for _, tc := range []struct {
name string
Expand Down Expand Up @@ -43,10 +42,10 @@ func TestContext_NewCRSToCRS(t *testing.T) {
pj, err := context.NewCRSToCRS(tc.sourceCRS, tc.targetCRS, nil)
if tc.expectedErr != nil {
assert.EqualError(t, err, tc.expectedErr[proj.VersionMajor])
assert.Nil(t, pj)
assert.Zero(t, pj)
} else {
assert.NoError(t, err)
assert.NotNil(t, pj)
assert.NotZero(t, pj)
}
})
}
Expand All @@ -56,23 +55,23 @@ func TestContext_NewCRSToCRSFromPJ(t *testing.T) {
defer runtime.GC()

sourceCRS, err := proj.New("epsg:4326")
require.NoError(t, err)
assert.NoError(t, err)
assert.True(t, sourceCRS.IsCRS())

targetCRS, err := proj.New("epsg:3857")
require.NoError(t, err)
assert.NoError(t, err)
assert.True(t, targetCRS.IsCRS())

pj, err := proj.NewCRSToCRSFromPJ(sourceCRS, targetCRS, nil, "")
require.NoError(t, err)
assert.NotNil(t, pj)
assert.NoError(t, err)
assert.NotZero(t, pj)
}

func TestContext_New(t *testing.T) {
defer runtime.GC()

context := proj.NewContext()
require.NotNil(t, context)
assert.NotZero(t, context)

for _, tc := range []struct {
definition string
Expand All @@ -97,10 +96,10 @@ func TestContext_New(t *testing.T) {
pj, err := context.New(tc.definition)
if tc.expectedErr != nil {
assert.EqualError(t, err, tc.expectedErr[proj.VersionMajor])
assert.Nil(t, pj)
assert.Zero(t, pj)
} else {
assert.NoError(t, err)
assert.NotNil(t, pj)
assert.NotZero(t, pj)
}
})
}
Expand All @@ -110,7 +109,7 @@ func TestContext_NewFromArgs(t *testing.T) {
defer runtime.GC()

context := proj.NewContext()
require.NotNil(t, context)
assert.NotZero(t, context)

for i, tc := range []struct {
args []string
Expand All @@ -132,10 +131,10 @@ func TestContext_NewFromArgs(t *testing.T) {
pj, err := context.NewFromArgs(tc.args...)
if tc.expectedErr != nil {
assert.EqualError(t, err, tc.expectedErr[proj.VersionMajor])
assert.Nil(t, pj)
assert.Zero(t, pj)
} else {
assert.NoError(t, err)
assert.NotNil(t, pj)
assert.NotZero(t, pj)
}
})
}
Expand Down
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ module github.com/twpayne/go-proj/v10
go 1.19

require (
github.com/stretchr/testify v1.8.1
github.com/alecthomas/assert/v2 v2.2.2
golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9
)

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
github.com/alecthomas/repr v0.2.0 // indirect
github.com/hexops/gotextdiff v1.0.3 // indirect
)
23 changes: 6 additions & 17 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk=
github.com/alecthomas/assert/v2 v2.2.2/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk=
github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9 h1:yZNXmy+j/JpX19vZkVktWqAo7Gny4PBWYYK3zskGpx4=
golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
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.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading

0 comments on commit 56838b2

Please sign in to comment.