-
Notifications
You must be signed in to change notification settings - Fork 1
/
map_test.go
71 lines (60 loc) · 1.77 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
package tmx_test
import (
. "github.com/manyminds/tmx"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Tests for map", func() {
Context("Test map utility methods", func() {
var testMap Map
var miniTileset Tileset
var giantTileset Tileset
BeforeEach(func() {
miniImage := Image{Width: 320, Height: 320}
miniTileset = Tileset{
FirstGID: 1,
TileWidth: 32,
TileHeight: 32,
Image: miniImage,
}
giantImage := Image{Width: 16000, Height: 16000}
giantTileset = Tileset{
FirstGID: GID(miniTileset.GetNumTiles()),
TileWidth: 32,
TileHeight: 32,
Image: giantImage,
}
testMap = Map{Tilesets: []Tileset{miniTileset, giantTileset}}
})
It("should return no tileset for 0", func() {
set, err := testMap.GetTilesetForGID(0)
Expect(set).To(BeNil())
Expect(err).ToNot(HaveOccurred())
})
It("should error for invalid gid range", func() {
set, err := testMap.GetTilesetForGID(250100)
Expect(err).To(HaveOccurred())
Expect(set).To(BeNil())
})
It("should be returning miniTileset", func() {
set, err := testMap.GetTilesetForGID(2)
Expect(err).ToNot(HaveOccurred())
Expect(set).To(Equal(&miniTileset))
})
It("should be returning miniTileset lower boundary", func() {
set, err := testMap.GetTilesetForGID(100)
Expect(err).ToNot(HaveOccurred())
Expect(set).To(Equal(&miniTileset))
})
It("should be returning giantTileset", func() {
set, err := testMap.GetTilesetForGID(101)
Expect(err).ToNot(HaveOccurred())
Expect(set).To(Equal(&giantTileset))
})
It("should be returning giantTileset upper boundary", func() {
set, err := testMap.GetTilesetForGID(250099)
Expect(err).ToNot(HaveOccurred())
Expect(set).To(Equal(&giantTileset))
})
})
})