1
0
forked from MTSR/mapserver
mapserver/coords/convert_test.go

52 lines
1.0 KiB
Go
Raw Normal View History

2019-01-09 12:52:51 +03:00
package coords
import (
2023-12-29 18:00:11 +03:00
"mapserver/types"
2019-01-13 18:37:03 +03:00
"testing"
2019-01-20 22:10:48 +03:00
"github.com/sirupsen/logrus"
2019-01-09 12:52:51 +03:00
)
var log *logrus.Entry
2019-01-13 18:37:03 +03:00
func init() {
2019-01-09 12:52:51 +03:00
log = logrus.WithFields(logrus.Fields{"prefix": "coords/convert_test"})
}
2019-02-14 11:05:39 +03:00
func TestMinCoord(t *testing.T) {
2023-12-29 18:00:11 +03:00
c := types.NewMapBlockCoords(types.MinCoord, types.MinCoord, types.MinCoord)
2019-02-14 10:34:16 +03:00
pc := CoordToPlain(c)
2019-02-14 11:05:39 +03:00
log.WithFields(logrus.Fields{"coords": c, "plain": pc, "plain-1": pc - 1}).Info("TestMinCoord")
2019-02-14 10:34:16 +03:00
if pc != MinPlainCoord {
t.Fatal("no min match")
}
}
2023-12-29 18:00:11 +03:00
func testCoordConvert(t *testing.T, mb *types.MapBlockCoords) {
2019-01-13 18:37:03 +03:00
log.WithFields(logrus.Fields{"coords": mb}).Info("MapblockCoords")
2019-01-09 12:52:51 +03:00
2019-01-13 18:37:03 +03:00
p := CoordToPlain(mb)
log.WithFields(logrus.Fields{"plain": p}).Info("MapblockCoords")
2019-01-09 12:52:51 +03:00
2019-01-13 18:37:03 +03:00
mb2 := PlainToCoord(p)
log.WithFields(logrus.Fields{"coords2": mb2}).Info("MapblockCoords")
2019-01-09 12:52:51 +03:00
2019-01-13 18:37:03 +03:00
if mb.X != mb2.X {
t.Fatal("X mismatch")
}
2019-01-09 12:52:51 +03:00
2019-01-13 18:37:03 +03:00
if mb.Y != mb2.Y {
t.Fatal("Y mismatch")
}
2019-01-09 12:52:51 +03:00
2019-01-13 18:37:03 +03:00
if mb.Z != mb2.Z {
t.Fatal("Z mismatch")
}
2019-01-09 12:52:51 +03:00
}
2019-01-23 10:02:59 +03:00
2023-12-29 18:00:11 +03:00
func TestZeroCoord(t *testing.T) {
testCoordConvert(t, types.NewMapBlockCoords(0, 0, 0))
2019-01-23 10:02:59 +03:00
}