MCPcopy Index your code
hub / github.com/EngoEngine/engo / TestTMXGrid

Function TestTMXGrid

common/tmx_test.go:272–313  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

270}
271
272func TestTMXGrid(t *testing.T) {
273 imgbuf := bytes.NewBuffer([]byte{})
274 img := image.NewRGBA(image.Rect(0, 0, 457, 305))
275 err := png.Encode(imgbuf, img)
276 if err != nil {
277 t.Errorf("Unable to encode png from image")
278 }
279
280 err = engo.Files.LoadReaderData("test.png", imgbuf)
281 if err != nil {
282 t.Errorf("Unable to load test png. Error was: %v", err)
283 }
284
285 buf := bytes.NewBuffer([]byte{})
286 tmpl, err := template.New("test").Parse(testTMXtmpl)
287 if err != nil {
288 t.Error("Error parsing tmx template")
289 }
290 err = tmpl.Execute(buf, tmxData{
291 Orientation: "isometric",
292 RenderOrder: "left-down",
293 Grid: true,
294 })
295 if err != nil {
296 t.Error("Error executing tmx template")
297 }
298
299 err = engo.Files.LoadReaderData("test.tmx", buf)
300 if err != nil {
301 t.Errorf("Unable to load tmx file for testing. Error was: %v", err)
302 }
303
304 resource, err := engo.Files.Resource("test.tmx")
305 if err != nil {
306 panic(err)
307 }
308 tmxResource := resource.(TMXResource)
309 levelData := tmxResource.Level
310 if levelData.Orientation != "isometric" {
311 t.Errorf("orientation is not isometric. Was: %v", levelData.Orientation)
312 }
313}
314
315func TestTMXTileImages(t *testing.T) {
316 imgbuf := bytes.NewBuffer([]byte{})

Callers

nothing calls this directly

Calls 4

LoadReaderDataMethod · 0.80
ResourceMethod · 0.65
NewMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected