MCPcopy
hub / github.com/EngoEngine/engo / TestSceneSwitching

Function TestSceneSwitching

engo_test.go:267–298  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

265}
266
267func TestSceneSwitching(t *testing.T) {
268 RegisterScene(&testScene2{})
269 var buf bytes.Buffer
270 log.SetOutput(&buf)
271 Run(RunOptions{
272 NoRun: true,
273 HeadlessMode: true,
274 }, &testScene{})
275 SetSceneByName("testScene2", false)
276 if CurrentScene().Type() != "testScene2" {
277 t.Errorf("CurrentScene got wrong scene. was: %v, expected: %v", CurrentScene().Type(), "testScene2")
278 }
279 SetSceneByName("testScene", false)
280 expected := "Hiding testScene2.\n"
281 if !strings.HasSuffix(buf.String(), expected) {
282 t.Errorf("Did not properly set testScene1 and hide testScene2. was %v, expected: %v", buf.String(), expected)
283 }
284 buf.Reset()
285 SetSceneByName("testScene2", false)
286 expected = "Showing testScene2.\n"
287 if !strings.HasSuffix(buf.String(), expected) {
288 t.Errorf("Did not properly set and show testScene2. was: %v, expected: %v", buf.String(), expected)
289 }
290 err := SetSceneByName("doesNotExistScene", true)
291 if err == nil {
292 t.Error("No error when setting scene that doesn't exist.")
293 }
294 expected = "scene not registered:"
295 if !strings.HasPrefix(err.Error(), expected) {
296 t.Errorf("Did not recieve correct error for setting a scene that doesn't exist. was: %v, expected:%v", err.Error(), expected)
297 }
298}
299
300func TestUtils(t *testing.T) {
301 var buf bytes.Buffer

Callers

nothing calls this directly

Calls 6

RegisterSceneFunction · 0.85
RunFunction · 0.85
SetSceneByNameFunction · 0.85
CurrentSceneFunction · 0.85
TypeMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected