Skip to content

Commit 146f4cd

Browse files
authored
Issue 7 (#22)
* improve code coverage of tests * code coverage; small bugfix * code coverage * trivial coverage work * improved test coverage
1 parent 0e6d02e commit 146f4cd

15 files changed

+192
-20
lines changed

cmd/proj/proj_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func TestCmd(t *testing.T) {
3030
[]float64{0.0, 0.0},
3131
nil,
3232
}, {
33-
"proj-epsg 9999 -inverse",
33+
"proj -epsg 3395 -inverse",
3434
[]float64{0.0, 0.0},
3535
nil,
3636
}, {
@@ -42,7 +42,7 @@ func TestCmd(t *testing.T) {
4242
[]float64{12.0, 55.0},
4343
[]float64{691875.63, 6098907.83},
4444
}, {
45-
"proj -inverse +proj=utm +zone=32 +ellps=GRS80",
45+
"proj -verbose -inverse +proj=utm +zone=32 +ellps=GRS80",
4646
[]float64{691875.63, 6098907.83},
4747
[]float64{12.0, 55.0},
4848
},

core/Coordinate.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,30 @@ const (
2222

2323
// CoordAny just generically holds data, not assigned to a coordinate type.
2424
// Because unions.
25-
type CoordAny struct{ v [4]float64 }
25+
type CoordAny struct{ V [4]float64 }
2626

2727
//---------------------------------------------------------------------
2828

2929
// ToLP returns a CoordLP
3030
func (c *CoordAny) ToLP() *CoordLP {
31-
return &CoordLP{Lam: c.v[0], Phi: c.v[1]}
31+
return &CoordLP{Lam: c.V[0], Phi: c.V[1]}
3232
}
3333

3434
// FromLP sets this CoordAny
3535
func (c *CoordAny) FromLP(lp *CoordLP) {
36-
c.v[0] = lp.Lam
37-
c.v[1] = lp.Phi
36+
c.V[0] = lp.Lam
37+
c.V[1] = lp.Phi
3838
}
3939

4040
// ToXY returns a CoordXY
4141
func (c *CoordAny) ToXY() *CoordXY {
42-
return &CoordXY{X: c.v[0], Y: c.v[1]}
42+
return &CoordXY{X: c.V[0], Y: c.V[1]}
4343
}
4444

4545
// FromXY sets this CoordAny
4646
func (c *CoordAny) FromXY(xy *CoordXY) {
47-
c.v[0] = xy.Y
48-
c.v[1] = xy.Y
47+
c.V[0] = xy.X
48+
c.V[1] = xy.Y
4949
}
5050

5151
//---------------------------------------------------------------------

core/Coordinate_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package core_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/go-spatial/proj/core"
7+
"github.com/stretchr/testify/assert"
8+
)
9+
10+
func TestCoordinate(t *testing.T) {
11+
assert := assert.New(t)
12+
13+
{
14+
any := &core.CoordAny{V: [4]float64{1.0, 2.0, 3.0, 4.0}}
15+
lp := any.ToLP()
16+
assert.Equal(1.0, lp.Lam)
17+
assert.Equal(2.0, lp.Phi)
18+
lp.Lam = 10.0
19+
lp.Phi = 20.0
20+
any.FromLP(lp)
21+
assert.Equal(10.0, any.V[0])
22+
assert.Equal(20.0, any.V[1])
23+
assert.Equal(3.0, any.V[2])
24+
assert.Equal(4.0, any.V[3])
25+
}
26+
{
27+
any := &core.CoordAny{V: [4]float64{1.0, 2.0, 3.0, 4.0}}
28+
xy := any.ToXY()
29+
assert.Equal(1.0, xy.X)
30+
assert.Equal(2.0, xy.Y)
31+
xy.X = 10.0
32+
xy.Y = 20.0
33+
any.FromXY(xy)
34+
assert.Equal(10.0, any.V[0])
35+
assert.Equal(20.0, any.V[1])
36+
assert.Equal(3.0, any.V[2])
37+
assert.Equal(4.0, any.V[3])
38+
}
39+
}

core/Ellipsoid_test.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
11
package core_test
22

33
import (
4+
"fmt"
45
"testing"
56

7+
"github.com/go-spatial/proj/core"
8+
"github.com/go-spatial/proj/support"
9+
610
"github.com/stretchr/testify/assert"
711
)
812

913
func TestEllipsoid(t *testing.T) {
1014
assert := assert.New(t)
11-
assert.True(true)
15+
16+
ps, err := support.NewProjString("+proj=utm +zone=32 +ellps=GRS80")
17+
assert.NoError(err)
18+
sys, _, err := core.NewSystem(ps)
19+
assert.NoError(err)
20+
21+
e := sys.Ellipsoid
22+
23+
assert.Equal("GRS80", e.ID)
24+
25+
s := fmt.Sprintf("%s", e)
26+
assert.True(len(s) > 1)
1227
}

core/Operation.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,3 @@ func (op *Operation) GetSystem() *System {
3131
func (op *Operation) GetDescription() *OperationDescription {
3232
return op.Description
3333
}
34-
35-
// GetSignature returns the operation type, the input type, and the output type
36-
func (op *Operation) GetSignature() (OperationType, CoordType, CoordType) {
37-
d := op.Description
38-
return d.OperationType, d.InputType, d.OutputType
39-
}

core/OperationDescription_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package core_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/go-spatial/proj/core"
7+
8+
"github.com/stretchr/testify/assert"
9+
)
10+
11+
func TestOperationDescription(t *testing.T) {
12+
assert := assert.New(t)
13+
14+
opDesc := core.OperationDescriptionTable["utm"]
15+
assert.NotNil(opDesc)
16+
}

core/Operation_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package core_test
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
7+
"github.com/go-spatial/proj/core"
8+
"github.com/go-spatial/proj/support"
9+
10+
"github.com/stretchr/testify/assert"
11+
)
12+
13+
func TestOperation(t *testing.T) {
14+
assert := assert.New(t)
15+
16+
ps, err := support.NewProjString("+proj=utm +zone=32 +ellps=GRS80")
17+
assert.NoError(err)
18+
_, opx, err := core.NewSystem(ps)
19+
assert.NoError(err)
20+
21+
s := fmt.Sprintf("%s", opx)
22+
assert.True(len(s) > 1)
23+
24+
id := opx.GetDescription().ID
25+
assert.Equal("utm", id)
26+
}

core/System_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ func TestSystem(t *testing.T) {
1919
assert.NoError(err)
2020
assert.NotNil(sys)
2121
assert.NotNil(op)
22+
23+
assert.NotEqual("", sys.String())
2224
}
2325

2426
func TestProjStringValidation(t *testing.T) {

gie/Gie_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package gie_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/go-spatial/proj/gie"
7+
8+
"github.com/stretchr/testify/assert"
9+
)
10+
11+
func TestGie(t *testing.T) {
12+
assert := assert.New(t)
13+
14+
g, err := gie.NewGie(".")
15+
assert.NoError(err)
16+
assert.NotNil(g)
17+
}

merror/Error_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,8 @@ func TestError(t *testing.T) {
3030
exp3 := "wrapped error (from merror_test.TestError at Error_test.go:28)"
3131
exp3 += " // Inner: " + exp2
3232
assert.Equal(exp3, err3.Error())
33+
34+
err4 := merror.Pass(err2)
35+
assert.Error(err4)
36+
assert.Equal(exp2, err4.Error())
3337
}

0 commit comments

Comments
 (0)