MCPcopy Create free account
hub / github.com/EngoEngine/ecs / TestAddRemove

Function TestAddRemove

system_test.go:100–122  ·  view source on GitHub ↗

TestAddRemove tests adding and removing entities in systems that don't implement SystemAddByInterfacer to the world.

(t *testing.T)

Source from the content-addressed store, hash-verified

98// TestAddRemove tests adding and removing entities in systems that don't implement
99// SystemAddByInterfacer to the world.
100func TestAddRemove(t *testing.T) {
101 w := &World{}
102 sys := SystemAddRemove{}
103 w.AddSystem(&sys)
104 ent := struct {
105 BasicEntity
106 PriorityComponent
107 }{
108 BasicEntity: NewBasic(),
109 }
110 w.AddEntity(ent)
111 if len(sys.entities) != 0 {
112 t.Error("Entity was added even though the system does not implement SystemAddByInterfacer")
113 }
114 sys.Add(ent.BasicEntity, &ent.PriorityComponent)
115 if len(sys.entities) != 1 {
116 t.Error("Failed to add entity to system")
117 }
118 w.RemoveEntity(ent.BasicEntity)
119 if len(sys.entities) != 0 {
120 t.Error("Removing the entity from the world did not remove it from the system.")
121 }
122}

Callers

nothing calls this directly

Calls 5

AddSystemMethod · 0.95
AddEntityMethod · 0.95
AddMethod · 0.95
RemoveEntityMethod · 0.95
NewBasicFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…