forked from MTSR/mapserver
more testing
This commit is contained in:
parent
86a091d530
commit
876b4ac148
@ -1,8 +1,9 @@
|
|||||||
package coords
|
package coords
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var log *logrus.Entry
|
var log *logrus.Entry
|
||||||
@ -33,10 +34,3 @@ func testCoordConvert(t *testing.T, mb MapBlockCoords) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestConvertPlainMapBlock(t *testing.T) {
|
|
||||||
testCoordConvert(t, NewMapBlockCoords(10, 0, -10))
|
|
||||||
testCoordConvert(t, NewMapBlockCoords(-2048, 2047, -10))
|
|
||||||
testCoordConvert(t, NewMapBlockCoords(-3, 0, 2047)) //0...2047
|
|
||||||
|
|
||||||
}
|
|
||||||
|
94
coords/tileconvert_test.go
Normal file
94
coords/tileconvert_test.go
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
package coords
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestConvertMapblockToTile1(t *testing.T) {
|
||||||
|
mbc := NewMapBlockCoords(0, 0, 0)
|
||||||
|
tc := GetTileCoordsFromMapBlock(mbc)
|
||||||
|
|
||||||
|
if tc.X != 0 {
|
||||||
|
t.Fatal("x does not match")
|
||||||
|
}
|
||||||
|
|
||||||
|
if tc.Y != -1 {
|
||||||
|
t.Fatal("y does not match")
|
||||||
|
}
|
||||||
|
|
||||||
|
if tc.Zoom != 13 {
|
||||||
|
t.Fatal("zoom does not match")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetMapBlockRangeFromTile(t *testing.T) {
|
||||||
|
r := GetMapBlockRangeFromTile(NewTileCoords(0, 0, 13, 0), 0)
|
||||||
|
assert.Equal(t, r.Pos1.X, 0)
|
||||||
|
assert.Equal(t, r.Pos1.Z, -1)
|
||||||
|
assert.Equal(t, r.Pos2.X, 0)
|
||||||
|
assert.Equal(t, r.Pos2.Z, -1)
|
||||||
|
|
||||||
|
r = GetMapBlockRangeFromTile(NewTileCoords(-1, -1, 13, 0), 0)
|
||||||
|
assert.Equal(t, r.Pos1.X, -1)
|
||||||
|
assert.Equal(t, r.Pos1.Z, 0)
|
||||||
|
assert.Equal(t, r.Pos2.X, -1)
|
||||||
|
assert.Equal(t, r.Pos2.Z, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestConvertMapblockToTile2(t *testing.T) {
|
||||||
|
mbc := NewMapBlockCoords(1, 0, 1)
|
||||||
|
tc := GetTileCoordsFromMapBlock(mbc)
|
||||||
|
|
||||||
|
if tc.X != 1 {
|
||||||
|
t.Fatal("x does not match")
|
||||||
|
}
|
||||||
|
|
||||||
|
if tc.Y != -2 {
|
||||||
|
t.Fatal("y does not match")
|
||||||
|
}
|
||||||
|
|
||||||
|
if tc.Zoom != 13 {
|
||||||
|
t.Fatal("zoom does not match")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestConvertMapblockToTile3(t *testing.T) {
|
||||||
|
mbc := NewMapBlockCoords(-1, 0, -1)
|
||||||
|
tc := GetTileCoordsFromMapBlock(mbc)
|
||||||
|
|
||||||
|
if tc.X != -1 {
|
||||||
|
t.Fatal("x does not match")
|
||||||
|
}
|
||||||
|
|
||||||
|
if tc.Y != 0 {
|
||||||
|
t.Fatal("y does not match")
|
||||||
|
}
|
||||||
|
|
||||||
|
if tc.Zoom != 13 {
|
||||||
|
t.Fatal("zoom does not match")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestZoomedQuadrantsFromTile(t *testing.T) {
|
||||||
|
tc := NewTileCoords(0, 0, 12, 0)
|
||||||
|
q := tc.GetZoomedQuadrantsFromTile()
|
||||||
|
|
||||||
|
assert.Equal(t, q.UpperLeft.X, 0)
|
||||||
|
assert.Equal(t, q.UpperLeft.Y, 0)
|
||||||
|
assert.Equal(t, q.UpperLeft.Zoom, 13)
|
||||||
|
|
||||||
|
assert.Equal(t, q.UpperRight.X, 1)
|
||||||
|
assert.Equal(t, q.UpperRight.Y, 0)
|
||||||
|
assert.Equal(t, q.UpperRight.Zoom, 13)
|
||||||
|
|
||||||
|
assert.Equal(t, q.LowerLeft.X, 0)
|
||||||
|
assert.Equal(t, q.LowerLeft.Y, 1)
|
||||||
|
assert.Equal(t, q.LowerLeft.Zoom, 13)
|
||||||
|
|
||||||
|
assert.Equal(t, q.LowerRight.X, 1)
|
||||||
|
assert.Equal(t, q.LowerRight.Y, 1)
|
||||||
|
assert.Equal(t, q.LowerRight.Zoom, 13)
|
||||||
|
|
||||||
|
}
|
3
go.mod
3
go.mod
@ -1,10 +1,13 @@
|
|||||||
module mapserver
|
module mapserver
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/google/go-cmp v0.2.0 // indirect
|
||||||
github.com/google/pprof v0.0.0-20190109223431-e84dfd68c163 // indirect
|
github.com/google/pprof v0.0.0-20190109223431-e84dfd68c163 // indirect
|
||||||
github.com/mattn/go-sqlite3 v1.10.0
|
github.com/mattn/go-sqlite3 v1.10.0
|
||||||
github.com/mjibson/esc v0.1.0 // indirect
|
github.com/mjibson/esc v0.1.0 // indirect
|
||||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||||
github.com/sirupsen/logrus v1.3.0
|
github.com/sirupsen/logrus v1.3.0
|
||||||
|
github.com/stretchr/testify v1.2.2
|
||||||
golang.org/x/arch v0.0.0-20181203225421-5a4828bb7045 // indirect
|
golang.org/x/arch v0.0.0-20181203225421-5a4828bb7045 // indirect
|
||||||
|
gotest.tools v2.2.0+incompatible
|
||||||
)
|
)
|
||||||
|
4
go.sum
4
go.sum
@ -1,5 +1,7 @@
|
|||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
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/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
|
||||||
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
github.com/google/pprof v0.0.0-20190109223431-e84dfd68c163 h1:beB+Da4k9B1zmgag78k3k1Bx4L/fdWr5FwNa0f8RxmY=
|
github.com/google/pprof v0.0.0-20190109223431-e84dfd68c163 h1:beB+Da4k9B1zmgag78k3k1Bx4L/fdWr5FwNa0f8RxmY=
|
||||||
github.com/google/pprof v0.0.0-20190109223431-e84dfd68c163/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
github.com/google/pprof v0.0.0-20190109223431-e84dfd68c163/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||||
@ -22,3 +24,5 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1
|
|||||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8=
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8=
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
|
||||||
|
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
|
||||||
|
Loading…
Reference in New Issue
Block a user