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

Function TestWorld_SortSystems

world_test.go:108–141  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

106func (s *priorityChangeSystem) Update(dt float32) {}
107
108func TestWorld_SortSystems(t *testing.T) {
109 w := new(World)
110 one := priorityChangeSystem{Rank: 1}
111 w.AddSystem(&one)
112 two := priorityChangeSystem{Rank: 2}
113 w.AddSystem(&two)
114 expected := []System{
115 &two,
116 &one,
117 }
118 for idx, sys := range w.Systems() {
119 p := sys.(Prioritizer)
120 exp := expected[idx].(Prioritizer)
121 if p.Priority() != exp.Priority() {
122 t.Error("Systems were not in the correct order")
123 }
124 }
125 one.Rank = 5
126 for idx, sys := range w.Systems() {
127 p := sys.(Prioritizer)
128 exp := expected[idx].(Prioritizer)
129 if p.Priority() != exp.Priority() {
130 t.Error("Systems were switched before sort wwas called")
131 }
132 }
133 w.SortSystems()
134 for idx, sys := range w.Systems() {
135 p := sys.(Prioritizer)
136 exp := expected[len(expected)-1-idx].(Prioritizer)
137 if p.Priority() != exp.Priority() {
138 t.Error("Systems were switched before sort wwas called")
139 }
140 }
141}

Callers

nothing calls this directly

Calls 4

AddSystemMethod · 0.80
SystemsMethod · 0.80
SortSystemsMethod · 0.80
PriorityMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…