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

Function TestObjectImageNotExistTempFile

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

Source from the content-addressed store, hash-verified

472}
473
474func TestObjectImageNotExistTempFile(t *testing.T) {
475 imgbuf := bytes.NewBuffer([]byte{})
476 img := image.NewRGBA(image.Rect(0, 0, 55, 55))
477 err := png.Encode(imgbuf, img)
478 if err != nil {
479 t.Errorf("Unable to encode png from image")
480 }
481
482 dir, err := ioutil.TempDir(".", "testing")
483 if err != nil {
484 t.Errorf("failed to create temp directory for testing, error: %v", err)
485 }
486 defer os.RemoveAll(dir)
487
488 engo.Files.SetRoot(dir)
489
490 tmpfn := filepath.Join(dir, "objimgtest.png")
491 if err = ioutil.WriteFile(tmpfn, imgbuf.Bytes(), 0666); err != nil {
492 t.Errorf("failed to create temp file for testing, file: %v, error: %v", tmpfn, err)
493 }
494
495 buf := bytes.NewBuffer([]byte{})
496 tmpl, err := template.New("test").Parse(testTMXtmpl)
497 if err != nil {
498 t.Error("Error parsing tmx template")
499 }
500 err = tmpl.Execute(buf, tmxData{
501 Orientation: "orthogonal",
502 RenderOrder: "right-up",
503 ObjectImageTest: true,
504 ChunkData: true,
505 })
506 if err != nil {
507 t.Error("Error executing tmx template")
508 }
509
510 engo.Files.Unload("objimgtest.png")
511 err = engo.Files.LoadReaderData("test.tmx", buf)
512 if err != nil {
513 t.Errorf("Unable to load test image from file while loading object image. Error: %v", err)
514 }
515}
516
517func TestTMXBadObjectImageNotExist(t *testing.T) {
518 buf := bytes.NewBuffer([]byte{})

Callers

nothing calls this directly

Calls 6

BytesMethod · 0.80
LoadReaderDataMethod · 0.80
SetRootMethod · 0.65
UnloadMethod · 0.65
NewMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected