mapserver/server/coords/convert_test.go

41 lines
727 B
Go
Raw Normal View History

2019-01-09 10:52:51 +01:00
package coords
import (
2019-01-13 16:37:03 +01:00
"testing"
2019-01-20 20:10:48 +01:00
"github.com/sirupsen/logrus"
2019-01-09 10:52:51 +01:00
)
var log *logrus.Entry
2019-01-13 16:37:03 +01:00
func init() {
2019-01-09 10:52:51 +01:00
log = logrus.WithFields(logrus.Fields{"prefix": "coords/convert_test"})
}
2019-01-13 16:37:03 +01:00
func testCoordConvert(t *testing.T, mb MapBlockCoords) {
log.WithFields(logrus.Fields{"coords": mb}).Info("MapblockCoords")
2019-01-09 10:52:51 +01:00
2019-01-13 16:37:03 +01:00
p := CoordToPlain(mb)
log.WithFields(logrus.Fields{"plain": p}).Info("MapblockCoords")
2019-01-09 10:52:51 +01:00
2019-01-13 16:37:03 +01:00
mb2 := PlainToCoord(p)
log.WithFields(logrus.Fields{"coords2": mb2}).Info("MapblockCoords")
2019-01-09 10:52:51 +01:00
2019-01-13 16:37:03 +01:00
if mb.X != mb2.X {
t.Fatal("X mismatch")
}
2019-01-09 10:52:51 +01:00
2019-01-13 16:37:03 +01:00
if mb.Y != mb2.Y {
t.Fatal("Y mismatch")
}
2019-01-09 10:52:51 +01:00
2019-01-13 16:37:03 +01:00
if mb.Z != mb2.Z {
t.Fatal("Z mismatch")
}
2019-01-09 10:52:51 +01:00
}
2019-01-23 08:02:59 +01:00
func TestZeorCoord(t *testing.T) {
2019-01-23 13:13:32 +01:00
testCoordConvert(t, NewMapBlockCoords(0, 0, 0))
2019-01-23 08:02:59 +01:00
}