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

51 lines
995 B
Go
Raw Normal View History

2019-01-09 12:52:51 +03:00
package coords
import (
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) {
2019-02-14 10:34:16 +03:00
c := NewMapBlockCoords(MinCoord, MinCoord, MinCoord)
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")
}
}
2019-02-06 10:38:08 +03:00
func testCoordConvert(t *testing.T, mb *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
func TestZeorCoord(t *testing.T) {
2019-01-23 15:13:32 +03:00
testCoordConvert(t, NewMapBlockCoords(0, 0, 0))
2019-01-23 10:02:59 +03:00
}