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

Function TestTMXTileNotLoadedTempFile

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

Source from the content-addressed store, hash-verified

179}
180
181func TestTMXTileNotLoadedTempFile(t *testing.T) {
182 imgbuf := bytes.NewBuffer([]byte{})
183 img := image.NewRGBA(image.Rect(0, 0, 132, 99))
184 err := png.Encode(imgbuf, img)
185 if err != nil {
186 t.Errorf("Unable to encode png from image")
187 }
188
189 dir, err := ioutil.TempDir(".", "testing")
190 if err != nil {
191 t.Errorf("failed to create temp directory for testing, error: %v", err)
192 }
193 defer os.RemoveAll(dir)
194
195 engo.Files.SetRoot(dir)
196
197 tmpfn := filepath.Join(dir, "test.png")
198 if err = ioutil.WriteFile(tmpfn, imgbuf.Bytes(), 0666); err != nil {
199 t.Errorf("failed to create temp file for testing, file: %v, error: %v", tmpfn, err)
200 }
201
202 buf := bytes.NewBuffer([]byte{})
203 tmpl, err := template.New("test").Parse(testTMXtmpl)
204 if err != nil {
205 t.Error("Error parsing tmx template")
206 }
207 err = tmpl.Execute(buf, tmxData{
208 Orientation: "orthogonal",
209 RenderOrder: "right-down",
210 ChunkData: true,
211 })
212 if err != nil {
213 t.Error("Error executing tmx template")
214 }
215
216 engo.Files.Unload("test.png")
217 err = engo.Files.LoadReaderData("test.tmx", buf)
218 if err != nil {
219 t.Errorf("Unable to load test image from file while loading tmx. Error: %v", err)
220 }
221}
222
223func TestTMXTileNotLoadedTempFileBadExtensions(t *testing.T) {
224 imgbuf := 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