-
Notifications
You must be signed in to change notification settings - Fork 0
/
map_test.go
74 lines (57 loc) · 1.7 KB
/
map_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package tiled
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestLoadMap(t *testing.T) {
m, err := LoadMap("tmx/simple_map_10x10.tmx")
assert.Nil(t, err)
assert.NotNil(t, m)
assert.Equal(t, 10, m.Height())
assert.Equal(t, 10, m.Width())
assert.Equal(t, 1, len(m.Layers()))
layer := m.Layers()[0]
assert.Equal(t, 0, layer.X())
assert.Equal(t, 0, layer.Y())
tile := layer.TileAt(NewPoint(0, 0))
assert.Equal(t, 0, tile.X())
assert.Equal(t, 0, tile.Y())
tile = layer.TileAt(NewPoint(9, 9))
assert.Equal(t, 9, tile.X())
assert.Equal(t, 9, tile.Y())
}
func TestSubMap(t *testing.T) {
m, err := LoadMap("tmx/simple_map_10x10.tmx")
assert.Nil(t, err)
sub := m.Sub(NewRect(0, 0, 5, 6))
assert.NotNil(t, sub)
assert.Equal(t, 5, sub.Width())
assert.Equal(t, 6, sub.Height())
assert.Equal(t, len(m.Layers()), len(sub.Layers()))
layer := sub.Layers()[0]
assert.Equal(t, 5, layer.Width())
assert.Equal(t, 6, layer.Height())
tile := layer.TileAt(NewPoint(0, 0))
assert.Equal(t, 0, tile.X())
assert.Equal(t, 0, tile.Y())
//assert.Equal(t, 0, tile.Type().Gid())
sub = m.Sub(NewRect(1, 1, 5, 6))
assert.NotNil(t, sub)
layer = sub.Layers()[0]
tile = layer.TileAt(NewPoint(0, 0))
assert.Equal(t, 1, tile.X())
assert.Equal(t, 1, tile.Y())
//assert.Equal(t, 0, tile.Type().Gid())
sub = m.Sub(NewRect(1, 2, 5, 6))
assert.NotNil(t, sub)
assert.Equal(t, 5, sub.Width())
assert.Equal(t, 6, sub.Height())
assert.Equal(t, len(m.Layers()), len(sub.Layers()))
layer = sub.Layers()[0]
assert.Equal(t, 5, layer.Width())
assert.Equal(t, 6, layer.Height())
tile = layer.TileAt(NewPoint(0, 0))
assert.Equal(t, 1, tile.X())
assert.Equal(t, 2, tile.Y())
//assert.Equal(t, 0, tile.Type().Gid())
}